results.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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({
  41. // ...( openid ? { openid } : { code })
  42. // })
  43. const result ={
  44. "code": 0,
  45. "message": "获取成功",
  46. "data": {
  47. "id": "1",
  48. "openid": "oOpc26KiZFBKIm7SB8knFGvov1qg",
  49. "mobile": "",
  50. "gender": "0",
  51. "nickname": "雪寒",
  52. "avatar": "",
  53. "subscribe_time": "2022-12-21 15:52:14",
  54. "addr": "\/\/",
  55. "status": "1",
  56. "is_show": ["1", "2", "4"],
  57. "companyArr": [{
  58. "companyNo": "GS2302231125079621",
  59. "companyName": "北京百辰荣达国际科贸有限公司",
  60. "info": [1,2]
  61. }, {
  62. "companyNo": "GS2302231323386950",
  63. "companyName": "北京泓源广诚国际商贸有限公司",
  64. "info": [1,2]
  65. }, {
  66. "companyNo": "GS2304031312553746",
  67. "companyName": "北京锦兴弘昌科技有限公司",
  68. "info": [1, 2]
  69. }, {
  70. "companyNo": "GS2302231124114965",
  71. "companyName": "北京普润心堂商贸有限公司",
  72. "info": [1, 2]
  73. }, {
  74. "companyNo": "GS2203161855277894",
  75. "companyName": "北京万宇恒通国际科贸有限公司",
  76. "info": [1, 2]
  77. }],
  78. "addtime": "2023-04-10 18:11:07",
  79. "updatetime": "2023-05-09 16:22:33"
  80. }
  81. }
  82. this.state.loading = false
  83. switch(Number(result.code)){
  84. case 0:
  85. this.companyArr = result.data.companyArr.filter(({info = []}) => info.includes(1) || info.includes('1'))
  86. this.hasPlatformDimension = (result.data.is_show || []).includes(1) || (result.data.is_show || []).includes('1')
  87. this.isShow = this.hasPlatformDimension
  88. setOpenid(result.data.openid)
  89. break
  90. default:
  91. this.state.error = true
  92. this.state.message = result.message
  93. openid && removeOpenid()
  94. break
  95. }
  96. }
  97. }
  98. };
  99. </script>