Files
PC-202306242200\Administrator 4d06351f6a no message
2026-03-28 23:00:29 +08:00

80 lines
2.5 KiB
JavaScript

"use strict";
const common_vendor = require("../../common/vendor.js");
const api_api = require("../../api/api.js");
const utils_fun = require("../../utils/fun.js");
if (!Array) {
const _easycom_up_avatar2 = common_vendor.resolveComponent("up-avatar");
const _easycom_up_cell2 = common_vendor.resolveComponent("up-cell");
const _easycom_up_cell_group2 = common_vendor.resolveComponent("up-cell-group");
(_easycom_up_avatar2 + _easycom_up_cell2 + _easycom_up_cell_group2)();
}
const _easycom_up_avatar = () => "../../uni_modules/uview-plus/components/u-avatar/u-avatar.js";
const _easycom_up_cell = () => "../../uni_modules/uview-plus/components/u-cell/u-cell.js";
const _easycom_up_cell_group = () => "../../uni_modules/uview-plus/components/u-cell-group/u-cell-group.js";
if (!Math) {
(_easycom_up_avatar + _easycom_up_cell + _easycom_up_cell_group)();
}
const _sfc_main = {
__name: "sett",
setup(__props) {
let info = common_vendor.ref({});
common_vendor.onShow(async () => {
getInfo();
});
const getInfo = async () => {
let _res = await api_api.userInfo();
info.value = _res;
};
const chooseAvatar = async (e) => {
let img = await utils_fun.uploadFiles(e.detail.avatarUrl);
api_api.updateAvatar({ avatar: img }).then((res) => {
getInfo();
});
console.log(img);
};
const upNickName = () => {
common_vendor.index.showModal({
title: "修改昵称",
content: info.value.nickName,
editable: true,
success: function(res) {
if (res.confirm) {
api_api.updateNickName({ nickName: res.content }).then((res2) => {
getInfo();
});
console.log(res);
console.log("用户点击确定");
} else if (res.cancel) {
console.log("用户点击取消");
}
}
});
};
return (_ctx, _cache) => {
return {
a: common_vendor.p({
src: common_vendor.unref(info).avatar
}),
b: common_vendor.p({
title: "头像",
isLink: true,
size: "min"
}),
c: common_vendor.o(chooseAvatar),
d: common_vendor.t(common_vendor.unref(info).nickName),
e: common_vendor.o(upNickName),
f: common_vendor.p({
title: "昵称",
isLink: true,
size: "min",
border: false
}),
g: common_vendor.p({
border: false
})
};
};
}
};
my.createPage(_sfc_main);