tabCenter.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. <template>
  2. <view class="center">
  3. <view
  4. @click="goPath(item, index)"
  5. class="center-item"
  6. v-for="(item, index) in centerList"
  7. :key="index"
  8. >
  9. <div :style="{'background':index==0?'#8AE6C7':'#B1CEFF'}" class="center-circle">
  10. <image class="center-img" :src="item.img"></image>
  11. <view style="width: 100%;"
  12. ><text style="color:#0A6345" v-if="index == 0">{{ "精选考题 \n500题" }}</text
  13. ><text style="color:#174087" v-if="index == 1">{{ "模拟考试 \n仿真题目" }}</text></view
  14. >
  15. </div>
  16. </view>
  17. </view>
  18. </template>
  19. <script>
  20. import utils from "@/utils/index";
  21. export default {
  22. data() {
  23. //exercise
  24. return {};
  25. },
  26. computed: {
  27. isVip() {
  28. return this.$store.getters.isVip;
  29. },
  30. },
  31. methods: {
  32. goPath(item, index) {
  33. let query = Object.assign({}, this.query);
  34. query.title = item.text;
  35. if (this.needVipList.includes(index) && !this.isVip) {
  36. uni.showModal({
  37. title: "提示",
  38. content: "需要vip才能使用这个功能",
  39. confirmText: "购买vip",
  40. cancelText: "取消",
  41. success(res) {
  42. console.log(res);
  43. if (res.confirm) {
  44. uni.navigateTo({
  45. url: "/otherPages/buyVip/index",
  46. });
  47. }
  48. },
  49. });
  50. return;
  51. }
  52. if (item.path) {
  53. let str = utils.mapToUrlQuery(query);
  54. console.log(item.path + "?" + str, "str");
  55. uni.navigateTo({
  56. url: item.path + "?" + str,
  57. });
  58. }
  59. },
  60. },
  61. props: {
  62. needVipList: {
  63. type: Array,
  64. default: () => {
  65. return [];
  66. },
  67. },
  68. query: {
  69. type: Object,
  70. default: () => {
  71. return {};
  72. },
  73. },
  74. centerList: {
  75. type: Array,
  76. default: () => {
  77. return [];
  78. },
  79. },
  80. },
  81. };
  82. </script>
  83. <style lang="scss" scoped>
  84. .center {
  85. display: flex;
  86. flex-direction: column;
  87. width: 300rpx;
  88. margin-top: 80rpx;
  89. .center-circle {
  90. width: 240rpx;
  91. height: 240rpx;
  92. border-radius: 50%;
  93. font-size: 28rpx;
  94. display: flex;
  95. align-items: center;
  96. align-content: center;
  97. flex-wrap: wrap;
  98. justify-content: center;
  99. }
  100. .center-item {
  101. position: relative;
  102. margin-bottom: 100rpx;
  103. color: #fff;
  104. text-align: center;
  105. display: flex;
  106. justify-content: center;
  107. }
  108. .center-img {
  109. width: 74rpx;
  110. height: 82rpx;
  111. }
  112. .center-text {
  113. position: absolute;
  114. width: 100%;
  115. height: 100%;
  116. display: flex;
  117. align-content: center;
  118. justify-content: center;
  119. align-items: center;
  120. left: 0;
  121. top: 0;
  122. font-size: $uni-app-fontsize-paragraph;
  123. }
  124. }
  125. </style>