saoCode.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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,
  13. chemicalAioVerifyAppletLogin
  14. } from '@/pages/api/index.js'
  15. export default {
  16. name: "saoCode",
  17. data() {
  18. return {
  19. webViewType: false,
  20. baseUrl: config.base_url,
  21. code: "",
  22. type: "",
  23. }
  24. },
  25. onLoad(option) {
  26. let self = this;
  27. if (option.q) {
  28. let text = decodeURIComponent(option.q)
  29. let list = text.split("?")[1].split("&");
  30. let codeData = {};
  31. list.forEach((item) => {
  32. codeData[item.split("=")[0]] = item.split("=")[1];
  33. })
  34. if (!uni.getStorageSync('token')) {
  35. uni.setStorageSync('codeData', codeData);
  36. uni.redirectTo({
  37. url: '/pages/login/login',
  38. });
  39. } else {
  40. if (codeData.type == 11) {
  41. //化学品终端-扫码登录
  42. this.chemicalAioVerifyScanLogin(codeData.code, codeData.subId, codeData.macId);
  43. } else if (codeData.type == 12) {
  44. //化学品终端-双人认证
  45. this.chemicalAioVerifyAppletLogin(codeData.doorId, codeData.subId, codeData.macId, codeData.code);
  46. } else if (codeData.type == 7) {
  47. //培训课程
  48. uni.redirectTo({
  49. url: '/pages/pages_patrolInspector/courseQRcode?code=' + codeData.code,
  50. });
  51. } else if (codeData.type == 8) {
  52. //化学品柜
  53. uni.redirectTo({
  54. url: '/pages/pages_patrolInspector/chemicalCabinetQRcode?code=' + codeData.code,
  55. });
  56. } else if (codeData.type == 9) {
  57. //化学品
  58. uni.redirectTo({
  59. url: '/pages/pages_patrolInspector/chemicalDetail?code=' + codeData.code,
  60. });
  61. } else if(codeData.type == 1 || codeData.type == 2 || codeData.type == 3){
  62. //type == 1 / 2 / 3 / 4 / 5 / 6
  63. this.$set(this, 'code', codeData.code);
  64. this.$set(this, 'type', codeData.type);
  65. this.$set(this, 'webViewType', true);
  66. }
  67. }
  68. } else {
  69. let codeData = uni.getStorageSync('codeData');
  70. uni.removeStorageSync('codeData');
  71. if (codeData.type == 11) {
  72. //化学品终端-扫码登录
  73. this.chemicalAioVerifyScanLogin(codeData.code, codeData.subId, codeData.macId);
  74. } else if (codeData.type == 12) {
  75. //化学品终端-双人认证
  76. this.chemicalAioVerifyAppletLogin(codeData.doorId, codeData.subId, codeData.macId, codeData.code);
  77. } else if (codeData.type == 7) {
  78. //培训课程
  79. uni.redirectTo({
  80. url: '/pages/views/pages_patrolInspector/courseQRcode?code=' + codeData.code,
  81. });
  82. } else if (codeData.type == 8) {
  83. //化学品柜
  84. uni.redirectTo({
  85. url: '/pages/views/pages_patrolInspector/chemicalCabinetQRcode?code=' + codeData.code,
  86. });
  87. } else if (codeData.type == 9) {
  88. //化学品
  89. uni.redirectTo({
  90. url: '/pages/views/pages_patrolInspector/chemicalDetail?code=' + codeData.code,
  91. });
  92. } else if(codeData.type == 1 || codeData.type == 2 || codeData.type == 3){
  93. //type == 1 / 2 / 3 / 4 / 5 / 6
  94. this.$set(this, 'code', codeData.code);
  95. this.$set(this, 'type', codeData.type);
  96. this.$set(this, 'webViewType', true);
  97. }
  98. }
  99. },
  100. mounted() {
  101. },
  102. methods: {
  103. //化学品终端-扫码登录
  104. async chemicalAioVerifyScanLogin(code, subId, macId) {
  105. const {
  106. data
  107. } = await chemicalAioVerifyScanLogin({
  108. code: code,
  109. subId: subId,
  110. userId: uni.getStorageSync('userId'),
  111. macId: macId
  112. });
  113. uni.showToast({
  114. mask: true,
  115. icon: "none",
  116. position: "center",
  117. title: data.message,
  118. duration: 2000
  119. });
  120. setTimeout(function() {
  121. uni.redirectTo({
  122. url: '/pages/mine/mine',
  123. });
  124. }, 2000);
  125. },
  126. //化学品终端-双人认证
  127. async chemicalAioVerifyAppletLogin(doorId, subId, macId, code) {
  128. const {
  129. data
  130. } = await chemicalAioVerifyAppletLogin({
  131. doorId: doorId,
  132. subId: subId,
  133. macId: macId,
  134. code: code,
  135. userId: uni.getStorageSync('userId'),
  136. });
  137. uni.showToast({
  138. mask: true,
  139. icon: "none",
  140. position: "center",
  141. title: data.message,
  142. duration: 2000
  143. });
  144. setTimeout(function() {
  145. uni.redirectTo({
  146. url: '/pages/mine/mine',
  147. });
  148. }, 2000);
  149. },
  150. },
  151. }
  152. </script>
  153. <style lang="stylus" scoped>
  154. #saoCode {
  155. overflow scroll
  156. }
  157. </style>