Kaynağa Gözat

cps:粉丝列表

panyong 3 yıl önce
ebeveyn
işleme
c9995584d4

+ 10 - 0
htmldev/cps/src/views/fans/api/api.js

@@ -0,0 +1,10 @@
+import request from '@/api/request'
+
+/**
+ * 订单列表接口
+ */
+export const apiOrderList = (params) => request({
+  method: 'GET',
+  url: '/api/v1/user/order/list',
+  params: params
+})

+ 271 - 0
htmldev/cps/src/views/fans/child/main.vue

@@ -0,0 +1,271 @@
+<template>
+  <div
+    class="wrapper"
+    ref="returnWrapper">
+    <ul>
+      <li
+        :class="{'static': isRefresh}"
+        class="pulldown-wrapper">
+        <van-loading
+          v-show="isRefresh"
+          size="24px"
+          type="spinner">加载中...
+        </van-loading>
+        <div
+          v-show="!isRefresh"
+          class="van-loading">
+          <span
+            class="van-loading__text">下拉刷新</span>
+        </div>
+      </li>
+      <li
+        v-for="(item, index) in list"
+        :key="index"
+        class="list-item border-bottom-1px">
+        <div class="wrap">
+          <div class="left">
+            <div class="avatar">
+              <img src="" alt="">
+            </div>
+            <p class="name">刘亚楠</p>
+          </div>
+          <p class="status">未激活</p>
+        </div>
+        <p class="date">加入时间:2020-12-23 19:30</p>
+      </li>
+      <li class="pullup-wrapper">
+        <van-loading
+          v-show="!finished"
+          size="24px"
+          type="spinner">加载中...
+        </van-loading>
+        <div
+          v-show="finished"
+          class="van-loading">
+          <span
+            class="van-loading__text">没有更多了</span>
+        </div>
+      </li>
+    </ul>
+  </div>
+</template>
+<script>
+import BScroll from 'better-scroll'
+import { Toast, Loading } from 'vant'
+import { apiOrderList } from '../api/api'
+
+export default {
+  components: {
+    'van-loading': Loading
+  },
+  data () {
+    return {
+      finished: false, // 所有数据是否加载完
+      isRefresh: false, // 是否下拉刷新
+      isFetchLock: false, // 接口调用加锁
+      pagenum: 0,
+      pagesize: 20,
+      list: [],
+      scroll: null
+    }
+  },
+  activated () {
+    if (!this.$route.meta.isUseCache) {
+      this.finished = false
+      this.isRefresh = false
+      this.isFetchLock = false
+      this.pagenum = 0
+      this.pagesize = 20
+      this.list = []
+      this.scroll = null
+      this.getList()
+    } else {
+      this.scroll && this.scroll.refresh()
+    }
+    this.$route.meta.isUseCache = false
+  },
+  methods: {
+    goDetail (id) {},
+    onRefresh () {
+      this.pagenum = 0
+      this.pagesize = 20
+      this.finished = false
+      this.isRefresh = true
+      this.getList()
+    },
+    async getList () {
+      if (this.finished) {
+        return
+      }
+      if (this.isFetchLock) {
+        return
+      }
+      this.isFetchLock = true
+      this.pagenum++
+      try {
+        const { status, data, msg } = await apiOrderList({ page: this.pagenum, page_size: this.pagesize })
+        if (status) {
+          const { list } = data
+          // 下拉刷新数据清空
+          if (this.isRefresh) {
+            this.isRefresh = false
+            this.list = []
+          }
+
+          // 没有数据返回了
+          if (Array.isArray(list) && !list.length) {
+            this.finished = true
+          }
+
+          if (Array.isArray(list) && list.length) {
+            // 总页数小于等于1页时
+            if (list.length < this.pagesize) {
+              this.finished = true
+            }
+            this.list = this.list.concat(list)
+
+            this.$nextTick(() => {
+              if (!this.scroll) {
+                this.scroll = new BScroll(this.$refs.returnWrapper, {
+                  click: true,
+                  pullDownRefresh: {
+                    threshold: 50, // 顶部下拉的距离
+                    stop: 20 // 回弹停留的距离
+                  },
+                  pullUpLoad: {
+                    threshold: -20
+                  },
+                  scrollbar: true
+                })
+
+                this.scroll.on('pullingDown', () => {
+                  this.onRefresh()
+                })
+
+                this.scroll.on('pullingUp', () => {
+                  this.getList()
+                })
+              } else {
+                this.scroll.finishPullDown()
+                this.scroll.finishPullUp()
+                this.scroll.refresh()
+              }
+            })
+          }
+        } else {
+          Toast(msg)
+        }
+        this.isFetchLock = false
+      } catch (err) {
+        this.isFetchLock = false
+      }
+    }
+  },
+  beforeDestroy () {
+    this.scroll && this.scroll.destroy()
+  },
+  beforeRouteLeave (to, form, next) {
+    if (['Mine', 'OrderDetail'].findIndex(item => item === to.name) > -1) {
+      form.meta.isUseCache = true
+    }
+    next()
+  }
+}
+</script>
+<style lang="scss" scoped>
+.wrapper {
+  width: 100%;
+  height: calc(100% - 117px);
+  overflow: hidden;
+  background: #FFFFFF;
+
+  ul {
+    display: flex;
+    flex-direction: column;
+    align-items: center;
+    width: 100%;
+    padding: 15px 0 102px;
+  }
+}
+
+.pulldown-wrapper {
+  position: absolute;
+  left: 0;
+  top: -43px;
+  width: 100%;
+  text-align: center;
+  margin-bottom: 10px;
+
+  &.static {
+    position: static;
+    left: 0;
+    top: 0;
+  }
+}
+
+.pullup-wrapper {
+  width: 100%;
+  text-align: center;
+
+  .van-loading {
+    margin-top: 16px;
+  }
+}
+
+.list-item {
+  width: 340px;
+  padding: 15px 19px 15px 14px;
+  @include border-bottom-1px(rgba(31, 49, 74, 0.1));
+
+  .wrap {
+    display: flex;
+    align-items: center;
+    justify-content: space-between;
+  }
+
+  .left {
+    display: flex;
+    align-items: center;
+  }
+
+  .avatar {
+    width: 40px;
+    height: 40px;
+    border-radius: 50%;
+    overflow: hidden;
+    background: pink;
+
+    img {
+      display: block;
+      width: 100%;
+    }
+  }
+
+  .name {
+    margin-left: 10px;
+    font-size: 16px;
+    font-family: PingFangSC-Medium, PingFang SC;
+    font-weight: 500;
+    color: #333333;
+    line-height: 22px;
+  }
+
+  .status {
+    width: 44px;
+    height: 19px;
+    background: #FFF0BF;
+    border-radius: 4px;
+    font-size: 12px;
+    color: #DD8C01;
+    line-height: 19px;
+    text-align: center;
+  }
+
+  .date {
+    margin-top: 16px;
+    font-size: 12px;
+    color: #999999;
+    line-height: 17px;
+  }
+}
+</style>

