NurseStationApp/pages/modify/modify.vue
2023-03-08 09:46:11 +08:00

336 lines
9.2 KiB
Vue

<template>
<view class="app">
<view class="userinfo">
<view class="item" style="height: 200rpx; " @tap='uploadImag'>
<span style='height:200rpx;line-height: 200rpx;'>头像:</span>
<image class="picture" :src="img" mode=""></image>
<image class="pictureA" src="../../static/huijiantou.png" mode=""></image>
</view>
<view class="item">
<span>姓名:</span>
<u-input :clearable='false' v-model="appPersonallist.patientName" placeholder="请输入" type="text"
maxlength='5' />
</view>
<!-- <view class="item">
<span>电话:</span>
<u-input :clearable='false' v-model="appPersonallist.phone" placeholder="请输入" maxlength='11' type="text" />
</view> -->
<view class="item">
<span>身份证号:</span>
<u-input :clearable='false' v-model="appPersonallist.cardNo" placeholder="请输入" type="text"
maxlength='18' />
</view>
<view class="item" @tap='showPicker'>
<span>所属区域:</span>
<view class="address">{{address}}</view>
</view>
<view class="item">
<span>详细地址:</span>
<u-input :clearable='false' v-model="appPersonallist.address" type="text" placeholder='小区、单元、门牌号' />
</view>
<view class="item" @tap='getAddress'>
<span>所在位置:</span>
<view class="address" style="overflow: hidden;text-overflow: ellipsis;white-space: nowrap;">
{{appPersonallist.locationName}}
</view>
</view>
<view class="disease" style="border: none;" @tap="godisease">
<view style="display: block;line-height: 120rpx;">疾病类型:</view>
<image class="pictureA" src="../../static/huijiantou.png" mode=""></image>
<view class="" style="padding-right: 10rpx" v-for="(item,index) in patientDiseaseInfoList">
{{item.diseaseName}}
</view>
</view>
</view>
<view class="radio-content">
<view class="radio-right" @tap="changeRadio">
<view class="radio" :class="radio == 2 ? 'radio-default':''">
<view :class="radio == 2 ? 'radio-active':''"></view>
</view>
</view>
<view class="agreement">我已阅读并同意<text @tap='maskshow=true'
style="color: #000000;border-bottom: 1rpx solid #000000;">《用户协议》</text>
</view>
</view>
<view class="finish" @tap="informationinfo()">完成
</view>
<u-toast ref="uToast" />
<!-- //用户协议 -->
<u-mask :show="maskshow" class='mask' @click='maskshow=false'>
<view class="Agreement">
<view class="title">
用户协议与隐私政策
</view>
<scroll-view scroll-y="true" class="scroll-Y" style="">
<contenttext></contenttext>
</scroll-view>
<view class="cancel" @tap='maskshow=false'>
取消
</view>
<view class="determine" @tap='tapradio'>
确定并同意
</view>
</view>
</u-mask>
<view class="">
<m-city style='z-index: 10076;' :provinceData="list" headTitle="地区选择" ref="cityPicker"
@funcValue="getpickerParentValue" pickerSize="4">
</m-city>
</view>
</view>
</template>
<script>
import {
getRegionAndStreetInfo
} from '@/api/information/index.js'
import {
information
} from '@/api/information/index.js'
import contenttext from '../information/text.vue'
import baseurl from '@/api/baseurl.js'
import gkcity from "../m-city/m-city.vue";
import {
getSubordinateRegions,
} from '@/api/modifyAddress/modifyAddress.js';
import {
appPersonal,
} from '@/api/user/user.js';
export default {
components: {
contenttext,
"m-city": gkcity
},
data() {
return {
radio: 1,
timer: null,
baseurl: '',
address: '',
list: [{
id: "",
localName: "请选择",
children: [],
}, ],
maskshow: false, //用户协议
chooseLocation: '',
img: null,
image: null,
appPersonallist: {
patientName: "",
cardNo: "",
phone: "",
address: "",
areaCode: "",
homeLongitude: "",
homeLatitude: "",
nurseTypeIdList: [],
diseaseInfoList: [],
headPictureUrl: '',
locationName: '',
},
patientDiseaseInfoList: [], //获取个人信息
addresslength: null,
}
},
onLoad(options) {
var that = this
this.areaInfo();
this.baseurl = baseurl
const value = uni.getStorageSync('patientId');
if (value) {
appPersonal(value).then(Response => {
if (Response.code == 200) {
that.appPersonallist = Response.data
that.appPersonallist.homeLatitude = Number(that.appPersonallist.homeLatitude)
that.appPersonallist.homeLongitude = Number(that.appPersonallist.homeLongitude)
that.img = baseurl + that.appPersonallist.headPictureUrl
if (that.appPersonallist.areaName) {
that.address = that.appPersonallist.areaName
}
that.patientDiseaseInfoList = that.appPersonallist.patientDiseaseInfoList
that.patientDiseaseInfoList.forEach(e => {
e.id = e.diseaseId
})
} else if (Response.code == 9999) {} else {}
})
} else {}
},
methods: {
// 三级地址联动回调
getpickerParentValue(e) {
this.addresslength = e
if (e.length == 4) {
this.address = e[0].localName + e[1].localName + e[2].localName + e[3]
.localName
this.appPersonallist.areaCode = e[3].id
} else if (e.length == 3) {
this.address = e[0].localName + e[1].localName + e[2].localName
this.appPersonallist.areaCode = e[2].id
} else if (e.length == 2) {
this.address = e[0].localName + e[1].localName
this.appPersonallist.areaCode = e[1].id
} else if (e.length == 1) {
this.address = e[0].localName
this.appPersonallist.areaCode = e[0].id
}else {
this.address = ''
this.appPersonallist.areaCode = ''
}
},
// 显示三级地址联动
showPicker() {
this.$refs.cityPicker.show();
},
data() {
var that = this
if (that.radio == 1) {
that.$refs.uToast.show({
title: '请审核并同意用户协议',
type: 'error'
})
} else {
if (that.image) {
uni.uploadFile({
url: baseurl + '/nurseApplet/uploadFile/uploadHeadPictureUrl',
filePath: that.appPersonallist.headPictureUrl,
name: 'file',
formData: {
'patientId': that.appPersonallist.patientId
},
timeout: 5000,
success(res) {
that.appPersonallist.headPictureUrl = JSON.parse(res.data).imgUrl
that.appPersonallist.diseaseInfoList = that.patientDiseaseInfoList
information(that.appPersonallist).then(res => {
if (res.code == 200) {
that.$refs.uToast.show({
title: '修改信息成功',
type: 'success',
duration: '1500'
})
if (that.timer) {
clearTimeout(that.timer)
}
that.timer = setTimeout(e => {
uni.navigateBack({
delta: 1
})
}, 1500)
} else if (res.code == 500) {
that.$refs.uToast.show({
title: res.msg,
type: 'error',
url: ''
})
}
})
}
})
} else {
that.appPersonallist.diseaseInfoList = that.patientDiseaseInfoList
information(that.appPersonallist).then(res => {
if (res.code == 200) {
that.$refs.uToast.show({
title: '修改信息成功',
type: 'success',
duration: '1500'
})
if (that.timer) {
clearTimeout(that.timer)
}
that.timer = setTimeout(e => {
uni.navigateBack({
delta: 1
})
}, 1500)
} else if (res.code == 500) {
that.$refs.uToast.show({
title: res.msg,
type: 'error',
url: ''
})
}
})
}
}
},
informationinfo() {
//上传图片
var that = this
if (this.addresslength) {
if (this.addresslength.length > 2) {
that.data();
} else {
that.$refs.uToast.show({
title: '所属区域应选择所在的区或街道,请重新选择!',
type: 'error'
})
}
} else {
that.data();
}
},
//上传头像
uploadImag() {
var that = this;
uni.chooseImage({
count: 1,
sourceType: ['album'],
success(res) {
that.appPersonallist.headPictureUrl = res.tempFilePaths[0]
that.img = res.tempFilePaths[0]
that.image = res.tempFilePaths[0]
}
})
},
tapradio() {
this.radio = 2;
this.maskshow = false;
},
changeRadio() {
if (this.radio == 1) {
this.radio = 2;
} else {
this.radio = 1;
}
},
//获取所在位置
getAddress() {
var that = this;
uni.chooseLocation({
success: function(res) {
that.appPersonallist.locationName = res.address
that.appPersonallist.homeLongitude = res.longitude;
that.appPersonallist.homeLatitude = res.latitude;
}
});
},
//区街道
areaInfo() {
getSubordinateRegions().then(res => {
this.list = res.data;
})
},
//跳转疾病选择
godisease() {
uni.navigateTo({
url: `/pages/disease/disease?diseaseInfoList=${JSON.stringify(this.patientDiseaseInfoList)}`,
})
},
},
//带参返回
onShow() {
let that = this
uni.$on('disease', function(data) {
that.patientDiseaseInfoList = JSON.parse(data.disease)
})
}
}
</script>
<style lang="scss">
@import "./modify.scss"
</style>