story#7189,认证页radio回显处理

This commit is contained in:
2025-09-10 09:20:41 +08:00
parent 8f066a7bbf
commit 1a15772f08
2 changed files with 29 additions and 91 deletions

View File

@ -4,12 +4,12 @@
<div class="photo_title custom-title">
<span><span class="star">*</span>{{title}}</span>
<van-radio-group @change="radioChange" v-model="form.isInsure" class="flexWrap">
<van-radio name="0"></van-radio>
<van-radio name="1"></van-radio>
<van-radio :name="0"></van-radio>
<van-radio :name="1"></van-radio>
</van-radio-group>
</div>
<div class="photoWrap" v-if="form.isInsure == 1">
<van-uploader :after-read="(file) => afterRead(file,'urlList')" class="customUploadMul" max-count="3" :disabled="!showFun()">
<div class="photoWrap" v-if="inSure == 1">
<van-uploader :after-read="(file) => afterRead(file,'urlList')" class="customUploadMul" :max-count="3" :disabled="!showFun()">
<template v-if="urlList.length > 0">
<div v-for="(item, index) in urlList" :key="'uploaded-' + index" class="uploaded-item">
<img class="photo_item" mode="widthFix" :src="item.replace(/http:\/\//g, 'https://')" />
@ -56,13 +56,12 @@
<script>
import {uploadImage} from "@/api/mine";
let baseUrl=''
/*let baseUrl=''
if (window.location.href.includes('www.sinoassist.com')) {
baseUrl = 'https://www.sinoassist.com'
} else {
baseUrl = 'https://crm1.sino-assist.com'
}
}*/
export default {
name: "photoItem",
props: {
@ -81,9 +80,10 @@ export default {
},
urlList: {
type: Array,
default: ()=>[]
},
inSure:{
type:String || Number,
type:Number,
}
},
data() {
@ -92,26 +92,36 @@ export default {
leftImg: '',
rightImg: '',
urlList:[],
isInsure:1,
isInsure:'',
},
options:[{value:0,name:'否'},{value:1,name:'是'}],
localUrlList: [...this.urlList] // 使用本地副本操作
}
},
activated() {
console.log("inSure",this.inSure)
watch:{
// 监听父组件传入的urlList变化
urlList(newVal) {
this.localUrlList = [...newVal];
},
mounted() {
// 监听inSure变化
inSure(newVal) {
this.form.isInsure = newVal;
}
},
mounted() {
setTimeout(()=>{
this.form.isInsure=this.inSure
},1500)
},
methods: {
async afterRead(file,type,index){
async afterRead(file,type,index){ // 支持多文件上传
const formData = new FormData();
formData.append("file" , file.file);
let res = await uploadImage(formData)
if (type=='urlList' && (index==0 || index)){
this.$set( this.form.urlList,index,res.data)
}else if(type=='urlList'){
this.form[type].push(res.data)
this.form[type].push(...this.urlList,res.data)
}else{
this.form[type] = res.data
}
@ -130,79 +140,6 @@ export default {
}
return true
},
async chooseHandler(type,i) {
console.log("type,i",type,i,baseUrl)
return
// #ifdef MP-WEIXIN
// await this.weChatImage(type,i)
// #endif
// #ifndef MP-WEIXIN
// await this.commonImage(type,i)
// #endif
},
/* commonImage(type,index) {
uni.chooseImage({
success: (chooseImageRes) => {
const tempFilePaths = chooseImageRes.tempFilePaths;
uni.uploadFile({
url: baseUrl + '/order/uploadImage', //仅为示例,非真实的接口地址
filePath: tempFilePaths[0],
name: 'file',
success: async (uploadFileRes) => {
if (type=='urlList' && (index==0 || index)){
this.$set( this.form.urlList,index,JSON.parse(uploadFileRes.data).data)
} else if(type=='urlList'){
this.form[type].push(JSON.parse(uploadFileRes.data).data)
}else {
this.form[type] = JSON.parse(uploadFileRes.data).data
}
this.$emit(type, this.form[type])
},
fail: () => {
this.$toast('上传失败')
}
});
},
fail: (res) => {
console.log('选择照片出错', res)
// this.$toast('选择照片出错,请重试')
}
})
},
weChatImage(type,index) {
uni.chooseMedia({
sourceType: ['album', 'camera'],
mediaType: ['image'],
count: 1,
success: (chooseImageRes) => {
const tempFilePaths = chooseImageRes.tempFiles[0].tempFilePath;
uni.uploadFile({
url: baseUrl + '/order/uploadImage', //仅为示例,非真实的接口地址
filePath: tempFilePaths,
name: 'file',
success: async (uploadFileRes) => {
if (type=='urlList' && (index==0 || index)){
this.$set( this.form.urlList,index,JSON.parse(uploadFileRes.data).data)
}else if(type=='urlList'){
this.form[type].push(JSON.parse(uploadFileRes.data).data)
}else{
this.form[type] = JSON.parse(uploadFileRes.data).data
}
this.$emit(type, this.form[type])
},
fail: () => {
this.$toast('上传失败')
}
});
},
fail: (res) => {
console.log('选择照片出错', res)
// this.$toast('选择照片出错,请重试')
}
})
}
*/
}
}
</script>