2 lines
2.7 KiB
JavaScript
2 lines
2.7 KiB
JavaScript
"use strict";var e=(e,t,a)=>new Promise(((r,o)=>{var s=e=>{try{p(a.next(e))}catch(t){o(t)}},n=e=>{try{p(a.throw(e))}catch(t){o(t)}},p=e=>e.done?r(e.value):Promise.resolve(e.value).then(s,n);p((a=a.apply(e,t)).next())}));const t=require("../../../common/vendor.js"),a=require("../sheep/index.js"),r=require("../sheep/hooks/useGoods.js"),o=require("../sheep/api/pay/order.js"),s=require("../sheep/api/pay/channel.js"),n=require("../sheep/platform/pay.js");if(!Array){(t.resolveComponent("s-layout")+t.resolveComponent("layout-default-uni"))()}Math;const p={__name:"index",setup(p){const u=t.computed((()=>a.sheep.$store("user").userWallet)),d=t.reactive({orderType:"goods",orderInfo:{},payStatus:0,payMethods:[],payment:""}),i=()=>{""!==d.payment?"wallet"===d.payment?t.index.showModal({title:"提示",content:"确定要支付吗?",success:function(e){e.confirm&&a.sheep.$platform.pay(d.payment,d.orderType,d.orderInfo.id)}}):a.sheep.$platform.pay(d.payment,d.orderType,d.orderInfo.id):a.sheep.$helper.toast("请选择支付方式")},l=t.computed((()=>{if(2===d.payStatus)return"该订单已支付";if(1===d.payStatus){const e=r.useDurationTime(d.orderInfo.expireTime);return e.ms<=0?(d.payStatus=-1,""):`剩余支付时间 ${e.h}:${e.m}:${e.s} `}return-2===d.payStatus?"未查询到支付单信息":""}));function y(e){d.payment=e.detail.value}function c(t){return e(this,null,(function*(){const{data:a,code:r}=yield o.PayOrderApi.getOrder(t);0===r&&a?(d.orderInfo=a,yield function(){return e(this,null,(function*(){const{data:e,code:t}=yield s.PayChannelApi.getEnableChannelCodeList(d.orderInfo.appId);0===t&&(d.payMethods=n.getPayMethods(e))}))}(),10!==d.orderInfo.status&&20!==d.orderInfo.status?30!==d.orderInfo.status?d.payStatus=1:d.payStatus=-1:d.payStatus=2):d.payStatus=-2}))}return t.onLoad((e=>{if("WechatOfficialAccount"===a.sheep.$platform.name&&"ios"===a.sheep.$platform.os&&!a.sheep.$platform.landingPage.includes("pages/pay/index"))return void location.reload();const t=e.id;e.orderType&&(d.orderType=e.orderType),c(t),a.sheep.$store("user").getWallet()})),(e,o)=>t.e({a:t.t(t.unref(r.fen2yuan)(d.orderInfo.price)),b:t.t(l.value),c:t.f(d.payMethods,((e,o,s)=>t.e({a:e.disabled},e.disabled?{b:t.unref(a.sheep).$url.static("/static/img/shop/pay/cod_disabled.png")}:{c:t.unref(a.sheep).$url.static(e.icon)},{d:t.t(e.title),e:"wallet"===e.value},"wallet"===e.value?{f:t.t(t.unref(r.fen2yuan)(u.value.balance))}:{},{g:e.value,h:e.disabled,i:d.payment===e.value,j:e.disabled?1:"",k:e.title}))),d:t.o(y),e:0===d.payStatus},0===d.payStatus||-1===d.payStatus?{}:{g:t.o(i),h:1!==d.payStatus,i:1!==d.payStatus?1:""},{f:-1===d.payStatus,j:t.p({title:"收银台"})})}},u=t._export_sfc(p,[["__scopeId","data-v-cb67a36a"]]);wx.createPage(u);
|