Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

order-evaluate-product.vue 10KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388
  1. <!-- 订单-评价 -->
  2. <template>
  3. <!-- 1,4 -->
  4. <!-- 产品 -->
  5. <view class="card" style="padding: 40rpx 30rpx;">
  6. <view class="title">{{state.orderInfo.productName}}</view>
  7. <evaluate-star v-model="state.product.score" title="评价得分"></evaluate-star>
  8. <textarea class="input-box" v-model="state.product.content" placeholder-class="text-hint" :maxlength="500"
  9. style="height: 260rpx;" placeholder="从多角度评价,可以帮助我们提升服务质量。">
  10. </textarea>
  11. <view class="upload-img">
  12. <form-image @backImg="backImg($event)" @removeImg="removeImg" :isUrl="false" style="width: 100%;"
  13. :retract="-15"></form-image>
  14. </view>
  15. </view>
  16. <!-- 权益产品评价 -->
  17. <view class="card" v-if='state.haveInterestsProduct' style="padding: 40rpx 30rpx;">
  18. <view class="title">权益产品评价</view>
  19. <evaluate-star v-model="state.interest.score" title="评价得分"></evaluate-star>
  20. <textarea class="input-box" v-model="state.interest.content" placeholder-class="text-hint" :maxlength="500"
  21. style="height: 260rpx;" placeholder="从多角度评价,可以帮助我们提升服务质量。">
  22. </textarea>
  23. <view class="upload-img">
  24. <form-image @backImg="backImgInterest($event)" @removeImg="removeImgInterest" :isUrl="false"
  25. style="width: 100%;" :retract="-15"></form-image>
  26. </view>
  27. </view>
  28. <view class="uni-list" style='font-size:32rpx'>
  29. <view class="uni-list-cell uni-list-cell-pd">
  30. <view class="uni-list-cell-db">是否匿名</view>
  31. <switch checked style="transform:scale(0.7)" @change="switchChange" />
  32. </view>
  33. </view>
  34. <view class="btn">
  35. <submit-button @submit="publish" title="发布"></submit-button>
  36. </view>
  37. <!-- 选择标签弹窗 -->
  38. <u-popup v-model="state.showTagPop" mode="bottom" height="60%">
  39. <view v-if="state.showTagPop">
  40. <tag-popup :selTags="state.user.tagList" :tagAllList="state.tagAllList"
  41. @cancel="state.showTagPop = !state.showTagPop" @confirm="confirmSelectTag"></tag-popup>
  42. </view>
  43. </u-popup>
  44. </template>
  45. <script setup lang="ts">
  46. import evaluateStar from "./components/evaluate-star.vue"
  47. import { reactive } from "vue";
  48. import { confirm, isBlank, msg } from "@/utils/utils";
  49. import tagPopup from "./components/popup-order-evaluate-tag";
  50. import { request } from "@/utils/network/request";
  51. import { orderDetail, orderEvaluate, orderEvaluateTag, saleMessage, addEvaluation, judageQuanProduct } from "@/utils/network/api";
  52. import { onLoad } from "@dcloudio/uni-app";
  53. import { stringToJson } from "@/utils/network/encryption";
  54. import { getItem, StorageKeys } from "@/utils/storage";
  55. const state = reactive({
  56. orderInfo: {} as any, //订单信息
  57. showTagPop: false, //显示标签选择弹窗
  58. product: { //产品
  59. score: 0, //星级得分 最高5分,0.5小数点 2.5分及以下为差评 2.5以上4.0以下为中评 4.0及4.0以上为好评(必选)
  60. content: '', //评价内容
  61. imageList: [], //支持拍照上传最多上传9张
  62. },
  63. interest: { //产品
  64. score: 0, //星级得分 最高5分,0.5小数点 2.5分及以下为差评 2.5以上4.0以下为中评 4.0及4.0以上为好评(必选)
  65. content: '', //评价内容
  66. imageList: [], //支持拍照上传最多上传9张
  67. },
  68. user: { //业务员
  69. score: 0, //星级得分 最高5分,0.5小数点 2.5分及以下为差评 2.5以上4.0以下为中评 4.0及4.0以上为好评(必选)
  70. content: '', //评价内容
  71. tagList: [], //已选择的评价标签列表
  72. },
  73. tagAllList: [],
  74. orderId: "",
  75. haveInterestsProduct: false, //是否有权益产品
  76. isAnonymity: 1, //是否匿名
  77. })
  78. /* 确认选择tag */
  79. const confirmSelectTag = (selectTag) => {
  80. state.showTagPop = !state.showTagPop
  81. state.user.tagList = [...selectTag];
  82. }
  83. //选择图片
  84. const backImg = (e : any) => {
  85. state.product.imageList = e;
  86. }
  87. //删除图片
  88. const removeImg = (imgList) => {
  89. state.product.imageList = imgList
  90. }
  91. //选择图片权益产品
  92. const backImgInterest = (e : any) => {
  93. state.interest.imageList = e;
  94. }
  95. //删除图片
  96. const removeImgInterest = (imgList) => {
  97. state.interest.imageList = imgList
  98. }
  99. /* 删除评价标签 */
  100. const removeTag = (item : any) => {
  101. state.user.tagList.map((tag, index) => {
  102. if (tag.id === item.id) {
  103. state.user.tagList.splice(index, 1)
  104. }
  105. })
  106. }
  107. /* 发布 */
  108. const publish = (e) => {
  109. addProduct();
  110. }
  111. const addProduct = () => {
  112. if (state.product.score === 0) {
  113. msg('请对产品进行打分!');
  114. return;
  115. }
  116. //若不填评价内容,根据打分规则自动填充评价内容
  117. //差评展示:默认差评 2.5分及以下
  118. //中评展示:默认中评 2.5以上4.0以下
  119. //好评展示:默认好评 4.0及4.0以上
  120. if (!state.product.content) {
  121. if (state.product.score <= 2.5) {
  122. state.product.content = "默认差评";
  123. } else if (state.product.score > 2.5 && state.product.score < 4) {
  124. state.product.content = "默认中评";
  125. } else {
  126. state.product.content = "默认好评";
  127. }
  128. }
  129. const options = {
  130. type: 2,
  131. data: {
  132. "orderId": state.orderId,
  133. "serviceType": "product",
  134. "score": state.product.score,
  135. "pictureUrl": state.product.imageList.join(";"),
  136. "message": '',
  137. "suggestion": state.product.content,
  138. "isAnonymity": state.isAnonymity
  139. },
  140. method: 'POST',
  141. showLoading: true,
  142. }
  143. console.log("options", options)
  144. request(addEvaluation, options).then((res) => {
  145. if (state.haveInterestsProduct) {
  146. addProductInterest();
  147. } else {
  148. confirm('您的评价已发布成功!', () => {
  149. uni.$emit('refreshOrder');
  150. uni.navigateBack();
  151. }, '发布成功', false);
  152. }
  153. })
  154. }
  155. const addProductInterest = () => {
  156. if (state.interest.score === 0) {
  157. msg('请对权益产品进行打分!');
  158. return;
  159. }
  160. //若不填评价内容,根据打分规则自动填充评价内容
  161. //差评展示:默认差评 2.5分及以下
  162. //中评展示:默认中评 2.5以上4.0以下
  163. //好评展示:默认好评 4.0及4.0以上
  164. if (!state.interest.content) {
  165. if (state.interest.score <= 2.5) {
  166. state.interest.content = "默认差评";
  167. } else if (state.interest.score > 2.5 && state.interest.score < 4) {
  168. state.interest.content = "默认中评";
  169. } else {
  170. state.interest.content = "默认好评";
  171. }
  172. }
  173. const options = {
  174. type: 2,
  175. data: {
  176. "orderId": state.orderId,
  177. "serviceType": "equity",
  178. "equityId": state.orderInfo.equityId,//权益产品id
  179. "score": state.interest.score,
  180. "pictureUrl": state.interest.imageList.join(";"),
  181. "message": '',
  182. "suggestion": state.interest.content,
  183. "isAnonymity": state.isAnonymity
  184. },
  185. method: 'POST',
  186. showLoading: true,
  187. }
  188. console.log("options", options)
  189. request(addEvaluation, options).then((res) => {
  190. confirm('您的评价已发布成功!', () => {
  191. uni.$emit('refreshOrder');
  192. uni.navigateBack();
  193. }, '发布成功', false);
  194. })
  195. }
  196. /* 获取业务员标签ID */
  197. const getTagIds = () => {
  198. const list = [];
  199. state.user.tagList.map((tag) => {
  200. list.push(tag.id);
  201. });
  202. return list;
  203. }
  204. // 获取是否有权益产品
  205. const isInterestsProduct = (orderId) => {
  206. const options = {
  207. type: 2,
  208. data: { "orderId": orderId },
  209. method: 'POST',
  210. showLoading: true,
  211. }
  212. request(judageQuanProduct, options).then((res) => {
  213. console.log("获取是否有业务员", stringToJson(res.bizContent))
  214. state.haveInterestsProduct = stringToJson(res.bizContent);
  215. })
  216. }
  217. /* 获取订单详情 */
  218. const getOrderDetails = (id) => {
  219. const options = {
  220. type: 2,
  221. data: { "id": id },
  222. method: 'POST',
  223. showLoading: true,
  224. }
  225. request(orderDetail, options).then((res) => {
  226. state.orderInfo = stringToJson(res.bizContent);
  227. console.log("获取订单详情", stringToJson(res.bizContent), state.orderInfo.equityId)
  228. })
  229. }
  230. // 是否匿名
  231. const switchChange = (e) => {
  232. console.log('switch1 发生 change 事件,携带值为', e.detail.value);
  233. if (e.detail.value) {
  234. state.isAnonymity = 1
  235. } else {
  236. state.isAnonymity = 0
  237. }
  238. }
  239. onLoad((option) => {
  240. console.log("option11111", option)
  241. getOrderDetails(option.id);
  242. state.orderId = option.orderId
  243. isInterestsProduct(option.orderId); //获取是否有权益产品
  244. })
  245. </script>
  246. <style>
  247. page {
  248. background-color: #EEF7F7;
  249. padding-bottom: 50rpx;
  250. }
  251. </style>
  252. <style lang="scss" scoped>
  253. .card {
  254. background-color: white;
  255. border-radius: 20rpx;
  256. box-shadow: 0px 0px 6rpx 2rpx rgba(223, 223, 223, 0.3);
  257. margin: 30rpx;
  258. .title {
  259. text-align: center;
  260. font-size: 32rpx;
  261. color: #333333;
  262. padding-bottom: 30rpx;
  263. }
  264. .upload-img {
  265. margin-top: 10rpx;
  266. }
  267. .rate {
  268. .rate-label {
  269. font-size: 28rpx;
  270. color: #333333;
  271. padding-right: 20rpx;
  272. }
  273. }
  274. .input-box {
  275. width: 100%;
  276. border: 1px solid #DCDCDC;
  277. border-radius: 10rpx;
  278. background-color: #F3F3F3;
  279. padding: 30rpx;
  280. box-sizing: border-box;
  281. -moz-box-sizing: border-box;
  282. /*Firefox*/
  283. -webkit-box-sizing: border-box;
  284. /*Safari*/
  285. margin-top: 30rpx;
  286. }
  287. .text-hine {
  288. color: #999999;
  289. font-size: 26rpx;
  290. }
  291. .title1 {
  292. font-size: 30rpx;
  293. color: #333333;
  294. border-bottom: 1px solid #DCDCDC;
  295. padding: 30rpx;
  296. }
  297. .user {
  298. margin-bottom: 40rpx;
  299. .avatar {
  300. width: 140rpx;
  301. height: 160rpx;
  302. background-color: #F3F3F3;
  303. border-radius: 10rpx;
  304. }
  305. .user-info {
  306. margin-left: 40rpx;
  307. margin-top: 28rpx;
  308. .name {
  309. font-size: 28rpx;
  310. color: #333333;
  311. &:last-child {
  312. margin-top: 40rpx;
  313. }
  314. }
  315. }
  316. }
  317. .center {
  318. margin-top: 40rpx;
  319. padding-bottom: 20rpx;
  320. border-bottom: 1rpx solid #DCDCDC;
  321. .tags {
  322. flex-wrap: wrap;
  323. .tag {
  324. border-radius: 28rpx;
  325. background-color: #F3F3F3;
  326. padding: 0rpx 20rpx;
  327. border: 1px solid #DCDCDC;
  328. margin-right: 18rpx;
  329. margin-bottom: 15rpx;
  330. color: #333333;
  331. font-size: 26rpx;
  332. display: flex;
  333. flex-direction: row;
  334. justify-content: center;
  335. align-items: center;
  336. height: 57rpx;
  337. &:last-child {
  338. margin-right: 0rpx;
  339. margin-bottom: 0px;
  340. }
  341. .tag-close {
  342. width: 32rpx;
  343. height: 32rpx;
  344. margin-left: 15rpx;
  345. }
  346. }
  347. }
  348. }
  349. }
  350. .btn {
  351. margin: 60rpx 40rpx 0rpx;
  352. }
  353. .uni-list-cell {
  354. display: flex;
  355. margin: 10rpx auto;
  356. width: 90%;
  357. justify-content: space-between;
  358. align-items: center;
  359. }
  360. </style>