zqwang 1 år sedan
förälder
incheckning
0d26683eec
6 ändrade filer med 239 tillägg och 44 borttagningar
  1. 22 14
      components/pay/recharge.vue
  2. 4 2
      manifest.json
  3. 109 6
      pages/pay/pay.vue
  4. 79 4
      pages/pay/style/pay.css
  5. 24 17
      pages/video/index.nvue
  6. 1 1
      pages/zhuiju/index.vue

+ 22 - 14
components/pay/recharge.vue

@@ -113,25 +113,33 @@
 					video_series_sequence:this.video_info && this.video_info.video_series_sequence  ? this.video_info.video_series_sequence :0,
 				};
 				let result = false;
-				// #ifdef MP-WEIXIN  
+		
 					let res = await getPayInfo(params);
+					console.log('00000000000000',res)
 					if(res){
-						uni.requestPayment({
-						    "provider": "wxpay", 
-						    "orderInfo":res,
-						    success(res) {
-								result = true;
-								console.log('success:' + JSON.stringify(res));
-							},
-						    fail(e) {
-								return false;
-								console.log('success:' + JSON.stringify(e));
-							}
-						})
+						console.log('1111111111111',res)
+							
+						try{
+							uni.requestPayment({
+							    "provider": "wxpay", 
+							    "orderInfo":JSON.stringify(res),
+							    success(res) {
+									result = true;
+									console.log('success:' + JSON.stringify(res));
+								}, 
+							    fail(e) {
+									return false;
+									console.log('fail:' + JSON.stringify(e));
+								}
+							})
+						}catch(e){
+							console.log('pay-error-:',e);
+						}
+						
 					}
 					
 					return this.$emit('is_pay',result);
-				// #endif
+				
 				return this.$emit('is_pay',result);
 			}
 		}

+ 4 - 2
manifest.json

@@ -18,7 +18,8 @@
         "modules" : {
             "VideoPlayer" : {},
             "OAuth" : {},
-            "Share" : {}
+            "Share" : {},
+            "Payment" : {}
         },
         "distribute" : {
             "android" : {
@@ -59,7 +60,8 @@
                         "appid" : "wxa0ffb845cac1d527",
                         "UniversalLinks" : ""
                     }
-                }
+                },
+                "payment" : {}
             }
         }
     },

+ 109 - 6
pages/pay/pay.vue

@@ -1,25 +1,128 @@
 <template>
 	<view class="body">
