checkPayMode.js 2.6 KB
"use strict";const e=require("../common/vendor.js"),p=require("../api/index.js");require("../utils/request.js");Array||e.resolveComponent("u-popup")();const w=()=>"../uni_modules/uview-plus/components/u-popup/u-popup.js";Math||w();const v={__name:"checkPayMode",props:{payParams:{type:Object,default:{}},modeShow:{type:Boolean,default:!1},adressId:{type:String,default:""},totalPrice:{type:String,default:0},balance:{type:String,default:""},isOrderPay:{type:Boolean,default:!1},orderId:{type:String,default:""},carId:{type:String,default:""}},emits:["canclePop"],setup(l,{emit:g}){const a=l;e.onMounted(()=>{setTimeout(()=>{a.totalPrice>+a.balance&&(i[1].shows=!1)},100)}),e.watchEffect(()=>{console.log("余额",a.balance),a.totalPrice<+a.balance&&(i[1].shows=!0)});const i=e.reactive([{id:1,name:"微信支付",check:!0,modeUrl:"/static/shopCarIc/weCaat.png",shows:!0},{id:2,name:"余额支付",check:!1,modeUrl:"/static/shopCarIc/yue.png",shows:!0}]);e.ref(0);let s=e.ref(0),y=o=>{s.value=o};const h=()=>{a.car_Id?(console.log("购物车支付",a.car_Id),_()):(console.log("dindan支付",a.car_Id),a.isOrderPay?P():m())},f=()=>{e.index.navigateTo({url:"/pages/mine/recharge"})},c=()=>{g("canclePop")},{proxy:r}=e.getCurrentInstance(),m=async()=>{try{let{id:o,num:n,specId:t}=a.payParams,d={goods_id:o,num:n,goods_spec_id:t,address_id:a.adressId,fangs:s.value==0?1:2,remark:""};const u=await p.getPay(d);r.$methods.pay(u),c(),s.value===1&&(e.index.showToast({title:"支付成功",icon:"none"}),setTimeout(()=>{e.index.navigateBack()},1500))}catch(o){e.index.showToast({title:o,icon:"none"}),console.log("getPay",o)}},_=async()=>{try{let o={cart_ids:a.car_Id,address_id:a.adressId,remark:"",fangs:s.value==0?1:2};const n=await p.getCarPay(o);r.$methods.pay(n),c(),console.log("getCarPay",n),s.value===1&&r.$methods.showTN("余额支付成功~")}catch(o){e.index.showToast({title:o,icon:"none"}),console.log("getCarPay",o)}},P=async()=>{try{const o=await p.getOrderPay(a.orderId,s.value==0?1:2);r.$methods.pay(o),c(),console.log("getOrderPay",o),s.value===1&&(e.index.showToast({title:"支付成功",icon:"none"}),setTimeout(()=>{e.index.navigateBack()},1500))}catch(o){e.index.showToast({title:o,icon:"none"}),console.log("getOrderPay",o)}};return(o,n)=>({a:e.f(i,(t,d,u)=>e.e({a:t.modeUrl,b:e.t(t.name),c:t.shows},t.shows?{d:e.unref(s)==d?"/static/shopCarIc/modeCheck.png":"/static/shopCarIc/checks.png"}:{e:e.o(f,t.id)},{f:t.id,g:e.o(C=>e.unref(y)(d),t.id)})),b:e.o(h),c:e.o(c),d:e.p({show:l.modeShow,bgColor:"#F6F8FA",closeable:!0,round:"12"})})}},I=e._export_sfc(v,[["__file","D:/vue/大健康商城/healthMall/componets/checkPayMode.vue"]]);wx.createComponent(I);