Commit 0f160df4 authored by jyx's avatar jyx

代码优化

parent c13fbd42
...@@ -2,10 +2,8 @@ ...@@ -2,10 +2,8 @@
<z-paging :style="[bgStyle]"> <z-paging :style="[bgStyle]">
<template> <template>
<detail-thumb :detail='bookData'></detail-thumb> <detail-thumb :detail='bookData'></detail-thumb>
<detail-content @tapVip='tapVipPop' :detail='bookData' :userInfo='userInfo'></detail-content> <detail-content :detail='bookData' :userInfo='userInfo' @tapVip='tapVipPop'></detail-content>
<detail-new-buy v-if="bookData.isUnlock==0 && !isVip()" <detail-new-buy v-if="bookData.isUnlock==0 && !isVip()" @tapVip='tapVipPop'></detail-new-buy>
:detail='bookData' :userInfo='userInfo' @tapVip='tapVipPop'
></detail-new-buy>
<detail-bottom :detail='bookData' :userInfo='userInfo' @tapBottomItem='tapBottomItem'></detail-bottom> <detail-bottom :detail='bookData' :userInfo='userInfo' @tapBottomItem='tapBottomItem'></detail-bottom>
<setting-pop :show='showSetting' @close='closePop'></setting-pop> <setting-pop :show='showSetting' @close='closePop'></setting-pop>
<coin-popup v-if="bookData.isUnlock==0 && !isVip()" :show="showVip" @close="coinClose($event)" <coin-popup v-if="bookData.isUnlock==0 && !isVip()" :show="showVip" @close="coinClose($event)"
...@@ -63,12 +61,12 @@ ...@@ -63,12 +61,12 @@
}, },
data() { data() {
return { return {
bookId: null, bookId: '',
bookData: null, bookData: {},
backgroundColor: "#fff", backgroundColor: "#fff",
showSetting: false, showSetting: false,
showVip: false, showVip: false,
userInfo: null, userInfo: {},
showVipOpen: 0, showVipOpen: 0,
showVipbackPop: false, showVipbackPop: false,
vipPopRefresh: false, vipPopRefresh: false,
...@@ -135,9 +133,6 @@ ...@@ -135,9 +133,6 @@
return result; return result;
}, },
computed: { computed: {
showEmpty: function() {
return isEmpty(this.bookData)
},
bgStyle: function() { bgStyle: function() {
let height = 300; let height = 300;
if (this.windowHeight) { if (this.windowHeight) {
...@@ -162,10 +157,6 @@ ...@@ -162,10 +157,6 @@
} }
}, },
methods: { methods: {
// 解锁回调
unlockBook() {
this.$set(this.bookData, "isUnlock", true);
},
// 文章数据刷新 // 文章数据刷新
refreshBookData(bookId) { refreshBookData(bookId) {
getBookDetailData(bookId, (success, data) => { getBookDetailData(bookId, (success, data) => {
...@@ -218,7 +209,7 @@ ...@@ -218,7 +209,7 @@
}, },
// 价格弹窗 // 价格弹窗
coinClose(e) { coinClose(e) {
this.vipPopRefresh=false; this.vipPopRefresh = false;
let item = e.detail.data; let item = e.detail.data;
if (item != null) { if (item != null) {
...@@ -232,14 +223,14 @@ ...@@ -232,14 +223,14 @@
}, },
// 价格挽留弹窗 // 价格挽留弹窗
vipbackClose() { vipbackClose() {
this.vipPopRefresh=false; this.vipPopRefresh = false;
// this.showVip = false; // this.showVip = false;
this.showVipbackPop = false; this.showVipbackPop = false;
this.vipPopRefresh = true; this.vipPopRefresh = true;
}, },
// 价格挽留弹窗-支付成功回调 // 价格挽留弹窗-支付成功回调
vipbackpaySuccess(largeType) { vipbackpaySuccess(largeType) {
this.vipPopRefresh=false; this.vipPopRefresh = false;
this.showVip = false; this.showVip = false;
this.showVipbackPop = false; this.showVipbackPop = false;
......
...@@ -48,7 +48,7 @@ ...@@ -48,7 +48,7 @@
}, },
data: function() { data: function() {
return { return {
user: null, user: {},
fontSize: `18px`, fontSize: `18px`,
PRECENT_VALUE: 40 PRECENT_VALUE: 40
} }
...@@ -79,7 +79,9 @@ ...@@ -79,7 +79,9 @@
}, },
computed: { computed: {
contentSources: function() { contentSources: function() {
return [...this.detail.free , ...this.detail.charge]; return this.detail && this.detail.free && this.detail.charge ? [...this.detail.free,
...this.detail.charge
] : [];
}, },
preContentSources: function() { preContentSources: function() {
return this.detail && this.detail.free ? [...this.detail.free] : []; return this.detail && this.detail.free ? [...this.detail.free] : [];
......
<template> <template>
<view class="detail-buy"> <view class="detail-buy">
<view class="book-card"> <view class="book-card">
<view class="section" style="margin-top: 30rpx;">
<view v-if="!isVip() " class="section" style="margin-top: 30rpx;"> <button class="btn2" @click="tapVip">开通会员,免费阅读本书</button>
<button class="btn2" :disabled="loading" :loading="loading" @click="tapVip">开通会员,免费阅读本书</button>
</view> </view>
</view> </view>
<view class="warn-box"> <view class="warn-box">
...@@ -24,99 +23,13 @@ ...@@ -24,99 +23,13 @@
</template> </template>
<script> <script>
import Pack from "../../../../common/models/Pack.js";
import BookBeanPack from "../../../../common/models/BookBeanPack.js"
import {
showLoginView,
} from "../../../../common/services/userServices.js"
import {
buyBookWithBookBean
} from "../../../../common/services/index.js";
import {
toastHide,
toastLoading,
toastMessage
} from "../../../../common/utils/toastUtil.js";
export default { export default {
props: {
detail: {
type: Object,
default: function() {
return {}
}
},
userInfo: {
type: Object,
default: function() {
return null
}
},
showVipOpen: {
type: Number,
default: 1
},
showBeanOpen: {
type: Number,
default: 1
}
},
data: function() { data: function() {
return { return {}
selectedIndex: 0,
loading: false,
imageError: true
}
},
computed: {
bookBeanText: function() {
if (this.userInfo && this.detail) {
if (this.userInfo.bookLegumes < this.detail.bookLegumes) {
return '余额不足,立即充值'
}
}
return '全本订阅';
},
bookAllBeanCount: function() {
if (this.userInfo) return this.userInfo.bookLegumes
return 0;
},
bookBeanCount: function() {
return this.detail && this.detail.bookLegumes ? `${this.detail.bookLegumes}` : "免费"
},
},
mounted() {
}, },
methods: { methods: {
isVip() {
if (this.userInfo != null && this.userInfo.memberFlag) {
let cDate = new Date();
cDate = cDate.getTime();
return this.userInfo.memberExpirationDate >= cDate;
}
return false;
},
tapBeanBtn() {
let isIOS = wx.getSystemInfoSync().platform;
if (isIOS === 'ios') {
uni.showToast({
title: '暂不支持IOS系统',
icon: 'none'
})
return
}
if (this.userInfo && this.detail) {
if (this.userInfo.bookLegumes < this.detail.bookLegumes) {
this.tapBean()
return
}
}
this.tapBuy()
},
tapVip() { tapVip() {
let isIOS = wx.getSystemInfoSync().platform; let isIOS = tt.getSystemInfoSync().platform;
if (isIOS === 'ios') { if (isIOS === 'ios') {
uni.showToast({ uni.showToast({
title: '暂不支持IOS系统', title: '暂不支持IOS系统',
...@@ -127,41 +40,7 @@ ...@@ -127,41 +40,7 @@
} }
// 展示充值VIP弹框 // 展示充值VIP弹框
this.$emit('tapVip') this.$emit('tapVip')
},
tapBean() {
// 展示充值书豆弹框
this.$emit('tapBean')
},
tapBuy() {
if (!this.userInfo) {
uni.showModal({
title: "登录",
content: "购买前请前往登录系统",
success: (res) => {
if (res.confirm) {
showLoginView()
}
}
})
return;
} }
if (this.userInfo.bookLegumes < this.detail.bookLegumes) {
uni.showModal({
title: "余额不足",
content: `当前余额:${this.userInfo.bookLegumes}, 请前往充值`,
showCancel: false,
confirmText: "知道了"
})
return;
}
toastLoading("购买中");
buyBookWithBookBean(this.detail.id, (success, data) => {
toastHide();
if (success) {
this.$emit("unlockBook")
}
})
},
} }
} }
</script> </script>
...@@ -205,43 +84,6 @@ ...@@ -205,43 +84,6 @@
line-height: 80rpx; line-height: 80rpx;
} }
} }
.line-box {
display: flex;
flex-direction: row;
padding: 30rpx;
flex-wrap: wrap;
align-items: center;
.line {
width: 30%;
background-color: lightgray;
height: 1rpx;
}
.text {
text-align: center;
width: 36%;
color: lightgray;
font-size: 26rpx;
}
}
.text-box {
display: flex;
flex-direction: row;
.text1 {
font-size: 24rpx;
color: black;
}
.text2 {
padding: 0 10rpx;
font-size: 24rpx;
color: #DCBD3B;
}
}
} }
.warn-box { .warn-box {
......
...@@ -8,9 +8,6 @@ ...@@ -8,9 +8,6 @@
<setting-pop :show='showSetting' @close='closePop'></setting-pop> <setting-pop :show='showSetting' @close='closePop'></setting-pop>
<catalogue-pop :detail='bookData' :show='showCatalogue' @close='closeCataPop' :current="current" <catalogue-pop :detail='bookData' :show='showCatalogue' @close='closeCataPop' :current="current"
@tabVip='tapVipPop'></catalogue-pop> @tabVip='tapVipPop'></catalogue-pop>
<recommend-pop :show='showRecommend' @close='closeRecommendPop' :bookId="bookId"></recommend-pop>
<coin-popup v-if="bookData.isUnlock==0 && !isVip()" :show="showVip" @close="coinClose($event)" <coin-popup v-if="bookData.isUnlock==0 && !isVip()" :show="showVip" @close="coinClose($event)"
:vedioId="bookData.id" @paySuccess="paySuccess" :vipPopRefresh="vipPopRefresh"> :vedioId="bookData.id" @paySuccess="paySuccess" :vipPopRefresh="vipPopRefresh">
</coin-popup> </coin-popup>
...@@ -32,7 +29,6 @@ ...@@ -32,7 +29,6 @@
import { import {
collectionBook collectionBook
} from "../../../common/services/index.js" } from "../../../common/services/index.js"
import DetailWarn from "./components/detail-warn.vue";
import DetailThumb from "./components/detail-thumb.vue"; import DetailThumb from "./components/detail-thumb.vue";
import DetailContent from "./components/detail-content.vue"; import DetailContent from "./components/detail-content.vue";
import DetailBottom from "./components/detail-bottom.vue"; import DetailBottom from "./components/detail-bottom.vue";
...@@ -40,11 +36,8 @@ ...@@ -40,11 +36,8 @@
import config from "../../../config/index.js"; import config from "../../../config/index.js";
import SettingPop from "./components/setting-pop.vue"; import SettingPop from "./components/setting-pop.vue";
import CataloguePop from "./components/catalogue-pop.vue"; import CataloguePop from "./components/catalogue-pop.vue";
import VipPop from "./components/vip-pop.vue";
import BeanPop from "./components/bean-pop.vue";
import VipbackPopup from '@/components/vipback-popup/vipback-popup.vue'; import VipbackPopup from '@/components/vipback-popup/vipback-popup.vue';
import CoinPopup from "@/components/coin-popup/coin-popup.vue"; import CoinPopup from "@/components/coin-popup/coin-popup.vue";
import RecommendPop from "./components/recommend-pop.vue";
import SystemInfoMixin from "../../../common/mixins/system-info-mixin.js"; import SystemInfoMixin from "../../../common/mixins/system-info-mixin.js";
import { import {
gotoBookCoverPage gotoBookCoverPage
...@@ -53,13 +46,11 @@ ...@@ -53,13 +46,11 @@
watchUserInfoChange, watchUserInfoChange,
removeUserInfoChangeWatch, removeUserInfoChangeWatch,
refreshUserInfo, refreshUserInfo,
postPhone
} from "../../../common/services/userServices.js" } from "../../../common/services/userServices.js"
import { import {
noticeCollectionListChange, noticeCollectionListChange,
startCountReadTime, startCountReadTime,
endCountReadTime, endCountReadTime,
getOpens
} from "../../../common/services/index.js" } from "../../../common/services/index.js"
import { import {
saveStorage, saveStorage,
...@@ -88,11 +79,7 @@ ...@@ -88,11 +79,7 @@
showSetting: false, showSetting: false,
showCatalogue: false, showCatalogue: false,
showVip: false, showVip: false,
showBean: false,
showRecommend: false,
userInfo: null, userInfo: null,
showVipOpen: 0,
showBeanOpen: 0,
current: 1, current: 1,
height: 0, height: 0,
showVipbackPop: false, showVipbackPop: false,
...@@ -187,7 +174,7 @@ ...@@ -187,7 +174,7 @@
methods: { methods: {
// 解锁回调 // 解锁回调
paySuccess() { paySuccess() {
this.vipPopRefresh=false; this.vipPopRefresh = false;
this.showVip = false; this.showVip = false;
this.$set(this.bookData, "isUnlock", 1); this.$set(this.bookData, "isUnlock", 1);
...@@ -251,15 +238,11 @@ ...@@ -251,15 +238,11 @@
closeCataPop(e) { closeCataPop(e) {
this.showCatalogue = false; this.showCatalogue = false;
}, },
// 关闭推荐弹窗
closeRecommendPop(e) {
this.showRecommend = false;
},
changeCurrent(current) { changeCurrent(current) {
this.current = current this.current = current
}, },
coinClose(e) { coinClose(e) {
this.vipPopRefresh=false; this.vipPopRefresh = false;
let item = e.detail.data; let item = e.detail.data;
if (item != null) { if (item != null) {
...@@ -269,26 +252,15 @@ ...@@ -269,26 +252,15 @@
}, 300); }, 300);
} else { } else {
this.showVip = false; this.showVip = false;
// if (this.bookData.isUnlock == 0) {
// setTimeout(() => {
// this.showRecommend = true;
// }, 300);
// }
} }
}, },
vipbackClose() { vipbackClose() {
// this.showVip = false; // this.showVip = false;
this.showVipbackPop = false; this.showVipbackPop = false;
this.vipPopRefresh = true; this.vipPopRefresh = true;
// if (this.bookData.isUnlock == 0) {
// setTimeout(() => {
// this.showRecommend = true;
// }, 300);
// }
}, },
vipbackpaySuccess(largeType) { vipbackpaySuccess(largeType) {
this.vipPopRefresh=false; this.vipPopRefresh = false;
this.showVip = false; this.showVip = false;
this.showVipbackPop = false; this.showVipbackPop = false;
......
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