Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

order-evaluate.vue 8.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  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="300"
  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.haveUser">
  18. <view class="title1">业务员</view>
  19. <view style="padding: 30rpx 30rpx 45rpx;">
  20. <view class="user as-layout-horizontal">
  21. <image class="avatar" :src="`${$imgUrl}default_head.png`" mode="aspectFill"></image>
  22. <view class="user-info">
  23. <view class="name">{{state.orderInfo.staffName ?state.orderInfo.staffName: ''}}</view>
  24. <view class="name">{{state.orderInfo.staffPhone ?state.orderInfo.staffPhone: ''}}</view>
  25. </view>
  26. </view>
  27. <evaluate-star v-model="state.user.score" title="进行评价"></evaluate-star>
  28. <view class="center as-layout-horizontal">
  29. <view class="tags as-layout-horizontal">
  30. <view class="tag" v-for="(item,index) in state.user.tagList" :key="item">
  31. {{item.label}}
  32. <image v-if="state.user.tagList.length > 1" class="tag-close"
  33. :src="`${$imgUrl}common/icon-close.png`" @click="removeTag(item)" />
  34. </view>
  35. </view>
  36. <image :src="`${$imgUrl}common/${state.showTagPop ? 'arror-top.png' : 'arror-down.png'}`"
  37. style="width: 40rpx;height: 40rpx;" @click="state.showTagPop = !state.showTagPop"></image>
  38. </view>
  39. <textarea class="input-box" v-model="state.user.content" placeholder-class="text-hint"
  40. style="height: 200rpx;" placeholder="请输入评价内容" :maxlength="300">
  41. </textarea>
  42. </view>
  43. </view>
  44. <view class="btn">
  45. <submit-button @submit="publish" title="发布"></submit-button>
  46. </view>
  47. <!-- 选择标签弹窗 -->
  48. <u-popup v-model="state.showTagPop" mode="bottom" height="60%">
  49. <view v-if="state.showTagPop">
  50. <tag-popup :selTags="state.user.tagList" :tagAllList="state.tagAllList"
  51. @cancel="state.showTagPop = !state.showTagPop" @confirm="confirmSelectTag"></tag-popup>
  52. </view>
  53. </u-popup>
  54. </template>
  55. <script setup lang="ts">
  56. import evaluateStar from "./components/evaluate-star.vue"
  57. import { reactive } from "vue";
  58. import { confirm, isBlank, msg } from "@/utils/utils";
  59. import tagPopup from "./components/popup-order-evaluate-tag";
  60. import { request,requestNew } from "@/utils/network/request";
  61. import { orderDetail, orderEvaluate, orderEvaluateTag, saleMessage } from "@/utils/network/api";
  62. import { onLoad } from "@dcloudio/uni-app";
  63. import { stringToJson } from "@/utils/network/encryption";
  64. import { getItem, StorageKeys } from "@/utils/storage";
  65. const state = reactive({
  66. orderInfo: {} as any, //订单信息
  67. haveUser: false, //存在有业务员发起的业务展示业务员评价模块
  68. showTagPop: false, //显示标签选择弹窗
  69. product: { //产品
  70. score: 0, //星级得分 最高5分,0.5小数点 2.5分及以下为差评 2.5以上4.0以下为中评 4.0及4.0以上为好评(必选)
  71. content: '', //评价内容
  72. imageList: [], //支持拍照上传最多上传9张
  73. },
  74. user: { //业务员
  75. score: 0, //星级得分 最高5分,0.5小数点 2.5分及以下为差评 2.5以上4.0以下为中评 4.0及4.0以上为好评(必选)
  76. content: '', //评价内容
  77. tagList: [], //已选择的评价标签列表
  78. },
  79. tagAllList: []
  80. })
  81. /* 确认选择tag */
  82. const confirmSelectTag = (selectTag) => {
  83. state.showTagPop = !state.showTagPop
  84. state.user.tagList = [...selectTag];
  85. }
  86. //选择图片
  87. const backImg = (e : any) => {
  88. state.product.imageList = e;
  89. }
  90. //删除图片
  91. const removeImg = (imgList) => {
  92. state.product.imageList = imgList
  93. }
  94. /* 删除评价标签 */
  95. const removeTag = (item : any) => {
  96. state.user.tagList.map((tag, index) => {
  97. if (tag.id === item.id) {
  98. state.user.tagList.splice(index, 1)
  99. }
  100. })
  101. }
  102. /* 发布 */
  103. const publish = (e) => {
  104. if (state.product.score === 0) {
  105. msg('请对产品进行打分!');
  106. return;
  107. }
  108. if (state.haveUser && state.user.score === 0) {
  109. msg('请对业务员进行打分!');
  110. return;
  111. }
  112. //若不填评价内容,根据打分规则自动填充评价内容
  113. //差评展示:默认差评 2.5分及以下
  114. //中评展示:默认中评 2.5以上4.0以下
  115. //好评展示:默认好评 4.0及4.0以上
  116. if (!state.product.content) {
  117. if (state.product.score <= 2.5) {
  118. state.product.content = "默认差评";
  119. } else if (state.product.score > 2.5 && state.product.score < 4) {
  120. state.product.content = "默认中评";
  121. } else {
  122. state.product.content = "默认好评";
  123. }
  124. }
  125. if (state.haveUser && !state.user.content) {
  126. if (state.user.score <= 2.5) {
  127. state.user.content = "默认差评";
  128. } else if (state.user.score > 2.5 && state.user.score < 4) {
  129. state.user.content = "默认中评";
  130. } else {
  131. state.user.content = "默认好评";
  132. }
  133. }
  134. const options = {
  135. type: 2,
  136. data: {
  137. "id": state.orderInfo.id,
  138. 'productScore': state.product.score,
  139. 'productAppraise': state.product.content,
  140. 'appraisePics': state.product.imageList.join(";"),
  141. 'staffId': state.orderInfo.staffId,
  142. 'staffName': state.orderInfo.staffName,
  143. 'staffScore': state.user.score,
  144. 'staffTips': getTagIds().join(';'),
  145. 'staffAppraise': state.user.content,
  146. 'opId': getItem(StorageKeys.OpenId)
  147. },
  148. method: 'POST',
  149. showLoading: true,
  150. }
  151. requestNew(orderEvaluate, options).then((res) => {
  152. confirm('您的评价已发布成功!', () => {
  153. uni.$emit('refreshOrder');
  154. uni.navigateBack();
  155. }, '发布成功', false);
  156. })
  157. }
  158. /* 获取业务员标签ID */
  159. const getTagIds = () => {
  160. const list = [];
  161. state.user.tagList.map((tag) => {
  162. list.push(tag.id);
  163. });
  164. return list;
  165. }
  166. /* 获取订单详情 */
  167. const getOrderDetails = (id) => {
  168. const options = {
  169. type: 2,
  170. data: { "id": id },
  171. method: 'POST',
  172. showLoading: true,
  173. }
  174. request(orderDetail, options).then((res) => {
  175. state.orderInfo = stringToJson(res.bizContent);
  176. state.haveUser = !isBlank(state.orderInfo.staffId);
  177. })
  178. }
  179. /* 获取评价标签 */
  180. const getEnvTag = () => {
  181. const options = {
  182. type: 2,
  183. data: {},
  184. method: 'POST',
  185. showLoading: true,
  186. }
  187. requestNew(orderEvaluateTag, options).then((res) => {
  188. console.log("获取评价标签", res)
  189. state.tagAllList = res;
  190. })
  191. }
  192. onLoad((option) => {
  193. getOrderDetails(option.id);
  194. getEnvTag();
  195. })
  196. </script>
  197. <style>
  198. page {
  199. background-color: #EEF7F7;
  200. padding-bottom: 50rpx;
  201. }
  202. </style>
  203. <style lang="scss" scoped>
  204. .card {
  205. background-color: white;
  206. border-radius: 20rpx;
  207. box-shadow: 0px 0px 6rpx 2rpx rgba(223, 223, 223, 0.3);
  208. margin: 30rpx;
  209. .title {
  210. text-align: center;
  211. font-size: 32rpx;
  212. color: #333333;
  213. padding-bottom: 30rpx;
  214. }
  215. .upload-img {
  216. margin-top: 10rpx;
  217. }
  218. .rate {
  219. .rate-label {
  220. font-size: 28rpx;
  221. color: #333333;
  222. padding-right: 20rpx;
  223. }
  224. }
  225. .input-box {
  226. width: 100%;
  227. border: 1px solid #DCDCDC;
  228. border-radius: 10rpx;
  229. background-color: #F3F3F3;
  230. padding: 30rpx;
  231. box-sizing: border-box;
  232. -moz-box-sizing: border-box;
  233. /*Firefox*/
  234. -webkit-box-sizing: border-box;
  235. /*Safari*/
  236. margin-top: 30rpx;
  237. }
  238. .text-hine {
  239. color: #999999;
  240. font-size: 26rpx;
  241. }
  242. .title1 {
  243. font-size: 30rpx;
  244. color: #333333;
  245. border-bottom: 1px solid #DCDCDC;
  246. padding: 30rpx;
  247. }
  248. .user {
  249. margin-bottom: 40rpx;
  250. .avatar {
  251. width: 140rpx;
  252. height: 160rpx;
  253. background-color: #F3F3F3;
  254. border-radius: 10rpx;
  255. }
  256. .user-info {
  257. margin-left: 40rpx;
  258. margin-top: 28rpx;
  259. .name {
  260. font-size: 28rpx;
  261. color: #333333;
  262. &:last-child {
  263. margin-top: 40rpx;
  264. }
  265. }
  266. }
  267. }
  268. .center {
  269. margin-top: 40rpx;
  270. padding-bottom: 20rpx;
  271. border-bottom: 1rpx solid #DCDCDC;
  272. .tags {
  273. flex-wrap: wrap;
  274. .tag {
  275. border-radius: 28rpx;
  276. background-color: #F3F3F3;
  277. padding: 0rpx 20rpx;
  278. border: 1px solid #DCDCDC;
  279. margin-right: 18rpx;
  280. margin-bottom: 15rpx;
  281. color: #333333;
  282. font-size: 26rpx;
  283. display: flex;
  284. flex-direction: row;
  285. justify-content: center;
  286. align-items: center;
  287. height: 57rpx;
  288. &:last-child {
  289. margin-right: 0rpx;
  290. margin-bottom: 0px;
  291. }
  292. .tag-close {
  293. width: 32rpx;
  294. height: 32rpx;
  295. margin-left: 15rpx;
  296. }
  297. }
  298. }
  299. }
  300. }
  301. .btn {
  302. margin: 60rpx 40rpx 0rpx;
  303. }
  304. </style>