123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226 |
- "use strict";
- const common_vendor = require("../../common/vendor.js");
- const sheep_index = require("../../sheep/index.js");
- const sheep_hooks_useGoods = require("../../sheep/hooks/useGoods.js");
- const sheep_api_pay_order = require("../../sheep/api/pay/order.js");
- const sheep_api_pay_channel = require("../../sheep/api/pay/channel.js");
- const sheep_platform_pay = require("../../sheep/platform/pay.js");
- require("../../sheep/api/index.js");
- require("../../sheep/api/distri/score.js");
- require("../../sheep/request/index.js");
- require("../../sheep/config/index.js");
- require("../../sheep/store/index.js");
- require("../../sheep/store/app.js");
- require("../../sheep/api/promotion/diy.js");
- require("../../sheep/platform/index.js");
- require("../../sheep/platform/provider/wechat/index.js");
- require("../../sheep/platform/provider/wechat/miniProgram.js");
- require("../../sheep/api/member/auth.js");
- require("../../sheep/api/member/social.js");
- require("../../sheep/api/member/user.js");
- require("../../sheep/platform/provider/apple/index.js");
- require("../../sheep/platform/share.js");
- require("../../sheep/router/index.js");
- require("../../sheep/hooks/useModal.js");
- require("../../sheep/helper/index.js");
- require("../../sheep/helper/test.js");
- require("../../sheep/helper/digit.js");
- require("../../sheep/api/member/signin.js");
- require("../../sheep/helper/throttle.js");
- require("../../sheep/url/index.js");
- require("../../sheep/store/user.js");
- require("../../sheep/store/cart.js");
- require("../../sheep/api/trade/cart.js");
- require("../../sheep/api/pay/wallet.js");
- require("../../sheep/api/trade/order.js");
- require("../../sheep/api/promotion/coupon.js");
- require("../../sheep/store/sys.js");
- require("../../sheep/store/modal.js");
- require("../../sheep/api/distri/share.js");
- require("../../sheep/api/distri/team.js");
- require("../../sheep/api/infra/file.js");
- require("../../sheep/api/member/address.js");
- require("../../sheep/api/member/point.js");
- require("../../sheep/api/migration/app.js");
- require("../../sheep/api/migration/chat.js");
- require("../../sheep/api/migration/index.js");
- require("../../sheep/api/migration/third.js");
- require("../../sheep/api/product/category.js");
- require("../../sheep/api/product/comment.js");
- require("../../sheep/api/product/favorite.js");
- require("../../sheep/api/product/history.js");
- require("../../sheep/api/product/spu.js");
- require("../../sheep/api/promotion/activity.js");
- require("../../sheep/api/promotion/article.js");
- require("../../sheep/api/promotion/bargain.js");
- require("../../sheep/api/promotion/combination.js");
- require("../../sheep/api/promotion/rewardActivity.js");
- require("../../sheep/api/promotion/seckill.js");
- require("../../sheep/api/system/area.js");
- require("../../sheep/api/system/voice.js");
- require("../../sheep/api/trade/afterSale.js");
- require("../../sheep/api/trade/brokerage.js");
- require("../../sheep/api/trade/config.js");
- require("../../sheep/api/trade/delivery.js");
- require("../../sheep/config/zIndex.js");
- require("../../sheep/util/index.js");
- if (!Array) {
- const _easycom_s_layout2 = common_vendor.resolveComponent("s-layout");
- _easycom_s_layout2();
- }
- const _easycom_s_layout = () => "../../sheep/components/s-layout/s-layout.js";
- if (!Math) {
- _easycom_s_layout();
- }
- const _sfc_main = {
- __name: "index",
- setup(__props) {
- const userWallet = common_vendor.computed(() => sheep_index.sheep.$store("user").userWallet);
- const state = common_vendor.reactive({
- orderType: "goods",
- // 订单类型; goods - 商品订单, recharge - 充值订单
- orderInfo: {},
- // 支付单信息
- payStatus: 0,
- // 0=检测支付环境, -2=未查询到支付单信息, -1=支付已过期, 1=待支付,2=订单已支付
- payMethods: [],
- // 可选的支付方式
- payment: ""
- // 选中的支付方式
- });
- const onPay = () => {
- if (state.payment === "") {
- sheep_index.sheep.$helper.toast("请选择支付方式");
- return;
- }
- if (state.payment === "wallet") {
- common_vendor.index.showModal({
- title: "提示",
- content: "确定要支付吗?",
- success: function(res) {
- if (res.confirm) {
- sheep_index.sheep.$platform.pay(state.payment, state.orderType, state.orderInfo.id);
- }
- }
- });
- } else {
- sheep_index.sheep.$platform.pay(state.payment, state.orderType, state.orderInfo.id);
- }
- };
- const payDescText = common_vendor.computed(() => {
- if (state.payStatus === 2) {
- return "该订单已支付";
- }
- if (state.payStatus === 1) {
- const time = sheep_hooks_useGoods.useDurationTime(state.orderInfo.expireTime);
- if (time.ms <= 0) {
- state.payStatus = -1;
- return "";
- }
- return `剩余支付时间 ${time.h}:${time.m}:${time.s} `;
- }
- if (state.payStatus === -2) {
- return "未查询到支付单信息";
- }
- return "";
- });
- function checkPayStatus() {
- if (state.orderInfo.status === 10 || state.orderInfo.status === 20) {
- state.payStatus = 2;
- return;
- }
- if (state.orderInfo.status === 30) {
- state.payStatus = -1;
- return;
- }
- state.payStatus = 1;
- }
- function onTapPay(e) {
- state.payment = e.detail.value;
- }
- async function setOrder(id) {
- const { data, code } = await sheep_api_pay_order.PayOrderApi.getOrder(id);
- if (code !== 0 || !data) {
- state.payStatus = -2;
- return;
- }
- state.orderInfo = data;
- await setPayMethods();
- checkPayStatus();
- }
- async function setPayOrder(id) {
- const { data, code } = await sheep_api_pay_order.PayOrderApi.getPayOrder(id);
- if (code !== 0 || !data) {
- state.payStatus = -2;
- return;
- }
- state.orderInfo = data;
- await setPayMethods();
- checkPayStatus();
- }
- async function setPayMethods() {
- const { data, code } = await sheep_api_pay_channel.PayChannelApi.getEnableChannelCodeList(state.orderInfo.appId);
- if (code !== 0) {
- return;
- }
- state.payMethods = sheep_platform_pay.getPayMethods(data);
- }
- common_vendor.onLoad((options) => {
- if (sheep_index.sheep.$platform.name === "WechatOfficialAccount" && sheep_index.sheep.$platform.os === "ios" && !sheep_index.sheep.$platform.landingPage.includes("pages/pay/index")) {
- location.reload();
- return;
- }
- console.log(options);
- let id = options.id;
- if (options.orderType) {
- state.orderType = options.orderType;
- }
- if (options.openType == 2) {
- setPayOrder(id);
- } else {
- console.log(123);
- setOrder(id);
- }
- sheep_index.sheep.$store("user").getWallet();
- });
- return (_ctx, _cache) => {
- return common_vendor.e({
- a: common_vendor.t(common_vendor.unref(sheep_hooks_useGoods.fen2yuan)(state.orderInfo.price)),
- b: common_vendor.t(payDescText.value),
- c: common_vendor.f(state.payMethods, (item, k0, i0) => {
- return common_vendor.e({
- a: item.disabled
- }, item.disabled ? {
- b: common_vendor.unref(sheep_index.sheep).$url.static("/static/img/shop/pay/cod_disabled.png")
- } : {
- c: common_vendor.unref(sheep_index.sheep).$url.static(item.icon)
- }, {
- d: common_vendor.t(item.title),
- e: item.value === "wallet"
- }, item.value === "wallet" ? {
- f: common_vendor.t(common_vendor.unref(sheep_hooks_useGoods.fen2yuan)(userWallet.value.balance))
- } : {}, {
- g: item.value,
- h: item.disabled,
- i: state.payment === item.value,
- j: item.disabled ? 1 : "",
- k: item.title
- });
- }),
- d: common_vendor.o(onTapPay),
- e: state.payStatus === 0
- }, state.payStatus === 0 ? {} : state.payStatus === -1 ? {} : {
- g: common_vendor.o(onPay),
- h: state.payStatus !== 1,
- i: state.payStatus !== 1 ? 1 : ""
- }, {
- f: state.payStatus === -1,
- j: common_vendor.p({
- title: "收银台"
- })
- });
- };
- }
- };
- const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-d7fd7b38"], ["__file", "D:/zx/mall-front-app/pages/pay/index.vue"]]);
- wx.createPage(MiniProgramPage);
|