feedback.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. <template>
  2. <view>
  3. <uni-nav-bar id="nav-bar" status-bar="true" @clickLeft="onBack" :title="pageTitle" color="#000000" fixed="true"
  4. :border="false">
  5. <view slot="left">
  6. <view class=" flex align-center margin-left">
  7. <image class="p-left-arrow" src="../../../static/p-left-arrow.png"></image>
  8. </view>
  9. </view>
  10. </uni-nav-bar>
  11. <form @submit="onUploadFeedback" class="padding flex flex-direction">
  12. <textarea name="problemDescription" :maxlength='500' class="feedback-textarea" placeholder="请输入你要反馈的问题"
  13. placeholder-class="feedback-placeholder"></textarea>
  14. <view style="height: 20px;"></view>
  15. <view class="feedback-upload-image">
  16. <view class="cu-bar" style="color: #BEBEBE; font-size: 14px;">
  17. <view class="action">
  18. 请提供问题的截图或照片
  19. </view>
  20. <view class="action">
  21. {{imgList.length}}/4
  22. </view>
  23. </view>
  24. <view style="height: 1px; background-color: #dadada; margin: 0px 15px 15px;"></view>
  25. <view class="cu-form-group" style="background-color: #F6F6F6;">
  26. <view class="grid col-4 grid-square flex-sub">
  27. <view class="bg-img" v-for="(item,index) in imgList" :key="index" @tap="ViewImage" :data-url="imgList[index]">
  28. <image :src="imgList[index]" mode="aspectFill"></image>
  29. <view class="cu-tag bg-red" @tap.stop="DelImg" :data-index="index">
  30. <text class='cuIcon-close'></text>
  31. </view>
  32. </view>
  33. <view class="solids" style="background-color: #EEEEEE; border-radius: 15rpx;" @tap="ChooseImage" v-if="imgList.length<4">
  34. <text class='cuIcon-cameraadd'></text>
  35. </view>
  36. </view>
  37. </view>
  38. </view>
  39. <view class="cu-form-group margin-top radius" style="background-color: #F6F6F6;">
  40. <view class="feedback-title">用户名</view>
  41. <input name="userName" style=" text-align: right;" placeholder="请输入用户名" placeholder-class="feedback-placeholder"
  42. :value="userName"></input>
  43. </view>
  44. <view class="cu-form-group margin-top radius" style="background-color: #F6F6F6;">
  45. <view class="feedback-title">联系方式</view>
  46. <input name="phoneNumber" type="number" style="text-align: right;" placeholder="请输入手机号" placeholder-class="feedback-placeholder"
  47. :value="phoneNumber"></input>
  48. </view>
  49. <view class="flex flex-direction margin-top">
  50. <button form-type="submit" class="cu-btn make-bg-bPurple margin-tb-sm lg text-white">提交</button>
  51. </view>
  52. <input v-show="false" name="versionName" :value="version"></input>
  53. <input v-show="false" name="versionCode" :value="versionCode"></input>
  54. </form>
  55. </view>
  56. </template>
  57. <script>
  58. import reqUtil from '@/util/util-js/requstUtil.js';
  59. import config from '@/common/config.js';
  60. import {
  61. mapState
  62. } from 'vuex';
  63. export default {
  64. computed: mapState(['userName', 'phoneNumber', 'version', 'versionCode']),
  65. data() {
  66. return {
  67. pageTitle: '意见反馈',
  68. imgList: []
  69. }
  70. },
  71. methods: {
  72. onBack() {
  73. uni.navigateBack({
  74. delta: 1
  75. })
  76. },
  77. ChooseImage() {
  78. uni.chooseImage({
  79. count: 4, //默认9
  80. sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  81. sourceType: ['album'], //从相册选择
  82. success: (res) => {
  83. if (this.imgList.length != 0) {
  84. this.imgList = this.imgList.concat(res.tempFilePaths)
  85. } else {
  86. this.imgList = res.tempFilePaths
  87. }
  88. }
  89. });
  90. },
  91. ViewImage(e) {
  92. uni.previewImage({
  93. urls: this.imgList,
  94. current: e.currentTarget.dataset.url
  95. });
  96. },
  97. DelImg(e) {
  98. uni.showModal({
  99. title: '删除照片',
  100. content: '确定要删除这张照片吗?',
  101. cancelText: '不是',
  102. confirmColor: '#ff0004',
  103. confirmText: '是',
  104. success: res => {
  105. if (res.confirm) {
  106. this.imgList.splice(e.currentTarget.dataset.index, 1)
  107. }
  108. }
  109. })
  110. },
  111. onUploadFeedback(e) {
  112. console.log(e.detail.value, this.imgList);
  113. if(e.detail.value.problemDescription.length <= 10){
  114. uni.showModal({
  115. title:'提示',
  116. content: "请填写不少于10个字的问题内容!",
  117. showCancel: false
  118. });
  119. return;
  120. }
  121. if(this.imgList.length == 0){
  122. uni.showModal({
  123. title:'提示',
  124. content: "至少选择一张反馈问题的截图照片!",
  125. showCancel: false
  126. });
  127. return;
  128. }
  129. uni.showLoading({
  130. title: '上传中...',
  131. mask: true
  132. });
  133. let files = this.imgList.map((value, index) => {
  134. return {
  135. name: 'images' + index,
  136. uri: value
  137. };
  138. });
  139. console.log("files:",files);
  140. reqUtil.reqUploadFiles(config.URL.UPLOADFEEDBACK, e.detail.value, files)
  141. .then(res => {
  142. uni.hideLoading();
  143. this.imgList = [];
  144. console.log(res)
  145. if(res.code ==0){
  146. uni.showModal({
  147. content: '成功',
  148. showCancel: false
  149. });
  150. }else{
  151. uni.showModal({
  152. title:'上传失败',
  153. content: res.msg,
  154. showCancel: false
  155. });
  156. }
  157. }, e => {
  158. console.log(e);
  159. uni.hideLoading();
  160. });
  161. }
  162. }
  163. }
  164. </script>
  165. <style>
  166. page {
  167. background-color: #FFFFFF;
  168. }
  169. .feedback-textarea {
  170. /* border: solid 1px red; */
  171. background-color: #F6F6F6;
  172. width: 100%;
  173. border-radius: 20rpx;
  174. padding: 50rpx;
  175. }
  176. .feedback-placeholder {
  177. color: #BEBEBE;
  178. font-size: 14px;
  179. }
  180. .feedback-upload-image {
  181. background-color: #F6F6F6;
  182. width: 100%;
  183. border-radius: 20rpx;
  184. padding: 20rpx;
  185. }
  186. .feedback-title {
  187. font-size: 14px;
  188. color: #7B7B7B;
  189. }
  190. </style>