123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191 |
- <template>
- <mobile-frame>
- <view class="main">
- <view class="one">
- <view class="one_1">
- <text>{{user.integral||0}}</text><text>分</text>
- </view>
- <view class="one_2" style="display: none;">
- <button type="default" size="mini">礼品兑换记录</button>
- </view>
- </view>
- <view class="two">
- <view class="two_1" v-if="list&&list.length>0">
- scroll-view scroll-y="true" class="scroll-view" @scrolltolower="toPage">
- <view class="list-scroll-view">
- <view class="list" v-for="(item, index) in list" :key="index">
- </view>
- </view>
- </scroll-view>
- </view>
- <view class="two_2" v-else>
- 已加载完全部
- </view>
- </view>
- </view>
- </mobile-frame>
- </template>
- <script>
- export default {
- data() {
- return {
- user: {},
- list: [],
- total: 0,
- skip: 0,
- limit: 6,
- page: 0,
- // 状态
- statusList: [],
- // 来源
- sourceList: [],
- };
- },
- onShow: async function() {
- const that = this;
- await that.searchOther();
- await that.watchLogin();
- },
- methods: {
- watchLogin() {
- const that = this;
- uni.getStorage({
- key: 'token',
- success: function(res) {
- let user = that.$jwt(res.data);
- that.$set(that, `user`, user)
- that.search()
- }
- })
- },
- // 查询列表
- async search() {
- const that = this;
- let user = that.user;
- if (user._id) {
- let info = {
- skip: that.skip,
- limit: that.limit,
- customer: user._id,
- }
- let res = await that.$api(`/point`, 'GET', {
- ...info,
- })
- if (res.errcode == '0') {
- let list = [...that.list, ...res.data];
- that.$set(that, `list`, list);
- that.$set(that, `total`, res.total)
- }
- }
- },
- // 查询其他信息
- async searchOther() {
- const that = this;
- let res;
- res = await that.$api(`/dictData`, 'GET', {
- code: "point_status"
- });
- if (res.errcode == '0') {
- that.$set(that, `statusList`, res.data)
- }
- res = await that.$api(`/dictData`, 'GET', {
- code: "point_source"
- });
- if (res.errcode == '0') {
- that.$set(that, `sourceList`, res.data)
- }
- },
- // 分页
- toPage(e) {
- const that = this;
- let list = that.list;
- let limit = that.limit;
- if (that.total > list.length) {
- uni.showLoading({
- title: '加载中',
- mask: true
- })
- let page = that.page + 1;
- that.$set(that, `page`, page)
- let skip = page * limit;
- that.$set(that, `skip`, skip)
- that.search();
- uni.hideLoading();
- } else uni.showToast({
- title: '没有更多数据了',
- icon: 'none'
- });
- },
- // 清空列表
- clearPage() {
- const that = this;
- that.$set(that, `list`, [])
- that.$set(that, `skip`, 0)
- that.$set(that, `limit`, 6)
- that.$set(that, `page`, 0)
- }
- }
- }
- </script>
- <style lang="scss">
- .main {
- display: flex;
- flex-direction: column;
- width: 100vw;
- height: 100vh;
- .one {
- background-color: var(--fFB1Color);
- padding: 5vw 2vw;
- display: flex;
- justify-content: space-between;
- .one_1 {
- color: #fff;
- font-size: 25px;
- font-weight: bold;
- text:last-child {
- padding: 0 0 0 2vw;
- font-size: 15px;
- }
- }
- .one_2 {
- button {
- background: #fff;
- color: #ff0000;
- border-radius: 25px;
- font-size: 14px;
- }
- }
- }
- .two {
- .two_2 {
- text-align: center;
- color: #858585;
- font-size: 14px;
- margin: 5vw 0;
- }
- }
- }
- .scroll-view {
- position: absolute;
- top: 0;
- left: 0;
- right: 0;
- bottom: 0;
- .list-scroll-view {
- display: flex;
- flex-direction: column;
- }
- }
- </style>
|