-		<recharge :user_info="user_info"> </recharge>
+		<view style="margin: 0px 20px;">
+			<view  class="ft18">请选择充值金额 <label class="ft14" style="float: right;">账户余额<label class="ft14 kb-txt">{{user_info.total_coin}}</label>K币</label></view>
+			<text class="ft14" style="font-weight: bold;padding-top: 10px;display: block;">1元=100K币</text>
+		</view>
+		<view class="pay-box">
+			<block v-for="(item,key) in list" :key="key">
+				<view v-if="item.type =='COIN'" @click="selectPayItem(item)"
+					:class="item.id == select.id ?'pay-select' :'' " class="box pay-box-items">
+					<view style="height: 20px;align-self: flex-end;"><text class="ft12 top-lab"
+							v-if="item.tip_text">{{item.tip_text}}</text></view>
+					<text class="ft18 pay-box-items-txt" style="color: #FF9800;">{{item.price}}元</text>
+					<view class="ft14 pay-box-items-txt" style="flex-direction: row;">
+						{{item.price_text}} <text class="ft14"
+							style="color: #FF9800;">+{{item.given}}K币</text> </view>
+					<view class="ft14 pay-box-items-txt"
+						style="flex-direction: row;display: flex;justify-content:  space-between;"
+						:class=" item.id == select.id ?'select-text' :'given-txt'">
+						{{item.given_amount}} <text v-if="item.id == select.id"
+							class="ft14" style="margin-right: 20px;">&#10003;️</text></view>
+				</view>
+				<view v-else @click="selectPayItem(item)"
+					:class="item.id == select.id ?'pay-select' :'' " class="box pay-box-items"> 
+					<view style="height: 20px;align-self: flex-end;"><text class="ft12 top-lab"
+							v-if="item.tip_text">{{item.tip_text}}</text></view>
+					<view class="vip-center">
+						<view class="">
+							<text class="ft18 pay-box-items-txt"
+								style="color: #FF9800;">{{item.price}}0元</text>
+							<view class="ft14 pay-box-items-txt">{{item.price_text}}</text></view>
+						</view>
+						<image class="vip-level-icon" src="/static/icon/vip.png"></image>
+					</view>
+					<view class="ft14 pay-box-items-txt"
+						style="flex-direction: row;display: flex;justify-content: space-between;"
+						:class=" item.id == select.id ?'select-text' :'given-txt'">
+						<text class="ft14">{{item.given_amount}}</text> <text v-if="item.id == select.id"
+							class="ft14" style="margin-right: 20px;">&#10003;️</text></view>
+				</view>
+			</block>
+		</view>
+		<view  @click="toPay" class="ft16 btn-cz  mt16 " >
+			确认充值{{select.price||0}}
+		</view>
+		<view class="ft14" style="margin: 10px 0; padding: 0 20px;">付费须知</view>
+		<view class="ft14" style="padding: 0 20px;margin-bottom: 50px;">
+			<text class="ft12">1、虚拟商品,一经购买不得退换</text>
+			<text class="ft12">2、充值后K币可能有延迟,1小时未到账请在“我的”页面联系客服</text>
+			<text class="ft12">3、未满18岁的未成年需要在监护人陪同下购买并观看短剧剧</text>
+			<text class="ft12">4、购买成功后,“K币”仅在本小程序中使用</text>
+			<text class="ft12">5、购买成功后可在”我的”页面订单中心进行查看</text>
+		</view>
 	</view>
 </template>
 
 <script>
-	import recharge from '@/components/pay/recharge.vue';
+	
 	import {getUserInfo} from "@/common/apis/my.js";
+	import {
+		getOptions,
+		getPayInfo,
+		
+	} from "@/common/apis/recharge.js"
 	export default {
-		components:{
-			recharge
-		},
 		data() {
 			return {
 				user_info:{},
+				list: [],
+				select: {},
+				pay_success:false
 			}
 		},async onShow() {
 			this.user_info = await  getUserInfo();
+			this.get_options();
 		},
 		methods: {
-			
+			async get_options() {
+				this.list = await getOptions();
+				this.list.forEach((item, index) => {
+					if (item.is_default == 1) {
+						this.select = item;
+					}
+				})
+			},selectPayItem(item){
+				this.select = item;
+			},async toPay(){
+				if(this.select.lenght <  1){
+					uni.showToast({ title: '请选择要充值的项',icon:"none" });
+					return false;
+				}
+				let params = {
+					pay_proudct_id:this.select.id,
+					video_id:this.video_info && this.video_info.video_id ? this.video_info.video_id :0,
+					video_series_sequence:this.video_info && this.video_info.video_series_sequence  ? this.video_info.video_series_sequence :0,
+				};
+				let result = false;
+		
+					let res = await getPayInfo(params);
+					if(res){
+						// #ifdef MP-WEIXIN
+							this.wxMinPay(res);	
+						// #endif
+					}
+			},wxMinPay(param){
+				wx.requestPayment({
+				  timeStamp: param.timeStamp,
+				  nonceStr: param.nonceStr,
+				  package: param.package,
+				  signType: param.signType,
+				  paySign: param.paySign,
+				  success (res) {
+					  this.pay_success = true;
+					  uni.showToast({ title: '支付成功',icon:"none" });
+					  // console.log('success:' + JSON.stringify(res));
+				  },
+				  fail (e) { 
+					  if(e.errMsg == "requestPayment:fail cancel"){
+						   uni.showToast({ title: '取消支付',icon:"none" });
+					  }else{
+						  uni.showToast({ title: '支付失败',icon:"none" });
+					  }
+				  }
+				})
+			}
 		}
 	}
 </script>

