Commit 0f160df4 authored by jyx's avatar jyx

代码优化

parent c13fbd42
......@@ -2,10 +2,8 @@
<z-paging :style="[bgStyle]">
<template>
<detail-thumb :detail='bookData'></detail-thumb>
<detail-content @tapVip='tapVipPop' :detail='bookData' :userInfo='userInfo'></detail-content>
<detail-new-buy v-if="bookData.isUnlock==0 && !isVip()"
:detail='bookData' :userInfo='userInfo' @tapVip='tapVipPop'
></detail-new-buy>
<detail-content :detail='bookData' :userInfo='userInfo' @tapVip='tapVipPop'></detail-content>
<detail-new-buy v-if="bookData.isUnlock==0 && !isVip()" @tapVip='tapVipPop'></detail-new-buy>
<detail-bottom :detail='bookData' :userInfo='userInfo' @tapBottomItem='tapBottomItem'></detail-bottom>
<setting-pop :show='showSetting' @close='closePop'></setting-pop>
<coin-popup v-if="bookData.isUnlock==0 && !isVip()" :show="showVip" @close="coinClose($event)"
......@@ -32,7 +30,7 @@
collectionBook
} from "../../../common/services/index.js"
import DetailThumb from "./components/detail-thumb.vue";
import DetailContent from "./components/detail-content.vue";
import DetailContent from "./components/detail-content.vue";
import DetailNewBuy from "./components/detail-new-buy.vue";
import DetailBottom from "./components/detail-bottom.vue";
import config from "../../../config/index.js";
......@@ -56,21 +54,21 @@
DetailThumb,
DetailContent,
DetailBottom,
SettingPop,
SettingPop,
DetailNewBuy,
VipbackPopup,
CoinPopup,
},
data() {
return {
bookId: null,
bookData: null,
bookId: '',
bookData: {},
backgroundColor: "#fff",
showSetting: false,
showVip: false,
userInfo: null,
userInfo: {},
showVipOpen: 0,
showVipbackPop: false,
showVipbackPop: false,
vipPopRefresh: false,
backvipBean: null,
};
......@@ -135,9 +133,6 @@
return result;
},
computed: {
showEmpty: function() {
return isEmpty(this.bookData)
},
bgStyle: function() {
let height = 300;
if (this.windowHeight) {
......@@ -162,10 +157,6 @@
}
},
methods: {
// 解锁回调
unlockBook() {
this.$set(this.bookData, "isUnlock", true);
},
// 文章数据刷新
refreshBookData(bookId) {
getBookDetailData(bookId, (success, data) => {
......@@ -215,10 +206,10 @@
// 关闭设置弹窗
closePop(e) {
this.showSetting = false;
},
},
// 价格弹窗
coinClose(e) {
this.vipPopRefresh=false;
coinClose(e) {
this.vipPopRefresh = false;
let item = e.detail.data;
if (item != null) {
......@@ -229,18 +220,18 @@
} else {
this.showVip = false;
}
},
},
// 价格挽留弹窗
vipbackClose() {
this.vipPopRefresh=false;
vipbackClose() {
this.vipPopRefresh = false;
// this.showVip = false;
this.showVipbackPop = false;
this.showVipbackPop = false;
this.vipPopRefresh = true;
},
},
// 价格挽留弹窗-支付成功回调
vipbackpaySuccess(largeType) {
this.vipPopRefresh=false;
this.showVip = false;
vipbackpaySuccess(largeType) {
this.vipPopRefresh = false;
this.showVip = false;
this.showVipbackPop = false;
this.$set(this.bookData, "isUnlock", true);
......
......@@ -48,7 +48,7 @@
},
data: function() {
return {
user: null,
user: {},
fontSize: `18px`,
PRECENT_VALUE: 40
}
......@@ -79,7 +79,9 @@
},
computed: {
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() {
return this.detail && this.detail.free ? [...this.detail.free] : [];
......
<template>
<view class="detail-buy">
<view class="book-card">
<view v-if="!isVip() " class="section" style="margin-top: 30rpx;">
<button class="btn2" :disabled="loading" :loading="loading" @click="tapVip">开通会员,免费阅读本书</button>
<view class="section" style="margin-top: 30rpx;">
<button class="btn2" @click="tapVip">开通会员,免费阅读本书</button>
</view>
</view>
<view class="warn-box">
......@@ -24,99 +23,13 @@
</template>
<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 {
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() {
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() {
return {}
},
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() {
let isIOS = wx.getSystemInfoSync().platform;
let isIOS = tt.getSystemInfoSync().platform;
if (isIOS === 'ios') {
uni.showToast({
title: '暂不支持IOS系统',
......@@ -127,41 +40,7 @@
}
// 展示充值VIP弹框
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>
......@@ -205,43 +84,6 @@
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 {
......
......@@ -8,9 +8,6 @@
<setting-pop :show='showSetting' @close='closePop'></setting-pop>
<catalogue-pop :detail='bookData' :show='showCatalogue' @close='closeCataPop' :current="current"
@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)"
:vedioId="bookData.id" @paySuccess="paySuccess" :vipPopRefresh="vipPopRefresh">
</coin-popup>
......@@ -32,7 +29,6 @@
import {
collectionBook
} from "../../../common/services/index.js"
import DetailWarn from "./components/detail-warn.vue";
import DetailThumb from "./components/detail-thumb.vue";
import DetailContent from "./components/detail-content.vue";
import DetailBottom from "./components/detail-bottom.vue";
......@@ -40,11 +36,8 @@
import config from "../../../config/index.js";
import SettingPop from "./components/setting-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 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 {
gotoBookCoverPage
......@@ -53,13 +46,11 @@
watchUserInfoChange,
removeUserInfoChangeWatch,
refreshUserInfo,
postPhone
} from "../../../common/services/userServices.js"
import {
noticeCollectionListChange,
startCountReadTime,
endCountReadTime,
getOpens
} from "../../../common/services/index.js"
import {
saveStorage,
......@@ -88,14 +79,10 @@
showSetting: false,
showCatalogue: false,
showVip: false,
showBean: false,
showRecommend: false,
userInfo: null,
showVipOpen: 0,
showBeanOpen: 0,
current: 1,
height: 0,
showVipbackPop: false,
showVipbackPop: false,
vipPopRefresh: false,
backvipBean: null,
};
......@@ -186,8 +173,8 @@
},
methods: {
// 解锁回调
paySuccess() {
this.vipPopRefresh=false;
paySuccess() {
this.vipPopRefresh = false;
this.showVip = false;
this.$set(this.bookData, "isUnlock", 1);
......@@ -251,15 +238,11 @@
closeCataPop(e) {
this.showCatalogue = false;
},
// 关闭推荐弹窗
closeRecommendPop(e) {
this.showRecommend = false;
},
changeCurrent(current) {
this.current = current
},
coinClose(e) {
this.vipPopRefresh=false;
coinClose(e) {
this.vipPopRefresh = false;
let item = e.detail.data;
if (item != null) {
......@@ -269,26 +252,15 @@
}, 300);
} else {
this.showVip = false;
// if (this.bookData.isUnlock == 0) {
// setTimeout(() => {
// this.showRecommend = true;
// }, 300);
// }
}
},
vipbackClose() {
// this.showVip = false;
this.showVipbackPop = false;
this.showVipbackPop = false;
this.vipPopRefresh = true;
// if (this.bookData.isUnlock == 0) {
// setTimeout(() => {
// this.showRecommend = true;
// }, 300);
// }
},
vipbackpaySuccess(largeType) {
this.vipPopRefresh=false;
vipbackpaySuccess(largeType) {
this.vipPopRefresh = false;
this.showVip = 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