0313
This commit is contained in:
@@ -112,6 +112,8 @@ export const setPay = function(payInfo, callback) {
|
||||
} else if (payInfo.typePay == 'smallPay') {
|
||||
// 微信小程序支付
|
||||
httpUrl = 'api/pay/v1/small_pay_sign_wx'
|
||||
}else if(payInfo.typePay == 'appleiap'){
|
||||
// 苹果支付
|
||||
}
|
||||
$http.post(httpUrl, payInfo).then(data => {
|
||||
let payData = {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name" : "E-crazy",
|
||||
"name" : "疯子读书",
|
||||
"appid" : "__UNI__9788EB5",
|
||||
"description" : "E-crazy-案例",
|
||||
"description" : "疯子读书",
|
||||
"transformPx" : false,
|
||||
"icons" : [
|
||||
{
|
||||
|
||||
@@ -248,7 +248,8 @@
|
||||
"navigationBarTitleText": "物流详情"
|
||||
}
|
||||
}
|
||||
],
|
||||
|
||||
],
|
||||
"globalStyle": {
|
||||
"navigationBarTextStyle": "black",
|
||||
"navigationBarTitleText": "uni-app",
|
||||
|
||||
@@ -215,19 +215,19 @@
|
||||
nowClick: true,
|
||||
paylist: [{
|
||||
title: '支付宝',
|
||||
id: 1,
|
||||
id: 2,
|
||||
img: '../../static/icon/pay_1.png'
|
||||
},
|
||||
{
|
||||
title: '微信',
|
||||
id: 1,
|
||||
img: '../../static/icon/pay_2.png'
|
||||
},
|
||||
{
|
||||
title: '疯币购买',
|
||||
id: 4,
|
||||
img: '../../static/icon/oder_chong.png'
|
||||
}
|
||||
// {
|
||||
// title: '微信',
|
||||
// id: 2,
|
||||
// img: '../../static/icon/pay_2.png'
|
||||
// },
|
||||
},
|
||||
// {
|
||||
// title: 'ios内购',
|
||||
// id: 3,
|
||||
|
||||
@@ -523,6 +523,7 @@
|
||||
.then(res => {
|
||||
if (res.code == 0) {
|
||||
if (res.status == 'error') {
|
||||
this.buysignShow = false
|
||||
uni.showToast({
|
||||
icon: 'none',
|
||||
title: res.msg
|
||||
|
||||
@@ -17,29 +17,47 @@
|
||||
</view>
|
||||
<view class="cha_fangsh">
|
||||
<view class="cf_title">支付方式</view>
|
||||
|
||||
<view class="cf_radio">
|
||||
<u-radio-group v-model="payType">
|
||||
<view style="width: 100%;">
|
||||
<view style="width: 100%;" v-if="isAndroid">
|
||||
<view v-for="(item, index) in paylist" @click="choseType(item.id)"
|
||||
:class="payType == item.id?'Tab_xf cf_xuanx':'cf_xuanx'">
|
||||
<image :src="item.img"></image>
|
||||
{{item.title}}
|
||||
<u-radio :key="index" activeColor="#fe6e09" :name='item.id'
|
||||
<u-radio v-if="isAndroid" :key="index" activeColor="#fe6e09" :name='item.id'
|
||||
style="float: right;margin-top: 5rpx;"></u-radio>
|
||||
|
||||
</view>
|
||||
</view>
|
||||
<view style="width: 100%;" v-else>
|
||||
<view v-for="(item, index) in iosPaylist" @click="choseType(item.id)"
|
||||
:class="payType == item.id?'Tab_xf cf_xuanx':'cf_xuanx'">
|
||||
<image :src="item.img"></image>
|
||||
{{item.title}}
|
||||
<u-radio v-if="isAndroid" :key="index" activeColor="#fe6e09" :name='item.id'
|
||||
style="float: right;margin-top: 5rpx;"></u-radio>
|
||||
|
||||
</view>
|
||||
</view>
|
||||
</u-radio-group>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
<view class="agree_wo">* 我已阅读并同意《会员服务协议》</view>
|
||||
<view class="char_btn">
|
||||
<view @click="kaiChar">立即充值</view>
|
||||
<view @click="kaiChar" v-if="isAndroid">立即充值</view>
|
||||
<view @click="iosPay" v-else>立即充值</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import $http from '@/config/requestConfig.js';
|
||||
// import { // 引入ios支付
|
||||
// Iap,
|
||||
// IapTransactionState
|
||||
// } from "@/utils/iap.js"
|
||||
import {
|
||||
mapState
|
||||
} from 'vuex';
|
||||
@@ -49,20 +67,29 @@
|
||||
} from '@/config/utils';
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
return {
|
||||
stepsCj: {},
|
||||
cjList: [],
|
||||
productid:'',
|
||||
isAndroid:true, // 是否为安卓环境
|
||||
payType: 2,
|
||||
paylist: [{
|
||||
title: '支付宝',
|
||||
id: 1,
|
||||
id: 2,
|
||||
img: '../../static/icon/pay_1.png'
|
||||
},
|
||||
{
|
||||
title: '微信',
|
||||
id: 1,
|
||||
img: '../../static/icon/pay_2.png'
|
||||
}
|
||||
],
|
||||
iosPaylist: [
|
||||
{
|
||||
title: 'ios内购',
|
||||
id: 3,
|
||||
img: '../../static/icon/pay_2.png'
|
||||
}
|
||||
// {
|
||||
// title: '微信',
|
||||
// id: 2,
|
||||
// img: '../../static/icon/pay_2.png'
|
||||
// }
|
||||
],
|
||||
};
|
||||
},
|
||||
@@ -71,17 +98,99 @@
|
||||
// 隐藏原生的tabbar
|
||||
uni.hideTabBar();
|
||||
this.getData();
|
||||
this.getIapChannels()
|
||||
},
|
||||
//页面显示
|
||||
onShow() {
|
||||
// 隐藏原生的tabbar
|
||||
uni.hideTabBar();
|
||||
this.requestIapOrder()
|
||||
},
|
||||
computed: {
|
||||
...mapState(['userInfo']),
|
||||
},
|
||||
//方法
|
||||
methods: {
|
||||
// 获取应用内支付对象
|
||||
getIapChannels() {
|
||||
console.log('------getIapChannels' );
|
||||
let _this = this;
|
||||
plus.payment.getChannels(function(channels){
|
||||
for (let i in channels) {
|
||||
let channel = channels[i];
|
||||
// 获取 id 为 'appleiap' 的 channel
|
||||
if (channel.id == 'appleiap') {
|
||||
_this.iap = channel;
|
||||
_this.requestIapOrder();
|
||||
}
|
||||
}
|
||||
}, function(e){
|
||||
showToasts("获取iap支付通道失败:" + e.message);
|
||||
});
|
||||
},
|
||||
// 获取到支付对象后,初始化支付项目列表
|
||||
requestIapOrder() {
|
||||
console.log('------requestIapOrder' );
|
||||
// #ifdef APP-PLUS
|
||||
let ids = [this.productid];
|
||||
this.iap.requestOrder(ids, function(res) {
|
||||
console.log(res);
|
||||
this.iapOrder = true;
|
||||
}, function(e) {
|
||||
this.vm.jumpPay = false;
|
||||
showToasts("获取订单信息失败:" + e.code);
|
||||
});
|
||||
// #endif
|
||||
},
|
||||
// 支付
|
||||
goApplePay() {
|
||||
console.log('------goApplePay' );
|
||||
// 获取订单
|
||||
let _this = this;
|
||||
payApply().then(res => {
|
||||
// 发起支付
|
||||
plus.payment.request(this.iap, {
|
||||
productid: this.productid,
|
||||
username: res.data.out_trade_no,
|
||||
}, function(result){
|
||||
console.log(result);
|
||||
_this.appleNotify(result);
|
||||
}, function(e){
|
||||
// console.log(e);
|
||||
this.vm.jumpPay = false;
|
||||
showToasts("支付失败");
|
||||
});
|
||||
}).catch(err => {
|
||||
showToasts(err.message || '获取数据失败');
|
||||
})
|
||||
},
|
||||
appleNotify(notifyData) {
|
||||
console.log('------appleNotify' );
|
||||
|
||||
// 关闭支付弹窗
|
||||
this.popPayClose();
|
||||
|
||||
// 支付成功
|
||||
appleNotify({notify: notifyData}).then(res => {
|
||||
console.log(res);
|
||||
if(res.data == 1) {
|
||||
this.$emit('apply-pay-success');
|
||||
}
|
||||
}).catch(err => {
|
||||
showToasts("支付失败");
|
||||
});
|
||||
},
|
||||
// 回调处理,这里是用的前端回调返回给服务端处理
|
||||
getDevName(){
|
||||
// 获取使用环境
|
||||
if(uni.getSystemInfoSync().platform === 'android'){
|
||||
this.isAndroid = true
|
||||
// console.log('运行Android上')
|
||||
}else{
|
||||
this.isAndroid = false
|
||||
// console.log('运行iOS上')
|
||||
}
|
||||
},
|
||||
// 获取充值金额
|
||||
getData() {
|
||||
this.$http
|
||||
@@ -105,7 +214,32 @@
|
||||
let that = this
|
||||
that.payType = e
|
||||
},
|
||||
|
||||
//ios充值
|
||||
iosPay(){
|
||||
let that = this
|
||||
|
||||
let data = {
|
||||
userId: that.userInfo.id, //下单人ID
|
||||
userPhone: that.userInfo.tel, //收货人手机号
|
||||
paymentMethod: that.payType,
|
||||
orderMoney: that.stepsCj.money * 1, //订单金额
|
||||
districtMoney: 0, //优惠金额
|
||||
realMoney: that.stepsCj.money * 1, //实收金额
|
||||
orderStatus: 0, //订单状态
|
||||
orderType: "point", //订单类型
|
||||
}
|
||||
|
||||
$http.request({
|
||||
url: "book/buyorder/rechargeSave",
|
||||
method: "POST", // POST、GET、PUT、DELETE,具体说明查看官方文档
|
||||
data,
|
||||
header: { //默认 无 说明:请求头
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
}).then(res => {
|
||||
console.log(res)
|
||||
})
|
||||
},
|
||||
// 充值
|
||||
kaiChar() {
|
||||
let that = this
|
||||
@@ -129,18 +263,6 @@
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
}).then(res => {
|
||||
// let obj={
|
||||
// typePay: 'alipay',
|
||||
// subject: 'order',
|
||||
// // subject: 'point',
|
||||
// totalAmount: that.stepsCj.money,
|
||||
// type: that.payType,
|
||||
// relevanceoid: res.orderSn,
|
||||
// customerId:this.userInfo.id, // 用户id
|
||||
// // body: that.stepsCj.priceTypeId,
|
||||
// }
|
||||
// console.log(obj,'obj')
|
||||
// return false
|
||||
if (res.code == 0) {
|
||||
setPay({
|
||||
typePay: 'alipay',
|
||||
|
||||
@@ -593,18 +593,7 @@
|
||||
},
|
||||
...mapState(['userInfo']),
|
||||
},
|
||||
methods: {
|
||||
// scroll1: function(e) {
|
||||
// // console.log(e)
|
||||
// // this.old.scrollTop = e.detail.scrollTop
|
||||
// },
|
||||
// upper: function(e) {
|
||||
// console.log(e)
|
||||
// },
|
||||
// lower: function(e) {
|
||||
// console.log(e)
|
||||
// },
|
||||
// view的滑动事件
|
||||
methods: {
|
||||
scroll: function(e) {
|
||||
// this.oldType = "Vertical"
|
||||
// console.log(e.detail)
|
||||
|
||||
Reference in New Issue
Block a user