Commit ee3b8180 authored by jyx's avatar jyx

代码优化

parent bae59d4e
......@@ -262,16 +262,6 @@ function getPayInfo(id, amount, openId, callback, typeId = ENUM_PAY_TYPE.VIP.val
})
}
function getPayInfoDy(pid) {
apiPOST({
url: `/vip/getVipPayParams/douyin`,
data: {
pid: pid
},
callback
})
}
/**
* 获取书豆套餐数据
......@@ -318,7 +308,6 @@ module.exports = {
getOpenId,
getFeedback,
ENUM_PAY_TYPE,
getPayInfoDy,
getPayInfo,
buyBookWithBookBean,
......
......@@ -29,7 +29,7 @@ function gotoBookContentPage(bookId, shortis) {
function gotoShortBookContentPage(bookId) {
// 短篇小说
uni.navigateTo({
url: `/page-subs/sub_A/book-content/book-content`,
url: `/page-subs/sub_A/book-content/book-content?bookId=` + bookId,
success: (res) => {
res.eventChannel.emit("openBookContentPage", {
bookId
......@@ -41,7 +41,7 @@ function gotoShortBookContentPage(bookId) {
// 长篇文章详情
function gotoLongBookContentPage(bookId) {
uni.navigateTo({
url: `/page-subs/sub_A/book-long-content/book-long-content`,
url: `/page-subs/sub_A/book-long-content/book-long-content?bookId=` + bookId,
success: (res) => {
res.eventChannel.emit("openBookContentPage", {
bookId
......
......@@ -114,7 +114,7 @@ function refreshUserInfo() {
id: userData.idcode,
memberExpirationDate: userData.expireTime
})
saveNickname(userData.nickname);
// saveNickname(userData.nickname);
saveUserInfo(user); // 存储用户数据
postNotification(KEY_NOTIFICATION_LOGIN_SUCCESS); // 通知登录成功
}
......@@ -147,7 +147,7 @@ function postPhone(data, callback) {
// 请求token
function requestToken(data, callback) {
let url = `${config["BASE_URL"]}/user/wechatlogin`;
let url = `${config["BASE_URL"]}/user/ksLogin`;
let header = {
pkgName: PAKEAGE_NAME,
version: VERSION_CODE,
......
<template>
<z-paging>
<c-navi id='navi'></c-navi>
<!-- <c-navi id='navi'></c-navi> -->
<book-search-box id='search' :searchType='searchType'></book-search-box>
<read-time-count-row id='count' ref='timeCount' @resize='resizeTimeCount'></read-time-count-row>
<BookshelfList ref='bookList' :height='listHeight'></BookshelfList>
......
<template>
<view v-if="false" class="c-empty" :style="[emptyStyle]">
<view class="c-empty" :style="[emptyStyle]">
<image class='empty-image' :style="[emptyImgStyle]" :src='emptyImg'>
</image>
<view class="empty-title" :style="[emptyTitleStyle]">
......
......@@ -203,7 +203,9 @@
if (this.refreshTrigger) {
this.refreshTrigger = false;
}
this.refreshTrigger = true;
this.refreshTrigger = true;
this.refresh()
},
closeTrigger() {
if (!this.refreshTrigger) {
......@@ -230,7 +232,7 @@
}
},
/** 外部触发 变更trigger list 响应 refresh 接口 */
onPullRefreshing() {
onPullRefreshing() {
if (this.loading && !this.customRequest) {
this.closeTrigger();
return;
......@@ -238,7 +240,7 @@
this.openTrigger();
},
/** 响应触发 响应 list 回调 */
refresh() {
refresh() {
if (this.loading && !this.customRequest) { // loading 用于内部数据判断标识, 所以要判断是否启用 customeRequest
this.closeTrigger();
return;
......@@ -274,10 +276,10 @@
}
},
/** customeRequst 不会使用的接口*/
requestData() {
requestData() {
if (this.needLogin && !this.userInfo) {
this.loading = false;
this.closeTrigger();
this.closeTrigger();
return;
}
this.loading = true;
......
......@@ -132,7 +132,7 @@
}
this.post({
url: '/vip/getVipProducts/cyc',
url: '/vip/getVipProducts',
data: {
bookId: that.vedioId
},
......@@ -199,83 +199,36 @@
message.notify('暂不支持ios系统~');
} else {
this.post({
url: '/vip/getVipPayParams/wechat',
url: '/vip/getVipPayParams/kuaishou',
data: {
pid: vipBean.pid,
payChannel: 'WEIXIN'
payChannel: 'kuaishou'
},
showLoading: true,
success: ({
data
}) => {
if (vipBean.firstPayPrice == 0) {
//签约
that.wxSign(data, vipBean.largeType);
} else {
//普通支付
that.wxPay(data, vipBean.largeType);
}
//普通支付
that.wxPay(data, vipBean.largeType);
}
});
}
},
wxPay(wxData, largeType) {
let wxParams = wxData.params;
ksPay(wxData, largeType) {
let that = this;
// 发起微信支付
wx.requestPayment({
timeStamp: wxParams.timeStamp,
nonceStr: wxParams.nonceStr,
package: wxParams.packageStr,
signType: wxParams.signType,
paySign: wxParams.paySign,
success(res) {
ks.pay({
serviceId: '1',
orderInfo: ksData.params,
// paymentChannel: ksData.params.paymentChannel,
success() {
message.notify('支付成功')
that.queryOrderStatus(largeType, wxData.tidStr);
},
fail(res) {}
})
},
wxSign(wxData, largeType) {
let wxParams = wxData.params;
let that = this;
// 发起微信签约
wx.navigateToMiniProgram({
appId: "wxbd687630cd02ce1d",
path: 'pages/index/index',
extraData: wxData.params,
success(res) {
console.log("wxSign suc=", res);
if (res.return_code == 'SUCCESS') {
console.log("wxSign suc1111");
// 成功跳转到签约小程序
that.queryOrderStatus(largeType, wxData.tidStr);
} else {
// 签约失败
console.log("wxSign fail22222");
}
fail() {
message.notify('支付失败');
},
fail(res) {
// 未成功跳转到签约小程序
console.log("wxSign fail=3333", res);
}
})
},
queryOrderStatus(largeType, tid) {
let that = this;
this.post({
data: {
tid: tid
},
url: '/vip/queryVipOrder',
showLoading: true,
success: ({
data
}) => {
that.paySuccess(largeType);
}
});
}
},
watch: {
show: {
......
......@@ -16,6 +16,7 @@
import {
isEmpty
} from '../../../common/utils/util'
import { login } from '../../../utils/fun';
import WarehouseBookItem from '../models/WarehouseBookItem.js';
export default {
components: {},
......@@ -53,7 +54,7 @@
refreshList() {
this.$nextTick(() => {
let ref = this.$refs.list;
if (ref) {
if (ref) {
ref.onPullRefreshing();
}
})
......@@ -63,7 +64,7 @@
return new WarehouseBookItem(item)
})
},
tapItem(e, index) {
tapItem(e, index) {
gotoBookContentPage(e.detail.data.id, e.detail.data.shortis)
},
tapClose(e, index) {
......
<template>
<z-paging>
<c-navi id='navi'></c-navi>
<view>
<book-search-box id='search'></book-search-box>
<CategoryBar id='category' :range='categorys' :current='currentIndex' @change='changeCategory'
@ready='readyCategory'></CategoryBar>
<view :style="[listStyle]" v-if='showEmpty'>
<c-empty emptyTitle="暂无数据"></c-empty>
<c-empty emptyTitle="正在加载中~"></c-empty>
</view>
<view :style="[listStyle]" v-else>
<swiper :style="[listStyle]" :indicator-dots="false" :autoplay="false" :current="currentIndex"
......@@ -16,8 +15,8 @@
</swiper-item>
</swiper>
</view>
<c-login></c-login>
</z-paging>
<!-- <c-login></c-login> -->
</view>
</template>
<script>
......@@ -80,13 +79,6 @@
setTimeout(() => {
this.$refs[`bookList${n.currentIndex}`][0].initRefresh();
}, 500)
// this.$nextTick(() => {
// // this.$refs[`bookList${n.currentIndex}`][0].initRefresh();
// let ref = this.$refs.bookList;
// if (ref) {
// ref[n.currentIndex].initRefresh();
// }
// })
},
deep: true
}
......@@ -119,7 +111,7 @@
if (success) {
setTimeout(() => {
// 匹配用户直接跳转小说
if (data.articleMsg != null) {
if (data.articleMsg != null) {
gotoBookContentPage(data.articleMsg.id, data.articleMsg.shortis);
}
}, 800);
......@@ -145,14 +137,15 @@
},
initHeight() {
const query = uni.createSelectorQuery().in(this);
query.select("#navi").boundingClientRect();
query.select("#search").boundingClientRect();
query.select("#category").boundingClientRect();
query.exec((res) => {
let result = 0;
var result = 0;
res.forEach(item => {
if (item) {
result = result + item.height;
if (item.height) {
result = result + item.height;
}
}
})
this.listHeight = this.windowHeight - result - (this.windowHeight * 0.1);
......
<template>
<view style="padding-top: 50rpx;">
<profile-header :userInfo='userInfo'></profile-header>
<CategoryBar id='category' :range='categorys' :current='currentIndex' @change='changeCategory'
@ready='readyCategory'></CategoryBar>
<view :style="[listStyle]" v-if='showEmpty'>
<c-empty emptyTitle="暂无数据"></c-empty>
</view>
<view :style="[listStyle]" v-else>
<swiper :style="[listStyle]" :indicator-dots="false" :autoplay="false" :current="currentIndex"
@change="changeSwiper">
<swiper-item v-for='(item, index) in categorys' :key='index'>
<WarehouseList ref='bookList' :category='item' :height='listHeight'></WarehouseList>
</swiper-item>
</swiper>
</view>
<c-login></c-login>
</view>
</template>
<script>
import ProfileHeader from "./components/profile-headertemp.vue";
import {
watchUserInfoChange,
refreshUserInfo
} from "../../common/services/userServices.js"
import CategoryBar from "./components/category-bar.vue";
import WarehouseList from "./components/warehouse-list.vue";
import SystemInfoMixin from "../../common/mixins/system-info-mixin.js";
import Category from "./models/Category.js";
import {
getCategorys
} from "./services/index.js"
import {
isEmpty
} from "../../common/utils/util";
import {
readStorage,
saveStorage
} from '../../common/utils/storageUtil';
export default {
mixins: [SystemInfoMixin],
components: {
CategoryBar,
ProfileHeader,
WarehouseList
},
data() {
return {
userInfo: null,
listHeight: 0,
categorys: [],
currentIndex: 0
};
},
onLoad() {
},
computed: {
showEmpty: function() {
return isEmpty(this.categorys);
},
listStyle: function() {
return {
height: `${this.listHeight}px`
}
},
categroyChange: function() {
const {
categorys,
currentIndex
} = this;
return {
categorys,
currentIndex
}
}
},
watch: {
categroyChange: {
handler: function(n, o) {
this.$nextTick(() => {
let ref = this.$refs.bookList;
if (ref) {
ref[n.currentIndex].initRefresh();
}
})
},
deep: true
}
},
methods: {
show(){
console.log("123123123")
this.getCategoryData();
watchUserInfoChange((info) => {
this.userInfo = info.userInfo
}, this);
this.refreshUserData();
},
hide() {
},
readyCategory() {
setTimeout(() => {
this.initHeight()
}, 300)
},
getCategoryData() {
getCategorys((success, data) => {
if (success) {
let result = data ? data.map(item => {
return new Category(item)
}).sort((a, b) => {
return a.sort - b.sort
}) : [];
result.unshift(new Category({
name: "全部",
id: ""
}))
this.categorys = result;
}
})
},
initHeight() {
const query = uni.createSelectorQuery().in(this);
// query.select("#navi").boundingClientRect();
// query.select("#search").boundingClientRect();
query.select("#category").boundingClientRect();
query.exec((res) => {
let result = 0;
res.forEach(item => {
result = result + item.height;
})
this.listHeight = this.windowHeight - result;
})
},
changeCategory(e) {
this.changeCurrent(e.index);
},
changeSwiper(e) {
this.changeCurrent(e.detail.current);
},
changeCurrent(index) {
if (index != this.currentIndex) {
this.currentIndex = index;
}
},
refreshUserData() {
if (this.userInfo) {
refreshUserInfo();
}
}
}
}
</script>
<style lang="scss">
.name {
font-size: 34rpx;
font-weight: 700;
}
</style>
\ No newline at end of file
<template>
<z-paging :style="[bgStyle]">
<c-empty v-if='showEmpty'></c-empty>
<template v-else>
<template v-if="bookData">
<detail-warn></detail-warn>
<detail-thumb :detail='bookData' @tapThumb='tapThumb'></detail-thumb>
<detail-content @tapVip='tapPayPop' :detail='bookData' :userInfo='userInfo'></detail-content>
......@@ -18,6 +17,7 @@
:vedioId="bookData.id" @paySuccess="paySuccess">
</coin-popup>
</template>
<c-empty v-else emptyTitle="正在加载中~"></c-empty>
<c-login :isShareLink="true"></c-login>
<popup :show="showMoibleLogin" @close="showMoibleLogin=false">
<view>
......@@ -142,14 +142,14 @@
uni.startPullDownRefresh({})
})
// 绑定分享参数
// #ifdef MP-WEIXIN
wx.onCopyUrl(() => {
return {
query: `bookId=${this.bookData.id}`
}
})
// #endif
// // 绑定分享参数
// // #ifdef MP-KUAISHOU
// ks.onCopyUrl(() => {
// return {
// query: `bookId=${this.bookData.id}`
// }
// })
// // #endif
},
onShow() {
refreshUserInfo();
......@@ -167,10 +167,10 @@
removeContentFormatChangeWatch(this);
removeUserInfoChangeWatch(this);
// 取消绑定分享参数
// #ifdef MP-WEIXIN
wx.offCopyUrl()
// #endif
// // 取消绑定分享参数
// // #ifdef MP-KUAISHOU
// ks.offCopyUrl()
// // #endif
},
onPullDownRefresh() {
this.refreshBookData(this.bookId)
......@@ -282,7 +282,7 @@
}
})
break;
case 'setting': // 设置
case 'setting': // 设置
this.showSetting = true;
break;
default:
......@@ -321,7 +321,7 @@
this.showBean = true;
},
// 关闭设置弹窗
closePop(e) {
closePop(e) {
this.showSetting = false;
},
// 关闭会员弹窗
......
......@@ -12,12 +12,13 @@ import {
apiGET,
apiPOST
} from "../../../../common/utils/apiRequest.js"
import Book from "../../../../common/models/Book";
/** 获取文章详情
* @param {Object} bookId
* @param {Object} callback
*/
function getBookDetailData(bookId, callback) {
function getBookDetailData(bookId, callback) {
apiPOST({
url: `/book/info`,
data: {
......
<template>
<view v-if="localActiviteFlag==1" class="body">
<view class="body">
<view style="height: 92%;">
<bookshelf v-show="currentPage==0" ref="index" />
<warehouse v-show="currentPage==1" ref="recommend" />
......@@ -36,22 +36,6 @@
</view>
</view>
</view>
<view v-else class="body">
<view
:style="'display: flex;flex-direction: row;align-items: center;margin: 20rpx;padding-left: 10rpx;margin-top:'+10+'px;'">
<image class="avatar" src="@/static/logo-about.png"></image>
<view>
<view style="font-size: 34rpx;color: black;margin-left: 30rpx;">用户ID:{{localIdcode}}</view>
<view style="font-size: 26rpx;color: #b5b5b5;margin-left: 30rpx;margin-top: 10rpx;">
书中自有颜如玉,书中自有黄金屋,书中自有千钟黍</view>
</view>
</view>
<view style="height: 92%;">
<warehouse v-show="currentPage==1" ref="recommend" />
</view>
</view>
</template>
<script>
......@@ -77,13 +61,11 @@
data() {
return {
currentPage: 1,
localActiviteFlag: 0,
localIdcode: 0,
}
},
onLoad(options) {
let index = options.index ?? ''
this.localActiviteFlag = options.activiteFlag;
this.localIdcode = options.idcode;
if (index != '' && index != undefined) {
this.currentPage = index
......@@ -107,13 +89,6 @@
// 渲染完成 初始化首页数据
this.loadComponentData();
let that = this
if (this.localActiviteFlag == 1) {
uni.$on('goWareHouse', function(data) {
that.tabChange(1)
})
}
uni.$on('refreshPreviousPage', (data) => {
if (data.vipFlag == '1') {
......@@ -131,18 +106,12 @@
this.loadComponentData();
},
loadComponentData() {
if (this.localActiviteFlag == 1) {
if (this.currentPage == 0) {
this.$refs.index.show();
} else if (this.currentPage == 1) {
this.$refs.recommend.show();
} else if (this.currentPage == 2) {
this.$refs.user.show();
}
} else {
if (this.currentPage == 1) {
this.$refs.recommend.show();
}
if (this.currentPage == 0) {
this.$refs.index.show();
} else if (this.currentPage == 1) {
this.$refs.recommend.show();
} else if (this.currentPage == 2) {
this.$refs.user.show();
}
}
}
......
......@@ -46,10 +46,10 @@
this.tips1 = options.tips1
},
onShow(options) {
this.ttLoging()
this.ksLoging()
},
methods: {
ttLoging() {
ksLoging() {
var that = this;
var obj = ks.getLaunchOptionsSync()
......@@ -89,11 +89,8 @@
app.globalData.userId = data.idcode;
saveToken(data.token)
setTimeout(() => {
redirectTo('home?activiteFlag=' + data.activiteFlag +
"&idcode=" + data.idcode);
// redirectTo('/pagesA/vipPay/vipPay');
}, 1000);
redirectTo('home?&idcode=' + data.idcode);
}, 500);
}
});
},
......
......@@ -43,21 +43,21 @@
</view>
<view class="trialStyle">
<text v-if="hintText">
<text v-if="hintText">
{{hintText}}
</text>
</view>
<view class="agreementWrp">
<checkbox-group @change="checkboxChange" style="width: 50rpx;">
<checkbox-group @change="checkboxChange" style="width: 50rpx; margin-right: 10rpx;">
<checkbox :checked="checked" style="transform:scale(0.9)">
</checkbox>
</checkbox-group>
<text>您已阅读并同意
<view>您已阅读并同意
<text class="agreementText" @click="goAgreement(1)">《连续订阅服务协议》</text>
<text class="agreementText" @click="goAgreement(2)">《支付协议》</text>
<text class="agreementText" @click="goAgreement(3)">《隐私政策》</text>
</text>
</view>
</view>
<view class="section">
......@@ -98,7 +98,7 @@
}
this.post({
url: '/vip/getVipProducts/cyc',
url: '/vip/getVipProducts',
showLoading: false,
success: ({
data
......@@ -163,58 +163,27 @@
message.notify('暂不支持ios系统~');
} else {
this.post({
url: '/vip/getVipPayParams/wechat',
url: '/vip/getVipPayParams/kuaishou',
data: {
pid: vipBean.pid,
payChannel: 'WEIXIN'
payChannel: 'kuaishou'
},
showLoading: true,
success: ({
data
}) => {
if (vipBean.firstPayPrice == 0) {
//签约
that.wxSign(data, vipBean.largeType);
} else {
//普通支付
that.wxPay(data, vipBean.largeType);
}
that.ksPay(data);
}
});
}
},
wxSign(wxData, largeType) {
ksPay(ksData) {
let that = this;
// 发起微信签约
wx.navigateToMiniProgram({
appId: "wxbd687630cd02ce1d",
path: 'pages/index/index',
extraData: wxData.params,
success(res) {
message.notify('支付成功')
setTimeout(() => {
navigateBack();
}, 1000);
},
fail(res) {
// 未成功跳转到签约小程序
console.log("wxSign fail=", res);
}
})
},
wxPay(wxData) {
let wxParams = wxData.params;
let that = this;
// 发起微信支付
wx.requestPayment({
timeStamp: wxParams.timeStamp,
nonceStr: wxParams.nonceStr,
package: wxParams.packageStr,
signType: wxParams.signType,
paySign: wxParams.paySign,
success(res) {
ks.pay({
serviceId: '1',
orderInfo: ksData.params,
// paymentChannel: ksData.params.paymentChannel,
success() {
message.notify('支付成功')
setTimeout(() => {
......@@ -226,9 +195,9 @@
});
}, 1000);
},
fail(res) {
message.notify('取消支付')
}
fail() {
message.notify('支付失败');
},
})
},
checkboxChange(e) {
......@@ -353,8 +322,8 @@
}
.label {
margin-top: -4rpx;
margin-left: -4rpx;
// margin-top: -4rpx;
// margin-left: -4rpx;
border-radius: 20rpx 0 20rpx 0;
width: 80%;
background: linear-gradient(90deg, #FC4F3B, #FBCB7A);
......@@ -370,9 +339,9 @@
}
.label2 {
margin-bottom: -4rpx;
margin-left: -4rpx;
margin-right: -4rpx;
// margin-bottom: -4rpx;
// margin-left: -4rpx;
// margin-right: -4rpx;
width: 100%;
border-radius: 0 0 20rpx 20rpx;
background-color: #FC4F3B;
......@@ -408,7 +377,8 @@
color: darkgray;
font-size: 26rpx;
margin-top: 30rpx;
padding-left: 30rpx;
padding: 0 30rpx;
.agreementText {
color: #387EF4;
......@@ -416,7 +386,7 @@
}
}
.trialStyle {
.trialStyle {
height: 60rpx;
padding: 40rpx;
font-size: 22rpx;
......
export const PAKEAGE_NAME = 'com.mingce.wxhelibook'
export const VERSION_CODE = '1.0.3'
// export const PAKEAGE_NAME = 'com.test.test'
export const PAKEAGE_NAME = 'com.mingce.kshelibook'
export const VERSION_CODE = '1.0.0'
export function trim(str) {
return str ? str.replace(/(^\s*)|(\s*$)/g, "") : ''
......
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