68 lines
2.3 KiB
JavaScript
68 lines
2.3 KiB
JavaScript
|
"use strict";
|
||
|
const common_vendor = require("../../common/vendor.js");
|
||
|
const _sfc_main = {
|
||
|
__name: "index",
|
||
|
setup(__props) {
|
||
|
const amount = common_vendor.ref("");
|
||
|
const loading = common_vendor.ref(false);
|
||
|
const statusMessage = common_vendor.ref("");
|
||
|
const diaoqu = () => {
|
||
|
const urlpost = `${saveurl.value}/weiXinPay/native`;
|
||
|
const payload = {
|
||
|
title: "测试",
|
||
|
openId: openid.value,
|
||
|
amountPrice: amount.value
|
||
|
};
|
||
|
common_vendor.index.__f__("log", "at pages/pay/index.vue:71", "???/", payload);
|
||
|
fetch(urlpost, {
|
||
|
method: "POST",
|
||
|
headers: {
|
||
|
"Content-Type": "application/json"
|
||
|
},
|
||
|
body: JSON.stringify(payload)
|
||
|
}).then((res) => res.json()).then((data) => {
|
||
|
common_vendor.index.__f__("log", "at pages/pay/index.vue:82", "???", data);
|
||
|
}).catch((err) => {
|
||
|
common_vendor.index.__f__("error", "at pages/pay/index.vue:85", "请求失败:", err);
|
||
|
});
|
||
|
};
|
||
|
const saveurl = common_vendor.ref("");
|
||
|
const openid = common_vendor.ref("");
|
||
|
function initiatePayment() {
|
||
|
if (!amount.value)
|
||
|
return;
|
||
|
loading.value = true;
|
||
|
statusMessage.value = "拉起微信支付...";
|
||
|
common_vendor.index.getStorage({
|
||
|
key: "serverUrl",
|
||
|
success: function(res) {
|
||
|
common_vendor.index.__f__("log", "at pages/pay/index.vue:97", "读取缓存:", res.data.url);
|
||
|
saveurl.value = res.data.url;
|
||
|
}
|
||
|
});
|
||
|
common_vendor.index.getStorage({
|
||
|
key: "openid",
|
||
|
success: function(res) {
|
||
|
common_vendor.index.__f__("log", "at pages/pay/index.vue:105", "读取缓存:", res.data.openid);
|
||
|
openid.value = res.data.openid;
|
||
|
}
|
||
|
});
|
||
|
diaoqu();
|
||
|
}
|
||
|
return (_ctx, _cache) => {
|
||
|
return common_vendor.e({
|
||
|
a: amount.value,
|
||
|
b: common_vendor.o(($event) => amount.value = $event.detail.value),
|
||
|
c: common_vendor.o(initiatePayment),
|
||
|
d: loading.value || !amount.value,
|
||
|
e: statusMessage.value
|
||
|
}, statusMessage.value ? {
|
||
|
f: common_vendor.t(statusMessage.value)
|
||
|
} : {});
|
||
|
};
|
||
|
}
|
||
|
};
|
||
|
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-d7fd7b38"]]);
|
||
|
wx.createPage(MiniProgramPage);
|
||
|
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/pay/index.js.map
|