Commit d3be846a authored by liwei's avatar liwei

对接了金币充值接口

parent 2a1ed63d
......@@ -148,7 +148,7 @@ export function getConsumeRecord(data){
export function payGoldCoins(data){
return request({
method: "post",
url: '/app/memGoldCoinFlow/add',
url: '/app/order/addGold',
data,
});
}
......@@ -209,4 +209,4 @@ export function addMemTraffic(data) {
method: 'post',
data: data
})
}
\ No newline at end of file
}
......@@ -111,73 +111,61 @@ import {activityDetail, addApplication, pay} from "../api/activity/index.js"
if (res.data.code === 200) {
const activityId = this.activityId
const orderId = res.data.data.businessId
// 如果支付总金额大于0,则进行支付,反之则不进行支付
// if(this.totalprice > 0){
// 支付
const payquery = {
orderId: orderId,
activityId: this.activityId
}
pay(payquery).then(res => {
console.log("支付参数", res)
console.log("测试支付", res.data.errMsg)
if (res.data.errMsg === 'OK') {
if (!res.data.data.nonceStr) {
uni.showToast({
title: '下单失败,请稍后重试',
icon: 'none'
})
} else {
// 调取微信支付窗口
uni.requestPayment({
provider: "wxpay",
appId: res.data.appid, // 微信小程序appid
timeStamp: res.data.timeStamp, // 时间戳
nonceStr: res.data.nonceStr, // 随机字符串
package: res.data.package,
signType: "MD5", // 签名算法
paySign: res.data.paySign, // 签名
success(res) {
uni.showToast({
title: '支付成功',
icon: 'success'
})
this.show = false
uni.navigateTo({
url:'/my/myorder/index'
})
},
fail(e) {
console.log("支付失败", e)
uni.showToast({
title: '支付已取消',
icon: 'none'
})
const orderStatus = {
orderId: orderId,
activityId: activityId
}
// 修改订单状态为待支付
// updateorderstatus(orderStatus).then(res=>{
// console.log('修改订单状态',res)
// })
}
});
}
} else {
// 支付
const payquery = {
orderId: orderId,
activityId: this.activityId,
type:'0'
}
pay(payquery).then(res => {
console.log("支付参数", res)
console.log("测试支付", res.data.errMsg)
if (res.data.errMsg === 'OK') {
if (!res.data.data.nonceStr) {
uni.showToast({
title: '下单失败',
title: '下单失败,请稍后重试',
icon: 'none'
})
} else {
// 调取微信支付窗口
uni.requestPayment({
provider: "wxpay",
appId: res.data.appid, // 微信小程序appid
timeStamp: res.data.timeStamp, // 时间戳
nonceStr: res.data.nonceStr, // 随机字符串
package: res.data.package,
signType: "MD5", // 签名算法
paySign: res.data.paySign, // 签名
success(res) {
uni.showToast({
title: '支付成功',
icon: 'success'
})
this.show = false
uni.navigateTo({
url:'/my/myorder/index'
})
},
fail(e) {
console.log("支付失败", e)
uni.showToast({
title: '支付已取消',
icon: 'none'
})
const orderStatus = {
orderId: orderId,
activityId: activityId
}
}
});
}
})
// }else{
// uni.showToast({
// title: '支付成功',
// icon: 'success'
// })
// }
} else {
uni.showToast({
title: '下单失败',
icon: 'none'
})
}
})
} else if(res.data.code !== 200){
uni.showToast({
title: res.data.message,
......
......@@ -29,12 +29,13 @@
</view>
</view>
<view class="bottom">
<button class="btn" :loading="loading" @click="Pay">立即充值</button>
<button class="btn" :loading="loading" @click="submitorder">立即充值</button>
</view>
</view>
</template>
<script>
import {getBalance, payGoldCoins} from "../../api/user";
import {addApplication, pay} from "../../api/activity";
let iapChannel = null // 苹果内部支付渠道
export default {
......@@ -50,7 +51,6 @@ export default {
{ coin: 600, price: 600 }
],
activeIndex: 0,//激活的索引
payMoney:0,//支付金额
loading: false, // 是否充值中
balance: 0, // 余额
moneyList: [], // 充值列表展示金额
......@@ -58,37 +58,15 @@ export default {
courseIds: [], // 支付的课程ids
applePrice: 30, // ios充值金额
userId: null,//用户id
memberId:null//会员id
memberId:null,//会员id
coinCount:100,//金币数量
payMoney:100,//支付金额
}
},
onLoad(option) {
const userInfo = uni.getStorageSync("userInfo");
this.userId = userInfo.businessId
this.memberId = userInfo.memberId
// // 获取支付金额
// if (option.params) {
// const params = JSON.parse(option.params)
// this.price = params.price
// this.courseIds = params.courseIds
// }
// // 查询余额
// this.loadData()
// // 获取apple支付渠道实例
// plus.payment.getChannels((channels) => {
// console.log("获取到channel" + JSON.stringify(channels))
// for (var i in channels) {
// var channel = channels[i];
// if (channel.id === 'appleiap') {
// iapChannel = channel;
// this.requestOrder();
// }
// }
// if (!iapChannel) {
// this.errorMsg()
// }
// }, (error) => {
// this.errorMsg()
// });
},
onShow(){
this.getCoinBalance()
......@@ -108,80 +86,78 @@ export default {
this.coinCount = item.coin
this.payMoney = item.price
},
//立即充值
Pay(){
// 提交订单
submitorder() {
const params = {
type:'1',//类型 1充值 2消费
balance: this.balance,//当前用户余额
count: this.coinCount,//充值的金币数
actionType:'10',//行为类型 10:用户充值 11:系统充值 20:点赞 21:发动态 22:留言 23:要微信联系方式 24:接收微信请求
targetId: this.userId,//目标用户id
memberId: this.memberId//当前用户会员id
price: 0,
num: this.coinCount
}
payGoldCoins(params).then( res =>{
if (res.data.code == 200){
uni.showToast({
title: '充值成功',
icon: 'success'
})
//调用查余额接口
this.getCoinBalance()
} else {
// 添加订单(报名)
payGoldCoins(params).then(res => {
if (res.data.code === 200) {
const orderId = res.data.data.businessId
// 支付
const payquery = {
orderId: orderId,
type:'1',
activityId: 0
}
// pay(payquery).then(res => {
// console.log("支付参数", res)
// console.log("测试支付", res.data.errMsg)
// if (res.data.errMsg === 'OK') {
// if (!res.data.data.nonceStr) {
// uni.showToast({
// title: '下单失败,请稍后重试',
// icon: 'none'
// })
// } else {
// // 调取微信支付窗口
// uni.requestPayment({
// provider: "wxpay",
// appId: res.data.appid, // 微信小程序appid
// timeStamp: res.data.timeStamp, // 时间戳
// nonceStr: res.data.nonceStr, // 随机字符串
// package: res.data.package,
// signType: "MD5", // 签名算法
// paySign: res.data.paySign, // 签名
// success(res) {
// uni.showToast({
// title: '支付成功',
// icon: 'success'
// })
// this.show = false
// uni.navigateTo({
// url:'/my/myorder/index'
// })
// },
// fail(e) {
// console.log("支付失败", e)
// uni.showToast({
// title: '支付已取消',
// icon: 'none'
// })
// const orderStatus = {
// orderId: orderId,
// activityId: activityId
// }
// }
// });
// }
// } else {
// uni.showToast({
// title: '下单失败',
// icon: 'none'
// })
// }
// })
} else if(res.data.code !== 200){
uni.showToast({
title: res.data.message,
icon: 'none'
})
}
})
},
// requestOrder() {
// uni.showLoading({
// title: '检测支付环境...'
// })
// //必须调用此方法向Appstore请求有效的商品详情,才能进行 iap 支付,
// iapChannel.requestOrder(this.moneyList, (orderList) => {
// console.log('requestOrder success666: ' + JSON.stringify(orderList));
// uni.hideLoading();
// }, (e) => {
// console.log('requestOrder failed: ' + JSON.stringify(e));
// uni.hideLoading();
// this.errorMsg()
// });
// },
// iosPayHandler() {
// this.loading = true;
// uni.requestPayment({
// provider: 'appleiap',
// orderInfo: {
// productid: this.applePrice // 商品id
// },
// success: (e) => {
// console.log("success", e);
// uni.showToast({
// title: "支付成功!"
// })
// // 调用接口,立即扣款购买商品
// },
// fail: (e) => {
// console.log("fail", e);
// uni.showModal({
// content: "支付失败,原因为: " + e.errMsg,
// showCancel: false
// })
// },
// complete: () => {
// this.loading = false;
// }
// })
// },
// errorMsg() {
// uni.showModal({
// content: "暂不支持苹果 iap 支付",
// showCancel: false
// })
// },
async loadData() {
},
//消费记录
consumeRecord(){
......
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