grade.vue 6.79 KB
Newer Older
xulili's avatar
xulili committed
1 2 3 4 5 6 7 8 9 10 11 12
<template>
  <div class="grade-status">
    <div class="nav">
      <van-icon
        name="arrow-left"
        size="20"
        class="nav-left"
        @click="$router.go(-1)"
      />
      <span class="nav-title">森林状态</span>
    </div>
    <div class="forest-content">
xulili's avatar
xulili committed
13
      <div class="forest-level">Lv.{{ userLevel }}{{ levelDes }}</div>
xulili's avatar
xulili committed
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
      <div v-for="(item, key, index) in diffrentMap" :key="index">
        <div>
          <div class="nums">
            <span>距离下一级</span>
            <span v-if="key === 'team'">团队用户</span>
            <span v-else-if="key === 'recommend'">直推用户</span>
            <span v-else></span>
            <span>还需增加</span>
            <span v-for="(d, i) in item" :key="i">
              {{ d.value }}
              {{ d.label }}
            </span>
          </div>
        </div>
      </div>

      <!-- <div class="level-progress" v-if="userLevel!=7"> -->
leiqingsong's avatar
leiqingsong committed
31
      <div class="level-progress">
xulili's avatar
xulili committed
32
        <div class="level-num">Lv.{{ userLevel }}</div>
xulili's avatar
xulili committed
33
        <van-progress :percentage="perenct * 100" />
xulili's avatar
xulili committed
34
        <div class="level-num">Lv.{{ nextLevel }}</div>
leiqingsong's avatar
leiqingsong committed
35 36
      </div>
      <div class="relegation">保级还需增加¥{{ relegationNum }} 业绩</div>
xulili's avatar
xulili committed
37 38
    </div>
    <div class="forest-list">
leiqingsong's avatar
leiqingsong committed
39 40 41 42 43 44 45 46 47 48 49
      <div class="forest-item" v-for="(item, index) in list" :key="index">
        <span class="forest-item-num">{{ item.num }}</span>
        <div class="forest-item-label">
          <span>{{ item.label }}</span>
          <van-icon
            v-if="item.hasArrow"
            name="arrow"
            size="16"
            class="nav-left"
            @click="handleUrl(item.urlName)"
          />
xulili's avatar
xulili committed
50
        </div>
leiqingsong's avatar
leiqingsong committed
51
      </div>
xulili's avatar
xulili committed
52 53 54 55 56
    </div>
  </div>
</template>

<script>
xulili's avatar
xulili committed
57
import { getForestStatus } from "@/api/grade";
xulili's avatar
xulili committed
58
import { getLevelDes, getNextLevel, diffrentOflevel } from "@/config/grade";
xulili's avatar
xulili committed
59 60 61 62
export default {
  name: "grade",
  data() {
    return {
xulili's avatar
xulili committed
63 64
      userLevel: "",
      levelDes: "白银树",
leiqingsong's avatar
leiqingsong committed
65 66
      directpush: "XXX",
      relegationNum: "21,141",
xulili's avatar
xulili committed
67 68
      currentLevel: "",
      nextLevel: "",
xulili's avatar
xulili committed
69 70 71
      perenct: 0,
      diffrentMap: {},
      type: ["amount", "recommend", "team"],
leiqingsong's avatar
leiqingsong committed
72 73 74 75 76
      list: [
        {
          num: 14,
          label: "团队总人数",
          hasArrow: true,
xulili's avatar
xulili committed
77 78
          urlName: "LeagueNums",
          field: "teamUserCount"
leiqingsong's avatar
leiqingsong committed
79 80 81 82
        },
        {
          num: 12,
          label: "我的直推",
xulili's avatar
xulili committed
83
          hasArrow: true,
xulili's avatar
xulili committed
84
          urlName: "MyStatus",
xulili's avatar
xulili committed
85
          field: "recommendUserCount"
leiqingsong's avatar
leiqingsong committed
86 87 88 89
        },
        {
          num: 61859,
          label: "团队累计总业绩",
xulili's avatar
xulili committed
90 91
          hasArrow: false,
          field: "teamCountDouble"
leiqingsong's avatar
leiqingsong committed
92 93 94 95
        },
        {
          num: 11256,
          label: "团队当月新增业绩",
xulili's avatar
xulili committed
96 97
          hasArrow: false,
          field: "teamNowCount"
leiqingsong's avatar
leiqingsong committed
98
        }
xulili's avatar
xulili committed
99 100 101
      ]
    };
  },
xulili's avatar
xulili committed
102
  mounted() {
xulili's avatar
xulili committed
103
    this.getstatus();
xulili's avatar
xulili committed
104
  },
xulili's avatar
xulili committed
105
  methods: {
leiqingsong's avatar
leiqingsong committed
106 107
    handleUrl(urlName) {
      this.$router.push({ name: urlName });
xulili's avatar
xulili committed
108 109 110 111 112 113 114 115 116 117 118 119 120 121
    },
    getstatus() {
      const userId = 13933770749;
      const _this = this;
      getForestStatus(userId).then(res => {
        if (res.code === 0) {
          let resData = res.data;
          _this.handleData(resData);
        } else {
          _this.$toast.fail(res.msg);
        }
      });
    },
    handleData(data) {
xulili's avatar
xulili committed
122
      this.perenct = data.perenct;
xulili's avatar
xulili committed
123 124 125 126 127 128 129
      this.userLevel = data.userLevel;
      this.levelDes = getLevelDes(data.userLevel);
      let nextLevelObj = getNextLevel(data.userLevel);
      if (!nextLevelObj.isHighest) {
        this.nextLevel = nextLevelObj.nextLevel;
      }
      this.list.forEach(v => {
xulili's avatar
xulili committed
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148
        v.num = data[v["field"]];
      });
      this.diffrentMap = [];
      if (data.userLevel < 7) {
        let diffrentMap = diffrentOflevel[data.userLevel];
        let desObj = {};
        if (diffrentMap) {
          diffrentMap.forEach(v => {
            v.value = data.differenceMap[v.field];
            if (desObj[v.type]) {
              desObj[v.type].push(v);
            } else {
              desObj[v.type] = [];
              desObj[v.type].push(v);
            }
          });
          this.diffrentMap = desObj;
        }
      }
xulili's avatar
xulili committed
149 150 151 152 153 154
    }
  }
};
</script>

