123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172 |
- <template>
- <view
- class="msgList"
- >
- <view class="mt30">
- <navigator class="msgItem" v-for="(item,index) in msgList" :key="index" :url="`/pages/msgInfo/msgInfo?id=${item.id}`">
- <view class="msgItemLeft">
- <image class="fixedTitle" src="/static/msg_title_3.jpg"></image>
- </view>
- <view class="msgItemRight">
- <text class="msgItemTitle">{{item.title}}</text>
- <text>{{item.added_on}}</text>
- </view>
- </navigator>
- </view>
- <view class="loading" v-if="isMore">没有更多数据了</view>
- </view>
- </template>
- <script>
-
- import { messageList } from "../../api/index.js"
-
- export default {
- data(){
- return {
- msgList:[],
- isMore:false,
- page_index:1,
- page_size:10,
- scrollType:true
- }
- },
- onShow() {
- this.create({
- page_index:1,
- page_size:10,
- })
- },
- onPullDownRefresh:function(){
- this.scrollType=true
- this.create({
- page_index:1,
- page_size:this.page_index*this.page_size,
- });
- },
- onReachBottom:function(){
- if(!this.isMore){
- this.page_index++;
- this.scrollType=false
- if(!this.loading){
- this.create({
- page_index:this.page_index,
- page_size:10
- })
- }
- }
- },
- methods:{
- create(params){
- const that = this
- this.$nextTick(function(){
- messageList(params).then(res=>{
- uni.stopPullDownRefresh(); //停止下拉刷新动画
- const { error_code } = res
- if(error_code===200){
- const { data } = res
- if(data.length<1 || data.length<that.page_size){
- that.isMore=true
- }
- if(that.scrollType){
- that.msgList=data
- }else{
- that.msgList=that.msgList.concat(data)
- }
- }
- })
- })
- }
- }
- }
- </script>
- <style lang="scss">
- page{
- width: 100%;
- height: 100%;
- background: $uni-bg-color-normal;
- }
- .msgList{
- width: 100%;
- height: 100%;
- }
- .mt30{
- padding-top: 30rpx;
- }
- .msgItem{
- width: 100%;
- height: 156rpx;
- background-color: $uni-bg-color;
- position: relative;
- overflow: hidden;
- display: flex;
- justify-content: space-between;
- align-items: center;
- margin-bottom: 30rpx;
- }
- .msgItem::after,.msgItem::before{
- content: "";
- display: block;
- width: 42rpx;
- height: 42rpx;
- border-radius: 50%;
- position: absolute;
- background: $uni-bg-color-normal;
- left: 138rpx;
- }
- .msgItem::before{
- top: 0;
- margin-top: -21rpx;
- }
- .msgItem::after{
- bottom: 0;
- margin-bottom: -21rpx;
- }
- .fixedTitle{
- display: block;
- width: 72rpx;
- height: 35rpx;
- background-size: 100% 100%;
- }
- .msgItemLeft{
- width: 159rpx;
- height: 100%;
- display: flex;
- justify-content: center;
- align-items: center;
- position: relative;
- }
- .msgItemLeft::after{
- content: "";
- display: block;
- width: 6rpx;
- height: 90rpx;
- background: url(../../static/border_circle.jpg);
- background-size: 100% 100%;
- position: absolute;
- top: 50%;
- right: 0;
- margin-top: -45rpx;
- margin-right: -3rpx;
- }
- .msgItemRight{
- width: calc(100% - 159rpx - 89rpx - 57rpx);
- padding: 0 89rpx 0 57rpx;
- overflow: hidden;
- text-overflow: ellipsis;
- font-size: 24rpx;
- color: #999999;
- }
- .msgItemTitle{
- font-size: 28rpx;
- color: #323332;
- margin-bottom: 10rpx;
- display: block;
- }
- .loading{
- font-size: 24rpx;
- text-align: center;
- padding-bottom: 10px;
- }
- </style>
|