262 lines
6.3 KiB
Vue
262 lines
6.3 KiB
Vue
<template>
|
|
<view class="app">
|
|
<view class="address" v-for="(item,index) in goodPatient" :key="index">
|
|
<view class="addressinfo">
|
|
<view class="item" @tap='goorder(item)'>
|
|
{{item.receiveName}},
|
|
{{item.receivePhone}}
|
|
</view>
|
|
<view class="item detail" @tap='goorder(item)'>
|
|
{{item.address}}
|
|
</view>
|
|
<view class="update">
|
|
<view class="up ups" @tap='updataxg(item)'>
|
|
修改
|
|
</view>
|
|
<view class="up" @tap='del(item)'>
|
|
删除
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
<view class="ADDress" @tap='add()'>
|
|
<image src="../../static/add.png" mode=""></image>
|
|
<span class="ADDtext">
|
|
添加地址
|
|
</span>
|
|
</view>
|
|
<!-- 弹框 -->
|
|
<u-popup v-model="show" mode="center" width="80%" height="50%" border-radius="30">
|
|
<view class="payment">
|
|
<span>{{shipAddress}}</span>
|
|
<view class="cencel" @tap="cencel()">
|
|
<image src="../../static/gb.png" mode=""></image>
|
|
</view>
|
|
<view class="addinfos">
|
|
<u-field v-model="infolist.receiveName" label="收货人" placeholder="姓名" class="items" maxlength='10'>
|
|
</u-field>
|
|
<u-field v-model="infolist.receivePhone" label="手机号" placeholder="电话" class="items" maxlength='11'>
|
|
</u-field>
|
|
<view class="area" @tap='areashow=true'>
|
|
<u-field v-model="infolist.address" label="地区" placeholder="请选择" class="items" disabled>
|
|
</u-field>
|
|
<image src="../../static/jiantou.png" mode=""></image>
|
|
</view>
|
|
<u-field v-model="infolist.receiveAddress" label-width="170" label="详细地址" placeholder="如街道、门牌号、小区等"
|
|
class="items" maxlength='50'>
|
|
</u-field>
|
|
</view>
|
|
<view class="save" @tap='submit()'>
|
|
保存
|
|
</view>
|
|
</view>
|
|
</u-popup>
|
|
<u-select v-model="areashow" mode="mutil-column-auto" label-name='areaName' value-name='areaCode'
|
|
:list="arealist" @confirm="areaconfirm"></u-select>
|
|
<u-toast ref="uToast" />
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
import {
|
|
goodPatientInfo,
|
|
addnursingStation,
|
|
delnursingStation,
|
|
nursingStationGoodsinfo,
|
|
updatenursingStation,
|
|
getSubordinateRegions,
|
|
getSubordinate
|
|
} from '@/api/modifyAddress/modifyAddress.js';
|
|
import baseurl from '@/api/baseurl.js'
|
|
export default {
|
|
data() {
|
|
return {
|
|
timer: null,
|
|
isedit: true, //标识
|
|
delshow: false, //删除弹框
|
|
content: '确认要删除信息吗?',
|
|
show: false, //弹框
|
|
areashow: false, //经纬度开关
|
|
arealist: [], //区街道list
|
|
areaCode: '',
|
|
shipAddress: '添加地址',
|
|
infolist: {
|
|
receiveName: '',
|
|
receivePhone: '',
|
|
receiveAddress: '',
|
|
areaCode: '',
|
|
patientId: '',
|
|
address: '', //页面所属区域
|
|
},
|
|
goodPatient: [], // 查询地址信息
|
|
patientId: null,
|
|
url: '',
|
|
updata: [],
|
|
}
|
|
},
|
|
onShow() {
|
|
this.goodsList()
|
|
},
|
|
onLoad(options) {
|
|
let that = this
|
|
this.updata = JSON.parse(options.updata)
|
|
this.areaInfo()
|
|
},
|
|
methods: {
|
|
//将信息携带至订单页面
|
|
goorder(item) {
|
|
uni.$emit('updata', {
|
|
updata: JSON.stringify(this.updata),
|
|
useritem: JSON.stringify(item)
|
|
})
|
|
uni.navigateBack({
|
|
delta: 1
|
|
});
|
|
},
|
|
// 查询地址信息
|
|
goodsList() {
|
|
let that = this
|
|
try {
|
|
const value = uni.getStorageSync('patientId');
|
|
if (value) {
|
|
that.patientId = value
|
|
goodPatientInfo(that.patientId).then(res => {
|
|
res.data.forEach(e => {
|
|
e.address = e.provinceName + e.cityName + e.regionName + e
|
|
.streetName + e.receiveAddress
|
|
})
|
|
that.goodPatient = res.data
|
|
})
|
|
} else {
|
|
that.$refs.uToast.show({
|
|
title: '登录状态异常',
|
|
type: 'error'
|
|
})
|
|
if (that.timer) {
|
|
clearTimeout(that.timer)
|
|
}
|
|
that.timer = setTimeout(e => {
|
|
uni.navigateBack({
|
|
delta: 2
|
|
})
|
|
}, 1500)
|
|
}
|
|
} catch (e) {}
|
|
},
|
|
// 保存按钮
|
|
submit() {
|
|
let that = this
|
|
if (that.isedit == true) {
|
|
addnursingStation(that.infolist).then(res => {
|
|
if (res.code == 200) {
|
|
that.$refs.uToast.show({
|
|
title: '新增成功',
|
|
type: 'success'
|
|
})
|
|
that.show = false;
|
|
setTimeout(e => {
|
|
that.goodsList()
|
|
}, 1000)
|
|
}
|
|
})
|
|
} else {
|
|
updatenursingStation(that.infolist).then(res => {
|
|
if (res.code == 200) {
|
|
that.$refs.uToast.show({
|
|
title: '修改成功',
|
|
type: 'success'
|
|
})
|
|
that.show = false;
|
|
setTimeout(e => {
|
|
that.goodsList()
|
|
}, 1000)
|
|
} else {
|
|
that.$refs.uToast.show({
|
|
title: res.msg,
|
|
type: 'error'
|
|
})
|
|
}
|
|
})
|
|
}
|
|
},
|
|
// 修改按钮
|
|
updataxg(item) {
|
|
this.shipAddress = '修改地址'
|
|
this.isedit = false
|
|
nursingStationGoodsinfo(item.id).then(res => {
|
|
this.infolist = res.data
|
|
getSubordinate(res.data.areaCode).then(res => {
|
|
this.infolist.address = res.data.regionName + '-' + res.data.streetName
|
|
this.show = true
|
|
})
|
|
})
|
|
},
|
|
// 新增
|
|
add() {
|
|
this.infolist = {
|
|
receiveName: '',
|
|
receivePhone: '',
|
|
receiveAddress: '',
|
|
areaCode: '',
|
|
patientId: this.patientId,
|
|
}
|
|
this.isedit = true
|
|
this.show = true
|
|
},
|
|
// 删除
|
|
del(item) {
|
|
let that = this
|
|
uni.showModal({
|
|
title: '提示',
|
|
content: '确认要删除信息吗',
|
|
success: function(res) {
|
|
if (res.confirm) {
|
|
delnursingStation(item.id).then(res => {
|
|
uni.showToast({
|
|
title: '删除成功',
|
|
duration: 1000,
|
|
});
|
|
setTimeout(e => {
|
|
that.goodsList()
|
|
}, 1000)
|
|
that.delshow = false;
|
|
})
|
|
} else if (res.cancel) {}
|
|
}
|
|
});
|
|
},
|
|
// 取消
|
|
cencel() {
|
|
this.show = false
|
|
this.infolist = {}
|
|
},
|
|
// 选择区街道
|
|
areaInfo() {
|
|
getSubordinateRegions(this.areaCode).then(res => {
|
|
//区下无街道添加一个空街道
|
|
res.data.forEach(e => {
|
|
if (e.children.length == 0) {
|
|
e.children.push({
|
|
areaCode: "",
|
|
areaName: "暂无街道",
|
|
children: null,
|
|
id: '',
|
|
})
|
|
}
|
|
})
|
|
this.arealist = res.data;
|
|
})
|
|
},
|
|
//区街道选择
|
|
areaconfirm(e) {
|
|
this.infolist.areaCode = e[e.length - 1].value
|
|
this.infolist.address = e[0].label + '-' + e[1].label
|
|
},
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss">
|
|
@import './modifyAddress.scss'
|
|
</style>
|