index.vue 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <template>
  2. <mobile v-if="!isPC" :com="com" :dev="dev" :vipDetail="vipDetail" :isCom="isCom"></mobile>
  3. </template>
  4. <script>
  5. import { mapState } from "vuex";
  6. // import http from '@/plugins/http'
  7. import pc from "@/components/type/vip/pc";
  8. import mobile from "@/components/type/vip/mobile";
  9. import getDeviceType from "@/mixins/getDeviceType";
  10. import qs from "qs";
  11. export default {
  12. // async asyncData({ $axios, params }) {
  13. // let res = await $axios.$get(`/api/vip/getList`)
  14. // console.log('init', res)
  15. // },
  16. head: {
  17. title: "会员中心页 - 程序员客栈"
  18. },
  19. components: {
  20. pc,
  21. mobile
  22. },
  23. mixins: [getDeviceType],
  24. data() {
  25. return {
  26. vipList: [],
  27. vipDetail: {}
  28. };
  29. },
  30. computed: {
  31. ...mapState(["isPC"]),
  32. com() {
  33. return this.vipList[0];
  34. },
  35. dev() {
  36. return this.vipList[1];
  37. },
  38. isCom() {
  39. if (this.$route.query.isCom) return true;
  40. return this.vipDetail.vip_type_id !== "2";
  41. }
  42. },
  43. async mounted() {
  44. await this.getList();
  45. this.getVipDetail();
  46. if (this.isPC){
  47. location.href="/#vip";
  48. }
  49. },
  50. methods: {
  51. async getList() {
  52. let extraHeaders = {};
  53. if (this.deviceType === "ios") {
  54. extraHeaders = this.getSign();
  55. }
  56. let res = await this.$axios.$post(`/api/vip/getList`, extraHeaders);
  57. if (res) {
  58. this.vipList = res.data;
  59. }
  60. },
  61. async getVipDetail() {
  62. let res = await this.$axios.$post("/api/vip/getVipUserDetail");
  63. // if (!res || !res.data) return
  64. this.vipDetail = res && res.data ? res.data : {};
  65. if (this.isCom) this.currentCom = true;
  66. }
  67. }
  68. };
  69. </script>
  70. <style>
  71. </style>