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

order-evaluate.vue 8.5KB

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