作者 徐强

提交

<template>
<view class="chooseHomeWrap">
<view class="chooseHome">
<view class="addressWrap">
<view class="address">
{{chAddressName}}
</view>
</view>
<view class="changeAddress">
<view class="addressItem" @click="changeChAddress(0)" v-if="chAddress.length >= 0">
省级
<view class="addressLine" v-if="chAddressIndex == 0"></view>
</view>
<view class="addressItem" @click="changeChAddress(1)" v-if="chAddress.length >= 1">
<view class="addressLine" v-if="chAddressIndex == 1"></view>
</view>
<view class="addressItem" @click="changeChAddress(2)" v-if="chAddress.length >= 2">
区县
<view class="addressLine" v-if="chAddressIndex == 2"></view>
</view>
<view class="addressItem" @click="changeChAddress(3)" v-if="chAddress.length >= 3">
<view class="addressLine" v-if="chAddressIndex == 3"></view>
</view>
<view class="addressItem" @click="changeChAddress(4)" v-if="chAddress.length >= 4">
<view class="addressLine" v-if="chAddressIndex == 4"></view>
</view>
</view>
<scroll-view scroll-y class="addressList">
<view class="addressName" v-for="(item,index) in addressList" :key="index" @click="clickAddress(index)">
{{item.Name}}
</view>
</scroll-view>
<view class="bottomBtn">
<view class="btn" @click="$emit('close')">
取消
</view>
<view class="btn active" @click="confirm">
确定
</view>
</view>
</view>
</view>
</template>
<script>
export default {
name:"chooseAddress",
data() {
return {
chAddressIndex:0,
chAddress:[],
chAddressName:'',
addressList:[]
};
},
mounted() {
this.$request('/common/area').then((res)=>{
this.addressList = res.data
})
},
methods:{
changeChAddress(index){
let area_id = ''
this.chAddressIndex = index
if(index > 0){
area_id = this.chAddress[index-1].id
this.$request('/common/area',{area_id:area_id}).then((res)=>{
this.addressList = res.data
})
}else{
this.$request('/common/area').then((res)=>{
this.addressList = res.data
})
}
},
clickAddress(index){
if(this.chAddressIndex < this.chAddress.length - 1){
for(let i = this.chAddress.length - 1; i > this.chAddressIndex; i--){
this.chAddress.splice(i,1)
}
}
let ID = this.addressList[index].ID
this.chAddress[this.chAddressIndex] = {
id:ID,
name:this.addressList[index].Name,
}
this.chAddressName = this.chAddress.map((obj)=>{return obj.name}).join("");
if(this.chAddressIndex < 4){
this.addressList = []
this.chAddressIndex++
this.$request('/common/area',{area_id:ID}).then((res)=>{
this.addressList = res.data
})
}
},
confirm(){
if(this.chAddress.length < 3){
uni.showToast({
title:'请选择至区县',
icon:'none'
})
return
}
this.$emit('confirm',{address:this.chAddressName,area_id:this.chAddress[this.chAddress.length-1].id})
}
}
}
</script>
<style lang="scss">
// 选择家乡弹框区域
.chooseHomeWrap{
position: fixed;
top: 0;
bottom: 0;
left: 0;
right: 0;
background: rgba(0,0,0,0.5);
display: flex;
align-items: flex-end;
.chooseHome{
width: 750rpx;
height: 1200rpx;
background: #fff;
border-radius: 30rpx 30rpx 0 0;
padding: 32rpx 0;
.addressWrap{
padding: 0 32rpx;
.address{
background: #f3f3f3;
padding: 32rpx;
height: 32rpx;
border-radius: 30rpx;
line-height: 32rpx;
color: #9c9c9c;
font-size: 28rpx;
}
}
.changeAddress{
height: 90rpx;
border-bottom: 2rpx solid #ededed;
display: flex;
align-items: center;
font-size: 28rpx;
color: #585858;
.addressItem{
width: 150rpx;
line-height: 90rpx;
text-align: center;
position: relative;
.addressLine{
position: absolute;
width: 36rpx;
height: 8rpx;
background: #35655f;
border-radius: 18rpx;
bottom: 10rpx;
left: 57rpx;
}
}
}
.addressList{
padding: 0 32rpx;
height: calc(1200rpx - 64rpx - 92rpx - 100rpx);
.addressName{
height: 60rpx;
line-height: 60rpx;
font-size: 28rpx;
}
}
.bottomBtn{
height: 100rpx;
padding: 0 32rpx;
display: flex;
align-items: center;
justify-content: space-between;
.btn{
height: 80rpx;
width: 333rpx;
background: #9c9c9c;
text-align: center;
line-height: 80rpx;
border-radius: 10rpx;
color: #fff;
font-size: 28rpx;
}
.btn.active{
background: #35655f;
}
}
}
}
</style>
... ...
... ... @@ -47,22 +47,20 @@
<image src="../../static/image/right_icon.png" mode=""></image>
</view>
</view>
</view>
<!-- 服务位置区域 -->
<view class="serviceWrap">
<view class="title">
家乡
</view>
<view class="content">
<u-steps @chooseAddress="chooseAddress" :direction="direction" :current="current" :list="steps" :mode="mode" :icon="icon"></u-steps>
<!-- <view class="left">
<text class="alertTxt" :class="{active:param.address != '请选择服务位置'}">{{param.address}}</text>
<view class="infoItem" @click="showChooseAddress = true">
<view class="infoLeft">
家乡
</view>
<view class="infoCenter">
</view>
<view class="infoRight">
<text class="alertTxt" :class="{active:param.address != '请选择家乡'}">{{param.address}}</text>
<image src="../../static/image/right_icon.png" mode=""></image>
</view>
<view class="right">
<image @click="chooseLocation" src="../../static/image/my/icon_faqi@2x.png" mode=""></image>
</view> -->
</view>
</view>
<!-- 服务位置区域 -->
<!-- 服务内容区域 -->
<!-- <view class="serviceWrap">
<view class="title">
... ... @@ -132,48 +130,28 @@
</view>
</view>
</view>
<u-select :default-value="defaultValue" :value-name="'ID'" :label-name="'Name'" :mode="selectMode" v-model="show" :list="addressList" @confirm="confirmAddress" @cancel="cancel"></u-select>
<!-- 选择家乡弹框 -->
<choose-address v-if="showChooseAddress" @close="showChooseAddress = false" @confirm="confirmAddress"></choose-address>
</view>
</template>
<script>
var amapFile = require('../../static/js/amap-wx.js');
import chooseAddress from '@/components/chooseAddress.vue'
import {mapState} from "vuex"
export default{
data(){
return{
//列选择开始
show: false,
defaultValue: [0],
selectMode: 'single-column', // single-column, mutil-column, mutil-column-auto
addressList: [],
//列选择结束
//步骤条开始
steps: [{
name: '请选择省份'
}, {
name: '请选择市'
}, {
name: '请选择区(县)'
}, {
name: '请选择镇'
}, {
name: '请选择村'
}, ],
current: -1,
icon: 'map-fill',
mode: 'dot',
direction: 'column',
//步骤条结束
showChooseAddress:false,
nicknameFocus:false,
userInfo:{},
param:{
area_id:'',
phone:'',
province:'',
city:'',
county:'',
address:'请选择服务位置',
address:'请选择家乡',
longitude:'',
latitude:'',
stop_money:'',
... ... @@ -185,6 +163,9 @@
computed:{
...mapState(["userinfo"])
},
components:{
chooseAddress
},
created() {
uni.$on('bAvatarCropper', path => {
// this.userInfo.bg_image = path;
... ... @@ -226,17 +207,6 @@
getData(){
let areaIds = []
let areaNames = []
let stepsTemp =[{
name: '请选择省份'
}, {
name: '请选择市'
}, {
name: '请选择区(县)'
}, {
name: '请选择镇'
}, {
name: '请选择村'
}]
//获取用户信息
this.$request('/user/info').then((res)=>{
let avatar = res.data.avatar
... ... @@ -251,17 +221,14 @@
if(this.userInfo.area_id != ''){
areaIds = Object.keys(this.userInfo.area_arr)
areaNames = Object.values(this.userInfo.area_arr)
for(let i = 0; i < areaIds.length; i ++){
stepsTemp[i].id = areaIds[i]
stepsTemp[i].name = areaNames[i]
}
this.steps = stepsTemp
this.param.area_id = areaIds[areaIds.length - 1]
this.param.address = areaNames.join('')
}
this.param.phone = this.userInfo.phone != '' ? this.userInfo.phone : this.userInfo.mobile
this.param.province = this.userInfo.form_province
this.param.city = this.userInfo.form_city
this.param.county = this.userInfo.form_county
this.param.address = this.userInfo.form_address
// this.param.address = this.userInfo.form_address
this.param.longitude = this.userInfo.form_longitude
this.param.latitude = this.userInfo.form_latitude
this.param.stop_money = this.userInfo.form_stop_money
... ... @@ -277,47 +244,10 @@
})
},
chooseAddress(e){
let area_id
if(e > 0 && this.steps[e-1].id == undefined){
return
}
if(e > 0){
area_id = this.steps[e-1].id
}
this.$request('/common/area',{area_id:area_id}).then((res)=>{
this.addressList = res.data
this.current = e
this.show = true
})
},
confirmAddress(e) {
let Name = ''
let ID = ''
let stepsTemp = [{
name: '请选择省份'
}, {
name: '请选择市'
}, {
name: '请选择区(县)'
}, {
name: '请选择镇'
}, {
name: '请选择村'
}, ]
e.map((val, index) => {
Name += Name == '' ? val.label : '-' + val.label;
ID += ID == '' ? val.value : '-' + val.value;
})
for(let i = 0; i <= this.current; i ++){
if(this.steps[i].id == undefined || i == this.current){
stepsTemp[i].id = ID
stepsTemp[i].name = Name
}else{
stepsTemp[i] = this.steps[i]
}
}
this.steps = stepsTemp
this.param.address = e.address
this.param.area_id = e.area_id
this.showChooseAddress = false
},
//选择头像
chooseImage(imgType){
... ... @@ -445,8 +375,6 @@
},
confirm(){
let area_id
let areaName
if(this.userInfo.nickname == ''){
uni.showToast({
title:'请输入姓名',
... ... @@ -462,41 +390,17 @@
return
}
if(!this.check.telphone(this.param.phone)){return;}
if(this.steps[0].id == undefined){
uni.showToast({
title:'请选择省份',
icon:'none'
})
return
}
if(this.steps[1].id == undefined){
uni.showToast({
title:'请选择市',
icon:'none'
})
return
}
if(this.steps[2].id == undefined){
if(this.param.address == '请选择家乡'){
uni.showToast({
title:'请选择区(县)',
title:'请选择家乡',
icon:'none'
})
return
}
if(this.steps[4].id != undefined){
area_id = this.steps[4].id
areaName = this.steps[0].name + this.steps[1].name + this.steps[2].name + this.steps[3].name + this.steps[4].name
}else if(this.steps[3].id != undefined){
area_id = this.steps[3].id
areaName = this.steps[0].name + this.steps[1].name + this.steps[2].name + this.steps[3].name
}else{
area_id = this.steps[2].id
areaName = this.steps[0].name + this.steps[1].name + this.steps[2].name
}
var myAmapFun = new amapFile.AMapWX({key:'a8c52aaa1ccef354745fb14886b7d633'});
myAmapFun.getInputtips({
keywords: areaName,
keywords: this.param.address,
location: '',
success: (data)=>{
this.userInfo.latitude = data.tips[0].location.split(',')[1]
... ... @@ -509,7 +413,7 @@
let timUserInfo = JSON.parse(uni.getStorageSync('userInfo'))
timUserInfo.img = this.imgUrl + this.userInfo.avatar
uni.setStorageSync('userInfo',JSON.stringify(timUserInfo))
this.$request('/user_hometown_check/add',{area_id:area_id}).then((res)=>{
this.$request('/user_hometown_check/add',this.param).then((res)=>{
if(res.code == 1){
this.$href('checkWait')
setTimeout(()=>{
... ... @@ -630,6 +534,15 @@
}
}
.infoRight{
display: flex;
align-items: center;
.alertTxt{
color: #c8c9cc;
font-weight: 300;
}
.alertTxt.active{
color: #323232;
}
image{width: 32rpx;height: 32rpx;}
}
}
... ... @@ -770,4 +683,5 @@
}
}
}
</style>
... ...
... ... @@ -47,19 +47,17 @@
<image src="../../static/image/right_icon.png" mode=""></image>
</view>
</view>
</view>
<view class="serviceWrap">
<view class="title">
家乡
</view>
<view class="content">
<u-steps @chooseAddress="chooseAddress" :direction="direction" :current="current" :list="steps" :mode="mode" :icon="icon"></u-steps>
<!-- <view class="left">
<text class="alertTxt" :class="{active:param.address != '请选择服务位置'}">{{param.address}}</text>
<view class="infoItem" @click="showChooseAddress = true">
<view class="infoLeft">
家乡
</view>
<view class="infoCenter">
</view>
<view class="infoRight">
<text class="alertTxt" :class="{active:param.address != ''}">{{userInfo.address}}</text>
<image src="../../static/image/right_icon.png" mode=""></image>
</view>
<view class="right">
<image @click="chooseLocation" src="../../static/image/my/icon_faqi@2x.png" mode=""></image>
</view> -->
</view>
</view>
<view class="otherInfo">
... ... @@ -139,7 +137,8 @@
保存
</view>
</view>
<u-select :default-value="defaultValue" :value-name="'ID'" :label-name="'Name'" :mode="selectMode" v-model="show" :list="addressList" @confirm="confirmAddress" @cancel="cancel"></u-select>
<!-- 选择家乡弹框 -->
<choose-address v-if="showChooseAddress" @close="showChooseAddress = false" @confirm="confirmAddress"></choose-address>
</view>
</template>
... ... @@ -147,35 +146,13 @@
var amapFile = require('../../static/js/amap-wx.js');
import {mapState} from "vuex"
import wPicker from "@/components/w-picker/w-picker.vue"
import chooseAddress from '@/components/chooseAddress.vue'
var apiUrl = 'http://landlord.t.brotop.cn/api'
// var apiUrl = 'http://app.zhaodizhu.cn/api'
export default{
data(){
return{
//列选择开始
show: false,
defaultValue: [0],
selectMode: 'single-column', // single-column, mutil-column, mutil-column-auto
addressList: [],
//列选择结束
//步骤条开始
steps: [{
name: '请选择省份'
}, {
name: '请选择市'
}, {
name: '请选择区(县)'
}, {
name: '请选择镇'
}, {
name: '请选择村'
}, ],
current: -1,
icon: 'map-fill',
mode: 'dot',
direction: 'column',
//步骤条结束
showChooseAddress:false,
nicknameFocus:false,
chooseImageStatus:false,
imgUrl:this.imgUrl,
... ... @@ -246,7 +223,8 @@
...mapState(["userinfo"])
},
components:{
wPicker
wPicker,
chooseAddress
},
onShow() {
if(!this.chooseImageStatus){
... ... @@ -257,17 +235,6 @@
getData(){
let areaIds = []
let areaNames = []
let stepsTemp =[{
name: '请选择省份'
}, {
name: '请选择市'
}, {
name: '请选择区(县)'
}, {
name: '请选择镇'
}, {
name: '请选择村'
}]
//获取用户信息
this.$request('/user/info').then((res)=>{
console.log('用户信息',res)
... ... @@ -283,11 +250,8 @@
if(this.userInfo.area_id != ''){
areaIds = Object.keys(this.userInfo.area_arr)
areaNames = Object.values(this.userInfo.area_arr)
for(let i = 0; i < areaIds.length; i ++){
stepsTemp[i].id = areaIds[i]
stepsTemp[i].name = areaNames[i]
}
this.steps = stepsTemp
this.userInfo.area_id = areaIds[areaIds.length - 1]
this.userInfo.address = areaNames.join('')
}
this.showPersonInfo = true
})
... ... @@ -306,34 +270,6 @@
this.show = true
})
},
confirmAddress(e) {
let Name = ''
let ID = ''
let stepsTemp = [{
name: '请选择省份'
}, {
name: '请选择市'
}, {
name: '请选择区(县)'
}, {
name: '请选择镇'
}, {
name: '请选择村'
}, ]
e.map((val, index) => {
Name += Name == '' ? val.label : '-' + val.label;
ID += ID == '' ? val.value : '-' + val.value;
})
for(let i = 0; i <= this.current; i ++){
if(this.steps[i].id == undefined || i == this.current){
stepsTemp[i].id = ID
stepsTemp[i].name = Name
}else{
stepsTemp[i] = this.steps[i]
}
}
this.steps = stepsTemp
},
cancel(e) {
console.log(e);
},
... ... @@ -404,6 +340,11 @@
})
}
},
confirmAddress(e) {
this.userInfo.address = e.address
this.userInfo.area_id = e.area_id
this.showChooseAddress = false
},
//保存
save(){
if(this.userInfo.nickname == ''){
... ... @@ -427,73 +368,42 @@
})
return
} */
if(this.steps[0].id == undefined){
uni.showToast({
title:'请选择省份',
icon:'none'
})
return
}
if(this.steps[1].id == undefined){
uni.showToast({
title:'请选择市',
icon:'none'
})
return
}
if(this.steps[2].id == undefined){
if(this.userInfo.bio.length > 27){
uni.showToast({
title:'请选择区(县)',
title:'个人描述长度不可超过27个字',
icon:'none'
})
return
}
let areaName
if(this.steps[4].id != undefined){
this.userInfo.area_id = this.steps[4].id
areaName = this.steps[0].name + this.steps[1].name + this.steps[2].name + this.steps[3].name + this.steps[4].name
}else if(this.steps[3].id != undefined){
this.userInfo.area_id = this.steps[3].id
areaName = this.steps[0].name + this.steps[1].name + this.steps[2].name + this.steps[3].name
}else{
this.userInfo.area_id = this.steps[2].id
areaName = this.steps[0].name + this.steps[1].name + this.steps[2].name
}
var myAmapFun = new amapFile.AMapWX({key:'a8c52aaa1ccef354745fb14886b7d633'});
myAmapFun.getInputtips({
keywords: areaName,
keywords: this.userInfo.address,
location: '',
success: (data)=>{
this.userInfo.latitude = data.tips[0].location.split(',')[1]
this.userInfo.longitude = data.tips[0].location.split(',')[0]
}
})
if(this.userInfo.bio.length > 27){
uni.showToast({
title:'个人描述长度不可超过27个字',
icon:'none'
})
return
}
console.log('修改会员个人信息参数',this.userInfo)
this.$request('/user/profile',this.userInfo).then((res)=>{
if(res.code == 1){
this.userinfo.avatar = this.imgUrl + this.userInfo.avatar
uni.setStorageSync('userinfo',JSON.stringify(this.userinfo))
let timUserInfo = JSON.parse(uni.getStorageSync('userInfo'))
timUserInfo.img = this.imgUrl + this.userInfo.avatar
uni.setStorageSync('userInfo',JSON.stringify(timUserInfo))
this.$href('my',2)
setTimeout(()=>{
uni.showToast({
title:'保存成功'
})
},500)
}else{
uni.showToast({
title:res.msg,
icon:'none'
console.log('修改会员个人信息参数',this.userInfo)
this.$request('/user/profile',this.userInfo).then((res)=>{
if(res.code == 1){
this.userinfo.avatar = this.imgUrl + this.userInfo.avatar
uni.setStorageSync('userinfo',JSON.stringify(this.userinfo))
let timUserInfo = JSON.parse(uni.getStorageSync('userInfo'))
timUserInfo.img = this.imgUrl + this.userInfo.avatar
uni.setStorageSync('userInfo',JSON.stringify(timUserInfo))
this.$href('my',2)
setTimeout(()=>{
uni.showToast({
title:'保存成功'
})
},500)
}else{
uni.showToast({
title:res.msg,
icon:'none'
})
}
})
}
})
... ...