| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700 |
- <template>
- <view class="user-info-wrap">
- <view class="nav-bar">
- <view class="nav-content">
- <view class="nav-info">
- <view class="nav-desc">
- <view class="nav-name">
- <!-- <view class="">宝贝头像</view>-->
- </view>
- </view>
- <view class="arrow-right">
- <view class="head-img" @click="uploadImg1(1)">
- <image v-if="userInfo.facePhotoUrl" :src="userInfo.facePhotoUrl" mode="aspectFill"></image>
- <image v-else src="../../static/me/u1796.png" mode=""></image>
- </view>
- <!-- <u-icon name="arrow-right" color="#666" size="26"></u-icon> -->
- </view>
- </view>
- </view>
- <view class="custom-line"></view>
- <view class="nav-content">
- <view class="nav-info">
- <view class="nav-desc">
- <view class="nav-name">
- <view class="">宝贝昵称</view>
- </view>
- </view>
- <view class="arrow-right">
- <input class="custom-input" v-model="userInfo.nickName" type="text" placeholder="请输入昵称">
- </view>
- </view>
- </view>
- <view class="custom-line"></view>
- <view class="nav-content">
- <view class="nav-info">
- <view class="nav-desc">
- <view class="nav-name">
- <view class="">宝贝性别</view>
- </view>
- </view>
- <view @click="chooseGender()" class="arrow-right">
- <view class="change-store">
- <text v-if="userInfo.sex == 0">男</text>
- <text v-else-if="userInfo.sex == 1">女</text>
- <text v-else-if="userInfo.sex == 2">未知</text>
- <text v-else>请选择性别</text>
- </view>
- <u-icon name="arrow-right" color="#666" size="16"></u-icon>
- </view>
- </view>
- </view>
- <view class="custom-line"></view>
- <view class="nav-content">
- <view class="nav-info">
- <view class="nav-desc">
- <view class="nav-name">
- <view class="">宝贝生日</view>
- </view>
- </view>
- <view class="arrow-right">
- <!-- <picker mode="date" :value="date" :start="date" @change="bindDateChange">-->
- <!-- <view class="picker-change-store">-->
- <!-- <text v-if="userInfo.birthday">{{ userInfo.birthday }}</text>-->
- <!-- <text v-else>请选择生日</text>-->
- <!-- <u-icon name="arrow-right" color="#666" size="16"></u-icon>-->
- <!-- </view>-->
- <!-- </picker>-->
- <picker @change="bindDateChange" mode='date' range-key="label" >
- <view class="flex-row justify-end picker-change-store">
- <text>{{userInfo.birthday || '请选择出生日期' }}</text>
- <u-icon name="arrow-right" color="#666" size="16"></u-icon>
- </view>
- </picker>
- </view>
- </view>
- </view>
- <view class="custom-line"></view>
- <view class="nav-content">
- <view class="nav-info">
- <view class="nav-desc">
- <view class="nav-name">
- <view class="">是否双胞胎</view>
- </view>
- </view>
- <view class="arrow-right">
- <view class="change-store">
- <u-radio-group
- v-model="userInfo.ranks"
- size="14"
- @change="handleRankChange"
- placement="row">
- <u-radio activeColor="#eac00f" name="0" label="否"></u-radio>
- <u-radio activeColor="#eac00f" name="1" label="是"></u-radio>
- </u-radio-group>
- </view>
- </view>
- </view>
- </view>
- <view v-if="userInfo.ranksState == '1'" class="custom-line"></view>
- <view v-if="userInfo.ranksState == '1'" class="nav-content">
- <view class="nav-info">
- <view class="nav-desc">
- <view class="nav-name">
- <view class="">宝贝排行</view>
- </view>
- </view>
- <view class="arrow-right button-group">
- <text class="button" @click="decrement">-</text>
- <input class="custom-input-ranks" v-model="userInfo.ranks" type="number">
- <text class="button" @click="increment">+</text>
- </view>
- <!-- <view @click="gotoRealNameAuth()" class="arrow-right">
- <view class="change-store">
- <u-radio-group
- v-model="userInfo.ranks"
- size="14"
- placement="row">
- <u-radio activeColor="#eac00f" name="1" label="老大"></u-radio>
- <u-radio activeColor="#eac00f" name="2" label="老二"></u-radio>
- <u-radio activeColor="#eac00f" name="3" label="老三"></u-radio>
- <u-radio activeColor="#eac00f" name="4" label="老四"></u-radio>
- </u-radio-group>
- </view>
- </view> -->
- </view>
- </view>
- <view class="custom-line"></view>
- <!-- <view class="nav-content">
- <view class="nav-info">
- <view class="nav-desc">
- <view class="nav-name">
- <view class="">服务对象编号</view>
- </view>
- </view>
- <view @click="gotoRealNameAuth()" class="arrow-right">
- <view class="change-store">
- <text>NTML0801</text>
- </view>
- </view>
- </view>
- </view>
- <view class="custom-line"></view> -->
- <view class="nav-content">
- <view class="nav-info">
- <view class="nav-desc">
- <view class="nav-name">
- <view class="">关系</view>
- </view>
- </view>
- <view class="arrow-right">
- <input class="custom-input" v-model="userInfo.blood" type="text" placeholder="请输入关系">
- </view>
- </view>
- </view>
- <view class="custom-line"></view>
- <view class="nav-content">
- <view class="nav-info">
- <view class="nav-desc">
- <view class="nav-name">
- <view class="">是否监护人</view>
- </view>
- </view>
- <view class="arrow-right">
- <view class="change-store">
- <u-radio-group
- size="14"
- v-model="userInfo.wardship"
- placement="row">
- <u-radio class="radio-item" activeColor="#eac00f" name="2" label="否"></u-radio>
- <u-radio class="radio-item" activeColor="#eac00f" name="1" label="是"></u-radio>
- </u-radio-group>
- </view>
- </view>
- </view>
- </view>
- <view class="custom-line"></view>
- <view class="nav-content">
- <view class="nav-info">
- <view class="nav-desc">
- <view class="nav-name">
- <view class="">备注</view>
- </view>
- </view>
- <view class="arrow-right">
- <input class="custom-input" v-model="userInfo.remark" type="text" placeholder="请输入备注">
- </view>
- </view>
- </view>
- <view class="custom-line"></view>
- <view class="nav-content" v-if="userInfo.minMainCardStatus">
- <view class="nav-info" style="align-items: normal">
- <view class="nav-desc">
- <view class="nav-name">
- <view class="">服务项目</view>
- </view>
- </view>
- <view class="arrow-right">
- <uni-data-checkbox mode="button" multiple v-model="userInfo.serviceProjectId"
- :localdata="serviceProjectList"/>
- </view>
- </view>
- </view>
- </view>
- <view @click="saveUserInfo()" class="sure-btn">
- <view class="btn">保存</view>
- </view>
- <!-- 性别选择 -->
- <u-picker :show="genderShow" keyName="gender" @confirm="sureChooseGender" :columns="genderList"></u-picker>
- <cropper selWidth="660rpx" selHeight="660rpx" ref="cropper" quality="0.5" @uploadImg="uploadCropImg" @upload="userInfo.facePhotoUrl" />
- </view>
- </template>
- <script>
- import cropper from '@/components/lxiaoxiao-cropper/lxiaoxiao-cropper.vue';
- export default {
- components: {
- cropper
- },
- data() {
- return {
- accessToken: null,
- isAuthUpdate: false,
- serviceProjectList: [],
- userInfo: {
- auth: true,
- nickName: '',
- sex: '1',
- birthday: '',
- selfPhoto: '',
- memberType: '',
- facePhotos: '',
- facePhoto: '',
- ranks: 0,
- wardship: '1',
- blood: '',
- ranksState: '0',
- facePhotoUrl: '',
- name: '',
- authBook: '',
- signPhoto: '',
- remark: '',
- serviceProjectId: []
- },
- genderShow: false,
- date: Number(new Date()),
- // 服务时间
- genderList: [
- [{gender: '男', id: '0'},
- {gender: '女', id: '1'},
- {gender: '未知', id: '2'}
- ],
- ],
- imgUrl1: '',
- requestStatus: false,
- };
- },
- mounted() {
- },
- onLoad(option) {
- this.accessToken = uni.getStorageSync("accessToken");
- this.getServiceObjectList()
- if (option.data) {
- const data = JSON.parse(option.data);
- console.log('+++++++JSON.parse(option.data)++++++', option.data)
- if(data.authServiceIds){
- this.userInfo.serviceProjectId = data.authServiceIds.split(',');
- }
- this.userInfo.facePhotoUrl = data.facePhotoUrl;
- this.userInfo.minMainCardStatus = data.minMainCardStatus;
- this.userInfo.facePhoto = data.facePhoto;
- this.userInfo.facePhotos = data.facePhoto;
- this.userInfo.birthday = data.birthday;
- this.userInfo.memberType = data.memberType;
- this.userInfo.ranks = data.ranks;
- this.userInfo.wardship = data.wardship;
- this.userInfo.blood = data.blood;
- this.userInfo.ranksState = data.ranksState;
- this.userInfo.name = data.name;
- this.userInfo.authBook = data.authBook;
- this.userInfo.signPhoto = data.signPhoto;
- this.userInfo.sex = data.sex;
- this.userInfo.nickName = data.nickName;
- this.userInfo.remark = data.remark;
- this.userInfo.id = data.id;
- if (this.userInfo.id){
- this.getServiceObjectPhotoRecord(this.userInfo.id)
- }
- console.log('+++++++JSON.parse(option.data)++++++', this.userInfo)
- }
- },
- methods: {
- uploadCropImg(e){
- uni.compressImage({
- src: e,
- success: res => {
- uni.uploadFile({
- url: this.$baseUrl + '/resource/oss/upload',
- filePath:res.tempFilePath,
- name: 'file',
- header: {
- 'Authorization': 'Bearer ' + uni.getStorageInfo('accessToken'),
- },
- success: (uploadFileRes) => {
- let res = JSON.parse(uploadFileRes.data)
- console.log(res,'成功回调')
- if(res.code !== 200){
- uni.showToast({
- icon: 'none',
- duration: 3000,
- title: res.msg || '系统繁忙,请重试!'
- });
- }
- res.data.url.replace("http", "https");
- this.verifyFace(res.data)
- this.userInfo.facePhotoUrl = res.data.url.replace("http", "https");
- }
- });
- }
- })
- },
- getServiceObjectPhotoRecord(serviceObjectId){
- this.$api.getServiceObjectPhotoRecord(
- {
- serviceObjectId:serviceObjectId
- }).then(res=>{
- console.log(res)
- if (res.data.data){
- uni.showModal({
- title:"温馨提示",
- content:"当前服务对象已授权,照片可修改",
- showCancel: false,
- success: function (res) {
- if (res.confirm) {
- console.log('用户点击确定');
- } else if (res.cancel) {
- console.log('用户点击取消');
- }
- }
- })
- }
- this.isAuthUpdate = res.data.data
- })
- },
- // 验证人象
- verifyFace(data){
- let that = this;
- uni.showLoading({
- title: '人脸识别中'
- })
- if(this.requestStatus){
- return;
- }
- this.requestStatus=true
- this.$api.verifyFace({
- auth: true,
- facePath: data.ossId,
- businessId: ''
- }).then((res)=>{
- this.requestStatus=false
- uni.hideLoading();
- this.userInfo.facePhoto= data.ossId
- this.userInfo.facePhotoUrl=data.url
- }).catch((err) =>{
- this.requestStatus=false
- uni.$u.toast(err.data.msg||'识别失败,请重新上传照片')
- });
- },
- //修改数组属性名
- changeKey(arr, newName, oldName) {
- arr.forEach(item => {
- item[newName] = item[oldName]
- delete item[oldName]
- })
- return arr
- },
- getServiceObjectList() {
- this.$api.serviceProjectList().then(res => {
- this.serviceProjectList = res.data.data
- console.log()
- this.changeKey(this.serviceProjectList, 'value', 'id')
- this.changeKey(this.serviceProjectList, 'text', 'serviceName')
- })
- },
- increment() {
- this.userInfo.ranks++;
- },
- decrement() {
- if (this.userInfo.ranks > 1) {
- this.userInfo.ranks--;
- }
- },
- handleRankChange(value) {
- console.log('Rank changed:', value);
- this.userInfo.ranks = value;
- // 在这里处理值改变事件的逻辑
- },
- // 选择性别
- chooseGender() {
- this.genderShow = true;
- },
- // 选择值
- sureChooseGender(e) {
- this.genderShow = false;
- this.userInfo.sex = e.value[0].id;
- },
- // 确定选择的服务日期
- bindDateChange(e) {
- console.log(e)
- this.userInfo.birthday = e.detail.value
- },
- // 保存用户信息
- saveUserInfo() {
- if (!this.userInfo.nickName) {
- uni.showToast({
- title: "请认真填写宝贝昵称"
- })
- return;
- }
- if (!this.userInfo.blood) {
- uni.showToast({
- title: "请认真填写关系"
- })
- return;
- }
- if (!this.userInfo.birthday) {
- uni.showToast({
- title: "请认真填写宝贝生日"
- })
- return;
- }
- if (this.requestStatus) {
- return;
- }
- this.requestStatus = true
- this.userInfo.auth = true;
- this.userInfo.authServiceIds = this.userInfo.serviceProjectId.join()
- if (this.userInfo.id) {
- // 修改数据
- this.$api.updateServiceObject(this.userInfo).then((res) => {
- console.log(res)
- uni.showToast({
- title: "修改成功"
- })
- setTimeout(() => {
- this.requestStatus = false
- // uni.reLaunch({
- // url: '/myPages/ServiceObjectManagement/index'
- // });
- uni.navigateBack({
- delta: 1
- });
- }, 2000)
- }).catch(() => {
- this.requestStatus = false
- })
- } else {
- // 保存数据
- this.$api.saveServiceObject(this.userInfo).then((res) => {
- console.log(res)
- uni.showToast({
- title: "保存成功"
- })
- setTimeout(() => {
- this.requestStatus = false
- // uni.reLaunch({
- // url: '/myPages/ServiceObjectManagement/index'
- // });
- uni.navigateBack({
- delta: 1
- });
- }, 2000)
- }).catch(() => {
- this.requestStatus = false
- })
- }
- },
- //头像上传
- uploadImg1(imgIndex) {
- console.log(this.isAuthUpdate)
- if (!this.isAuthUpdate){
- return //关闭头像上传
- }
- this.$refs.cropper.fSelect();
- // let that = this;
- // uni.chooseImage({
- // count: 1,
- // success: (chooseImageRes) => {
- // const tempFilePaths = chooseImageRes.tempFilePaths;
- // console.log(tempFilePaths)
- // uni.uploadFile({
- // url: that.$baseUrl + '/resource/oss/upload',
- // filePath: tempFilePaths[0],
- // name: 'file',
- //
- // header: {
- // // "Content-Type": "multipart/form-data",
- // // 'X-Access-Token': uni.getStorageSync('token'),
- // 'Authorization': 'Bearer ' + this.accessToken,
- // },
- // success: (uploadFileRes) => {
- // let res = JSON.parse(uploadFileRes.data)
- // console.log(res)
- // this.verifyFace(res.data)
- // },
- // fail: (err)=> {
- // console.log(err)
- // }
- // });
- // }
- // });
- }
- }
- };
- </script>
- <style lang="scss">
- .user-info-wrap {
- margin-left: 12px;
- margin-right: 12px;
- /* 导航菜单 */
- .nav-bar {
- background: #fff;
- border-radius: 10px;
- margin-top: 12px;
- /* 商店信息 */
- .nav-content {
- padding-right: 6px;
- padding-top: 10px;
- padding-bottom: 6px;
- .nav-info {
- display: flex;
- padding-left: 10px;
- align-items: center;
- .logo {
- width: 12%;
- text-align: center;
- image {
- width: 24px;
- height: 24px;
- }
- }
- .nav-desc {
- width: 46%;
- display: flex;
- line-height: 30px;
- font-family: PingFangSC-Regular, PingFang SC;
- font-weight: 400;
- align-items: center;
- .custom-input {
- font-size: 12px;
- }
- .nav-name {
- width: 60%;
- font-size: 14px;
- color: #333333;
- line-height: 22px;
- }
- .change-store {
- text-align: right;
- width: 40%;
- font-size: 12px;
- color: #333333;
- line-height: 22px;
- }
- }
- .arrow-right {
- width: 64%;
- /*text-align: right;*/
- margin: 0 auto;
- padding-top: 3px;
- display: flex;
- justify-content: flex-end;
- align-items: center;
- image {
- width: 18px;
- height: 18px;
- }
- .custom-input {
- font-size: 12px;
- width: 200rpx;
- /*border: 1px solid red;*/
- }
- .head-img {
- width: 50px;
- height: 50px;
- border-radius: 25px;
- text-align: center;
- padding-right: 20px;
- image {
- width: 50px;
- height: 50px;
- border-radius: 25px;
- }
- }
- .change-store {
- font-size: 14px;
- color: #999;
- line-height: 22px;
- }
- }
- }
- }
- }
- .sure-btn {
- margin-top: 20px;
- width: 100%;
- .btn {
- text-align: center;
- height: 42px;
- background: #FFE05C;
- border-radius: 27px;
- color: #333333;
- line-height: 42px;
- margin-top: 12px;
- font-size: 14px;
- }
- }
- }
- .button-group {
- display: flex;
- align-items: center;
- }
- .button {
- padding: 6px 12px;
- font-size: 14px;
- background-color: #e6e6e6;
- border: none;
- border-radius: 4px;
- cursor: pointer;
- }
- .custom-input-ranks {
- width: 30px;
- font-size: 12px;
- text-align: center;
- }
- .radio-item {
- padding-right: 6px;
- }
- .picker-change-store {
- font-size: 14px;
- color: #999;
- line-height: 22px;
- display: flex;
- flex-direction: row;
- }
- </style>
|