complaint.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. <template>
  2. <view>
  3. <uni-nav-bar :fixed="true" shadow left-icon="left" title="意见反馈" :statusBar="true" @clickLeft="handleToBack" />
  4. <view class="content">
  5. <view style="padding: 42upx">
  6. <view class="title_wrap">
  7. <text class="title_prefix">*</text>问题类型</view
  8. >
  9. <view class="content_wrap" @tap="handleOpenPopup"
  10. ><text> {{ items[current]?.name || "请选择问题" }}</text>
  11. <image
  12. class="card_thumbnail"
  13. src="/static/common/right.png"
  14. mode="aspectFill"
  15. style="width: 14upx; height: 24upx"
  16. />
  17. </view>
  18. <view class="title_wrap">
  19. <text class="title_prefix">*</text>问题详情</view
  20. >
  21. <view class="content_wrap" style="height: auto; flex-direction: column">
  22. <textarea
  23. auto-height
  24. :maxlength="100"
  25. placeholder="请描述您遇到的相关问题或功能建议,请上传手机截图,我们将为您不断改进。"
  26. style="
  27. min-height: 150upx;
  28. font-size: 24upx;
  29. font-weight: 400;
  30. color: #999999;
  31. "
  32. v-model="params.idea"
  33. />
  34. <view style="width: 100%; display: flex; justify-content: flex-end"
  35. >{{ params.idea.length }}/100</view
  36. >
  37. </view>
  38. <!-- <view class="title_wrap">
  39. 截图或图片<text class="title_suffix">(最多上传3张)</text></view
  40. > -->
  41. </view>
  42. <view class="footer">
  43. <image mode="widthFix" src="/static/images/footer.png" />
  44. </view>
  45. <view class="footer_btn_wrap flex align-center" style="position: fixed">
  46. <view class="footer_btn" @tap="handleSubmit"> 提交 </view>
  47. </view>
  48. <uni-popup ref="popup" background-color="#fff">
  49. <view class="uni-list">
  50. <radio-group @change="handleRadioChange" style="padding: 20upx">
  51. <label
  52. class="flex align-center justify-between"
  53. style="padding-left: 40upx"
  54. v-for="(item, index) in items"
  55. :key="index"
  56. >
  57. <view>{{ item.name }}</view>
  58. <view>
  59. <radio
  60. :value="`${index}`"
  61. :checked="index == current"
  62. style="margin: 20upx"
  63. />
  64. </view>
  65. </label>
  66. </radio-group>
  67. </view>
  68. </uni-popup>
  69. </view>
  70. </view>
  71. </template>
  72. <script setup>
  73. import { ref, reactive } from "vue";
  74. import { onLoad, onShow } from "@dcloudio/uni-app";
  75. import request from "/common/request.js";
  76. import auth from "/common/auth.js";
  77. const statusBarHeight = ref();
  78. onLoad((option) => {
  79. statusBarHeight.value = uni.getSystemInfoSync().statusBarHeight;
  80. });
  81. onShow(() => {
  82. auth();
  83. uni.$emit('fastOrderNum', false);
  84. uni.$emit('receiveOrdernum', false);
  85. });
  86. const params = reactive({
  87. idea: "",
  88. });
  89. const current = ref(0);
  90. const items = reactive([
  91. { value: "1", name: "订单问题" },
  92. { value: "2", name: "功能问题" },
  93. { value: "3", name: "账号问题" },
  94. { value: "4", name: "操作问题" },
  95. { value: "5", name: "BUG反馈" },
  96. { value: "6", name: "其他" },
  97. ]);
  98. const popup = ref();
  99. const handleToBack = () => {
  100. const canNavBack = getCurrentPages();
  101. if (canNavBack && canNavBack.length > 1) uni.navigateBack();
  102. else history.back();
  103. };
  104. const handleSubmit = () => {
  105. if (!params.idea.trim()) {
  106. uni.showToast({
  107. title: "请填写意见",
  108. duration: 2000,
  109. icon: "none",
  110. });
  111. return;
  112. }
  113. uni.showLoading();
  114. request({
  115. url: "/api/user/addIdea",
  116. method: "POST",
  117. data: {
  118. ...params,
  119. type: items[current.value].value,
  120. },
  121. success: (res) => {
  122. console.log("投诉建议", res);
  123. uni.hideLoading();
  124. uni.showToast({
  125. title: res.data?.msg,
  126. duration: 2000,
  127. icon: "none",
  128. });
  129. if (res.data.code == 1) {
  130. setTimeout(function () {
  131. const canNavBack = getCurrentPages();
  132. if (canNavBack && canNavBack.length > 1) {
  133. uni.navigateBack();
  134. } else {
  135. history.back();
  136. }
  137. }, 1500);
  138. }
  139. },
  140. fail: () => {
  141. uni.hideLoading();
  142. },
  143. complete: () => {},
  144. });
  145. };
  146. const handleOpenPopup = () => {
  147. popup.value.open("bottom");
  148. };
  149. const handleRadioChange = (e) => {
  150. console.log("选择", e);
  151. current.value = e.detail.value;
  152. popup.value.close();
  153. };
  154. </script>
  155. <style lang="scss" scoped>
  156. .content {
  157. .title_wrap {
  158. font-size: 28upx;
  159. font-weight: 400;
  160. font-family: Verdana;
  161. color: #333333;
  162. margin: 42upx 0 24upx;
  163. .title_prefix {
  164. color: #ff490e;
  165. margin-right: 5upx;
  166. }
  167. .title_suffix {
  168. font-size: 26upx;
  169. color: #999999;
  170. }
  171. }
  172. .content_wrap {
  173. width: 670upx;
  174. height: 80upx;
  175. background: #ffffff;
  176. border: 1upx solid #cccccc;
  177. border-radius: 10upx;
  178. display: flex;
  179. align-items: center;
  180. justify-content: space-between;
  181. padding: 20upx;
  182. font-size: 24upx;
  183. font-weight: 400;
  184. color: #999999;
  185. }
  186. uni-radio {
  187. &::before {
  188. content: "";
  189. }
  190. }
  191. }
  192. </style>