+ 179 - 2
htmldev/cps/src/views/fans/index.vue

@@ -1,13 +1,190 @@
 <template>
-  <div>粉丝</div>
+  <div class="bill-container">
+    <h2>粉丝</h2>
+    <van-tabs
+      class="fbt-van-tabs"
+      v-model="numActiveTab"
+      :color="'#FA4A4A'"
+      :title-active-color="'rgba(51, 51, 51, 1)'"
+      :title-inactive-color="'#666666'"
+      ref="myTabs">
+      <van-tab title="未激活(999999999)"></van-tab>
+      <van-tab title="有效(14)"></van-tab>
+    </van-tabs>
+    <Main/>
+    <van-popup
+      class="fbt-van-popup"
+      v-model="showDetail"
+      position="bottom">
+      <div class="fbt-van-popup-body">
+        <h3>费用详情</h3>
+        <p>
+          <span class="label">支付类型:</span>
+          <span class="value">下单返</span>
+        </p>
+        <p>
+          <span class="label">支付时间:</span>
+          <span class="value">2021-8-12  09:23:04</span>
+        </p>
+        <p>
+          <span class="label">订单号:</span>
+          <span class="value">126452164518</span>
+        </p>
+        <p>
+          <span class="label">交易单号:</span>
+          <span class="value">1274554794</span>
+        </p>
+        <p>
+          <span class="label">备注:</span>
+          <span class="value">备注备注备注备注备注</span>
+        </p>
+        <p class="amont">+¥736.23</p>
+      </div>
+    </van-popup>
+  </div>
 </template>
 
 <script>
