login.js
2.6 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
"use strict";
var common_vendor = require("../../common/vendor.js");
var api_index = require("../../api/index.js");
require("../../utils/request.js");
const _sfc_main = {
setup(__props) {
const agreeStatus = common_vendor.ref(false);
const code = common_vendor.ref("");
common_vendor.onLoad(() => {
if (common_vendor.index.getStorageSync("token")) {
common_vendor.index.reLaunch({
url: "/pages/index/index"
});
}
});
common_vendor.onShow(() => {
getCode();
});
const login = () => {
if (!agreeStatus.value)
return common_vendor.index.showToast({
title: "\u8BF7\u52FE\u9009\u534F\u8BAE",
icon: "none"
});
};
const getphonenumber = (e) => {
if (e.detail.errMsg == "getPhoneNumber:fail user deny") {
common_vendor.index.showToast({
title: "\u60A8\u5DF2\u53D6\u6D88\u6388\u6743",
icon: "none"
});
} else {
getLogins(e.detail.encryptedData, e.detail.iv);
}
};
const getCode = () => {
common_vendor.index.login({
provider: "weixin",
success: function(loginRes) {
console.log(loginRes);
code.value = loginRes.code;
}
});
};
const getLogins = async (data, iv) => {
try {
let params = {
code: code.value,
encryptedData: data,
iv
};
const res = await api_index.getLogin(params);
common_vendor.index.setStorageSync("token", res.token);
common_vendor.index.setStorageSync("userInfo", res);
common_vendor.index.reLaunch({ url: "/pages/index/index" });
console.log("getLogin", res);
} catch (err) {
console.log("getLogin", err);
}
};
const toRichText = (e) => {
common_vendor.index.navigateTo({
url: `/pages/richText/richText?type=${e}`
});
};
const agree = () => {
agreeStatus.value = !agreeStatus.value;
};
return (_ctx, _cache) => {
return common_vendor.e({
a: !agreeStatus.value
}, !agreeStatus.value ? {
b: common_vendor.o(login)
} : {
c: common_vendor.o(getphonenumber)
}, {
d: !agreeStatus.value
}, !agreeStatus.value ? {} : {}, {
e: common_vendor.o(agree),
f: common_vendor.o(($event) => toRichText(4)),
g: common_vendor.o(($event) => toRichText(5))
});
};
}
};
var MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__file", "D:/vue/\u5927\u5065\u5EB7\u5546\u57CE/healthMall/pages/login/login.vue"]]);
wx.createPage(MiniProgramPage);