saoCode.vue 6.2 KB

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