api
This commit is contained in:
87
unpackage/dist/dev/mp-weixin/pages/login/login.js
vendored
Normal file
87
unpackage/dist/dev/mp-weixin/pages/login/login.js
vendored
Normal file
@@ -0,0 +1,87 @@
|
||||
"use strict";
|
||||
const common_vendor = require("../../common/vendor.js");
|
||||
const components_request = require("../../components/request.js");
|
||||
const components_debug_GenerateTestUserSig = require("../../components/debug/GenerateTestUserSig.js");
|
||||
const _sfc_main = {
|
||||
data() {
|
||||
return {
|
||||
userInfo: {},
|
||||
info: {}
|
||||
};
|
||||
},
|
||||
onLoad() {
|
||||
common_vendor.index.getUserInfo({
|
||||
provider: "weixin",
|
||||
success: (res) => {
|
||||
this.userInfo = res.userInfo;
|
||||
}
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
// 获取手机号
|
||||
async getPhoneNumber(e) {
|
||||
common_vendor.index.showLoading({
|
||||
title: "登录中...",
|
||||
mask: true
|
||||
});
|
||||
try {
|
||||
const res = await components_request.request({
|
||||
url: "/user/loginWithPhoneNumber",
|
||||
method: "POST",
|
||||
data: {
|
||||
code: e.detail.code
|
||||
},
|
||||
userInfo: false
|
||||
});
|
||||
common_vendor.index.__f__("log", "at pages/login/login.vue:46", "登录结果:", res);
|
||||
this.info = res;
|
||||
if (this.info.code === 200) {
|
||||
if (this.info.data.newAccount) {
|
||||
const sdkAppID = Number(this.info.data.chatInfo.appId);
|
||||
const userID = "administrator";
|
||||
const { userSig } = components_debug_GenerateTestUserSig.genTestUserSig({
|
||||
SDKAPPID: sdkAppID,
|
||||
SECRETKEY: this.info.data.chatInfo.appKey,
|
||||
userID
|
||||
});
|
||||
common_vendor.index.setStorageSync("userSig", userSig);
|
||||
common_vendor.index.setStorageSync("userinfo", this.info.data.info);
|
||||
common_vendor.index.reLaunch({
|
||||
url: "/pages/UserInformation/UserInformation"
|
||||
});
|
||||
} else {
|
||||
common_vendor.index.setStorageSync("userinfo", this.info.data.info);
|
||||
common_vendor.index.hideLoading();
|
||||
common_vendor.index.navigateBack({
|
||||
delta: 1
|
||||
// 返回层级(默认值为 1)
|
||||
});
|
||||
}
|
||||
} else {
|
||||
common_vendor.index.showToast({
|
||||
title: "登录失败",
|
||||
icon: "none"
|
||||
});
|
||||
}
|
||||
} catch (err) {
|
||||
common_vendor.index.__f__("error", "at pages/login/login.vue:87", "登录错误:", err);
|
||||
common_vendor.index.showToast({
|
||||
title: "请检查网络连接",
|
||||
icon: "none"
|
||||
});
|
||||
} finally {
|
||||
common_vendor.index.hideLoading();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
||||
return {
|
||||
a: $data.userInfo.avatarUrl,
|
||||
b: common_vendor.t($data.userInfo.nickName),
|
||||
c: common_vendor.o$1((...args) => $options.getPhoneNumber && $options.getPhoneNumber(...args))
|
||||
};
|
||||
}
|
||||
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render]]);
|
||||
wx.createPage(MiniProgramPage);
|
||||
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/login/login.js.map
|
||||
Reference in New Issue
Block a user