NurseStationApp/pages/modifyAddress/modifyAddress.vue

364 lines
9.4 KiB
Vue
Raw Normal View History

2022-10-20 19:39:57 +08:00
<template>
<view class="app">
<view class="address" v-for="(item,index) in goodPatient" :key="index">
<view class="addressinfo">
2022-10-31 09:04:45 +08:00
<view class="item" @tap='goorder(item)'>
2022-12-02 16:04:52 +08:00
{{item.receiveName}},
{{item.receivePhone}}
2022-10-20 19:39:57 +08:00
</view>
2022-10-31 09:04:45 +08:00
<view class="item detail" @tap='goorder(item)'>
{{item.address}}
2022-10-20 19:39:57 +08:00
</view>
<view class="update">
2022-10-31 09:04:45 +08:00
<view class="up ups" @tap='updataxg(item)'>
2022-10-20 19:39:57 +08:00
修改
</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">
2022-12-01 17:03:02 +08:00
添加地址
2022-10-20 19:39:57 +08:00
</span>
</view>
<!-- 弹框 -->
2023-01-10 10:35:17 +08:00
<u-popup v-model="show" mode="center" width="80%" height="50%" border-radius="30" @close='cencel()'>
<view class="payment" @click.stop=''>
<span>{{shipAddress}}</span>
2022-10-20 19:39:57 +08:00
<view class="cencel" @tap="cencel()">
<image src="../../static/gb.png" mode=""></image>
</view>
<view class="addinfos">
2022-11-11 14:19:07 +08:00
<u-field v-model="infolist.receiveName" label="收货人" placeholder="姓名" class="items" maxlength='10'>
2022-10-20 19:39:57 +08:00
</u-field>
<u-field v-model="infolist.receivePhone" label="手机号" placeholder="电话" class="items" maxlength='11'>
2022-10-20 19:39:57 +08:00
</u-field>
2023-01-10 10:35:17 +08:00
<view class="area" @click="showPicker">
<!-- <view class="area" @tap='areashow=true'> -->
<u-field v-model="address" label="地区" placeholder="请选择" class="items" disabled>
2022-10-20 19:39:57 +08:00
</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'>
2022-10-20 19:39:57 +08:00
</u-field>
</view>
<view class="save" @tap='submit()'>
保存
</view>
</view>
</u-popup>
2023-01-10 10:35:17 +08:00
<!-- <u-select v-model="areashow" mode="mutil-column-auto" label-name='areaName' value-name='areaCode'
:list="arealist" @confirm="areaconfirm"></u-select> -->
2022-11-03 17:26:15 +08:00
<u-toast ref="uToast" />
2023-01-10 10:35:17 +08:00
<view class="" v-if="cityPickershow">
<m-city style='z-index: 10076;' :provinceData="list" headTitle="地区选择" ref="cityPicker"
@funcValue="getpickerParentValue" pickerSize="4">
</m-city>
</view>
2022-10-20 19:39:57 +08:00
</view>
</template>
<script>
import {
goodPatientInfo,
addnursingStation,
delnursingStation,
nursingStationGoodsinfo,
updatenursingStation,
getSubordinateRegions,
getSubordinate
2022-10-20 19:39:57 +08:00
} from '@/api/modifyAddress/modifyAddress.js';
import baseurl from '@/api/baseurl.js'
2023-01-10 10:35:17 +08:00
import gkcity from "../m-city/m-city.vue";
2022-10-20 19:39:57 +08:00
export default {
2023-01-10 10:35:17 +08:00
components: {
"m-city": gkcity
},
2022-10-20 19:39:57 +08:00
data() {
return {
2023-01-10 10:35:17 +08:00
timer: null,
2022-10-20 19:39:57 +08:00
isedit: true, //标识
delshow: false, //删除弹框
content: '确认要删除信息吗?',
show: false, //弹框
2023-01-10 10:35:17 +08:00
address: null,
// areashow: false, //经纬度开关
// arealist: [], //区街道list
areaCode: '',
2022-12-02 16:04:52 +08:00
shipAddress: '添加地址',
infolist: {
2022-10-20 19:39:57 +08:00
receiveName: '',
receivePhone: '',
receiveAddress: '',
2023-01-10 10:35:17 +08:00
areaCode: null,
2022-10-31 09:04:45 +08:00
patientId: '',
2023-01-10 10:35:17 +08:00
address: null, //页面所属区域
2022-10-20 19:39:57 +08:00
},
goodPatient: [], // 查询地址信息
2022-10-31 09:04:45 +08:00
patientId: null,
2023-01-10 10:35:17 +08:00
url: '',
2022-11-01 16:26:34 +08:00
updata: [],
2023-01-10 10:35:17 +08:00
list: [{
id: "",
localName: "请选择",
children: [],
}, ],
cityPickershow: false,
addresslength: null,
2022-10-20 19:39:57 +08:00
}
},
2023-01-10 10:35:17 +08:00
onShow() {
this.goodsList()
this.areaInfo()
},
2022-10-20 19:39:57 +08:00
onLoad(options) {
2022-10-31 09:04:45 +08:00
let that = this
this.updata = JSON.parse(options.updata)
2022-10-20 19:39:57 +08:00
},
methods: {
2023-01-10 10:35:17 +08:00
// 三级地址联动回调
getpickerParentValue(e) {
console.log(e)
this.addresslength = e
if (e.length == 4) {
this.infolist.address = e[0].localName + '-' + e[1].localName + '-' + e[2].localName + '-' + e[3]
.localName
this.address = e[0].localName + '-' + e[1].localName + '-' + e[2].localName + '-' + e[3]
.localName
this.infolist.areaCode = e[3].id
} else if (e.length == 3) {
this.infolist.address = e[0].localName + '-' + e[1].localName + '-' + e[2].localName
this.address = e[0].localName + '-' + e[1].localName + '-' + e[2].localName
this.infolist.areaCode = e[2].id
} else if (e.length == 2) {
this.infolist.address = e[0].localName + '-' + e[1].localName
this.address = e[0].localName + '-' + e[1].localName
this.infolist.areaCode = e[1].id
} else if (e.length == 1) {
this.infolist.address = e[0].localName
this.address = e[0].localName
this.infolist.areaCode = e[0].id
}
},
// 显示三级地址联动
showPicker() {
this.cityPickershow = true
this.$refs.cityPicker.show();
},
2022-10-31 09:04:45 +08:00
//将信息携带至订单页面
goorder(item) {
2022-11-09 16:38:05 +08:00
uni.$emit('updata', {
updata: JSON.stringify(this.updata),
useritem: JSON.stringify(item)
})
uni.navigateBack({
delta: 1
});
2022-10-31 09:04:45 +08:00
},
2022-10-20 19:39:57 +08:00
// 查询地址信息
goodsList() {
2022-11-01 16:26:34 +08:00
let that = this
2022-11-09 16:38:05 +08:00
try {
const value = uni.getStorageSync('patientId');
if (value) {
that.patientId = value
2022-11-01 16:26:34 +08:00
goodPatientInfo(that.patientId).then(res => {
res.data.forEach(e => {
2022-11-03 17:26:15 +08:00
e.address = e.provinceName + e.cityName + e.regionName + e
2022-11-01 16:26:34 +08:00
.streetName + e.receiveAddress
})
that.goodPatient = res.data
})
2022-12-02 16:04:52 +08:00
} else {
that.$refs.uToast.show({
title: '登录状态异常',
type: 'error'
})
if (that.timer) {
clearTimeout(that.timer)
}
that.timer = setTimeout(e => {
uni.navigateBack({
delta: 2
})
2023-01-10 10:35:17 +08:00
2022-12-02 16:04:52 +08:00
}, 1500)
2022-11-01 16:26:34 +08:00
}
2022-11-09 16:38:05 +08:00
} catch (e) {}
2022-10-20 19:39:57 +08:00
},
// 保存按钮
2023-01-10 15:26:26 +08:00
data() {
let that = this
2023-01-10 15:26:26 +08:00
if (that.isedit == true) {
addnursingStation(that.infolist).then(res => {
if (res.code == 200) {
that.$refs.uToast.show({
title: '新增成功',
type: 'success'
})
that.cencel();
setTimeout(e => {
that.goodsList()
}, 1000)
}
})
} else {
updatenursingStation(that.infolist).then(res => {
if (res.code == 200) {
that.$refs.uToast.show({
title: '修改成功',
type: 'success'
})
that.cencel();
setTimeout(e => {
that.goodsList()
}, 1000)
} else {
that.$refs.uToast.show({
title: res.msg,
type: 'error'
})
}
})
}
},
submit() {
if (this.addresslength) {
if (this.addresslength.length > 2) {
this.data();
2023-01-10 10:35:17 +08:00
} else {
2023-01-10 15:26:26 +08:00
this.$refs.uToast.show({
title: '地址不完整,请选择到区级',
type: 'error'
2023-01-10 10:35:17 +08:00
})
}
2022-10-20 19:39:57 +08:00
} else {
2023-01-10 15:26:26 +08:00
this.data()
2022-10-20 19:39:57 +08:00
}
},
// 修改按钮
2022-10-31 09:04:45 +08:00
updataxg(item) {
2023-01-10 10:35:17 +08:00
this.cityPickershow = true
2022-12-01 17:03:02 +08:00
this.shipAddress = '修改地址'
2022-10-20 19:39:57 +08:00
this.isedit = false
nursingStationGoodsinfo(item.id).then(res => {
this.infolist = res.data
getSubordinate(res.data.areaCode).then(res => {
2023-01-10 10:35:17 +08:00
if (res.data.streetName) {
this.infolist.address = res.data.provinceName + '-' + res.data.cityName +
'-' +
res
.data.regionName + '-' + res.data.streetName
this.address = res.data.provinceName + '-' + res.data.cityName +
'-' +
res
.data.regionName + '-' + res.data.streetName
} else {
this.infolist.address = res.data.provinceName + '-' + res.data.cityName +
'-' +
res
.data.regionName
this.address = res.data.provinceName + '-' + res.data.cityName +
'-' +
res
.data.regionName
}
this.show = true
})
2022-10-20 19:39:57 +08:00
})
},
// 新增
add() {
2023-01-10 10:35:17 +08:00
this.cityPickershow = true
this.infolist = {
receiveName: '',
receivePhone: '',
receiveAddress: '',
areaCode: '',
2022-10-31 09:04:45 +08:00
patientId: this.patientId,
}
2022-10-20 19:39:57 +08:00
this.isedit = true
this.show = true
},
// 删除
del(item) {
let that = this
2022-10-20 19:39:57 +08:00
uni.showModal({
title: '提示',
content: '确认要删除信息吗',
success: function(res) {
if (res.confirm) {
2023-01-10 10:35:17 +08:00
if (that.goodPatient.length == 1) {
that.$refs.uToast.show({
title: '最少保留一条地址信息',
type: 'error'
})
} else {
delnursingStation(item.id).then(res => {
that.$refs.uToast.show({
title: '删除成功',
type: 'success'
})
setTimeout(e => {
that.goodsList()
}, 1000)
that.delshow = false;
})
}
2022-12-02 16:04:52 +08:00
} else if (res.cancel) {}
2022-10-20 19:39:57 +08:00
}
});
},
// 取消
cencel() {
this.show = false
2023-01-10 10:35:17 +08:00
this.cityPickershow = false
},
// 选择区街道
areaInfo() {
2023-01-10 10:35:17 +08:00
getSubordinateRegions().then(res => {
//区下无街道添加一个空街道
2023-01-10 10:35:17 +08:00
this.list = res.data;
})
},
2023-01-10 10:35:17 +08:00
// 选择区街道
// 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
2022-10-24 15:37:38 +08:00
this.infolist.address = e[0].label + '-' + e[1].label
},
2023-01-10 10:35:17 +08:00
},
onPullDownRefresh() { //下拉刷新
this.goodsList()
setTimeout(function() {
uni.stopPullDownRefresh();
}, 1000);
},
2022-10-20 19:39:57 +08:00
}
</script>
<style lang="scss">
2022-10-24 15:37:38 +08:00
@import './modifyAddress.scss'
2022-10-20 19:39:57 +08:00
</style>