123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198 |
- <template>
- <view class="main">
- <view class="container">
- <view class="prompt-message" style="text-align: center;margin: 20px 0;" v-if="collectList.length<=0">
- 没有更多数据了...
- </view>
- <uni-swipe-action v-else>
- <view class="list" :key="index" v-for="(item , index) in collectList" @click="articleDetails(item.id)">
- <uni-swipe-action-item :options="options" @click="uncollect(item.id)" class="list-item">
- <view class="infobox">
- <view class="left">
- <view class="infoname">{{item.title}}</view>
- <view class="infotxt">{{item.gist == null? '': item.gist}}</view>
- <view class="infolook">
- <image src="../../static/index/look.png"></image>
- <view>{{ item.virtual_view + item.view }}</view>
- </view>
- </view>
- <view class="right">
- <image :src="item.image"></image>
- </view>
- </view>
- </uni-swipe-action-item>
- </view>
- </uni-swipe-action>
- </view>
- </view>
- </template>
- <script>
- // 引入uniapp滑动组件
- import uniSwipeAction from '@/components/uni-swipe-action/uni-swipe-action.vue'
- import uniSwipeActionItem from '@/components/uni-swipe-action-item/uni-swipe-action-item.vue'
- export default {
- name: 'CollectList',
- components: {
- uniSwipeAction,
- uniSwipeActionItem
- },
- data() {
- return {
- options: [{
- text: '取消收藏',
- style: {
- backgroundColor: 'rgb(255,58,49)'
- }
- }, ],
- collectList: []
- }
- },
- onLoad() {
- },
- mounted() {
- this.CollectData()
- },
- methods: {
- // 下拉刷新数据
- onPullDownRefresh: function() {
- this.CollectData()
- setTimeout(function() {
- uni.stopPullDownRefresh();
- }, 1000);
- },
- async CollectData() {
- let res = await this.$request.post('/api/Article/favoriteList');
- console.log(res.data)
- if (res.code == 200) {
- this.collectList = res.data
- console.log(this.collectList)
- } else {
- uni.showToast({
- icon: 'none',
- title: res.message
- })
- }
- },
- // 删除函数
- async uncollect(id) {
- console.log(id)
- let url = '/api/article/deleteFavroite?id=' + id
- let res = await this.$request.post(url);
- if (res.code == 200) {
- uni.showToast({
- title: '取消成功'
- })
- this.CollectData()
- } else {
- uni.showToast({
- icon: 'none',
- title: res.message
- })
- }
- },
- // 跳转到文章详情
- articleDetails(id) {
- uni.navigateTo({
- url: '/pages/index/articleDetails?id=' + id
- })
- }
- }
- }
- </script>
- <style>
- page {
- background: #F5F5F5;
- }
- .main {
- width: 100vw;
- height: auto;
- margin-bottom: 20px;
- }
- .container {
- padding: 0 15px;
- }
- .list {
- width: 100%;
- height: auto;
- margin-top: 20px;
- }
- .list .infobox {
- width: 100%;
- /* height: 200rpx; */
- /* margin: 15px 0; */
- padding: 15rpx;
- display: flex;
- justify-content: space-between;
- background: #fff;
- border-radius: 5px;
- }
- .infobox .left {
- width: 54vw;
- }
- .infobox .right {
- width: 34vw;
- }
- .infobox .right .right-img-item {
- border-radius: 12rpx;
- }
- .right image {
- width: 100%;
- height: 100%;
- }
- .left .infoname {
- /* width: 100%; */
- /* height: 80rpx; */
- font-size: 32rpx;
- font-weight: 400;
- color: rgba(85, 88, 100, 1);
- font-family: PingFangSC-Regular, sans-serif;
- /* overflow: hidden; */
- }
- .left .infotxt {
- width: 100%;
- /* height: 92rpx; */
- display: flex;
- align-items: center;
- color: #999;
- font-size: 24rpx;
- font-family: PingFangSC-Regular, sans-serif;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- }
- .left .infolook {
- width: 100%;
- height: 50rpx;
- display: flex;
- align-items: center;
- }
- .infolook image {
- width: 34rpx;
- height: 34rpx;
- margin: 2px;
- border-radius: 12rpx;
- }
- .infolook view {
- width: auto;
- height: 30px;
- line-height: 30px;
- padding: 0 5px;
- color: #999;
- }
- </style>
|