123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164 |
- <template>
- <view class="content">
- <view class="main">
- <view v-for="(item, index) in list">
- <view class="first" v-if="index == 0" @click="navToList(item.id)">
- <view class="title">{{item.title}}</view>
- <view class="image"><image :src="item.image_input[0]" mode=""></image></view>
- <view class="time">{{item.add_time}}</view>
- </view>
- <view class="item flex" @click="navToList(item.id)" v-else>
- <view class="item-left"><image :src="item.image_input[0]" mode=""></image></view>
- <view class="item-right">
- <view class="item-font clamp">{{item.title}}</view>
- <view class="item-time">{{item.add_time}}</view>
- </view>
- </view>
- </view>
- </view>
- <uni-load-more :status="loadingType"></uni-load-more>
- </view>
- </template>
- <script>
- import { article } from '@/api/user.js';
- export default {
- data() {
- return {
- list: [],
- page: 1.,
- limit: 10,
- loadingType: 'more'
- };
- },
- onLoad() {
- this.loadData();
- },
- onShareAppMessage(options) {
- // 设置菜单中的转发按钮触发转发事件时的转发内容
- let pages = getCurrentPages(); //获取加载的页面
- let currentPage = pages[pages.length - 1]; //获取当前页面的对象
- let url = currentPage.route; //当前页面url
- let item = currentPage.options; //如果要获取url中所带的参数可以查看options
- let shareObj = {
- title: '水箱计算', // 默认是小程序的名称(可以写slogan等)
- path: url, // 默认是当前页面,必须是以‘/’开头的完整路径
- imageUrl: '',
- success: function(res) {
- // 转发成功之后的回调
- if (res.errMsg == 'shareAppMessage:ok') {}
- },
- fail: function() {
- // 转发失败之后的回调
- if (res.errMsg == 'shareAppMessage:fail cancel') {
- // 用户取消转发
- } else if (res.errMsg == 'shareAppMessage:fail') {
- // 转发失败,其中 detail message 为详细失败信息
- }
- }
- };
- return shareObj;
- },
- methods: {
- // 载入数据
- async loadData() {
- let obj = this;
- if(obj.loadingType == 'noMore' || obj.loadingType == 'loading' ) {
- return
- }
- obj.loadingType = 'loading'
- article({page:obj.page,limit:obj.limit},1).then(({data}) =>{
- obj.list = obj.list.concat(data)
- obj.page++
- if(data.length == obj.limit) {
- obj.loadingType = 'more'
- }else {
- obj.loadingType = 'noMore'
- }
- })
- },
- navToList(id) {
- uni.navigateTo({
- url: '/pages/index/artDetail?id=' + id
- });
- }
- }
- };
- </script>
- <style lang="scss">
- page,
- .content {
- height: auto;
- min-height: 100%;
- background: #f5f5f5;
- }
- .main {
- // margin-top: 20rpx;
- background: #ffffff;
- .first {
- padding: 50rpx 0 18rpx;
- margin: 0 22rpx;
- border-bottom: 1px solid #e0e0e0;
- .title {
- font-size: 32rpx;
- font-family: PingFang SC;
- font-weight: bold;
- color: #333333;
- }
- .image {
- width: 710rpx;
- height: 400rpx;
- background: #eee;
- margin-top: 20rpx;
- image {
- width: 100%;
- height: 100%;
- }
- }
- .time {
- margin-top: 20rpx;
- font-size: 26rpx;
- font-family: PingFang SC;
- font-weight: 500;
- color: #666666;
- }
- }
- .item {
- padding: 26rpx 0 18rpx;
- margin: 0 22rpx;
- justify-content: flex-start;
- align-items: flex-start;
- border-bottom: 1px solid #e0e0e0;
- .item-left {
- width: 224rpx;
- height: 160rpx;
- image {
- width: 100%;
- height: 100%;
- }
- }
- .item-right {
- width: 458rpx;
- height: 160rpx;
- margin-left: 24rpx;
- padding: 18rpx 0;
- display: flex;
- flex-direction: column;
- justify-content: space-between;
- .item-font {
- font-size: 32rpx;
- font-family: PingFang SC;
- font-weight: bold;
- color: #333333;
- }
- .item-time {
- font-size: 28rpx;
- font-family: PingFang SC;
- font-weight: 500;
- color: #666666;
- }
- }
- }
- }
- </style>
|