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.
yanzong/public/assets/pages-order-comment-index.c...

1 lines
5.5 KiB

import{$ as e,o as s,c as a,w as o,n as t,e as l,i as c,a as i,b as d,d as n,F as r,j as m,f as g,t as u,g as f,k as h,a3 as _}from"./index-ae8bbb19.js";import{i as p}from"./upload.b4cf29ca.js";import{_ as L}from"./_plugin-vue_export-helper.1b428a4d.js";const b="order.comment/list",D="order.comment/submit";const k=L({data:()=>({isLoading:!0,orderId:null,goodsList:[],formData:[],maxImageLength:6,disabled:!1}),onLoad({orderId:e}){this.orderId=e,this.getGoodsList()},methods:{getGoodsList(){const s=this;var a,o;s.isLoading=!0,(a=s.orderId,e.get(b,{orderId:a,...o})).then((e=>{s.goodsList=e.data.goodsList,s.initFormData(),s.isLoading=!1}))},initFormData(){const{goodsList:e}=this,s=e.map((e=>({goods_id:e.goods_id,order_goods_id:e.order_goods_id,score:10,content:"",imageList:[],uploaded:[]})));this.formData=s},setScore(e,s){this.formData[e].score=s},chooseImage(e){const s=this,a=s.formData[e].imageList;uni.chooseImage({count:6-a.length,sizeType:["original","compressed"],sourceType:["album","camera"],success({tempFiles:o}){s.formData[e].imageList=a.concat(o)}})},deleteImage(e,s){this.formData[e].imageList.splice(s,1)},handleSubmit(){const e=this;if(!0===e.disabled)return!1;e.disabled=!0;e.getImagesLength()>0?e.uploadFile().then((()=>{console.log("then"),e.onSubmit()})).catch((s=>{console.log("catch"),e.disabled=!1,0!==s.statusCode&&e.$toast(s.errMsg),console.log("err",s)})):e.onSubmit()},getImagesLength(){const{formData:e}=this;let s=0;return e.forEach((e=>{e.content.trim()&&(s+=e.imageList.length)})),s},onSubmit(){const s=this;var a,o;(a=s.orderId,o=s.formData,e.post(D,{orderId:a,form:o})).then((e=>{s.$toast(e.message),setTimeout((()=>{s.disabled=!1,uni.navigateBack()}),1500)})).catch((e=>s.disabled=!1))},uploadFile(){const e=this,{formData:s}=e,a=[];return s.forEach(((e,s)=>{if(e.content.trim()&&e.imageList.length){const o=e.imageList.map((e=>e));a.push({formDataIndex:s,images:o})}})),new Promise(((s,o)=>{Promise.all(a.map(((s,a)=>new Promise(((o,t)=>{p(s.images).then((s=>{e.formData[a].uploaded=s,o(s)})).catch(t)}))))).then(s,o)}))}}},[["render",function(e,p,L,b,D,k){const I=f,x=c,v=h,C=_;return D.isLoading?l("",!0):(s(),a(x,{key:0,class:"container",style:t(e.appThemeStyle)},{default:o((()=>[i(x,{class:"goods-list"},{default:o((()=>[(s(!0),d(r,null,n(D.goodsList,((e,t)=>(s(),a(x,{class:"goods-item",key:t},{default:o((()=>[i(x,{class:"goods-main"},{default:o((()=>[i(x,{class:"goods-image"},{default:o((()=>[i(I,{class:"image",src:e.goods_image,mode:"scaleToFill"},null,8,["src"])])),_:2},1024),i(x,{class:"goods-content"},{default:o((()=>[i(x,{class:"goods-title"},{default:o((()=>[i(v,{class:"twoline-hide"},{default:o((()=>[g(u(e.goods_name),1)])),_:2},1024)])),_:2},1024),i(x,{class:"goods-props clearfix"},{default:o((()=>[(s(!0),d(r,null,n(e.goods_props,((e,t)=>(s(),a(x,{class:"goods-props-item",key:t},{default:o((()=>[i(v,null,{default:o((()=>[g(u(e.value.name),1)])),_:2},1024)])),_:2},1024)))),128))])),_:2},1024)])),_:2},1024),i(x,{class:"goods-trade"},{default:o((()=>[i(x,{class:"goods-price"},{default:o((()=>[i(v,{class:"unit"},{default:o((()=>[g("¥")])),_:1}),i(v,{class:"value"},{default:o((()=>[g(u(e.goods_price),1)])),_:2},1024)])),_:2},1024),i(x,{class:"goods-num"},{default:o((()=>[i(v,null,{default:o((()=>[g("×"+u(e.total_num),1)])),_:2},1024)])),_:2},1024)])),_:2},1024)])),_:2},1024),i(x,{class:"score-row"},{default:o((()=>[i(x,{class:m(["score-item score-praise",{active:10==D.formData[t].score}]),onClick:e=>k.setScore(t,10)},{default:o((()=>[i(x,{class:"score"},{default:o((()=>[i(v,{class:"score-icon iconfont icon-haoping"}),i(v,{class:"score-text"},{default:o((()=>[g("好评")])),_:1})])),_:1})])),_:2},1032,["class","onClick"]),i(x,{class:m(["score-item score-review",{active:20==D.formData[t].score}]),onClick:e=>k.setScore(t,20)},{default:o((()=>[i(x,{class:"score"},{default:o((()=>[i(v,{class:"score-icon iconfont icon-zhongping"}),i(v,{class:"score-text"},{default:o((()=>[g("中评")])),_:1})])),_:1})])),_:2},1032,["class","onClick"]),i(x,{class:m(["score-item score-negative",{active:30==D.formData[t].score}]),onClick:e=>k.setScore(t,30)},{default:o((()=>[i(x,{class:"score"},{default:o((()=>[i(v,{class:"score-icon iconfont icon-chaping"}),i(v,{class:"score-text"},{default:o((()=>[g("差评")])),_:1})])),_:1})])),_:2},1032,["class","onClick"])])),_:2},1024),i(x,{class:"form-content"},{default:o((()=>[i(C,{class:"textarea",modelValue:D.formData[t].content,"onUpdate:modelValue":e=>D.formData[t].content=e,maxlength:"500",placeholder:"请输入评价内容 (留空则不评价)"},null,8,["modelValue","onUpdate:modelValue"])])),_:2},1024),i(x,{class:"image-list"},{default:o((()=>[(s(!0),d(r,null,n(D.formData[t].imageList,((e,l)=>(s(),a(x,{class:"image-preview",key:l},{default:o((()=>[i(v,{class:"image-delete iconfont icon-shanchu",onClick:e=>k.deleteImage(t,l)},null,8,["onClick"]),i(I,{class:"image",mode:"aspectFill",src:e.path},null,8,["src"])])),_:2},1024)))),128)),!D.formData[t].imageList||D.formData[t].imageList.length<D.maxImageLength?(s(),a(x,{key:0,class:"image-picker",onClick:e=>k.chooseImage(t)},{default:o((()=>[i(v,{class:"choose-icon iconfont icon-camera"}),i(v,{class:"choose-text"},{default:o((()=>[g("上传图片")])),_:1})])),_:2},1032,["onClick"])):l("",!0)])),_:2},1024)])),_:2},1024)))),128))])),_:1}),i(x,{class:"footer-fixed"},{default:o((()=>[i(x,{class:"btn-wrapper"},{default:o((()=>[i(x,{class:m(["btn-item btn-item-main",{disabled:D.disabled}]),onClick:p[0]||(p[0]=e=>k.handleSubmit())},{default:o((()=>[g("确认提交")])),_:1},8,["class"])])),_:1})])),_:1})])),_:1},8,["style"]))}],["__scopeId","data-v-f8bbc17f"]]);export{k as default};