微信支付完成
This commit is contained in:
@@ -21,6 +21,10 @@
|
||||
{
|
||||
"playground" : "custom",
|
||||
"type" : "uni-app:app-ios"
|
||||
},
|
||||
{
|
||||
"playground" : "custom",
|
||||
"type" : "uni-app:app-android"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -84,7 +84,12 @@
|
||||
"alipay" : {
|
||||
"__platform__" : [ "ios", "android" ]
|
||||
},
|
||||
"appleiap" : {}
|
||||
"appleiap" : {},
|
||||
"weixin" : {
|
||||
"__platform__" : [ "android" ],
|
||||
"appid" : "wx47134a8f15083734",
|
||||
"UniversalLinks" : ""
|
||||
}
|
||||
}
|
||||
},
|
||||
"splashscreen" : {
|
||||
|
||||
@@ -279,6 +279,7 @@
|
||||
console.log('检测支付环境...')
|
||||
plus.payment.getChannels((channels) => {
|
||||
console.log(channels, 'channels')
|
||||
//this.setUserInfo({channelList:channels}); // 将支付通道保存到本地
|
||||
for (var i in channels) {
|
||||
// 判断是否苹果支付1
|
||||
if (channels[i].id === 'appleiap') {
|
||||
@@ -296,7 +297,6 @@
|
||||
let that = this
|
||||
console.log('检测未完成订单')
|
||||
console.log(this.iapChannel,'this.iapChannel')
|
||||
|
||||
this.iapChannel.restoreComplateRequest({
|
||||
manualFinishTransaction: true
|
||||
}, function(results) {
|
||||
|
||||
@@ -70,9 +70,9 @@
|
||||
<view class="nav_list" @click="onPageJump('../user/address')">
|
||||
<text>地址管理</text>
|
||||
</view>
|
||||
<view class="nav_list" @click="onGoing()">
|
||||
<!-- <view class="nav_list" @click="onGoing()">
|
||||
<text>帮助与反馈</text>
|
||||
</view>
|
||||
</view> -->
|
||||
<view class="nav_list" @click="signShow=true">
|
||||
<text>退出登录</text>
|
||||
</view>
|
||||
|
||||
@@ -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) {
|
||||
if(e.errCode == 2){
|
||||
// 用户未绑定支付方式,app内支付流程结束,系统弹出框引导用户绑定支付方式,此过程将跳转到系统应用 AppStore 进行绑定支付方式,绑定成功同步支付成功,用户成功付款
|
||||
plus.runtime.openURL("https://apps.apple.com/account/billing");
|
||||
}else{
|
||||
// restoreFlag = false; // 支付失败清楚标记
|
||||
that.setUserInfo({restoreFlag:false});
|
||||
that.finishTransaction(result);
|
||||
//console.log('订单关闭后的用户信息', that.userInfo);
|
||||
console.log(e)
|
||||
//console.log(e.message)
|
||||
uni.hideLoading()
|
||||
}
|
||||
});
|
||||
},
|
||||
iapCheck(result) {
|
||||
@@ -292,11 +296,18 @@
|
||||
that.finishTransaction(result);
|
||||
}
|
||||
}).catch(e => {
|
||||
uni.showToast({
|
||||
title:'支付验证失败,请稍后重启app,如不能解决您的问题,可联系官方客服',
|
||||
icon: 'none',
|
||||
duration:5000
|
||||
})
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
showCancel:false,
|
||||
content: '支付验证失败,请稍后重启app,如不能解决您的问题,可联系官方客服',
|
||||
success: function (res) {
|
||||
if (res.confirm) {
|
||||
console.log('用户点击确定');
|
||||
} else if (res.cancel) {
|
||||
console.log('用户点击取消');
|
||||
}
|
||||
}
|
||||
});
|
||||
})
|
||||
},
|
||||
getDevName() {
|
||||
@@ -411,10 +422,41 @@
|
||||
})
|
||||
} else if (that.payType == 1) {
|
||||
// 微信支付
|
||||
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: '微信支付',
|
||||
none: 'none'
|
||||
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()
|
||||
|
||||
@@ -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 += "<p class='paragraph " + classname + " paragraph" + newVal.SimulationText[i][j].paragraph +"' style="+styleconteent+">" + newVal.SimulationText[i][j].list + "</p>"
|
||||
}
|
||||
var page1 = i+1
|
||||
|
||||
Reference in New Issue
Block a user