saoCode.vue 6.3 KB

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