saoCode.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  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 if(codeData.type == 'offlineTraining'){
  123. uni.reLaunch({
  124. url: '/pages_basics/views/trainingSignIn?code=' + codeData.code
  125. });
  126. } else {
  127. uni.showToast({
  128. mask: true,
  129. icon: "none",
  130. position: "center",
  131. title: '二维码异常,请联系管理员',
  132. duration: 2000
  133. });
  134. setTimeout(function() {
  135. uni.reLaunch({
  136. url: '/pages/views/home/home',
  137. });
  138. }, 2000);
  139. }
  140. }
  141. },
  142. //化学品终端-扫码登录
  143. async chemicalAioVerifyScanLogin(code, subId, macId) {
  144. const {
  145. data
  146. } = await chemicalAioVerifyScanLogin({
  147. code: code,
  148. subId: subId,
  149. userId: uni.getStorageSync('userId'),
  150. macId: macId
  151. });
  152. uni.showToast({
  153. mask: true,
  154. icon: "none",
  155. position: "center",
  156. title: data.message,
  157. duration: 2000
  158. });
  159. setTimeout(function() {
  160. uni.reLaunch({
  161. url: '/pages/views/mine/mine',
  162. });
  163. }, 2000);
  164. },
  165. //化学品终端-双人认证
  166. async chemicalAioVerifyAppletLogin(doorId, subId, macId, code) {
  167. const {
  168. data
  169. } = await chemicalAioVerifyAppletLogin({
  170. doorId: doorId,
  171. subId: subId,
  172. macId: macId,
  173. code: code,
  174. userId: uni.getStorageSync('userId'),
  175. });
  176. uni.showToast({
  177. mask: true,
  178. icon: "none",
  179. position: "center",
  180. title: data.message,
  181. duration: 2000
  182. });
  183. setTimeout(function() {
  184. uni.reLaunch({
  185. url: '/pages/views/mine/mine',
  186. });
  187. }, 2000);
  188. },
  189. //电子信息牌二维码-小程序扫码验证
  190. async laboratoryAppBoardScanCodeVerification(macId, subId, code) {
  191. const {
  192. data
  193. } = await laboratoryAppBoardScanCodeVerification({
  194. macId: macId,
  195. subId: subId,
  196. code: code,
  197. userId: uni.getStorageSync('userId'),
  198. });
  199. uni.showToast({
  200. mask: true,
  201. icon: "none",
  202. position: "center",
  203. title: data.message,
  204. duration: 2000
  205. });
  206. setTimeout(function() {
  207. uni.reLaunch({
  208. url: '/pages/views/mine/mine',
  209. });
  210. }, 2000);
  211. },
  212. //实验室详情-跳转
  213. async laboratoryAppletGetSubDetailInfo(infoId) {
  214. const {
  215. data
  216. } = await laboratoryAppletGetSubDetailInfo({
  217. infoId: infoId
  218. });
  219. if (data.code == 200) {
  220. uni.reLaunch({
  221. // url: '/pages_manage/views/laboratory/infoPage?infoData=' + encodeURIComponent(JSON.stringify(data.data))+'&saoCode=true'
  222. url: '/pages_manage/views/laboratory/safetyCardScan?infoData=' + encodeURIComponent(JSON.stringify(data.data))+'&saoCode=true'
  223. });
  224. }
  225. },
  226. },
  227. }
  228. </script>
  229. <style lang="stylus" scoped>
  230. #saoCode {
  231. overflow scroll
  232. }
  233. </style>