NurseStationApp/pages/modifyAddress/modifyAddress.vue

272 lines
6.9 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)'>
{{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">
添加收货地址
</span>
</view>
<!-- 弹框 -->
2022-10-31 09:04:45 +08:00
<u-popup v-model="show" mode="center" width="80%" height="50%" border-radius="30">
2022-10-20 19:39:57 +08:00
<view class="payment">
<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">
<u-field v-model="infolist.receiveName" label="收货人" placeholder="姓名" class="items" maxlength='30'>
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>
<view class="area" @tap='areashow=true'>
<u-field v-model="infolist.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>
<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" />
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'
export default {
data() {
return {
isedit: true, //标识
delshow: false, //删除弹框
content: '确认要删除信息吗?',
show: false, //弹框
areashow: false, //经纬度开关
arealist: [], //区街道list
areaCode: '',
shipAddress: '添加收货地址',
infolist: {
2022-10-20 19:39:57 +08:00
receiveName: '',
receivePhone: '',
receiveAddress: '',
areaCode: '',
2022-10-31 09:04:45 +08:00
patientId: '',
address: '', //页面所属区域
2022-10-20 19:39:57 +08:00
},
goodPatient: [], // 查询地址信息
2022-10-31 09:04:45 +08:00
patientId: null,
2022-11-01 16:26:34 +08:00
url: '',
updata: [],
2022-10-20 19:39:57 +08:00
}
},
onLoad(options) {
2022-10-31 09:04:45 +08:00
let that = this
2022-11-01 16:26:34 +08:00
this.url = options.url
2022-10-31 09:04:45 +08:00
this.updata = JSON.parse(options.updata)
2022-10-20 19:39:57 +08:00
//获取传值
this.goodsList()
this.areaInfo()
2022-10-20 19:39:57 +08:00
},
methods: {
2022-10-31 09:04:45 +08:00
//将信息携带至订单页面
goorder(item) {
2022-11-09 16:38:05 +08:00
// if (this.url == "appointmenttime") {
uni.$emit('updata', {
updata: JSON.stringify(this.updata),
useritem: JSON.stringify(item)
})
uni.navigateBack({
delta: 1
});
// uni.navigateTo({
// url: `/pages/appointmenttime/appointmenttime?updata=${JSON.stringify(this.updata)}&useritem=${JSON.stringify(item)}`
// })
// } else {
// uni.navigateTo({
// url: `/pages/confirmOrder/confirmOrder?updata=${JSON.stringify(this.updata)}&useritem=${JSON.stringify(item)}`
// })
// }
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
that.infolist.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-11-09 16:38:05 +08:00
} catch (e) {}
// uni.getStorage({
// key: 'patientId',
// success: function(res) {
// that.patientId = res.data
// that.infolist.patientId = res.data
// 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
// })
// }
// });
2022-10-20 19:39:57 +08:00
},
// 保存按钮
submit() {
let that = this
2022-10-20 19:39:57 +08:00
if (that.isedit == true) {
addnursingStation(that.infolist).then(res => {
2022-10-20 19:39:57 +08:00
if (res.code == 200) {
uni.showToast({
title: '新增成功',
duration: 1500
});
that.show = false;
setTimeout(e => {
that.goodsList()
}, 1500)
2022-10-20 19:39:57 +08:00
}
})
} else {
updatenursingStation(that.infolist).then(res => {
2022-10-20 19:39:57 +08:00
uni.showToast({
title: '修改成功',
duration: 1500
2022-10-20 19:39:57 +08:00
});
that.show = false;
setTimeout(e => {
that.goodsList()
}, 1500)
2022-10-20 19:39:57 +08:00
})
}
},
// 修改按钮
2022-10-31 09:04:45 +08:00
updataxg(item) {
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 => {
2022-10-31 09:04:45 +08:00
this.infolist.address = res.data.regionName + '-' + res.data.streetName
this.show = true
})
2022-10-20 19:39:57 +08:00
})
},
// 新增
add() {
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) {
delnursingStation(item.id).then(res => {
uni.showToast({
title: '删除成功',
duration: 1500,
});
setTimeout(e => {
that.goodsList()
}, 1500)
that.delshow = false;
2022-10-20 19:39:57 +08:00
})
} else if (res.cancel) {
console.log('用户点击取消');
}
}
});
},
// 取消
cencel() {
this.show = false
this.infolist = {}
// this.address=""
},
// 选择区街道
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.address = e[0].label + '-' + e[1].label
this.infolist.address = e[0].label + '-' + e[1].label
},
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>