From 4b80c98ef5fda8d6358778f2efe8bb35cb20ccf9 Mon Sep 17 00:00:00 2001 From: queenwuli <942534046@qq.com> Date: Fri, 15 Jan 2021 16:18:21 +0800 Subject: [PATCH] gx --- hive-app/pages/mine/myInfo.vue | 116 ++++++++++++++++++++++++++++++++++++++++++++++++++++------ 1 files changed, 104 insertions(+), 12 deletions(-) diff --git a/hive-app/pages/mine/myInfo.vue b/hive-app/pages/mine/myInfo.vue index e5af2e8..72f1ae8 100644 --- a/hive-app/pages/mine/myInfo.vue +++ b/hive-app/pages/mine/myInfo.vue @@ -1,29 +1,28 @@ <template> <!-- 我的信息 --> <view class="font-14"> - <view class="right mr-10"> - <text class="gray">NO.354</text> - </view> <view class="center"> - <image class="header-img" src="../../static/images/default-avatar.png"></image> + <image class="header-img" + :src="formData.photo?formData.photo:'../../static/images/default-avatar.png'" + @click="showUploadImage"></image> </view> <view class="mt-20 content"> <view class="input-group-row"> <text class="label">姓名<text class="require">*</text></text> - <input type="text" maxlength="20" placeholder="阿狸" placeholder-class='placeholder'/> + <input type="text" v-model="formData.name" maxlength="20" placeholder="姓名" placeholder-class='placeholder'/> </view> <view class="input-group-row"> <text class="label">英文名</text> - <input type="text" maxlength="20" placeholder="Lisa" placeholder-class='placeholder'/> + <input type="text" v-model="formData.engName" maxlength="100" placeholder="英文名" placeholder-class='placeholder'/> </view> <view class="input-group-row"> <text class="label">手机号码<text class="require">*</text></text> - <input type="text" maxlength="20" placeholder="13170303460" placeholder-class='placeholder'/> + <input type="text" v-model="formData.telphone" maxlength="20" placeholder="手机号码" placeholder-class='placeholder'/> </view> <view class="input-group-row"> <text class="label">性别<text class="require">*</text></text> <view class="right-text"> - <radio-group name="sex"> + <radio-group name="sex" @change="sexChange"> <label><radio value="男" color="#518EFF" class="radio" :checked="formData.sex==='男'"/>男</label> <label><radio value="女" color="#518EFF" class="radio" :checked="formData.sex==='女'"/>女</label> </radio-group> @@ -39,29 +38,121 @@ </view> <view class="input-group-row"> <text class="label">Eamil</text> - <input type="text" maxlength="20" placeholder="请输入Eamil" placeholder-class='placeholder'/> + <input type="text" v-model="formData.email" maxlength="20" placeholder="请输入Eamil" placeholder-class='placeholder'/> </view> <view class="input-group-row"> <text class="label">服务签名</text> - <input type="text" maxlength="20" placeholder="请输入服务签名" placeholder-class='placeholder'/> + <input type="text" v-model="formData.serviceSign" maxlength="100" placeholder="请输入服务签名" placeholder-class='placeholder'/> </view> <view class="input-group-row"> <text class="label">住址</text> - <input type="text" maxlength="20" placeholder="请输入住址" placeholder-class='placeholder'/> + <input type="text" v-model="formData.address" maxlength="100" placeholder="请输入住址" placeholder-class='placeholder'/> </view> </view> - <button class="blue-btn sticky-footer">保存</button> + <button class="blue-btn sticky-footer" :disabled="isDisabled" @click="submit">保存</button> </view> </template> <script> + import imageUploadUtils from '../../common/jssdk/uploadImg.js' export default{ data(){ return{ + isDisabled: false, formData: { sex: '女', + photo: '' } } + }, + onLoad() { + this.loadUserInfo() + }, + computed: { + endDate() { + return this.getDate('end'); + } + }, + methods:{ + loadUserInfo(){ + this.$httpUtils.request('/api/user/findUserInfo').then((res) => { + if(res.status == 200){ + this.formData = res.mapInfo.detail + } + }) + }, + valid(){ + const {name, telphone, sex} = this.formData; + if(!name){ + this.$toast.info('请输入姓名'); + return false; + } + if(!this.$utils.checkPhone(telphone)){ + this.$toast.info('请填写正确的手机号码'); + return false; + } + if(!sex){ + this.$toast.info('请选择性别'); + return false; + } + }, + submit(){ + if(this.valid() === false){ + return; + } + let roleInfo = this.$httpUtils.getRoleInfo(); + let token = this.$httpUtils.getToken(); + let userFunction = this.$httpUtils.getUserFunction(); + this.isDisabled = true; + this.$httpUtils.request('/api/user/modifyUserInfo', this.formData, 'POST').then((res) => { + if(res.status == 200){ + if(roleInfo){ + roleInfo.name = this.formData.name; + roleInfo.photo = this.formData.photo; + uni.setStorage({ + key: 'userInfo', + data: JSON.stringify({ + token: token, + roleInfo: roleInfo, + userFunction: userFunction + }), + success: () => { + uni.navigateBack() + } + }); + } + + } + this.isDisabled = false; + this.$toast.info(res.info) + }).catch((err) => { + this.isDisabled = false; + }) + }, + sexChange(e){ + this.formData.sex = e.detail.value; + }, + dateChange(e){ + this.formData.birthday = e.detail.value; + }, + showUploadImage(){ + imageUploadUtils.show((res) => { + this.formData.photo = res; + }) + }, + getDate(type) { + const date = new Date(); + let year = date.getFullYear(); + let month = date.getMonth() + 1; + let day = date.getDate(); + + if (type === 'start') { + year = year - 70; + } + month = month > 9 ? month : '0' + month;; + day = day > 9 ? day : '0' + day; + return `${year}-${month}-${day}`; + }, } } </script> @@ -70,6 +161,7 @@ .header-img{ width: 60px; height: 60px; + padding-top: 10px; border-radius: 50%; } .content{ -- Gitblit v1.9.1