rank.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. <template>
  2. <div class="contentBody">
  3. <van-nav-bar title="排行榜" left-arrow @click-left="onClickLeft" />
  4. <van-tabs :active="active" @click="rootChange">
  5. <!-- 根目录 -->
  6. <van-tab
  7. v-for="(item, index) in rankList"
  8. :key="index"
  9. :title="item.name"
  10. >
  11. <van-list
  12. v-model="loading"
  13. :finished="finished"
  14. finished-text="没有更多了"
  15. @load="onLoad"
  16. >
  17. <van-cell>
  18. <div slot="default" class="contentItemTop">
  19. <div
  20. :class="{
  21. contentItemTopRowChild: true,
  22. contentItemTopRowOne: index === 0,
  23. contentItemTopRowTwo: index === 1,
  24. contentItemTopRowThree: index === 2
  25. }"
  26. v-for="(item, index) in rankListTopThree"
  27. :key="index"
  28. >
  29. <div class="contentItemTopRowChildImg">
  30. <van-image
  31. class="userHeaderImg"
  32. width="100%"
  33. height="100%"
  34. fit="cover"
  35. round
  36. :src="item.src || maleAvatar"
  37. :show-error="true"
  38. :error-icon="maleAvatar"
  39. />
  40. <div class="contentItemTopRowChildImgNum">
  41. {{ index + 1 }}
  42. </div>
  43. </div>
  44. <div class="contentItemTopRowChildName">
  45. {{ item.name || "userName" + (index + 1) }}
  46. </div>
  47. <span class="contentItemTopRowChildPoints">
  48. {{ item.ponits || "undefind" }}
  49. </span>
  50. <span class="contentItemTopRowChildSteps">Steps</span>
  51. </div>
  52. </div>
  53. </van-cell>
  54. <van-cell v-for="(item, index) in rankListOthers" :key="index">
  55. <div slot="default" class="contentItemDiv">
  56. <div class="contentBox">
  57. <div class="headerContent">
  58. <van-image
  59. class="userHeaderImg"
  60. fit="cover"
  61. round
  62. :src="maleAvatar"
  63. :show-error="true"
  64. :error-icon="maleAvatar"
  65. />
  66. <div>{{ item.name || "未知" }}</div>
  67. </div>
  68. <div class="userPonits">
  69. {{ item.points || "undefind" }}
  70. <span>Steps</span>
  71. </div>
  72. </div>
  73. </div>
  74. </van-cell>
  75. </van-list>
  76. </van-tab>
  77. </van-tabs>
  78. </div>
  79. </template>
  80. <script>
  81. import maleAvatar from "@/assets/image/maleAvatar.jpg";
  82. import { mapState } from "vuex";
  83. export default {
  84. name: "collection",
  85. components: {},
  86. data() {
  87. return {
  88. maleAvatar,
  89. active: 0,
  90. rankList: [{ name: "魁首榜" }, { name: "跃进榜" }, { name: "失格榜" }],
  91. loading: false,
  92. finished: false,
  93. rankListTopThree: [{}, {}, {}], // 前三名
  94. rankListOthers: []
  95. };
  96. },
  97. created() {
  98. this.getRankListFun();
  99. },
  100. computed: {
  101. ...mapState({
  102. user: state => state.user
  103. })
  104. },
  105. methods: {
  106. // 查询:排行榜信息
  107. getRankListFun() {
  108. this.$store.commit("toggleLoading", true);
  109. let path = {
  110. userName: this.user.userInfo.userName
  111. };
  112. this.$_http
  113. .get(this.$pathParams(this.$_API.JTXT_GET_USER_FAVORITES, path))
  114. .then(res => {
  115. res.data.materials.forEach((item, index) => {
  116. this.getFavoritesItemDeitalFun(
  117. item,
  118. index,
  119. index + 1 === res.data.materials
  120. );
  121. });
  122. })
  123. .catch(() => {
  124. this.$store.commit("toggleLoading", false);
  125. });
  126. },
  127. // 查询:排行榜单条数据ID对应的详情
  128. getFavoritesItemDeitalFun(item, index, isLast) {
  129. // this.$_http
  130. // .get(this.$pathParams(this.$_API.接口名字, path))
  131. // .then(res => {
  132. if (index < 3) {
  133. // this.rankListTopThree[index] = res.data;
  134. this.rankListTopThree[index] = item;
  135. } else {
  136. // this.rankListOthers.push(res.data);
  137. this.rankListOthers.push(item);
  138. }
  139. if (isLast) {
  140. console.log(
  141. "--collection--",
  142. this.rankListTopThree,
  143. this.rankListOthers
  144. );
  145. this.finished = true;
  146. this.$store.commit("toggleLoading", false);
  147. }
  148. // })
  149. // .catch(() => {
  150. // this.$store.commit("toggleLoading", false);
  151. // });
  152. },
  153. // 操作:返回
  154. onClickLeft() {
  155. this.$router.back();
  156. },
  157. onLoad() {},
  158. rootChange() {}
  159. }
  160. };
  161. </script>
  162. <style lang="scss" scoped>
  163. .contentBody {
  164. background-color: #fff;
  165. .contentItemTop {
  166. display: flex;
  167. justify-content: space-between;
  168. align-items: flex-end;
  169. .contentItemTopRowChild {
  170. display: flex;
  171. flex-direction: column;
  172. align-items: center;
  173. max-width: 30%;
  174. .contentItemTopRowChildImg {
  175. width: 3rem;
  176. height: 3rem;
  177. position: relative;
  178. .contentItemTopRowChildImgNum {
  179. width: 1rem;
  180. height: 1rem;
  181. border-radius: 100%;
  182. color: #fff;
  183. font-size: 0.7rem;
  184. font-weight: bold;
  185. text-align: center;
  186. line-height: 1rem;
  187. position: absolute;
  188. left: 0;
  189. right: 0;
  190. bottom: -0.5rem;
  191. margin: auto;
  192. }
  193. }
  194. .contentItemTopRowChildName {
  195. margin-top: 0.5rem;
  196. font-size: 0.65rem;
  197. word-break: break-all;
  198. word-wrap: break-word;
  199. font-weight: bold;
  200. text-align: center;
  201. color: #333;
  202. }
  203. .contentItemTopRowChildPoints {
  204. color: #0088e9;
  205. font-size: 0.65rem;
  206. margin-top: 0.25rem;
  207. }
  208. .contentItemTopRowChildSteps {
  209. font-size: 0.6rem;
  210. color: #dfdfe1;
  211. margin-top: -0.25rem;
  212. }
  213. }
  214. .contentItemTopRowOne {
  215. .contentItemTopRowChildImg {
  216. width: 4rem;
  217. height: 4rem;
  218. .contentItemTopRowChildImgNum {
  219. background-color: #f6d403;
  220. font-size: 0.8rem;
  221. }
  222. }
  223. }
  224. .contentItemTopRowTwo {
  225. order: -1;
  226. .contentItemTopRowChildImg .contentItemTopRowChildImgNum {
  227. background-color: #f46d66;
  228. }
  229. }
  230. .contentItemTopRowThree {
  231. .contentItemTopRowChildImg .contentItemTopRowChildImgNum {
  232. background-color: #69c9bc;
  233. }
  234. }
  235. }
  236. .contentItemDiv {
  237. .userHeaderImg {
  238. width: 2.5rem;
  239. height: 2.5rem;
  240. margin-right: 0.5rem;
  241. }
  242. .contentBox {
  243. display: flex;
  244. justify-content: space-between;
  245. align-items: center;
  246. }
  247. .headerContent {
  248. display: flex;
  249. justify-content: space-between;
  250. align-items: center;
  251. }
  252. .userPonits {
  253. font-size: 0.6rem;
  254. color: #dfdfe1;
  255. span {
  256. margin-left: 0.25rem;
  257. }
  258. }
  259. }
  260. }
  261. </style>