feedback.vue 5.0 KB

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