recharge.js
3.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
"use strict";
var common_vendor = require("../../common/vendor.js");
var api_index = require("../../api/index.js");
require("../../utils/request.js");
if (!Array) {
const _easycom_u_navbar2 = common_vendor.resolveComponent("u-navbar");
_easycom_u_navbar2();
}
const _easycom_u_navbar = () => "../../uni_modules/uview-plus/components/u-navbar/u-navbar.js";
if (!Math) {
_easycom_u_navbar();
}
const _sfc_main = {
setup(__props) {
common_vendor.onShow(() => {
getPackages();
getyues();
});
let packageList = common_vendor.ref([]);
let money = common_vendor.ref("");
let cur = common_vendor.ref(0);
let balance = common_vendor.ref(0);
const checkPackage = (item, index) => {
cur.value = index;
};
const rechargeBtn = () => {
let packageMoney = packageList.value[cur.value].money;
getRecharges(money.value == "" ? packageMoney : money.value);
};
const { proxy } = common_vendor.getCurrentInstance();
const getRecharges = async (money2) => {
try {
const res = await api_index.getRecharge(money2);
proxy.$methods.pay(res);
console.log("getRecharge", res);
} catch (err) {
common_vendor.index.showToast({ title: err, icon: "none" });
console.log("getRecharge", err);
}
};
const getPackages = async () => {
try {
const res = await api_index.getPackage();
packageList.value = res;
console.log("getPackage", res);
} catch (err) {
common_vendor.index.showToast({ title: err, icon: "none" });
console.log("getPackage", err);
}
};
const getyues = async () => {
try {
const res = await api_index.getyue();
balance.value = res.money;
common_vendor.index.setStorageSync("balance", res.money);
console.log("getyue", res);
} catch (err) {
common_vendor.index.showToast({ title: err, icon: "none" });
console.log("getyue", err);
}
};
return (_ctx, _cache) => {
return {
a: common_vendor.p({
leftIconColor: "#fff",
placeholder: true,
title: "\u4F1A\u5458\u4E2D\u5FC3",
bgColor: "#1D1E24",
autoBack: true
}),
b: common_vendor.t(common_vendor.unref(balance)),
c: common_vendor.unref(money),
d: common_vendor.o(($event) => common_vendor.isRef(money) ? money.value = $event.detail.value : money = $event.detail.value),
e: common_vendor.f(common_vendor.unref(packageList), (item, index, i0) => {
return {
a: common_vendor.t(item.money),
b: common_vendor.t(item.discount),
c: common_vendor.o(($event) => checkPackage(item, index), item.id),
d: common_vendor.n(common_vendor.unref(cur) == index ? "check" : ""),
e: item.id
};
}),
f: common_vendor.o(rechargeBtn)
};
};
}
};
var MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__file", "D:/vue/\u5927\u5065\u5EB7\u5546\u57CE/healthMall/pages/mine/recharge.vue"]]);
wx.createPage(MiniProgramPage);