gesture.vue 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <template>
  2. <view>
  3. <view class="uni-page-head">
  4. <view class="uni-page-head-title">手势图案</view>
  5. </view>
  6. <view class="uni-padding-wrap uni-common-mt">
  7. <view>
  8. <mpvue-gesture-lock :containerWidth="590" :cycleRadius="70" @end="onEnd" :password="password"></mpvue-gesture-lock>
  9. </view>
  10. <view class="uni-center">{{text}}</view>
  11. </view>
  12. </view>
  13. </template>
  14. <script>
  15. import mpvueGestureLock from '@/components/mpvueGestureLock/index.vue';
  16. import {
  17. mapMutations
  18. } from "vuex"
  19. export default {
  20. components: {
  21. mpvueGestureLock
  22. },
  23. data() {
  24. return {
  25. title: "手势图案",
  26. password: [],
  27. text: '请设定手势'
  28. }
  29. },
  30. onShow() {
  31. //#ifdef H5
  32. document.title="手势图案"
  33. //#endif
  34. },
  35. methods: {
  36. ...mapMutations(["setWord"]),
  37. onEnd(data) {
  38. console.log(data, this.password)
  39. if (this.password.length) {
  40. if (this.password.join('') === data.join('')) {
  41. this.setWord(data.join(''))
  42. this.text = '手势设定完成'
  43. this.password = []
  44. this.tips()
  45. setTimeout(function() {
  46. uni.navigateBack({delta:1})
  47. }, 1500);
  48. } else {
  49. this.text = '两次手势设定不一致'
  50. this.password = []
  51. }
  52. } else {
  53. this.text = '请确认手势设定'
  54. this.password = data
  55. }
  56. },
  57. tips() {
  58. uni.showToast({
  59. title:"设定成功"
  60. })
  61. }
  62. }
  63. }
  64. </script>
  65. <style scoped>
  66. .uni-page-head{
  67. padding: 34rpx;
  68. text-align: center;
  69. }
  70. .uni-page-head-title{
  71. display: inline-block;
  72. padding: 0 40rpx;
  73. font-size: 30rpx;
  74. height: 88rpx;
  75. line-height: 88rpx;
  76. color: #BEBEBE;
  77. box-sizing: border-box;
  78. border-bottom: 1rpx solid #D8D8D8;
  79. }
  80. .uni-center{
  81. text-align: center;
  82. margin-top: 30rpx;;
  83. }
  84. </style>