Browse Source

2022-8-17

cmy 2 years ago
parent
commit
1354c4d1b8
5 changed files with 119 additions and 91 deletions
  1. 10 0
      api/wallet.js
  2. 1 6
      pages.json
  3. 106 84
      pages/money/recharge.vue
  4. 0 1
      pages/money/wallet.vue
  5. 2 0
      pages/user/myvip.vue

+ 10 - 0
api/wallet.js

@@ -72,6 +72,16 @@ export function rechargeRoutine(data) {
 	});
 }
 // #endif
+// #ifdef APP-PLUS
+// 支付宝充值
+export function rechargeAli(data) {
+	return request({
+		url: '/api/recharge/ali',
+		method: 'post',
+		data
+	});
+}
+// #endif
 // 获取提现支付宝账号
 export function aliInfo(data) {
 	return request({

+ 1 - 6
pages.json

@@ -575,12 +575,7 @@
 			"style": {
 				"navigationBarTitleText": "我的钱包",
 				"navigationBarBackgroundColor": "#111111",
-				"navigationBarTextStyle": "white", 
-				"app-plus": {
-					"titleNView": {
-						"type": "transparent"
-					}
-				}
+				"navigationBarTextStyle": "white"
 			}
 		},
 		{

+ 106 - 84
pages/money/recharge.vue

@@ -4,9 +4,7 @@
 			<text class="yue-tit">当前余额:</text>
 			<text class="yue-num">¥{{ now_money | parseFloatNum }}</text>
 		</view>
-
 		<view class="line_box"></view>
-
 		<view class="cz_box">
 			<view class="cz_wrap">
 				<text class="cz_tit">¥</text>
@@ -20,24 +18,8 @@
 				</view>
 			</view>
 		</view>
-		<!-- <view class="line_box"></view> -->
-
-		<!-- <view class="row-box">
-			<view class="title">充值金额</view>
-			<view class="row">
-				<text class="tit">¥</text>
-				<input class="input" type="number" v-model="money" placeholder="请输入充值金额" placeholder-class="placeholder" />
-			</view>
-		</view> -->
-
-		<!-- <view class="rechar-box">
-			<view class="rechar-title">注意事项</view>
-			<view class="rechar-text" v-for="(item, index) in zhuyi" :key="index">
-				<text>{{ index + 1 }}.{{item}}</text>
-			</view>
-		</view> -->
 		<view class="line_box"></view>
-		<view class="cz-type">
+		<!-- <view class="cz-type" @click="type = 'weixin'">
 			<view class="type-left">
 				<view class="icon iconfont iconweixin"></view>
 				<view class="tit">微信充值</view>
@@ -45,15 +27,20 @@
 			<view class="right">
 				<radio value="weixin" color=" #EB001C" :checked="type == 'weixin'" />
 			</view>
+		</view> -->
+		<!-- #ifdef APP-PLUS -->
+		<view class="cz-type" @click="type = 'ali'">
+			<view class="type-left">
+				<view class="icon iconfont iconzhifubao"></view>
+				<view class="tit">支付宝充值</view>
+			</view>
+			<view class="right">
+				<radio value="ali" color=" #EB001C" :checked="type == 'ali'" />
+			</view>
 		</view>
+		<!-- #endif -->
 		<button class="add-btn up" :class="{ 'active-bg': payLoding }"
 			@click="!payLoding ? confirm() : ''">立即充值</button>
-			
-			<!-- <view class="aaa">
-				<view class="bbb">
-					22222
-				</view>
-			</view> -->
 	</view>
 </template>
 
@@ -61,17 +48,21 @@
 	import {
 		getMoneyStyle
 	} from '@/utils/rocessor.js';
+	
 	// #ifdef H5
 	import {
 		rechargeWechat,
-		rechargeIndex
+		rechargeAli
 	} from '@/api/wallet.js';
 	// #endif
 	// #ifdef MP
 	import {
-		rechargeWechat,
 		rechargeRoutine,
-		rechargeIndex
+	} from '@/api/wallet.js';
+	// #endif
+	// #ifdef APP-PLUS
+	import {
+		rechargeAli
 	} from '@/api/wallet.js';
 	// #endif
 	import {
@@ -174,67 +165,96 @@
 					obj.payLoding = false;
 					return;
 				}
-				// #ifdef H5
-				rechargeWechat({
-						price: this.money,
-						from: this.type,
-					}).then(e => {
-						let da = e.data.data;
-						obj.weichatObj.chooseWXPay({
-							timestamp: da.timestamp,
-							nonceStr: da.nonceStr,
-							package: da.package,
-							signType: da.signType,
-							paySign: da.paySign,
-							success: function(res) {
-								uni.showToast({
-									title: '充值成功',
-									duration: 2000,
-									position: 'top',
-									success: function(res) {
-										uni.navigateBack()
-									}
-								});
-							}
+				// 微信支付
+				if(obj.type=='weixin'){
+					// #ifdef H5
+					rechargeWechat({
+							price: this.money,
+							from: this.type,
+						}).then(e => {
+							let da = e.data.data;
+							obj.weichatObj.chooseWXPay({
+								timestamp: da.timestamp,
+								nonceStr: da.nonceStr,
+								package: da.package,
+								signType: da.signType,
+								paySign: da.paySign,
+								success: function(res) {
+									uni.showToast({
+										title: '充值成功',
+										duration: 2000,
+										position: 'top',
+										success: function(res) {
+											uni.navigateBack()
+										}
+									});
+								}
+							});
+							obj.payLoding = false;
+						})
+						.catch(e => {
+							obj.payLoding = false;
+							console.log(e);
 						});
-						obj.payLoding = false;
-					})
-					.catch(e => {
-						obj.payLoding = false;
-						console.log(e);
-					});
-				// #endif
-				// #ifdef MP
-				rechargeRoutine({
+					// #endif
+					// #ifdef MP
+					rechargeRoutine({
+							price: this.money
+						})
+						.then(e => {
+							let da = e.data;
+							wx.requestPayment({
+								timeStamp: da.timestamp,
+								nonceStr: da.nonceStr,
+								package: da.package,
+								signType: da.signType,
+								paySign: da.paySign,
+								success: function(res) {
+									uni.showToast({
+										title: '充值成功',
+										duration: 2000,
+										position: 'top',
+										success: function(res) {
+											uni.navigateBack()
+										}
+									});
+								},
+					
+							})
+					
+							obj.payLoding = false;
+						})
+						.catch(e => {
+							obj.payLoding = false;
+							console.log(e);
+						});
+					// #endif
+				}
+				// #ifdef APP-PLUS
+				if(obj.type=='ali'){
+					rechargeAli({
 						price: this.money
-					})
-					.then(e => {
-						let da = e.data;
-						wx.requestPayment({
-							timeStamp: da.timestamp,
-							nonceStr: da.nonceStr,
-							package: da.package,
-							signType: da.signType,
-							paySign: da.paySign,
-							success: function(res) {
+					}).then((data)=>{
+						const url = data.msg;
+						uni.requestPayment({
+							provider: 'alipay',
+							orderInfo: url,
+							success: res => {
 								uni.showToast({
-									title: '充值成功',
-									duration: 2000,
-									position: 'top',
-									success: function(res) {
-										uni.navigateBack()
-									}
+									title: '支付成功',
+									duration: 2000
 								});
+								obj.paySuccessTo();
 							},
-
-						})
-
-						obj.payLoding = false;
-					})
-					.catch(e => {
+							fail: e => {
+								console.log(e);
+							},
+							complete: () => {}
+						});
 						obj.payLoding = false;
-						console.log(e);
-					});
+						return
+					}).catch()
+				}
 				// #endif
 			},
 		}
@@ -424,7 +444,9 @@
 			.iconweixin {
 				color: #36cb59;
 			}
-
+			.iconzhifubao{
+				color: #08aaec;
+			}
 			.tit {
 				margin-left: 12rpx;
 				font-size: 30rpx;

+ 0 - 1
pages/money/wallet.vue

@@ -1,6 +1,5 @@
 <template>
 	<view class="content">
-		<view class="" style="height: 100rpx;"></view>
 		<view class="title-box">
 			<view class="yue-box">
 				<view class="yue-top">

+ 2 - 0
pages/user/myvip.vue

@@ -119,6 +119,7 @@
 			payChecked(data){
 				console.log(data,'fanhui ');
 				const that = this;
+				// #ifdef APP-PLUS
 				if (that.type == 'ali') {
 					const url = data.payConfig;
 					console.log(url, 'url');
@@ -141,6 +142,7 @@
 					obj.payLoding = false;
 					return
 				}
+				// #endif
 				if (that.type == 'yue') {
 					that.paySuccess();
 					that.getBalance()