Yansen 2 years ago
parent
commit
dc2d4b6b17

+ 2
- 0
src/app.js View File

1
 import Taro from '@tarojs/taro';
1
 import Taro from '@tarojs/taro';
2
 import { createApp } from 'vue';
2
 import { createApp } from 'vue';
3
+import bannerAd from '@/components/ad/bannerAd.vue'
3
 import aLayout from '@/layout/aLayout.vue'
4
 import aLayout from '@/layout/aLayout.vue'
4
 import './app.less';
5
 import './app.less';
5
 import { login, updatePerson } from './service/person';
6
 import { login, updatePerson } from './service/person';
37
 });
38
 });
38
 
39
 
39
 App.use(store);
40
 App.use(store);
41
+App.component('banner-ad', bannerAd);
40
 App.component('a-layout', aLayout);
42
 App.component('a-layout', aLayout);
41
 
43
 
42
 export default App
44
 export default App

+ 42
- 0
src/components/ad/bannerAd.vue View File

1
+<template>
2
+  <view style="height: 130px">
3
+    <template v-for="(it, inx) in list" :key="inx">
4
+      <basic-ad v-if="current === inx"></basic-ad>
5
+    </template>
6
+  </view>
7
+</template>
8
+
9
+<script>
10
+  import { onMounted, ref } from 'vue';
11
+  import { getSeq } from '@/service/adSeq';
12
+  import basicAd from './basicAd.vue'
13
+
14
+  export default {
15
+    components: {
16
+      'basic-ad': basicAd,
17
+    },
18
+    setup() {
19
+      const current = ref(0);
20
+      const list = new Array(20).fill();
21
+
22
+      onMounted(() => {
23
+        getSeq().then(res => {
24
+          if (res.dt > 0) {
25
+            const t = setInterval(() => {
26
+              if (current.value >= list.length - 1) {
27
+                current.value = 0;
28
+              } else {
29
+                current.value += 1;
30
+              }
31
+            }, res.dt);
32
+          }
33
+        })
34
+      });
35
+
36
+      return {
37
+        current,
38
+        list
39
+      }
40
+    }
41
+  }
42
+</script>

+ 3
- 0
src/components/ad/basicAd.vue View File

1
+<template>
2
+  <ad unit-id="adunit-134135d609e5c485"></ad>
3
+</template>

+ 1
- 1
src/layout/aLayout.vue View File

4
       <slot></slot>
4
       <slot></slot>
5
     </view>
5
     </view>
6
     <view class="flex-0">
6
     <view class="flex-0">
7
-      <ad unit-id="adunit-134135d609e5c485"></ad>
7
+      <banner-ad />
8
     </view>
8
     </view>
9
   </view>
9
   </view>
10
 </template>
10
 </template>

+ 38
- 22
src/pages/rank/components/list.vue View File

1
 <template>
1
 <template>
2
-  <scroll-view
3
-    :style="style"
4
-    scroll-y="true"
5
-    lower-threshold="60"
6
-    @scrolltolower="onScroll"
7
-  >
8
-    <view class="flex rank-row" v-for="(item, index) in list" :key="item.id">
9
-      <view class="flex-0 rank-no">{{index + 1}}</view>
10
-      <view class="flex-0 rank-thumb">
11
-        <image :src="item.avatar || flag"></image>
12
-      </view>
13
-      <view class="flex-1">{{item.name || '-'}}</view>
14
-      <view class="flex-0 rank-num">{{`${item.stNum} 人次`}}</view>
2
+  <view style="height: 100%">
3
+    <view class="rank-list-box" :style="style">
4
+      <scroll-view
5
+        style="height: 100%"
6
+        scroll-y="true"
7
+        lower-threshold="60"
8
+        @scrolltolower="onScroll"
9
+      >
10
+        <view class="flex rank-row" v-for="(item, index) in list" :key="item.id">
11
+          <view class="flex-0 rank-no">{{index + 1}}</view>
12
+          <view class="flex-0 rank-thumb">
13
+            <image :src="item.avatar || flag"></image>
14
+          </view>
15
+          <view class="flex-1">{{item.name || '-'}}</view>
16
+          <view class="flex-0 rank-num">{{`${item.stNum} 人次`}}</view>
17
+        </view>
18
+      </scroll-view>
15
     </view>
