index.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. <template>
  2. <view class="app-container">
  3. <view class="list">
  4. <view class="item margin-bottom">
  5. <h3>问题类型</h3>
  6. </view>
  7. <view class="item">
  8. <radio-group @change="radioChange">
  9. <label v-for="item in typeOptions" :key="item.id">
  10. <radio :value="item.id.toString()" color="#A4D099" :checked="item.id == active"
  11. style="transform: scale(0.7); margin: -7rpx;" />
  12. <span>{{ item.name }}</span>
  13. </label>
  14. </radio-group>
  15. </view>
  16. <view class="item margin-bottom">
  17. <textarea v-model="form.content" maxlength="200" placeholder="请描述您遇到的问题或意见" />
  18. </view>
  19. <view class="item upload margin-bottom">
  20. <view class="img-list" v-for="(item, index) in imageFiles" :key="index">
  21. <uni-icons class="close" type="closeempty" color="#FFF" size="12" @click="getDelete(index)" />
  22. <img :src="item" />
  23. </view>
  24. <button v-if="imageFiles.length < 9" @click="upload">
  25. <uni-icons type="plusempty" color="#A4D099" size="36" />
  26. </button>
  27. </view>
  28. </view>
  29. <view class="submit">
  30. <button type="submit" circle @click="getSubmit">提交</button>
  31. <view class="contact">
  32. <span>客服微信:miao_friend</span>
  33. <span>客服电话:4008508199</span>
  34. </view>
  35. </view>
  36. </view>
  37. </template>
  38. <script>
  39. import { list, submit } from '@/api/help.js'
  40. export default {
  41. data() {
  42. const info = getApp().globalData.userInfo
  43. return {
  44. // 表单
  45. form: {
  46. appVersion: info.version,
  47. phone: info.phone,
  48. platformType: info.deviceType,
  49. systemVersion: info.systemVersion,
  50. imageFiles: '',
  51. type: '',
  52. content: ''
  53. },
  54. // 图片列表
  55. imageFiles: [],
  56. length: 0,
  57. // 单选
  58. active: 0,
  59. // 反馈类型
  60. typeOptions: []
  61. }
  62. },
  63. onLoad() {
  64. this.getList()
  65. },
  66. methods: {
  67. // 反馈类型
  68. getList() {
  69. list().then(res => {
  70. if (res.data.code === 0) {
  71. this.typeOptions = res.data.data
  72. }
  73. })
  74. },
  75. // 单选
  76. radioChange(e) {
  77. this.active = e.detail.value
  78. this.form.type = e.detail.value
  79. },
  80. // 上传
  81. upload() {
  82. selectImageCount.postMessage(this.length)
  83. selectImage.postMessage('获取相册信息')
  84. window['receiveImageAddress'] = e => {
  85. JSON.parse(e).addressList.map(i => {
  86. this.imageFiles.push(i)
  87. })
  88. this.length = this.imageFiles.length
  89. }
  90. },
  91. // 删除按钮
  92. getDelete(index) {
  93. this.imageFiles.splice(index, 1)
  94. this.length = this.imageFiles.length
  95. },
  96. // 提交
  97. getSubmit() {
  98. if (this.form.type !== '' && this.form.content !== '') {
  99. this.form.imageFiles = this.imageFiles.join(',')
  100. submit(this.form).then(res => {
  101. if (res.data.code === 0) {
  102. uni.showToast({
  103. title: '提交成功!'
  104. })
  105. this.form.imageFiles = ''
  106. this.form.type = ''
  107. this.active = 0
  108. this.form.content = ''
  109. this.imageFiles = []
  110. } else {
  111. uni.showToast({
  112. title: res.data.message,
  113. icon: 'error'
  114. })
  115. }
  116. })
  117. } else {
  118. uni.showToast({
  119. title: '请选择问题类型并且描述您遇到的问题或意见',
  120. icon: 'none',
  121. duration: 3000
  122. })
  123. }
  124. }
  125. }
  126. }
  127. </script>
  128. <style lang="scss" scoped>
  129. .app-container {
  130. background-color: #FFF;
  131. color: #353535;
  132. display: flex;
  133. flex-flow: column nowrap;
  134. min-height: 100vh;
  135. .list {
  136. flex: 1;
  137. .item {
  138. uni-radio-group {
  139. display: flex;
  140. flex-wrap: wrap;
  141. label {
  142. width: calc(25% - 10px);
  143. font-size: 24rpx;
  144. display: flex;
  145. align-items: flex-start;
  146. margin: 0 10px 20px 0;
  147. }
  148. span {
  149. word-break: break-all;
  150. }
  151. }
  152. textarea {
  153. border-radius: 8px;
  154. height: 240rpx;
  155. background-color: #FAFAFA;
  156. }
  157. }
  158. .upload {
  159. display: flex;
  160. flex-wrap: wrap;
  161. gap: 12px;
  162. .img-list {
  163. display: flex;
  164. position: relative;
  165. .close {
  166. width: 40rpx;
  167. height: 40rpx;
  168. line-height: 40rpx;
  169. border-radius: 50%;
  170. position: absolute;
  171. right: 0rpx;
  172. top: 0rpx;
  173. background-color: #888;
  174. }
  175. img {
  176. width: 80px;
  177. height: 80px;
  178. border-radius: 16rpx;
  179. }
  180. }
  181. button {
  182. width: 80px;
  183. height: 80px;
  184. display: flex;
  185. align-items: center;
  186. justify-content: center;
  187. margin: 0;
  188. background-color: #F0F7EE;
  189. border-radius: 16rpx;
  190. }
  191. }
  192. }
  193. .submit {
  194. width: 100%;
  195. margin-top: 100px;
  196. button {
  197. width: 400rpx;
  198. height: 80rpx;
  199. display: flex;
  200. align-items: center;
  201. justify-content: center;
  202. }
  203. .contact {
  204. width: 100%;
  205. font-size: 24rpx;
  206. color: #999;
  207. display: flex;
  208. justify-content: space-around;
  209. margin-top: 95rpx;
  210. }
  211. }
  212. }
  213. .margin-bottom {
  214. margin-bottom: 20px;
  215. }
  216. </style>