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 10.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382
  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.haveInterestsProduct' style="padding: 40rpx 30rpx;">
  17. <view class="title">权益产品评价</view>
  18. <evaluate-star v-model="state.interest.score" title="评价得分"></evaluate-star>
  19. <textarea class="input-box" v-model="state.interest.content" placeholder-class="text-hint" :maxlength="500"
  20. style="height: 260rpx;" placeholder="从多角度评价,可以帮助我们提升服务质量。">
  21. </textarea>
  22. <view class="upload-img">
  23. <form-image @backImg="backImgInterest($event)" @removeImg="removeImgInterest" :isUrl="false" style="width: 100%;" :retract="-15"></form-image>
  24. </view>
  25. </view>
  26. <view class="uni-list" style='font-size:32rpx'>
  27. <view class="uni-list-cell uni-list-cell-pd">
  28. <view class="uni-list-cell-db">是否匿名</view>
  29. <switch checked style="transform:scale(0.7)" @change="switchChange"/>
  30. </view>
  31. </view>
  32. <view class="btn">
  33. <submit-button @submit="publish" title="发布"></submit-button>
  34. </view>
  35. <!-- 选择标签弹窗 -->
  36. <u-popup v-model="state.showTagPop" mode="bottom" height="60%">
  37. <view v-if="state.showTagPop">
  38. <tag-popup :selTags="state.user.tagList" :tagAllList="state.tagAllList" @cancel="state.showTagPop = !state.showTagPop" @confirm="confirmSelectTag"></tag-popup>
  39. </view>
  40. </u-popup>
  41. </template>
  42. <script setup lang="ts">
  43. import evaluateStar from "./components/evaluate-star.vue"
  44. import {reactive} from "vue";
  45. import {confirm, isBlank, msg} from "@/utils/utils";
  46. import tagPopup from "./components/popup-order-evaluate-tag";
  47. import { request } from "@/utils/network/request";
  48. import { orderDetail, orderEvaluate,orderEvaluateTag,saleMessage,addEvaluation,judageQuanProduct } from "@/utils/network/api";
  49. import {onLoad} from "@dcloudio/uni-app";
  50. import { stringToJson } from "@/utils/network/encryption";
  51. import { getItem, StorageKeys } from "@/utils/storage";
  52. const state = reactive({
  53. orderInfo:{} as any, //订单信息
  54. showTagPop: false, //显示标签选择弹窗
  55. product: { //产品
  56. score: 0, //星级得分 最高5分,0.5小数点 2.5分及以下为差评 2.5以上4.0以下为中评 4.0及4.0以上为好评(必选)
  57. content: '', //评价内容
  58. imageList: [], //支持拍照上传最多上传9张
  59. },
  60. interest: { //产品
  61. score: 0, //星级得分 最高5分,0.5小数点 2.5分及以下为差评 2.5以上4.0以下为中评 4.0及4.0以上为好评(必选)
  62. content: '', //评价内容
  63. imageList: [], //支持拍照上传最多上传9张
  64. },
  65. user: { //业务员
  66. score: 0, //星级得分 最高5分,0.5小数点 2.5分及以下为差评 2.5以上4.0以下为中评 4.0及4.0以上为好评(必选)
  67. content: '', //评价内容
  68. tagList: [], //已选择的评价标签列表
  69. },
  70. tagAllList:[],
  71. orderId:"",
  72. haveInterestsProduct:false, //是否有权益产品
  73. isAnonymity:1, //是否匿名
  74. })
  75. /* 确认选择tag */
  76. const confirmSelectTag = (selectTag) => {
  77. state.showTagPop = !state.showTagPop
  78. state.user.tagList = [...selectTag];
  79. }
  80. //选择图片
  81. const backImg = (e: any) => {
  82. state.product.imageList = e;
  83. }
  84. //删除图片
  85. const removeImg = (imgList) => {
  86. state.product.imageList = imgList
  87. }
  88. //选择图片权益产品
  89. const backImgInterest = (e: any) => {
  90. state.interest.imageList = e;
  91. }
  92. //删除图片
  93. const removeImgInterest = (imgList) => {
  94. state.interest.imageList = imgList
  95. }
  96. /* 删除评价标签 */
  97. const removeTag = (item: any) => {
  98. state.user.tagList.map((tag, index) => {
  99. if (tag.id === item.id) {
  100. state.user.tagList.splice(index, 1)
  101. }
  102. })
  103. }
  104. /* 发布 */
  105. const publish = (e) => {
  106. addProduct();
  107. }
  108. const addProduct=()=>{
  109. if (state.product.score === 0) {
  110. msg('请对产品进行打分!');
  111. return;
  112. }
  113. //若不填评价内容,根据打分规则自动填充评价内容
  114. //差评展示:默认差评 2.5分及以下
  115. //中评展示:默认中评 2.5以上4.0以下
  116. //好评展示:默认好评 4.0及4.0以上
  117. if (!state.product.content) {
  118. if (state.product.score <= 2.5) {
  119. state.product.content = "默认差评";
  120. } else if (state.product.score > 2.5 && state.product.score < 4) {
  121. state.product.content = "默认中评";
  122. } else {
  123. state.product.content = "默认好评";
  124. }
  125. }
  126. const options = {
  127. type: 2,
  128. data: {
  129. "orderId":state.orderId,
  130. "serviceType":"product",
  131. "score":state.product.score,
  132. "pictureUrl":state.product.imageList.join(";"),
  133. "message":'',
  134. "suggestion":state.product.content,
  135. "isAnonymity":state.isAnonymity
  136. },
  137. method: 'POST',
  138. showLoading: true,
  139. }
  140. console.log("options",options)
  141. debugger;
  142. request(addEvaluation,options).then((res)=>{
  143. if(state.haveInterestsProduct){
  144. addProductInterest();
  145. }else{
  146. confirm('您的评价已发布成功!',()=>{
  147. uni.$emit('refreshOrder');
  148. uni.navigateBack();
  149. },'发布成功',false);
  150. }
  151. })
  152. }
  153. const addProductInterest=()=>{
  154. if (state.interest.score === 0) {
  155. msg('请对权益产品进行打分!');
  156. return;
  157. }
  158. //若不填评价内容,根据打分规则自动填充评价内容
  159. //差评展示:默认差评 2.5分及以下
  160. //中评展示:默认中评 2.5以上4.0以下
  161. //好评展示:默认好评 4.0及4.0以上
  162. if (!state.interest.content) {
  163. if (state.interest.score <= 2.5) {
  164. state.interest.content = "默认差评";
  165. } else if (state.interest.score > 2.5 && state.interest.score < 4) {
  166. state.interest.content = "默认中评";
  167. } else {
  168. state.interest.content = "默认好评";
  169. }
  170. }
  171. const options = {
  172. type: 2,
  173. data: {
  174. "orderId":state.orderId,
  175. "serviceType":"equity",
  176. "score":state.interest.score,
  177. "pictureUrl":state.interest.imageList.join(";"),
  178. "message":'',
  179. "suggestion":state.interest.content,
  180. "isAnonymity":state.isAnonymity
  181. },
  182. method: 'POST',
  183. showLoading: true,
  184. }
  185. console.log("options",options)
  186. request(addEvaluation,options).then((res)=>{
  187. confirm('您的评价已发布成功!',()=>{
  188. uni.$emit('refreshOrder');
  189. uni.navigateBack();
  190. },'发布成功',false);
  191. })
  192. }
  193. /* 获取业务员标签ID */
  194. const getTagIds = () => {
  195. const list = [];
  196. state.user.tagList.map((tag)=>{
  197. list.push(tag.id);
  198. });
  199. return list;
  200. }
  201. // 获取是否有权益产品
  202. const isInterestsProduct=(orderId)=>{
  203. const options = {
  204. type: 2,
  205. data: {"orderId": orderId},
  206. method: 'POST',
  207. showLoading: true,
  208. }
  209. request(judageQuanProduct, options).then((res) => {
  210. console.log("获取是否有业务员",stringToJson(res.bizContent))
  211. state.haveInterestsProduct = stringToJson(res.bizContent);
  212. })
  213. }
  214. /* 获取订单详情 */
  215. const getOrderDetails = (id) => {
  216. const options = {
  217. type: 2,
  218. data: {"id": id},
  219. method: 'POST',
  220. showLoading: true,
  221. }
  222. request(orderDetail, options).then((res) => {
  223. console.log("获取订单详情",stringToJson(res.bizContent))
  224. state.orderInfo = stringToJson(res.bizContent);
  225. })
  226. }
  227. // 是否匿名
  228. const switchChange=(e)=>{
  229. console.log('switch1 发生 change 事件,携带值为', e.detail.value);
  230. if(e.detail.value){
  231. state.isAnonymity=1
  232. }else{
  233. state.isAnonymity=0
  234. }
  235. }
  236. onLoad((option) => {
  237. getOrderDetails(option.id);
  238. state.orderId=option.orderId
  239. isInterestsProduct(option.orderId); //获取是否有权益产品
  240. })
  241. </script>
  242. <style>
  243. page {
  244. background-color: #EEF7F7;
  245. padding-bottom: 50rpx;
  246. }
  247. </style>
  248. <style lang="scss" scoped>
  249. .card {
  250. background-color: white;
  251. border-radius: 20rpx;
  252. box-shadow: 0px 0px 6rpx 2rpx rgba(223, 223, 223, 0.3);
  253. margin: 30rpx;
  254. .title {
  255. text-align: center;
  256. font-size: 32rpx;
  257. color: #333333;
  258. padding-bottom: 30rpx;
  259. }
  260. .upload-img {
  261. margin-top: 10rpx;
  262. }
  263. .rate {
  264. .rate-label {
  265. font-size: 28rpx;
  266. color: #333333;
  267. padding-right: 20rpx;
  268. }
  269. }
  270. .input-box {
  271. width: 100%;
  272. border: 1px solid #DCDCDC;
  273. border-radius: 10rpx;
  274. background-color: #F3F3F3;
  275. padding: 30rpx;
  276. box-sizing: border-box;
  277. -moz-box-sizing: border-box;
  278. /*Firefox*/
  279. -webkit-box-sizing: border-box;
  280. /*Safari*/
  281. margin-top: 30rpx;
  282. }
  283. .text-hine {
  284. color: #999999;
  285. font-size: 26rpx;
  286. }
  287. .title1 {
  288. font-size: 30rpx;
  289. color: #333333;
  290. border-bottom: 1px solid #DCDCDC;
  291. padding: 30rpx;
  292. }
  293. .user {
  294. margin-bottom: 40rpx;
  295. .avatar {
  296. width: 140rpx;
  297. height: 160rpx;
  298. background-color: #F3F3F3;
  299. border-radius: 10rpx;
  300. }
  301. .user-info {
  302. margin-left: 40rpx;
  303. margin-top: 28rpx;
  304. .name {
  305. font-size: 28rpx;
  306. color: #333333;
  307. &:last-child {
  308. margin-top: 40rpx;
  309. }
  310. }
  311. }
  312. }
  313. .center {
  314. margin-top: 40rpx;
  315. padding-bottom: 20rpx;
  316. border-bottom: 1rpx solid #DCDCDC;
  317. .tags {
  318. flex-wrap: wrap;
  319. .tag {
  320. border-radius: 28rpx;
  321. background-color: #F3F3F3;
  322. padding: 0rpx 20rpx;
  323. border: 1px solid #DCDCDC;
  324. margin-right: 18rpx;
  325. margin-bottom: 15rpx;
  326. color: #333333;
  327. font-size: 26rpx;
  328. display: flex;
  329. flex-direction: row;
  330. justify-content: center;
  331. align-items: center;
  332. height: 57rpx;
  333. &:last-child {
  334. margin-right: 0rpx;
  335. margin-bottom: 0px;
  336. }
  337. .tag-close {
  338. width: 32rpx;
  339. height: 32rpx;
  340. margin-left: 15rpx;
  341. }
  342. }
  343. }
  344. }
  345. }
  346. .btn {
  347. margin: 60rpx 40rpx 0rpx;
  348. }
  349. .uni-list-cell{
  350. display: flex;
  351. margin: 10rpx auto;
  352. width: 90%;
  353. justify-content: space-between;
  354. align-items: center;
  355. }
  356. </style>