diff --git a/.hbuilderx/launch.json b/.hbuilderx/launch.json index f3a5ba7..2122ab4 100644 --- a/.hbuilderx/launch.json +++ b/.hbuilderx/launch.json @@ -21,6 +21,10 @@ { "playground" : "custom", "type" : "uni-app:app-ios" + }, + { + "playground" : "custom", + "type" : "uni-app:app-android" } ] } diff --git a/config/utils.js b/config/utils.js index ebf77f8..3468168 100644 --- a/config/utils.js +++ b/config/utils.js @@ -105,7 +105,7 @@ export const setPay = function(payInfo, callback) { let httpUrl = ""; if (payInfo.typePay == 'wxpay') { // APP微信支付 - httpUrl = 'api/pay/v1/pay_sign_wx' + httpUrl = '/v3/pay/placeAnOrder/app' } else if (payInfo.typePay == 'alipay') { // APP支付宝支付 httpUrl = 'pay/aliPay/pay' @@ -116,6 +116,7 @@ export const setPay = function(payInfo, callback) { // 苹果支付 } $http.post(httpUrl, payInfo).then(data => { + console.log(data,'data') let payData = { success: function(res) { callback && callback({ @@ -156,10 +157,33 @@ export const setPay = function(payInfo, callback) { if (payData.orderInfo != '' && payData.orderInfo != undefined) { console.log("支付参数", payData); - let EnvUtils = plus.android.importClass('com.alipay.sdk.app.EnvUtils'); - EnvUtils.setEnv(EnvUtils.EnvEnum.SANDBOX); - - uni.requestPayment(payData); + // let EnvUtils = plus.android.importClass('com.alipay.sdk.app.EnvUtils'); + // EnvUtils.setEnv(EnvUtils.EnvEnum.SANDBOX); + let payData1 = { + provider: 'alipay', + orderInfo: data.orderInfo, + success(res) { + console.log('success:' + res); + }, + //调用失败的回调 + fail(err) { + console.log('fail:' + err); + console.log(JSON.stringify(err)) + uni.showModal({ + title: '提示', + showCancel:false, + content: '商家支付参数错误,请重新发起付款', + success: function (res) { + if (res.confirm) { + console.log('用户点击确定'); + } else if (res.cancel) { + console.log('用户点击取消'); + } + } + }); + } + } + uni.requestPayment(payData1); } }, err => { @@ -234,3 +258,50 @@ export const getLatLon = function(tip) { // #endif }); } + +// 单独重新微信支付 +export const setWXPay = function(payInfo, callback) { + $http.request({ + url: "/pay/placeAnOrder/app", + method: "POST", // POST、GET、PUT、DELETE,具体说明查看官方文档 + data:payInfo, + header: { //默认 无 说明:请求头1 + 'Content-Type': 'application/json' + }, + }).then(res => { + console.log(res,'res') + + if(res.code === 0){ + let payData = { + provider : 'wxpay', + orderInfo: { + "appid": res.paramMap.appid , // 微信开放平台 - 应用 - AppId,注意和微信小程序、公众号 AppId 可能不一致 + "noncestr": res.Map.noncestr, // 随机字符串 + "package": res.Map.package, // 固定值 + "partnerid": res.paramMap.mchid, // 微信支付商户号 + "prepayid": res.Map.prepayid, // 统一下单订单号 + "timestamp": res.Map.timestamp, // 时间戳(单位:秒) + "signType": "SHA256-RSA", + "sign": res.Map.sign + }, + success(res) { + callback && callback({ + success: true, + data: res + }); + // console.log('success:' + JSON.stringify(res)); + }, + fail(err) { + callback && callback({ + success: false, + data: err + }); + // console.log('fail:' + JSON.stringify(err)); + + } + } + // console.log(payData) + uni.requestPayment(payData); + } + }) +} diff --git a/manifest.json b/manifest.json index 3847fd9..4e121f4 100644 --- a/manifest.json +++ b/manifest.json @@ -2,9 +2,9 @@ "name" : "疯子读书", "appid" : "__UNI__9788EB5", "description" : "疯子读书", - "networkTimeout":{ - "request":3000 - }, + "networkTimeout" : { + "request" : 3000 + }, "transformPx" : false, "icons" : [ { @@ -84,7 +84,12 @@ "alipay" : { "__platform__" : [ "ios", "android" ] }, - "appleiap" : {} + "appleiap" : {}, + "weixin" : { + "__platform__" : [ "android" ], + "appid" : "wx47134a8f15083734", + "UniversalLinks" : "" + } } }, "splashscreen" : { diff --git a/pages/peanut/home.vue b/pages/peanut/home.vue index 2ae7138..6877109 100644 --- a/pages/peanut/home.vue +++ b/pages/peanut/home.vue @@ -279,7 +279,8 @@ console.log('检测支付环境...') plus.payment.getChannels((channels) => { console.log(channels, 'channels') - for (var i in channels) { + //this.setUserInfo({channelList:channels}); // 将支付通道保存到本地 + for (var i in channels) { // 判断是否苹果支付1 if (channels[i].id === 'appleiap') { this.iapChannel = channels[i] @@ -288,15 +289,14 @@ this.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) { diff --git a/pages/peanut/mine.vue b/pages/peanut/mine.vue index 086f0c1..e7b2447 100644 --- a/pages/peanut/mine.vue +++ b/pages/peanut/mine.vue @@ -70,9 +70,9 @@ 地址管理 - + 退出登录 diff --git a/pages/peanut/reCharge.vue b/pages/peanut/reCharge.vue index 4bf1914..9beaa53 100644 --- a/pages/peanut/reCharge.vue +++ b/pages/peanut/reCharge.vue @@ -89,7 +89,7 @@ } from 'vuex'; import { setPay, - setPayAssign + setPayAssign,setWXPay } from '@/config/utils'; // const IAPOrders = [ // 根据这些ids获取到苹果app内商品信息,这些ids就是你上面设置的产品id // 'add69' @@ -163,6 +163,7 @@ finishTransaction(trans){ this.iapChannel.finishTransaction(trans, (success) => { console.log('关闭订单成功'); + this.setUserInfo({restoreFlag:false}); }, (fail) => { console.log('关闭订单失败'); }); @@ -189,6 +190,7 @@ }, iphonepay() { const that = this + // 如果ios已经绑定支付信息,就直接支付,如果没有绑定,就需要先绑定 console.log('检测支付环境...') plus.payment.getChannels((channels) => { console.log(channels, 'channels') @@ -250,16 +252,18 @@ // restoreFlag = false; // 支付成功清除标记 restoreFlag = false that.transaction = result // 支付成功,result 为 IAP商品交易信息对象 IAPTransaction 需将返回的支付凭证传给后端进行二次认证 - uni.hideLoading() that.iapCheck(result) }, function(e) { - // restoreFlag = false; // 支付失败清楚标记 - that.setUserInfo({restoreFlag:false}); - that.finishTransaction(result); - //console.log('订单关闭后的用户信息', that.userInfo); - console.log(e) - //console.log(e.message) - uni.hideLoading() + if(e.errCode == 2){ + // 用户未绑定支付方式,app内支付流程结束,系统弹出框引导用户绑定支付方式,此过程将跳转到系统应用 AppStore 进行绑定支付方式,绑定成功同步支付成功,用户成功付款 + plus.runtime.openURL("https://apps.apple.com/account/billing"); + }else{ + // restoreFlag = false; // 支付失败清楚标记 + that.finishTransaction(result); + //console.log('订单关闭后的用户信息', that.userInfo); + console.log(e) + //console.log(e.message) + } }); }, iapCheck(result) { @@ -291,12 +295,19 @@ // 服务器验证票据有效后在客户端关闭订单 (iapChannel.finishTransaction) that.finishTransaction(result); } - }).catch(e => { - uni.showToast({ - title:'支付验证失败,请稍后重启app,如不能解决您的问题,可联系官方客服', - icon: 'none', - duration:5000 - }) + }).catch(e => { + uni.showModal({ + title: '提示', + showCancel:false, + content: '支付验证失败,请稍后重启app,如不能解决您的问题,可联系官方客服', + success: function (res) { + if (res.confirm) { + console.log('用户点击确定'); + } else if (res.cancel) { + console.log('用户点击取消'); + } + } + }); }) }, getDevName() { @@ -401,7 +412,7 @@ uni.showToast({ title: "支付成功" }); - } else { + } else { uni.showToast({ title: "支付失败", icon: "none", @@ -410,11 +421,42 @@ } }) } else if (that.payType == 1) { - // 微信支付 - uni.showToast({ - title: '微信支付', - none: 'none' - }) + // 微信支付 + that.orderSn = res.orderSn + let data1={ + orderSn:that.orderSn, + // orderId:that.orderSn, + } + console.log(data1,'data1') + // console.log(this.userInfo.channelList,'channelList') + // this.userInfo.channelList.map(item => { + // if(item.id == "wxpay"){ + // console.log('支持微信支付') + setWXPay(data1,res => { + if (res.success) { + uni.showToast({ + title: "支付成功" + }); + } else { + console.log(res) + if(res.data.errMsg.indexOf('User canceled') != -1){ + uni.showToast({ + title: "用户取消支付", + icon: "none", + image: '../../static/icon/ic_close.png' + }); + }else{ + uni.showToast({ + title: "支付失败", + icon: "none", + image: '../../static/icon/ic_close.png' + }); + } + } + }) + // } + // }) + } else if (that.payType == 3) { console.log('苹果支付', ) that.iosPay() diff --git a/pages/yRead/angbook.vue b/pages/yRead/angbook.vue index cb3a14f..5a649ca 100644 --- a/pages/yRead/angbook.vue +++ b/pages/yRead/angbook.vue @@ -1602,12 +1602,12 @@ import { nextTick } from "vue"; }) //return if (this.domIndex > this.curPage.text[this.curPage.text.length - 1].paragraph) { // 是否跨页 是的话就翻页 - // console.log(this.curPage.text[this.curPage.text.length - 1].paragraph,'该翻页了') - // this.musicItem.page = this.currentPage + 1 + console.log(this.currentPage,'this.currentPage') this.musicItem ={ page:this.currentPage + 1, - musicIndexDom: this.domIndex + musicIndexDom: this.domIndex, + musicPlaying:true } this.goNextPage() @@ -2364,7 +2364,7 @@ import { nextTick } from "vue"; icon: 'none' }) } - this.showAnimation = true + this.showAnimation = false // 关闭动画 this.prePage.pageTranslate = [ `(${-this.windowWidth}px,0)`, `(${-this.windowWidth}px,0)`, @@ -3214,9 +3214,10 @@ import { nextTick } from "vue"; // page = $("#flipbook").turn('page') if(newVal.musicPlaying){ // 开启听书 + console.log(newVal.page,'newVal.page') if(newVal.page > 0){ // 翻页 console.log('翻页翻页', newVal.page+2) - $("#flipbook").turn('page', newVal.page+2) + $("#flipbook").turn('page', newVal.page+3) } $("#flipbook .paragraph").css({color:"#333"}) $("#flipbook .paragraph"+newVal.musicIndexDom).css({color:"#e5d6a0"}) @@ -3261,7 +3262,7 @@ import { nextTick } from "vue"; var classname = '' var styleconteent = '' newVal.SimulationText[i][j].class == 'jushou' ? classname = 'shouhang' : 'notshouhang' - newVal.SimulationText[i][j].class == 'jushou' ? styleconteent = "'text-indent:2em ;font-size:"+newVal.fontSize+"px; color: #5d5d5d; line-height:"+newVal.lineHeight*newVal.fontSize+"px;'": styleconteent = "'font-size:"+newVal.fontSize+"px ; line-height:"+newVal.lineHeight*newVal.fontSize+"px; color: #5d5d5d;'" + newVal.SimulationText[i][j].class == 'jushou' ? styleconteent = "'text-indent:2em ;font-size:"+newVal.fontSize+"px; color: #5d5d5d; line-height:"+newVal.lineHeight*newVal.fontSize+"px;'": styleconteent = "'font-size:"+newVal.fontSize+"px ; display:inline;line-height:"+newVal.lineHeight*newVal.fontSize+"px; color: #5d5d5d;'" conntentHtml += "

" + newVal.SimulationText[i][j].list + "

" } var page1 = i+1