This commit is contained in:
xyc 2025-04-25 16:21:02 +08:00
parent 8cbc068624
commit cf369722b6
2 changed files with 235 additions and 232 deletions

View File

@ -1,245 +1,248 @@
<template> <template>
<view class="my-info-box"> <view class="my-info-box">
<navigation-bar-vue title="个人信息" style="width: 100%;" background-color="#ffffff" <navigation-bar-vue title="个人信息" style="width: 100%;" background-color="#ffffff"
title-color="#000000"></navigation-bar-vue> title-color="#000000"></navigation-bar-vue>
<view class="form-data-box"> <view class="form-data-box">
<!-- 基础表单校验 --> <!-- 基础表单校验 -->
<uni-forms ref="valiForm" :rules="rules" :modelValue="valiFormData"> <uni-forms ref="valiForm" :rules="rules" :modelValue="valiFormData">
<uni-forms-item labelWidth="280rpx" label="头像" name="avatar"> <uni-forms-item labelWidth="280rpx" label="头像" name="avatar">
<uni-file-picker small="true" :value="fileList" :sizeType="sizeType" @select="afterRead" <uni-file-picker small="true" :value="fileList" :sizeType="sizeType" @select="afterRead"
@delete="deleteFile" limit="1"></uni-file-picker> @delete="deleteFile" limit="1"></uni-file-picker>
</uni-forms-item> </uni-forms-item>
<uni-forms-item labelWidth="280rpx" label="昵称" required name="nickName"> <uni-forms-item labelWidth="280rpx" label="昵称" required name="nickName">
<uni-easyinput v-model="valiFormData.nickName" placeholder="请输入" /> <uni-easyinput v-model="valiFormData.nickName" placeholder="请输入"/>
</uni-forms-item> </uni-forms-item>
<uni-forms-item labelWidth="280rpx" label="联系方式" required name="phonenumber"> <uni-forms-item labelWidth="280rpx" label="联系方式" required name="phonenumber">
<uni-easyinput v-model="valiFormData.phonenumber" placeholder="请输入" /> <uni-easyinput v-model="valiFormData.phonenumber" placeholder="请输入"/>
</uni-forms-item> </uni-forms-item>
<uni-forms-item labelWidth="280rpx" label="绑定手机号" required name="userName"> <uni-forms-item labelWidth="280rpx" label="绑定手机号" required name="userName">
<uni-easyinput disabled v-model="valiFormData.userName" /> <uni-easyinput disabled v-model="valiFormData.userName"/>
</uni-forms-item> </uni-forms-item>
<uni-forms-item labelWidth="280rpx" label="收款码" name="trecipientImage"> <uni-forms-item labelWidth="280rpx" label="收款码" name="trecipientImage">
<uni-file-picker small="true" :value="recipientImageList" :sizeType="sizeType" <uni-file-picker small="true" :value="recipientImageList" :sizeType="sizeType"
@select="afterReadRecipient" @delete="deleteFileRecipient" limit="1"></uni-file-picker> @select="afterReadRecipient" @delete="deleteFileRecipient" limit="1"></uni-file-picker>
</uni-forms-item> </uni-forms-item>
<uni-forms-item labelWidth="280rpx" label="收款码真实姓名" name="trecipientName"> <uni-forms-item labelWidth="280rpx" label="收款码真实姓名" name="trecipientName">
<uni-easyinput v-model="valiFormData.trecipientName" placeholder="请输入" /> <uni-easyinput v-model="valiFormData.trecipientName" placeholder="请输入"/>
</uni-forms-item> </uni-forms-item>
<uni-forms-item labelWidth="280rpx" label="通告报名免打扰" name="topenDisturb"> <uni-forms-item labelWidth="280rpx" label="通告报名免打扰" name="topenDisturb">
<uni-data-checkbox v-model="valiFormData.topenDisturb" :localdata="ranges" /> <uni-data-checkbox v-model="valiFormData.topenDisturb" :localdata="ranges"/>
</uni-forms-item> </uni-forms-item>
</uni-forms> </uni-forms>
<button type="primary" style="background-color: #FC2B49;" @click="submit('valiForm')">提交</button> <button type="primary" style="background-color: #FC2B49;" @click="submit('valiForm')">提交</button>
<view class="my-black-list" @click="goMyBlackList()">我的黑名单<uni-icons type="right" color="#623109" <view class="my-black-list" @click="goMyBlackList()">我的黑名单
size="12"></uni-icons></view> <uni-icons type="right" color="#623109"
</view> size="12"></uni-icons>
</view> </view>
</view>
</view>
</template> </template>
<script> <script>
import navigationBarVue from '@/components/navigation/navigationBar.vue'; import navigationBarVue from '@/components/navigation/navigationBar.vue';
import config from '@/config' import config from '@/config'
import { import {
queryDetail,uniSaveMember queryDetail, uniSaveMember
} from '@/api/business/member.js' } from '@/api/business/member.js'
import upload from '@/utils/upload' import upload from '@/utils/upload'
export default {
components: {
navigationBarVue
},
data() {
return {
userType:'',
sizeType: ['compressed'],
//
fileList: [],
fileImageUrl:[],
//
recipientImageList: [],
recipientImageUrl: [],
ranges: [{
text: '开启',
value: "1"
}, {
text: '关闭',
value: "0"
}],
//
valiFormData: {
avatar: "",
nickName: "",
phonenumber: "",
userName: "",
trecipientImage: "",
trecipientName: "",
topenDisturb: "0"
},
//
rules: {
// avatar: {
// rules: [{
// required: true,
// errorMessage: ''
// }]
// },
nickName: {
rules: [{
required: true,
errorMessage: '昵称不能为空'
}]
},
phonenumber: {
rules: [{
required: true,
errorMessage: '联系方式不能为空'
}]
},
// trecipientImage: {
// rules: [{
// required: true,
// errorMessage: ''
// }]
// },
// trecipientName: {
// rules: [{
// required: true,
// errorMessage: ''
// }]
// },
},
}
},
onLoad(options){
this.userType = options.userType
this.userId = options.userId
this.initData(options.userType,options.userId)
},
methods: {
goMyBlackList() {
this.$tab.navigateTo('/pages/mine/set/black-list?userId='+this.userId)
},
submit(ref) {
this.valiFormData.avatar = this.fileImageUrl.join(',');
this.valiFormData.trecipientImage = this.recipientImageUrl.join(',');
let that = this
this.$refs[ref].validate().then(res => {
uniSaveMember(that.valiFormData).then(res => {
uni.showToast({
icon: 'success',
duration: 2000,
title: '保存成功'
});
uni.navigateBack()
})
}).catch(err => {
console.log('err', err);
})
},
/**初始化数据*/ export default {
initData(userType,userId){ components: {
this.fileList = [] navigationBarVue
this.fileImageUrl = [] },
this.recipientImageList = [] data() {
this.recipientImageUrl = [] return {
queryDetail({userType:userType,userId:userId}).then(res=>{ userType: '',
console.log(res,131) sizeType: ['compressed'],
this.valiFormData = res.data //
if (this.valiFormData.avatar != null && this.valiFormData.avatar != ''){ fileList: [],
this.fileImageUrl = this.valiFormData.avatar.split(',') fileImageUrl: [],
this.fileImageUrl.map((item)=>{ //
this.fileList.push({ recipientImageList: [],
url:item recipientImageUrl: [],
}) ranges: [{
}) text: '开启',
} value: "1"
if (this.valiFormData.trecipientImage != null && this.valiFormData.trecipientImage != ''){ }, {
this.recipientImageUrl = this.valiFormData.trecipientImage.split(',') text: '关闭',
this.recipientImageUrl.map((item)=>{ value: "0"
this.recipientImageList.push({ }],
url:config.baseUrl + item //
}) valiFormData: {
}) avatar: "",
} nickName: "",
}) phonenumber: "",
userName: "",
trecipientImage: "",
trecipientName: "",
topenDisturb: "0"
}, },
//
rules: {
// avatar: {
// rules: [{
// required: true,
// errorMessage: ''
// }]
// },
nickName: {
rules: [{
required: true,
errorMessage: '昵称不能为空'
}]
},
phonenumber: {
rules: [{
required: true,
errorMessage: '联系方式不能为空'
}]
},
// trecipientImage: {
// rules: [{
// required: true,
// errorMessage: ''
// }]
// },
// trecipientName: {
// rules: [{
// required: true,
// errorMessage: ''
// }]
// },
},
}
},
onLoad(options) {
this.userType = options.userType
this.userId = options.userId
this.initData(options.userType, options.userId)
},
methods: {
goMyBlackList() {
this.$tab.navigateTo('/pages/mine/set/black-list?userId=' + this.userId)
},
submit(ref) {
this.valiFormData.avatar = this.fileImageUrl.join(',');
this.valiFormData.trecipientImage = this.recipientImageUrl.join(',');
let that = this
this.$refs[ref].validate().then(res => {
uniSaveMember(that.valiFormData).then(res => {
uni.showToast({
icon: 'success',
duration: 2000,
title: '保存成功'
});
uni.navigateBack()
})
}).catch(err => {
console.log('err', err);
})
},
afterRead(file) { /**初始化数据*/
for (let i = 0; i < file.tempFilePaths.length; i++) { initData(userType, userId) {
upload({ this.fileList = []
url: '', this.fileImageUrl = []
filePath: file.tempFilePaths[i] this.recipientImageList = []
}).then((res) => { this.recipientImageUrl = []
console.log(res, '215') queryDetail({userType: userType, userId: userId}).then(res => {
this.fileList.push({ console.log(res, 131)
url: res.url this.valiFormData = res.data
}) if (this.valiFormData.avatar != null && this.valiFormData.avatar != '') {
this.fileImageUrl.push(res.fileName) this.fileImageUrl = this.valiFormData.avatar.split(',')
console.log(this.fileList, 'fileList') this.fileImageUrl.map((item) => {
}) this.fileList.push({
} url: item
}, })
deleteFile(file, index) { })
console.log('删除文件'); }
this.fileList.splice(index, 1); if (this.valiFormData.trecipientImage != null && this.valiFormData.trecipientImage != '') {
this.fileImageUrl.splice(index, 1); this.recipientImageUrl = this.valiFormData.trecipientImage.split(',')
}, this.recipientImageUrl.map((item) => {
afterReadRecipient(file) { this.recipientImageList.push({
for (let i = 0; i < file.tempFilePaths.length; i++) { url: item
upload({ })
url: '', })
filePath: file.tempFilePaths[i] }
}).then((res) => { })
console.log(res, '215') },
this.recipientImageList.push({
url: res.url afterRead(file) {
}) for (let i = 0; i < file.tempFilePaths.length; i++) {
this.recipientImageUrl.push(res.fileName) upload({
}) url: '',
} filePath: file.tempFilePaths[i]
}, }).then((res) => {
deleteFileRecipient(file, index) { console.log(res, '215')
console.log('删除文件'); this.fileList.push({
this.recipientImageList.splice(index, 1); url: res.url
this.recipientImageUrl.splice(index, 1); })
}, this.fileImageUrl.push(res.fileName)
} console.log(this.fileList, 'fileList')
} })
}
},
deleteFile(file, index) {
console.log('删除文件');
this.fileList.splice(index, 1);
this.fileImageUrl.splice(index, 1);
},
afterReadRecipient(file) {
for (let i = 0; i < file.tempFilePaths.length; i++) {
upload({
url: '',
filePath: file.tempFilePaths[i]
}).then((res) => {
console.log(res, '215')
this.recipientImageList.push({
url: res.url
})
this.recipientImageUrl.push(res.fileName)
})
}
},
deleteFileRecipient(file, index) {
console.log('删除文件');
this.recipientImageList.splice(index, 1);
this.recipientImageUrl.splice(index, 1);
},
}
}
</script> </script>
<style lang="scss"> <style lang="scss">
.my-info-box { .my-info-box {
padding-top: calc(90rpx + var(--status-bar-height)); padding-top: calc(90rpx + var(--status-bar-height));
border-top: 1rpx solid #F4F4F4; border-top: 1rpx solid #F4F4F4;
background-color: white; background-color: white;
width: 100%; width: 100%;
color: #363636; color: #363636;
font-size: 30rpx; font-size: 30rpx;
height: 100%; height: 100%;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
align-items: self-start; align-items: self-start;
justify-content: center; justify-content: center;
position: relative; position: relative;
.form-data-box { .form-data-box {
border-top: 1rpx solid #F4F4F4; border-top: 1rpx solid #F4F4F4;
height: calc(100vh - var(--status-bar-height) - var(--window-bottom) - 95rpx); height: calc(100vh - var(--status-bar-height) - var(--window-bottom) - 95rpx);
overflow-y: scroll; overflow-y: scroll;
width: 100%; width: 100%;
padding: 20rpx 30rpx; padding: 20rpx 30rpx;
background-color: white; background-color: white;
.my-black-list { .my-black-list {
width: 100%; width: 100%;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
font-size: 26rpx; font-size: 26rpx;
margin-top: 20rpx; margin-top: 20rpx;
} }
} }
} }
</style> </style>

View File

@ -379,14 +379,14 @@
if (this.dataObj.images) { if (this.dataObj.images) {
this.dataObj.images.split(',').forEach(it => { this.dataObj.images.split(',').forEach(it => {
this.fileList.push({ this.fileList.push({
url: config.baseUrl + it url: it
}) })
}) })
} }
if (this.dataObj.groupImage) { if (this.dataObj.groupImage) {
this.dataObj.groupImage.split(',').forEach(it => { this.dataObj.groupImage.split(',').forEach(it => {
this.groupImageList.push({ this.groupImageList.push({
url: config.baseUrl + it url: it
}) })
}) })
} }