123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132 |
- <template>
- <view>
- <view class="tab">
- <u-tabs :list="tab" @click="click" :lineHeight="5"></u-tabs>
- </view>
- <view class="list">
- <view class="item" v-for="(item, index) in list" :key="index" @click="detail(item)">
- <view class="top">
- <view class="icon"></view>
- <view class="title" v-if="item.types == 1">系统消息</view>
- <view class="title" v-if="item.types == 2">交易消息</view>
- <view class="date">{{ item.createTime }}</view>
- </view>
- <view class="content">{{ item.contents }}</view>
- </view>
- <view class="loading" v-if="loadMore"><u-loadmore :status="loadMore ? 'loading' : 'nomore'" /></view>
- <u-empty v-if="!loadMore && list.length == 0"></u-empty>
- </view>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- user: this.getUser(),
- tab: [
- { name: '交易消息', types: 2 },
- { name: '系统消息', types: 1 }
- ],
- list: [],
- param: { pageNo: 1, pageSize: 10, types: 2 },
- loadMore: true
- };
- },
- onShow() {
- uni.removeTabBarBadge({ index: 1 });
- this.param.types = 2;
- this.refresh();
- },
- methods: {
- getData() {
- this.http.request({
- url: '/sp-admin/app/TbMessage/getList',
- data: this.param,
- loading: 'false',
- success: res => {
- this.loadMore = parseInt(res.data.pageCount) > this.param.pageNo;
- this.list.push(...res.data.data);
- }
- });
- },
- //点击tab切换
- click(e) {
- this.param.types = e.types;
- this.refresh();
- },
- detail(item) {
- uni.navigateTo({ url: item.url });
- },
- //刷新数据
- refresh() {
- this.loadMore = true;
- this.param.pageNo = 1;
- this.list = [];
- this.getData();
- }
- },
- //下拉刷新
- onPullDownRefresh() {
- setTimeout(() => {
- this.refresh();
- uni.stopPullDownRefresh();
- }, 1000);
- },
- //上拉加载
- onReachBottom() {
- if (this.loadMore) {
- this.param.pageNo++;
- this.getData();
- }
- }
- };
- </script>
- <style lang="scss">
- page {
- background-color: #f5f5f5;
- }
- .list {
- padding: 12px;
- .item {
- background-color: white;
- border-bottom: 1px solid #f0f2f7;
- padding: 14px;
- margin-bottom: 10px;
- border-radius: 10px;
- .top {
- color: $font-c;
- border-bottom: 1px solid $line;
- padding-bottom: 13px;
- overflow: hidden;
- .icon {
- float: left;
- width: 17px;
- height: 17px;
- border-radius: 50%;
- background-color: $main-color;
- padding: 5px;
- text-align: center;
- line-height: 19px;
- color: white;
- }
- .title {
- float: left;
- font-weight: bold;
- padding-left: 7px;
- color: #192b20;
- }
- .date {
- float: right;
- color: #a0a2a6;
- }
- }
- .content {
- padding-top: 15px;
- color: #666666;
- line-height: 25px;
- }
- }
- }
- </style>
|