index.vue 1.6 KB

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