+ 79 - 4
pages/pay/style/pay.css

@@ -1,7 +1,82 @@
-.body{
+.body {
 	background-color: #fff;
-}
+	
+}
 
-.cz-desc-txt{
-	padding-left: 20px;
+.btn-cz{
+	text-align: center;
+	padding: 10px;
+	background-color: #ff5722;
+	color: #fff;
+	border-radius: 40rpx;
+	margin: 10px  20px;
+}
+.vip-center {
+	display: flex;
+	flex-direction: row;
+	justify-content: space-between;
+	align-items: center;
+}
+
+.vip-level-icon {
+	margin: 0 5rpx;
+	max-width: 60px;
+	height: 20px;
+}
+
+.pay-box {
+	background-color: #fff;
+	display: flex;
+	justify-content: space-between;
+	flex-direction: row;
+	padding: 0 20px;
+	flex-wrap: wrap;
+}
+
+.top-lab {
+	width: 40px;
+	text-align: center;
+	background-color: #ff5722;
+	color: #fff;
+	float: right;
+	border-top: none;
+	border-radius: 10px;
+}
+
+.pay-box-items {
+	margin-top: 10px;
+	width: 48%;
+	flex-direction: column;
+	border-radius: 10px;
+	line-height: 25px;
+	overflow: hidden;
+}
+
+.pay-box-items-txt {
+	padding: 1rpx 0;
+	padding-left: 13px;
+}
+
+.pay-box-items view text {
+	line-height: 25px;
+}
+
+.pay-select {
+	border: solid 1px #ff5722;
+}
+
+.select-text {
+	background-color: #ff5722;
+	color: #fff;
+	height: 30px;
+	border-radius: 0rpx 0rpx 10rpx 10rpx;
+}
+
+.given-txt {
+	height: 30px;
+	border-top: solid 1rpx #9e9e9e1f;
+}
+
+.kb-txt {
+	color: #FF9800;
 }

+ 24 - 17
pages/video/index.nvue

@@ -476,25 +476,32 @@
 					pay_proudct_id: item.id
 				}
 				let res = await getPayInfo(params);
-				if (res) {
-					uni.requestPayment({
-						"provider": "wxpay",
-						"orderInfo": res,
-						success(res) {
-							uni.showToast({
-								title: '支付成功',
-								duration: 1000,
-								icon: 'none'
-							});
-							console.log('success:' + JSON.stringify(res));
-						},
-						fail(e) {
-							return false;
-							console.log('success:' + JSON.stringify(e));
-						}
-					})
+				if (res) {
+					// #ifdef MP-WEIXIN
+						this.wxMinPay(res);	
+					// #endif
 				}
 
+			},wxMinPay(param){
+				wx.requestPayment({
+				  timeStamp: param.timeStamp,
+				  nonceStr: param.nonceStr,
+				  package: param.package,
+				  signType: param.signType,
+				  paySign: param.paySign,
+				  success (res) {
+					  this.pay_success = true;
+					  uni.showToast({ title: '支付成功',icon:"none" });
+					  // console.log('success:' + JSON.stringify(res));
+				  },
+				  fail (e) { 
+					  if(e.errMsg == "requestPayment:fail cancel"){
+						   uni.showToast({ title: '取消支付',icon:"none" });
+					  }else{
+						  uni.showToast({ title: '支付失败',icon:"none" });
+					  }
+				  }
+				})
 			},
 			playTest(item) {
 				console.log(item)

+ 1 - 1
pages/zhuiju/index.vue

@@ -148,7 +148,7 @@
 			},
 			detail(video_id,item_id) {
 				// console.log(value);
-				uni.navigateTo({url: '/pages/video/index?video_id='+video_id+"&sequence="+item_id})
+				uni.navigateTo({url: '/pages/video/index?video_id='+video_id+"&sequence="+item_id + "&ranse_id=3"})
 				// uni.navigateTo({
 				// 	url: '/pages/video/index?video_id=' + value.video_id 
 				// })