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.
2 lines
5.5 KiB
2 lines
5.5 KiB
11 months ago
|
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,k as m,f as g,t as u,g as f,l as h,a3 as _}from"./index-4ddb689d.js";import{i as p}from"./upload.3f305180.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}]),on
|