saoCode.vue 6.3 KB

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