future 1 year ago
parent
commit
0094421447

+ 1 - 1
xs-app/config/config.ts

@@ -101,7 +101,7 @@ export class config {
 				/**
 				 * 充值
 				 */
-				order_buy:'/order/buy',
+				order_buy:'/order/buy', //支付类型 1:抖音支付 2:微信支付 3:内部充值(内部测试)
 				order_info:'/order/info',
 			},
 			buy_chapter:'/book/buy_chapter', //购买书籍

+ 34 - 0
xs-app/framework/tools.ts

@@ -446,4 +446,38 @@ export class tools {
 		}
 		return config.read_config.colorBgResList[index].off_res
 	}
+	
+	// 下单(支付类型 1:抖音支付 2:微信支付 3:内部充值(内部测试))
+	public static requestRechargeOrderBuy(pay_type:number, goods_id:number, cb:Function) {
+		let opt = {'pay_type':pay_type,'goods_id':goods_id}
+		http.DynamicRequest(config.url_confg.Dynamic.recharge.order_buy,opt,(err=null,data=null)=>{
+			if(!err&&data) {
+				if(data.code==config.url_confg.StatesCode.SUCCESS){
+					let order_id = data.content.order_id
+					cb && cb(order_id)
+				} else {
+					cb && cb('')
+				}
+			} else {
+				cb && cb('')
+			}
+		})
+	}
+	
+	// 查询订单
+	public static requestRechargeOrderInfo(order_id:string, cb:Function) {
+		let opt = {'order_id':order_id}
+		http.DynamicRequest(config.url_confg.Dynamic.recharge.order_info,opt,(err=null,data=null)=>{
+			if(!err&&data) {
+				if(data.code==config.url_confg.StatesCode.SUCCESS){
+					let status = data.content.status //订单状态 1:支付中 2:已经支付
+					cb && cb(status)
+				} else {
+					cb && cb(-1)
+				}
+			} else {
+				cb && cb(-1)
+			}
+		})
+	}
 }

+ 3 - 0
xs-app/framework/util.ts

