You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

order-evaluate-product.vue 10KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389
  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. console.log("e", e)
  86. state.product.imageList = e;
  87. }
  88. //删除图片
  89. const removeImg = (imgList) => {
  90. state.product.imageList = imgList
  91. }
  92. //选择图片权益产品
  93. const backImgInterest = (e : any) => {
  94. state.interest.imageList = e;
  95. }
  96. //删除图片
  97. const removeImgInterest = (imgList) => {
  98. state.interest.imageList = imgList
  99. }
  100. /* 删除评价标签 */
  101. const removeTag = (item : any) => {
  102. state.user.tagList.map((tag, index) => {
  103. if (tag.id === item.id) {
  104. state.user.tagList.splice(index, 1)
  105. }
  106. })
  107. }
  108. /* 发布 */
  109. const publish = (e) => {
  110. addProduct();
  111. }
  112. const addProduct = () => {
  113. if (state.product.score === 0) {
  114. msg('请对产品进行打分!');
  115. return;
  116. }
  117. //若不填评价内容,根据打分规则自动填充评价内容
  118. //差评展示:默认差评 2.5分及以下
  119. //中评展示:默认中评 2.5以上4.0以下
  120. //好评展示:默认好评 4.0及4.0以上
  121. if (!state.product.content) {
  122. if (state.product.score <= 2.5) {
  123. state.product.content = "默认差评";
  124. } else if (state.product.score > 2.5 && state.product.score < 4) {
  125. state.product.content = "默认中评";
  126. } else {
  127. state.product.content = "默认好评";
  128. }
  129. }
  130. const options = {
  131. type: 2,
  132. data: {
  133. "orderId": state.orderId,
  134. "serviceType": "product",
  135. "score": state.product.score,
  136. "pictureUrl": state.product.imageList.join(";"),
  137. "message": '',
  138. "suggestion": state.product.content,
  139. "isAnonymity": state.isAnonymity
  140. },
  141. method: 'POST',
  142. showLoading: true,
  143. }
  144. console.log("options", options)
  145. request(addEvaluation, options).then((res) => {
  146. if (state.haveInterestsProduct) {
  147. addProductInterest();
  148. } else {
  149. confirm('您的评价已发布成功!', () => {
  150. uni.$emit('refreshOrder');
  151. uni.navigateBack();
  152. }, '发布成功', false);
  153. }
  154. })
  155. }
  156. const addProductInterest = () => {
  157. if (state.interest.score === 0) {
  158. msg('请对权益产品进行打分!');
  159. return;
  160. }
  161. //若不填评价内容,根据打分规则自动填充评价内容
  162. //差评展示:默认差评 2.5分及以下
  163. //中评展示:默认中评 2.5以上4.0以下
  164. //好评展示:默认好评 4.0及4.0以上
  165. if (!state.interest.content) {
  166. if (state.interest.score <= 2.5) {
  167. state.interest.content = "默认差评";
  168. } else if (state.interest.score > 2.5 && state.interest.score < 4) {
  169. state.interest.content = "默认中评";
  170. } else {
  171. state.interest.content = "默认好评";
  172. }
  173. }
  174. const options = {
  175. type: 2,
  176. data: {
  177. "orderId": state.orderId,
  178. "serviceType": "equity",
  179. "equityId": state.orderInfo.equityId,//权益产品id
  180. "score": state.interest.score,
  181. "pictureUrl": state.interest.imageList.join(";"),
  182. "message": '',
  183. "suggestion": state.interest.content,
  184. "isAnonymity": state.isAnonymity
  185. },
  186. method: 'POST',
  187. showLoading: true,
  188. }
  189. console.log("options", options)
  190. request(addEvaluation, options).then((res) => {
  191. confirm('您的评价已发布成功!', () => {
  192. uni.$emit('refreshOrder');
  193. uni.navigateBack();
  194. }, '发布成功', false);
  195. })
  196. }
  197. /* 获取业务员标签ID */
  198. const getTagIds = () => {
  199. const list = [];
  200. state.user.tagList.map((tag) => {
  201. list.push(tag.id);
  202. });
  203. return list;
  204. }
  205. // 获取是否有权益产品
  206. const isInterestsProduct = (orderId) => {
  207. const options = {
  208. type: 2,
  209. data: { "orderId": orderId },
  210. method: 'POST',
  211. showLoading: true,
  212. }
  213. request(judageQuanProduct, options).then((res) => {
  214. console.log("获取是否有业务员", stringToJson(res.bizContent))
  215. state.haveInterestsProduct = stringToJson(res.bizContent);
  216. })
  217. }
  218. /* 获取订单详情 */
  219. const getOrderDetails = (id) => {
  220. const options = {
  221. type: 2,
  222. data: { "id": id },
  223. method: 'POST',
  224. showLoading: true,
  225. }
  226. request(orderDetail, options).then((res) => {
  227. state.orderInfo = stringToJson(res.bizContent);
  228. console.log("获取订单详情", stringToJson(res.bizContent), state.orderInfo.equityId)
  229. })
  230. }
  231. // 是否匿名
  232. const switchChange = (e) => {
  233. console.log('switch1 发生 change 事件,携带值为', e.detail.value);
  234. if (e.detail.value) {
  235. state.isAnonymity = 1
  236. } else {
  237. state.isAnonymity = 0
  238. }
  239. }
  240. onLoad((option) => {
  241. console.log("option11111", option)
  242. getOrderDetails(option.id);
  243. state.orderId = option.orderId
  244. isInterestsProduct(option.orderId); //获取是否有权益产品
  245. })
  246. </script>
  247. <style>
  248. page {
  249. background-color: #EEF7F7;
  250. padding-bottom: 50rpx;
  251. }
  252. </style>
  253. <style lang="scss" scoped>
  254. .card {
  255. background-color: white;
  256. border-radius: 20rpx;
  257. box-shadow: 0px 0px 6rpx 2rpx rgba(223, 223, 223, 0.3);
  258. margin: 30rpx;
  259. .title {
  260. text-align: center;
  261. font-size: 32rpx;
  262. color: #333333;
  263. padding-bottom: 30rpx;
  264. }
  265. .upload-img {
  266. margin-top: 10rpx;
  267. }
  268. .rate {
  269. .rate-label {
  270. font-size: 28rpx;
  271. color: #333333;
  272. padding-right: 20rpx;
  273. }
  274. }
  275. .input-box {
  276. width: 100%;
  277. border: 1px solid #DCDCDC;
  278. border-radius: 10rpx;
  279. background-color: #F3F3F3;
  280. padding: 30rpx;
  281. box-sizing: border-box;
  282. -moz-box-sizing: border-box;
  283. /*Firefox*/
  284. -webkit-box-sizing: border-box;
  285. /*Safari*/
  286. margin-top: 30rpx;
  287. }
  288. .text-hine {
  289. color: #999999;
  290. font-size: 26rpx;
  291. }
  292. .title1 {
  293. font-size: 30rpx;
  294. color: #333333;
  295. border-bottom: 1px solid #DCDCDC;
  296. padding: 30rpx;
  297. }
  298. .user {
  299. margin-bottom: 40rpx;
  300. .avatar {
  301. width: 140rpx;
  302. height: 160rpx;
  303. background-color: #F3F3F3;
  304. border-radius: 10rpx;
  305. }
  306. .user-info {
  307. margin-left: 40rpx;
  308. margin-top: 28rpx;
  309. .name {
  310. font-size: 28rpx;
  311. color: #333333;
  312. &:last-child {
  313. margin-top: 40rpx;
  314. }
  315. }
  316. }
  317. }
  318. .center {
  319. margin-top: 40rpx;
  320. padding-bottom: 20rpx;
  321. border-bottom: 1rpx solid #DCDCDC;
  322. .tags {
  323. flex-wrap: wrap;
  324. .tag {
  325. border-radius: 28rpx;
  326. background-color: #F3F3F3;
  327. padding: 0rpx 20rpx;
  328. border: 1px solid #DCDCDC;
  329. margin-right: 18rpx;
  330. margin-bottom: 15rpx;
  331. color: #333333;
  332. font-size: 26rpx;
  333. display: flex;
  334. flex-direction: row;
  335. justify-content: center;
  336. align-items: center;
  337. height: 57rpx;
  338. &:last-child {
  339. margin-right: 0rpx;
  340. margin-bottom: 0px;
  341. }
  342. .tag-close {
  343. width: 32rpx;
  344. height: 32rpx;
  345. margin-left: 15rpx;
  346. }
  347. }
  348. }
  349. }
  350. }
  351. .btn {
  352. margin: 60rpx 40rpx 0rpx;
  353. }
  354. .uni-list-cell {
  355. display: flex;
  356. margin: 10rpx auto;
  357. width: 90%;
  358. justify-content: space-between;
  359. align-items: center;
  360. }
  361. </style>