两种方法
一 不懂得找我下哈
<!-- 遍历数组 -->
<view class="itemList">
<view class="item acea-row row-between-wrapper" v-for="(item, indexw) in hnUserlist"
:key="indexw">
<view class="namele">{{ item.allname }}</view>
<view class="listn acea-row row-middle">
<view class="itemn" :class=" item.indexOld == indexn ?'on' : '' "
v-for="(itemn, indexn) in item.detailValue" @click="tapAttr(indexw, indexn,{[item.name]:itemn.value})" :key="indexn" >
{{ itemn.name}}
</view>
</view>
</view>
</view>
方法
hnUserlist:[
{
detailValue: [{
name: '男',
value: 0
}, {
name: '女',
value: 1
}],
indexOld: 0,
allname: "性别",
name: 'sex1'
},
{
detailValue: [{
name: '社区居民',
value: 0
}, {
name: '非社区',
value: 1
}],
indexOld: 1,
allname: "常驻类型",
name: "reside1",
}】
methods: {
bindDateChange: function(res) {
this.birthday1 = res.target.value
console.log(res.detail.value)
},
getDate(type) {
const date = new Date();
let year = date.getFullYear();
let month = date.getMonth() + 1;
let day = date.getDate();
if (type === 'start') {
year = year - 60;
} else if (type === 'end') {
year = year + 2;
}
month = month > 9 ? month : '0' + month;;
day = day > 9 ? day : '0' + day;
return `${year}-${month}-${day}`;
},
initHnUser: function(res) {
let that = this;
},
tapAttr: function(indexw, indexn,value) {
this.hnUserlist[indexw].indexOld = indexn;
if (indexw == 0) {
this.addressData.sex1 = indexn
} else if (indexw == 1) {
this.addressData.reside1 = indexn
} else if (indexw == 2) {
this.addressData.nation1 = indexn
} else if (indexw == 3) {
this.addressData.bloodYype1 = indexn
} else if (indexw == 4) {
this.addressData.standardCulture1 = indexn
} else if (indexw == 5) {
this.addressData.profession1 = indexn
} else if (indexw == 6) {
this.addressData.marriageStatus1 = indexn
} else if (indexw == 7) {
this.addressData.healthProducts1 = indexn
} else if (indexw == 8) {
this.addressData.takeExercise1 = indexn
} else if (indexw == 9) {
this.addressData.communityActivity1 = indexn
} else if (indexw == 10) {
this.addressData.healthSurvey1 = indexn
}
console.log(this.clickArr);
console.log("indexw", indexw);
console.log("indexn", indexn);
},
submit(e){
let data = this.addressData
console.log('this.addressData', this.addressData)
console.log(this.data)
postUsermessage({
sex: data.sex1,
reside: data.reside1,
realName: this.addressData.realName1,
mobile: this.addressData.mobile1,
examinationTimes: this.addressData.examinationTimes1,
subHealthRemark: this.addressData.subHealthRemark1,
xryTimes: this.addressData.xryTimes1,
xryExperience: this.addressData.xryExperience1,
xqjTimes: this.addressData.xqjTimes1,
xqjExperience: this.addressData.xqjExperience1,
fqsTimes: this.addressData.fqsTimes1,
fqsExperience: this.addressData.fqsExperience1,
birthday: this.currentDate,
nation: data.nation1,
bloodYype: data.bloodYype1,
standardCulture: data.standardCulture1,
profession: data.profession1,
marriageStatus: data.marriageStatus1,
healthProducts: data.healthProducts1,
takeExercise: data.takeExercise1,
communityActivity: data.communityActivity1,
healthSurvey: data.healthSurvey1,
})
.then((res) => {
handleOrderPayResults.call(this, res.data, "create", this.active);
})