微信支付完成
This commit is contained in:
@@ -21,6 +21,10 @@
|
|||||||
{
|
{
|
||||||
"playground" : "custom",
|
"playground" : "custom",
|
||||||
"type" : "uni-app:app-ios"
|
"type" : "uni-app:app-ios"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"playground" : "custom",
|
||||||
|
"type" : "uni-app:app-android"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ export const setPay = function(payInfo, callback) {
|
|||||||
let httpUrl = "";
|
let httpUrl = "";
|
||||||
if (payInfo.typePay == 'wxpay') {
|
if (payInfo.typePay == 'wxpay') {
|
||||||
// APP微信支付
|
// APP微信支付
|
||||||
httpUrl = 'api/pay/v1/pay_sign_wx'
|
httpUrl = '/v3/pay/placeAnOrder/app'
|
||||||
} else if (payInfo.typePay == 'alipay') {
|
} else if (payInfo.typePay == 'alipay') {
|
||||||
// APP支付宝支付
|
// APP支付宝支付
|
||||||
httpUrl = 'pay/aliPay/pay'
|
httpUrl = 'pay/aliPay/pay'
|
||||||
@@ -116,6 +116,7 @@ export const setPay = function(payInfo, callback) {
|
|||||||
// 苹果支付
|
// 苹果支付
|
||||||
}
|
}
|
||||||
$http.post(httpUrl, payInfo).then(data => {
|
$http.post(httpUrl, payInfo).then(data => {
|
||||||
|
console.log(data,'data')
|
||||||
let payData = {
|
let payData = {
|
||||||
success: function(res) {
|
success: function(res) {
|
||||||
callback && callback({
|
callback && callback({
|
||||||
@@ -156,10 +157,33 @@ export const setPay = function(payInfo, callback) {
|
|||||||
|
|
||||||
if (payData.orderInfo != '' && payData.orderInfo != undefined) {
|
if (payData.orderInfo != '' && payData.orderInfo != undefined) {
|
||||||
console.log("支付参数", payData);
|
console.log("支付参数", payData);
|
||||||
let EnvUtils = plus.android.importClass('com.alipay.sdk.app.EnvUtils');
|
// let EnvUtils = plus.android.importClass('com.alipay.sdk.app.EnvUtils');
|
||||||
EnvUtils.setEnv(EnvUtils.EnvEnum.SANDBOX);
|
// EnvUtils.setEnv(EnvUtils.EnvEnum.SANDBOX);
|
||||||
|
let payData1 = {
|
||||||
uni.requestPayment(payData);
|
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 => {
|
}, err => {
|
||||||
@@ -234,3 +258,50 @@ export const getLatLon = function(tip) {
|
|||||||
// #endif
|
// #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);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
"name" : "疯子读书",
|
"name" : "疯子读书",
|
||||||
"appid" : "__UNI__9788EB5",
|
"appid" : "__UNI__9788EB5",
|
||||||
"description" : "疯子读书",
|
"description" : "疯子读书",
|
||||||
"networkTimeout":{
|
"networkTimeout" : {
|
||||||
"request":3000
|
"request" : 3000
|
||||||
},
|
},
|
||||||
"transformPx" : false,
|
"transformPx" : false,
|
||||||
"icons" : [
|
"icons" : [
|
||||||
{
|
{
|
||||||
@@ -84,7 +84,12 @@
|
|||||||
"alipay" : {
|
"alipay" : {
|
||||||
"__platform__" : [ "ios", "android" ]
|
"__platform__" : [ "ios", "android" ]
|
||||||
},
|
},
|
||||||
"appleiap" : {}
|
"appleiap" : {},
|
||||||
|
"weixin" : {
|
||||||
|
"__platform__" : [ "android" ],
|
||||||
|
"appid" : "wx47134a8f15083734",
|
||||||
|
"UniversalLinks" : ""
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"splashscreen" : {
|
"splashscreen" : {
|
||||||
|
|||||||
@@ -279,7 +279,8 @@
|
|||||||
console.log('检测支付环境...')
|
console.log('检测支付环境...')
|
||||||
plus.payment.getChannels((channels) => {
|
plus.payment.getChannels((channels) => {
|
||||||
console.log(channels, 'channels')
|
console.log(channels, 'channels')
|
||||||
for (var i in channels) {
|
//this.setUserInfo({channelList:channels}); // 将支付通道保存到本地
|
||||||
|
for (var i in channels) {
|
||||||
// 判断是否苹果支付1
|
// 判断是否苹果支付1
|
||||||
if (channels[i].id === 'appleiap') {
|
if (channels[i].id === 'appleiap') {
|
||||||
this.iapChannel = channels[i]
|
this.iapChannel = channels[i]
|
||||||
@@ -288,15 +289,14 @@
|
|||||||
this.restoreComplateRequest()
|
this.restoreComplateRequest()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
// 查询未关闭订单
|
// 查询未关闭订单
|
||||||
restoreComplateRequest(){
|
restoreComplateRequest(){
|
||||||
let that = this
|
let that = this
|
||||||
console.log('检测未完成订单')
|
console.log('检测未完成订单')
|
||||||
console.log(this.iapChannel,'this.iapChannel')
|
console.log(this.iapChannel,'this.iapChannel')
|
||||||
|
|
||||||
this.iapChannel.restoreComplateRequest({
|
this.iapChannel.restoreComplateRequest({
|
||||||
manualFinishTransaction: true
|
manualFinishTransaction: true
|
||||||
}, function(results) {
|
}, function(results) {
|
||||||
|
|||||||
@@ -70,9 +70,9 @@
|
|||||||
<view class="nav_list" @click="onPageJump('../user/address')">
|
<view class="nav_list" @click="onPageJump('../user/address')">
|
||||||
<text>地址管理</text>
|
<text>地址管理</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="nav_list" @click="onGoing()">
|
<!-- <view class="nav_list" @click="onGoing()">
|
||||||
<text>帮助与反馈</text>
|
<text>帮助与反馈</text>
|
||||||
</view>
|
</view> -->
|
||||||
<view class="nav_list" @click="signShow=true">
|
<view class="nav_list" @click="signShow=true">
|
||||||
<text>退出登录</text>
|
<text>退出登录</text>
|
||||||
</view>
|
</view>
|
||||||
|
|||||||
@@ -89,7 +89,7 @@
|
|||||||
} from 'vuex';
|
} from 'vuex';
|
||||||
import {
|
import {
|
||||||
setPay,
|
setPay,
|
||||||
setPayAssign
|
setPayAssign,setWXPay
|
||||||
} from '@/config/utils';
|
} from '@/config/utils';
|
||||||
// const IAPOrders = [ // 根据这些ids获取到苹果app内商品信息,这些ids就是你上面设置的产品id
|
// const IAPOrders = [ // 根据这些ids获取到苹果app内商品信息,这些ids就是你上面设置的产品id
|
||||||
// 'add69'
|
// 'add69'
|
||||||
@@ -163,6 +163,7 @@
|
|||||||
finishTransaction(trans){
|
finishTransaction(trans){
|
||||||
this.iapChannel.finishTransaction(trans, (success) => {
|
this.iapChannel.finishTransaction(trans, (success) => {
|
||||||
console.log('关闭订单成功');
|
console.log('关闭订单成功');
|
||||||
|
this.setUserInfo({restoreFlag:false});
|
||||||
}, (fail) => {
|
}, (fail) => {
|
||||||
console.log('关闭订单失败');
|
console.log('关闭订单失败');
|
||||||
});
|
});
|
||||||
@@ -189,6 +190,7 @@
|
|||||||
},
|
},
|
||||||
iphonepay() {
|
iphonepay() {
|
||||||
const that = this
|
const that = this
|
||||||
|
// 如果ios已经绑定支付信息,就直接支付,如果没有绑定,就需要先绑定
|
||||||
console.log('检测支付环境...')
|
console.log('检测支付环境...')
|
||||||
plus.payment.getChannels((channels) => {
|
plus.payment.getChannels((channels) => {
|
||||||
console.log(channels, 'channels')
|
console.log(channels, 'channels')
|
||||||
@@ -250,16 +252,18 @@
|
|||||||
// restoreFlag = false; // 支付成功清除标记 restoreFlag = false
|
// restoreFlag = false; // 支付成功清除标记 restoreFlag = false
|
||||||
that.transaction = result
|
that.transaction = result
|
||||||
// 支付成功,result 为 IAP商品交易信息对象 IAPTransaction 需将返回的支付凭证传给后端进行二次认证
|
// 支付成功,result 为 IAP商品交易信息对象 IAPTransaction 需将返回的支付凭证传给后端进行二次认证
|
||||||
uni.hideLoading()
|
|
||||||
that.iapCheck(result)
|
that.iapCheck(result)
|
||||||
}, function(e) {
|
}, function(e) {
|
||||||
// restoreFlag = false; // 支付失败清楚标记
|
if(e.errCode == 2){
|
||||||
that.setUserInfo({restoreFlag:false});
|
// 用户未绑定支付方式,app内支付流程结束,系统弹出框引导用户绑定支付方式,此过程将跳转到系统应用 AppStore 进行绑定支付方式,绑定成功同步支付成功,用户成功付款
|
||||||
that.finishTransaction(result);
|
plus.runtime.openURL("https://apps.apple.com/account/billing");
|
||||||
//console.log('订单关闭后的用户信息', that.userInfo);
|
}else{
|
||||||
console.log(e)
|
// restoreFlag = false; // 支付失败清楚标记
|
||||||
//console.log(e.message)
|
that.finishTransaction(result);
|
||||||
uni.hideLoading()
|
//console.log('订单关闭后的用户信息', that.userInfo);
|
||||||
|
console.log(e)
|
||||||
|
//console.log(e.message)
|
||||||
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
iapCheck(result) {
|
iapCheck(result) {
|
||||||
@@ -291,12 +295,19 @@
|
|||||||
// 服务器验证票据有效后在客户端关闭订单 (iapChannel.finishTransaction)
|
// 服务器验证票据有效后在客户端关闭订单 (iapChannel.finishTransaction)
|
||||||
that.finishTransaction(result);
|
that.finishTransaction(result);
|
||||||
}
|
}
|
||||||
}).catch(e => {
|
}).catch(e => {
|
||||||
uni.showToast({
|
uni.showModal({
|
||||||
title:'支付验证失败,请稍后重启app,如不能解决您的问题,可联系官方客服',
|
title: '提示',
|
||||||
icon: 'none',
|
showCancel:false,
|
||||||
duration:5000
|
content: '支付验证失败,请稍后重启app,如不能解决您的问题,可联系官方客服',
|
||||||
})
|
success: function (res) {
|
||||||
|
if (res.confirm) {
|
||||||
|
console.log('用户点击确定');
|
||||||
|
} else if (res.cancel) {
|
||||||
|
console.log('用户点击取消');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
getDevName() {
|
getDevName() {
|
||||||
@@ -401,7 +412,7 @@
|
|||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: "支付成功"
|
title: "支付成功"
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: "支付失败",
|
title: "支付失败",
|
||||||
icon: "none",
|
icon: "none",
|
||||||
@@ -410,11 +421,42 @@
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
} else if (that.payType == 1) {
|
} else if (that.payType == 1) {
|
||||||
// 微信支付
|
// 微信支付
|
||||||
uni.showToast({
|
that.orderSn = res.orderSn
|
||||||
title: '微信支付',
|
let data1={
|
||||||
none: 'none'
|
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) {
|
} else if (that.payType == 3) {
|
||||||
console.log('苹果支付', )
|
console.log('苹果支付', )
|
||||||
that.iosPay()
|
that.iosPay()
|
||||||
|
|||||||
@@ -1602,12 +1602,12 @@ import { nextTick } from "vue";
|
|||||||
})
|
})
|
||||||
//return
|
//return
|
||||||
if (this.domIndex > this.curPage.text[this.curPage.text.length - 1].paragraph) { // 是否跨页 是的话就翻页
|
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 ={
|
this.musicItem ={
|
||||||
page:this.currentPage + 1,
|
page:this.currentPage + 1,
|
||||||
musicIndexDom: this.domIndex
|
musicIndexDom: this.domIndex,
|
||||||
|
musicPlaying:true
|
||||||
}
|
}
|
||||||
this.goNextPage()
|
this.goNextPage()
|
||||||
|
|
||||||
@@ -2364,7 +2364,7 @@ import { nextTick } from "vue";
|
|||||||
icon: 'none'
|
icon: 'none'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
this.showAnimation = true
|
this.showAnimation = false // 关闭动画
|
||||||
this.prePage.pageTranslate = [
|
this.prePage.pageTranslate = [
|
||||||
`(${-this.windowWidth}px,0)`,
|
`(${-this.windowWidth}px,0)`,
|
||||||
`(${-this.windowWidth}px,0)`,
|
`(${-this.windowWidth}px,0)`,
|
||||||
@@ -3214,9 +3214,10 @@ import { nextTick } from "vue";
|
|||||||
// page = $("#flipbook").turn('page')
|
// page = $("#flipbook").turn('page')
|
||||||
if(newVal.musicPlaying){
|
if(newVal.musicPlaying){
|
||||||
// 开启听书
|
// 开启听书
|
||||||
|
console.log(newVal.page,'newVal.page')
|
||||||
if(newVal.page > 0){ // 翻页
|
if(newVal.page > 0){ // 翻页
|
||||||
console.log('翻页翻页', newVal.page+2)
|
console.log('翻页翻页', newVal.page+2)
|
||||||
$("#flipbook").turn('page', newVal.page+2)
|
$("#flipbook").turn('page', newVal.page+3)
|
||||||
}
|
}
|
||||||
$("#flipbook .paragraph").css({color:"#333"})
|
$("#flipbook .paragraph").css({color:"#333"})
|
||||||
$("#flipbook .paragraph"+newVal.musicIndexDom).css({color:"#e5d6a0"})
|
$("#flipbook .paragraph"+newVal.musicIndexDom).css({color:"#e5d6a0"})
|
||||||
@@ -3261,7 +3262,7 @@ import { nextTick } from "vue";
|
|||||||
var classname = ''
|
var classname = ''
|
||||||
var styleconteent = ''
|
var styleconteent = ''
|
||||||
newVal.SimulationText[i][j].class == 'jushou' ? classname = 'shouhang' : 'notshouhang'
|
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 += "<p class='paragraph " + classname + " paragraph" + newVal.SimulationText[i][j].paragraph +"' style="+styleconteent+">" + newVal.SimulationText[i][j].list + "</p>"
|
conntentHtml += "<p class='paragraph " + classname + " paragraph" + newVal.SimulationText[i][j].paragraph +"' style="+styleconteent+">" + newVal.SimulationText[i][j].list + "</p>"
|
||||||
}
|
}
|
||||||
var page1 = i+1
|
var page1 = i+1
|
||||||
|
|||||||
Reference in New Issue
Block a user