saoCode.vue 6.1 KB

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