diff --git a/pages/clock/clock.vue b/pages/clock/clock.vue index 1587d06..51dd9bf 100644 --- a/pages/clock/clock.vue +++ b/pages/clock/clock.vue @@ -18,23 +18,8 @@ 今天已签到 - - - - + + diff --git a/pages/eBook/bookContent.vue b/pages/eBook/bookContent.vue index 452d918..07164f3 100644 --- a/pages/eBook/bookContent.vue +++ b/pages/eBook/bookContent.vue @@ -18,8 +18,9 @@

--> - + + diff --git a/pages/peanut/home.vue b/pages/peanut/home.vue index d06ce95..2d00839 100644 --- a/pages/peanut/home.vue +++ b/pages/peanut/home.vue @@ -5,43 +5,43 @@ - + 请输入想要搜索的书名 - + 搜索 - + - - - - 读书打卡 - - - + + + + 读书打卡 + + + 听书 - - - + + + 书评 - + 图书馆 - + - + @@ -98,124 +98,44 @@ - + 新书上市 - - + + - - - - - - {{item.productName}} + + + + + {{item.productName}} + - - - - - - {{item.bookName}} - {{item.authorName}} [著] - VIP - 付费 - -
- - - {{item.bookName}} - {{item.authorName}} [著] - VIP - 付费 - -
-
- - - - - - - - 限时特价 - 查看更多 > - - - - - - {{item.bookName}} - {{item.authorName}} [著] - {{item.price}}疯币 - {{item.salePrice}}疯币 - VIP - 付费 - - - - - - - - - 精选书单 - 查看更多 > - - - - - {{item.bookName}} - {{item.authorName}} - - - - 出版社:{{item.publisherName}} - - - {{item.introduce | ellipsis}} - - - - VIP - 付费 - - - +
+ - 精选图书 + 精选商品 - + 查看更多 > - - - - - + + - {{item.name}} + {{item.productName}} - - - - - - - - - {{item.authorName}}     -    /  {{item.publisherName}}   - + + ¥{{item.price}} + 已售:{{item.sumSales}} 件 @@ -235,7 +155,7 @@ - + @@ -245,25 +165,26 @@ import repciptData from '@/static/json/repcipt.json' import $http from '@/config/requestConfig.js'; import { - mapState,mapMutations + mapState, + mapMutations } from 'vuex'; export default { data() { return { - myList:[], - showEbook:false, // 显示电子书相关 + myList: [], + showEbook: false, // 显示电子书相关 transaction: { // 成功回调 - + }, - status:3, - jPage:1, - jTotal:0, - scrollLeft:0, - maxTimes:1, // 轮询最大次数 - ComplateRequestInterval:null, // 轮询定时器 - checking:false, // 正在检测 - ComplateRequestArr:[], - iapChannel:null, + status: 3, + jPage: 1, + jTotal: 0, + scrollLeft: 0, + maxTimes: 1, // 轮询最大次数 + ComplateRequestInterval: null, // 轮询定时器 + checking: false, // 正在检测 + ComplateRequestArr: [], + iapChannel: null, scrollTop: 0, list3: [ // '../../static/icon/home_ban_1.jpg', @@ -278,7 +199,7 @@ bgiStyle: { background: '#fff' }, - newBookList:[], + newBookList: [], iconStyle: { fontSize: '40rpx', fontWeight: 'bold', @@ -293,16 +214,16 @@ onLoad(e) { // 隐藏原生的tabbar uni.hideTabBar(); - // this.requestIapOrder() + // this.requestIapOrder() }, //页面显示 onShow() { // 隐藏原生的tabbar uni.hideTabBar(); this.goodsList = [] - this.getData(); - - + this.getData(); + + }, // 页面加载完毕 onReady() { @@ -315,22 +236,21 @@ this.goodsList = [] this.getData() uni.stopPullDownRefresh() - this.requestIapOrder() + this.requestIapOrder() }, onHide() { this.jPage = 1 this.goodsList = [] - + }, onReachBottom() { console.log('到底了') - - if(this.jPage+1 <= this.jTotal){ - this.jPage++ - this.getJBook() - }else{ - this.status = 1 - } + // if (this.jPage + 1 <= this.jTotal) { + // this.jPage++ + // this.getJBook() + // } else { + // this.status = 1 + // } }, filters: { // 控制字数 @@ -348,72 +268,72 @@ computed: { ...mapState(['userInfo']), }, - components:{ + components: { musicPlay }, //方法 methods: { ...mapMutations(['setUserInfo']), - gotopingshu(val){ + gotopingshu(val) { uni.navigateTo({ - url: '../comments/comments?bookid='+ val.id, + url: '../comments/comments?bookid=' + val.id, }); }, // 去打卡 - gotoclock(item){ - this.onPageJump('../clock/clock?bookid='+ item.id ) + gotoclock(item) { + this.onPageJump('../clock/clock?bookid=' + item.id) }, // 去听书 - gotoListen(item){ - uni.navigateTo({ - url: "../listen/listen?bookid="+ item.id + gotoListen(item) { + uni.navigateTo({ + url: "../listen/listen?bookid=" + item.id }); }, // 新书上市 - getNewBook(){ + getNewBook() { this.$http - .post('book/shopproduct/getNewBook',{ + .post('book/shopproduct/getNewBook', { 'limit': 10, - 'page':1 + 'page': 1 }) .then(res => { - console.log(res,'xinshu') - this.newBookList = res.page.list + console.log(res, 'xinshu') + this.newBookList = res.page.list }); }, // 检测未完成订单 - requestIapOrder(){ + requestIapOrder() { console.log('检测支付环境...') plus.payment.getChannels((channels) => { console.log(channels, 'channels') //this.setUserInfo({channelList:channels}); // 将支付通道保存到本地 - for (var i in channels) { + for (var i in channels) { // 判断是否苹果支付1 if (channels[i].id === 'appleiap') { - this.iapChannel = channels[i] + this.iapChannel = channels[i] // console.log(this.userInfo.restoreFlag,'this.userInfo.restoreFlag') - if(this.userInfo.restoreFlag){ // 如果存在异常回调订单 + if (this.userInfo.restoreFlag) { // 如果存在异常回调订单 this.restoreComplateRequest() } } - } + } }) }, - // 查询未关闭订单 - restoreComplateRequest(){ + // 查询未关闭订单 + restoreComplateRequest() { let that = this console.log('检测未完成订单') - console.log(this.iapChannel,'this.iapChannel') + console.log(this.iapChannel, 'this.iapChannel') this.iapChannel.restoreComplateRequest({ manualFinishTransaction: true - }, function(results) { - if(!that.checking){ - that.checking = true - // console.log(that.checking) - // results 格式为数组存放恢复的IAP商品交易信息对象 IAPTransaction,通用需将返回的支付凭证传给后端进行二次认证 + }, function(results) { + if (!that.checking) { + that.checking = true + // console.log(that.checking) + // results 格式为数组存放恢复的IAP商品交易信息对象 IAPTransaction,通用需将返回的支付凭证传给后端进行二次认证 that.ComplateRequestArr = results - console.log(that.ComplateRequestArr,'未完成订单数组') - if(results && results.length>0){ + console.log(that.ComplateRequestArr, '未完成订单数组') + if (results && results.length > 0) { // for(var j = 0; j{ - // "0"为正在支付;"1"为支付成功;"2"为支付失败;"3"为支付已恢复。 - if(item.transactionState == '1'){ - // 已经支付,但是没有走逻辑的内购订单 - that.iapCheck(item,index) - }else{ - // 其他状态的内购订单 - that.finishTransaction(item) - - } - }) + results.map((item, index) => { + // "0"为正在支付;"1"为支付成功;"2"为支付失败;"3"为支付已恢复。 + if (item.transactionState == '1') { + // 已经支付,但是没有走逻辑的内购订单 + that.iapCheck(item, index) + } else { + // 其他状态的内购订单 + that.finishTransaction(item) + + } + }) } - } - }); - - + } + }); + + }, // 关闭交易订单 - finishTransaction(trans,index){ + finishTransaction(trans, index) { this.iapChannel.finishTransaction(trans, (success) => { - console.log('关闭订单成功',index); - - if(index == this.ComplateRequestArr.length-1){ // 最后一个支付订单 - this.setUserInfo({restoreFlag:false}); + console.log('关闭订单成功', index); + + if (index == this.ComplateRequestArr.length - 1) { // 最后一个支付订单 + this.setUserInfo({ + restoreFlag: false + }); // console.log(this.userInfo.restoreFlag,'this.ComplateRequestArr.length+++') } - - }, (fail) => { - console.log('关闭订单失败'); - }); + + }, (fail) => { + console.log('关闭订单失败'); + }); }, - iapCheck(result,index) { - const that = this + iapCheck(result, index) { + const that = this console.log('进入后台验证') let data = { transactionId: result.transactionIdentifier, // 支付交易id - customerOid: that.userInfo.id, + customerOid: that.userInfo.id, productId: result.payment.productid, // 产品id orderId: result.payment.username, // 系统订单号 - receiptData: result.transactionReceipt ,// 苹果返回收据 - loadAnimate:'none', // 请求加载动画 - } - console.log(data,'data') + receiptData: result.transactionReceipt, // 苹果返回收据 + loadAnimate: 'none', // 请求加载动画 + } + console.log(data, 'data') $http.request({ url: "/Ipa/veri", method: "POST", // POST、GET、PUT、DELETE,具体说明查看官方文档 @@ -476,54 +398,54 @@ 'Content-Type': 'application/json' }, }).then(res => { - console.log(JSON.stringify(res)) + console.log(JSON.stringify(res)) console.log(res.code) - if(res.code == 0){ + if (res.code == 0) { // uni.hideLoading() - console.log('充值订单已处理,请留意账户金额变动....') - // 服务器验证票据有效后在客户端关闭订单 - that.finishTransaction(result,index) - }else if(res.code == 200){ // 重复验证订单 + console.log('充值订单已处理,请留意账户金额变动....') + // 服务器验证票据有效后在客户端关闭订单 + that.finishTransaction(result, index) + } else if (res.code == 200) { // 重复验证订单 console.log('重复验证....') - that.finishTransaction(result,index) + that.finishTransaction(result, index) } - }).catch(e => { + }).catch(e => { console.log('支付验证失败,进入轮询程序...') - that.getIapPayResult(result,index) - }) + that.getIapPayResult(result, index) + }) console.log('--------------') }, - + // 轮询验证支付结果 - getIapPayResult(result,index){ + getIapPayResult(result, index) { // let interval = null - this.ComplateRequestInterval = setTimeout(() => { - if(this.maxTimes <= 3){ - this.iapCheck(result,index) - console.log('执行1', this.maxTimes,this.ComplateRequestInterval) - this.maxTimes += 1 - }else{ + this.ComplateRequestInterval = setTimeout(() => { + if (this.maxTimes <= 3) { + this.iapCheck(result, index) + console.log('执行1', this.maxTimes, this.ComplateRequestInterval) + this.maxTimes += 1 + } else { this.maxTimes = 0 - console.log('停止轮询', this.maxTimes,this.ComplateRequestInterval, this.maxTimes) + console.log('停止轮询', this.maxTimes, this.ComplateRequestInterval, this.maxTimes) this.checking = false - this.saveErrorIapOrder(result,index) + this.saveErrorIapOrder(result, index) clearTimeout(this.ComplateRequestInterval) - + } - },10000) - + }, 10000) + }, // 轮询失败接口 - saveErrorIapOrder(result,index){ + saveErrorIapOrder(result, index) { console.log('提交到充值问题单里面...') let data = { - transactionId : result.transactionIdentifier, + transactionId: result.transactionIdentifier, failureflag: 1, - orderId:result.payment.username, - receiptData:result.transactionReceipt, - productId:result.payment.productid, - customerOid:this.userInfo.id - } + orderId: result.payment.username, + receiptData: result.transactionReceipt, + productId: result.payment.productid, + customerOid: this.userInfo.id + } $http.request({ url: "Ipa/failure", method: "POST", // POST、GET、PUT、DELETE,具体说明查看官方文档 @@ -532,17 +454,17 @@ 'Content-Type': 'application/json' }, }).then(res => { - console.log(JSON.stringify(res)) - if(res.code == 200){ + console.log(JSON.stringify(res)) + if (res.code == 200) { console.log('提交成功,关闭订单') - this.finishTransaction(result,index) + this.finishTransaction(result, index) } - }).catch(e => { - console.log(e) - if(e.statusCode == 0){ // 重复提交,直接关闭订单 - this.finishTransaction(result,index) + }).catch(e => { + console.log(e) + if (e.statusCode == 0) { // 重复提交,直接关闭订单 + this.finishTransaction(result, index) } - }) + }) }, // 获取列表数据 getData() { @@ -564,23 +486,16 @@ // 获取精选图书 this.getJBook() - + this.getNewBook() }, // 获取精选图书 - getJBook(){ + getJBook() { this.$http - .post('book/book/listbooks',{ - 'limit':6, - 'page': this.jPage - }) + .post('book/shopproduct/appGetList?limit=30&page=1&istop=1') .then(res => { - console.log(res,'首页商品') - this.jTotal = res.page.totalPage - this.goodsList = this.goodsList.concat(res.page.list) - console.log(this.goodsList,'this.goodsList') - this.status = 3 - uni.stopPullDownRefresh() + console.log(res.page.list, '首页商品') + this.goodsList = res.page.list }) }, // 跳转 @@ -614,14 +529,14 @@ uni.navigateTo({ url: '../eBook/bookContent?Id=' + e.id }); - }, + }, // 商品详情页 goDetail(id) { uni.navigateTo({ url: '../bookShop/commodityDetail?id=' + id }); }, - + // 列表跳页 onShopMore(e) { uni.navigateTo({ @@ -644,29 +559,62 @@ + \ No newline at end of file