wangxy hai 3 días
pai
achega
44e44cd804
Modificáronse 4 ficheiros con 170 adicións e 34 borrados
  1. 55 2
      api/shop.js
  2. 103 30
      pages/chanpinShop/cp1/dingdan.vue
  3. 7 2
      pages/chanpinShop/cp1/intro.vue
  4. 5 0
      pages/chanpinShop/index.vue

+ 55 - 2
api/shop.js

@@ -12,7 +12,7 @@ export function getAppShopIndex(data = {}) {
 }
 
 
-export function getAppShuxueBuy(data = {}) {
+export function getAppCp1Buy(data = {}) {
 	return request({
 		url: "/app/shop/shuxue/buy",
 		headers: {
@@ -24,7 +24,7 @@ export function getAppShuxueBuy(data = {}) {
 	})
 }
 
-export function getAppShuxueInfo(data = {}) {
+export function getAppCp1Info(data = {}) {
 	return request({
 		url: "/app/shop/shuxue/info",
 		headers: {
@@ -35,3 +35,56 @@ export function getAppShuxueInfo(data = {}) {
 		timeout: 20000
 	})
 }
+
+
+export function orderPayAli(data = {}) {
+	return request({
+		url: "/app/order/pay/ali",
+		headers: {
+			isToken: true
+		},
+		method: 'post',
+		data,
+		timeout: 20000
+	})
+}
+
+
+
+export function orderPayWx(data = {}) {
+	return request({
+		url: "/app/order/pay/wx",
+		headers: {
+			isToken: true
+		},
+		method: 'post',
+		data,
+		timeout: 20000
+	})
+}
+
+export function orderPayApple(data = {}) {
+	return request({
+		url: "/app/order/pay/apple",
+		headers: {
+			isToken: true
+		},
+		method: 'post',
+		data,
+		timeout: 20000
+	})
+}
+
+
+
+export function orderCheck(data = {}) {
+	return request({
+		url: "/app/order/check",
+		headers: {
+			isToken: true
+		},
+		method: 'post',
+		data,
+		timeout: 20000
+	})
+}

+ 103 - 30
pages/chanpinShop/cp1/dingdan.vue

@@ -5,34 +5,42 @@
 			<text class="nav-bar-title">确认订单</text>
 		</view>
 		<!-- 卡片 -->
+		<view>
 			<view>
-				<view><image :src="data.cover"></image></view>
-				<view>名称:{{data.name}}</view>
-				<view>简介:{{data.intro}}</view>
-				<view>价格:{{data.xianjia}}</view>
+				<image :src="data.cover"></image>
 			</view>
+			<view>名称:{{data.name}}</view>
+			<view>简介:{{data.intro}}</view>
+			<view>价格:{{data.xianjia}}</view>
+		</view>
 		<!-- 等级 -->
 		<view>
 			<view>课程学习等级</view>
 			<view>
 				<!-- 套餐 -->
-				<view v-for="item in data.taocanList" @click="handleSelectTaoCan(item)" :class="{active: item.taocanId == activeTaocan.taocanId}">
+				<view v-for="item in data.taocanList" @click="handleSelectTaoCan(item)"
+					:class="{active: item.taocanId == activeTaocan.taocanId}">
 					{{item.name}}
 				</view>
 			</view>
 		</view>
-		<!-- 商品总价 -->	
+		<!-- 商品总价 -->
 		<view>
 			<view>商品总价 ¥{{yuanjia}}</view>
-			<view>优惠券   -¥{{youhui}}</view>
+			<view>优惠券 -¥{{youhui}}</view>
 			<view>合计 ¥{{xianjia}}</view>
 		</view>
 		<!-- 支付模式 -->
-		<view>
-			<view>微信</view>
-			<view>支付宝</view>
-		</view>	
-		
+		<template v-if="currentPlatform != 'ios'">
+			<radio-group @change="radioChange">
+				<label class="uni-list-cell uni-list-cell-pd" v-for="(item, index) in items" :key="item.value">
+					<view>
+						<radio :value="item.value" :checked="index === current" />
+					</view>
+					<view>{{item.name}}</view>
+				</label>
+			</radio-group>
+		</template>
 		<!-- 支付区 -->
 		<view>
 			<view>
@@ -42,7 +50,7 @@
 			<view @click="handlePay">立即支付</view>
 		</view>
 	</view>
-	
+
 	<kaiTongFongShiVue ref="kaiRef"></kaiTongFongShiVue>
 </template>
 
@@ -58,26 +66,57 @@
 	} from "@dcloudio/uni-app"
 	import * as shopHttp from "@/api/shop.js"
 	import kaiTongFongShiVue from "../components/kaiTongFongShi.vue";
+	import {
+		getAppCp1Buy
+	} from "@/api/shop";
+	import {
+		usePay
+	} from "../usePay.js";
+	import {
+		getUserIsYouke
+	} from "@/utils/common.js"
+	const currentPlatform = ref(null);
+
+	function isIOSorAndroid() {
+		const systemInfo = uni.getSystemInfoSync();
+
+		if (systemInfo.platform == 'ios') {
+			currentPlatform.value = 'ios'
+		} else {
+			currentPlatform.value = 'android'
+		}
+	}
 
 	const data = reactive({
-		chanpinId:null,
+		chanpinId: null,
 		cover: null,
 		intro: null,
 		name: null,
 		taocanList: []
 	})
-	
+
 	const activeTaocan = ref(null)
 	const kaiRef = ref(null)
 
+	const current = ref(0)
+	const items = ref([{
+		name: '微信',
+		value: 0
+	}, {
+		name: '支付宝',
+		value: 1
+	}])
+
+
+
 	const youhui = computed(() => {
 		if (!activeTaocan.value) {
 			return '0.00'
 		} else {
 			return activeTaocan.value.youhui
 		}
-	})	
-	
+	})
+
 	const xianjia = computed(() => {
 		if (!activeTaocan.value) {
 			return '0.00'
@@ -85,7 +124,7 @@
 			return activeTaocan.value.xianjia
 		}
 	})
-	
+
 	const yuanjia = computed(() => {
 		if (!activeTaocan.value) {
 			return '0.00'
@@ -93,34 +132,68 @@
 			return activeTaocan.value.yuanjia
 		}
 	})
-	
+
+	const {
+		OrderPay
+	} = usePay({
+		createOrderError: () => {}, // 创建订单失败
+		checkError: () => {}, // 校验失败
+		payError: () => {}, // 支付失败
+		paySuccess: () => {}, //支付成功
+		applePayError: () => {}, // 苹果内购失败
+	});
 
 	onLoad(() => {
-		initPage()
+		isIOSorAndroid();
+		initPage();
+		if (currentPlatform.value == 'ios') {
+			// ios 无微信与支付宝
+			current.value = -1;
+			console.log('cccc', current.value)
+		}
 	})
-	
+
+	function radioChange() {}
+
 	function handleSelectTaoCan(item) {
 		activeTaocan.value = item;
 	}
 
 	function initPage() {
-		shopHttp.getAppShuxueBuy().then(res => {
+		shopHttp.getAppCp1Buy().then(res => {
 			Object.assign(data, res.data)
-			
+
 			activeTaocan.value = res.data.taocanList[0]
-		})	
+		})
 	}
-	
+
 	function handlePay() {
-		
-		kaiRef.value.handleShow();
-		
-		/* if (getUserIsYouke()) {
+
+		if (getUserIsYouke()) {
 			// 游客
 			kaiRef.value.handleShow();
 		} else {
 			// 非游客
-		} */
+			const options = {
+				chanpinId: data.chanpinId,
+				taocanId: activeTaocan.value.taocanId
+			};
+
+			if (currentPlatform.value == 'ios') {
+				options.applePid = activeTaocan.value.applePid;
+				console.log('apple支付入参', options)
+				// 苹果
+				OrderPay('apple', options)
+			} else if (currentPlatform.value != 'ios' && current.value == 0) {
+				console.log('wx支付入参', options)
+				// 微信
+				OrderPay('wx', options)
+			} else if (currentPlatform.value != 'ios' && current.value == 1) {
+				console.log('ali支付入参', options)
+				// 支付宝
+				OrderPay('ali', options)
+			}
+		}
 	}
 
 	function handleBack() {

+ 7 - 2
pages/chanpinShop/cp1/intro.vue

@@ -2,7 +2,7 @@
 	<view>
 		<view class="icon-title-navBar-box">
 			<view class="nav-bar-icon" @click="handleBack"></view>
-			<text class="nav-bar-title">商</text>
+			<text class="nav-bar-title">商品详情</text>
 		</view>
 		<view>
 			<image :src="imageUrl" alt=""></image>
@@ -24,6 +24,7 @@
 		onShow
 	} from "@dcloudio/uni-app"
 	import * as shopHttp from "@/api/shop.js"
+  import {getAppCp1Info} from "../../../api/shop";
 	
 	const imageUrl = ref(null);
 
@@ -32,7 +33,7 @@
 	})
 
 	function initPage() {
-		shopHttp.getAppShuxueInfo().then(res => {
+		shopHttp.getAppCp1Info().then(res => {
 			imageUrl.value = res.data.image;
 		})
 	}
@@ -43,6 +44,10 @@
 			url: '/pages/chanpinShop/cp1/dingdan'
 		})
 	}
+	
+	function handleBack() {
+		uni.navigateBack()
+	}
 </script>
 
 <style>

+ 5 - 0
pages/chanpinShop/index.vue

@@ -124,4 +124,9 @@
 	onLoad(() => {
 
 	})
+
+
+  function handleBack() {
+    uni.navigateBack()
+  }
 </script>