您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

order-evaluate-product.vue 10KB

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