Merge pull request 'dev-hxf' (#13) from dev-hxf into master
Reviewed-on: http://114.55.169.15:3000/huxiaofeng666/jwl-applet/pulls/13
This commit was merged in pull request #13.
This commit is contained in:
165
src/jtools/pay/index.js
Normal file
165
src/jtools/pay/index.js
Normal file
@@ -0,0 +1,165 @@
|
|||||||
|
import request from '../request/index.js';
|
||||||
|
// #ifdef H5
|
||||||
|
import wxsdk from '@/jtools/wechat/sdk'
|
||||||
|
// #endif
|
||||||
|
import wechat from '@/jtools/wechat/wechat'
|
||||||
|
import $platform from '@/jtools/platform';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 支付
|
||||||
|
*
|
||||||
|
* @param {String} payment = ['wechat','alipay','wallet'] - 支付方式
|
||||||
|
* @param {Object} order = {} - 订单详情
|
||||||
|
* @param {String} orderType = ['goods','recharge'] - 订单类型
|
||||||
|
*/
|
||||||
|
|
||||||
|
export default class JtoolsPay {
|
||||||
|
|
||||||
|
|
||||||
|
// wxOfficialAccount wxMiniProgram App H5
|
||||||
|
// wechat 公众号JSSDK支付 小程序支付 微信开放平台支付 H5网页支付
|
||||||
|
// alipay 复制网址 复制网址 支付宝开放平台支付 直接跳转链接
|
||||||
|
// wallet v v v v
|
||||||
|
|
||||||
|
|
||||||
|
constructor(payment, order, orderType) {
|
||||||
|
this.payment = payment;
|
||||||
|
this.order = order;
|
||||||
|
this.orderType = orderType;
|
||||||
|
this.platform = $platform.get();
|
||||||
|
let payMehod = this.getPayMethod();
|
||||||
|
payMehod();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
getPayMethod() {
|
||||||
|
var payMethod = {
|
||||||
|
'wxMiniProgram': {
|
||||||
|
'wechat': () => {
|
||||||
|
this.wxMiniProgramPay()
|
||||||
|
},
|
||||||
|
},
|
||||||
|
'App': {
|
||||||
|
'wechat': () => {
|
||||||
|
this.wechatPay()
|
||||||
|
},
|
||||||
|
'alipay': () => {
|
||||||
|
this.aliPay()
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
return payMethod[this.platform][this.payment];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// 预支付
|
||||||
|
prepay() {
|
||||||
|
let that = this;
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
const p = $platform.device()
|
||||||
|
const tradeInfoType = p == 'android' ? 'Android' : p == 'ios' ? 'iOS' : 'Wap'
|
||||||
|
let params = {
|
||||||
|
orderId: this.order.orderId,
|
||||||
|
orderPayType: this.order.orderPayType,
|
||||||
|
money: this.order.money,
|
||||||
|
microServiceName: this.order.microServiceName,
|
||||||
|
prepayParamUrl: this.order.prepayParamUrl,
|
||||||
|
paymentType: 'weChatPay',
|
||||||
|
payType: 'JSAPI',
|
||||||
|
tradeInfoType: tradeInfoType,
|
||||||
|
tenantId: '-1',
|
||||||
|
clientType: 'miniWx'
|
||||||
|
}
|
||||||
|
if (uni.getStorageSync('openId')) {
|
||||||
|
params.openId = uni.getStorageSync('openId');
|
||||||
|
}
|
||||||
|
request({
|
||||||
|
url: 'driver-api/applet/pay/prepay',
|
||||||
|
method: 'POST',
|
||||||
|
param,
|
||||||
|
}).then(res => {
|
||||||
|
if (res.code == 'SUCCESS') {
|
||||||
|
resolve(res);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 微信小程序支付
|
||||||
|
async wxMiniProgramPay() {
|
||||||
|
let that = this;
|
||||||
|
let result = await this.prepay();
|
||||||
|
const params = result.data.jsApiResult
|
||||||
|
uni.requestPayment({
|
||||||
|
provider: 'wxpay',
|
||||||
|
...{
|
||||||
|
appId: params.appId, //公众号名称,由商户传入
|
||||||
|
timeStamp: params.timestamp, //时间戳,自1970年以来的秒数
|
||||||
|
nonceStr: params.nonceStr, //随机串
|
||||||
|
package: `prepay_id=${params.prepay_id}`,
|
||||||
|
signType: params.signType, //微信签名方式:
|
||||||
|
paySign: params.paySign, //微信签名
|
||||||
|
},
|
||||||
|
success: res => {
|
||||||
|
that.payResult('success', result.data.orderPayNo)
|
||||||
|
},
|
||||||
|
fail: err => {
|
||||||
|
console.log('支付取消或者失败:', err);
|
||||||
|
err.errMsg !== "requestPayment:fail cancel" && that.payResult('fail')
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// 支付宝支付
|
||||||
|
async aliPay() {
|
||||||
|
let that = this;
|
||||||
|
let result = await this.prepay();
|
||||||
|
if (result.code === 1) {
|
||||||
|
uni.requestPayment({
|
||||||
|
provider: 'alipay',
|
||||||
|
orderInfo: result.data.pay_data, //支付宝订单数据
|
||||||
|
success: res => {
|
||||||
|
that.payResult('success')
|
||||||
|
},
|
||||||
|
fail: err => {
|
||||||
|
console.log('支付取消或者失败:', err);
|
||||||
|
err.errMsg !== "requestPayment:fail cancel" && that.payResult('fail')
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 微信支付
|
||||||
|
async wechatPay() {
|
||||||
|
let that = this;
|
||||||
|
let result = await this.prepay();
|
||||||
|
if (result.code === 1) {
|
||||||
|
uni.requestPayment({
|
||||||
|
provider: 'wxpay',
|
||||||
|
orderInfo: JSON.parse(result.data.pay_data), //微信订单数据(官方说是string。实测为object)
|
||||||
|
success: res => {
|
||||||
|
that.payResult('success')
|
||||||
|
},
|
||||||
|
fail: err => {
|
||||||
|
err.errMsg !== "requestPayment:fail cancel" && that.payResult('fail')
|
||||||
|
console.log('支付取消或者失败:', err);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 支付结果跳转,success:成功,fail:失败
|
||||||
|
payResult(resultType, orderPayNo) {
|
||||||
|
const that = this;
|
||||||
|
let path = ''
|
||||||
|
uni.navigateTo({
|
||||||
|
url:path
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -43,7 +43,7 @@
|
|||||||
</swiper>
|
</swiper>
|
||||||
<view class="wp100 flex jc-sb ai-c p14 bc-fff" v-if="isShowAll" style="position: fixed;bottom: 0;left: 0;">
|
<view class="wp100 flex jc-sb ai-c p14 bc-fff" v-if="isShowAll" style="position: fixed;bottom: 0;left: 0;">
|
||||||
<view style="width: 220rpx;">
|
<view style="width: 220rpx;">
|
||||||
<button v-if="type==='practice'" class="btn">四步学科一</button>
|
<view v-if="type==='practice'" style="width: 220rpx;height: 80rpx;"></view>
|
||||||
<view v-else class="btn" style="text-align: center;" @tap="submitPaper">
|
<view v-else class="btn" style="text-align: center;" @tap="submitPaper">
|
||||||
<u-count-down ref="countDown_1" :time=" 1*60*60 * 1000" format="HH:mm:ss" @change="timeChange"></u-count-down>
|
<u-count-down ref="countDown_1" :time=" 1*60*60 * 1000" format="HH:mm:ss" @change="timeChange"></u-count-down>
|
||||||
<text>交卷</text>
|
<text>交卷</text>
|
||||||
@@ -117,7 +117,7 @@
|
|||||||
<view>
|
<view>
|
||||||
<view class="wp100 flex jc-sb p14 bc-fff">
|
<view class="wp100 flex jc-sb p14 bc-fff">
|
||||||
<view style="width: 220rpx;">
|
<view style="width: 220rpx;">
|
||||||
<button v-if="type==='practice'" class="btn">四步学科一</button>
|
<view v-if="type==='practice'" style="width: 220rpx;height: 80rpx;"></view>
|
||||||
<view v-else class="btn" style="text-align: center;" @tap="submitPaper">
|
<view v-else class="btn" style="text-align: center;" @tap="submitPaper">
|
||||||
<u-count-down ref="countDown_2" :time="1 * 60 * 60 * 1000" format="HH:mm:ss"></u-count-down>
|
<u-count-down ref="countDown_2" :time="1 * 60 * 60 * 1000" format="HH:mm:ss"></u-count-down>
|
||||||
<text>交卷</text>
|
<text>交卷</text>
|
||||||
@@ -508,8 +508,9 @@ export default {
|
|||||||
},
|
},
|
||||||
sectionChange(index) {
|
sectionChange(index) {
|
||||||
this.tCurrent = index
|
this.tCurrent = index
|
||||||
this.getQuestionList()
|
// this.getQuestionList()
|
||||||
this.renderSwiper(0)
|
// this.renderSwiper(0)
|
||||||
|
this.$emit('changeTab',index)
|
||||||
},
|
},
|
||||||
getQuestionList(val) {
|
getQuestionList(val) {
|
||||||
const arr = JSON.parse(val)
|
const arr = JSON.parse(val)
|
||||||
|
|||||||
@@ -30,8 +30,8 @@
|
|||||||
</view>
|
</view>
|
||||||
<view class="mt14 p14 bc-fff" style="border-radius: 20rpx;">
|
<view class="mt14 p14 bc-fff" style="border-radius: 20rpx;">
|
||||||
<text class="fs18 cor-000 fw600">常见考点</text>
|
<text class="fs18 cor-000 fw600">常见考点</text>
|
||||||
<view class="flex ai-c wp100 mt10" style="flex-wrap: wrap;">
|
<view class="flex ai-c wp100 mt15" style="flex-wrap: wrap;">
|
||||||
<view class="wp50 flex ai-c mb10" v-for="(item,index) of testCenterList" :key="index">
|
<view class="wp50 flex ai-c mb15" v-for="(item,index) of testCenterList" :key="index">
|
||||||
<view class="dot_item">{{index+1}}</view>
|
<view class="dot_item">{{index+1}}</view>
|
||||||
<text class="ml5">{{item.label}}</text>
|
<text class="ml5">{{item.label}}</text>
|
||||||
</view>
|
</view>
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<!-- <u-navbar :title="navTitle" @rightClick="rightClick" :autoBack="true">
|
<!-- <u-navbar :title="navTitle" @rightClick="rightClick" :autoBack="true">
|
||||||
</u-navbar> -->
|
</u-navbar> -->
|
||||||
<j-navbar>{{navTitle}}</j-navbar>
|
<j-navbar>{{navTitle}}</j-navbar>
|
||||||
<Question ref="question" :tabsList="tabsList" :isShowAll="isShowAll" :subject="subject" :navTitle="navTitle"></Question>
|
<Question ref="question" :tabsList="tabsList" :isShowAll="isShowAll" :subject="subject" :navTitle="navTitle" @changeTab="changeTab"></Question>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -93,6 +93,20 @@
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
...mapActions(useUserStore,['searchUserVip']),
|
...mapActions(useUserStore,['searchUserVip']),
|
||||||
|
changeTab(val){
|
||||||
|
if(val==1){
|
||||||
|
let list =JSON.parse(JSON.stringify(this.questionArr))
|
||||||
|
list=list.map(item=>{
|
||||||
|
return{
|
||||||
|
...item,
|
||||||
|
clickAnswer:item.trueAnswer
|
||||||
|
}
|
||||||
|
})
|
||||||
|
this.$refs.question.getQuestionList(JSON.stringify(list))
|
||||||
|
}else{
|
||||||
|
this.$refs.question.getQuestionList(JSON.stringify(this.questionArr))
|
||||||
|
}
|
||||||
|
},
|
||||||
rightClick() {
|
rightClick() {
|
||||||
console.log('返回');
|
console.log('返回');
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user