index.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  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 placeholder="请描述您遇到的问题或意见" />
  14. </view>
  15. <view class="upload">
  16. <view class="img-list" v-for="(item, index) in form.imageFiles" :key="index">
  17. <uni-icons class="close" type="closeempty" color="#FFF" size="12" @click="getDelete(index)" />
  18. <image :src="item" />
  19. </view>
  20. <button v-if="form.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. return {
  38. // 表单
  39. form: {},
  40. // 单选
  41. active: 0,
  42. // 反馈类型
  43. typeOptions: []
  44. }
  45. },
  46. onLoad() {
  47. this.getList()
  48. const e = getApp().globalData.userInfo
  49. this.form = {
  50. appVersion: e.version,
  51. phone: e.phone,
  52. platformType: e.deviceType,
  53. systemVersion: e.systemVersion,
  54. imageFiles: [],
  55. type: '',
  56. content: ''
  57. }
  58. },
  59. methods: {
  60. // 反馈类型
  61. getList() {
  62. uni.showLoading({
  63. title: '加载中...',
  64. mask: true
  65. })
  66. list().then(res => {
  67. if (res.data.code === 0) {
  68. uni.hideLoading()
  69. this.typeOptions = res.data.data
  70. }
  71. })
  72. },
  73. // 单选
  74. radioChange(e) {
  75. this.typeOptions.map(i => {
  76. if (i.id === e.detail.value) {
  77. this.active = i.id
  78. this.form.type = i.id
  79. }
  80. })
  81. },
  82. // 上传
  83. upload() {
  84. // let count = 9 - this.form.imageFiles.length
  85. // uni.chooseImage({
  86. // count: count,
  87. // sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  88. // sourceType: ['album'], //从相册选择
  89. // success: (res) => {
  90. // res.tempFilePaths.map(i => {
  91. // this.form.imageFiles.push(i)
  92. // })
  93. // }
  94. // })
  95. selectImageCount.postMessage(`${this.form.imageFiles.length}`)
  96. selectImage.postMessage('获取相册信息')
  97. window['receiveImageAddress'] = res => {
  98. JSON.parse(res).addressList.map(i => {
  99. this.form.imageFiles.push(`blob:${window.location.origin}${i}`)
  100. })
  101. console.log(this.form.imageFiles);
  102. }
  103. },
  104. // 删除按钮
  105. getDelete(index) {
  106. this.form.imageFiles.splice(index, 1)
  107. },
  108. // 提交
  109. getSubmit() {
  110. if (this.form.type !== '' && this.form.content !== '') {
  111. uni.showLoading({
  112. title: '提交中...',
  113. mask: true
  114. })
  115. submit(this.form).then(res => {
  116. uni.hideLoading()
  117. if (res.data.code === 0) {
  118. uni.showToast({
  119. title: '提交成功!'
  120. })
  121. } else {
  122. uni.showToast({
  123. title: res.data.message,
  124. icon: 'error'
  125. })
  126. }
  127. })
  128. } else {
  129. uni.showToast({
  130. title: '请选择问题类型并且描述您遇到的问题或意见',
  131. icon: 'none',
  132. duration: 3000
  133. })
  134. }
  135. }
  136. }
  137. }
  138. </script>
  139. <style lang="scss">
  140. .app-container {
  141. background-color: #FFFFFF;
  142. color: #353535;
  143. }
  144. .radio-list {
  145. ::v-deep uni-radio .uni-radio-input {
  146. width: 24rpx;
  147. height: 24rpx;
  148. }
  149. label {
  150. display: inline-block;
  151. width: 25%;
  152. font-size: 24rpx;
  153. margin-top: 40rpx;
  154. }
  155. span {
  156. vertical-align: middle;
  157. }
  158. }
  159. .textarea {
  160. margin-top: 48rpx;
  161. textarea {
  162. border-radius: 8px;
  163. height: 240rpx;
  164. background-color: #FAFAFA;
  165. }
  166. }
  167. .upload {
  168. margin-top: 48rpx;
  169. display: flex;
  170. flex-wrap: wrap;
  171. align-content: start;
  172. height: calc(160rpx * 3 + 24rpx * 3);
  173. .img-list {
  174. position: relative;
  175. }
  176. uni-image {
  177. width: 160rpx;
  178. height: 160rpx;
  179. margin: 0 24rpx 24rpx 0;
  180. border-radius: 16rpx;
  181. }
  182. .close {
  183. width: 40rpx;
  184. height: 40rpx;
  185. line-height: 40rpx;
  186. text-align: center;
  187. border-radius: 50%;
  188. position: absolute;
  189. right: 28rpx;
  190. top: 4rpx;
  191. background-color: #888;
  192. z-index: 99;
  193. }
  194. button {
  195. width: 160rpx;
  196. height: 160rpx;
  197. line-height: 160rpx;
  198. margin: 0;
  199. background-color: #F0F7EE;
  200. border-radius: 16rpx;
  201. }
  202. }
  203. .submit {
  204. margin-top: 48rpx;
  205. button {
  206. width: 400rpx;
  207. height: 80rpx;
  208. line-height: 80rpx;
  209. }
  210. .contact {
  211. width: 100%;
  212. font-size: 24rpx;
  213. color: #999;
  214. display: flex;
  215. justify-content: space-around;
  216. margin-top: 190rpx;
  217. }
  218. }
  219. </style>