skip.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. <template>
  2. <view class="skip">
  3. <view class="bg">
  4. </view>
  5. <view class="text">
  6. {{ tip }}
  7. </view>
  8. </view>
  9. </template>
  10. <script>
  11. import {
  12. mapState,
  13. mapMutations
  14. } from "vuex";
  15. import Base64 from "../../util/base64.js"
  16. import Parse from "../../util/parse.js"
  17. export default {
  18. data() {
  19. return {
  20. tip: "跳转中,请稍后..."
  21. }
  22. },
  23. computed: {
  24. // ...mapState(["appId", "stationId", "phoneNumber", "countryCode", "purePhoneNumber", "openId", "unionId",
  25. // "userInfo"
  26. // ]),
  27. },
  28. created() {
  29. uni.showLoading({
  30. title: '跳转中...',
  31. mask: true
  32. });
  33. },
  34. async onLoad(e) {
  35. console.log(e)
  36. // #ifdef MP-WEIXIN
  37. const res = decodeURIComponent(e.q)
  38. // #endif
  39. // #ifdef MP-ALIPAY
  40. const res = e.qrCode
  41. // #endif
  42. const parse = new Parse.getInstance();
  43. const info = await parse.parseCode(res).catch((e) => {
  44. uni.hideLoading()
  45. return parse.scanCode(true, {
  46. title: '( •̀ ω •́ )✧',
  47. showCancel: false,
  48. content: '亲,您扫的码不对哦~',
  49. confirmText: '重新扫码',
  50. })
  51. })
  52. this.goIndex();
  53. },
  54. methods: {
  55. ...mapMutations(["updateStationId", "updateLabelId", "updateEmployeeId"]),
  56. goIndex() {
  57. uni.hideLoading();
  58. uni.redirectTo({
  59. url: "/pages/index/index"
  60. })
  61. },
  62. goList() {
  63. uni.hideLoading();
  64. uni.redirectTo({
  65. url: "/pages/list/list"
  66. })
  67. },
  68. async parseCode(msg) {
  69. const showModalPro = await uni.showModal({
  70. title: '( •̀ ω •́ )✧',
  71. showCancel: false,
  72. content: '亲,扫码错误哦~',
  73. confirmText: '重新扫码',
  74. })
  75. const scanCodePro = await uni.scanCode({
  76. onlyFromCamera: true
  77. })
  78. // try {
  79. // const parse = new Parse.getInstance();
  80. // const info = await parse.start(res)
  81. // return Promise.resolve(info)
  82. // } catch (e) {
  83. // const showModalPro = await uni.showModal({
  84. // title: '(~ ̄▽ ̄)~',
  85. // showCancel: false,
  86. // content: '您扫的二维码错误~',
  87. // confirmText: '重新扫码',
  88. // })
  89. // const scanCodePro = await uni.scanCode({
  90. // onlyFromCamera: true
  91. // })
  92. // this.scanCode();
  93. // }
  94. },
  95. async scanCode() {
  96. const showModalPro = await uni.showModal({
  97. title: '(~ ̄▽ ̄)~',
  98. showCancel: !!this.stationId,
  99. content: msg || '此站点只能扫码进入~',
  100. cancelText: '返回',
  101. confirmText: '立刻扫码',
  102. })
  103. const parse = Parse.getInstance()
  104. if (showModalPro[1].cancel) {
  105. uni.navigateBack({
  106. delta: 1
  107. })
  108. } else if (showModalPro[1].confirm) {
  109. const parse = Parse.getInstance()
  110. return parse.scanCode().catch((err) => {
  111. return this.scanCode(err)
  112. });
  113. }
  114. }
  115. }
  116. }
  117. </script>
  118. <style lang="scss">
  119. page {
  120. .skip {
  121. position: relative;
  122. .bg {
  123. // background: url(../../static/icon/1_b01_down.2x.png) no-repeat 0px 0px;
  124. background: url(../../static/icon/goto.png) no-repeat 0px 0px;
  125. background-size: 100% 100%;
  126. width: 182rpx;
  127. height: 216rpx;
  128. position: absolute;
  129. top: 238rpx;
  130. left: 270rpx;
  131. }
  132. .text {
  133. font-size: 40rpx;
  134. width: 750rpx;
  135. text-align: center;
  136. font-weight: 550;
  137. color: #000000;
  138. line-height: 56rpx;
  139. position: absolute;
  140. top: 522rpx;
  141. }
  142. }
  143. }
  144. </style>