|
@@ -54,7 +54,8 @@
|
|
|
} from "vue";
|
|
|
import {
|
|
|
orderAdd,
|
|
|
- orderPayAli
|
|
|
+ orderPayAli,
|
|
|
+ orderPayWx,
|
|
|
} from "@/api/order.js"
|
|
|
import CustomTabBar from '@/components/custom-tabbar/custom-tabbar.vue';
|
|
|
import cacheManager from "@/utils/cacheManager.js";
|
|
@@ -106,65 +107,128 @@
|
|
|
|
|
|
function creatOrder(data) {
|
|
|
|
|
|
- if(payType.value =='weixin'){
|
|
|
- toast("微信支付暂未开通,请选择支付宝")
|
|
|
- return false
|
|
|
- }
|
|
|
- let req = {
|
|
|
- cardId: cardId.value
|
|
|
- }
|
|
|
- orderAdd(req).then(res => {
|
|
|
- console.log('res',res);
|
|
|
- orderPayAli({id:res.data.id}).then(res2=>{
|
|
|
- console.log('res2',res2);
|
|
|
- uni.requestPayment({
|
|
|
- "provider": "alipay",
|
|
|
- "orderInfo": res2.data.text, //此处为服务器返回的订单信息字符串
|
|
|
- success: function (res) {
|
|
|
- var rawdata = JSON.parse(res.rawdata);
|
|
|
- console.log('支付成功');
|
|
|
- console.log('rawdata',rawdata);
|
|
|
- // toast("支付成功");
|
|
|
- cacheManager.updateVipStatus('auth', cardId.value)
|
|
|
- cacheManager.updateObject('auth', {
|
|
|
- growthType: 1
|
|
|
- })
|
|
|
- if (isVip != 'VIP') {
|
|
|
- daoPokeRef.value.handleShow();
|
|
|
- } else {
|
|
|
- daoPokeAllRef.value.handleShow();
|
|
|
- }
|
|
|
- setTimeout(() => {
|
|
|
- daoPokeRef.value.handleClose();
|
|
|
- daoPokeAllRef.value.handleClose();
|
|
|
- if(formPage.value =='my'){
|
|
|
- uni.redirectTo({
|
|
|
- url: '/pages/my/index'
|
|
|
- })
|
|
|
- }else{
|
|
|
- uni.redirectTo({
|
|
|
- url: '/pages/study/index'
|
|
|
- })
|
|
|
- }
|
|
|
- }, 3000)
|
|
|
- },
|
|
|
- fail: function (err) {
|
|
|
- // toast('支付失败:' + JSON.stringify(err));
|
|
|
- console.log('支付失败:' + JSON.stringify(err));
|
|
|
- }
|
|
|
- });
|
|
|
+ if (payType.value == 'weixin') {
|
|
|
+ let req = {
|
|
|
+ cardId: cardId.value
|
|
|
+ }
|
|
|
+ orderAdd(req).then(res => {
|
|
|
+ console.log('res', res);
|
|
|
+ console.log(' res.data.id', res.data.id);
|
|
|
+ orderPayWx({
|
|
|
+ id: res.data.id
|
|
|
+ }).then(res2 => {
|
|
|
+ console.log('res2', res2);
|
|
|
+ uni.requestPayment({
|
|
|
+ "provider": "wxpay",
|
|
|
+ "orderInfo": {
|
|
|
+ "appid": res2.data.appid, // 应用ID(AppID)
|
|
|
+ "partnerid": res2.data.partnerId, // 商户号(PartnerID)
|
|
|
+ "prepayid": res2.data.prepayId, // 预支付交易会话ID
|
|
|
+ "package": res2.data.packageVal, // 固定值
|
|
|
+ "noncestr": res2.data.nonceStr, // 随机字符串
|
|
|
+ "timestamp": res2.data.timestamp, // 时间戳(单位:秒)
|
|
|
+ "sign": res2.data.sign // 签名,这里用的 MD5 签名
|
|
|
+ }, //此处为服务器返回的订单信息字符串
|
|
|
+ success: function(res) {
|
|
|
+ var rawdata = JSON.parse(res.rawdata);
|
|
|
+ console.log('支付成功');
|
|
|
+ console.log('rawdata', rawdata);
|
|
|
+ // toast("支付成功");
|
|
|
+ cacheManager.updateVipStatus('auth', cardId.value)
|
|
|
+ cacheManager.updateObject('auth', {
|
|
|
+ growthType: 1
|
|
|
+ })
|
|
|
+ if (isVip != 'VIP') {
|
|
|
+ daoPokeRef.value.handleShow();
|
|
|
+ } else {
|
|
|
+ daoPokeAllRef.value.handleShow();
|
|
|
+ }
|
|
|
+ setTimeout(() => {
|
|
|
+ daoPokeRef.value.handleClose();
|
|
|
+ daoPokeAllRef.value.handleClose();
|
|
|
+ if (formPage.value == 'my') {
|
|
|
+ uni.redirectTo({
|
|
|
+ url: '/pages/my/index'
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ uni.redirectTo({
|
|
|
+ url: '/pages/study/index'
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }, 3000)
|
|
|
+ },
|
|
|
+ fail: function(err) {
|
|
|
+ // toast('支付失败:' + JSON.stringify(err));
|
|
|
+ console.log('支付失败:' + JSON.stringify(err));
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }).catch((error) => {
|
|
|
+ console.log(error);
|
|
|
+ })
|
|
|
+
|
|
|
+
|
|
|
})
|
|
|
-
|
|
|
-
|
|
|
- })
|
|
|
+ } else {
|
|
|
+ let req = {
|
|
|
+ cardId: cardId.value
|
|
|
+ }
|
|
|
+ orderAdd(req).then(res => {
|
|
|
+ console.log('res', res);
|
|
|
+ orderPayAli({
|
|
|
+ id: res.data.id
|
|
|
+ }).then(res2 => {
|
|
|
+ console.log('res2', res2);
|
|
|
+
|
|
|
+ uni.requestPayment({
|
|
|
+ "provider": "alipay",
|
|
|
+ "orderInfo": res2.data.text, //此处为服务器返回的订单信息字符串
|
|
|
+ success: function(res) {
|
|
|
+ var rawdata = JSON.parse(res.rawdata);
|
|
|
+ console.log('支付成功');
|
|
|
+ console.log('rawdata', rawdata);
|
|
|
+ // toast("支付成功");
|
|
|
+ cacheManager.updateVipStatus('auth', cardId.value)
|
|
|
+ cacheManager.updateObject('auth', {
|
|
|
+ growthType: 1
|
|
|
+ })
|
|
|
+ if (isVip != 'VIP') {
|
|
|
+ daoPokeRef.value.handleShow();
|
|
|
+ } else {
|
|
|
+ daoPokeAllRef.value.handleShow();
|
|
|
+ }
|
|
|
+ setTimeout(() => {
|
|
|
+ daoPokeRef.value.handleClose();
|
|
|
+ daoPokeAllRef.value.handleClose();
|
|
|
+ if (formPage.value == 'my') {
|
|
|
+ uni.redirectTo({
|
|
|
+ url: '/pages/my/index'
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ uni.redirectTo({
|
|
|
+ url: '/pages/study/index'
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }, 3000)
|
|
|
+ },
|
|
|
+ fail: function(err) {
|
|
|
+ // toast('支付失败:' + JSON.stringify(err));
|
|
|
+ console.log('支付失败:' + JSON.stringify(err));
|
|
|
+ }
|
|
|
+ });
|
|
|
+ })
|
|
|
+
|
|
|
+
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
function goBack(data) {
|
|
|
- if(formPage.value =='my'){
|
|
|
+ if (formPage.value == 'my') {
|
|
|
uni.redirectTo({
|
|
|
url: '/pages/my/index'
|
|
|
})
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
uni.redirectTo({
|
|
|
url: '/pages/study/index'
|
|
|
})
|