home.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. <template>
  2. <view>
  3. <!--活动页面-->
  4. <view v-if="current == 0">
  5. <activity-view :rankList="rankList" :activityId="activityId"></activity-view>
  6. </view>
  7. <!--花积分-->
  8. <view v-if="current == 1">
  9. <points-view :activityId="activityId"></points-view>
  10. </view>
  11. <!--个人中心-->
  12. <view v-if="current == 2">
  13. <mine-view ref="mine" :activityId="activityId"></mine-view>
  14. </view>
  15. <view style="height: 100upx;"></view>
  16. <view class="footer-fixed">
  17. <bottom-bar-home ref="bar" @onTap="change"></bottom-bar-home>
  18. </view>
  19. </view>
  20. </template>
  21. <script>
  22. import {getUrlParams} from '@/common/utils/utils.js';
  23. import searchBar from "@/components/basic/search-bar.vue";
  24. import bottomBarHome from "@/components/basic/bottom-bar-home.vue";
  25. import activityView from "@/components/homeViews/activity-view.vue";
  26. import pointsView from "@/components/homeViews/points-view.vue";
  27. import mineView from "@/components/homeViews/mine-view.vue";
  28. export default {
  29. components: {
  30. searchBar,
  31. bottomBarHome,
  32. activityView,
  33. mineView,
  34. pointsView
  35. },
  36. data() {
  37. return {
  38. rankList:[],
  39. activityId: '',
  40. current: 0,
  41. }
  42. },
  43. onLoad(options) {
  44. this.activityId = options.activityId;
  45. this.authorization(options.current);
  46. this.addVisit(options.activityId);
  47. },
  48. onShow() {
  49. if (this.current == 0) {
  50. this.getRankList()
  51. }
  52. if (this.current == 2) {
  53. this.$refs.mine.getUserInfo();
  54. }
  55. },
  56. methods: {
  57. getRankList() {
  58. let params={
  59. activityId:this.activityId,
  60. type:0,//选手排名
  61. current:1,
  62. size:20
  63. }
  64. this.$u.api.activity.rankList(params).then(res => {
  65. this.rankList = res.records;
  66. })
  67. },
  68. async authorization(current) {
  69. let agenterId=uni.getStorageSync("agenterId")
  70. let params = getUrlParams(window.location.search);
  71. if (!this.$u.test.isEmpty(params.code)) {
  72. let res = await this.$u.api.wxInfo.getUserInfo({userCode: params.code});
  73. uni.setStorageSync("openid", res.openid);
  74. let datas = {
  75. nickName: res.nickname,
  76. avatar: res.headimgurl,
  77. gender: res.sex,
  78. openid: res.openid,
  79. unionid: res.unionid,
  80. province:res.province,
  81. city:res.city
  82. }
  83. if (!this.$u.test.isEmpty(agenterId)) {
  84. datas.agenterId=agenterId
  85. }
  86. let result = await this.$u.api.user.login(datas);
  87. if (result) {
  88. uni.setStorageSync("userId", result.id);
  89. if (!this.$u.test.isEmpty(current)) {
  90. this.$refs.bar.change(current);
  91. }
  92. }
  93. }
  94. },
  95. addVisit(id) {
  96. let params={
  97. id,
  98. userId:uni.getStorageSync("userId")
  99. }
  100. this.$u.api.activity.visit(params).then(res => {
  101. console.log(res);
  102. })
  103. },
  104. change(index) {
  105. this.current = index;
  106. }
  107. }
  108. }
  109. </script>
  110. <style lang="scss" scoped>
  111. .first {
  112. height: 300upx;
  113. width: 30%;
  114. border-radius: 30upx;
  115. box-shadow: -1upx -1upx 60upx #d8d8d8;
  116. }
  117. .second {
  118. height: 260upx;
  119. width: 27%;
  120. border-radius: 30upx;
  121. box-shadow: -1upx -1upx 60upx #d8d8d8;
  122. }
  123. .third {
  124. height: 260upx;
  125. width: 27%;
  126. border-radius: 30upx;
  127. box-shadow: -1upx -1upx 60upx #d8d8d8;
  128. }
  129. .hot-btn {
  130. color: #FFFFFF;
  131. line-height: 56upx;
  132. width: 70%;
  133. border-radius: 30upx;
  134. background-color: #583ce6;
  135. font-weight: bold;
  136. }
  137. </style>