171 lines
4.4 KiB
Plaintext
171 lines
4.4 KiB
Plaintext
<template>
|
|
<view style=" margin: 20rpx; padding: 20rpx;">
|
|
|
|
<view @click="uploadFImg(140,140,'Avatar','headimg')" class=""
|
|
style=" display: flex; flex-direction: column; justify-content: center; align-items: center; ">
|
|
<img v-if="userInfo.headImg!=''" :src="Service.GetMateUrlByImg(userInfo.headImg)"
|
|
style="width: 140rpx; height: 140rpx; border-radius: 50%; " alt="" />
|
|
<view v-else class=""
|
|
style="background-color: #EBEBEB; width: 140rpx; height: 140rpx; border-radius: 50%; display: flex; align-items: center; justify-content: center; ">
|
|
<img :src="Service.GetIconImg('/static/userFunc/photo.png')" style="width: 50rpx; height: 50rpx; "
|
|
alt="" />
|
|
</view>
|
|
<view class="" style="margin-top: 15rpx; font-size: 26rpx; color: #999999; ">
|
|
点击更换头像
|
|
</view>
|
|
</view>
|
|
|
|
|
|
<view class="" style=" margin-top: 30rpx; ">
|
|
<up-form labelWidth='90' labelPosition="left" :model="userInfo" ref="form1">
|
|
<up-form-item label="昵称" prop="userInfo.name" :borderBottom="true" ref="item1">
|
|
<up-input inputAlign='right' v-model="userInfo.nick" border="none"></up-input>
|
|
</up-form-item>
|
|
|
|
<up-form-item label="性别" prop="userInfo.sex" :borderBottom="true">
|
|
<view class="" style="position: relative; width: 100%;">
|
|
<view class="" style=" position: absolute; top: -8rpx; right: 0; ">
|
|
<up-radio-group style="width: 300rpx;" v-model="userInfo.sex" placement="row">
|
|
<up-radio v-for="(item, index) in radiolist1" activeColor='#FF6A00' :key="index"
|
|
iconPlacement="right" :label="item.name" :name="item.name">
|
|
</up-radio>
|
|
</up-radio-group>
|
|
</view>
|
|
</view>
|
|
</up-form-item>
|
|
<up-form-item label="手机号" prop="userInfo.sex" :borderBottom="true">
|
|
<up-input inputAlign='right' v-model="userInfo.phone" border="none"></up-input>
|
|
</up-form-item>
|
|
|
|
</up-form>
|
|
</view>
|
|
|
|
|
|
<view class="" style="width: 100%; height: 200rpx;">
|
|
|
|
</view>
|
|
<view class="" style=" width: 100% ; background-color: #fff; position: fixed; bottom: 15rpx; left: 0; ">
|
|
<view class="" @click="save()"
|
|
style=" margin: 0 20rpx; padding: 20rpx 0; color: #fff; display: flex; align-items: center; justify-content: center; border-radius: 10rpx; background-color: #FF6A00;">
|
|
保存信息
|
|
</view>
|
|
</view>
|
|
</view>
|
|
|
|
|
|
|
|
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import { onShow, onLoad } from "@dcloudio/uni-app";
|
|
import { Service } from '@/Service/Service';
|
|
import { ref } from "vue";
|
|
import { vpUserService } from '@/Service/vp/vpUserService';
|
|
import ImageCropperFunc from "@/components/ImageCropper";
|
|
|
|
|
|
interface userInfo {
|
|
nick : string
|
|
sex : string
|
|
phone : string
|
|
headImg : string
|
|
}
|
|
let showDate = ref(false)
|
|
const userInfo = ref<userInfo>({
|
|
nick: '',
|
|
sex: '',
|
|
phone: '',
|
|
headImg: ''
|
|
})
|
|
|
|
|
|
let nowDate = ref()
|
|
|
|
const radiolist1 = ref([
|
|
{
|
|
name: '男',
|
|
disabled: false,
|
|
},
|
|
{
|
|
name: '女',
|
|
disabled: false,
|
|
}
|
|
])
|
|
|
|
|
|
onLoad(() => {
|
|
getUserinfo()
|
|
});
|
|
|
|
onShow(() => {
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const getUserinfo = () => {
|
|
vpUserService.GetUserInfo().then(res => {
|
|
userInfo.value = res.data.userInfo
|
|
})
|
|
}
|
|
|
|
const uploadFImg = (width : any, height : any, Type : any, Name : any) => {
|
|
uni.chooseImage({
|
|
count: 1, // 最多选择3张图片
|
|
sizeType: ['original', 'compressed'], // 支持原图和压缩图
|
|
sourceType: ['album', 'camera'], // 可从相册选择或使用相机拍照
|
|
success: function (res) {
|
|
let path = res.tempFiles[0].path
|
|
let arr = path.split('.')
|
|
let name = arr[arr.length - 1]
|
|
Service.UpLoadMedia('Avatar',name,'',path).then(res=>{
|
|
userInfo.value.headImg=res.data.file
|
|
})
|
|
},
|
|
fail: function (err) {
|
|
console.error('选择失败:', err.errMsg);
|
|
}
|
|
})
|
|
}
|
|
|
|
|
|
|
|
const save=()=>{
|
|
if(!userInfo.value.headImg){
|
|
Service.Msg('请上传头像')
|
|
return
|
|
}
|
|
if(!userInfo.value.nick){
|
|
Service.Msg('请输入昵称')
|
|
return
|
|
}
|
|
if(!userInfo.value.sex){
|
|
Service.Msg('请输入性别')
|
|
return
|
|
}
|
|
if(!userInfo.value.phone){
|
|
Service.Msg('请输入电话')
|
|
return
|
|
}
|
|
vpUserService.UpdateUser(userInfo.value.headImg,userInfo.value.nick,userInfo.value.sex,userInfo.value.phone).then(res=>{
|
|
if(res.code==0){
|
|
Service.Msg('修改成功!')
|
|
setTimeout(()=>{
|
|
Service.GoPageBack()
|
|
},3000)
|
|
}else{
|
|
Service.Msg(res.msg)
|
|
}
|
|
})
|
|
}
|
|
|
|
|
|
</script>
|
|
|
|
<style lang="scss">
|
|
page {
|
|
background-color: #fff;
|
|
}
|
|
</style> |