63 lines
1.8 KiB
JavaScript
63 lines
1.8 KiB
JavaScript
"use strict";
|
|
const common_vendor = require("../../common/vendor.js");
|
|
const comm_api = require("../../comm/api.js");
|
|
const utils_Auth = require("../../utils/Auth.js");
|
|
require("../../utils/http.js");
|
|
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) {
|
|
console.log(e.code);
|
|
try {
|
|
const resp = await comm_api.loginByCode({
|
|
code: e.code
|
|
});
|
|
console.log(resp, "resp");
|
|
common_vendor.index.showToast({
|
|
icon: "none",
|
|
title: "登录成功"
|
|
});
|
|
utils_Auth.setToken(resp.token);
|
|
setTimeout(() => {
|
|
common_vendor.index.switchTab({
|
|
url: "/pages/user/user"
|
|
});
|
|
}, 800);
|
|
} catch (err) {
|
|
console.log(err, "errorCatch");
|
|
common_vendor.index.showToast({
|
|
icon: "none",
|
|
title: "登录失败"
|
|
});
|
|
}
|
|
},
|
|
fail(err) {
|
|
console.log(err, "error");
|
|
}
|
|
});
|
|
}
|
|
return (_ctx, _cache) => {
|
|
return {
|
|
a: common_vendor.o(login),
|
|
b: common_vendor.p({
|
|
type: "primary",
|
|
text: "登录"
|
|
})
|
|
};
|
|
};
|
|
}
|
|
};
|
|
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__file", "C:/Users/33043/Desktop/文件/work/newStud学习/greenStu/pages/user/login.vue"]]);
|
|
wx.createPage(MiniProgramPage);
|