89 lines
3.0 KiB
JavaScript
89 lines
3.0 KiB
JavaScript
"use strict";
|
|
const common_vendor = require("../../common/vendor.js");
|
|
const api_user = require("../../api/user.js");
|
|
const utils_helper = require("../../utils/helper.js");
|
|
if (!Array) {
|
|
const _easycom_nut_icon2 = common_vendor.resolveComponent("nut-icon");
|
|
const _easycom_nut_avatar2 = common_vendor.resolveComponent("nut-avatar");
|
|
const _easycom_nut_button2 = common_vendor.resolveComponent("nut-button");
|
|
(_easycom_nut_icon2 + _easycom_nut_avatar2 + _easycom_nut_button2)();
|
|
}
|
|
const _easycom_nut_icon = () => "../../uni_modules/nutui-uni/components/icon/icon.js";
|
|
const _easycom_nut_avatar = () => "../../uni_modules/nutui-uni/components/avatar/avatar.js";
|
|
const _easycom_nut_button = () => "../../uni_modules/nutui-uni/components/button/button.js";
|
|
if (!Math) {
|
|
(_easycom_nut_icon + _easycom_nut_avatar + _easycom_nut_button)();
|
|
}
|
|
const _sfc_main = {
|
|
__name: "index",
|
|
setup(__props) {
|
|
const code = common_vendor.ref("");
|
|
const redirect_url = common_vendor.ref("");
|
|
common_vendor.onLoad((options) => {
|
|
redirect_url.value = options.redirect_url;
|
|
});
|
|
common_vendor.onMounted(() => {
|
|
common_vendor.index.login({
|
|
provider: "weixin",
|
|
success(res) {
|
|
if (res.errMsg === "login:ok") {
|
|
code.value = res.code;
|
|
}
|
|
}
|
|
});
|
|
});
|
|
const getUserInfo = (res) => {
|
|
if (code.value === "") {
|
|
common_vendor.index.showToast({
|
|
icon: "none",
|
|
title: "请稍后再试"
|
|
});
|
|
return;
|
|
}
|
|
api_user.login(code.value, JSON.stringify(res.detail.userInfo)).then((res2) => {
|
|
common_vendor.index.__f__("log", "at pages/login/index.vue:63", res2);
|
|
common_vendor.index.setStorageSync("token", res2.token);
|
|
common_vendor.index.setStorageSync("uid", res2.user_id);
|
|
if (res2.is_bind_phone) {
|
|
utils_helper.navigateTo("/pages/login/phoneAuthorization");
|
|
return;
|
|
}
|
|
common_vendor.index.showToast({
|
|
title: "授权成功",
|
|
icon: "none"
|
|
});
|
|
if (redirect_url.value !== "undefined") {
|
|
utils_helper.navigateTo(redirect_url.value);
|
|
} else {
|
|
common_vendor.index.navigateBack();
|
|
}
|
|
});
|
|
};
|
|
return (_ctx, _cache) => {
|
|
return {
|
|
a: common_vendor.p({
|
|
size: "30",
|
|
name: "my"
|
|
}),
|
|
b: common_vendor.p({
|
|
size: "80"
|
|
}),
|
|
c: common_vendor.o(getUserInfo),
|
|
d: common_vendor.p({
|
|
type: "success",
|
|
size: "large",
|
|
["open-type"]: "getUserInfo"
|
|
}),
|
|
e: common_vendor.o(($event) => common_vendor.unref(utils_helper.switchTab)("/pages/index/index")),
|
|
f: common_vendor.p({
|
|
type: "danger",
|
|
size: "large"
|
|
})
|
|
};
|
|
};
|
|
}
|
|
};
|
|
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-d08ef7d4"]]);
|
|
wx.createPage(MiniProgramPage);
|
|
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/login/index.js.map
|