nurseWeChatAppletUI/pages/modify/modify.vue

320 lines
9.2 KiB
Vue
Raw Normal View History

<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/jiantou.png" mode=""></image>
</view>
<view class="item">
<span>姓名:</span>
<u-input :clearable='false' v-model="appPersonallist.patientName" placeholder="请输入" type="text"
maxlength='15' />
</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='areashow=true'>
<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;">
2022-12-28 08:50:08 +08:00
{{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/jiantou.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>
<u-select v-model="areashow" mode="mutil-column-auto" label-name='areaName' value-name='areaCode'
:list="arealist" @confirm="areaconfirm"></u-select>
<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>
</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'
2022-12-28 08:50:08 +08:00
import {
appPersonal,
} from '@/api/user/user.js';
export default {
components: {
contenttext
},
data() {
return {
radio: 1,
baseurl: '',
address: '',
arealist: [],
areashow: false,
2022-12-28 08:50:08 +08:00
maskshow: false, //用户协议
img: null,
image: null,
timer: null,
appPersonallist: {
patientName: "",
cardNo: "",
phone: "",
address: "",
areaCode: "",
homeLongitude: "",
homeLatitude: "",
nurseTypeIdList: [],
diseaseInfoList: [],
headPictureUrl: '',
locationName: '',
},
patientDiseaseInfoList: [], //获取个人信息
}
},
onLoad(options) {
this.areaInfo();
this.baseurl = baseurl
2022-12-28 08:50:08 +08:00
var that = this
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.regionName && that.appPersonallist.streetName) {
that.address = that.appPersonallist.regionName + '-' + that.appPersonallist.streetName
}
that.patientDiseaseInfoList = that.appPersonallist.patientDiseaseInfoList
that.patientDiseaseInfoList.forEach(e => {
e.id = e.diseaseId
})
} else if (Response.code == 9999) {} else {}
})
} else {}
},
methods: {
//上传图片+提交信息
informationinfo() {
//上传图片
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: ''
})
}
})
}
}
},
//上传头像
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() {
uni.getLocation({
type: 'wgs84',
success: function(res) {
const key = '3VABZ-6LZWK-YPAJ3-AMQED-D7RUK-VPB37'; //使用在腾讯位置服务申请的key
const referer = '泉医到家'; //调用插件的app的名称
const location = JSON.stringify({
latitude: 39.89631551,
longitude: 116.323459711
});
wx.navigateTo({
url: 'plugin://chooseLocation/index?key=' + key + '&referer=' + referer
});
}
});
},
//区街道选择
areaconfirm(e) {
this.appPersonallist.areaCode = e[e.length - 1].value
this.address = e[0].label + '-' + e[1].label
},
//区街道
areaInfo() {
getRegionAndStreetInfo().then(res => {
//区下无街道添加一个空街道
res.data.forEach(e => {
if (e.children.length == 0) {
e.children.push({
areaCode: "",
areaName: "暂无街道",
children: null,
id: '',
})
}
})
this.arealist = res.data;
})
},
//跳转疾病选择
godisease() {
uni.navigateTo({
url: `/pages/disease/disease?diseaseInfoList=${JSON.stringify(this.patientDiseaseInfoList)}`,
})
},
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() {
2022-12-28 08:50:08 +08:00
let that = this
const chooseLocation = requirePlugin('chooseLocation');
const location = chooseLocation.getLocation(); // 如果点击确认选点按钮则返回选点结果对象否则返回null
if (location) {
2022-12-28 08:50:08 +08:00
console.log(location)
that.appPersonallist.locationName = location.address
that.appPersonallist.homeLongitude = location.longitude;
that.appPersonallist.homeLatitude = location.latitude;
}
uni.$on('disease', function(data) {
that.patientDiseaseInfoList = JSON.parse(data.disease)
})
},
}
</script>
<style lang="scss">
@import "./modify.scss"
</style>