saoCode.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <!--扫描二维码页面-->
  2. <template>
  3. <view id="saoCode">
  4. <web-view v-if="webViewType" :src="baseUrl+'admin/#/codeHtml?code='+code+'&type='+type"></web-view>
  5. </view>
  6. </template>
  7. <script>
  8. import {
  9. config
  10. } from '@/api/request/config.js'
  11. import {
  12. chemicalAioVerifyScanLogin,chemicalAioVerifyAppletLogin
  13. } from '@/api/basicsModules/index.js'
  14. export default {
  15. name: "saoCode",
  16. data() {
  17. return {
  18. webViewType:false,
  19. baseUrl: config.base_url,
  20. code: "",
  21. type: "",
  22. }
  23. },
  24. onLoad(option) {
  25. let self = this;
  26. if (option.q) {
  27. let text = decodeURIComponent(option.q)
  28. console.log('text',text)
  29. let list = text.split("?")[1].split("&");
  30. let codeData = {};
  31. console.log('codeData',codeData)
  32. list.forEach((item) => {
  33. codeData[item.split("=")[0]] = item.split("=")[1];
  34. })
  35. if (!uni.getStorageSync('token')) {
  36. uni.setStorageSync('codeData', codeData);
  37. uni.redirectTo({
  38. url: '/pages/login/login',
  39. });
  40. } else {
  41. if (codeData.type == 11) {
  42. //化学品终端-扫码登录
  43. this.chemicalAioVerifyScanLogin(codeData.code, codeData.subId, codeData.macId);
  44. }else if (codeData.type == 12) {
  45. //化学品终端-双人认证
  46. this.chemicalAioVerifyAppletLogin(codeData.doorId, codeData.subId, codeData.macId, codeData.code);
  47. }
  48. }
  49. } else {
  50. let codeData = uni.getStorageSync('codeData');
  51. uni.removeStorageSync('codeData');
  52. if (codeData.type == 11) {
  53. //化学品终端-扫码登录
  54. this.chemicalAioVerifyScanLogin(codeData.code, codeData.subId, codeData.macId);
  55. }else if (codeData.type == 12) {
  56. //化学品终端-双人认证
  57. this.chemicalAioVerifyAppletLogin(codeData.doorId, codeData.subId, codeData.macId, codeData.code);
  58. }
  59. }
  60. },
  61. mounted() {
  62. },
  63. methods: {
  64. //化学品终端-扫码登录
  65. async chemicalAioVerifyScanLogin(code, subId, macId) {
  66. const {
  67. data
  68. } = await chemicalAioVerifyScanLogin({
  69. code: code,
  70. subId: subId,
  71. userId: uni.getStorageSync('userId'),
  72. macId: macId
  73. });
  74. uni.showToast({
  75. mask: true,
  76. icon: "none",
  77. position: "center",
  78. title: data.message,
  79. duration: 2000
  80. });
  81. setTimeout(function() {
  82. uni.redirectTo({
  83. url: '/pages/mine/mine',
  84. });
  85. }, 2000);
  86. },
  87. //化学品终端-双人认证
  88. async chemicalAioVerifyAppletLogin(doorId, subId, macId, code) {
  89. const {
  90. data
  91. } = await chemicalAioVerifyAppletLogin({
  92. doorId: doorId,
  93. subId: subId,
  94. macId: macId,
  95. code: code,
  96. userId: uni.getStorageSync('userId'),
  97. });
  98. uni.showToast({
  99. mask: true,
  100. icon: "none",
  101. position: "center",
  102. title: data.message,
  103. duration: 2000
  104. });
  105. setTimeout(function() {
  106. uni.redirectTo({
  107. url: '/pages/mine/mine',
  108. });
  109. }, 2000);
  110. },
  111. },
  112. }
  113. </script>
  114. <style lang="stylus" scoped>
  115. #saoCode {
  116. overflow scroll
  117. }
  118. </style>