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.vue 8.6KB

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