xinelu-applet-ui/pagesB/modify/modify.vue

458 lines
13 KiB
Vue
Raw Normal View History

2023-09-22 11:08:14 +08:00
<template>
<view class="app">
<view class="userinfo">
<view class="itemimgs">
<image class="picture" :src="img" mode="" v-if="img" @tap='uploadImag'></image>
2023-10-10 10:24:50 +08:00
<image class="picture" src="../../static/headsculpture.png" mode="" v-else @tap='uploadImag'></image>
2023-09-22 15:29:53 +08:00
<view class="text" @tap='uploadImag'>
点击编辑头像
</view>
2023-09-22 11:08:14 +08:00
</view>
<view class="item">
<span>姓名</span>
<u-input :clearable='false' v-model="appPersonallist.patientName" placeholder="请输入" type="text"
maxlength='30' />
</view>
<view class="item">
<span>性别</span>
<u-radio-group v-model="appPersonallist.sex" size='44'>
<u-radio @change='sexchange' v-for="(item, index) in sexlist" :key="index" :name="item.name"
:disabled="item.disabled">
{{item.name}}
</u-radio>
</u-radio-group>
</view>
<!-- <view class="item">
<span>电话:</span>
<u-input :clearable='false' v-model="appPersonallist.phone" placeholder="请输入" maxlength='11'
type="number" />
</view> -->
<view class="item" @tap='timeshow=true'>
<span>出生日期</span>
<view class="address" style="" v-if="appPersonallist.birthDate">
{{appPersonallist.birthDate}}
</view>
</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" maxlength='40'
placeholder='小区、单元、门牌号' />
</view>
<view class="item" @tap='getAddress()'>
<span>所在位置:</span>
<view class="address" style="overflow: hidden;text-overflow: ellipsis;white-space: nowrap;"
v-if="appPersonallist.locationName">
{{appPersonallist.locationName}}
</view>
<view class="address" style="overflow: hidden;text-overflow: ellipsis;white-space: nowrap;" v-else>
</view>
</view>
2023-10-13 15:17:41 +08:00
<view class="name">
<span>基础疾病</span>
<view class="select">
<ld-select :multiple="true" :list="options" label-key="label" value-key="value" placeholder="请选择"
v-model="value2" @change="selectChange" @cancel="cancel" @confirm="confirm"></ld-select>
</view>
</view>
2023-09-22 11:08:14 +08:00
</view>
<view class="radio-content">
<view class="radio-right" @click='changeRadio'>
<view class="radio" :class="radio == 2 ? 'radio-default':''">
<view :class="radio == 2 ? 'radio-active':''"></view>
</view>
</view>
<view class="agreement" @click.stop='changeRadio'>我已阅读并同意<text @click.stop='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>
<u-picker mode="time" v-model="timeshow" :params="params" @confirm='timechange' @canel='timeshow=false'>
</u-picker>
</view>
</template>
<script>
import {
getRegionAndStreetInfo
2023-09-22 11:30:57 +08:00
} from '@/api/pagesB/information/index.js'
2023-09-22 11:08:14 +08:00
import contenttext from '../../components/text.vue'
import baseurl from '@/api/baseurl.js'
import {
appPersonal,
2023-09-22 15:07:20 +08:00
} from '@/api/pages/myinformation/myinformation.js';
2023-09-22 11:08:14 +08:00
import {
getSubordinateRegions,
2023-09-22 11:30:57 +08:00
} from '@/api/pagesB/modifyAddress/modifyAddress.js';
2023-09-22 11:08:14 +08:00
import gkcity from "../../components/m-city/m-city.vue";
2023-10-13 15:17:41 +08:00
import {
registerdata
} from '@/api/pages/register/register.js'
2023-09-22 11:08:14 +08:00
export default {
components: {
contenttext,
"m-city": gkcity
},
data() {
return {
params: {
year: true,
month: true,
day: true,
hour: false,
minute: false,
second: false
},
2023-10-13 15:17:41 +08:00
value2: [],
options: [{
value: '1',
label: '高血压'
}, {
value: '2',
label: '高血糖'
}, {
value: '3',
label: '高血脂'
}, {
value: '0',
label: '无'
}],
2023-09-22 11:08:14 +08:00
timeshow: false, //出生日期
sexlist: [{
name: '男',
disabled: false
},
{
name: '女',
disabled: false
}
],
list: [{
id: "",
localName: "请选择",
children: [],
}, ],
radio: 1,
baseurl: '',
address: '',
maskshow: false, //用户协议
img: null,
image: null,
timer: null,
appPersonallist: {
patientName: "",
cardNo: "",
phone: "",
address: "",
areaCode: "",
homeLongitude: null,
homeLatitude: null,
nurseTypeIdList: [],
diseaseInfoList: [],
2023-10-13 15:17:41 +08:00
diseaseList: [],
2023-09-22 11:08:14 +08:00
headPictureUrl: '',
birthDate: '',
locationName: '',
sex: '',
2023-10-13 15:17:41 +08:00
cityCode: '1',
2023-09-22 11:08:14 +08:00
},
addresslength: null,
}
},
onLoad(options) {
2023-10-13 15:17:41 +08:00
console.log(options, '555')
2023-09-22 11:08:14 +08:00
this.areaInfo();
this.baseurl = baseurl
var that = this
2023-10-13 15:17:41 +08:00
const value = uni.getStorageSync('userinfo');
2023-09-22 11:08:14 +08:00
if (value) {
2023-10-13 15:17:41 +08:00
const patientid = value.id
appPersonal(patientid).then(Response => {
2023-09-22 11:08:14 +08:00
if (Response.code == 200) {
2023-10-13 15:17:41 +08:00
if (Response.data.sex == 'MALE') {
that.appPersonallist.sex = '男';
} else if (Response.data.sex == 'FEMALE') {
that.appPersonallist.sex = '女';
}
2023-09-22 11:08:14 +08:00
that.appPersonallist = Response.data
2023-10-16 11:23:57 +08:00
that.value2=Response.data.diseaseList.map(String)
2023-09-22 11:30:57 +08:00
Number(that.appPersonallist.homeLatitude) > 0 ? that.appPersonallist.homeLatitude = Number(
that.appPersonallist.homeLatitude) : that.appPersonallist.homeLatitude = null
Number(that.appPersonallist.homeLongitude) > 0 ? that.appPersonallist.homeLongitude =
Number(that.appPersonallist.homeLongitude) : that.appPersonallist.homeLongitude = null
2023-09-22 11:08:14 +08:00
if (that.appPersonallist.headPictureUrl) {
that.img = baseurl + that.appPersonallist.headPictureUrl
}
2023-10-13 15:17:41 +08:00
console.log(Response)
2023-09-22 11:08:14 +08:00
if (that.appPersonallist.areaName) {
that.address = that.appPersonallist.areaName
}
} else if (Response.code == 9999) {} else {
uni.navigateBack({
delta: 1
})
}
})
} else {}
},
methods: {
2023-10-13 15:17:41 +08:00
confirm(e) {
this.appPersonallist.diseaseList = e.map(Number)
},
// 下拉框多选
selectChange(val) {
console.log(val);
},
cancel() {},
2023-09-22 11:08:14 +08:00
//性别
sexchange(e) {
if (e == '男') {
this.appPersonallist.sex = 'MALE';
} else if (e == '女') {
this.appPersonallist.sex = 'FEMALE';
}
},
//选择出生日期
timechange(e) {
this.appPersonallist.birthDate = e.year + '-' + e.month + '-' + e.day
},
// 三级地址联动回调
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
2023-10-13 15:17:41 +08:00
that.appPersonallist.openid = uni.getStorageSync('openid');
2023-09-22 11:08:14 +08:00
if (that.appPersonallist.sex == '男') {
that.appPersonallist.sex = 'MALE';
} else if (that.appPersonallist.sex == '女') {
that.appPersonallist.sex = 'FEMALE';
}
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
2023-10-13 15:17:41 +08:00
that.appPersonallist.cityCode = '1'
console.log(that.appPersonallist.sex,'4')
registerdata(that.appPersonallist).then(res => {
2023-09-22 11:08:14 +08:00
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 {
2023-10-13 15:17:41 +08:00
that.appPersonallist.cityCode = '1'
registerdata(that.appPersonallist).then(res => {
2023-09-22 11:08:14 +08:00
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',
})
}
})
}
}
},
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,
sizeType: ['original'],
sourceType: ['album'],
success(res) {
that.appPersonallist.headPictureUrl = res.tempFilePaths[0]
that.img = res.tempFilePaths[0]
that.image = res.tempFilePaths[0]
}
})
},
//获取所在位置
getAddress() {
var that = this;
uni.chooseLocation({
success: function(res) {
that.appPersonallist.locationName = res.address
that.appPersonallist.homeLongitude = res.longitude;
that.appPersonallist.homeLatitude = res.latitude;
}
});
},
// //获取所在位置
// getAddress() {
// uni.getLocation({
// type: 'wgs84',
// success: function(res) {
// const key = '3VABZ-6LZWK-YPAJ3-AMQED-D7RUK-VPB37'; //使用在腾讯位置服务申请的key
2023-09-22 11:45:09 +08:00
// const referer = '新医路健康服务平台'; //调用插件的app的名称
2023-09-22 11:08:14 +08:00
// const location = JSON.stringify({
// latitude: 39.89631551,
// longitude: 116.323459711
// });
// wx.navigateTo({
// url: 'plugin://chooseLocation/index?key=' + key + '&referer=' + referer
// });
// }
// });
// },
//区街道
areaInfo() {
getSubordinateRegions().then(res => {
this.list = res.data;
})
},
changeRadio() {
if (this.radio == 1) {
this.radio = 2;
} else {
this.radio = 1;
}
},
tapradio() {
this.radio = 2;
this.maskshow = false;
},
},
onUnload() {
// 页面卸载时设置插件选点数据为null防止再次进入页面geLocation返回的是上次选点结果
// chooseLocation.setLocation(null);
},
//带参返回
onShow() {
2023-09-22 15:29:53 +08:00
// let that = this
// // const chooseLocation = requirePlugin('chooseLocation');
// // const location = chooseLocation.getLocation(); // 如果点击确认选点按钮则返回选点结果对象否则返回null
// // if (location) {
// // that.appPersonallist.locationName = location.address
// // that.appPersonallist.homeLongitude = location.longitude;
// // that.appPersonallist.homeLatitude = location.latitude;
// // }
// uni.$on('disease', function(data) {
2023-10-13 17:32:38 +08:00
// console.log(data,'777')
2023-09-22 15:29:53 +08:00
// that.patientDiseaseInfoList = JSON.parse(data.disease)
// uni.$off('disease')
// })
2023-09-22 11:08:14 +08:00
},
}
</script>
<style lang="scss">
@import "./modify.scss"
2023-09-22 15:07:20 +08:00
</style>