index.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  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" />
  18. <img :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(i)
  100. })
  101. }
  102. },
  103. // 提交
  104. getSubmit() {
  105. if (this.form.type !== '' && this.form.content !== '') {
  106. uni.showLoading({
  107. title: '提交中...',
  108. mask: true
  109. })
  110. submit(this.form).then(res => {
  111. uni.hideLoading()
  112. if (res.data.code === 0) {
  113. uni.showToast({
  114. title: '提交成功!'
  115. })
  116. } else {
  117. uni.showToast({
  118. title: res.data.message,
  119. icon: 'error'
  120. })
  121. }
  122. })
  123. } else {
  124. uni.showToast({
  125. title: '请选择问题类型并且描述您遇到的问题或意见',
  126. icon: 'none',
  127. duration: 3000
  128. })
  129. }
  130. }
  131. }
  132. }
  133. </script>
  134. <style lang="scss">
  135. .app-container {
  136. background-color: #FFFFFF;
  137. color: #353535;
  138. }
  139. .radio-list {
  140. ::v-deep uni-radio .uni-radio-input {
  141. width: 24rpx;
  142. height: 24rpx;
  143. }
  144. label {
  145. display: inline-block;
  146. width: 25%;
  147. font-size: 24rpx;
  148. margin-top: 40rpx;
  149. }
  150. span {
  151. vertical-align: middle;
  152. }
  153. }
  154. .textarea {
  155. margin-top: 48rpx;
  156. textarea {
  157. border-radius: 8px;
  158. height: 240rpx;
  159. background-color: #FAFAFA;
  160. }
  161. }
  162. .upload {
  163. margin-top: 48rpx;
  164. display: flex;
  165. flex-wrap: wrap;
  166. align-content: start;
  167. height: calc(160rpx * 3 + 24rpx * 3);
  168. .img-list {
  169. position: relative;
  170. }
  171. img {
  172. width: 160rpx;
  173. height: 160rpx;
  174. margin: 0 24rpx 24rpx 0;
  175. border-radius: 16rpx;
  176. }
  177. .close {
  178. width: 40rpx;
  179. height: 40rpx;
  180. line-height: 40rpx;
  181. text-align: center;
  182. border-radius: 50%;
  183. position: absolute;
  184. right: 28rpx;
  185. top: 4rpx;
  186. background-color: #888;
  187. }
  188. button {
  189. width: 160rpx;
  190. height: 160rpx;
  191. line-height: 160rpx;
  192. margin: 0;
  193. background-color: #F0F7EE;
  194. border-radius: 16rpx;
  195. }
  196. }
  197. .submit {
  198. margin-top: 48rpx;
  199. button {
  200. width: 400rpx;
  201. height: 80rpx;
  202. line-height: 80rpx;
  203. }
  204. .contact {
  205. width: 100%;
  206. font-size: 24rpx;
  207. color: #999;
  208. display: flex;
  209. justify-content: space-around;
  210. margin-top: 190rpx;
  211. }
  212. }
  213. </style>