saoCode.vue 6.0 KB

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