wangguoyu 4 months ago
parent
commit
56010a6379
2 changed files with 53 additions and 25 deletions
  1. 7 1
      manifest.json
  2. 46 24
      pages/pay/svip.vue

+ 7 - 1
manifest.json

@@ -33,7 +33,8 @@
         /* 模块配置 */
         /* 模块配置 */
         "modules" : {
         "modules" : {
             "VideoPlayer" : {},
             "VideoPlayer" : {},
-            "OAuth" : {}
+            "OAuth" : {},
+            "Payment" : {}
         },
         },
         /* 应用发布信息 */
         /* 应用发布信息 */
         "distribute" : {
         "distribute" : {
@@ -76,6 +77,11 @@
                         "appid" : "wxd6a8954fa7b0f8a0",
                         "appid" : "wxd6a8954fa7b0f8a0",
                         "UniversalLinks" : ""
                         "UniversalLinks" : ""
                     }
                     }
+                },
+                "payment" : {
+                    "alipay" : {
+                        "__platform__" : [ "ios", "android" ]
+                    }
                 }
                 }
             },
             },
             "splashscreen" : {
             "splashscreen" : {

+ 46 - 24
pages/pay/svip.vue

@@ -53,7 +53,8 @@
 		ref
 		ref
 	} from "vue";
 	} from "vue";
 	import {
 	import {
-		orderAdd
+		orderAdd,
+		orderPayAli
 	} from "@/api/order.js"
 	} from "@/api/order.js"
 	import CustomTabBar from '@/components/custom-tabbar/custom-tabbar.vue';
 	import CustomTabBar from '@/components/custom-tabbar/custom-tabbar.vue';
 	import cacheManager from "@/utils/cacheManager.js";
 	import cacheManager from "@/utils/cacheManager.js";
@@ -105,34 +106,55 @@
 
 
 	function creatOrder(data) {
 	function creatOrder(data) {
 
 
-
-
+		if(payType.value =='weixin'){
+			toast("微信支付暂未开通,请选择支付宝")
+			return false
+		}
 		let req = {
 		let req = {
 			cardId: cardId.value
 			cardId: cardId.value
 		}
 		}
 		orderAdd(req).then(res => {
 		orderAdd(req).then(res => {
-			cacheManager.updateVipStatus('auth', cardId.value)
-			cacheManager.updateObject('auth', {
-				growthType: 1
+			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));
+				                }
+				            });
 			})
 			})
-			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)
+			
+	
 		})
 		})
 	}
 	}