feedback.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362
  1. <template>
  2. <view class="page">
  3. <!-- <PageHeader title="意见与反馈" class="PageHeader">
  4. <template slot="center"> </template>
  5. </PageHeader> -->
  6. <view class="feedback-container">
  7. <!-- 举报内容 -->
  8. <view class="report-content scale-tap" v-if="isReportContent" @click="openReportSheet">
  9. <view class="report-title">
  10. 举报内容
  11. </view>
  12. <view>
  13. <text v-if="selectedReportIndex !== null" style="color:#1f1f1f;margin-left:16rpx;">
  14. {{ reportItems[selectedReportIndex].text }}
  15. </text>
  16. <image class="arrow" src="../../static/me/arrow_right_gray.png" mode="widthFix"></image>
  17. </view>
  18. </view>
  19. <!-- 问题描述区域 -->
  20. <view class="description-area">
  21. <view class="title">问题描述</view>
  22. <textarea class="input-area" v-model="content" placeholder="请尽可能详细地描述您的反馈或问题" :maxlength="200"
  23. show-count></textarea>
  24. <view class="word-count">{{ content.length }}/200</view>
  25. </view>
  26. <!-- 图片上传区域 -->
  27. <view class="upload-area">
  28. <view class="title">上传图片 <text class="subtitle">(最多5张,可选)</text></view>
  29. <view class="tips">* 上传问题截图更好的帮助我们快速定位您反馈的问题</view>
  30. <view class="tips" style="margin-bottom: 20rpx;">* 需要您授权相册权限</view>
  31. <view class="image-list">
  32. <view class="image-item" v-for="(item, index) in imgList" :key="index">
  33. <image class="preview" :src="item" mode="aspectFill"></image>
  34. <view class="delete-btn" @tap="deleteImage(index)">
  35. <text class="fa fa-times"></text>
  36. </view>
  37. </view>
  38. <view class="upload-btn" @tap="upload" v-if="imgList.length < 5">
  39. <text class="fa fa-plus"></text>
  40. </view>
  41. </view>
  42. </view>
  43. <!-- 提交按钮 -->
  44. <view class="submit-btn" @tap="submitFeedback">
  45. 确认提交
  46. </view>
  47. </view>
  48. <ActionSheet
  49. ref="actionSheet"
  50. :title="'举报内容'"
  51. :items="reportItems"
  52. @select="onReportSelect"
  53. />
  54. </view>
  55. </template>
  56. <script>
  57. import ActionSheet from '@/components/dropDownSelection/ActionSheet.vue';
  58. export default {
  59. components: {
  60. ActionSheet
  61. },
  62. data() {
  63. return {
  64. content: '',
  65. imgList: [],
  66. skey: getApp().globalData.skey || '',
  67. reportItems: [
  68. { text: '售后问题' },
  69. { text: '其他问题' }
  70. ],
  71. selectedReportIndex: null,
  72. isReportContent:false
  73. }
  74. },
  75. onLoad(e) {
  76. if (e&&e.isReportContent) {
  77. this.isReportContent = e.isReportContent === 'true'?true:false;
  78. }
  79. },
  80. methods: {
  81. openReportSheet() {
  82. this.$refs.actionSheet.show();
  83. },
  84. onReportSelect(index, item) {
  85. this.selectedReportIndex = index;
  86. console.log('选择的标签',index,item,item.text);
  87. },
  88. // 上传图片
  89. upload() {
  90. if (this.imgList.length >= 5) {
  91. uni.showToast({
  92. title: '最多只能上传5张图片',
  93. icon: 'none'
  94. });
  95. return;
  96. }
  97. let that = this;
  98. uni.chooseImage({
  99. count: 5 - this.imgList.length,
  100. sizeType: ['compressed'],
  101. sourceType: ['album', 'camera'],
  102. success: function (res) {
  103. let tempFilePaths = [];
  104. // #ifdef H5
  105. res.tempFiles.forEach(file => {
  106. tempFilePaths.push(file.path);
  107. });
  108. // #endif
  109. // #ifdef APP-PLUS || MP
  110. tempFilePaths = res.tempFilePaths;
  111. // #endif
  112. for (let i = 0; i < tempFilePaths.length; i++) {
  113. const uploadTask = uni.uploadFile({
  114. url: that.$apiHost + '/Xweb/upload_img?skey=' + that.skey,
  115. filePath: tempFilePaths[i],
  116. name: 'file',
  117. success: function (uploadFileRes) {
  118. let resdata = JSON.parse(uploadFileRes.data);
  119. if (resdata.success == 'yes') {
  120. that.imgList.push(resdata.url);
  121. } else {
  122. uni.showToast({
  123. title: resdata.str || '上传失败',
  124. icon: 'none'
  125. });
  126. }
  127. },
  128. fail: function (err) {
  129. console.error('上传失败:', err);
  130. uni.showToast({
  131. title: '图片上传失败',
  132. icon: 'none'
  133. });
  134. }
  135. });
  136. }
  137. }
  138. });
  139. },
  140. // 删除图片
  141. deleteImage(index) {
  142. this.imgList.splice(index, 1);
  143. },
  144. // 提交反馈
  145. submitFeedback() {
  146. if (!this.content.trim()) {
  147. uni.showToast({
  148. title: '请输入问题描述',
  149. icon: 'none'
  150. });
  151. return;
  152. }
  153. let imgStr = this.imgList.join('|');
  154. uni.request({
  155. url: this.$apiHost + '/Member/feedback',
  156. method: 'POST',
  157. data: {
  158. uuid: getApp().globalData.uuid,
  159. content: this.content,
  160. image: imgStr
  161. },
  162. header: {
  163. 'Content-Type': 'application/x-www-form-urlencoded',
  164. 'sign': getApp().globalData.headerSign,
  165. uuid: getApp().globalData.uuid,
  166. },
  167. success: (res) => {
  168. if (res.data.success === 'yes') {
  169. uni.showToast({
  170. title: '反馈成功!我们将尽快处理',
  171. icon: 'none'
  172. });
  173. setTimeout(() => {
  174. uni.navigateBack();
  175. }, 1500);
  176. } else {
  177. uni.showToast({
  178. title: res.data.str || '提交失败',
  179. icon: 'none'
  180. });
  181. }
  182. },
  183. fail: (err) => {
  184. console.error('提交失败:', err);
  185. uni.showToast({
  186. title: '网络错误,请稍后重试',
  187. icon: 'none'
  188. });
  189. }
  190. });
  191. }
  192. }
  193. }
  194. </script>
  195. <style lang="scss">
  196. .page {
  197. min-height: 100vh;
  198. background-color: #f8f8f8;
  199. padding-bottom: env(safe-area-inset-bottom);
  200. }
  201. .feedback-container {
  202. padding: 30rpx;
  203. .report-content{
  204. display: flex;
  205. padding: 26rpx 40rpx 22rpx 24rpx;
  206. background: #fff;
  207. border-radius: 20rpx;
  208. margin-bottom: 20rpx;
  209. display: flex;
  210. align-items: center;
  211. justify-content: space-between;
  212. font-size: 32rpx;
  213. color: #333;
  214. margin-bottom: 20rpx;
  215. image{
  216. width: 28rpx;
  217. height: 28rpx;
  218. }
  219. }
  220. .description-area {
  221. background: #fff;
  222. border-radius: 16rpx;
  223. padding: 24rpx;
  224. margin-bottom: 30rpx;
  225. position: relative;
  226. .title {
  227. font-size: 32rpx;
  228. color: #333;
  229. margin-bottom: 20rpx;
  230. }
  231. .input-area {
  232. width: 100%;
  233. height: 300rpx;
  234. font-size: 28rpx;
  235. line-height: 1.6;
  236. padding: 20rpx;
  237. background: #f8f8f8;
  238. border-radius: 12rpx;
  239. }
  240. .word-count {
  241. position: absolute;
  242. right: 44rpx;
  243. bottom: 44rpx;
  244. font-size: 24rpx;
  245. color: #999;
  246. }
  247. }
  248. .upload-area {
  249. background: #fff;
  250. border-radius: 16rpx;
  251. padding: 24rpx;
  252. margin-bottom: 30rpx;
  253. .title {
  254. font-size: 32rpx;
  255. color: #333;
  256. margin-bottom: 20rpx;
  257. .subtitle {
  258. font-size: 24rpx;
  259. color: #999;
  260. }
  261. }
  262. .image-list {
  263. display: flex;
  264. flex-wrap: wrap;
  265. gap: 16rpx;
  266. margin-bottom: 20rpx;
  267. .image-item {
  268. width: 200rpx;
  269. height: 200rpx;
  270. position: relative;
  271. .preview {
  272. width: 100%;
  273. height: 100%;
  274. border-radius: 12rpx;
  275. }
  276. .delete-btn {
  277. position: absolute;
  278. top: -16rpx;
  279. right: -16rpx;
  280. width: 40rpx;
  281. height: 40rpx;
  282. background: rgba(0, 0, 0, 0.5);
  283. border-radius: 50%;
  284. display: flex;
  285. align-items: center;
  286. justify-content: center;
  287. .fa {
  288. color: #fff;
  289. font-size: 24rpx;
  290. }
  291. }
  292. }
  293. .upload-btn {
  294. width: 200rpx;
  295. height: 200rpx;
  296. background: #f8f8f8;
  297. border-radius: 12rpx;
  298. display: flex;
  299. align-items: center;
  300. justify-content: center;
  301. .fa {
  302. font-size: 48rpx;
  303. color: #999;
  304. }
  305. }
  306. }
  307. .tips {
  308. font-size: 24rpx;
  309. color: #999;
  310. line-height: 1.6;
  311. }
  312. }
  313. .submit-btn {
  314. width: 100%;
  315. height: 88rpx;
  316. background: #000;
  317. border-radius: 44rpx;
  318. color: #fff;
  319. font-size: 32rpx;
  320. display: flex;
  321. align-items: center;
  322. justify-content: center;
  323. margin-top: 60rpx;
  324. &:active {
  325. opacity: 0.9;
  326. }
  327. }
  328. }
  329. </style>