joinnum.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341
  1. <template>
  2. <view class="joinnum" @tap="cancleChoose">
  3. <custom-nav :title="pageTitle"></custom-nav>
  4. <view class="content">
  5. <view class="top">
  6. <image src="https://api.jiuweiyun.cn/public/uploads/weapp/icon/logo.png" mode="scaleToFill"></image>
  7. <view class="info">
  8. <view class="season">{{ seasonNameList[seasonNameList.length - targetSeason] }}</view>
  9. <view class="total" v-if="userServerInfo.type === 3">
  10. <text class="cuIcon-friendfill" style="color: #FA6342; margin-right: 5px;"></text>
  11. <text style="color: #FA6342; margin-right: 15px;">{{ totalTop + totalSuper }}</text>
  12. <text>参赛总人数</text>
  13. </view>
  14. </view>
  15. <view class="choose" @tap.stop="chooseSeason">{{ `大卫博士学位争霸赛第${targetSeason}季` }}&nbsp;<text class="cuIcon-right"></text></view>
  16. <scroll-view class="down" scroll-y :class="down ? 'show' : 'hide'">
  17. <view class="item"
  18. v-for="(item, index) in seasonNameList"
  19. :key="index"
  20. @tap="switchSeason(index)">{{ seasonNameList.length - targetSeason === index ? '' : item }}
  21. <text :style="{ display: seasonNameList.length - targetSeason === index ? 'none' : 'flex' }" class="cuIcon-right"></text></view>
  22. </scroll-view>
  23. </view>
  24. <view class="switch" v-if="userServerInfo.type === 3">
  25. <text :class="index === 0 ? 'active' : ''" @tap="switchTab(0)">我的</text>
  26. <text :class="index === 1 ? 'active' : ''" @tap="switchTab(1)">全部</text>
  27. </view>
  28. <view class="bubble" v-if="userServerInfo.type === 3">
  29. <view class="row">
  30. <view class="left"><text>{{ index === 0 ? '服务' : '赛季'}}</text>
  31. 参赛总人数:<text style="color: #FA6342;">{{ index === 0 ? serverTop + serverSuper + crownNum : totalTop + totalSuper }}人</text></view>
  32. <view class="right" v-if="index === 0">
  33. 批发商:<text style="color: #FA6342;">{{ crownNum }}人</text></view>
  34. </view>
  35. <view class="line"></view>
  36. <view class="row">
  37. <view class="left">经销商:<text style="color: #FA6342;">{{ index === 0 ? serverTop : totalTop }}人</text></view>
  38. <view class="right">销售员:<text style="color: #FA6342;">{{ index === 0 ? serverSuper : totalSuper }}人</text></view>
  39. </view>
  40. </view>
  41. <view class="bubble" v-else>
  42. <view class="row">
  43. <view class="left">团队参赛总人数:<text style="color: #FA6342;">{{ crownTop + crownSuper }}人</text></view>
  44. </view>
  45. <view class="line"></view>
  46. <view class="row">
  47. <view class="left">经销商:<text style="color: #FA6342;">{{ crownTop }}人</text></view>
  48. <view class="right">销售员:<text style="color: #FA6342;">{{ crownSuper }}人</text></view>
  49. </view>
  50. </view>
  51. <view class="list">
  52. <scroll-view scroll-y :style="{ height: scrollViewHeight + 'px' }" @scrolltolower="scrolltolower">
  53. <ranking-item v-for="(item, index) in list" :key="item.id" :index="index+1" :item="item" :type="type"></ranking-item>
  54. <custom-reach-bottom v-if="list.length" :nomore="nomore"></custom-reach-bottom>
  55. </scroll-view>
  56. </view>
  57. </view>
  58. </view>
  59. </template>
  60. <script>
  61. import { api_getTotalJoinNum, api_getTeamJoinNum, api_todayPerson, api_todayTeam } from '../../api.js'
  62. import rankingItem from '../../components/ranking-item.vue'
  63. export default {
  64. components: {
  65. rankingItem
  66. },
  67. data() {
  68. return {
  69. pageTitle: '参赛人数',
  70. totalTop: 0, //赛季总参赛经销商人数
  71. totalSuper: 0, //赛季总参赛销售员人数
  72. crownTop: 0, //批发商的经销商人数
  73. crownSuper: 0, //批发商的销售员人数
  74. crownNum: 0, //客服团队的批发商数量
  75. serverTop: 0, //客服团队的经销商数量
  76. serverSuper: 0, //客服团队的销售员数量
  77. index: 0, //客服查看参赛数据时,active 下标
  78. list: [],
  79. scrollViewHeight: 0, //scrollview 高
  80. type: 2, //排行榜类型
  81. page: 1, //页数
  82. nomore: false, //没得更多了
  83. requesting: false, //是否正在进行网络请求
  84. targetSeason: 0, //要切换的目标赛季届数
  85. seasonNameList: [], //历史赛季名称
  86. down: false,
  87. };
  88. },
  89. computed: {
  90. userServerInfo () {
  91. return this.$store.state.userServerInfo
  92. }
  93. },
  94. methods: {
  95. switchSeason (index) { //切换赛季
  96. this.page = 1 //恢复页码
  97. this.nomore = false //恢复没得更多了
  98. uni.showLoading({ title: '加载中', mask: true }) //显示loading
  99. this.targetSeason = this.userServerInfo.season - index
  100. this.initData(this.targetSeason)
  101. },
  102. switchTab(index) { //客服点击切换时
  103. uni.showLoading({ title: '加载中', mask: true }) //显示loading
  104. this.index = index
  105. this.page = 1 //恢复页码
  106. this.nomore = false //恢复没得更多了
  107. if (index) {
  108. this.type = 0
  109. this.getScrollViewList(api_todayPerson) //切换到全部(个人榜)
  110. } else {
  111. this.type = 2
  112. this.getScrollViewList(api_todayTeam) //切换到我的(团队榜)
  113. }
  114. },
  115. getScrollViewList (api) { //获取scrollview 里的诗句
  116. this.$ajax.get(`${api}?page=${this.page}&season=${this.targetSeason}`).then(([ , { data: res }]) => {
  117. res.data.list.length < 20 ? this.nomore = true : '' //如果返回的数据长度小于20,说明没得更多了
  118. this.list = this.list = res.data.list
  119. this.$hideLoading() //异步操作结束,停止 loading
  120. })
  121. },
  122. chooseSeason () { //点击切换赛季
  123. this.down = !this.down
  124. },
  125. cancleChoose () { //收起下拉效果
  126. this.down = false
  127. },
  128. scrolltolower () {
  129. if (!this.requesting && !this.nomore) { //防抖
  130. this.requesting = true
  131. this.$ajax.get(`${ this.index ? api_todayPerson : api_todayTeam }?page=${this.page + 1}&season=${this.targetSeason}`).then(([ , { data: res }]) => {
  132. res.data.list.length < 20 ? this.nomore = true : '' //如果返回的数据长度小于20,说明没得更多了
  133. this.requesting = false
  134. this.page ++
  135. this.list = [...this.list, ...res.data.list]
  136. }, () => {
  137. this.requesting = false
  138. })
  139. }
  140. },
  141. async initData (season) {
  142. if (this.userServerInfo.type === 2) { //如果是批发商查看参赛人数
  143. const [ , { data: res }] = await this.$ajax.get(`${api_getTeamJoinNum}?season=${season}`) //获取批发商的团队数据
  144. this.crownTop = res.data.top_num
  145. this.crownSuper = res.data.super_num
  146. this.getScrollViewList(api_todayTeam) //获取批发商的团队榜列表
  147. } else if (this.userServerInfo.type === 3) { //如果是客服查看参赛人数
  148. const [ , { data: res1 }] = await this.$ajax.get(`${api_getTotalJoinNum}?season=${season}`) //获取赛季总参赛人数
  149. this.totalTop = res1.data.top_num
  150. this.totalSuper = res1.data.super_num
  151. const [ , { data: res2 }] = await this.$ajax.get(`${api_getTeamJoinNum}?season=${season}`) //获取客服的团队数据
  152. this.crownNum = res2.data.crown_num
  153. this.serverTop = res2.data.top_num
  154. this.serverSuper = res2.data.super_num
  155. this.getScrollViewList(this.index ? api_todayPerson : api_todayTeam) //获取客服的团队榜列表
  156. }
  157. }
  158. },
  159. async created() {
  160. uni.showLoading({ title: '加载中', mask: true }) //显示loading
  161. this.$scrollViewHeight('.list') //设置页面内 scroll view 的高度
  162. this.targetSeason = this.$store.state.userServerInfo.season //获取当前届数
  163. this.seasonNameList = new Array(this.targetSeason - 19 + 1).fill(0) //将下拉选择里面的数据(历史赛季名称)放在数组里
  164. this.seasonNameList.forEach((e, i) => {
  165. this.seasonNameList[i] = `大卫博士学位争霸赛第${this.$store.state.userServerInfo.season - i}季`
  166. })
  167. this.initData(this.targetSeason)
  168. }
  169. }
  170. </script>
  171. <style lang="scss" scoped>
  172. .joinnum {
  173. @include page();
  174. .content {
  175. border-top: $custom-nav-borderbot-height solid $custom-nav-borderbot-color;
  176. background: $custom-nav-borderbot-color;
  177. display: flex;
  178. flex-direction: column;
  179. align-items: center;
  180. .top {
  181. width: 100%;
  182. height: 140rpx;
  183. margin-bottom: 10rpx;
  184. background: #FFFFFF;
  185. box-sizing: border-box;
  186. padding: 30rpx;
  187. display: flex;
  188. align-items: center;
  189. position: relative;
  190. image {
  191. height: 100%;
  192. width: 80rpx;
  193. }
  194. .info {
  195. flex: 1;
  196. height: 100%;
  197. margin-left: 12rpx;
  198. display: flex;
  199. flex-direction: column;
  200. position: relative;
  201. .season {
  202. color: #2A2A2A;
  203. font-size: 26rpx;
  204. }
  205. .total {
  206. margin-top: 20rpx;
  207. height: 30rpx;
  208. display: flex;
  209. font-size: 24rpx;
  210. align-items: center;
  211. }
  212. }
  213. .choose {
  214. color: #999999;
  215. font-size: 26rpx;
  216. }
  217. .down {
  218. position: absolute;
  219. width: 750rpx;
  220. height: 0;
  221. top: 140rpx;
  222. right: 0rpx;
  223. background: #FFFFFF;
  224. box-shadow:0px 1px 3px 0px rgba(0, 0, 0, 0.2);
  225. z-index: 1;
  226. border-bottom: 100vh solid;
  227. border-color: transparent;
  228. box-sizing: content-box;
  229. &.show {
  230. animation: down-show .2s;
  231. animation-fill-mode: forwards;
  232. border-bottom-width: 100vh;
  233. }
  234. &.hide {
  235. animation: down-hide .2s;
  236. animation-fill-mode: forwards;
  237. border-bottom-width: 0rpx;
  238. }
  239. .item {
  240. line-height: 80rpx;
  241. box-sizing: border-box;
  242. padding: 0 30rpx;
  243. border-bottom: 1rpx solid #EEEEEE;
  244. display: flex;
  245. justify-content: space-between;
  246. background: #FFFFFF;
  247. }
  248. }
  249. }
  250. .switch {
  251. width: 100%;
  252. height: 60rpx;
  253. background: #FFFFFF;
  254. display: flex;
  255. justify-content: space-around;
  256. align-items: center;
  257. margin-bottom: 10rpx;
  258. text {
  259. font-size: 32rpx;
  260. color: #999999;
  261. height: 100%;
  262. line-height: 60rpx;
  263. text-align: center;
  264. flex: 1;
  265. position: relative;
  266. &.active {
  267. color: #FA6342;
  268. }
  269. &.active::after {
  270. content: '';
  271. position: absolute;
  272. width: 100rpx;
  273. height: 4rpx;
  274. background: #FA6342;
  275. bottom: 0;
  276. left: 50%;
  277. transform: translateX(-50%);
  278. }
  279. }
  280. }
  281. .bubble {
  282. width: 100%;
  283. box-sizing: border-box;
  284. padding: 0 30rpx;
  285. margin-bottom: 10rpx;
  286. background: #FFFFFF;
  287. .row {
  288. height: 60rpx;
  289. display: flex;
  290. .left, .right {
  291. box-sizing: border-box;
  292. flex: 1;
  293. height: 100%;
  294. float: left;
  295. display: flex;
  296. align-items: center;
  297. justify-content: center;
  298. &.right {
  299. border-left: 1rpx solid #EEEEEE;
  300. }
  301. }
  302. }
  303. .line {
  304. height: 1rpx;
  305. background: #EEEEEE;
  306. }
  307. }
  308. .list {
  309. flex: 1;
  310. width: 100%;
  311. background: #FFFFFF;
  312. }
  313. }
  314. }
  315. @keyframes down-show {
  316. 0% {
  317. height: 0;
  318. background: rgba(0, 0, 0, 0);
  319. }
  320. 100% {
  321. height: 260rpx;
  322. background: rgba(0, 0, 0, .6);
  323. }
  324. }
  325. @keyframes down-hide {
  326. 0% {
  327. height: 260rpx;
  328. background: rgba(0, 0, 0, .6);
  329. }
  330. 100% {
  331. height: 0;
  332. background: rgba(0, 0, 0, 0);
  333. }
  334. }
  335. </style>