187 lines
5.6 KiB
JavaScript
187 lines
5.6 KiB
JavaScript
"use strict";
|
|
const common_vendor = require("../../../common/vendor.js");
|
|
const request_api = require("../../../request/api.js");
|
|
require("../../../request/http.js");
|
|
const common_assets = require("../../../common/assets.js");
|
|
const _sfc_main = {
|
|
data() {
|
|
return {
|
|
avatarTop: "",
|
|
contentTop: "",
|
|
avatar: "",
|
|
//选择头像临时地址
|
|
avatarUrl: "",
|
|
//已上传的链接
|
|
nickname: "",
|
|
//昵称
|
|
mobile: "",
|
|
//手机号
|
|
sexList: ["男", "女"],
|
|
sex: "",
|
|
profile: ""
|
|
//个人简介
|
|
};
|
|
},
|
|
onLoad() {
|
|
this.avatarTop = common_vendor.inject("navHeight") + 60 / 750 * common_vendor.inject("windowWidth");
|
|
this.contentTop = this.avatarTop + 75 / 750 * common_vendor.inject("windowWidth");
|
|
this.getUserInfoData();
|
|
},
|
|
methods: {
|
|
/**
|
|
* 点击选择头像
|
|
* @param {Object} e
|
|
*/
|
|
chooseAvatar(e) {
|
|
common_vendor.index.__f__("log", "at pages/mine/basicInfo/basicInfo.vue:71", e);
|
|
this.avatar = e.detail.avatarUrl;
|
|
},
|
|
/**
|
|
* 点击选择性别
|
|
* @param {Object} e
|
|
*/
|
|
sexChange(e) {
|
|
common_vendor.index.__f__("log", "at pages/mine/basicInfo/basicInfo.vue:80", e);
|
|
let value = e.detail.value;
|
|
this.sex = this.sexList[value];
|
|
},
|
|
/**
|
|
* 获取手机号
|
|
* @param {Object} e
|
|
*/
|
|
getPhoneNumData(e) {
|
|
common_vendor.index.__f__("log", "at pages/mine/basicInfo/basicInfo.vue:90", e);
|
|
if (e.detail.errMsg == "getPhoneNumber:ok") {
|
|
let param = { code: e.detail.code };
|
|
request_api.wxBindPhone(param).then((res) => {
|
|
if (res.code == 200) {
|
|
common_vendor.index.showToast({
|
|
title: res.message
|
|
});
|
|
this.mobile = res.data.phone;
|
|
} else
|
|
common_vendor.index.showToast({
|
|
title: res.message,
|
|
icon: "none"
|
|
});
|
|
}).catch((error) => {
|
|
});
|
|
}
|
|
},
|
|
/**
|
|
* 点击完成或下一步
|
|
*/
|
|
clickFinishOrNext(type) {
|
|
if (!this.avatar && !this.avatarUrl) {
|
|
common_vendor.index.showToast({
|
|
title: "请选择头像",
|
|
icon: "none"
|
|
});
|
|
return;
|
|
}
|
|
if (!this.nickname) {
|
|
common_vendor.index.showToast({
|
|
title: "请输入昵称",
|
|
icon: "none"
|
|
});
|
|
return;
|
|
}
|
|
if (!this.sex) {
|
|
common_vendor.index.showToast({
|
|
title: "请选择性别",
|
|
icon: "none"
|
|
});
|
|
return;
|
|
}
|
|
if (this.avatar) {
|
|
let param = {
|
|
avatar: this.avatar,
|
|
nickname: this.nickname,
|
|
gender: this.sex == "男" ? "male" : "female",
|
|
phone: this.mobile,
|
|
bio: this.profile,
|
|
isFile: 1
|
|
};
|
|
request_api.updateBasicInfo(param).then((res) => {
|
|
if (type == 1) {
|
|
common_vendor.index.navigateTo({
|
|
url: "/pages/mine/investPreference/investPreference"
|
|
});
|
|
} else
|
|
common_vendor.index.navigateBack();
|
|
}).catch((error) => {
|
|
});
|
|
} else {
|
|
let param = {
|
|
nickname: this.nickname,
|
|
gender: this.sex == "男" ? "male" : "female",
|
|
phone: this.mobile,
|
|
bio: this.profile
|
|
};
|
|
request_api.updateBasicInfo(param).then((res) => {
|
|
if (type == 1) {
|
|
common_vendor.index.navigateTo({
|
|
url: "/pages/mine/investPreference/investPreference"
|
|
});
|
|
} else
|
|
common_vendor.index.navigateBack();
|
|
}).catch((error) => {
|
|
});
|
|
}
|
|
},
|
|
/**
|
|
* 获取用户信息数据
|
|
*/
|
|
getUserInfoData() {
|
|
request_api.userInfo().then((res) => {
|
|
if (res.code == 200) {
|
|
this.avatarUrl = res.data.basic_info.avatar_url;
|
|
this.nickname = res.data.basic_info.nickname;
|
|
this.mobile = res.data.basic_info.phone;
|
|
this.sex = res.data.basic_info.gender == "male" ? "男" : "女";
|
|
this.profile = res.data.basic_info.bio;
|
|
} else
|
|
common_vendor.wx$1.showToast({
|
|
title: res.message,
|
|
icon: "none"
|
|
});
|
|
}).catch((error) => {
|
|
});
|
|
}
|
|
}
|
|
};
|
|
if (!Array) {
|
|
const _easycom_navBar2 = common_vendor.resolveComponent("navBar");
|
|
_easycom_navBar2();
|
|
}
|
|
const _easycom_navBar = () => "../../../components/navBar/navBar.js";
|
|
if (!Math) {
|
|
_easycom_navBar();
|
|
}
|
|
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
return {
|
|
a: common_vendor.p({
|
|
leftText: "信息完善"
|
|
}),
|
|
b: common_assets._imports_0,
|
|
c: $data.avatar ? $data.avatar : $data.avatarUrl,
|
|
d: common_assets._imports_1$5,
|
|
e: common_vendor.o((...args) => $options.chooseAvatar && $options.chooseAvatar(...args)),
|
|
f: common_vendor.s("top:" + $data.avatarTop + "px;"),
|
|
g: $data.nickname,
|
|
h: common_vendor.o(($event) => $data.nickname = $event.detail.value),
|
|
i: common_vendor.t($data.mobile),
|
|
j: common_vendor.o((...args) => $options.getPhoneNumData && $options.getPhoneNumData(...args)),
|
|
k: common_vendor.t($data.sex),
|
|
l: common_assets._imports_2$6,
|
|
m: $data.sexList,
|
|
n: common_vendor.o((...args) => $options.sexChange && $options.sexChange(...args)),
|
|
o: common_vendor.s("top:" + $data.contentTop + "px;"),
|
|
p: common_vendor.o(($event) => $options.clickFinishOrNext(0)),
|
|
q: common_vendor.o(($event) => $options.clickFinishOrNext(1))
|
|
};
|
|
}
|
|
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render]]);
|
|
wx.createPage(MiniProgramPage);
|
|
//# sourceMappingURL=../../../../.sourcemap/mp-weixin/pages/mine/basicInfo/basicInfo.js.map
|