index.vue 4.9 KB

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