gree_leran/unpackage/dist/dev/mp-weixin/pages/user/login.js

63 lines
1.8 KiB
JavaScript
Raw Normal View History

2024-06-16 01:04:56 +00:00
"use strict";
const common_vendor = require("../../common/vendor.js");
const comm_api = require("../../comm/api.js");
const utils_Auth = require("../../utils/Auth.js");
2024-06-16 23:47:03 +00:00
require("../../utils/http.js");
2024-06-16 01:04:56 +00:00
if (!Array) {
const _easycom_up_button2 = common_vendor.resolveComponent("up-button");
_easycom_up_button2();
}
const _easycom_up_button = () => "../../node-modules/uview-plus/components/u-button/u-button.js";
if (!Math) {
_easycom_up_button();
}
const _sfc_main = {
__name: "login",
setup(__props) {
async function login() {
common_vendor.index.login({
provider: "weixin",
async success(e) {
2024-06-16 15:32:15 +00:00
console.log(e.code);
2024-06-16 01:04:56 +00:00
try {
const resp = await comm_api.loginByCode({
code: e.code
});
2024-06-16 15:32:15 +00:00
console.log(resp, "resp");
2024-06-16 01:04:56 +00:00
common_vendor.index.showToast({
icon: "none",
title: "登录成功"
});
utils_Auth.setToken(resp.token);
setTimeout(() => {
common_vendor.index.switchTab({
url: "/pages/user/user"
});
}, 800);
} catch (err) {
2024-06-16 15:32:15 +00:00
console.log(err, "errorCatch");
2024-06-16 01:04:56 +00:00
common_vendor.index.showToast({
icon: "none",
title: "登录失败"
});
}
2024-06-16 15:32:15 +00:00
},
fail(err) {
console.log(err, "error");
2024-06-16 01:04:56 +00:00
}
});
}
return (_ctx, _cache) => {
return {
a: common_vendor.o(login),
b: common_vendor.p({
type: "primary",
text: "登录"
})
};
};
}
};
2024-06-16 23:47:03 +00:00
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__file", "C:/Users/33043/Desktop/文件/work/newStud学习/greenStu/pages/user/login.vue"]]);
2024-06-16 01:04:56 +00:00
wx.createPage(MiniProgramPage);