keepPhone.html
6.2 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
<meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
<title></title>
<script src="../../assets/js/fontsize.js"></script>
<link rel="stylesheet" href="../../assets/css/api.css"/>
<link rel="stylesheet" href="../../assets/css/login_index.css">
<link rel="stylesheet" href="../../assets/icon/iconfont.css">
<style>
.agree_box {
margin-top: 0.5rem;
}
</style>
</head>
<body>
<div id="app">
<form action="">
<div class="login_input"><input type="number" placeholder="请输入手机号" maxlength="11" v-model="phone"></div>
<div class="login_input"><input type="number" placeholder="请输入验证码" v-model="code">
<span v-if="show" @click="getCode" class="count">获取验证码</span>
<span v-else class="count">{{count}}S后可重发</span>
</div>
<div class="login_btn" @click="login">绑定</div>
<div class="no_reg">首次第三方登陆需要绑定手机号</div>
<div class="agree_box">
<span :class="['iconfont',isAgree?'icon-yigouxuan':'icon-weigouxuan']"
@click="isAgree=!isAgree"></span>
<span>我同意</span>
<span class="agreement" @click="agree_content">《慈界医养用户服务协议》</span>
</div>
</form>
</div>
</body>
</html>
<script type="text/javascript" src="../../assets/js/api.js"></script>
<script type="text/javascript" src="../../assets/js/public.js"></script>
<script type="text/javascript" src="../../assets/js/fastclick.js"></script>
<script>
new FastClick(document.body);
</script>
<script type="text/javascript" src="../../assets/js/vue.min.js"></script>
<script type="text/javascript" src="../../assets/js/axios.min.js"></script>
<script type="text/javascript" src="../../assets/icon/iconfont.js"></script>
<script>
var app = new Vue({
el: '#app',
data: {
show: true,
count: '',
timer: null,
isAgree: true,
phone: '',
code: '',
nickname: '',
openid: '',
avatar: ''
},
created: function () {
apiready = function () {
app.nickname = api.pageParam.nickname;
app.openid = api.pageParam.openid;
app.avatar = api.pageParam.avatar;
app.login_type = api.pageParam.login_type;
// alert(app.login_type)
}
},
methods: {
getCode: function () {
if (!mobileReg.test(app.phone)) {
toastMsg('手机号不正确')
}
else {
const TIME_COUNT = 60;
var post = {
tel: app.phone,
};
var header = {
'XX-Device-Type': getDevice()
};
getRequest('post', 'home/index/loginBySMS', post, header).then(function (res) {
if (res.data.code === 1) {
toastMsg(res.data.msg)
if (!app.timer) {
app.count = TIME_COUNT;
app.show = false;
app.timer = setInterval(function () {
if (app.count > 0 && app.count <= TIME_COUNT) {
app.count--;
} else {
app.show = true;
clearInterval(app.timer);
app.timer = null;
}
}, 1000)
}
} else {
toastMsg(res.data.msg)
}
})
}
},
login: function () {
if (app.phone == '') {
toastMsg('请输入手机号')
}
else if (app.code == '') {
toastMsg('请输入验证码')
}
else if (app.isAgree == false) {
toastMsg('请同意慈界医养用户服务协议')
}
else {
var post = {
code: app.code,
tel: app.phone,
openid: app.openid,
nickname: app.nickname,
avatar: app.avatar,
login_type: app.login_type
};
var header = {
'XX-Device-Type': getDevice()
};
// alert(JSON.stringify(post));
getRequest('POST', 'home/index/secondLogin', post, header).then(function (res) {
// alert(JSON.stringify(res.data.data))
if (res.data.code == 1) {
$api.setStorage('token', res.data.data);
api.openWin({
name: 'index_win',
url: '../common/index_win.html',
});
api.sendEvent({
name: 'index0',
extra: {
index: 0
}
});
} else {
toastMsg(res.data.msg)
}
})
}
},
agree_content: function () {
openView('agree_content', 'common/agree_content', '慈界医养用户服务协议', 'agree_content', false, {
title_name: '慈界医养用户服务协议',
id: 3
}, false)
},
}
})
</script>