feedback.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. <template>
  2. <ax-body title="">
  3. <view class="page-background">
  4. <image src="@/static/img/my-bg.svg" mode="widthFix"></image>
  5. </view>
  6. <view class="body app-hide-scrollbar">
  7. <view class="top">
  8. <view class="app-flex-one">
  9. <view class="title">意见反馈</view>
  10. <view class="subtitle">感谢您的每一条建议或反馈~</view>
  11. </view>
  12. <view class="em" style="font-size: 14px;"
  13. @click="$app.url.goto('/pages/feedback-reply/feedback-reply')">查看反馈</view>
  14. </view>
  15. <view class="card form-type">
  16. <view class="lable required">请选择问题</view>
  17. <view class="content">
  18. <view v-for="(item, index) in types.data" :key="index" class="tag"
  19. :class="{ active: types.index == index }" @click="onTag(item, index)">{{ item.name }}</view>
  20. </view>
  21. </view>
  22. <view class="card form-describe">
  23. <view class="lable required">问题描述</view>
  24. <view class="content">
  25. <textarea placeholder="请输入描述内容" maxlength="500" v-model="saveObj.description"
  26. placeholder-class="app-placeholder" class="textarea"></textarea>
  27. </view>
  28. <view class="footer"><text>可输入字数</text><text>{{ saveObj.description.length }}/500</text></view>
  29. </view>
  30. <view class="card form-picture">
  31. <view class="lable">相关截图或图片</view>
  32. <view class="content">
  33. <view class="picture view" v-for="(item, index) in upFileUrls" :key="index">
  34. <view class="remove" @click="clearUpFile(item)"><text class="ax-iconblock i-cancel icon"></text>
  35. </view>
  36. <image :src="item.temUrl" class="image" mode="aspectFill"></image>
  37. </view>
  38. <view class="picture" v-if="upFileUrls.length < 4" @click="upFile()"><text
  39. class="ax-iconblock i-paizhao icon"></text><text class="name">点击上传</text></view>
  40. </view>
  41. <view class="footer"><text>上传问题截图可以让问题快速解决哦</text><text>{{ upFileUrls.length }}/4</text></view>
  42. </view>
  43. <view class="card form-contact">
  44. <view class="lable">联系方式</view>
  45. <view class="content">
  46. <input placeholder="手机号或邮箱以便我们回复您" v-model="saveObj.contactWay" placeholder-class="app-placeholder"
  47. class="input" />
  48. </view>
  49. </view>
  50. <view class="tips">咨询问题可以联系<text class="em">在线客服</text>哦</view>
  51. <button class="submit" @click="saveFeeback()">确认提交</button>
  52. </view>
  53. </ax-body>
  54. </template>
  55. <script>
  56. export default {
  57. data() {
  58. return {
  59. types: {
  60. index: -1,
  61. data: [{ name: '投诉吐槽', value: 1 }, { name: '功能异常', value: 2 }, { name: '体验问题', value: 3 }, { name: '功能建议', value: 4 }, { name: '其他', value: 9 }]
  62. },
  63. upFileUrls: [],//上传的图片地址
  64. saveObj: {
  65. type: 9,//问题类型(1投诉吐槽,2功能异常,3体验问题,4功能建议,9其他 )
  66. description: "",//问题描述
  67. images: "",//相关图片地址
  68. contactWay: "",//联系方式(手机号或者邮箱)
  69. }
  70. }
  71. },
  72. methods: {
  73. onTag(item, index) {
  74. this.types.index = this.types.index == index ? -1 : index;
  75. this.saveObj.type = this.types.data[this.types.index].value;
  76. },
  77. //删除上传的图片
  78. clearUpFile(item) {
  79. this.upFileUrls = this.upFileUrls.filter(obj => obj.temUrl != item.temUrl);
  80. },
  81. //上次图片
  82. upFile() {
  83. var _this = this;
  84. uni.chooseImage({
  85. count: 6, //默认9
  86. sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  87. sourceType: ['album'], //从相册选择
  88. success: function (res) {
  89. console.log(JSON.stringify(res.tempFilePaths));
  90. uni.uploadFile({
  91. url: _this.$config.url.request + "api/v1/files",
  92. filePath: res.tempFilePaths[0],
  93. name: 'file',
  94. header: {
  95. 'Authorization': "Bearer " + _this.$app.storage.get("ACCESS_TOKEN"),
  96. 'Content-Type': 'multipart/form-data'
  97. },
  98. success: (uploadFileRes) => {
  99. var imgUrl = JSON.parse(uploadFileRes.data);
  100. var tem = {
  101. temUrl: res.tempFilePaths[0],
  102. url: imgUrl.data.url
  103. }
  104. _this.upFileUrls.push(tem);
  105. _this.saveObj.images = _this.upFileUrls.map(item => item.url).join(',');
  106. }
  107. });
  108. }
  109. });
  110. },
  111. //保存意见反馈
  112. saveFeeback() {
  113. if (this.types.index == -1) {
  114. this.$app.popup.alert("请选择一个问题。", "温馨提示");
  115. return;
  116. }
  117. if (!this.saveObj.description) {
  118. this.$app.popup.alert("请填写您意见或建议。", "温馨提示");
  119. return;
  120. }
  121. if (this.saveObj.description.length > 500) {
  122. this.$app.popup.alert("问题描述只能填写500字以内。", "温馨提示");
  123. return;
  124. }
  125. var obj = this.saveObj;
  126. this.$api.base("post", "/applet/v1/user/addUserFeedback", obj, {}).then(res => {
  127. this.$app.popup.confirm("感谢您的反馈。", "温馨提示", { showCancel: false }).then(cRes => {
  128. this.$app.url.back()
  129. })
  130. })
  131. }
  132. }
  133. }
  134. </script>
  135. <style scoped>
  136. @import url("feedback");
  137. </style>