acdr-ui/dist/build/mp-weixin/modules/pet/push/door.js
2024-10-01 09:15:35 +08:00

2 lines
4.0 KiB
JavaScript

"use strict";var e=(e,t,a)=>new Promise(((o,l)=>{var u=e=>{try{n(a.next(e))}catch(t){l(t)}},s=e=>{try{n(a.throw(e))}catch(t){l(t)}},n=e=>e.done?o(e.value):Promise.resolve(e.value).then(u,s);n((a=a.apply(e,t)).next())}));const t=require("../../../common/vendor.js"),a=require("../../../utils/http.js"),o=require("../../../utils/commUtils.js");require("../../../utils/map-utils.js"),require("../../../store/index.js");const l=require("../../../service/auth.js"),u=require("../../../store/user.js");if(!Array){t.resolveComponent("layout-default-uni")()}Math||s();const s=()=>"../../../components/Map.js",n={__name:"door",setup(s){let n=null;const i=t.ref(null),r=t.ref(!!i.value),v=t.ref(""),d=t.ref(["宠物看护","宠物洗澡","宠物训练","宠物寄养"]),c=t.ref(0),p=t.ref(""),h=t.ref(0),f=t.ref(""),m=t.ref(!0),y=t.ref([]),x=t.ref(!0),g=t.ref({}),w=t.ref({}),P=u.useUserStore();t.onLoad((t=>e(this,null,(function*(){t.id&&(i.value=t.id,yield C())})))),t.onShow((()=>e(this,null,(function*(){yield b()}))));const j=e=>{const t=e.detail.value;c.value=t},b=()=>e(this,null,(function*(){if(!P.userInfo.isRealName){o.toast("您还未实名认证,请先实名认证!");try{const e=yield l.isBindPhone();if(200!=e.code||!e.data)return o.toast("您手机号还未绑定!"),void t.index.navigateTo({url:"/modules/pet/permission/bind-phone"})}catch(e){}return o.toast("请先实名认证!"),void t.index.navigateTo({url:"/modules/pet/permission/real-name-auth"})}P.userInfo.isPetNursery||o.toPath("/modules/pet/certification/index")})),q=e=>{x.value=!1,w.value=e,f.value=w.value.formatted_address,g.value=w.value.location},C=()=>e(this,null,(function*(){try{const e=yield a.httpPost("/personal-service/get",{id:i.value});if(200==e.code){const t=e.data;v.value=t.serviceName,c.value=d.value.indexOf(t.type),p.value=t.description,h.value=t.price,f.value=t.serviceHost,m.value=1===t.state,y.value=[t.url],g.value={latitude:t.latitude,longitude:t.longitude,address:t.address}}}catch(e){t.index.showToast({title:"获取服务数据失败",icon:"none"})}})),T=e=>{h.value=Math.max(h.value+e,0)},N=e=>{n=setInterval((()=>{T(e?10:-10)}),200)},_=()=>{clearInterval(n)},I=e=>{m.value=e.value},M=()=>{t.index.chooseImage({count:1,success:t=>e(this,null,(function*(){for(const e of t.tempFilePaths){const t=yield U(e);t&&(y.value.pop(),y.value.push(t))}})),fail:()=>{t.index.showToast({title:"图片选择失败",icon:"none"})}})},U=o=>e(this,null,(function*(){try{const e=yield a.httpUploadFile("/file/upload",o);return e&&e.data&&e.data.url?e.data.url:(t.index.showToast({title:"图片上传失败",icon:"none"}),"")}catch(e){return t.index.showToast({title:"图片上传失败",icon:"none"}),""}})),F=()=>{const e={id:i.value,serviceName:v.value,type:d.value[c.value],description:p.value,price:h.value,serviceHost:f.value,state:m.value?1:0,url:y.value[0],address:f.value,latitude:`${g.value.latitude}`,longitude:`${g.value.longitude}`,country:w.value.addressComponent.country,province:w.value.addressComponent.province,city:w.value.addressComponent.city,district:w.value.addressComponent.district,township:w.value.addressComponent.township,streetNumber:w.value.addressComponent.streetNumber.street+w.value.addressComponent.streetNumber.number},l=r.value?"/personal-service/update":"/personal-service/push";a.httpPost(l,e).then((e=>{200===e.code?(t.index.showToast({title:r.value?"更新成功":"发布成功",icon:"success"}),o.toPath(-1)):t.index.showToast({title:r.value?"更新失败":"发布失败:"+e.msg,icon:"none"})}))};return(e,a)=>t.e({a:v.value,b:t.o((e=>v.value=e.detail.value)),c:t.t(d.value[c.value]),d:d.value,e:t.o(j),f:p.value,g:t.o((e=>p.value=e.detail.value)),h:t.o((e=>N(!1))),i:t.o(_),j:t.o((e=>T(1))),k:h.value,l:t.o((e=>h.value=e.detail.value)),m:t.o((e=>N(!0))),n:t.o(_),o:t.o((e=>T(1))),p:t.t(f.value),q:x.value,r:t.o(q),s:m.value,t:t.o(I),v:t.o(M),w:y.value.length>0},y.value.length>0?{x:t.f(y.value,((e,t,a)=>({a:t,b:e})))}:{},{y:t.t(r.value?"更新服务":"发布上门服务"),z:t.o(F)})}},i=t._export_sfc(n,[["__scopeId","data-v-061e6dbf"]]);wx.createPage(i);