blob: 72aa6f838308baad72b3ada9c1d482807b33a04b [file] [log] [blame]
guangchao.xu070005a2020-12-07 09:56:40 +08001<template>
2 <view class="lock">
3 <view class="lock-avatar">
4 <u-avatar src="" mode="circle" size="120"></u-avatar>
5 </view>
6 <view class="lock-con">
7 <mpvue-gesture-lock :containerWidth="590" :cycleRadius="50" @end="onEnd" :password="password"></mpvue-gesture-lock>
8 </view>
9 <view class="lock-text">{{text}}</view>
10 </view>
11</template>
12
13<script>
guangchao.xu6cdd45e2021-04-16 17:44:30 +080014 import mpvueGestureLock from './components/mpvueGestureLock/index.vue';
guangchao.xu070005a2020-12-07 09:56:40 +080015 const app = getApp()
16 export default {
17 components: {
18 mpvueGestureLock
19 },
20 data() {
21 return {
22 password: [],
23 text: '请设置手势',
24 a: []
25 }
26 },
27 onLoad() {
guangchao.xu6cdd45e2021-04-16 17:44:30 +080028 //#ifdef MP-WEIXIN
29 wx.hideHomeButton();
30 //#endif
guangchao.xu070005a2020-12-07 09:56:40 +080031 let pwd = wx.getStorageSync("hands")
32 if (pwd) {
33 this.password = pwd
34 this.text = "请确认你的手势"
35 }
36 },
37 methods: {
38 login() {
39 let that = this
40 let tel = uni.getStorageSync('phone')
41 let pwd = uni.getStorageSync('pwd')
42
43 // #ifdef APP-PLUS
44 let uuid = app.globalData.clientid ? app.globalData.clientid : ''
45 let platform = uni.getStorageSync('platform') ? 'App-' + uni.getStorageSync('platform') : ''
46 let a = atob(pwd.substr(1))
47 // #endif
48
49 // #ifdef MP-WEIXIN
50 let a = pwd.substr(1)
51 let uuid = ''
52 let platform = uni.getStorageSync('platform') ? 'Wechat-' + uni.getStorageSync('platform') : ''
53 // #endif
54
55 // #ifdef H5
56 let platform = 'H5'
57 let uuid = ''
58 let a= atob(pwd.substr(1))
59 // #endif
60
61 let params = {
62 username: tel,
63 password: a,
64 deviceid: uuid,
65 platform: platform
66 }
67
68 that.$u.post('/login',params).then(res => {
69 uni.setStorageSync("token", res.token)
70 uni.setStorageSync("uid", res.uid)
71 uni.setStorageSync("userid", res.userid)
72 uni.setStorageSync("tenantid", res.tenantid)
73 uni.setStorageSync("tokenexpire", res.expire)
74 uni.setStorageSync("tokentime", res.now)
75 uni.setStorageSync("signed", res.signed)
76 uni.setStorageSync("paypwdset", res.paypwdset)
77 uni.setStorageSync("name", res.name)
78 uni.setStorageSync("localpwd", res.localpwd)
79 uni.setStorageSync("phoneX", res.phone)
80 uni.setStorageSync("imgurl", res.imgurl)
81 uni.setStorageSync("idno", res.idno)
82 uni.setStorageSync("cardno", res.citizenCardNo)
83 uni.setStorageSync("bankcardno", res.bankCardNo)
guangchao.xu50e42382021-01-04 17:53:47 +080084 uni.setStorageSync("email", res.email)
guangchao.xu070005a2020-12-07 09:56:40 +080085 if(res.needcheck){
86 uni.navigateTo({
guangchao.xu6cdd45e2021-04-16 17:44:30 +080087 url:'/pages/sub_basic/verification?data=' + JSON.stringify(params)
guangchao.xu070005a2020-12-07 09:56:40 +080088 })
89 return false
90 }
91 uni.showToast({
92 title: "登录成功",
93 icon: "none",
94 mask:true,
95 duration: 800,
96 complete(res) {
97 setTimeout(() => {
98 uni.switchTab({
99 url: "/pages/sub_tabbar/index"
100 })
101 }, 1500)
102 }
103 })
104 })
105 },
106 onEnd(data) {
107 let that = this
108 that.a = data
109 let pwd = wx.getStorageSync("hands")
110 if (pwd) {
111 if (pwd.join('') === data.join('')) {
112 let login = uni.getStorageSync("login")
guangchao.xuc43cf972021-01-18 13:37:55 +0800113 if(login == 1){
guangchao.xu070005a2020-12-07 09:56:40 +0800114 that.text = '手势正确,即将进入首页'
115 uni.removeStorageSync("login")
116 that.login()
guangchao.xuc43cf972021-01-18 13:37:55 +0800117 }else if(login ==2){
118 that.text = '手势正确'
119 uni.removeStorageSync("login")
120 setTimeout(() => {
121 uni.switchTab({
122 url: "/pages/sub_tabbar/index"
123 })
124 }, 1500)
guangchao.xu070005a2020-12-07 09:56:40 +0800125 }else{
126 that.text = '手势正确,关闭手势成功'
127 uni.removeStorageSync("hands")
128 setTimeout(() => {
129 uni.navigateBack({
130 delta:1
131 })
132 }, 1000)
133 }
134
135 } else {
136 that.text = '当前手势与原手势不一致,请确认后重新绘制'
137 }
138 } else {
139 if (that.password.length) {
140 if (that.password.length < 3) {
141 that.text = "所连接的圆圈数量不得少于3个"
142 that.password = []
143 } else {
144 if (that.password.join('') === data.join('')) {
145 that.text = '手势设定完成'
146 wx.setStorageSync("hands", that.password)
147 setTimeout(() => {
148 uni.navigateBack({
149 delta:1
150 })
151 }, 1000)
152 } else {
153 that.text = '两次手势设定不一致,请重新设置'
154 that.password = []
155 }
156 }
157 } else {
158 that.text = '请确认手势'
159 that.password = data
160 }
161 }
162 }
163 }
164 }
165</script>
166
167<style scoped lang="scss">
168 .lock {
169 width: 100vw;
170 height: 100vh;
171 background-color: #FFFFFF;
172 overflow: hidden;
173 font-family: "PingFang-SC-Medium";
174
175 &-avatar {
176 display: flex;
177 justify-content: center;
178 margin: 50rpx 0;
179 }
180
181 &-text {
182 display: flex;
183 justify-content: center;
184 font-size: 30rpx;
185 color: #666666;
186 margin-top: 50rpx;
187 }
188 }
189</style>