saoCode.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  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. //二维码功能识别
  41. this.codeRecognize(codeData);
  42. }
  43. } else {
  44. let codeData = uni.getStorageSync('codeData');
  45. uni.removeStorageSync('codeData');
  46. //二维码功能识别
  47. this.codeRecognize(codeData);
  48. }
  49. },
  50. mounted() {
  51. },
  52. methods: {
  53. //二维码功能识别
  54. codeRecognize(codeData) {
  55. if (!codeData.type) {
  56. //非功能二维码提示
  57. uni.showToast({
  58. mask: true,
  59. icon: "none",
  60. position: "center",
  61. title: '请扫描正确的小程序二维码',
  62. duration: 2000
  63. });
  64. setTimeout(function() {
  65. uni.redirectTo({
  66. url: '/pages/home/home',
  67. });
  68. }, 2000);
  69. } else {
  70. if (codeData.type == 11) {
  71. //化学品终端-扫码登录
  72. this.chemicalAioVerifyScanLogin(codeData.code, codeData.subId, codeData.macId);
  73. } else if (codeData.type == 12) {
  74. //化学品终端-双人认证
  75. this.chemicalAioVerifyAppletLogin(codeData.doorId, codeData.subId, codeData.macId, codeData.code);
  76. } else if (codeData.type == 7) {
  77. //培训课程
  78. uni.redirectTo({
  79. url: '/pages/pages_patrolInspector/courseQRcode?code=' + codeData.code,
  80. });
  81. } else if (codeData.type == 8) {
  82. //化学品柜
  83. uni.redirectTo({
  84. url: '/pages/pages_patrolInspector/chemicalCabinetQRcode?code=' + codeData.code,
  85. });
  86. } else if (codeData.type == 9) {
  87. //化学品
  88. uni.redirectTo({
  89. url: '/pages/pages_patrolInspector/chemicalDetail?code=' + codeData.code,
  90. });
  91. } else if (codeData.type == 1 || codeData.type == 2 || codeData.type == 3) {
  92. //1.MSDS说明书 2.安全制度 3.危险源详情
  93. this.$set(this, 'code', codeData.code);
  94. this.$set(this, 'type', codeData.type);
  95. this.$set(this, 'webViewType', true);
  96. } else if (codeData.type == 5) {
  97. //实验室详情
  98. } else if (codeData.type == 10) {
  99. uni.showToast({
  100. mask: true,
  101. icon: "none",
  102. position: "center",
  103. title: '专项检查功能请从安全检查进入',
  104. duration: 2000
  105. });
  106. setTimeout(function() {
  107. uni.redirectTo({
  108. url: '/pages/home/home',
  109. });
  110. }, 2000);
  111. } else {
  112. uni.showToast({
  113. mask: true,
  114. icon: "none",
  115. position: "center",
  116. title: '二维码异常,请联系管理员',
  117. duration: 2000
  118. });
  119. setTimeout(function() {
  120. uni.redirectTo({
  121. url: '/pages/home/home',
  122. });
  123. }, 2000);
  124. }
  125. }
  126. }
  127. //化学品终端-扫码登录
  128. async chemicalAioVerifyScanLogin(code, subId, macId) {
  129. const {
  130. data
  131. } = await chemicalAioVerifyScanLogin({
  132. code: code,
  133. subId: subId,
  134. userId: uni.getStorageSync('userId'),
  135. macId: macId
  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. async chemicalAioVerifyAppletLogin(doorId, subId, macId, code) {
  152. const {
  153. data
  154. } = await chemicalAioVerifyAppletLogin({
  155. doorId: doorId,
  156. subId: subId,
  157. macId: macId,
  158. code: code,
  159. userId: uni.getStorageSync('userId'),
  160. });
  161. uni.showToast({
  162. mask: true,
  163. icon: "none",
  164. position: "center",
  165. title: data.message,
  166. duration: 2000
  167. });
  168. setTimeout(function() {
  169. uni.redirectTo({
  170. url: '/pages/mine/mine',
  171. });
  172. }, 2000);
  173. },
  174. },
  175. }
  176. </script>
  177. <style lang="stylus" scoped>
  178. #saoCode {
  179. overflow scroll
  180. }
  181. </style>