saoCode.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  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. laboratoryAppBoardScanCodeVerification,
  15. laboratoryAppletGetSubDetailInfo
  16. } from '@/pages/api/index.js'
  17. export default {
  18. name: "saoCode",
  19. data() {
  20. return {
  21. webViewType: false,
  22. baseUrl: config.base_url,
  23. code: "",
  24. type: "",
  25. }
  26. },
  27. onLoad(option) {
  28. let self = this;
  29. if (option.q) {
  30. let text = decodeURIComponent(option.q)
  31. let list = text.split("?")[1].split("&");
  32. let codeData = {};
  33. list.forEach((item) => {
  34. codeData[item.split("=")[0]] = item.split("=")[1];
  35. })
  36. if (!uni.getStorageSync('token')) {
  37. uni.setStorageSync('codeData', codeData);
  38. uni.reLaunch({
  39. url: '/pages/views/login/login',
  40. });
  41. } else {
  42. //二维码功能识别
  43. this.codeRecognize(codeData);
  44. }
  45. } else {
  46. let codeData = uni.getStorageSync('codeData');
  47. uni.removeStorageSync('codeData');
  48. //二维码功能识别
  49. this.codeRecognize(codeData);
  50. }
  51. },
  52. mounted() {
  53. },
  54. methods: {
  55. //二维码功能识别
  56. codeRecognize(codeData) {
  57. if (!codeData.type) {
  58. //非功能二维码提示
  59. uni.showToast({
  60. mask: true,
  61. icon: "none",
  62. position: "center",
  63. title: '请扫描正确的小程序二维码',
  64. duration: 2000
  65. });
  66. setTimeout(function() {
  67. uni.reLaunch({
  68. url: '/pages/views/home/home',
  69. });
  70. }, 2000);
  71. } else {
  72. if (codeData.type == 11) {
  73. //化学品终端-扫码登录
  74. this.chemicalAioVerifyScanLogin(codeData.code, codeData.subId, codeData.macId);
  75. } else if (codeData.type == 12) {
  76. //化学品终端-双人认证
  77. this.chemicalAioVerifyAppletLogin(codeData.doorId, codeData.subId, codeData.macId, codeData.code);
  78. } else if (codeData.type == 13) {
  79. //电子信息牌二维码-小程序扫码验证
  80. this.laboratoryAppBoardScanCodeVerification(codeData.macId, codeData.subId, codeData.code);
  81. } else if (codeData.type == 7) {
  82. //培训课程
  83. uni.reLaunch({
  84. url: '/pages/views/pages_patrolInspector/courseQRcode?code=' + codeData.code,
  85. });
  86. } else if (codeData.type == 8) {
  87. //化学品柜
  88. uni.reLaunch({
  89. url: '/pages/views/pages_patrolInspector/chemicalCabinetQRcode?code=' + codeData.code,
  90. });
  91. } else if (codeData.type == 9) {
  92. //化学品
  93. uni.reLaunch({
  94. url: '/pages/views/pages_patrolInspector/chemicalDetail?code=' + codeData.code,
  95. });
  96. } else if (codeData.type == 1 || codeData.type == 2 || codeData.type == 3) {
  97. //1.MSDS说明书 2.安全制度 3.危险源详情
  98. this.$set(this, 'code', codeData.code);
  99. this.$set(this, 'type', codeData.type);
  100. this.$set(this, 'webViewType', true);
  101. } else if (codeData.type == 5) {
  102. //实验室详情
  103. this.laboratoryAppletGetSubDetailInfo(codeData.code);
  104. } else if (codeData.type == 10) {
  105. uni.showToast({
  106. mask: true,
  107. icon: "none",
  108. position: "center",
  109. title: '专项检查功能请从安全检查进入',
  110. duration: 2000
  111. });
  112. setTimeout(function() {
  113. uni.reLaunch({
  114. url: '/pages/views/home/home',
  115. });
  116. }, 2000);
  117. } else {
  118. uni.showToast({
  119. mask: true,
  120. icon: "none",
  121. position: "center",
  122. title: '二维码异常,请联系管理员',
  123. duration: 2000
  124. });
  125. setTimeout(function() {
  126. uni.reLaunch({
  127. url: '/pages/views/home/home',
  128. });
  129. }, 2000);
  130. }
  131. }
  132. },
  133. //化学品终端-扫码登录
  134. async chemicalAioVerifyScanLogin(code, subId, macId) {
  135. const {
  136. data
  137. } = await chemicalAioVerifyScanLogin({
  138. code: code,
  139. subId: subId,
  140. userId: uni.getStorageSync('userId'),
  141. macId: macId
  142. });
  143. uni.showToast({
  144. mask: true,
  145. icon: "none",
  146. position: "center",
  147. title: data.message,
  148. duration: 2000
  149. });
  150. setTimeout(function() {
  151. uni.reLaunch({
  152. url: '/pages/views/mine/mine',
  153. });
  154. }, 2000);
  155. },
  156. //化学品终端-双人认证
  157. async chemicalAioVerifyAppletLogin(doorId, subId, macId, code) {
  158. const {
  159. data
  160. } = await chemicalAioVerifyAppletLogin({
  161. doorId: doorId,
  162. subId: subId,
  163. macId: macId,
  164. code: code,
  165. userId: uni.getStorageSync('userId'),
  166. });
  167. uni.showToast({
  168. mask: true,
  169. icon: "none",
  170. position: "center",
  171. title: data.message,
  172. duration: 2000
  173. });
  174. setTimeout(function() {
  175. uni.reLaunch({
  176. url: '/pages/views/mine/mine',
  177. });
  178. }, 2000);
  179. },
  180. //电子信息牌二维码-小程序扫码验证
  181. async laboratoryAppBoardScanCodeVerification(macId, subId, code) {
  182. const {
  183. data
  184. } = await laboratoryAppBoardScanCodeVerification({
  185. macId: macId,
  186. subId: subId,
  187. code: code,
  188. userId: uni.getStorageSync('userId'),
  189. });
  190. uni.showToast({
  191. mask: true,
  192. icon: "none",
  193. position: "center",
  194. title: data.message,
  195. duration: 2000
  196. });
  197. setTimeout(function() {
  198. uni.reLaunch({
  199. url: '/pages/views/mine/mine',
  200. });
  201. }, 2000);
  202. },
  203. //实验室详情-跳转
  204. async laboratoryAppletGetSubDetailInfo(infoId) {
  205. const {
  206. data
  207. } = await laboratoryAppletGetSubDetailInfo({
  208. infoId: infoId
  209. });
  210. if (data.code == 200) {
  211. uni.reLaunch({
  212. // url: '/pages_manage/views/laboratory/infoPage?infoData=' + encodeURIComponent(JSON.stringify(data.data))+'&saoCode=true'
  213. url: '/pages_manage/views/laboratory/safetyCardScan?infoData=' + encodeURIComponent(JSON.stringify(data.data))+'&saoCode=true'
  214. });
  215. }
  216. },
  217. },
  218. }
  219. </script>
  220. <style lang="stylus" scoped>
  221. #saoCode {
  222. overflow scroll
  223. }
  224. </style>