Commit 2b43b53b authored by mengcuiguang's avatar mengcuiguang

代码优化

parent e3f5ed2d
<template>
<view class="body">
<z-paging class="flex-1" ref="paging" v-model="dataList" @query="queryList" :defaultPageNo="1"
:defaultPageSize="500">
<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 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;align-items: center;" @click="handleInfo(item)">
<view style="display: flex;flex-direction: column;margin-left: 20rpx;margin-top: 20rpx;">
<view style="font-size: 30rpx;color: black;">{{item.title}}</view>
<view style="font-size: 22rpx;color: gray;margin-top: 16rpx;">{{item.summary}}</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 style="display: flex;flex-direction: column;">
<image v-if="item.collect==0" @click="handleXing(item)"
style="width: 50rpx;height: 50rpx;display: flex;align-items: right;padding-right: 4rpx;"
src="../../static/home_collect_img_0.png"></image>
<image v-else @click="handleXing(item)"
style="width: 50rpx;height: 50rpx;display: flex;align-items: right;padding-right: 4rpx;"
src="../../static/home_collect_img_1.png"></image>
<view
style="font-size: 22rpx;color: gray;margin-top: 10rpx;display: flex;justify-content: center;">
收藏</view>
</view>
</view>
</view>
</view>
</z-paging>
</view>
</template>
<script>
import common from '@/mixins/common';
import {
navigateTo,
message,
alert,
loading
} from '@/utils/fun.js';
import {
openUrl
} from '@/utils/app+.js';
const app = getApp();
export default {
name: 'index',
mixins: [common],
data() {
return {
dataList: []
};
},
methods: {
show() {
if (this.$refs.paging != null) {
this.$refs.paging.refresh();
}
},
queryList(page, size) {
this.post({
url: '/book/readRecordList',
data: {
page,
size
},
showLoading: false,
success: ({
data
}) => {
this.$refs.paging.complete(data.list);
}
});
},
handleInfo(item) {
},
handleXing(item) {
var that = this;
//0未收藏,1收藏
if (!item.isCollect) {
this.post({
url: '/book/collect',
data: {
articleId: item.articleId,
},
showLoading: false,
success: ({
data
}) => {
that.show();
}
});
} else {
this.post({
url: '/book/cancelCollect',
data: {
articleId: item.articleId,
},
showLoading: false,
success: ({
data
}) => {
that.show();
}
});
}
}
}
};
</script>
<style>
.body {
background-color: whitesmoke;
}
.img {
position: relative;
border-radius: 10rpx;
width: 180rpx;
height: 240rpx;
}
<template>
<view class="body">
<z-paging class="flex-1" ref="paging" v-model="dataList" @query="queryList" :defaultPageNo="1"
:defaultPageSize="500">
<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
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;align-items: center;" @click="handleInfo(item)">
<view style="display: flex;flex-direction: column;margin-left: 20rpx;margin-top: 20rpx;">
<view style="font-size: 30rpx;color: black;">{{item.title}}</view>
<view style="font-size: 22rpx;color: gray;margin-top: 16rpx;">{{item.summary}}</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 style="display: flex;flex-direction: column;">
<image v-if="item.collect==0" @click="handleXing(item)"
style="width: 50rpx;height: 50rpx;display: flex;align-items: right;padding-right: 4rpx;"
src="../../static/home_collect_img_0.png"></image>
<image v-else @click="handleXing(item)"
style="width: 50rpx;height: 50rpx;display: flex;align-items: right;padding-right: 4rpx;"
src="../../static/home_collect_img_1.png"></image>
<view
style="font-size: 22rpx;color: gray;margin-top: 10rpx;display: flex;justify-content: center;">
收藏</view>
</view>
</view>
</view>
</view>
</z-paging>
</view>
</template>
<script>
import common from '@/mixins/common';
import {
navigateTo,
message,
alert,
loading
} from '@/utils/fun.js';
import {
openUrl
} from '@/utils/app+.js';
const app = getApp();
export default {
name: 'index',
mixins: [common],
data() {
return {
dataList: []
};
},
methods: {
show() {
if (this.$refs.paging != null) {
this.$refs.paging.refresh();
}
},
queryList(page, size) {
this.post({
url: '/book/readRecordList',
data: {
page,
size
},
showLoading: false,
success: ({
data
}) => {
this.$refs.paging.complete(data.list);
}
});
},
handleInfo(item) {
var bookId = item.id;
uni.navigateTo({
url: `/page-subs/sub_A/book-content/book-content`,
success: (res) => {
res.eventChannel.emit("openBookContentPage", {
bookId
})
}
})
},
handleXing(item) {
var that = this;
//0未收藏,1收藏
if (!item.isCollect) {
this.post({
url: '/book/collect',
data: {
articleId: item.articleId,
},
showLoading: false,
success: ({
data
}) => {
that.show();
}
});
} else {
this.post({
url: '/book/cancelCollect',
data: {
articleId: item.articleId,
},
showLoading: false,
success: ({
data
}) => {
that.show();
}
});
}
}
}
};
</script>
<style>
.body {
background-color: whitesmoke;
}
.img {
position: relative;
border-radius: 10rpx;
width: 180rpx;
height: 240rpx;
}
</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