Commit 1ccd41d1 by 侯体倬

个人中心新增地区选项

parent baab6581
...@@ -78,6 +78,12 @@ ...@@ -78,6 +78,12 @@
/> />
<van-cell class="noSelect" v-else title="生日" value="未设置" is-link /> <van-cell class="noSelect" v-else title="生日" value="未设置" is-link />
</div> </div>
<!-- 地区 -->
<div @click="areaShow = true">
<van-cell v-if="userMsg.provinceName" :value="userMsg.provinceName" title="地区" is-link />
<van-cell v-else class="noSelect" value="未设置" title="地区" is-link />
</div>
<div class="line"></div> <div class="line"></div>
<!--手机--> <!--手机-->
...@@ -121,6 +127,17 @@ ...@@ -121,6 +127,17 @@
/> />
</van-popup> </van-popup>
</div> </div>
<!-- 地区弹出框 -->
<div catchtouchmove="ture">
<van-popup :show="areaShow" position="bottom">
<van-picker
:columns="provinceNameList"
:show-toolbar="true"
@confirm="onConfirmArea"
@cancel="onCancelArea"
/>
</van-popup>
</div>
<!-- <div @click="click">按下试试</div> --> <!-- <div @click="click">按下试试</div> -->
</div> </div>
</template> </template>
...@@ -131,6 +148,7 @@ import index from "@/api/index"; ...@@ -131,6 +148,7 @@ import index from "@/api/index";
import { DFSImg } from "@/utils/index"; import { DFSImg } from "@/utils/index";
import { themeColor } from "@/utils/mayi.js"; import { themeColor } from "@/utils/mayi.js";
import { formatTime } from "@/utils/index"; import { formatTime } from "@/utils/index";
import tool from "@/utils/tool"
const app = getApp() const app = getApp()
export default { export default {
name: "userInfo", name: "userInfo",
...@@ -142,6 +160,8 @@ export default { ...@@ -142,6 +160,8 @@ export default {
realname: "", realname: "",
mobilephone: "", mobilephone: "",
nickname: "", nickname: "",
provinceCode: "",
provinceName: ""
}, },
imgArr: [], imgArr: [],
minDate: new Date(1900, 1, 1).getTime(), minDate: new Date(1900, 1, 1).getTime(),
...@@ -149,6 +169,9 @@ export default { ...@@ -149,6 +169,9 @@ export default {
birthShow: false, birthShow: false,
sex_show: false, sex_show: false,
sex_list: ["女", "男", "未设置"], sex_list: ["女", "男", "未设置"],
areaShow: false,
provinceList: null,
provinceNameList: [],
imgNumLimit: 1, imgNumLimit: 1,
currentTime: new Date().getTime(), currentTime: new Date().getTime(),
currentTime2: new Date().getTime(), currentTime2: new Date().getTime(),
...@@ -216,12 +239,24 @@ export default { ...@@ -216,12 +239,24 @@ export default {
this.$router.push("/personalCenter"); this.$router.push("/personalCenter");
} }
}, },
getUserMsg() { async getUserMsg() {
if (!this.provinceList) {
await tool.appArea().then(res => {
this.provinceList = res.province_list || {};
const list = [];
for (const key in this.provinceList) {
const item = this.provinceList[key];
list.push(item);
}
this.provinceNameList = list;
})
}
live.getUserInfo().then((res) => { live.getUserInfo().then((res) => {
let result = res.data.data; let result = res.data.data;
this.userMsg = { this.userMsg = {
...result, ...result,
birth: result.birth ? result.birth.split(" ")[0] : "", birth: result.birth ? result.birth.split(" ")[0] : "",
provinceName: this.provinceList[result.provinceCode] || "",
headPortraitUrl: DFSImg( headPortraitUrl: DFSImg(
result.headPortraitUrl, result.headPortraitUrl,
400, 400,
...@@ -250,6 +285,7 @@ export default { ...@@ -250,6 +285,7 @@ export default {
this.update_info_data.gender = this.userMsg.gender.toString(); this.update_info_data.gender = this.userMsg.gender.toString();
this.update_info_data.headPortraitUrl = this.userMsg.headPortraitUrl; this.update_info_data.headPortraitUrl = this.userMsg.headPortraitUrl;
this.update_info_data.realname = this.userMsg.realname; this.update_info_data.realname = this.userMsg.realname;
this.update_info_data.provinceCode = this.userMsg.provinceCode;
if (this.userMsg.nickname == "" || this.userMsg.nickname == " ") { if (this.userMsg.nickname == "" || this.userMsg.nickname == " ") {
wx.showToast({ wx.showToast({
...@@ -314,6 +350,23 @@ export default { ...@@ -314,6 +350,23 @@ export default {
correctTel(val) { correctTel(val) {
return /^1\d{10}$/.test(val); return /^1\d{10}$/.test(val);
}, },
onConfirmArea(selection) {
const value = selection.mp.detail.value;
let code;
for (const key in this.provinceList) {
const item = this.provinceList[key];
if (item === value) {
code = key;
break;
}
}
this.userMsg.provinceCode = code;
this.userMsg.provinceName = value;
this.areaShow = false;
},
onCancelArea() {
this.areaShow = false;
},
sexTransform(value) { sexTransform(value) {
console.log(value, "--------------249"); console.log(value, "--------------249");
if (value == 0) { if (value == 0) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment