saoCode.vue 6.1 KB

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