<style lang="scss" scoped>
leiqingsong's avatar
leiqingsong committed
155 156
$white: #ffffff;
.grade-status {
xulili's avatar
xulili committed
157 158 159 160 161
  width: 100%;
  height: 298px;
  background-image: url("../assets/images/森林状态.png");
  background-size: cover;
  .nav {
leiqingsong's avatar
leiqingsong committed
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
    height: 46px;
    color: #fff;
    .nav-left {
      position: absolute;
      top: 0;
      bottom: 0;
      width: 52px;
      height: 100%;
      line-height: 46px;
      text-align: center;
    }
    .nav-title {
      max-width: 60%;
      margin: 0 auto;
      font-weight: bold;
      font-size: 16px;
    }
xulili's avatar
xulili committed
183
  }
leiqingsong's avatar
leiqingsong committed
184
  .forest-content {
xulili's avatar
xulili committed
185 186
    text-align: center;
    padding-top: 25px;
leiqingsong's avatar
leiqingsong committed
187 188 189 190 191
    .nums {
      font-size: 14px;
      color: $white;
      line-height: 25px;
      margin-bottom: 12px;
xulili's avatar
xulili committed
192
    }
leiqingsong's avatar
leiqingsong committed
193 194 195 196
    .relegation {
      font-size: 16px;
      color: $white;
      margin-top: 20px;
xulili's avatar
xulili committed
197
    }
leiqingsong's avatar
leiqingsong committed
198 199 200 201 202 203 204 205 206 207 208
  }
  .forest-level {
    height: 45px;
    font-family: PingFang-SC-Bold;
    font-size: 24px;
    font-weight: normal;
    font-stretch: normal;
    letter-spacing: 0px;
    color: #ffffff;
  }
  .level-progress {
209
    box-sizing: border-box;
leiqingsong's avatar
leiqingsong committed
210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226
    width: 100%;
    padding: 0 30px;
    display: flex;
    align-items: center;
    .level-num {
      width: 36px;
      height: 16px;
      line-height: 16px;
      background-image: url("../assets/images/rankbox.png");
      background-size: cover;
      font-family: PingFang-SC-Bold;
      font-size: 11px;
      color: #fc5202;
    }
  }

  .forest-list {
xulili's avatar
xulili committed
227 228 229 230 231
    padding: 0 15px;
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: space-between;
xulili's avatar
xulili committed
232 233
    position: absolute;
    top: 270px;
leiqingsong's avatar
leiqingsong committed
234 235 236 237 238 239 240 241 242 243
    .forest-item {
      height: 98px;
      background-color: #ffffff;
      box-shadow: 0px 1px 6px 0px rgba(6, 0, 1, 0.04);
      border-radius: 4px;
      width: calc(50% - 8px);
      margin-bottom: 10px;
      text-align: center;
      padding-top: 15px;
      box-sizing: border-box;
xulili's avatar
xulili committed
244
    }
leiqingsong's avatar
leiqingsong committed
245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261
    .forest-item-num {
      height: 19px;
      font-family: DINCondensed-Bold;
      font-size: 26px;
      font-weight: normal;
      font-stretch: normal;
      line-height: 25px;
      letter-spacing: 0px;
      color: #333333;
    }
    .forest-item-label {
      display: flex;
      align-items: center;
      justify-content: center;
      span {
        font-family: PingFang-SC-Medium;
        font-size: 14px;
xulili's avatar
xulili committed
262 263 264
        font-weight: normal;
        font-stretch: normal;
        letter-spacing: 0px;
leiqingsong's avatar
leiqingsong committed
265 266 267 268 269
        color: #666666;
      }
      .nav-left {
        color: #666;
      }
xulili's avatar
xulili committed
270
    }
leiqingsong's avatar
leiqingsong committed
271
  }
xulili's avatar
xulili committed
272 273
}
</style>
leiqingsong's avatar
leiqingsong committed
274 275
<style lang="scss">
.van-progress {
xulili's avatar
xulili committed
276
  width: calc(100% - 72px);
leiqingsong's avatar
leiqingsong committed
277 278 279 280 281 282 283 284 285
  height: 4px;
  background-color: rgba(0, 0, 0, 0.2);
  .van-progress__portion {
    background: #f9f9f9;
  }
  .van-progress__pivot {
    display: none;
  }
}
xulili's avatar
xulili committed
286
</style>