Commit 93df8d24 authored by mengcuiguang's avatar mengcuiguang

修改小说内容分段展示

parent f9bc5529
......@@ -25,6 +25,8 @@ export default class Book {
createTime,
tagList,
isUnlock,
free,
charge,
bookLegumes,
lockRate
} = param || {}
......@@ -54,6 +56,8 @@ export default class Book {
this.categoryId = categoryId;
this.createTime = createTime;
this.isUnlock = isUnlock;
this.charge = charge;
this.free = free;
this.bookLegumes = bookLegumes;
this.lockRate = lockRate;
}
......
......@@ -25,31 +25,9 @@
src="@/static/index/ic_quit_white.png"></image>
</view>
</view>
<!-- <view style="display: flex;flex-direction: column;align-items: center;margin-bottom: 20rpx;">
<view style="font-size: 38rpx;color: black;">{{titleText}}</view>
<view class="flex">
<view v-if="point>0" style="display: flex;flex-direction: row;margin-top: 10rpx;">
<view style="font-size: 28rpx;color: #644238;margin-top: 12rpx;">解锁本部:</view>
<view style="font-size: 42rpx;color: red;font-weight: 777;">{{point}}</view>
<view style="font-size: 28rpx;color: #644238;margin-top: 12rpx;margin-left: 6rpx;">
书豆
</view>
</view>
<view v-if="point>0" style="width: 60rpx;"></view>
<view style="display: flex;flex-direction: row;margin-top: 10rpx;">
<view style="font-size: 28rpx;color: #644238;margin-top: 12rpx;">账户余额:</view>
<view style="font-size: 42rpx;color: red;font-weight: 777;">{{userBean.point}}
</view>
<view style="font-size: 28rpx;color: #644238;margin-top: 12rpx;margin-left: 6rpx;">
书豆
</view>
</view>
</view>
</view> -->
<view class="section">
<view class="pack-box">
<view class="pack-item"
:style="item.largeType !=='vip' ?'background: #f4c98b;':'background: #f5f5f5;'"
:class="[{active: index==selectedIndex}]" v-for='(item, index) in vipList'
:key='index' @click="choosePack(item, index)">
<view style="display: flex;flex-direction: column;align-items: center;">
......@@ -332,6 +310,7 @@
flex-wrap: wrap;
.active {
background-color: #f4c98b !important;
border: 6rpx solid #fd5350 !important;
}
......@@ -343,7 +322,7 @@
display: flex;
flex-direction: column;
justify-content: space-around;
// background: #f5f5f5;
background: #f5f5f5;
border: 6rpx solid #f5f5f5;
border-radius: 10rpx;
position: relative;
......
......@@ -50,7 +50,7 @@
return {
user: null,
fontSize: `18px`,
PRECENT_VALUE:40
PRECENT_VALUE: 40
}
},
mounted() {
......@@ -79,29 +79,17 @@
},
computed: {
contentSources: function() {
return this.detail && this.detail.content ? this.detail.content : [];
return [...this.detail.free , ...this.detail.charge];
},
preContentSources: function() {
let result = this.detail && this.detail.content ? [...this.detail.content] : [];
let length = result.length;
if (length >= 2) {
if(this.detail.lockRate!=null&&this.detail.lockRate>0){
this.PRECENT_VALUE=this.detail.lockRate;
}
console.log('this.PRECENT_VALUE='+this.PRECENT_VALUE);
let precent = this.PRECENT_VALUE / 100;
let preLength = Math.floor(length * precent);
return result.splice(0, preLength);
} else {
return result;
}
return this.detail && this.detail.free ? [...this.detail.free] : [];
},
limitButtonTitle: function() {
let result = `~剩余${100-this.PRECENT_VALUE}%内容`;
let result = `后续内容更精彩`;
if (!this.user) {
result = `${result},点击登录后继续阅读`;
} else if (!this.user.isVip()) {
result = `${result}为会员章节内容,请前往购买会员`
result = `${result},充值后继续阅读`
}
result = `${result}~`;
return result;
......
......@@ -4,13 +4,31 @@ export default class BookDetail extends Book {
constructor(param) {
super(param);
const {
contentMd
contentMd,
freeMd,
chargeMd,
} = param || {}
this.contentMd = contentMd;
this.freeMd = freeMd;
this.chargeMd = chargeMd;
let result = contentMd ? contentMd.replace(/<[^>]+>/g, "") : "";
result = result.split("\n");
this.content = result.filter(item => {
return item.split(/[\t\r\f\n\s]*/g).join("");
});
let result2 = freeMd ? freeMd.replace(/<[^>]+>/g, "") : "";
result2 = result2.split("\n");
this.free = result2.filter(item => {
return item.split(/[\t\r\f\n\s]*/g).join("");
});
let result3 = chargeMd ? chargeMd.replace(/<[^>]+>/g, "") : "";
result3 = result3.split("\n");
this.charge = result3.filter(item => {
return item.split(/[\t\r\f\n\s]*/g).join("");
});
console.log('param------',param)
}
}
\ 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