saoCode.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. <!--扫描二维码页面-->
  2. <template>
  3. <view id="saoCode">
  4. <web-view v-if="webViewType" :src="baseUrl+'admin/#/codeHtml?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. laboratoryAppletGetSubDetailInfo
  15. } from '@/pages/api/index.js'
  16. export default {
  17. name: "saoCode",
  18. data() {
  19. return {
  20. webViewType: false,
  21. baseUrl: config.base_url,
  22. code: "",
  23. type: "",
  24. }
  25. },
  26. onLoad(option) {
  27. console.log('option',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.redirectTo({
  39. url: '/pages/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.redirectTo({
  68. url: '/pages/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 == 7) {
  79. //培训课程
  80. uni.redirectTo({
  81. url: '/pages/views/pages_patrolInspector/courseQRcode?code=' + codeData.code,
  82. });
  83. } else if (codeData.type == 8) {
  84. //化学品柜
  85. uni.redirectTo({
  86. url: '/pages/views/pages_patrolInspector/chemicalCabinetQRcode?code=' + codeData.code,
  87. });
  88. } else if (codeData.type == 9) {
  89. //化学品
  90. uni.redirectTo({
  91. url: '/pages/views/pages_patrolInspector/chemicalDetail?code=' + codeData.code,
  92. });
  93. } else if (codeData.type == 1 || codeData.type == 2 || codeData.type == 3) {
  94. //1.MSDS说明书 2.安全制度 3.危险源详情
  95. this.$set(this, 'code', codeData.code);
  96. this.$set(this, 'type', codeData.type);
  97. this.$set(this, 'webViewType', true);
  98. } else if (codeData.type == 5) {
  99. //实验室详情
  100. this.laboratoryAppletGetSubDetailInfo(codeData.code);
  101. } else if (codeData.type == 10) {
  102. uni.showToast({
  103. mask: true,
  104. icon: "none",
  105. position: "center",
  106. title: '专项检查功能请从安全检查进入',
  107. duration: 2000
  108. });
  109. setTimeout(function() {
  110. uni.redirectTo({
  111. url: '/pages/views/home/home',
  112. });
  113. }, 2000);
  114. } else {
  115. uni.showToast({
  116. mask: true,
  117. icon: "none",
  118. position: "center",
  119. title: '二维码异常,请联系管理员',
  120. duration: 2000
  121. });
  122. setTimeout(function() {
  123. uni.redirectTo({
  124. url: '/pages/views/home/home',
  125. });
  126. }, 2000);
  127. }
  128. }
  129. },
  130. //化学品终端-扫码登录
  131. async chemicalAioVerifyScanLogin(code, subId, macId) {
  132. const {
  133. data
  134. } = await chemicalAioVerifyScanLogin({
  135. code: code,
  136. subId: subId,
  137. userId: uni.getStorageSync('userId'),
  138. macId: macId
  139. });
  140. uni.showToast({
  141. mask: true,
  142. icon: "none",
  143. position: "center",
  144. title: data.message,
  145. duration: 2000
  146. });
  147. setTimeout(function() {
  148. uni.redirectTo({
  149. url: '/pages/views/mine/mine',
  150. });
  151. }, 2000);
  152. },
  153. //化学品终端-双人认证
  154. async chemicalAioVerifyAppletLogin(doorId, subId, macId, code) {
  155. const {
  156. data
  157. } = await chemicalAioVerifyAppletLogin({
  158. doorId: doorId,
  159. subId: subId,
  160. macId: macId,
  161. code: code,
  162. userId: uni.getStorageSync('userId'),
  163. });
  164. uni.showToast({
  165. mask: true,
  166. icon: "none",
  167. position: "center",
  168. title: data.message,
  169. duration: 2000
  170. });
  171. setTimeout(function() {
  172. uni.redirectTo({
  173. url: '/pages/views/mine/mine',
  174. });
  175. }, 2000);
  176. },
  177. //实验室详情-跳转
  178. async laboratoryAppletGetSubDetailInfo(infoId) {
  179. const {
  180. data
  181. } = await laboratoryAppletGetSubDetailInfo({
  182. infoId: infoId
  183. });
  184. if (data.code == 200) {
  185. uni.redirectTo({
  186. url: '/pages_manage/views/laboratory/infoPage?infoData=' + encodeURIComponent(JSON.stringify(data.data))+'&saoCode=true'
  187. });
  188. }
  189. },
  190. },
  191. }
  192. </script>
  193. <style lang="stylus" scoped>
  194. #saoCode {
  195. overflow scroll
  196. }
  197. </style>