1169 lines
28 KiB
Vue
1169 lines
28 KiB
Vue
<template>
|
||
<view>
|
||
<u-popup v-model="shows" @close="close" :mask-close-able="false" :safe-area-inset-bottom="true" mode="bottom"
|
||
border-radius="32" closeable>
|
||
<view class="title">购买后继续观看</view>
|
||
<!-- <view class="money">
|
||
<view class="money-l flex align-center">
|
||
账号余额:
|
||
<text>{{moneyNum}}金豆</text>
|
||
<view class="money-l-go" @click="goWallet('/me/wallet/wallet')">
|
||
查看明细
|
||
</view>
|
||
</view>
|
||
<view class="money-r">
|
||
解锁价格:
|
||
<text>{{payPrice}}金豆</text>
|
||
</view>
|
||
</view> -->
|
||
<!-- <scroll-view scroll-y="true" class="payLists">
|
||
<view class="payList">
|
||
<view class="payList-item" @click="current = index" :class="current == index?'activePrice':''"
|
||
v-for="(item,index) in wallet" :key="index"> -->
|
||
<!-- #ifdef MP-TOUTIAO -->
|
||
<!-- <view class="payList-item-price">
|
||
{{item.payDiamond}}钻石
|
||
</view> -->
|
||
<!-- #endif -->
|
||
<!-- #ifndef MP-TOUTIAO -->
|
||
<!-- <view class="payList-item-price">
|
||
¥{{item.price}}
|
||
</view> -->
|
||
<!-- #endif -->
|
||
<!-- <view class="payList-item-dou">
|
||
{{item.money}}金豆
|
||
</view>
|
||
<view class="payList-item-duo" v-if="item.giveMoney>0">
|
||
多送{{item.giveMoney}}金豆
|
||
</view>
|
||
<view class="payList-item-hui" v-if="item.remarks">
|
||
{{item.remarks}}
|
||
</view>
|
||
</view>
|
||
</view>
|
||
</scroll-view> -->
|
||
<!-- 支付类型 -->
|
||
<view class="payType">
|
||
<view class="payType-item" @tap='selectWay(item)' v-for="(item,index) in openLists" :key="index">
|
||
<view class="payType-item-l">
|
||
<image :src="item.image" mode=""></image>
|
||
{{item.text}}
|
||
</view>
|
||
<view class="payType-item-r">
|
||
<radio-group name="openWay" style="margin-left: 20upx;">
|
||
<label class="tui-radio">
|
||
<radio color="#ff7581" :checked="openWay === item.id ? true : false" />
|
||
</label>
|
||
</radio-group>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
<view v-if="moneyTips" class="tips flex align-center justify-center">
|
||
<view class="tips-box">
|
||
<view class="tips-box-title">
|
||
温馨提示
|
||
</view>
|
||
<view class="tips-box-contont">
|
||
{{moneyTips}}
|
||
</view>
|
||
</view>
|
||
</view>
|
||
<view class="illustrate flex align-center justify-center">
|
||
<view class="illustrate-box flex align-center">
|
||
<u-checkbox active-color="#ff7581" v-model="checked" shape="circle"></u-checkbox>
|
||
<text @click="checked = !checked">
|
||
我已经阅读并同意
|
||
</text>
|
||
<view @click="goWallet('/me/setting/payXieYi')" class="illustrate-box-txt">
|
||
《付费须知说明》
|
||
</view>
|
||
</view>
|
||
</view>
|
||
<view class="sumbit flex align-center justify-center">
|
||
<view class="sumbit-box flex align-center justify-center">
|
||
<!-- #ifdef MP-WEIXIN -->
|
||
<button v-if="osName!='ios'"
|
||
style="background: #ff7581;color: #FFFFFF;width: 100%;height: 100%;border-radius: 44rpx;"
|
||
bindtap="getUserProfile" @tap="wxGetUserInfo">
|
||
确认支付
|
||
</button>
|
||
<block v-else>
|
||
<button v-if="isAccountPay=='是'"
|
||
style=" background: #ff7581;color: #FFFFFF;width: 100%;height: 100%;border-radius: 44rpx;"
|
||
@tap="wxPayMoney()">
|
||
确认支付
|
||
</button>
|
||
<button v-else
|
||
style="background: #ff7581;color: #FFFFFF;width: 100%;height: 100%;border-radius: 44rpx;"
|
||
@tap="goMsg()">
|
||
联系客服
|
||
</button>
|
||
</block>
|
||
|
||
|
||
<!-- #endif -->
|
||
<!-- #ifndef MP-WEIXIN -->
|
||
<view @tap="pay()" class="flex align-center justify-center"
|
||
style="background: #ff7581;color: #FFFFFF;width: 100%;height: 100%;border-radius: 44rpx;">
|
||
确认支付
|
||
</view>
|
||
<!-- #endif -->
|
||
</view>
|
||
</view>
|
||
</u-popup>
|
||
<!-- 关注公众号弹窗 -->
|
||
<u-popup v-model="showAccount" width="500" mode="center" border-radius="14" closeable>
|
||
<view class="showAccount-title">请关注公众号充值</view>
|
||
<view class="showAccount-img">
|
||
<image :show-menu-by-longpress="true" @click="prewImg(accountImg)" :src="accountImg" mode=""></image>
|
||
</view>
|
||
<view class="showAccount-txt">
|
||
长按/点击二维码后长按识别
|
||
</view>
|
||
</u-popup>
|
||
</view>
|
||
</template>
|
||
|
||
<script>
|
||
export default {
|
||
name: "payPopus",
|
||
props: {
|
||
show: {
|
||
type: Boolean,
|
||
default: true
|
||
},
|
||
orderId: {
|
||
type: Number,
|
||
default: null
|
||
},
|
||
//需要支付的金豆
|
||
payPrice: {
|
||
type: Number,
|
||
default: 0
|
||
}
|
||
},
|
||
data() {
|
||
return {
|
||
shows: false,
|
||
wallet: [],
|
||
current: 0,
|
||
productId: '', //默认苹果内购商品ID
|
||
productIds: ['sixzuan', 'shierzuan'], //苹果内购商品
|
||
moneyNum: 0,
|
||
osName: '',
|
||
openLists: [],
|
||
openWay: 1,
|
||
OfferID: '',
|
||
payEnv: '',
|
||
moneyTips: '',
|
||
isAccountPay: '否', //是否开启公众号支付
|
||
showAccount: false, //打开关注公众号弹窗
|
||
accountImg: '', //公众号二维码
|
||
sessionkey: '',
|
||
iapChannel: null,
|
||
iosPayId: '',
|
||
checked: false,
|
||
};
|
||
|
||
},
|
||
created() {
|
||
this.shows = this.show
|
||
this.getAccountImg()
|
||
this.getMoneyList()
|
||
this.getMyMoney()
|
||
this.isAccountPay = uni.getStorageSync('isAccountPay')
|
||
this.OfferID = uni.getStorageSync('OfferID')
|
||
this.payEnv = Number(uni.getStorageSync('payEnv'))
|
||
this.moneyTips = uni.getStorageSync('moneyTips')
|
||
// #ifdef MP-WEIXIN || MP-TOUTIAO
|
||
this.osName = uni.getSystemInfoSync().osName;
|
||
// #endif
|
||
// #ifdef APP-PLUS
|
||
if (plus.os.name.toLowerCase() === 'android') {
|
||
this.openLists = [
|
||
// {
|
||
// image: '/static/images/pay/weixin.png',
|
||
// text: '微信',
|
||
// id: 2
|
||
// },
|
||
{
|
||
image: '/static/images/pay/zhifubao.png',
|
||
text: '支付宝',
|
||
id: 1
|
||
}
|
||
];
|
||
this.openWay = 1;
|
||
let syPaySel = this.$queue.getData('syPaySel')
|
||
// if (syPaySel === '是') {
|
||
// let openListsItem = {
|
||
// image: '/static/images/pay/shouyi.png',
|
||
// text: '收益余额',
|
||
// id: 4
|
||
// };
|
||
// this.openLists.push(openListsItem)
|
||
// }
|
||
} else {
|
||
let checkIosPay = this.$queue.getData('checkIosPay');
|
||
// if (checkIosPay === '是') {
|
||
// this.openLists = [{
|
||
// image: '/static/images/pay/weixin.png',
|
||
// text: '苹果',
|
||
// id: 3
|
||
// }];
|
||
// this.openWay = 3;
|
||
// } else {
|
||
this.openLists = [
|
||
// {
|
||
// image: '/static/images/pay/weixin.png',
|
||
// text: '微信',
|
||
// id: 2
|
||
// },
|
||
{
|
||
image: '/static/images/pay/zhifubao.png',
|
||
text: '支付宝',
|
||
id: 1
|
||
}
|
||
];
|
||
this.openWay = 1;
|
||
let syPaySel = this.$queue.getData('syPaySel')
|
||
// if (syPaySel === '是') {
|
||
// let openListsItem = {
|
||
// image: '/static/images/pay/shouyi.png',
|
||
// text: '收益余额',
|
||
// id: 4
|
||
// };
|
||
// this.openLists.push(openListsItem)
|
||
// }
|
||
// }
|
||
}
|
||
|
||
// #endif
|
||
|
||
// #ifdef MP-WEIXIN
|
||
this.openLists = [{
|
||
image: '/static/images/pay/weixin.png',
|
||
text: '微信',
|
||
id: 2
|
||
}];
|
||
this.openWay = 2;
|
||
// #endif
|
||
|
||
// #ifdef H5
|
||
let ua = navigator.userAgent.toLowerCase();
|
||
// if (ua.indexOf('micromessenger') !== -1) {
|
||
// this.openLists = [{
|
||
// image: '/static/images/pay/weixin.png',
|
||
// text: '微信',
|
||
// id: 2
|
||
// }];
|
||
// this.openWay = 2;
|
||
// } else {
|
||
this.openLists = [{
|
||
image: '/static/images/pay/zhifubao.png',
|
||
text: '支付宝',
|
||
id: 1
|
||
}];
|
||
this.openWay = 1;
|
||
// }
|
||
|
||
let syPaySel = this.$queue.getData('syPaySel')
|
||
// if (syPaySel === '是') {
|
||
// let openListsItem = {
|
||
// image: '/static/images/pay/shouyi.png',
|
||
// text: '收益余额',
|
||
// id: 4
|
||
// };
|
||
// this.openLists.push(openListsItem)
|
||
// }
|
||
// #endif
|
||
},
|
||
methods: {
|
||
wxPayMoney() {
|
||
let that = this
|
||
if (this.checked == false) {
|
||
uni.showToast({
|
||
title: '请阅读并同意《付费须知说明》',
|
||
icon: 'none'
|
||
})
|
||
return
|
||
}
|
||
if (this.current == -1) {
|
||
uni.showToast({
|
||
title: '请选择充值',
|
||
icon: 'none'
|
||
})
|
||
return
|
||
}
|
||
let data = {
|
||
payClassifyId: this.wallet[this.current].payClassifyId,
|
||
classify: 3,
|
||
}
|
||
this.$Request.postT('/app/wxPay/payMoney', data).then(res => {
|
||
if (res.code == 0) {
|
||
uni.requestPayment({
|
||
provider: 'wxpay',
|
||
timeStamp: res.data.timestamp,
|
||
nonceStr: res.data.noncestr,
|
||
package: res.data.package,
|
||
signType: res.data.signType,
|
||
paySign: res.data.sign,
|
||
success: function(suc) {
|
||
console.log('success:' + JSON.stringify(suc));
|
||
uni.hideLoading()
|
||
uni.showToast({
|
||
title: '支付成功',
|
||
icon: 'success'
|
||
})
|
||
that.getMyMoney()
|
||
//支付成功后通知父组件
|
||
that.$emit('paySuccess', true)
|
||
},
|
||
fail: function(err) {
|
||
uni.hideLoading()
|
||
uni.showToast({
|
||
title: '支付失败',
|
||
icon: 'none'
|
||
})
|
||
}
|
||
});
|
||
} else {
|
||
uni.hideLoading()
|
||
uni.showToast({
|
||
title: res.msg,
|
||
icon: 'none'
|
||
})
|
||
}
|
||
})
|
||
},
|
||
//去充值页面
|
||
goWallet(url) {
|
||
uni.navigateTo({
|
||
url: url
|
||
})
|
||
},
|
||
iphonepay() {
|
||
let that = this
|
||
plus.payment.getChannels((res) => {
|
||
let channel = res.find(i => i.id === 'appleiap')
|
||
that.iapChannel = channel ? channel : null
|
||
that.requestOrder()
|
||
})
|
||
},
|
||
requestOrder() {
|
||
let that = this
|
||
console.log(that.productIds)
|
||
// ['xxxxx'] 是平台申请拿到的内购商品的id
|
||
that.iapChannel.requestOrder(that.productIds, function(event) {
|
||
uni.hideLoading()
|
||
console.log(event)
|
||
}, function(erroemsg) {
|
||
uni.hideLoading()
|
||
uni.showToast({
|
||
title: "获取支付通道失败:" + errormsg.message,
|
||
icon: 'none'
|
||
})
|
||
})
|
||
},
|
||
async topay() {
|
||
let that = this
|
||
uni.showLoading({
|
||
title: '充值中,请勿离开!',
|
||
mask: true
|
||
})
|
||
let productId = that.wallet[that.current].productId ? that.wallet[that.current].productId : '';
|
||
plus.payment.request(that.iapChannel, {
|
||
productid: productId,
|
||
optimize: true // 支付时设置 optimize: true
|
||
}, result => {
|
||
that.getIosSaveMessage(JSON.stringify(result));
|
||
// 支付成功回调
|
||
// console.log("plus.payment.request-success--------------------",JSON.stringify(results));
|
||
uni.showLoading({
|
||
title: '查询结果中,请勿离开!',
|
||
mask: true
|
||
})
|
||
|
||
}, e => {
|
||
uni.hideLoading();
|
||
that.$queue.showToast('支付失败');
|
||
});
|
||
},
|
||
|
||
async getIosSaveMessage(receipt) {
|
||
let that = this;
|
||
that.$Request.postT('/app/ios/isoPayApp?receipt=' + receipt + '&ordersId=' + that.iosPayId).then(
|
||
res => {
|
||
uni.hideLoading();
|
||
if (res.status == 0) {
|
||
uni.showToast({
|
||
title: '支付成功',
|
||
duration: 2000,
|
||
})
|
||
that.getMyMoney()
|
||
//支付成功后通知父组件
|
||
that.$emit('paySuccess', true)
|
||
}
|
||
});
|
||
},
|
||
//充值
|
||
pay() {
|
||
if (this.checked == false) {
|
||
uni.showToast({
|
||
title: '请阅读并同意《付费须知说明》',
|
||
icon: 'none'
|
||
})
|
||
return
|
||
}
|
||
let that = this
|
||
// #ifdef MP-TOUTIAO
|
||
let userId = this.$queue.getData('userId');
|
||
let data = {
|
||
payClassifyId: this.wallet[this.current].payClassifyId,
|
||
userId: userId
|
||
}
|
||
if (this.osName == 'ios') {
|
||
data.ios = 1
|
||
}
|
||
uni.showLoading({
|
||
title: '支付中...'
|
||
})
|
||
this.$Request.postT('/app/dyPay/payVirtualMoney', data).then(res => {
|
||
if (res.code == 0) {
|
||
tt.requestOrder({
|
||
data: JSON.stringify(res.data.data), // 请勿在前端对data做任何处理
|
||
byteAuthorization: res.data
|
||
.byteAuthorization, // 请勿在前端对byteAuthorization做任何处理
|
||
success(redd) {
|
||
console.log(JSON.stringify(redd))
|
||
tt.getOrderPayment({
|
||
orderId: redd.orderId,
|
||
success(reee) {
|
||
uni.hideLoading()
|
||
uni.showToast({
|
||
title: '支付成功',
|
||
duration: 1000,
|
||
})
|
||
that.getMyMoney()
|
||
//支付成功后通知父组件
|
||
that.$emit('paySuccess', true)
|
||
},
|
||
fail(ee) {
|
||
uni.hideLoading()
|
||
console.log(ee)
|
||
uni.showToast({
|
||
title: '支付失败,请重试',
|
||
icon: 'none',
|
||
duration: 2000,
|
||
})
|
||
}
|
||
});
|
||
},
|
||
fail(e) {
|
||
uni.hideLoading()
|
||
uni.showToast({
|
||
title: '支付失败,请重试',
|
||
icon: 'none',
|
||
duration: 2000,
|
||
})
|
||
console.log(e)
|
||
}
|
||
});
|
||
} else {
|
||
uni.hideLoading()
|
||
uni.showToast({
|
||
title: res.msg,
|
||
icon: 'none'
|
||
})
|
||
}
|
||
})
|
||
// #endif
|
||
// #ifndef MP-TOUTIAO
|
||
if (this.openWay == 2) {
|
||
// #ifdef APP-PLUS
|
||
// 微信APP支付 根据订单id获取支付信息
|
||
this.$Request.postT("/app/wxPay/payMoney", {
|
||
classify: 1,
|
||
payClassifyId: this.wallet[this.current].payClassifyId,
|
||
}).then(ret => {
|
||
this.isCheckPay(ret.code, 'wxpay', JSON.stringify(ret.data));
|
||
});
|
||
// #endif
|
||
|
||
// #ifdef MP-WEIXIN
|
||
// 微信小程序支付
|
||
this.$Request.postT('/app/wxPay/payMoneyOrders', {
|
||
payClassifyId: this.wallet[this.current].payClassifyId,
|
||
classify: 3,
|
||
}).then(res => {
|
||
if (res.code == 0) {
|
||
let data = {
|
||
sessionKey: this.sessionkey,
|
||
signData: {
|
||
offerId: this.OfferID, //offerId
|
||
buyQuantity: 1, //购买数量
|
||
env: this.payEnv, //环境配置, 0 米大师正式环境, 1 米大师沙箱环境, 默认为 0
|
||
currencyType: 'CNY', //币种 CNY-人民币
|
||
productId: this.wallet[this.current].wxGoodsId, //道具id
|
||
goodsPrice: Number(this.wallet[this.current].price * 100), //价格 单位:分
|
||
outTradeNo: res.data.orderId, //业务订单号
|
||
attach: '' //透传数据, 发货通知时会透传给开发者
|
||
}
|
||
}
|
||
this.$Request.postJson('/app/wxPay/selectSign', data).then(ret => {
|
||
if (ret.code == 0) {
|
||
wx.requestVirtualPayment({
|
||
signData: JSON.stringify(data.signData),
|
||
mode: 'short_series_goods',
|
||
paySig: ret.data.paySig,
|
||
signature: ret.data.signature,
|
||
success(ree) {
|
||
uni.hideLoading()
|
||
uni.showToast({
|
||
title: '支付成功'
|
||
})
|
||
that.getMyMoney()
|
||
//支付成功后通知父组件
|
||
that.$emit('paySuccess', true)
|
||
},
|
||
fail(err) {
|
||
console.log(err, '拉起支付失败')
|
||
uni.hideLoading()
|
||
uni.showToast({
|
||
title: '支付失败,请重试',
|
||
icon: 'none'
|
||
})
|
||
}
|
||
})
|
||
} else {
|
||
uni.hideLoading()
|
||
uni.showToast({
|
||
title: ret.msg,
|
||
icon: 'none'
|
||
})
|
||
}
|
||
})
|
||
} else {
|
||
uni.hideLoading()
|
||
uni.showToast({
|
||
title: res.msg,
|
||
icon: 'none'
|
||
})
|
||
}
|
||
})
|
||
// #endif
|
||
// #ifdef H5
|
||
let ua = navigator.userAgent.toLowerCase();
|
||
if (ua.indexOf('micromessenger') !== -1) {
|
||
let data = {
|
||
classify: 2,
|
||
payClassifyId: this.wallet[this.current].payClassifyId,
|
||
}
|
||
this.$Request.postT('/app/wxPay/payMoney', data).then(res => {
|
||
if (res.code == 0) {
|
||
this.callPay(res.data);
|
||
} else {
|
||
uni.showToast({
|
||
icon: 'none',
|
||
title: '支付失败!'
|
||
});
|
||
}
|
||
});
|
||
}
|
||
// #endif
|
||
|
||
} else if (this.openWay == 1) {
|
||
console.log(this.orderId)
|
||
// APP支付宝支付
|
||
// #ifdef APP
|
||
this.$Request.getT("/app/wuyou/payOrder/"+this.orderId, {}).then(ret => {
|
||
console.log(ret)
|
||
// this.isCheckPay(ret.code, 'alipay', ret.data);
|
||
that.$emit('paySuccess', ret.data)
|
||
});
|
||
// #endif
|
||
// #ifdef H5
|
||
let data = {
|
||
orderId: this.orderId,
|
||
}
|
||
this.$Request.getT("/app/wuyou/payOrder/"+this.orderId, {}).then(
|
||
res => {
|
||
if (res.code === 0) {
|
||
console.log(res)
|
||
that.$emit('paySuccess', res.data)
|
||
// const div = document.createElement('div')
|
||
// div.innerHTML = res.data //此处form就是后台返回接收到的数据
|
||
// document.body.appendChild(div)
|
||
// document.forms[0].submit()
|
||
} else {
|
||
uni.showToast({
|
||
icon: 'none',
|
||
title: '支付失败!'
|
||
});
|
||
}
|
||
});
|
||
// #endif
|
||
} else if (this.openWay == 3) {
|
||
let userId = this.$queue.getData('userId');
|
||
let data = {
|
||
payClassifyId: this.wallet[this.current].payClassifyId,
|
||
userId: userId
|
||
}
|
||
this.$Request.postT("/app/ios/insertPayMoneyOrders", data).then(res => {
|
||
if (res.code === 0) {
|
||
this.iosPayId = res.data.orderId;
|
||
// this.iphonepay();
|
||
} else {
|
||
uni.showToast({
|
||
icon: 'none',
|
||
title: '支付失败!'
|
||
});
|
||
}
|
||
});
|
||
} else if (this.openWay == 4) {
|
||
let userId = this.$queue.getData('userId');
|
||
let data = {
|
||
// money: this.wallet[this.current].price
|
||
payClassifyId: this.wallet[this.current].payClassifyId,
|
||
userId: userId
|
||
}
|
||
this.$Request.postT("/app/invite/inviteMoneyConvertUserMoney", data).then(res => {
|
||
if (res.code === 0) {
|
||
uni.hideLoading();
|
||
uni.showToast({
|
||
icon: 'none',
|
||
title: '支付成功'
|
||
})
|
||
that.getMyMoney()
|
||
//支付成功后通知父组件
|
||
that.$emit('paySuccess', true)
|
||
} else {
|
||
uni.showToast({
|
||
icon: 'none',
|
||
title: res.msg
|
||
});
|
||
}
|
||
});
|
||
}
|
||
// #endif
|
||
|
||
},
|
||
//安卓小程序支付
|
||
wxGetUserInfo() {
|
||
if (this.checked == false) {
|
||
uni.showToast({
|
||
title: '请阅读并同意《付费须知说明》',
|
||
icon: 'none'
|
||
})
|
||
return
|
||
}
|
||
let that = this
|
||
uni.showLoading({
|
||
title: '支付中'
|
||
})
|
||
uni.login({
|
||
provider: 'weixin',
|
||
success: function(loginRes) {
|
||
console.log(loginRes, '111111111111')
|
||
let data = {
|
||
code: loginRes.code
|
||
}
|
||
that.$Request.getT('/app/Login/wxLogin', data).then(res => {
|
||
if (res.code == 0 && res.data) {
|
||
that.sessionkey = res.data.session_key;
|
||
that.pay()
|
||
} else {
|
||
uni.hideLoading()
|
||
uni.showToast({
|
||
title: res.msg,
|
||
icon: 'none'
|
||
})
|
||
}
|
||
})
|
||
}
|
||
})
|
||
},
|
||
callPay: function(response) {
|
||
if (typeof WeixinJSBridge === "undefined") {
|
||
if (document.addEventListener) {
|
||
document.addEventListener('WeixinJSBridgeReady', this.onBridgeReady(response), false);
|
||
} else if (document.attachEvent) {
|
||
document.attachEvent('WeixinJSBridgeReady', this.onBridgeReady(response));
|
||
document.attachEvent('onWeixinJSBridgeReady', this.onBridgeReady(response));
|
||
}
|
||
} else {
|
||
this.onBridgeReady(response);
|
||
}
|
||
},
|
||
onBridgeReady: function(response) {
|
||
let that = this;
|
||
if (!response.package) {
|
||
return;
|
||
}
|
||
console.log(response, '++++++++')
|
||
WeixinJSBridge.invoke(
|
||
'getBrandWCPayRequest', {
|
||
"appId": response.appid, //公众号名称,由商户传入
|
||
"timeStamp": response.timestamp, //时间戳,自1970年以来的秒数
|
||
"nonceStr": response.noncestr, //随机串
|
||
"package": response.package,
|
||
"signType": response.signType, //微信签名方式:
|
||
"paySign": response.sign //微信签名
|
||
},
|
||
function(res) {
|
||
console.log(res, '/*-/*-/*-')
|
||
if (res.err_msg === "get_brand_wcpay_request:ok") {
|
||
// 使用以上方式判断前端返回,微信团队郑重提示:
|
||
//res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠。
|
||
uni.hideLoading();
|
||
uni.showLoading({
|
||
title: '支付成功'
|
||
});
|
||
//支付成功后通知父组件
|
||
that.$emit('paySuccess', true)
|
||
} else {
|
||
uni.hideLoading();
|
||
}
|
||
WeixinJSBridge.log(response.err_msg);
|
||
}
|
||
);
|
||
},
|
||
isCheckPay(status, name, order) {
|
||
if (status == 0) {
|
||
this.setPayment(name, order);
|
||
} else {
|
||
uni.hideLoading();
|
||
uni.showToast({
|
||
title: '支付信息有误',
|
||
icon: 'none'
|
||
});
|
||
}
|
||
},
|
||
setPayment(name, order) {
|
||
console.log('*-*-*')
|
||
let that = this
|
||
uni.requestPayment({
|
||
provider: name,
|
||
orderInfo: order, //微信、支付宝订单数据
|
||
success: function(res) {
|
||
console.log(res)
|
||
uni.hideLoading();
|
||
uni.showLoading({
|
||
title: '支付成功'
|
||
});
|
||
//支付成功后通知父组件
|
||
that.$emit('paySuccess', true)
|
||
},
|
||
fail: function(err) {
|
||
console.log(err)
|
||
uni.hideLoading();
|
||
},
|
||
complete() {
|
||
uni.hideLoading();
|
||
}
|
||
});
|
||
},
|
||
//预览二维码
|
||
prewImg(img) {
|
||
uni.previewImage({
|
||
urls: [img]
|
||
})
|
||
},
|
||
//获取公众号二维码
|
||
getAccountImg() {
|
||
this.$Request.get('/app/common/type/2').then(res => {
|
||
if (res.code == 0 && res.data) {
|
||
this.accountImg = res.data.value
|
||
}
|
||
});
|
||
},
|
||
//联系客服/打开公众号充值
|
||
goMsg() {
|
||
if (this.isAccountPay == '是') {
|
||
this.showAccount = true //打开公众号二维码弹窗
|
||
} else {
|
||
let kefu = uni.getStorageSync('kefu'); // 用户端联系方式 1 手机号 2企业微信
|
||
let kefuPhone = uni.getStorageSync('kefuPhone');
|
||
if (kefu == 1) {
|
||
uni.navigateTo({
|
||
url: '/me/setting/kefu'
|
||
})
|
||
} else if (kefu == 3) {
|
||
uni.makePhoneCall({
|
||
phoneNumber: kefuPhone //仅为示例
|
||
});
|
||
} else if (kefu == 2) {
|
||
// #ifdef MP-WEIXIN
|
||
let that = this
|
||
try {
|
||
wx.openCustomerServiceChat({
|
||
extInfo: {
|
||
url: uni.getStorageSync('kefuUrl')
|
||
},
|
||
corpId: uni.getStorageSync('kefuAppId'),
|
||
success(res) {},
|
||
fail(res) {
|
||
console.error(res)
|
||
}
|
||
})
|
||
} catch (error) {
|
||
console.error("catchcatch" + error)
|
||
uni.showToast({
|
||
title: '请更新至微信最新版本'
|
||
});
|
||
}
|
||
// #endif
|
||
// #ifndef MP-WEIXIN
|
||
let url = uni.getStorageSync('kefuUrl');
|
||
if (url.indexOf('/pages/') !== -1 || url.indexOf('/my/') !== -1) {
|
||
uni.navigateTo({
|
||
url
|
||
});
|
||
} else {
|
||
//#ifndef H5
|
||
uni.navigateTo({
|
||
url: '/pages/index/webView?url=' + url
|
||
});
|
||
//#endif
|
||
//#ifdef H5
|
||
window.location.href = url;
|
||
//#endif
|
||
}
|
||
// #endif
|
||
}
|
||
}
|
||
|
||
},
|
||
//选择支付类型
|
||
selectWay: function(item) {
|
||
this.openWay = item.id;
|
||
},
|
||
close() {
|
||
this.$emit('closeMoney', false)
|
||
},
|
||
//获取
|
||
getMyMoney() {
|
||
if (uni.getStorageSync('token')) {
|
||
this.$Request.getT('/app/moneyDetails/selectUserMoney').then(res => {
|
||
if (res.code == 0) {
|
||
this.moneyNum = res.data.money
|
||
}
|
||
})
|
||
}
|
||
|
||
},
|
||
findMinMaxPricesWithIndexes(array) {
|
||
// 初始化最小和最大价格为无穷大和小于无穷大的值
|
||
// 同时初始化对应的索引为-1,表示还未找到
|
||
let minPrice = Infinity;
|
||
let maxPrice = -Infinity;
|
||
let minPriceIndex = -1;
|
||
let maxPriceIndex = -1;
|
||
|
||
// 遍历数组中的每个元素
|
||
for (let i = 0; i < array.length; i++) {
|
||
const currentPrice = array[i].price;
|
||
|
||
// 检查当前价格是否比已知的最小价格更小
|
||
if (currentPrice < minPrice) {
|
||
minPrice = currentPrice;
|
||
minPriceIndex = i;
|
||
}
|
||
|
||
// 检查当前价格是否比已知的最大价格更大
|
||
if (currentPrice > maxPrice) {
|
||
maxPrice = currentPrice;
|
||
maxPriceIndex = i;
|
||
}
|
||
}
|
||
|
||
// 返回一个包含最小和最大价格及其索引的对象
|
||
return {
|
||
minPrice: minPrice,
|
||
minPriceIndex: minPriceIndex,
|
||
maxPrice: maxPrice,
|
||
maxPriceIndex: maxPriceIndex
|
||
};
|
||
},
|
||
/**
|
||
* 获取充值列表
|
||
*/
|
||
getMoneyList() {
|
||
this.$Request.getT('/app/payClassify/selectPayClassifyList').then(res => {
|
||
if (res.code == 0) {
|
||
let priceObj = this.findMinMaxPricesWithIndexes(res.data)
|
||
console.log(priceObj, 'bbbbbbbbbb')
|
||
this.wallet = res.data
|
||
this.wallet[priceObj.minPriceIndex].remarks = '特惠'
|
||
this.wallet[priceObj.maxPriceIndex].remarks = '80%用户选择'
|
||
} else {
|
||
uni.showToast({
|
||
title: res.msg,
|
||
icon: 'none'
|
||
})
|
||
}
|
||
})
|
||
},
|
||
},
|
||
}
|
||
</script>
|
||
|
||
<style lang="scss" scoped>
|
||
.title {
|
||
width: 100%;
|
||
padding-left: 30rpx;
|
||
color: #333333;
|
||
font-size: 32rpx;
|
||
font-weight: 500;
|
||
margin-top: 30rpx;
|
||
}
|
||
|
||
.money {
|
||
width: 100%;
|
||
padding: 0 30rpx;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: space-between;
|
||
color: #353535;
|
||
font-size: 26rpx;
|
||
margin-top: 30rpx;
|
||
|
||
.money-l {
|
||
text {
|
||
font-weight: bold;
|
||
margin-left: 10rpx;
|
||
}
|
||
|
||
.money-l-go {
|
||
margin-left: 10rpx;
|
||
color: #F6495A;
|
||
}
|
||
}
|
||
|
||
.money-r {
|
||
text {
|
||
color: #ff7581;
|
||
margin-left: 10rpx;
|
||
}
|
||
}
|
||
}
|
||
|
||
.activePrice {
|
||
background: linear-gradient(90deg, #FDECCB 0%, #F7D98D 100%) !important;
|
||
|
||
.payList-item-price {
|
||
color: #744A0A !important;
|
||
}
|
||
|
||
.payList-item-dou {
|
||
color: #744A0A !important;
|
||
}
|
||
}
|
||
|
||
.payLists {
|
||
width: 100%;
|
||
height: 440rpx;
|
||
}
|
||
|
||
.payList {
|
||
width: 100%;
|
||
height: 100%;
|
||
margin-top: 20rpx;
|
||
padding: 0 30rpx;
|
||
display: flex;
|
||
justify-content: space-between;
|
||
flex-wrap: wrap;
|
||
|
||
|
||
|
||
|
||
.payList-item {
|
||
margin-top: 20rpx;
|
||
width: 332rpx;
|
||
height: 194rpx;
|
||
background-color: #F5F7FF;
|
||
border-radius: 24rpx;
|
||
display: flex;
|
||
flex-wrap: wrap;
|
||
align-content: center;
|
||
position: relative;
|
||
}
|
||
|
||
.payList-item-hui {
|
||
position: absolute;
|
||
top: -10rpx;
|
||
left: 0;
|
||
background-color: #F6495A;
|
||
border-radius: 16rpx 16rpx 16rpx 0rpx;
|
||
color: #ffffff;
|
||
font-size: 20rpx;
|
||
padding: 4rpx 10rpx;
|
||
}
|
||
|
||
.payList-item-price {
|
||
color: #191919;
|
||
font-size: 48rpx;
|
||
font-weight: bold;
|
||
width: 100%;
|
||
text-align: center;
|
||
}
|
||
|
||
.payList-item-dou {
|
||
color: #666666;
|
||
font-size: 26rpx;
|
||
width: 100%;
|
||
text-align: center;
|
||
}
|
||
|
||
.payList-item-duo {
|
||
color: #FF1930;
|
||
font-size: 28rpx;
|
||
font-weight: 500;
|
||
margin-top: 4rpx;
|
||
width: 100%;
|
||
text-align: center;
|
||
}
|
||
}
|
||
|
||
.payType {
|
||
width: calc(100% - 60rpx);
|
||
margin: 0 auto;
|
||
margin-top: 30rpx;
|
||
|
||
.payType-item {
|
||
width: 100%;
|
||
margin-bottom: 20rpx;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: space-between;
|
||
}
|
||
|
||
.payType-item-l {
|
||
display: flex;
|
||
align-items: center;
|
||
|
||
image {
|
||
width: 56rpx;
|
||
height: 56rpx;
|
||
margin-right: 20rpx;
|
||
}
|
||
|
||
}
|
||
}
|
||
|
||
.sumbit {
|
||
width: 100%;
|
||
height: auto;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
margin-bottom: 20rpx;
|
||
|
||
.sumbit-box {
|
||
width: 686rpx;
|
||
height: 98rpx;
|
||
background: #ff7581;
|
||
border-radius: 50rpx;
|
||
color: #FFFFFF;
|
||
font-weight: bold;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
}
|
||
}
|
||
|
||
.showAccount-title {
|
||
width: 100%;
|
||
margin-top: 30rpx;
|
||
text-align: center;
|
||
font-weight: bold;
|
||
}
|
||
|
||
.showAccount-img {
|
||
width: 400rpx;
|
||
height: 400rpx;
|
||
margin: 0 auto;
|
||
margin-top: 20rpx;
|
||
|
||
image {
|
||
width: 100%;
|
||
height: 100%;
|
||
}
|
||
}
|
||
|
||
.showAccount-txt {
|
||
width: 100%;
|
||
text-align: center;
|
||
margin-top: 20rpx;
|
||
padding-bottom: 30rpx;
|
||
}
|
||
|
||
|
||
button::after {
|
||
border: none;
|
||
background-color: none;
|
||
}
|
||
|
||
button {
|
||
display: flex;
|
||
align-items: center;
|
||
position: relative;
|
||
display: block;
|
||
margin-left: auto;
|
||
margin-right: auto;
|
||
padding-left: 0px;
|
||
padding-right: 0px;
|
||
box-sizing: border-box;
|
||
text-decoration: none;
|
||
line-height: 88rpx;
|
||
overflow: hidden;
|
||
color: #000000;
|
||
/* background-color: #fff; */
|
||
background: rgba(255, 255, 255, 0);
|
||
font-size: 28rpx;
|
||
width: 100%;
|
||
height: 100%;
|
||
}
|
||
|
||
.tips {
|
||
width: 100%;
|
||
height: auto;
|
||
margin-top: 20rpx;
|
||
|
||
.tips-box {
|
||
width: 686rpx;
|
||
height: 100%;
|
||
}
|
||
|
||
.tips-box-title {
|
||
width: 100%;
|
||
font-size: 26rpx;
|
||
color: #333333;
|
||
font-weight: bold;
|
||
}
|
||
|
||
.tips-box-contont {
|
||
margin-top: 10rpx;
|
||
font-size: 24rpx;
|
||
color: gray;
|
||
}
|
||
|
||
}
|
||
|
||
.illustrate {
|
||
width: 100%;
|
||
margin: 30rpx 0;
|
||
|
||
.illustrate-box {
|
||
width: 686rpx;
|
||
}
|
||
|
||
.illustrate-box-txt {
|
||
color: #ff7581;
|
||
}
|
||
|
||
}
|
||
|
||
/deep/.u-radio__label {
|
||
display: none !important;
|
||
}
|
||
</style> |