Files
tk-mini-program/unpackage/dist/dev/mp-weixin/pages/UserInformation/UserInformation.js
pengxiaolong 36a240f854 优化
2025-06-23 22:00:46 +08:00

125 lines
3.8 KiB
JavaScript

"use strict";
const common_vendor = require("../../common/vendor.js");
const components_request = require("../../components/request.js");
const components_postFile = require("../../components/postFile.js");
const components_generateFileName = require("../../components/generateFileName.js");
const stores_counter = require("../../stores/counter.js");
const counter = stores_counter.useCounterStore();
const _sfc_main = {
inject: ["$global"],
data() {
return {
userinfo: "",
name: "",
id: "",
info: {},
userSig: "",
lastPage: "",
picture: "",
Filename: components_generateFileName.generateFileName()
};
},
onLoad(option) {
common_vendor.index.getStorage({
key: "userinfo",
success: (res) => {
this.id = res.data.id;
}
});
common_vendor.index.getStorage({
key: "userSig",
success: (res) => {
this.userSig = res.data;
}
});
common_vendor.index.getStorage({
key: "lastPage",
success: (res) => {
this.lastPage = "/" + res.data;
},
fail: () => {
this.lastPage = "/pages/Home/Home";
}
});
},
methods: {
// 输入昵称
inputName(e) {
this.name = e.detail.value;
},
// 选择头像
async Userinfo(e) {
const { avatarUrl } = e.detail;
this.userinfo = avatarUrl;
},
// 微信登录
async wxLogin(e) {
if (this.name !== "" && this.userinfo !== "") {
common_vendor.index.showLoading({
title: "登录中...",
mask: true
});
const { code } = await common_vendor.index.login({
provider: "weixin",
onlyAuthorize: true
});
components_postFile.uploadFile({
path: this.userinfo,
name: this.Filename
}).then((ress) => {
this.picture = ress.split("/").pop();
components_request.request({
url: "user/inputUserInfo",
method: "POST",
data: {
id: this.id,
headerIcon: this.Filename,
nickName: this.name,
code,
usersig: this.userSig.userSig
},
userInfo: false
}).then((res) => {
if (res.code === 200) {
common_vendor.index.showToast({
title: "登录成功",
icon: "success"
});
common_vendor.index.setStorageSync("userinfo", res.data.info);
counter.$patch({ myitem: res.data.info });
common_vendor.index.hideLoading();
common_vendor.index.reLaunch({
url: this.lastPage
});
} else {
common_vendor.index.showToast({
title: res.msg,
icon: "none"
});
}
});
}).catch((err) => {
common_vendor.index.__f__("log", "at pages/UserInformation/UserInformation.vue:126", err);
});
} else {
common_vendor.index.showToast({
title: "请填写头像昵称",
icon: "success",
duration: 3e3
});
}
}
}
};
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
return {
a: $data.userinfo,
b: common_vendor.o$1((...args) => $options.Userinfo && $options.Userinfo(...args)),
c: common_vendor.o$1((...args) => $options.inputName && $options.inputName(...args)),
d: common_vendor.o$1((...args) => $options.wxLogin && $options.wxLogin(...args))
};
}
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-35d730ef"]]);
wx.createPage(MiniProgramPage);
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/UserInformation/UserInformation.js.map