results.vue 3.2 KB

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