saoCode.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <!--扫描二维码页面-->
  2. <template>
  3. <view id="saoCode">
  4. <web-view :src="baseUrl+'admin/#/codeHtml?code='+code+'&type='+type"></web-view>
  5. </view>
  6. </template>
  7. <script>
  8. import { config } from '@/api/request/config.js'
  9. export default {
  10. name: "saoCode",
  11. data() {
  12. return {
  13. baseUrl:config.base_url,
  14. code:"",
  15. type:"",
  16. }
  17. },
  18. onLoad(option) {
  19. let self = this;
  20. if(option.q){
  21. let text = decodeURIComponent(option.q)
  22. let list = text.split("?")[1].split("&");
  23. for(let i=0;i<list.length;i++){
  24. let newList = list[i].split("=");
  25. if(newList[0] == 'code'){
  26. self.code = newList[1];
  27. }else if(newList[0] == 'type'){
  28. self.type = newList[1];
  29. }
  30. }
  31. if(!uni.getStorageSync('token')){
  32. uni.setStorageSync('saoCode',this.code);
  33. uni.setStorageSync('saoType',this.type);
  34. uni.redirectTo({
  35. url: '/pages/login',
  36. });
  37. }else{
  38. if(this.type==7){//培训课程
  39. uni.redirectTo({
  40. url: '/pages/pages_patrolInspector/courseQRcode?code='+this.code,
  41. });
  42. }else if(this.type==8){//化学品柜
  43. uni.redirectTo({
  44. url: '/pages/pages_patrolInspector/chemicalCabinetQRcode?code='+this.code,
  45. });
  46. }else if(this.type==9){//化学品
  47. uni.redirectTo({
  48. url: '/pages/pages_patrolInspector/chemicalDetail?code='+this.code,
  49. });
  50. }
  51. }
  52. }else{
  53. this.code = uni.getStorageSync('saoCode');
  54. this.type = uni.getStorageSync('saoType');
  55. uni.removeStorageSync('saoCode');
  56. uni.removeStorageSync('saoType');
  57. if(this.type==7){//培训课程
  58. uni.redirectTo({
  59. url: '/pages/pages_patrolInspector/courseQRcode?code='+this.code,
  60. });
  61. }else if(this.type==8){//化学品柜
  62. uni.redirectTo({
  63. url: '/pages/pages_patrolInspector/chemicalCabinetQRcode?code='+this.code,
  64. });
  65. }else if(this.type==9){//化学品
  66. uni.redirectTo({
  67. url: '/pages/pages_patrolInspector/chemicalDetail?code='+this.code,
  68. });
  69. }
  70. }
  71. },
  72. mounted(){
  73. },
  74. methods:{
  75. },
  76. }
  77. </script>
  78. <style lang="stylus" scoped>
  79. #saoCode{
  80. overflow scroll
  81. }
  82. </style>