19
     </view>
16
-  </scroll-view>
20
+    <view>
21
+      <banner-ad></banner-ad>
22
+    </view>
23
+  </view>
17
 </template>
24
 </template>
18
 
25
 
19
 <script>
26
 <script>
32
       const pageNumber = ref(0);
39
       const pageNumber = ref(0);
33
       const finished = ref(false);
40
       const finished = ref(false);
34
 
41
 
35
-      // 100vw * 130 / 375 为 banner 高度
36
-      // 130px 为广告高度
37
-      const style = 'height: calc(100vh - 100vw * 130 / 375 - 130px)';
42
+      // 160px 为head高度 + marginTop
43
+      const style = 'height: calc(100% - 160px)';
38
       
44
       
39
       const listReachBottom = (pg) => {
45
       const listReachBottom = (pg) => {
40
         Taro.showLoading();
46
         Taro.showLoading();
73
 </script>
79
 </script>
74
 
80
 
75
 <style lang="less">
81
 <style lang="less">
82
+.rank-list {
83
+  height: 100%;
84
+}
85
+
86
+.rank-list-box {
87
+  width: calc(100% - 2em);
88
+  box-sizing: border-box;
89
+  background: #faf4e6;
90
+  border-radius: 16rpx;
91
+  padding: 1em;
92
+  margin: 1em;
93
+}
94
+
76
 .rank-row {
95
 .rank-row {
77
   box-sizing: border-box;
96
   box-sizing: border-box;
78
-  padding: 16rpx 1em;
97
+  padding: 16rpx 0;
79
   font-size: 32rpx;
98
   font-size: 32rpx;
80
-
81
-  &:nth-child(odd) {
82
-    background: #fff;
83
-  }
84
 }
99
 }
85
 
100
 
86
 .rank-no {
101
 .rank-no {
100
 
115
 
101
 .rank-num {
116
 .rank-num {
102
   width: 6em;
117
   width: 6em;
118
+  text-align: right;
103
 }
119
 }
104
 </style>
120
 </style>

+ 62
- 23
src/pages/rank/index.vue View File

1
 <template>
1
 <template>
2
-  <a-layout>
3
-    <view class="v-flex container">
4
-      <banner-box class="flex-0">
5
-        <view class="rank-tab flex">
6
-          <view class="flex-1" :class="{ active: current === 0 }" @tap="current = 0">
7
-            分享排名
8
-          </view>
9
-          <view class="flex-1" :class="{ active: current === 1 }" @tap="current = 1">
10
-            区域排名
11
-          </view>
2
+  <view class="page rank-page">
3
+    <view class="rank-head">
4
+      <view class="rank-tab flex">
5
+        <view class="flex-1" :class="{ active: current === 0 }" @tap="current = 0">
6
+          分享排名
12
         </view>
7
         </view>
13
-      </banner-box>
14
-      <view class="flex-1">
15
-        <rank-list v-if="current === 0" st-type="person"></rank-list>
16
-        <rank-list v-else st-type="area"></rank-list>
8
+        <view class="flex-1" :class="{ active: current === 1 }" @tap="current = 1">
9
+          区域排名
10
+        </view>
11
+      </view>
12
+      <view class="rank-mine">
13
+        {{rankDesc}}
17
       </view>
14
       </view>
18
     </view>
15
     </view>
19
-  </a-layout>
16
+    <view class="rank-body">
17
+      <rank-list v-if="current === 0" st-type="person"></rank-list>
18
+      <rank-list v-else st-type="area"></rank-list>
19
+    </view>
20
+  </view>
20
 </template>
21
 </template>
21
 
22
 
22
 <script>
23
 <script>
23
-import { ref } from 'vue';
24
+import { computed, ref, watch } from 'vue';
24
 import Taro, { useReady } from '@tarojs/taro';
25
 import Taro, { useReady } from '@tarojs/taro';
25
 import { useModel } from '@zjxpcyc/vue-tiny-store';
26
 import { useModel } from '@zjxpcyc/vue-tiny-store';
26
 import BannerBox from '@/components/banner/index.vue'
27
 import BannerBox from '@/components/banner/index.vue'
28
+import { getMyRank } from '@/service/rank';
27
 import ListVue from './components/list.vue';
29
 import ListVue from './components/list.vue';
28
 
30
 
29
 export default {
31
 export default {
30
   components: {
32
   components: {
31
-    'banner-box': BannerBox,
33
+    // 'banner-box': BannerBox,
32
     'rank-list': ListVue,
34
     'rank-list': ListVue,
33
   },
35
   },
34
   onShareAppMessage() {
36
   onShareAppMessage() {
41
   setup () {
43
   setup () {
42
     const { user } = useModel('user');
44
     const { user } = useModel('user');
43
     const current = ref(0);
45
     const current = ref(0);
46
+    const myRank = ref(0);
47
+
48
+    const rankDesc = computed(() => myRank.value > 0 ? `我的全国排名:第 ${myRank.value} 名` : '我的全国排名:暂未上榜')
49
+
50
+    watch(user, (person) => {
51
+      if (person.personId) {
52
+        getMyRank(person.personId).then(res => myRank.value = res);
53
+      }
54
+    }, { immediate: true });
44
 
55
 
45
     return {
56
     return {
46
       user,
57
       user,
58
+      rankDesc,
47
       current,
59
       current,
48
     }
60
     }
49
   },
61
   },
51
 </script>
63
 </script>
52
 
64
 
53
 <style lang="less">
65
 <style lang="less">
66
+.rank-page {
67
+  background: linear-gradient(#EE1C25, #FFFD00);
68
+
69
+  @rankHeadHeight: 280rpx;
70
+
71
+  .rank-head {
72
+    height: @rankHeadHeight;
73
+  }
74
+
75
+  .rank-body {
76
+    height: calc(100% - @rankHeadHeight);
77
+  }
78
+}
79
+
80
+.rank-mine {
81
+  position: absolute;
82
+  width: calc(100vw - 2em);
83
+  top: 180rpx;
84
+  left: 1em;
85
+  background: rgba(250, 244, 230, .9);
86
+  color: #333;
87
+  border-radius: 48rpx;
88
+  line-height: 78rpx;
89
+  box-sizing: border-box;
90
+  padding: 0 2em;
91
+}
92
+
54
 .rank-tab {
93
 .rank-tab {
55
   position: absolute;
94
   position: absolute;
56
   width: 60vw;
95
   width: 60vw;
57
-  top: 100rpx;
96
+  top: 60rpx;
58
   left: 20vw;
97
   left: 20vw;
59
 
98
 
60
-  background: rgba(251, 254, 154, 0.1);
61
-  color: #333;
62
-  border: 8px solid #A02923;
99
+  background: transparent;
100
+  color: rgba(250, 244, 230, 1);
101
+  border: 4rpx solid rgba(250, 244, 230, 1);
63
   border-radius: 48rpx;
102
   border-radius: 48rpx;
64
   box-sizing: border-box;
103
   box-sizing: border-box;
65
   text-align: center;
104
   text-align: center;
67
   overflow: hidden;
106
   overflow: hidden;
68
 
107
 
69
   .active {
108
   .active {
70
-    background: rgba(160, 41, 35, 1);
71
-    color: #fff;
109
+    background: rgba(250, 244, 230, .9);
110
+    color: #333;
72
   }
111
   }
73
 }
112
 }
74
 </style>
113
 </style>

+ 3
- 0
src/service/adSeq.js View File

1
+import request from "../utils/request";
2
+
3
+export const getSeq = () => request(`/api/wx/adSeq/1`);

+ 2
- 0
src/service/rank.js View File

1
 import request from "../utils/request";
1
 import request from "../utils/request";
2
 
2
 
3
 export const getRank = (params) => request('/api/wx/stRank', { params });
3
 export const getRank = (params) => request('/api/wx/stRank', { params });
4
+
5
+export const getMyRank = (personId) => request(`/api/wx/stRank/person/${personId}`);