61 lines
1.1 KiB
JavaScript
61 lines
1.1 KiB
JavaScript
// packageE/healthy/component/healthy_sex/healthy_sex.js
|
|
Component({
|
|
/**
|
|
* 组件的属性列表
|
|
*/
|
|
properties: {
|
|
question:{
|
|
type:Object,
|
|
value:{}
|
|
},
|
|
answer:{
|
|
type:Object,
|
|
value:{}
|
|
},
|
|
site:{
|
|
type:Number,
|
|
value:0
|
|
}
|
|
},
|
|
|
|
/**
|
|
* 组件的初始数据
|
|
*/
|
|
data: {
|
|
currentSex:''
|
|
},
|
|
ready(){
|
|
|
|
let answer = this.data.answer.answer;
|
|
|
|
if(answer){
|
|
let sex = (answer == '女' ? 'girl' : 'male');
|
|
console.log("zhix",answer);
|
|
this.setData({
|
|
currentSex:sex
|
|
});
|
|
}
|
|
|
|
},
|
|
/**
|
|
* 组件的方法列表
|
|
*/
|
|
methods: {
|
|
setCurrentSex(event){
|
|
console.log(event);
|
|
let sex = event.currentTarget.dataset.sex;
|
|
console.log(sex);
|
|
if(sex == this.data.currentSex) return;
|
|
this.setData({
|
|
currentSex:sex
|
|
});
|
|
let str= (sex=='girl' ? '女' : '男');
|
|
this.triggerEvent("quesCallback",{
|
|
question:this.data.question,
|
|
site:this.data.site,
|
|
answer:str
|
|
});
|
|
}
|
|
}
|
|
});
|