"use strict";const e=require("../../common/vendor.js"),n=require("../../common/assets.js"),o=require("../../api/api.js"),t=require("../../store/index.js"),i=require("../../utils/fun.js"),a=require("../../hooks/useNav.js");if(!Array){(e.resolveComponent("up-tag")+e.resolveComponent("up-button")+e.resolveComponent("up-icon")+e.resolveComponent("uni-popup-dialog")+e.resolveComponent("uni-popup"))()}Math||((()=>"../../uni_modules/uview-plus/components/u-tag/u-tag.js")+(()=>"../../uni_modules/uview-plus/components/u-button/u-button.js")+(()=>"../../uni_modules/uview-plus/components/u-icon/u-icon.js")+(()=>"../../uni_modules/uni-popup/components/uni-popup-dialog/uni-popup-dialog.js")+(()=>"../../uni_modules/uni-popup/components/uni-popup/uni-popup.js"))();const s={__name:"star",setup(s){const{navTo:r}=a.useNav(),u=e.ref(null);let c=e.reactive({}),l=e.reactive({}),d=e.ref(!1),p=e.ref({}),m=e.ref(""),f=e.ref([]),g=e.ref(null),y=e.ref(1),v=e.reactive({money:30}),h=e.reactive([{id:1,name:"余额支付"}]);e.onLoad((e=>{if(e.q){let n=decodeURIComponent(e.q);n=n.split("?")[1];const o=n?n.split("&"):[],t={};for(let e=0;e{if(e.index.getStorageSync("token")&&m.value){N(m.value);let e=await o.userInfo();l.value=e}}));let x=()=>{d.value=!0,v.money=30==v.money||50==v.money||100==v.money?"":v.money},N=async n=>{let i=await o.gunInfo({deviceNo:n});c=i,(async e=>{let n=await o.userCardUsableList({stationId:e});f.value=n,0==n.length?y.value=1:(y.value=2,g.value=n[0].id,h.find((e=>"电卡支付"==e.name))||h.push({id:2,name:"电卡支付"}))})(i.stationId),p.value=i.currentPrice,console.log(i.deviceNo,"_res.deviceNo"),console.log(i.gunNo,"_res.gunNo"),t.store.commit("setInsertStatus",i.insertStatus),e.index.sendSocketMessage({data:JSON.stringify({command:"sub",deviceNo:i.deviceNo,gunNo:i.gunNo}),success:e=>{console.log("发送成功")},fail:e=>{console.log(e),console.log("发送失败")}})},S=e=>{v.money=e},w=async()=>{e.index.showLoading({title:"启动充电中...",mask:!0}),await o.startChargingByCard({deviceNo:c.deviceNo,gunNo:c.gunNo,amount:v.money,userCardId:g.value})},k=async()=>{e.index.showLoading({title:"启动充电中...",mask:!0});let n=await o.startChargingByAdaPay({deviceNo:c.deviceNo,gunNo:c.gunNo,amount:v.money}),i=n.payInfo;e.index.requestPayment({provider:"wxpay",timeStamp:i.timeStamp,nonceStr:i.nonceStr,package:i.package,signType:i.signType,paySign:i.paySign,success:function(e){t.store.commit("setTransactionNo",n.transactionNo),t.store.commit("setSokStatus",0),b(n)},fail:function(n){e.index.showToast({title:"已取消支付",icon:"none"}),console.log("fail:"+JSON.stringify(n))}})},C=async()=>{e.index.showLoading({title:"启动充电中...",mask:!0});let n=await o.startChargingByWallet({deviceNo:c.deviceNo,gunNo:c.gunNo,amount:v.money});t.store.commit("setTransactionNo",n.transactionNo),t.store.commit("setSokStatus",0),b(n)};const b=n=>{var i=setInterval((async()=>{if(1!=t.store.state.sokStatus){let a=await o.ordersInfo({transactionNo:n.transactionNo});t.store.commit("setDataObj",a),3==a.status&&(e.index.hideLoading(),e.index.navigateTo({url:`/pageOrder/recharge/recharge?transactionNo=${n.transactionNo}&type=order`}),clearTimeout(i),t.store.commit("setSokStatus",0)),-1==a.status&&(e.index.hideLoading(),e.index.showModal({title:"提示",content:"启动失败,请重试",showCancel:!1,confirmText:"确认",success:()=>{}}),clearTimeout(i),t.store.commit("setSokStatus",0)),-2==a.status&&(e.index.hideLoading(),e.index.showModal({title:"提示",content:"启动超时,请重试",showCancel:!1,confirmText:"确认",success:()=>{}}),clearTimeout(i),t.store.commit("setSokStatus",0))}}),5e3)};return(o,a)=>e.e({a:e.t(e.unref(c).stationName),b:e.t(e.unref(c).gunName),c:n._imports_0$6,d:e.o((n=>e.unref(i.copy)(e.unref(c).gunName))),e:e.t(e.unref(c).occupyCostInfo),f:e.t(e.unref(c).parkCostInfo),g:e.p({size:"mini",text:`当前计费时间段:${e.unref(p).startTime}-${e.unref(p).endTime}`,plain:!0,plainFill:!0}),h:e.t(e.unref(p).totalAmount),i:1==e.unref(t.store).state.insertStatus},1==e.unref(t.store).state.insertStatus?{j:e.p({size:"mini",text:"已插枪",plain:!0,plainFill:!0})}:{},{k:e.o((n=>e.unref(r)("/pages/money/recharge"))),l:e.p({type:"primary",size:"small",plain:!0,text:"余额充值"}),m:e.f(e.unref(h),((n,o,t)=>e.e({a:`/static/icon/lie${n.id}.png`,b:e.t(n.name),c:1==n.id},1==n.id?{d:e.t(e.unref(l).balance||0)}:{},{e:o,f:n.id==e.unref(y)?"1rpx solid #4879e6":"",g:e.o((o=>e.isRef(y)?y.value=n.id:y=n.id),o)}))),n:e.p({size:"mini",text:"余额原路退款",plain:!0,plainFill:!0}),o:e.o((n=>{e.unref(v).money=30,e.isRef(d)?d.value=!1:d=!1})),p:"1rpx solid "+(30!=e.unref(v).money||e.unref(d)?"#c5c5c5":"#4879e6"),q:e.o((n=>{e.unref(v).money=50,e.isRef(d)?d.value=!1:d=!1})),r:"1rpx solid "+(50!=e.unref(v).money||e.unref(d)?"#c5c5c5":"#4879e6"),s:e.o((n=>{e.unref(v).money=100,e.isRef(d)?d.value=!1:d=!1})),t:"1rpx solid "+(100!=e.unref(v).money||e.unref(d)?"#c5c5c5":"#4879e6"),v:e.unref(d)},e.unref(d)?{w:e.unref(v).money,x:e.o((n=>e.unref(v).money=n.detail.value))}:{},{y:e.o(((...n)=>e.unref(x)&&e.unref(x)(...n))),z:"1rpx solid "+(e.unref(d)?"#4879e6":"#c5c5c5"),A:2==e.unref(y)},2==e.unref(y)?{B:e.f(e.unref(f),((n,o,t)=>e.e({a:e.unref(g)==n.id},e.unref(g)==n.id?{b:"2dd6a3c8-4-"+t,c:e.p({name:"checkbox-mark",color:"#fff"})}:{},{d:e.t(n.name),e:e.t(n.cardNo),f:e.t(n.balance),g:e.o((o=>e.isRef(g)?g.value=n.id:g=n.id),o),h:o})))}:{},{C:e.t(e.unref(p).totalAmount),D:!e.unref(y)},e.unref(y)?{}:{E:e.p({customStyle:{height:"80rpx",width:"230rpx"},disabled:!0,color:"#4879e6",text:"请选择支付方式",shape:"circle"})},{F:1==e.unref(y)},1==e.unref(y)?{G:e.o(e.unref(C)),H:e.p({customStyle:{height:"80rpx",width:"280rpx"},color:"#4879e6",shape:"circle",text:"启动充电"})}:{},{I:3==e.unref(y)},3==e.unref(y)?{J:e.o(e.unref(k)),K:e.p({customStyle:{height:"80rpx",width:"280rpx"},color:"#4879e6",shape:"circle",text:`预付${e.unref(v).money}元,启动充电`})}:{},{L:2==e.unref(y)},2==e.unref(y)?{M:e.o(e.unref(w)),N:e.p({customStyle:{height:"80rpx",width:"280rpx"},disabled:!e.unref(g),color:"#4879e6",text:e.unref(g)?"启动充电":"请选择电卡",shape:"circle"})}:{},{O:e.sr("inputClose","2dd6a3c8-10,2dd6a3c8-9"),P:e.o(e.unref(S)),Q:e.p({mode:"input",title:"请输入预付金额",value:e.unref(v).money,placeholder:"请输入内容"}),R:e.sr(u,"2dd6a3c8-9",{k:"inputDialog"}),S:e.p({type:"dialog"})})}};wx.createPage(s);