Browse Source

cps:返钱、赚钱静态页面

panyong 3 years ago
parent
commit
c1773dd701

+ 10 - 0
htmldev/cps/src/views/marketing/make/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
+})

+ 290 - 4
htmldev/cps/src/views/marketing/make/index.vue

@@ -1,13 +1,299 @@
 <template>
-  <div>赚钱</div>
+  <div class="return-container">
+    <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">
+          <div class="wrap">
+            <div>
+              <p class="avatar">
+                <img src="" alt="">
+              </p>
+              <p class="user">L YongL YongL Yong</p>
+              <p class="shop">饿了么</p>
+            </div>
+            <p class="money">+99999.00</p>
+          </div>
+          <p class="date">2021-08-21</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>
+  </div>
 </template>
-
 <script>
+import BScroll from 'better-scroll'
+import { Toast, Loading } from 'vant'
+import { apiOrderList } from './api/api'
+
 export default {
-  name: 'index'
+  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>
+.return-container {
+  position: absolute;
+  left: 0;
+  top: 56px;
+  right: 0;
+  bottom: 0;
+  background: #F7F6F9;
+  overflow: hidden;
+}
 
+.wrapper {
+  width: 100%;
+  height: 100%;
+  overflow: hidden;
+
+  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;
+}
+
+.list-item {
+  width: 335px;
+  min-height: 92px;
+  background: #FFFFFF;
+  box-shadow: 0 2px 4px 0 rgba(31, 49, 74, 0.12);
+  border-radius: 10px;
+  padding: 15px;
+  margin-bottom: 16px;
+
+  .wrap {
+    display: flex;
+    align-items: center;
+
+    & > div {
+      display: flex;
+      align-items: center;
+      width: 205px;
+    }
+  }
+
+  .avatar {
+    flex: 0 0 28px;
+    width: 28px;
+    height: 28px;
+    border: 2px solid #FFFFFF;
+    border-radius: 50%;
+    overflow: hidden;
+    background: pink;
+
+    img {
+      display: block;
+      width: 100%;
+    }
+  }
+
+  .user,
+  .shop {
+    font-size: 20px;
+    color: #1F314A;
+    line-height: 28px;
+    white-space: nowrap;
+  }
+
+  .user {
+    max-width: 90px;
+    margin: 0 8px 0 10px;
+    overflow: hidden;
+    text-overflow: ellipsis;
+    white-space: nowrap;
+  }
+
+  .shop {
+    max-width: 69px;
+    overflow: hidden;
+    text-overflow: ellipsis;
+    white-space: nowrap;
+  }
+
+  .money {
+    width: 100px;
+    font-size: 18px;
+    font-family: PingFangSC-Semibold, PingFang SC;
+    font-weight: 600;
+    color: #FA4A4A;
+    line-height: 25px;
+    white-space: nowrap;
+    text-align: right;
+  }
+
+  .date {
+    margin-top: 12px;
+    font-size: 16px;
+    color: #1F314A;
+    line-height: 19px;
+  }
+}
 </style>

+ 10 - 0
htmldev/cps/src/views/marketing/return/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
+})

+ 258 - 4
htmldev/cps/src/views/marketing/return/index.vue

@@ -1,13 +1,267 @@
 <template>
-  <div>返钱</div>
+  <div class="return-container">
+    <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">
+          <div class="wrap">
+            <p class="shop">饿了么</p>
+            <p class="money">
+              <span>返</span>
+              <span>1.00</span>
+            </p>
+          </div>
+          <p class="date">2021-08-21</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>
+  </div>
 </template>
-
 <script>
+import BScroll from 'better-scroll'
+import { Toast, Loading } from 'vant'
+import { apiOrderList } from './api/api'
+
 export default {
-  name: 'index'
+  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>
+.return-container {
+  position: absolute;
+  left: 0;
+  top: 56px;
+  right: 0;
+  bottom: 0;
+  background: #F7F6F9;
+  overflow: hidden;
+}
+
+.wrapper {
+  width: 100%;
+  height: 100%;
+  overflow: hidden;
+
+  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;
+}
+
+.list-item {
+  width: 335px;
+  height: 92px;
+  background: #FFFFFF;
+  box-shadow: 0 2px 4px 0 rgba(31, 49, 74, 0.12);
+  border-radius: 10px;
+  padding: 16px 0 0 20px;
+  margin-bottom: 16px;
+
+  .wrap {
+    display: flex;
+    align-items: center;
+  }
+
+  .shop {
+    font-size: 20px;
+    color: #1F314A;
+    line-height: 28px;
+  }
+
+  .money {
+    display: flex;
+    align-items: center;
+
+    span:nth-of-type(1) {
+      margin: 0 4px 0 14px;
+      font-size: 20px;
+      color: #1F314A;
+      line-height: 28px;
+    }
+
+    span:nth-of-type(2) {
+      font-size: 18px;
+      font-family: PingFangSC-Semibold, PingFang SC;
+      font-weight: 600;
+      color: #FA4A4A;
+      line-height: 25px;
+    }
+  }
+
+  .date {
+    margin-top: 11px;
+    font-size: 16px;
+    color: #1F314A;
+    line-height: 19px;
+  }
+}
 </style>

+ 1 - 0
htmldev/cps/src/views/marketing/save/index.vue

@@ -82,6 +82,7 @@ export default {
   right: 0;
   bottom: 0;
   background: #F7F6F9;
+  overflow: hidden;
 }
 
 .wrapper {