home.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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. console.log("home", options);
  45. if (!this.$u.test.isEmpty(options.userId)) {
  46. uni.setStorageSync("userId", options.userId);
  47. }
  48. this.activityId = options.activityId;
  49. // this.authorization(options.current);
  50. this.addVisit(options.activityId);
  51. },
  52. onShow() {
  53. if (this.current == 0) {
  54. this.getRankList()
  55. }
  56. if (this.current == 2) {
  57. this.$refs.mine.getUserInfo();
  58. }
  59. },
  60. methods: {
  61. getRankList() {
  62. let params={
  63. activityId:this.activityId,
  64. type:0,//选手排名
  65. current:1,
  66. size:20
  67. }
  68. this.$u.api.activity.rankList(params).then(res => {
  69. this.rankList = res.records;
  70. })
  71. },
  72. async authorization(current) {
  73. let agenterId=uni.getStorageSync("agenterId")
  74. let params = getUrlParams(window.location.search);
  75. if (!this.$u.test.isEmpty(params.code)) {
  76. let res = await this.$u.api.wxInfo.getUserInfo({userCode: params.code});
  77. uni.setStorageSync("openid", res.openid);
  78. let datas = {
  79. nickName: res.nickname,
  80. avatar: res.headimgurl,
  81. gender: res.sex,
  82. openid: res.openid,
  83. unionid: res.unionid,
  84. province:res.province,
  85. city:res.city
  86. }
  87. if (!this.$u.test.isEmpty(agenterId)) {
  88. datas.agenterId=agenterId
  89. }
  90. let result = await this.$u.api.user.login(datas);
  91. if (result) {
  92. uni.setStorageSync("userId", result.id);
  93. if (!this.$u.test.isEmpty(current)) {
  94. this.$refs.bar.change(current);
  95. }
  96. }
  97. }
  98. },
  99. addVisit(id) {
  100. let params={
  101. id,
  102. userId:uni.getStorageSync("userId")
  103. }
  104. this.$u.api.activity.visit(params).then(res => {
  105. console.log(res);
  106. })
  107. },
  108. change(index) {
  109. this.current = index;
  110. }
  111. }
  112. }
  113. </script>
  114. <style lang="scss" scoped>
  115. .first {
  116. height: 300upx;
  117. width: 30%;
  118. border-radius: 30upx;
  119. box-shadow: -1upx -1upx 60upx #d8d8d8;
  120. }
  121. .second {
  122. height: 260upx;
  123. width: 27%;
  124. border-radius: 30upx;
  125. box-shadow: -1upx -1upx 60upx #d8d8d8;
  126. }
  127. .third {
  128. height: 260upx;
  129. width: 27%;
  130. border-radius: 30upx;
  131. box-shadow: -1upx -1upx 60upx #d8d8d8;
  132. }
  133. .hot-btn {
  134. color: #FFFFFF;
  135. line-height: 56upx;
  136. width: 70%;
  137. border-radius: 30upx;
  138. background-color: #583ce6;
  139. font-weight: bold;
  140. }
  141. </style>