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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
<template>
<div>
<div class="contentBox " >
<img class="logo" :src="imgUrl" alt="">
<h3>宝宝档案</h3>
<div class="inputBox">
<van-radio-group v-model="sex">
<van-radio class='boy' @click="changeActi(1)" name="1">
<span :class="{activity:activity==1}">男</span>
<img
slot="icon"
:src="activity==1 ? bbdaIcon.boy2 : bbdaIcon.boy1"
>
</van-radio>
<van-radio class="girl" @click="changeActi(2)" name="2">
<span :class="{activity:activity==2}">女</span>
<img
slot="icon"
:src="activity==2 ? bbdaIcon.girl2 : bbdaIcon.girl1"
>
</van-radio>
</van-radio-group>
</div>
<div class="inputBox">
<div class="subName">宝宝昵称</div>
<input type="text" v-model='baby_name' placeholder="请输入宝宝昵称" >
</div>
<div class="inputBox">
<div class="subName">宝宝生日</div>
<input type="text" v-if="birthday=='0000-00-00'" @click="dateShow=true" placeholder="请选择生日" >
<span class="birthday" v-if="birthday&&birthday!='0000-00-00'" @click="dateShow=true">{{birthday}}</span>
</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 {bbdaIcon} from "../../util/imgUrl";
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:{},
bbdaIcon:bbdaIcon,
activity:'1'
}
},
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.activity = this.sex
console.log(this.$route.params.index)
// this.getBannerListApi();
},
methods:{
changeActi(name){
// console.log(name)
this.activity = name
},
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));
if(this.$route.params.index==1){
this.$router.push({
name:"index"
})
}else{
this.$router.push({
name:"mine"
})
}
})
})
},
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 59*@toVw;
text-align: center;
.logo{width: 100*@toVw;}
}
.van-popup{
width: 100%;
.van-picker{width: 100%;}
}
.btn{
width: 156*@toVw;height: 50*@toVw;background:#40A9FF;color: white;line-height:47*@toVw; border-radius: 4px;border-radius:23*@toVw; margin: 97*@toVw auto 0;
}
.inputBox{text-align:left;
text-align: center;
width: 258*@toVw;
margin-top: 15*@toVw;
// line-height: 48*@toVw;
.subName{color: #666666;}
input{border: none;height: 40*@toVw;width: 258*@toVw;text-align: center;margin-top: 10*@toVw;
border-radius: 19*@toVw;
background: #F3F3F3;}
.van-radio-group{height: 40*@toVw;
display: flex;justify-content: space-between;
span{color: #999999;}
}
.van-radio{display: inline-block;
width: 100*@toVw;
height: 38*@toVw;
line-height: 38*@toVw;
border-radius: 19*@toVw;
background: #F3F3F3;
}
.girl{img{width: 29*@toVw;}}
.boy{img{width: 24*@toVw;}}
.girl .activity{color: #FBBCD8;}
.boy .activity{color: #4A90E2;}
.birthday{height: 40*@toVw;width: 258*@toVw;border-radius: 19*@toVw;background: #F3F3F3;display: block;line-height: 40*@toVw;margin-top: 10*@toVw;}
}
</style>