results.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <template>
  2. <div id="app" v-cloak v-loading="state.loading" style="min-height: 300px;">
  3. <template v-if="!state.error && isShow">
  4. <div style="color:red;position:absolute;top:30px;left:10px;font-weight: 700;display:flex">
  5. <div>
  6. <i class="el-icon-warning-outline"></i> 以下报表一小时更新一次
  7. </div>
  8. </div>
  9. <control-display :companyArr="companyArr" :hasPlatformDimension="hasPlatformDimension" />
  10. </template>
  11. <template v-else-if="!state.loading">
  12. <unusual-state :hasPermission="isShow" :message="state.message" path="results" />
  13. </template>
  14. </div>
  15. </template>
  16. <script>
  17. import asyncRequest from "@/api/index"
  18. import { ControlDisplay } from "@/ccomponents/reports"
  19. import UnusualState from "@/components/unusual/index.vue"
  20. import { getParameterByName , setOpenid, removeOpenid, getOpenid } from "../utils/auth"
  21. export default {
  22. name:'report',
  23. components:{ UnusualState, ControlDisplay},
  24. data() {
  25. return {
  26. companyArr:[],
  27. hasPlatformDimension: false,
  28. isShow : false,
  29. state:{
  30. error:false,
  31. loading:false,
  32. message:'',
  33. }
  34. }
  35. },
  36. async mounted(){
  37. document.title = "1.业绩报表"
  38. this.requestUserinfo()
  39. },
  40. methods:{
  41. async requestUserinfo(){
  42. this.state.loading = true;
  43. const openid = getOpenid()
  44. const code = getParameterByName('code')
  45. const result = await asyncRequest.userinfo({ ...( openid ? { openid } : { code }) })
  46. // const result ={
  47. // "code": 0,
  48. // "message": "获取成功",
  49. // "data": {
  50. // "id": "1",
  51. // "openid": "oOpc26KiZFBKIm7SB8knFGvov1qg",
  52. // "mobile": "",
  53. // "gender": "0",
  54. // "nickname": "雪寒",
  55. // "avatar": "",
  56. // "subscribe_time": "2022-12-21 15:52:14",
  57. // "addr": "\/\/",
  58. // "status": "1",
  59. // "is_show": ["1", "2", "4"],
  60. // "companyArr": [{
  61. // "companyNo": "GS2302231125079621",
  62. // "companyName": "北京百辰荣达国际科贸有限公司",
  63. // "info": [1,2]
  64. // }, {
  65. // "companyNo": "GS2302231323386950",
  66. // "companyName": "北京泓源广诚国际商贸有限公司",
  67. // "info": [1,2]
  68. // }, {
  69. // "companyNo": "GS2304031312553746",
  70. // "companyName": "北京锦兴弘昌科技有限公司",
  71. // "info": [1, 2]
  72. // }, {
  73. // "companyNo": "GS2302231124114965",
  74. // "companyName": "北京普润心堂商贸有限公司",
  75. // "info": [1, 2]
  76. // }, {
  77. // "companyNo": "GS2203161855277894",
  78. // "companyName": "北京万宇恒通国际科贸有限公司",
  79. // "info": [1, 2]
  80. // }],
  81. // "addtime": "2023-04-10 18:11:07",
  82. // "updatetime": "2023-05-09 16:22:33"
  83. // }
  84. // }
  85. this.state.loading = false
  86. switch(Number(result.code)){
  87. case 0:
  88. this.companyArr = result.data.companyArr.filter(({info = []}) => info.includes(1) || info.includes('1'))
  89. this.hasPlatformDimension = (result.data.is_show || []).includes(1) || (result.data.is_show || []).includes('1')
  90. this.isShow = this.hasPlatformDimension
  91. setOpenid(result.data.openid)
  92. break
  93. default:
  94. this.state.error = true
  95. this.state.message = result.message
  96. openid && removeOpenid()
  97. break
  98. }
  99. }
  100. }
  101. };
  102. </script>