134 lines
4.5 KiB
JavaScript
134 lines
4.5 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 components_goEasyTool_tool = require("../../components/goEasyTool/tool.js");
|
|
const _sfc_main = {
|
|
inject: ["$global"],
|
|
data() {
|
|
return {
|
|
userinfo: "",
|
|
name: "",
|
|
id: "",
|
|
info: {},
|
|
useravatar: ""
|
|
};
|
|
},
|
|
onLoad(option) {
|
|
common_vendor.index.getStorage({
|
|
key: "userinfo",
|
|
success: (res) => {
|
|
this.id = res.data.id;
|
|
this.name = res.data.nickName;
|
|
this.userinfo = this.useravatar = res.data.headerIcon;
|
|
}
|
|
});
|
|
},
|
|
methods: {
|
|
cancel() {
|
|
common_vendor.index.navigateBack({
|
|
delta: 1
|
|
});
|
|
},
|
|
// 输入昵称
|
|
inputName(e) {
|
|
this.name = e.detail.value;
|
|
},
|
|
// 选择头像
|
|
async Userinfo(e) {
|
|
const { avatarUrl } = e.detail;
|
|
this.userinfo = avatarUrl;
|
|
},
|
|
// 微信登录
|
|
wxLogin(e) {
|
|
components_goEasyTool_tool.goEasylogout(this.$goeasy);
|
|
common_vendor.index.showLoading({
|
|
title: "修改中...",
|
|
mask: true
|
|
});
|
|
if (this.useravatar == this.userinfo) {
|
|
components_request.request({
|
|
url: "user/updateUserInfo",
|
|
method: "POST",
|
|
data: {
|
|
id: this.id,
|
|
headerIcon: this.userinfo.split("/").pop(),
|
|
nickName: this.name
|
|
},
|
|
userInfo: true
|
|
}).then((ress) => {
|
|
if (ress.code === 200) {
|
|
common_vendor.index.showToast({
|
|
title: "修改成功",
|
|
icon: "success"
|
|
});
|
|
common_vendor.index.setStorageSync("userinfo", ress.data.info);
|
|
components_goEasyTool_tool.goEasylogin(this.$goeasy, String(ress.data.info.id), ress.data.info.headerIcon, ress.data.info.nickName);
|
|
common_vendor.index.hideLoading();
|
|
common_vendor.index.navigateBack({
|
|
delta: 1
|
|
});
|
|
} else {
|
|
common_vendor.index.showToast({
|
|
title: "修改失败",
|
|
icon: "none"
|
|
});
|
|
}
|
|
});
|
|
} else {
|
|
components_postFile.uploadFile({
|
|
path: this.userinfo,
|
|
name: components_generateFileName.generateFileName()
|
|
}).then((res) => {
|
|
components_request.request({
|
|
url: "user/updateUserInfo",
|
|
method: "POST",
|
|
data: {
|
|
id: this.id,
|
|
headerIcon: res.split("/").pop(),
|
|
nickName: this.name
|
|
},
|
|
userInfo: true
|
|
}).then((ress) => {
|
|
common_vendor.index.__f__("log", "at pages/Setting/Setting.vue:112", "修改调用返回", ress);
|
|
if (ress.code === 200) {
|
|
common_vendor.index.showToast({
|
|
title: "修改成功",
|
|
icon: "success"
|
|
});
|
|
common_vendor.index.setStorageSync("userinfo", ress.data.info);
|
|
components_goEasyTool_tool.goEasylogin(this.$goeasy, String(ress.data.info.id), ress.data.info.headerIcon, ress.data.info.nickName);
|
|
common_vendor.index.hideLoading();
|
|
common_vendor.index.navigateBack({
|
|
delta: 1
|
|
});
|
|
} else {
|
|
common_vendor.index.showToast({
|
|
title: "修改失败",
|
|
icon: "none"
|
|
});
|
|
}
|
|
});
|
|
}).catch((err) => {
|
|
common_vendor.index.__f__("log", "at pages/Setting/Setting.vue:135", "上传失败", err);
|
|
});
|
|
}
|
|
}
|
|
}
|
|
};
|
|
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
return {
|
|
a: $data.userinfo,
|
|
b: common_vendor.o((...args) => $options.Userinfo && $options.Userinfo(...args)),
|
|
c: common_vendor.o((...args) => $options.inputName && $options.inputName(...args)),
|
|
d: $data.name,
|
|
e: common_vendor.o(($event) => $data.name = $event.detail.value),
|
|
f: common_vendor.o((...args) => $options.wxLogin && $options.wxLogin(...args)),
|
|
g: common_vendor.o((...args) => $options.cancel && $options.cancel(...args))
|
|
};
|
|
}
|
|
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-3c55a289"]]);
|
|
wx.createPage(MiniProgramPage);
|
|
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/Setting/Setting.js.map
|