uni-app实现手势登录及绑定微信功能

首先是前端的手势插件下载引用,可以去插件市场搜索,我用的这个
https://ext.dcloud.net.cn/plugin?id=49
下载引入就好了。

一、手势密码设定功能

<template>
	<view class="content">
		<view class="ssmm">
			<mpvue-gesture-lock :containerWidth="590" :cycleRadius="70" @end="onEnd" :password="password"></mpvue-gesture-lock>
		</view>
		<view class="uni-center">{
  {text}}</view>
	</view>
</template>

<script>
	import mpvueGestureLock from '@/components/mpvueGestureLock/indexsz.vue';
	export default {
		components: {
			mpvueGestureLock
		},
		data() {
			return {
				password: [],
				text: '请设定手势'
			}
		},
		onLoad() {//禁用页面下滑功能,不然滑动会带动页面
			document.body.addEventListener('touchmove', bodyScroll, {
			    passive: false
			});
			function bodyScroll(event) {
			    event.preventDefault();
			}
		},
		methods: {
			onEnd(data) {
				var access_token=uni.getStorageSync("access_token");
				if (this.password.length) {
					if (this.password.join('') === data.join('')) {
						this.text = '手势设定完成'
						this.password = [ ]
						uni.request({    //设置完调用接口保存手势密码
							url: getApp().globalData.baseUrl+'/admin/user/updateUserLockpwd',
						    data: { 
								userId:uni.getStorageSync("userId"),
								lockpwd:data.join('-')
							},
							method:"PUT",
						    header: {
								isToken: false,
								'TENANT-ID': getApp().globalData.tenantId,
								'Authorization':'Bearer '+access_token
						    },
						    success: (res) => {
								if(res.data.code==0){
									uni.showToast({
										title: '手势设定完成',
										icon: 'success',
										mask: true
									});
									setTimeout(function() {
										uni.reLaunch({
											url:"../fxcp/cpjg/cpjg"
										})
									},1000);
								}
						    }
						});
						
					} else {
						this.text = '两次手势设定不一致'
						this.password = []
					}
				} else {
					this.text = '请确认手势设定'
					this.password = data//data是密码数字数组
				}
			}
		}
	}
</s
  • 1
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值