+import { Tabs, Tab, Popup } from 'vant'
+import Main from './child/main'
+
 export default {
-  name: 'index'
+  name: 'index',
+  components: {
+    'van-tabs': Tabs,
+    'van-tab': Tab,
+    Main,
+    'van-popup': Popup
+  },
+  data () {
+    return {
+      numActiveTab: 0,
+      showDetail: false
+    }
+  },
+  async mounted () {
+    await this.$nextTick()
+
+    setTimeout(() => {
+      this.$refs.myTabs.resize()
+    }, 500)
+  }
 }
 </script>
 
 <style lang="scss" scoped>
+.bill-container {
+  position: absolute;
+  left: 0;
+  top: 0;
+  right: 0;
+  bottom: 0;
+  width: 100%;
+}
+
+h2 {
+  padding: 16px 0 16px 24px;
+  font-size: 24px;
+  font-family: PingFangSC-Medium, PingFang SC;
+  font-weight: 500;
+  color: #333333;
+  line-height: 33px;
+}
+
+.fbt-van-tabs {
+  &:after {
+    position: absolute;
+    left: 0;
+    bottom: 0;
+    content: '';
+    display: block;
+    width: 100%;
+    border-bottom: 1px solid rgba(31, 49, 74, 0.1);
+  }
+
+  ::v-deep .van-tabs__nav--line {
+    padding-bottom: 0;
+  }
+
+  ::v-deep .van-tab {
+    &__text {
+      font-size: 14px;
+    }
+
+    &.van-tab--active {
+      .van-tab__text {
+        font-size: 16px;
+        font-family: PingFangSC-Medium, PingFang SC;
+        font-weight: 500;
+      }
+    }
+  }
+
+  ::v-deep .van-tabs__line {
+    bottom: 0;
+  }
+}
+
+.fbt-van-popup {
+  background: transparent;
+
+  &-body {
+    display: flex;
+    flex-direction: column;
+    align-items: center;
+    width: 343px;
+    background: #FFFFFF;
+    border-radius: 8px;
+    padding-top: 24px;
+    margin: 0 auto 16px;
+
+    h3 {
+      width: 304px;
+      font-size: 24px;
+      font-family: PingFangSC-Medium, PingFang SC;
+      font-weight: 500;
+      color: #333333;
+      line-height: 33px;
+    }
+
+    p {
+      display: flex;
+      align-items: center;
+      width: 304px;
+      margin-top: 12px;
 
+      &:nth-of-type(1) {
+        margin-top: 20px;
+      }
+
+      span {
+        font-size: 14px;
+        line-height: 20px;
+      }
+
+      .label {
+        width: 100px;
+        color: #999999;
+      }
+
+      .value {
+        width: calc(100% - 100px);
+        text-align: right;
+        color: #333333;
+      }
+    }
+
+    .amont {
+      justify-content: flex-end;
+      padding: 15px 0 17px;
+      margin-top: 20px;
+      border-top: 1px solid rgba(31, 49, 74, 0.1);
+      font-size: 20px;
+      font-family: PingFangSC-Medium, PingFang SC;
+      font-weight: 500;
+      color: #333333;
+      line-height: 28px;
+    }
+  }
+}
 </style>