"use strict";
|
|
const common_vendor = require("../../common/vendor.js");
|
|
const pages_mixins_pullRefreshMixin = require("../mixins/pullRefreshMixin.js");
|
|
const utils_ossUpload_oss_index = require("../../utils/oss-upload/oss/index.js");
|
|
const _sfc_main = {
|
|
mixins: [pages_mixins_pullRefreshMixin.pullRefreshMixin],
|
|
data() {
|
|
return {
|
|
statusBarHeight: 0,
|
|
navBarHeight: 44,
|
|
// px
|
|
navBarHeightRpx: 88,
|
|
// rpx
|
|
userInfo: {
|
|
nickname: "吴彦谋",
|
|
phone: "15888977617",
|
|
avatar: "",
|
|
newAvatar: "/static/logo.png"
|
|
},
|
|
uploadStatus: {
|
|
show: false,
|
|
type: "loading"
|
|
// loading, success, error
|
|
},
|
|
showPhone: false
|
|
};
|
|
},
|
|
computed: {
|
|
maskedPhone() {
|
|
return this.userInfo.phone ? "●".repeat(this.userInfo.phone.length) : "";
|
|
},
|
|
infoContainerStyle() {
|
|
return {
|
|
marginTop: this.navBarHeightRpx + "rpx"
|
|
};
|
|
}
|
|
},
|
|
onLoad() {
|
|
const sysInfo = common_vendor.index.getSystemInfoSync();
|
|
this.statusBarHeight = sysInfo.statusBarHeight;
|
|
let navBarHeight = 44;
|
|
try {
|
|
const menuButtonInfo = common_vendor.index.getMenuButtonBoundingClientRect();
|
|
navBarHeight = menuButtonInfo.bottom + menuButtonInfo.top - sysInfo.statusBarHeight;
|
|
} catch (e) {
|
|
}
|
|
this.navBarHeight = navBarHeight;
|
|
this.navBarHeightRpx = Math.round(navBarHeight * 750 / sysInfo.windowWidth);
|
|
if (common_vendor.index.getStorageSync("token")) {
|
|
this.$api("getUserByToken", {}, (res) => {
|
|
if (res.code === 200 && res.result) {
|
|
this.userInfo.nickname = res.result.nickName || "";
|
|
this.userInfo.phone = res.result.phone || "";
|
|
this.userInfo.avatar = res.result.headImage || "";
|
|
}
|
|
});
|
|
}
|
|
},
|
|
methods: {
|
|
async onRefresh() {
|
|
await new Promise((resolve) => setTimeout(resolve, 1e3));
|
|
common_vendor.index.stopPullRefresh();
|
|
},
|
|
goBack() {
|
|
common_vendor.index.navigateBack();
|
|
},
|
|
async chooseImage(res) {
|
|
try {
|
|
this.uploadStatus = { show: true, type: "loading" };
|
|
const url = await utils_ossUpload_oss_index.OSS.ossUpload(res.target.avatarUrl);
|
|
common_vendor.index.__f__("log", "at pages/subcomponent/edit_profile.vue:151", url, "url");
|
|
this.userInfo.avatar = url;
|
|
this.uploadStatus.type = "success";
|
|
setTimeout(() => {
|
|
this.uploadStatus.show = false;
|
|
}, 1e3);
|
|
} catch (error) {
|
|
this.uploadStatus = { show: true, type: "error" };
|
|
setTimeout(() => {
|
|
this.uploadStatus.show = false;
|
|
}, 1e3);
|
|
}
|
|
},
|
|
saveProfile() {
|
|
if (!this.userInfo.avatar)
|
|
return common_vendor.index.showToast({ title: "请上传头像", icon: "none" });
|
|
if (!this.userInfo.nickname)
|
|
return common_vendor.index.showToast({ title: "请填写昵称", icon: "none" });
|
|
if (!this.userInfo.phone)
|
|
return common_vendor.index.showToast({ title: "请填写手机号", icon: "none" });
|
|
this.uploadStatus = { show: true, type: "loading" };
|
|
common_vendor.index.__f__("log", "at pages/subcomponent/edit_profile.vue:166", this.userInfo, "this.userInfo");
|
|
this.$api("updateInfo", {
|
|
avatarUrl: this.userInfo.avatar,
|
|
nickName: this.userInfo.nickname,
|
|
phone: this.userInfo.phone
|
|
}, (res) => {
|
|
if (res.code === 200) {
|
|
setTimeout(() => {
|
|
common_vendor.index.$emit("refreshUserInfo");
|
|
common_vendor.index.showToast({ title: "保存成功", icon: "success" });
|
|
setTimeout(() => {
|
|
common_vendor.index.navigateBack();
|
|
}, 1e3);
|
|
}, 1e3);
|
|
} else {
|
|
this.uploadStatus.type = "error";
|
|
setTimeout(() => {
|
|
this.uploadStatus.show = false;
|
|
}, 1e3);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
};
|
|
if (!Array) {
|
|
const _easycom_uni_icons2 = common_vendor.resolveComponent("uni-icons");
|
|
_easycom_uni_icons2();
|
|
}
|
|
const _easycom_uni_icons = () => "../../uni_modules/uni-icons/components/uni-icons/uni-icons.js";
|
|
if (!Math) {
|
|
_easycom_uni_icons();
|
|
}
|
|
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
return common_vendor.e({
|
|
a: common_vendor.p({
|
|
type: "left",
|
|
size: "20",
|
|
color: "#222"
|
|
}),
|
|
b: common_vendor.o((...args) => $options.goBack && $options.goBack(...args)),
|
|
c: $data.statusBarHeight + 88 + "rpx",
|
|
d: $data.statusBarHeight + "px",
|
|
e: $data.userInfo.nickname,
|
|
f: common_vendor.o(($event) => $data.userInfo.nickname = $event.detail.value),
|
|
g: $data.showPhone ? $data.userInfo.phone : $options.maskedPhone,
|
|
h: !$data.showPhone,
|
|
i: common_vendor.o((e) => {
|
|
if ($data.showPhone)
|
|
$data.userInfo.phone = e.detail.value;
|
|
}),
|
|
j: common_vendor.o(($event) => $data.showPhone = !$data.showPhone),
|
|
k: common_vendor.p({
|
|
type: $data.showPhone ? "eye" : "eye-slash",
|
|
size: "20",
|
|
color: "#999"
|
|
}),
|
|
l: !$data.userInfo.avatar
|
|
}, !$data.userInfo.avatar ? {
|
|
m: common_vendor.p({
|
|
type: "reload",
|
|
size: "24",
|
|
color: "#999"
|
|
})
|
|
} : {
|
|
n: $data.userInfo.avatar
|
|
}, {
|
|
o: common_vendor.o((...args) => $options.chooseImage && $options.chooseImage(...args)),
|
|
p: $data.userInfo.newAvatar
|
|
}, $data.userInfo.newAvatar ? {
|
|
q: $data.userInfo.newAvatar
|
|
} : {}, {
|
|
r: common_vendor.s($options.infoContainerStyle),
|
|
s: $data.uploadStatus.show
|
|
}, $data.uploadStatus.show ? common_vendor.e({
|
|
t: $data.uploadStatus.type === "loading"
|
|
}, $data.uploadStatus.type === "loading" ? {} : $data.uploadStatus.type === "success" ? {
|
|
w: common_vendor.p({
|
|
type: "checkmark",
|
|
size: "24",
|
|
color: "#fff"
|
|
})
|
|
} : $data.uploadStatus.type === "error" ? {
|
|
y: common_vendor.p({
|
|
type: "closeempty",
|
|
size: "24",
|
|
color: "#fff"
|
|
})
|
|
} : {}, {
|
|
v: $data.uploadStatus.type === "success",
|
|
x: $data.uploadStatus.type === "error"
|
|
}) : {}, {
|
|
z: common_vendor.o((...args) => $options.saveProfile && $options.saveProfile(...args)),
|
|
A: $data.navBarHeightRpx + "rpx"
|
|
});
|
|
}
|
|
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-c93de0a0"]]);
|
|
wx.createPage(MiniProgramPage);
|
|
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/subcomponent/edit_profile.js.map
|