Commit 2b43b53b authored by mengcuiguang's avatar mengcuiguang

代码优化

parent e3f5ed2d
<template> <template>
<view class="body"> <view class="body">
<z-paging class="flex-1" ref="paging" v-model="dataList" @query="queryList" :defaultPageNo="1" <z-paging class="flex-1" ref="paging" v-model="dataList" @query="queryList" :defaultPageNo="1"
:defaultPageSize="500"> :defaultPageSize="500">
<view style="font-size: 30rpx;font-weight: 777;margin-left: 12rpx;margin-top: 10rpx;">最近阅读</view> <view style="font-size: 30rpx;font-weight: 777;margin-left: 12rpx;margin-top: 10rpx;">最近阅读</view>
<view v-for="(item, i) in dataList" :key="i"> <view v-for="(item, i) in dataList" :key="i">
<view style="display: flex;flex-direction: row;background-color:white;border-radius:10rpx;justify-content:space-between;margin: 20rpx;padding-bottom: 20rpx;"> <view
<view style="display: flex;align-items: center;" @click="handleInfo(item)"> style="display: flex;flex-direction: row;background-color:white;border-radius:10rpx;justify-content:space-between;margin: 20rpx;padding-bottom: 20rpx;">
<view style="display: flex;flex-direction: column;margin-left: 20rpx;margin-top: 20rpx;"> <view style="display: flex;align-items: center;" @click="handleInfo(item)">
<view style="font-size: 30rpx;color: black;">{{item.title}}</view> <view style="display: flex;flex-direction: column;margin-left: 20rpx;margin-top: 20rpx;">
<view style="font-size: 22rpx;color: gray;margin-top: 16rpx;">{{item.summary}}</view> <view style="font-size: 30rpx;color: black;">{{item.title}}</view>
<view style="font-size: 28rpx;color: black;margin-top: 16rpx;">作者:{{item.author}}</view> <view style="font-size: 22rpx;color: gray;margin-top: 16rpx;">{{item.summary}}</view>
</view> <view style="font-size: 28rpx;color: black;margin-top: 16rpx;">作者:{{item.author}}</view>
</view> </view>
<view style="display: flex;align-items: center;margin-right: 8rpx;"> </view>
<view style="display: flex;flex-direction: column;"> <view style="display: flex;align-items: center;margin-right: 8rpx;">
<image v-if="item.collect==0" @click="handleXing(item)" <view style="display: flex;flex-direction: column;">
style="width: 50rpx;height: 50rpx;display: flex;align-items: right;padding-right: 4rpx;" <image v-if="item.collect==0" @click="handleXing(item)"
src="../../static/home_collect_img_0.png"></image> style="width: 50rpx;height: 50rpx;display: flex;align-items: right;padding-right: 4rpx;"
<image v-else @click="handleXing(item)" src="../../static/home_collect_img_0.png"></image>
style="width: 50rpx;height: 50rpx;display: flex;align-items: right;padding-right: 4rpx;" <image v-else @click="handleXing(item)"
src="../../static/home_collect_img_1.png"></image> style="width: 50rpx;height: 50rpx;display: flex;align-items: right;padding-right: 4rpx;"
<view src="../../static/home_collect_img_1.png"></image>
style="font-size: 22rpx;color: gray;margin-top: 10rpx;display: flex;justify-content: center;"> <view
收藏</view> style="font-size: 22rpx;color: gray;margin-top: 10rpx;display: flex;justify-content: center;">
</view> 收藏</view>
</view> </view>
</view> </view>
</view> </view>
</view>
</z-paging>
</view> </z-paging>
</template> </view>
<script> </template>
import common from '@/mixins/common'; <script>
import { import common from '@/mixins/common';
navigateTo, import {
message, navigateTo,
alert, message,
loading alert,
} from '@/utils/fun.js'; loading
import { } from '@/utils/fun.js';
openUrl import {
} from '@/utils/app+.js'; openUrl
} from '@/utils/app+.js';
const app = getApp();
const app = getApp();
export default {
name: 'index', export default {
mixins: [common], name: 'index',
data() { mixins: [common],
return { data() {
dataList: [] return {
}; dataList: []
}, };
methods: { },
show() { methods: {
if (this.$refs.paging != null) { show() {
this.$refs.paging.refresh(); if (this.$refs.paging != null) {
} this.$refs.paging.refresh();
}, }
queryList(page, size) { },
this.post({ queryList(page, size) {
url: '/book/readRecordList', this.post({
data: { url: '/book/readRecordList',
page, data: {
size page,
}, size
showLoading: false, },
success: ({ showLoading: false,
data success: ({
}) => { data
this.$refs.paging.complete(data.list); }) => {
} this.$refs.paging.complete(data.list);
}); }
}, });
handleInfo(item) { },
handleInfo(item) {
}, var bookId = item.id;
handleXing(item) { uni.navigateTo({
var that = this; url: `/page-subs/sub_A/book-content/book-content`,
//0未收藏,1收藏 success: (res) => {
if (!item.isCollect) { res.eventChannel.emit("openBookContentPage", {
this.post({ bookId
url: '/book/collect', })
data: { }
articleId: item.articleId, })
}, },
showLoading: false, handleXing(item) {
success: ({ var that = this;
data //0未收藏,1收藏
}) => { if (!item.isCollect) {
that.show(); this.post({
} url: '/book/collect',
}); data: {
} else { articleId: item.articleId,
this.post({ },
url: '/book/cancelCollect', showLoading: false,
data: { success: ({
articleId: item.articleId, data
}, }) => {
showLoading: false, that.show();
success: ({ }
data });
}) => { } else {
that.show(); this.post({
} url: '/book/cancelCollect',
}); data: {
} articleId: item.articleId,
} },
} showLoading: false,
}; success: ({
</script> data
}) => {
<style> that.show();
}
.body { });
background-color: whitesmoke; }
} }
}
.img { };
position: relative; </script>
border-radius: 10rpx;
width: 180rpx; <style>
height: 240rpx; .body {
} background-color: whitesmoke;
}
.img {
position: relative;
border-radius: 10rpx;
width: 180rpx;
height: 240rpx;
}
</style> </style>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment