blob: 72aa6f838308baad72b3ada9c1d482807b33a04b [file] [log] [blame]
<template>
<view class="lock">
<view class="lock-avatar">
<u-avatar src="" mode="circle" size="120"></u-avatar>
</view>
<view class="lock-con">
<mpvue-gesture-lock :containerWidth="590" :cycleRadius="50" @end="onEnd" :password="password"></mpvue-gesture-lock>
</view>
<view class="lock-text">{{text}}</view>
</view>
</template>
<script>
import mpvueGestureLock from './components/mpvueGestureLock/index.vue';
const app = getApp()
export default {
components: {
mpvueGestureLock
},
data() {
return {
password: [],
text: '请设置手势',
a: []
}
},
onLoad() {
//#ifdef MP-WEIXIN
wx.hideHomeButton();
//#endif
let pwd = wx.getStorageSync("hands")
if (pwd) {
this.password = pwd
this.text = "请确认你的手势"
}
},
methods: {
login() {
let that = this
let tel = uni.getStorageSync('phone')
let pwd = uni.getStorageSync('pwd')
// #ifdef APP-PLUS
let uuid = app.globalData.clientid ? app.globalData.clientid : ''
let platform = uni.getStorageSync('platform') ? 'App-' + uni.getStorageSync('platform') : ''
let a = atob(pwd.substr(1))
// #endif
// #ifdef MP-WEIXIN
let a = pwd.substr(1)
let uuid = ''
let platform = uni.getStorageSync('platform') ? 'Wechat-' + uni.getStorageSync('platform') : ''
// #endif
// #ifdef H5
let platform = 'H5'
let uuid = ''
let a= atob(pwd.substr(1))
// #endif
let params = {
username: tel,
password: a,
deviceid: uuid,
platform: platform
}
that.$u.post('/login',params).then(res => {
uni.setStorageSync("token", res.token)
uni.setStorageSync("uid", res.uid)
uni.setStorageSync("userid", res.userid)
uni.setStorageSync("tenantid", res.tenantid)
uni.setStorageSync("tokenexpire", res.expire)
uni.setStorageSync("tokentime", res.now)
uni.setStorageSync("signed", res.signed)
uni.setStorageSync("paypwdset", res.paypwdset)
uni.setStorageSync("name", res.name)
uni.setStorageSync("localpwd", res.localpwd)
uni.setStorageSync("phoneX", res.phone)
uni.setStorageSync("imgurl", res.imgurl)
uni.setStorageSync("idno", res.idno)
uni.setStorageSync("cardno", res.citizenCardNo)
uni.setStorageSync("bankcardno", res.bankCardNo)
uni.setStorageSync("email", res.email)
if(res.needcheck){
uni.navigateTo({
url:'/pages/sub_basic/verification?data=' + JSON.stringify(params)
})
return false
}
uni.showToast({
title: "登录成功",
icon: "none",
mask:true,
duration: 800,
complete(res) {
setTimeout(() => {
uni.switchTab({
url: "/pages/sub_tabbar/index"
})
}, 1500)
}
})
})
},
onEnd(data) {
let that = this
that.a = data
let pwd = wx.getStorageSync("hands")
if (pwd) {
if (pwd.join('') === data.join('')) {
let login = uni.getStorageSync("login")
if(login == 1){
that.text = '手势正确,即将进入首页'
uni.removeStorageSync("login")
that.login()
}else if(login ==2){
that.text = '手势正确'
uni.removeStorageSync("login")
setTimeout(() => {
uni.switchTab({
url: "/pages/sub_tabbar/index"
})
}, 1500)
}else{
that.text = '手势正确,关闭手势成功'
uni.removeStorageSync("hands")
setTimeout(() => {
uni.navigateBack({
delta:1
})
}, 1000)
}
} else {
that.text = '当前手势与原手势不一致,请确认后重新绘制'
}
} else {
if (that.password.length) {
if (that.password.length < 3) {
that.text = "所连接的圆圈数量不得少于3个"
that.password = []
} else {
if (that.password.join('') === data.join('')) {
that.text = '手势设定完成'
wx.setStorageSync("hands", that.password)
setTimeout(() => {
uni.navigateBack({
delta:1
})
}, 1000)
} else {
that.text = '两次手势设定不一致,请重新设置'
that.password = []
}
}
} else {
that.text = '请确认手势'
that.password = data
}
}
}
}
}
</script>
<style scoped lang="scss">
.lock {
width: 100vw;
height: 100vh;
background-color: #FFFFFF;
overflow: hidden;
font-family: "PingFang-SC-Medium";
&-avatar {
display: flex;
justify-content: center;
margin: 50rpx 0;
}
&-text {
display: flex;
justify-content: center;
font-size: 30rpx;
color: #666666;
margin-top: 50rpx;
}
}
</style>