index.vue 4.7 KB

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