10.18前的开发
This commit is contained in:
57
unpackage/dist/dev/mp-weixin/pages/user/index.js
vendored
57
unpackage/dist/dev/mp-weixin/pages/user/index.js
vendored
@@ -1,48 +1,41 @@
|
||||
"use strict";
|
||||
const common_vendor = require("../../common/vendor.js");
|
||||
const store_index = require("../../store/index.js");
|
||||
const api_index = require("../../api/index.js");
|
||||
const utils_index = require("../../utils/index.js");
|
||||
require("../../api/index.js");
|
||||
require("../../api/request.js");
|
||||
require("../../config/index.js");
|
||||
const _sfc_main = {
|
||||
__name: "index",
|
||||
setup(__props) {
|
||||
store_index.useStore();
|
||||
function getPhoneNumber(e) {
|
||||
console.log(e);
|
||||
getAccess_token({ code: e.detail.code });
|
||||
}
|
||||
async function getAccess_token(params = {}) {
|
||||
const data = {
|
||||
username: params.code,
|
||||
//手机号按钮获取的code
|
||||
type: "wechat_mini_app",
|
||||
identity: "user",
|
||||
password: "111"
|
||||
};
|
||||
await api_index.API.getToken(data);
|
||||
wx_login();
|
||||
}
|
||||
async function wx_login(token_res) {
|
||||
let res = await new Promise((resolve) => {
|
||||
common_vendor.index.login({
|
||||
provider: "weixin",
|
||||
//使用微信登录
|
||||
success: function(loginRes) {
|
||||
resolve(loginRes);
|
||||
console.log(loginRes, "微信登录返回信息");
|
||||
}
|
||||
});
|
||||
common_vendor.onShow(() => {
|
||||
is_login.value = utils_index.custom.checkLogin();
|
||||
if (is_login.value) {
|
||||
userinfo.value = common_vendor.index.getStorageSync("userInfo");
|
||||
avatar.value = common_vendor.index.getStorageSync("avatarUrl");
|
||||
userinfo.value = JSON.parse(userinfo.value);
|
||||
}
|
||||
});
|
||||
const avatar = common_vendor.ref("");
|
||||
common_vendor.ref(null);
|
||||
const is_login = common_vendor.ref(null);
|
||||
const userinfo = common_vendor.ref(null);
|
||||
function toLogin() {
|
||||
common_vendor.index.navigateTo({
|
||||
url: "/pages/login/login"
|
||||
});
|
||||
let userId = "";
|
||||
await api_index.API.wx_login({ code: res.code }, userId);
|
||||
}
|
||||
return (_ctx, _cache) => {
|
||||
return {
|
||||
a: common_vendor.o(getPhoneNumber)
|
||||
};
|
||||
return common_vendor.e({
|
||||
a: is_login.value ? avatar.value : "../../static/avatar.png",
|
||||
b: common_vendor.t(is_login.value ? userinfo.value.nickname : "未登录"),
|
||||
c: !is_login.value
|
||||
}, !is_login.value ? {
|
||||
d: common_vendor.o(toLogin)
|
||||
} : {});
|
||||
};
|
||||
}
|
||||
};
|
||||
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__file", "F:/项目2023/视力表/vision-record/pages/user/index.vue"]]);
|
||||
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-79e6a490"], ["__file", "F:/项目2023/视力表/vision-record/pages/user/index.vue"]]);
|
||||
wx.createPage(MiniProgramPage);
|
||||
|
||||
Reference in New Issue
Block a user