feedback.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. <template>
  2. <view class="feedback">
  3. <view v-show="initFinish" class="fb-container" :style="{ paddingTop: navBarHeight + 'px' }">
  4. <view class="fb-navigation">
  5. <uni-icons type="left" color="#101333" size="48rpx" @tap="navigatorBack"></uni-icons>
  6. <view class="navigation-title" @tap="navigatorBack">意见反馈</view>
  7. </view>
  8. <view class="fb-content">
  9. <view class="fb-title">我要反馈</view>
  10. <view class="fb-textarea-box">
  11. <textarea v-model="formData.feedbackContent" class="fb-textarea" placeholder="请输入你想说的"></textarea>
  12. </view>
  13. <view style="display: none;" class="fb-title">联系方式</view>
  14. <view style="display: none;" class="fb-textarea-tel">
  15. <input v-model="formData.phone" class="fb-tel" type="tel" maxlength="20" />
  16. </view>
  17. </view>
  18. <button class="fb-button" @tap="submitFeedback">提交</button>
  19. </view>
  20. <uni-popup ref="replay" type="bottom" background-color="#ffffff" :mask-click="false"
  21. borderRadius="32rpx 32rpx 0 0">
  22. <view class="replay-content">
  23. <view class="replay-title">感谢您的反馈</view>
  24. <view class="replay-content">
  25. <ua-markdown ref="markdown" :source="replayMessage" />
  26. <view v-if="showLink" class="link" @click="copyLink">https://swt.sc.gov.cn/sccom/hdtzxx/hd_tzxx.shtml</view>
  27. </view>
  28. <button size="mini" class="replay-button" style="width: 100%;" @click="closeReplay">关闭</button>
  29. </view>
  30. </uni-popup>
  31. </view>
  32. </template>
  33. <script>
  34. import {
  35. RequestApi
  36. } from '../../api/requestApi';
  37. export default {
  38. data() {
  39. return {
  40. navBarHeight: 0,
  41. initFinish: false,
  42. loading: false,
  43. replayMessage: '',
  44. showLink: false,
  45. formData: {
  46. feedbackContent: '',
  47. phone: ''
  48. }
  49. };
  50. },
  51. mounted() {
  52. this.initPage();
  53. },
  54. methods: {
  55. initPage() {
  56. const menuButtonInfo = uni.getMenuButtonBoundingClientRect();
  57. this.navBarHeight = menuButtonInfo.top + 1;
  58. this.initFinish = true;
  59. },
  60. navigatorBack() {
  61. uni.navigateBack({
  62. fail: () => {
  63. uni.redirectTo({
  64. url: '/pages/index/index'
  65. });
  66. }
  67. });
  68. },
  69. submitFeedback() {
  70. if (this.loading) {
  71. return;
  72. }
  73. if (this.formData.feedbackContent.trim() == '') {
  74. uni.showToast({
  75. title: '反馈内容不能为空',
  76. icon: 'none'
  77. });
  78. return;
  79. }
  80. // if (this.formData.phone.trim() == '') {
  81. // uni.showToast({
  82. // title: '联系方式不能为空',
  83. // icon: 'none'
  84. // });
  85. // return;
  86. // }
  87. this.loading = true;
  88. uni.showLoading({
  89. title: '提交中'
  90. });
  91. RequestApi.sendFeedback(this.formData)
  92. .then((result) => {
  93. this.$refs.replay.open();
  94. this.formData = {
  95. feedbackContent: '',
  96. phone: ''
  97. };
  98. if (result.code == 1) { // 智能体有回答
  99. this.replayMessage = result.message
  100. } else if (result.code == 2) { // 与改进相关(写入数据库)
  101. this.replayMessage = '感谢您的宝贵建议!我们已收到您的反馈,感谢您的支持!';
  102. } else if (result.code == 3) { // 与改进相关
  103. this.showLink = true;
  104. this.replayMessage =
  105. '您好,感谢您的关注,关于您提到的内容,建议可到商务厅官方平台反馈以接收专业解答。反馈渠道:四川省商务厅网站首页-导航交流互动-厅长信箱栏目,或点击复制网址在浏览器中打开';
  106. }
  107. })
  108. .finally(() => {
  109. uni.hideLoading();
  110. this.loading = false;
  111. });
  112. },
  113. closeReplay() {
  114. this.showLink = false;
  115. this.$refs.replay.close();
  116. },
  117. copyLink() {
  118. uni.setClipboardData({
  119. data: 'https://swt.sc.gov.cn/sccom/hdtzxx/hd_tzxx.shtml',
  120. success: () => {
  121. uni.showToast({
  122. icon: 'none',
  123. title: '复制成功'
  124. })
  125. },
  126. fail: () => {
  127. uni.showToast({
  128. icon: 'none',
  129. title: '复制失败'
  130. })
  131. }
  132. })
  133. }
  134. }
  135. };
  136. </script>
  137. <style scoped lang="scss">
  138. @import '@/static/global.scss';
  139. .feedback {
  140. height: 100vh;
  141. position: relative;
  142. &::before {
  143. content: '';
  144. position: absolute;
  145. top: -180rpx;
  146. right: -80rpx;
  147. width: 68%;
  148. height: 70vh;
  149. background-color: #93bdfb;
  150. filter: blur(200rpx);
  151. z-index: -1;
  152. }
  153. .fb-container {
  154. padding: 32rpx;
  155. .fb-navigation {
  156. display: flex;
  157. align-items: center;
  158. .navigation-title {
  159. color: #101333;
  160. font-size: 32rpx;
  161. font-weight: 600;
  162. margin-right: 24rpx;
  163. }
  164. }
  165. .fb-content {
  166. padding-top: 32rpx;
  167. background-image: url(getImageUrl('/images/opinion-pencel.png'));
  168. background-repeat: no-repeat;
  169. background-position: right 20rpx;
  170. background-size: 260rpx auto;
  171. .fb-title {
  172. color: #101333;
  173. font-size: 32rpx;
  174. font-weight: 500;
  175. margin-bottom: 32rpx;
  176. }
  177. .fb-textarea-box {
  178. background: rgba(255, 255, 255, 0.4);
  179. padding: 24rpx;
  180. border: 2px solid #ffffff;
  181. border-radius: 8rpx 8rpx 8rpx 8rpx;
  182. border-image: linear-gradient(180deg, rgba(255, 255, 255, 1), rgba(208, 215, 247, 1)) 2 2;
  183. margin-bottom: 46rpx;
  184. .fb-textarea {
  185. width: calc(100% - 48rpx);
  186. }
  187. }
  188. .fb-textarea-tel {
  189. border: 2px solid #d0d7f7;
  190. padding: 24rpx;
  191. background: rgba(255, 255, 255, 0.4);
  192. margin-bottom: 120rpx;
  193. .fb-tel {}
  194. }
  195. }
  196. .fb-button {
  197. padding: 12rpx;
  198. color: #ffffff;
  199. background-color: #2943d6;
  200. font-size: 28rpx;
  201. font-weight: 500;
  202. }
  203. }
  204. .replay-content {
  205. padding: 32rpx;
  206. background-color: #ffffff;
  207. border-radius: 32rpx 32rpx 0 0;
  208. .replay-title {
  209. font-weight: bold;
  210. }
  211. .replay-content {
  212. margin: 32rpx 0;
  213. max-height: 60vh;
  214. overflow: hidden auto;
  215. .link {
  216. color: #2943d6;
  217. word-break: break-all;
  218. font-size: 24rpx;
  219. }
  220. }
  221. }
  222. }
  223. </style>