joinnum.vue 11 KB

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