integral-rank.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  1. <template>
  2. <view class="rank">
  3. <view class="rank_top">
  4. <view class="rank_bg">
  5. <view class="rank_title">奖学金排行榜</view>
  6. <view class="flexS rank_btn">
  7. <!-- <view @click="skipPage(0)">奖学金商城</view> -->
  8. <view @click="skipPage(1)">奖学金明细</view>
  9. </view>
  10. </view>
  11. <view class="person flexCC">
  12. <image :src="person.store.img" mode="" class="avatar" v-if="person.store"></image>
  13. <view class="person_title" v-if="person.store">{{ person.store.name }}</view>
  14. <view class="flexA person_rank">
  15. <view class="person_intr">
  16. <view>{{current==0?person.sort:person.yes_sort }}</view>
  17. <text>{{current==0?'个人总排名':'个人昨日排名'}}</text>
  18. </view>
  19. <view class="person_intr">
  20. <view v-if="current==0">{{person.integral?person.integral:0}}</view>
  21. <view v-else>{{person.yes_integral?person.yes_integral:0}}</view>
  22. <text>奖学金</text>
  23. </view>
  24. </view>
  25. </view>
  26. <view class="tabs">
  27. <u-tabs :list="list" :is-scroll="false" :current="current" @change="change" active-color="#FB231F">
  28. </u-tabs>
  29. </view>
  30. <view class="rank_intr">
  31. <view style="width: 15%;">排名</view>
  32. <view style="width: 15%;">头像</view>
  33. <view style="width: 50%;">昵称</view>
  34. <view>奖学金</view>
  35. </view>
  36. </view>
  37. <view class="rank_box">
  38. <scroll-view scroll-y="true" @scrolltolower="getMore">
  39. <view class="scroll_con">
  40. <view v-for="(item, idx) in rankList" :key="idx" class="flexS">
  41. <view style="width: 15%;text-align: center;" v-if="idx == 0 || idx == 1 || idx == 2">
  42. <image src="../../static/gold.png" v-if="idx == 0" class="rank_icon"></image>
  43. <image src="../../static/silver.png" v-if="idx == 1" class="rank_icon"></image>
  44. <image src="../../static/copper.png" v-if="idx == 2" class="rank_icon"></image>
  45. </view>
  46. <text style="width: 15%;font-size:32rpx;"
  47. v-if="idx != 0 && idx != 1 && idx != 2">{{ idx + 1 }}</text>
  48. <view style="width: 15%;text-align: center;">
  49. <image :src="item.img" class="user_avatar"></image>
  50. </view>
  51. <text style="width: 50%;font-size:32rpx;">{{ item.name | getName(10) }}</text>
  52. <text style="font-size:36rpx;color:#FB231F;">{{ item.integral }}</text>
  53. </view>
  54. </view>
  55. </scroll-view>
  56. </view>
  57. </view>
  58. </template>
  59. <script>
  60. import {
  61. integralRank,
  62. getIntegral
  63. } from '@/apis/shop.js';
  64. export default {
  65. data() {
  66. return {
  67. rankList: [],
  68. list: [{
  69. name: '总榜单'
  70. }, {
  71. name: '昨日榜单'
  72. }],
  73. current: 0,
  74. params: {
  75. page_index: 1,
  76. page_size: 15,
  77. type: 'all'
  78. },
  79. totalPage: 0,
  80. person: '', //个人信息
  81. exc_gifts: 0,
  82. };
  83. },
  84. onShow() {
  85. this.getIntegral();
  86. this.getRank();
  87. },
  88. methods: {
  89. //切换总榜单昨日榜单
  90. change(index) {
  91. this.current = index;
  92. this.params.type = index == 0 ? 'all' : 'yesterday';
  93. this.params.page_index = 1;
  94. this.rankList = [];
  95. this.getRank();
  96. this.goTop();
  97. },
  98. goTop() {
  99. // 一键回到顶部
  100. if (uni.pageScrollTo) {
  101. uni.pageScrollTo({
  102. scrollTop: 0
  103. });
  104. }
  105. },
  106. //获取个人排行
  107. getIntegral() {
  108. getIntegral().then(res => {
  109. if (res.code == 200) {
  110. this.person = res.data;
  111. this.exc_gifts = res.data.exc_gifts;
  112. } else {
  113. uni.showModal({
  114. content: res.msg || '获取数据失败',
  115. showCancel: false
  116. });
  117. }
  118. });
  119. },
  120. //跳转页面
  121. skipPage(type) {
  122. // if (type == 0) {
  123. // uni.showToast({
  124. // title: '暂未开启,敬请期待~',
  125. // icon: 'none'
  126. // });
  127. // return false;
  128. // }
  129. if (this.exc_gifts == 0 && type == 0) {
  130. uni.showToast({
  131. title: '暂未开启,敬请期待~',
  132. icon: 'none'
  133. });
  134. return false;
  135. }
  136. let url = '';
  137. url = type == 0 ? '../integral-store/integral-store?integral=' + this.person.store.integral :
  138. '../integral-detail/integral-detail';
  139. uni.navigateTo({
  140. url
  141. });
  142. },
  143. //获取排行榜
  144. getRank(isMore) {
  145. uni.showLoading({
  146. title: '加载中...'
  147. });
  148. let params = this.params;
  149. integralRank(params)
  150. .then(res => {
  151. if (res.code == 200) {
  152. this.rankList = isMore ? this.rankList.concat(res.data.list) : res.data.list;
  153. this.totalPage = Math.ceil(res.data.total / this.params.page_size);
  154. } else {
  155. uni.showModal({
  156. content: res.msg || '获取排名失败',
  157. showCancel: false
  158. });
  159. }
  160. uni.hideLoading();
  161. })
  162. .catch(err => {
  163. uni.hideLoading();
  164. });
  165. },
  166. getMore() {
  167. if (this.params.page_index >= this.totalPage) {
  168. uni.showToast({
  169. title: '没有更多啦~',
  170. icon: 'none'
  171. });
  172. return false;
  173. }
  174. this.params.page_index++;
  175. this.getRank(true);
  176. }
  177. }
  178. };
  179. </script>
  180. <style lang="scss" scoped>
  181. .rank {
  182. width: 100vw;
  183. height: 100vh;
  184. background: #f9f9fb;
  185. overflow: hidden;
  186. display: flex;
  187. flex-direction: column;
  188. .rank_top {
  189. width: 100%;
  190. .rank_bg {
  191. width: 100%;
  192. height: 458rpx;
  193. background: url(../../static/integral_bg.png) no-repeat;
  194. background-size: 100% 100%;
  195. .rank_title {
  196. font-size: 72rpx;
  197. font-weight: bold;
  198. color: #fff;
  199. padding: 30rpx 0 20rpx 30rpx;
  200. }
  201. .rank_btn {
  202. width: 100%;
  203. margin-left: 30rpx;
  204. view {
  205. width: 200rpx;
  206. height: 64rpx;
  207. color: #fff;
  208. font-size: 32rpx;
  209. border-radius: 32rpx;
  210. display: flex;
  211. justify-content: center;
  212. align-items: center;
  213. }
  214. view:first-child {
  215. background: linear-gradient(93deg, #ffa600 0%, #fcbc05 100%);
  216. margin-right: 20rpx;
  217. }
  218. view:last-child {
  219. background: rgba(255, 255, 255, 0.3);
  220. }
  221. }
  222. }
  223. .person {
  224. width: 690rpx;
  225. margin: -130rpx auto 0;
  226. height: 294rpx;
  227. background: #fff;
  228. border-radius: 24rpx;
  229. .person_title {
  230. font-size: 32rpx;
  231. padding: 20rpx 0 30rpx;
  232. font-weight: bold;
  233. }
  234. .avatar {
  235. width: 134rpx;
  236. height: 134rpx;
  237. margin-top: -125rpx;
  238. border-radius: 50%;
  239. border: 4rpx solid #fff;
  240. }
  241. .person_rank {
  242. width: 100%;
  243. .person_intr {
  244. text-align: center;
  245. view {
  246. font-size: 52rpx;
  247. font-weight: bold;
  248. }
  249. text {
  250. font-size: 28rpx;
  251. color: #999;
  252. }
  253. }
  254. }
  255. }
  256. .tabs {
  257. border-bottom: 2rpx solid #eee;
  258. margin-top: 30rpx;
  259. }
  260. .rank_intr {
  261. width: 100%;
  262. background: #fff;
  263. height: 92rpx;
  264. line-height: 92rpx;
  265. display: flex;
  266. align-items: center;
  267. view {
  268. text-align: center;
  269. font-size: 32rpx;
  270. }
  271. }
  272. }
  273. .rank_box {
  274. // flex: 1;
  275. height: 45vh;
  276. background: #f00;
  277. width: 100%;
  278. background: #fff;
  279. scroll-view {
  280. width: 100%;
  281. height: 100%;
  282. }
  283. .scroll_con {
  284. padding: 10rpx 0 100rpx 0;
  285. .rank_icon {
  286. width: 60rpx;
  287. height: 47rpx;
  288. }
  289. .user_avatar {
  290. width: 68rpx;
  291. height: 68rpx;
  292. border-radius: 50%;
  293. flex-shrink: 0;
  294. }
  295. >view {
  296. width: 100%;
  297. margin-top: 10rpx;
  298. text {
  299. text-align: center;
  300. }
  301. }
  302. }
  303. }
  304. }
  305. </style>