123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263 |
- <template>
- <div class="contentBody">
- <van-nav-bar title="排行榜" left-arrow @click-left="onClickLeft" />
- <van-tabs :active="active" @click="rootChange">
- <!-- 根目录 -->
- <van-tab
- v-for="(item, index) in rankList"
- :key="index"
- :title="item.name"
- >
- <van-list
- v-model="loading"
- :finished="finished"
- finished-text="没有更多了"
- @load="onLoad"
- >
- <van-cell>
- <div slot="default" class="contentItemTop">
- <div
- :class="{
- contentItemTopRowChild: true,
- contentItemTopRowOne: index === 0,
- contentItemTopRowTwo: index === 1,
- contentItemTopRowThree: index === 2
- }"
- v-for="(item, index) in rankListTopThree"
- :key="index"
- >
- <div class="contentItemTopRowChildImg">
- <van-image
- class="userHeaderImg"
- width="100%"
- height="100%"
- fit="cover"
- round
- :src="item.src || maleAvatar"
- :show-error="true"
- :error-icon="maleAvatar"
- />
- <div class="contentItemTopRowChildImgNum">
- {{ index + 1 }}
- </div>
- </div>
- <div class="contentItemTopRowChildName">
- {{ item.name || "userName" + (index + 1) }}
- </div>
- <span class="contentItemTopRowChildPoints">
- {{ item.ponits || "undefind" }}
- </span>
- <span class="contentItemTopRowChildSteps">Steps</span>
- </div>
- </div>
- </van-cell>
- <van-cell v-for="(item, index) in rankListOthers" :key="index">
- <div slot="default" class="contentItemDiv">
- <div class="contentBox">
- <div class="headerContent">
- <van-image
- class="userHeaderImg"
- fit="cover"
- round
- :src="maleAvatar"
- :show-error="true"
- :error-icon="maleAvatar"
- />
- <div>{{ item.name || "未知" }}</div>
- </div>
- <div class="userPonits">
- {{ item.points || "undefind" }}
- <span>Steps</span>
- </div>
- </div>
- </div>
- </van-cell>
- </van-list>
- </van-tab>
- </van-tabs>
- </div>
- </template>
- <script>
- import maleAvatar from "@/assets/image/maleAvatar.jpg";
- import { mapState } from "vuex";
- export default {
- name: "collection",
- components: {},
- data() {
- return {
- maleAvatar,
- active: 0,
- rankList: [{ name: "魁首榜" }, { name: "跃进榜" }, { name: "失格榜" }],
- loading: false,
- finished: false,
- rankListTopThree: [{}, {}, {}], // 前三名
- rankListOthers: []
- };
- },
- created() {
- this.getRankListFun();
- },
- computed: {
- ...mapState({
- user: state => state.user
- })
- },
- methods: {
- // 查询:排行榜信息
- getRankListFun() {
- this.$store.commit("toggleLoading", true);
- let path = {
- userName: this.user.userInfo.userName
- };
- this.$_http
- .get(this.$pathParams(this.$_API.JTXT_GET_USER_FAVORITES, path))
- .then(res => {
- res.data.materials.forEach((item, index) => {
- this.getFavoritesItemDeitalFun(
- item,
- index,
- index + 1 === res.data.materials
- );
- });
- })
- .catch(() => {
- this.$store.commit("toggleLoading", false);
- });
- },
- // 查询:排行榜单条数据ID对应的详情
- getFavoritesItemDeitalFun(item, index, isLast) {
- // this.$_http
- // .get(this.$pathParams(this.$_API.接口名字, path))
- // .then(res => {
- if (index < 3) {
- // this.rankListTopThree[index] = res.data;
- this.rankListTopThree[index] = item;
- } else {
- // this.rankListOthers.push(res.data);
- this.rankListOthers.push(item);
- }
- if (isLast) {
- console.log(
- "--collection--",
- this.rankListTopThree,
- this.rankListOthers
- );
- this.finished = true;
- this.$store.commit("toggleLoading", false);
- }
- // })
- // .catch(() => {
- // this.$store.commit("toggleLoading", false);
- // });
- },
- // 操作:返回
- onClickLeft() {
- this.$router.back();
- },
- onLoad() {},
- rootChange() {}
- }
- };
- </script>
- <style lang="scss" scoped>
- .contentBody {
- background-color: #fff;
- .contentItemTop {
- display: flex;
- justify-content: space-between;
- align-items: flex-end;
- .contentItemTopRowChild {
- display: flex;
- flex-direction: column;
- align-items: center;
- max-width: 30%;
- .contentItemTopRowChildImg {
- width: 3rem;
- height: 3rem;
- position: relative;
- .contentItemTopRowChildImgNum {
- width: 1rem;
- height: 1rem;
- border-radius: 100%;
- color: #fff;
- font-size: 0.7rem;
- font-weight: bold;
- text-align: center;
- line-height: 1rem;
- position: absolute;
- left: 0;
- right: 0;
- bottom: -0.5rem;
- margin: auto;
- }
- }
- .contentItemTopRowChildName {
- margin-top: 0.5rem;
- font-size: 0.65rem;
- word-break: break-all;
- word-wrap: break-word;
- font-weight: bold;
- text-align: center;
- color: #333;
- }
- .contentItemTopRowChildPoints {
- color: #0088e9;
- font-size: 0.65rem;
- margin-top: 0.25rem;
- }
- .contentItemTopRowChildSteps {
- font-size: 0.6rem;
- color: #dfdfe1;
- margin-top: -0.25rem;
- }
- }
- .contentItemTopRowOne {
- .contentItemTopRowChildImg {
- width: 4rem;
- height: 4rem;
- .contentItemTopRowChildImgNum {
- background-color: #f6d403;
- font-size: 0.8rem;
- }
- }
- }
- .contentItemTopRowTwo {
- order: -1;
- .contentItemTopRowChildImg .contentItemTopRowChildImgNum {
- background-color: #f46d66;
- }
- }
- .contentItemTopRowThree {
- .contentItemTopRowChildImg .contentItemTopRowChildImgNum {
- background-color: #69c9bc;
- }
- }
- }
- .contentItemDiv {
- .userHeaderImg {
- width: 2.5rem;
- height: 2.5rem;
- margin-right: 0.5rem;
- }
- .contentBox {
- display: flex;
- justify-content: space-between;
- align-items: center;
- }
- .headerContent {
- display: flex;
- justify-content: space-between;
- align-items: center;
- }
- .userPonits {
- font-size: 0.6rem;
- color: #dfdfe1;
- span {
- margin-left: 0.25rem;
- }
- }
- }
- }
- </style>
|