1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
<template>
<div>
<div class="contentBox " >
<img class="logo" :src="imgUrl" alt="">
<div class="inputBox">
<span class="subName">宝宝昵称</span><input type="text" v-model='baby_name' placeholder="请输入宝宝昵称" >
</div>
<div class="inputBox">
<span class="subName">宝宝生日</span><span @click="dateShow=true">{{birthday}}</span>
</div>
<div class="inputBox" >
<span class="subName">宝宝性别</span>
<van-radio-group v-model="sex">
<van-radio name="1">男</van-radio>
<van-radio name="2">女</van-radio>
</van-radio-group>
</div>
<div class="btn" ref="btn" @click="putBabyInfo">保存</div>
</div>
<van-popup v-model="dateShow" position="bottom">
<van-datetime-picker
@confirm="dateConfirm"
@cancel='dateShow=false'
v-model="currentDate"
type="date"
/>
</van-popup>
</div>
</template>
<script>
import {
bannerListApi,
putBabyInfoApi,
getUserDetailApi
} from "../../service/api";
import imgUrl from "../../assets/bbda.png";
import { DatetimePicker,Popup,RadioGroup, Radio, Toast } from 'vant';
export default {
name: "bbda",
components:{
[DatetimePicker.name]:DatetimePicker,
[Popup.name]:Popup,
[RadioGroup.name]:RadioGroup,
[Radio.name]:Radio,
},
data(){
return{
medList:[],
imgUrl:imgUrl,
dateShow:false,
currentDate: new Date(),
birthday:"",
sex:'1',
baby_name:"",
userDesc:{}
}
},
created() {
this.$sa.track('ViewBabypage',{
});
this.userDesc=JSON.parse(localStorage.getItem('userDesc'))
console.log(imgUrl)
this.imgUrl = imgUrl
if(this.userDesc.birthday){
this.birthday = this.userDesc.birthday
this.currentDate = this.userDesc.birthday
}else{
this.birthday = this.currentDate.toLocaleDateString()
}
if(this.userDesc.baby_name){
this.baby_name = this.userDesc.baby_name
}
this.userDesc.sex? this.sex = this.userDesc.sex.toString():this.sex='1'
// this.getBannerListApi();
},
methods:{
putBabyInfo(){
console.log(this.birthday)
this.$sa.quick('trackHeatMap',this.$refs.btn)
if(this.baby_name==''){
Toast('昵称不能为空')
return
}
let json = {
birthday:this.birthday,
sex:this.sex,
baby_name:this.baby_name
}
putBabyInfoApi(json).then(res =>{
Toast('保存成功')
getUserDetailApi().then(res=>{
localStorage.setItem('userDesc',JSON.stringify(res));
})
})
},
goMed(index){
this.showObj.audioIndex = index;
this.showObj.show = true
},
dateConfirm(val){
this.dateShow = false
this.birthday = this.currentDate.toLocaleDateString()
}
}
}
</script>
<style scoped lang="less">
@import "../../util/public";
*{margin: 0;}
.child-view{background: white;}
.contentBox{
padding: 30*@toVw;
text-align: center;
.logo{width: 100*@toVw;}
}
.van-popup{
width: 100%;
.van-picker{width: 100%;}
}
.btn{
width: 100%;height: 47*@toVw;background:#4A90E2;color: white;line-height:47*@toVw; border-radius: 4px;border-radius:23*@toVw; margin-top: 97*@toVw;
}
.inputBox{height: 48*@toVw;border-bottom:1px solid #CCCCCC;text-align:left;display: flex;
justify-content: flex-start;
line-height: 48*@toVw;
.subName{margin-right: 68*@toVw}
input{border: none;height: 40*@toVw;width: 140*@toVw;}
.van-radio-group{height: 40*@toVw;}
.van-radio{display: inline-block;}
}
</style>