saoCode.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  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. 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 == 14) {
  82. //化学品-操作教程
  83. uni.reLaunch({
  84. url: '/pages/views/saoCode/chemicalsInstructionsVideo'
  85. });
  86. } else if (codeData.type == 7) {
  87. //培训课程
  88. uni.reLaunch({
  89. url: '/pages/views/pages_patrolInspector/courseQRcode?code=' + codeData.code,
  90. });
  91. } else if (codeData.type == 8) {
  92. //化学品柜
  93. uni.reLaunch({
  94. url: '/pages/views/pages_patrolInspector/chemicalCabinetQRcode?code=' + codeData.code,
  95. });
  96. } else if (codeData.type == 9) {
  97. //化学品
  98. uni.reLaunch({
  99. url: '/pages/views/pages_patrolInspector/chemicalDetail?code=' + codeData.code,
  100. });
  101. } else if (codeData.type == 1 || codeData.type == 2 || codeData.type == 3) {
  102. //1.MSDS说明书 2.安全制度 3.危险源详情
  103. this.$set(this, 'code', codeData.code);
  104. this.$set(this, 'type', codeData.type);
  105. this.$set(this, 'webViewType', true);
  106. } else if (codeData.type == 5) {
  107. //实验室详情
  108. this.laboratoryAppletGetSubDetailInfo(codeData.code);
  109. } else if (codeData.type == 10) {
  110. uni.showToast({
  111. mask: true,
  112. icon: "none",
  113. position: "center",
  114. title: '专项检查功能请从安全检查进入',
  115. duration: 2000
  116. });
  117. setTimeout(function() {
  118. uni.reLaunch({
  119. url: '/pages/views/home/home',
  120. });
  121. }, 2000);
  122. } else {
  123. uni.showToast({
  124. mask: true,
  125. icon: "none",
  126. position: "center",
  127. title: '二维码异常,请联系管理员',
  128. duration: 2000
  129. });
  130. setTimeout(function() {
  131. uni.reLaunch({
  132. url: '/pages/views/home/home',
  133. });
  134. }, 2000);
  135. }
  136. }
  137. },
  138. //化学品终端-扫码登录
  139. async chemicalAioVerifyScanLogin(code, subId, macId) {
  140. const {
  141. data
  142. } = await chemicalAioVerifyScanLogin({
  143. code: code,
  144. subId: subId,
  145. userId: uni.getStorageSync('userId'),
  146. macId: macId
  147. });
  148. uni.showToast({
  149. mask: true,
  150. icon: "none",
  151. position: "center",
  152. title: data.message,
  153. duration: 2000
  154. });
  155. setTimeout(function() {
  156. uni.reLaunch({
  157. url: '/pages/views/mine/mine',
  158. });
  159. }, 2000);
  160. },
  161. //化学品终端-双人认证
  162. async chemicalAioVerifyAppletLogin(doorId, subId, macId, code) {
  163. const {
  164. data
  165. } = await chemicalAioVerifyAppletLogin({
  166. doorId: doorId,
  167. subId: subId,
  168. macId: macId,
  169. code: code,
  170. userId: uni.getStorageSync('userId'),
  171. });
  172. uni.showToast({
  173. mask: true,
  174. icon: "none",
  175. position: "center",
  176. title: data.message,
  177. duration: 2000
  178. });
  179. setTimeout(function() {
  180. uni.reLaunch({
  181. url: '/pages/views/mine/mine',
  182. });
  183. }, 2000);
  184. },
  185. //电子信息牌二维码-小程序扫码验证
  186. async laboratoryAppBoardScanCodeVerification(macId, subId, code) {
  187. const {
  188. data
  189. } = await laboratoryAppBoardScanCodeVerification({
  190. macId: macId,
  191. subId: subId,
  192. code: code,
  193. userId: uni.getStorageSync('userId'),
  194. });
  195. uni.showToast({
  196. mask: true,
  197. icon: "none",
  198. position: "center",
  199. title: data.message,
  200. duration: 2000
  201. });
  202. setTimeout(function() {
  203. uni.reLaunch({
  204. url: '/pages/views/mine/mine',
  205. });
  206. }, 2000);
  207. },
  208. //实验室详情-跳转
  209. async laboratoryAppletGetSubDetailInfo(infoId) {
  210. const {
  211. data
  212. } = await laboratoryAppletGetSubDetailInfo({
  213. infoId: infoId
  214. });
  215. if (data.code == 200) {
  216. uni.reLaunch({
  217. // url: '/pages_manage/views/laboratory/infoPage?infoData=' + encodeURIComponent(JSON.stringify(data.data))+'&saoCode=true'
  218. url: '/pages_manage/views/laboratory/safetyCardScan?infoData=' + encodeURIComponent(JSON.stringify(data.data))+'&saoCode=true'
  219. });
  220. }
  221. },
  222. },
  223. }
  224. </script>
  225. <style lang="stylus" scoped>
  226. #saoCode {
  227. overflow scroll
  228. }
  229. </style>