@@ -72,6 +72,9 @@ export class util {
 	
 	// Loadding
 	public static showLoading(title='加载中...',mask:boolean=false) {
+		if(title.length==0) {
+			title = '加载中...'
+		}
 		uni.showLoading({
 			title:title,
 			mask:mask

+ 5 - 9
xs-app/pages/mine/mine-wealth.vue

@@ -11,8 +11,11 @@
 				</view>
 			</view>
 			<view class="item__right">
-				<view class="item__right__info">
-					{{ item.id==1?user_data.coin:vip_string}}
+				<view v-if="item.id==1" class="item__right__info">
+					{{user_data.coin}}
+				</view>
+				<view v-else class="item__right__info">
+					{{user_data.is_vip==true?util.timeFormat(user_data.vip_effective_time_time)+'到期':''}}
 				</view>
 				<uni-icons class="item__right__icon" type='right' size="14"></uni-icons>
 			</view>
@@ -21,7 +24,6 @@
 </template>
 
 <script setup lang="ts">
-    import { ref } from 'vue';
     import { util } from '../../framework/util';
     import { UserData } from '../../stores/userDataManager';
     import { config } from '../../config/config';
@@ -30,12 +32,6 @@
 	    {'id':config.mine_goto_type.VIP,'name':'VIP','icon':'../../static/imgs/mine/img_mine_icon2.png'},
 	] 
 	let user_data = UserData().getData()
-	let vip_string = ref('')
-	if(user_data.is_vip==true) {
-		vip_string.value = util.timeFormat(user_data.vip_effective_time_time)+'到期'
-	} else {
-		vip_string.value = ''
-	}	
 	
 	const emits = defineEmits(['clickType'])
 	function clickType(type:number){

+ 28 - 3
xs-app/pages/recharge/rechargeCoin.vue

@@ -46,7 +46,7 @@
 	    	    </view>
 	    	</view>
 	    </view>
-	    <view class="bottom">
+	    <view class="bottom" @click="clickLjgm">
 	    	<view class="bottom__button-ljgm">
 	    		<image class="image" src="../../static/imgs/public/img_ljgm.png" mode=""></image>
 	    	</view>
@@ -60,6 +60,8 @@
 	import { http } from '../../framework/http';
 	import { log } from '../../framework/log';
     import { UserData } from '../../stores/userDataManager';
+import { util } from '../../framework/util';
+import { tools } from '../../framework/tools';
 		
 	let data_list = ref([])
 	let current_index = ref(-1)
@@ -73,8 +75,6 @@
 				// console.log('书币-',data)
 				if(data.code==config.url_confg.StatesCode.SUCCESS){
 					data_list.value = data.content
-				} else {
-					
 				}
 			} else {
 				log.Error(err)
@@ -86,6 +86,31 @@
 		current_index.value = index
 	}
 	
+	function clickLjgm() {
+		if(current_index.value<0) {
+			util.showInfoToast('请选择购买书币金额')
+			return
+		}
+		let data = data_list.value[current_index.value]
+		util.showLoading('',true)
+		tools.requestRechargeOrderBuy(3,data.goods_id,(order_id:string)=>{
+			if(order_id.length>0) {
+				setTimeout(function() {
+					tools.requestRechargeOrderInfo(order_id,(status:number)=>{
+						util.hideLoading()
+						if(status==2) {
+							UserData().update_user_info(()=>{
+								util.showSuccessToast('充值成功')
+							})
+						}
+					})
+				}, 2000);
+			} else {
+				util.hideLoading()
+			}
+		})
+	}
+	
 </script>
 
 <style lang="scss">

+ 78 - 31
xs-app/pages/recharge/rechargeVIP.vue

@@ -5,14 +5,17 @@
 				<image class="image" src="../../static/imgs/recharge/recharge_top_bg.png" mode="aspectFit"></image>
 			</view>
 			<view class="top__container">
-				<view class="top__container__title">
-					<view class="top__container__title__name">购买会员</view>
-					<view class="top__container__title__icon">
-						<image class="image" src="../../static/imgs/public/img_coin.png" mode="aspectFill"></image>
-					</view>
+				<view class="top__container__kaitong" v-if="user_data.is_vip">已开通</view>
+				<view class="top__container__avatar">
+				    <image class="image" :src="UserData().getData().avatar_url" mode=""></image>
 				</view>
-				<view class="top__container__coins">
-					{{UserData().getData().coin}}
+				<view class="top__container__info">
+					<view class="top__container__info__name">
+						{{user_data.user_name}}
+					</view>
+					<view class="top__container__info__date" v-if="user_data.is_vip">
+						有效期至:{{util.timeFormat(user_data.vip_effective_time_time)}}
+					</view>
 				</view>
 			</view>
 		</view>
@@ -39,7 +42,7 @@
 	    	</view>
 	    </view>
 	    <view class="bottom">
-	    	<view class="bottom__button-ljgm">
+	    	<view class="bottom__button-ljgm" @click="clickLjgm">
 	    		<image class="image" src="../../static/imgs/public/img_ljgm.png" mode=""></image>
 	    	</view>
 	    </view>
@@ -52,7 +55,10 @@
 	import { http } from '../../framework/http';
 	import { log } from '../../framework/log';
     import { UserData } from '../../stores/userDataManager';
+    import { util } from '../../framework/util';
+import { tools } from '../../framework/tools';
 		
+	let user_data = UserData().getData()
 	let data_list = ref([])
 	let current_index = ref(-1)
 	
@@ -71,8 +77,6 @@
 				console.log('vip-',data)
 				if(data.code==config.url_confg.StatesCode.SUCCESS){
 					data_list.value = data.content
-				} else {
-					
 				}
 			} else {
 				log.Error(err)
@@ -84,6 +88,31 @@
 		current_index.value = index
 	}
 	
+	function clickLjgm() {
+		if(current_index.value<0) {
+			util.showInfoToast('请选择购买会员金额')
+			return
+		}
+		let data = data_list.value[current_index.value]
+		util.showLoading('',true)
+		tools.requestRechargeOrderBuy(3,data.goods_id,(order_id:string)=>{
+			if(order_id.length>0) {
+				setTimeout(function() {
+					tools.requestRechargeOrderInfo(order_id,(status:number)=>{
+						util.hideLoading()
+						if(status==2) {
+							UserData().update_user_info(()=>{
+								util.showSuccessToast('VIP成功')
+							})
+						}
+					})
+				}, 2000);
+			} else {
+				util.hideLoading()
+			}
+		})
+	}
+	
 </script>
 
 <style lang="scss">
@@ -108,35 +137,53 @@
 			&__container{
 				position: absolute;
 				display: flex;
-				flex-direction: column;
+				flex-direction: row;
 				width: 90%;				
 				// background-color: green;
-				&__title{
-					margin-top: 40rpx;
+				
+				&__kaitong {
+					position: absolute;
+					top: 6rpx;
+					right: 0;
+					width: 128rpx;
+					height: 60rpx;
+					border-top-right-radius: 30rpx;
+					border-bottom-left-radius: 30rpx;
+					color: #ffffff;
+					background-color: #9A71F1;
+					display: flex;
+					justify-content: center;
+					align-items: center;
+				}
+				&__avatar{
+					margin-top: 70rpx;
 					margin-left: 60rpx;
+					flex-shrink: 0;
+					width: 110rpx;
+					height: 110rpx;
+					.image{
+						width: 100%;
+						height: 100%;
+						border-radius: 50%;
+					}
+				}
+				&__info {
+					margin-top: 60rpx;
+					margin-left: 30rpx;
 					display: flex;
-					flex-direction: row;
-					
+					flex-direction: column;
+					// height: 150rpx;
+					// background-color: red;
 					&__name{
-						font-size: 20px;
+						margin-top: 20rpx;
+						font-size: 25px;
+						font-weight: 450;
 					}
-					&__icon{
-						margin-left: 10rpx;
-						flex-shrink: 0;
-						width: 52rpx;
-						height: 52rpx;
-						.image{
-							width: 100%;
-							height: 100%;
-						}
+					&__date{
+						margin-top: 10rpx;
+						font-size: 17px;
 					}
 				}
-				&__coins{
-					margin-top: 20rpx;
-					display: flex;
-					justify-content: center;
-					font-size: 29px;
-				}
 			}
 		}