login - 副本 (2).vue
4.82 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
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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
<template>
<view class="page" :style="{backgroundImage:`url(${bgImg1})`}">
<view class="logo">
<image src="" mode=""></image>
</view>
<!-- 填写区 -->
<view class="input-info">
<view class="info">
<view class="info-icon">
<image src="../../static/login3.png"></image>
</view>
<input type="tel" maxlength="11" v-model="form.phone" :placeholder="isLoginWay?'请输入账号':'请输入您的手机号'">
<view class="more"></view>
</view>
<view class="info" :style="isLoginWay?'display: none':''">
<view class="info-icon">
<image src="../../static/login4.png"></image>
</view>
<input type="tel" v-model="form.code" maxlength="6" placeholder="请输入验证码">
<view class="more">
<text class="mo" v-if="!isTrue" @click="sendCode">获取验证码</text>
<text class="mo" v-else>{{num}}秒后重试</text>
</view>
</view>
</view>
<!-- 按钮 -->
<view class="btn-info">
<view class="btn" @click="register">
<text>登录</text>
</view>
</view>
<view class="check-box" style="margin-top: 80rpx;">
<view class="check" @click="change">
<text class="iconfont icon-checked " :class="ischange?'action':''"></text>
</view>
<view style="margin-left: 10rpx;">
<text @click="change">我已阅读并同意</text><text style="color:#89ACFF;" @click="giNav(1)">《魔唇用户协议》</text>和<text
style="color:#89ACFF;" @click="giNav(2)">《魔唇隐私政策》</text>
</view>
</view>
</view>
</template>
<script>
// import bgImg1 from "../../static/loginbg.png";
// import service from '@/service/service.js'
// import md5 from '@/service/md5.js'
export default {
data() {
return {
bgImg1: bgImg1,
isLogin: false,
isLoginWay: false,
isPassword: false,
// 表单
form: {
phone: '',
code: '',
password: '',
cid: ''
},
ischange: false,
isTrue: false,
num: 60,
time: null,
// cid
push_clientid: ''
};
},
onShow() {
},
methods: {
giNav(type) {
uni.navigateTo({
url: '/pages/my/user?type=' + type
})
},
register() {
// if (!this.ischange) {
// uni.showToast({
// icon: 'none',
// title: '请确认勾选用户协议及隐私协议'
// })
// return
// }
// if (this.form.phone == '') {
// uni.showToast({
// icon: 'none',
// title: '请输入账号'
// })
// return
// }
// if (this.form.password == '') {
// uni.showToast({
// icon: 'none',
// title: '请输入密码'
// })
// return
// }
const data = {
username:'18121815598',
code:'847213'
}
this.$http.sendRequest('/business/login', 'POST', data, 2).then(res => {
if (res.data.code == '') {
uni.setStorageSync('token', res.data.data.token);
uni.setStorageSync('shopId', res.data.data.shopId);
uni.switchTab({
url: '/pages/home/home'
})
} else {
uni.showToast({
icon: 'none',
title: res.data.message
})
}
})
},
change() {
this.ischange = !this.ischange
},
/**
* 登录切换
*/
onLoginCut() {
// this.form.phone = ''
this.isLoginWay = !this.isLoginWay;
// 验证码
if (this.isLoginWay) {
this.isLogin = this.form.code && this.form.phone ? true : false;
}
// 账号密码
if (!this.isLoginWay) {
this.isLogin = this.form.password && this.form.phone ? true : false;
}
},
/**
* 获取验证码
*/
sendCode() {
// console.error(this.form)
// if (!this.form.phone) {
// uni.showToast({
// title: '请填写手机号',
// icon: 'none'
// })
// return
// }
this.$http.sendRequest('/business/verification', 'POST', {
phone: '18121815598'
}).then(res => {
console.log('获取验证码', res)
if (res.data.code == 200) {
uni.showToast({
icon: 'none',
title: '发送成功'
})
if (this.num > 0) {
this.isTrue = true
this.time = setInterval(() => {
this.num--
}, 1000)
} else {
this.isTrue = false
clearInterval(this.time)
}
} else {
uni.showToast({
icon: 'none',
title: '请稍等再试'
})
}
})
},
/**
* 登录点击
*/
onLogin() {}
},
watch: {
form: {
handler(newValue, oldValue) {
// 验证码
if (this.isLoginWay) {
this.isLogin = newValue.code && newValue.phone ? true : false;
}
// 账号密码
if (!this.isLoginWay) {
this.isLogin = newValue.password && newValue.phone ? true : false;
}
},
deep: true
},
num() {
if (this.num == 0) {
clearInterval(this.time)
this.isTrue = false
}
}
}
}
</script>
<style scoped lang="scss">
@import 'login.scss';
</style>