Blame view

lvdao-miniapp/pages/login/login.vue 4.07 KB
3f535f30   杨鑫   '初始'
1
  <template>
900ab311   李宇   1
2
3
4
5
  	<view class="page" :style="{backgroundImage:`url(${$imgUrl('/homePhoto.png')})`}">
  		<view style="height: 100vh;width: 100%;position: fixed;bottom: 0;left: 0;">
  			<view style="width: 45%;margin: 0 auto;margin-top: 15vh;">
  				<image src="../../static/login/logo1.png" style="width: 100%;" mode="widthFix"></image>
3f535f30   杨鑫   '初始'
6
  			</view>
900ab311   李宇   1
7
8
  			<view style="width:60%;margin: 0 auto;">
  				<image src="../../static/login/logo2.png" style="width: 100%;" mode="widthFix"></image>
3f535f30   杨鑫   '初始'
9
  			</view>
900ab311   李宇   1
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
  			<!-- 填写区 -->
  			<view class="input-info" style="margin-top: 5vh;">
  				<view class="info">
  					<view class="info-icon">
  						<image src="../../static/login/icon1.png" mode="heightFix"></image>
  					</view>
  					<input type="tel" maxlength="11" v-model="phone" placeholder="请输入您的手机号">
  					<view class="more"></view>
  				</view>
  				<view class="info">
  					<view class="info-icon">
  						<image src="../../static/login/icon2.png" mode="heightFix"></image>
  					</view>
  					<input type="tel" v-model="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>
3f535f30   杨鑫   '初始'
29
  			</view>
900ab311   李宇   1
30
31
32
33
34
  			<!-- 按钮 -->
  			<view class="btn-info">
  				<view class="btn" @click="register">
  					<text>登录</text>
  				</view>
3f535f30   杨鑫   '初始'
35
  			</view>
900ab311   李宇   1
36
  
3f535f30   杨鑫   '初始'
37
  		</view>
900ab311   李宇   1
38
39
40
41
42
43
  		<view
  			style="position: fixed;left: 0;bottom: 49rpx;display: flex;flex-direction: row;justify-content: center;width: 100%;">
  			<u-checkbox-group @change="checkboxGroupChange" shape="circle" :label-disabled="true">
  				<u-checkbox active-color="#3f9b6a" v-model="checked" name="tongyi">我已阅读并同意<span style="color:#3f9b6a;"
  						@click="goyinsi">《隐私政策》</span></u-checkbox>
  			</u-checkbox-group>
3f535f30   杨鑫   '初始'
44
45
  		</view>
  	</view>
3f535f30   杨鑫   '初始'
46
47
48
49
50
51
  </template>
  
  <script>
  	export default {
  		data() {
  			return {
900ab311   李宇   1
52
53
54
  				checked: null,
  				phone: '',
  				code: '',
3f535f30   杨鑫   '初始'
55
56
57
  				isTrue: false,
  				num: 60,
  				time: null,
900ab311   李宇   1
58
  
3f535f30   杨鑫   '初始'
59
60
  			};
  		},
900ab311   李宇   1
61
62
63
64
65
66
67
68
69
70
71
72
  		watch: {
  			num() {
  				if (this.num == 0) {
  					clearInterval(this.time)
  					this.time = null
  					this.isTrue = false
  					this.num = 60
  				}
  			}
  		},
  		onShow() {
  
3f535f30   杨鑫   '初始'
73
74
  		},
  		methods: {
900ab311   李宇   1
75
76
77
78
79
80
81
82
83
84
  			goyinsi() {
  				uni.navigateTo({
  					url: '/pages/privacy/privacy'
  				});
  			},
  			checkboxGroupChange(val) {
  				this.showTong = val[0]
  				console.log(this.showTong)
  			},
  			register() {
e5b57447   杨鑫   '分包问卷'
85
  				if(this.showTong == 'tongyi'){
900ab311   李宇   1
86
  							
e5b57447   杨鑫   '分包问卷'
87
88
89
90
91
  				}else{
  					uni.showToast({
  						icon: 'none',
  						title: '请阅读并同意隐私政策'
  					})
900ab311   李宇   1
92
  					return
e5b57447   杨鑫   '分包问卷'
93
  				}
900ab311   李宇   1
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
  				if (this.phone == '') {
  					uni.showToast({
  						icon: 'none',
  						title: '请输入手机号'
  					})
  					return
  				}
  				if (this.code == '') {
  					uni.showToast({
  						icon: 'none',
  						title: '请输入验证码'
  					})
  					return
  				}
  
3f535f30   杨鑫   '初始'
109
  				const data = {
900ab311   李宇   1
110
111
  					username:this.phone,
  					 code:this.code
3f535f30   杨鑫   '初始'
112
  				}
900ab311   李宇   1
113
114
  				this.$http.sendRequest('/business/login', 'POST', data, 2).then(res => {
  					if (res.data.code == '') {
3f535f30   杨鑫   '初始'
115
  						uni.setStorageSync('token', res.data.data.token);
4373acf5   wesley88   1
116
117
  						uni.setStorageSync('user', res.data.data);
  						// uni.setStorageSync('shopId', res.data.data.shopId);
3f535f30   杨鑫   '初始'
118
  						uni.switchTab({
900ab311   李宇   1
119
  							url: '/pages/home/home'
3f535f30   杨鑫   '初始'
120
  						})
900ab311   李宇   1
121
  					} else {
3f535f30   杨鑫   '初始'
122
123
124
125
126
  						uni.showToast({
  							icon: 'none',
  							title: res.data.message
  						})
  					}
900ab311   李宇   1
127
128
129
  
  
  
3f535f30   杨鑫   '初始'
130
131
  				})
  			},
900ab311   李宇   1
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
  			sendCode() {
  				if (!this.phone) {
  					uni.showToast({
  						title: '请填写手机号',
  						icon: 'none'
  					})
  					return
  				}
  				this.$http.sendRequest('/business/verification', 'POST', {
  					phone: this.phone
  				}).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: '请稍等再试'
  						})
3f535f30   杨鑫   '初始'
163
  					}
900ab311   李宇   1
164
165
166
  
  				})
  
3f535f30   杨鑫   '初始'
167
  			},
3f535f30   杨鑫   '初始'
168
  		}
3f535f30   杨鑫   '初始'
169
170
171
172
173
  	}
  </script>
  
  <style scoped lang="scss">
  	@import 'login.scss';
900ab311   李宇   1
174
  </style>