wangguoyu hace 3 semanas
padre
commit
08aa6000ad
Se han modificado 3 ficheros con 141 adiciones y 59 borrados
  1. 12 0
      api/productMall.js
  2. 117 55
      pages/mall/mallPage.vue
  3. 12 4
      pages/my/index.vue

+ 12 - 0
api/productMall.js

@@ -11,6 +11,18 @@ export function getMallist(data = {}) {
   })
 }
 
+export function getMallistCom(data = {}) {
+  return request({
+    'url': '/common/index/card/list',
+    headers: {
+      isToken: true
+    },
+    method: 'post',
+    data,
+    timeout: 20000
+  })
+}
+
 export function mallCardInfo(data = {}) {
   return request({
     'url': '/app/card/info',

+ 117 - 55
pages/mall/mallPage.vue

@@ -105,6 +105,7 @@
 
 
 		<product-dialog ref="mallProductPopup"></product-dialog>
+		<tip-big-dialog ref="youkeDialogRef" @confirm-btn="ykConfirm" :imgShow="true"></tip-big-dialog>
 	</view>
 </template>
 
@@ -116,7 +117,8 @@
 		ref
 	} from "vue";
 	import {
-		getMallist
+		getMallist,
+		getMallistCom
 	} from "@/api/productMall.js";
 	import {
 		orderAdd,
@@ -136,12 +138,15 @@
 	import cacheManager from '@/utils/cacheManager.js';
 	import CustomTabBar from '@/components/custom-tabbar/custom-tabbar.vue';
 	import detailDialog from './detailDialog.vue'
+	import tipBigDialog from '@/components/dialog/tipBigDialog.vue';
 	import productDialog from './productDialog.vue'
+
 	const showPayWay = ref(true)
 	const showDetail = ref(false)
 	const mxjtClass = ref('mxjt-sq-icon')
 	const mallDetailPopup = ref(null);
 	const mallProductPopup = ref(null);
+	const youkeDialogRef = ref(null);
 	let scrollIntoId = ref(null)
 	const productData = reactive({
 		items: ['数学', '英语'],
@@ -159,6 +164,13 @@
 	let quantity = ref(1)
 	let channel = ref('')
 	let appleFlag = ref('')
+	const subjectId = ref(null); //游客使用
+	const levelId = ref(null); //游客使用
+	const typeId = ref(null); //游客使用
+	const tipFlag = ref(null); //游客使用
+
+
+
 	const totalPrice = computed(() => {
 		return productData.list
 			.filter(item => productData.selectedIds.includes(item.id))
@@ -177,6 +189,12 @@
 		mallProductPopup.value.detailShow(item);
 	}
 
+	function ykConfirm() {
+		uni.redirectTo({
+			url: '/pages/login/index'
+		});
+	}
+
 	function detailBtn() {
 		// // 获取选中商品的cardId列表
 		// const selectedProducts = productData.list.filter(
@@ -308,42 +326,42 @@
 		orderPayApple(req).then(res => {
 			if (res.code == 0 && res.data) {
 				iapChannel.finishTransaction(data.transactionIdentifier)
-				console.log('resiapChanneliapChanneliapChannel', res);		
-				orderCheck({
-					id: orderId.value
-				}).then(res3 => {
-					console.log('res3', res3);
-					if (res3.code == 0) {
-						genggaiVip(res3.data)
-					} else {
-						setTimeout(() => {
-							orderCheck({
-								id: orderId.value
-							}).then(res4 => {
-								if (res4.code == 0) {
-									genggaiVip(res4.data)
-								} else {
-									toast(
-										"开通失败,请联系管理员!"
-									)
-									uni
-										.hideLoading();
-									return false
-								}
-							}).catch(() => {
-								uni.hideLoading();
-								toast("check接口报错")
-								return false
-							})
-						}, 5000)
-					}
-				}).catch(() => {
-					uni.hideLoading();
-					toast("check接口报错")
-					return false
-				})
-				
-				
+				console.log('resiapChanneliapChanneliapChannel', res);
+				orderCheck({
+					id: orderId.value
+				}).then(res3 => {
+					console.log('res3', res3);
+					if (res3.code == 0) {
+						genggaiVip(res3.data)
+					} else {
+						setTimeout(() => {
+							orderCheck({
+								id: orderId.value
+							}).then(res4 => {
+								if (res4.code == 0) {
+									genggaiVip(res4.data)
+								} else {
+									toast(
+										"开通失败,请联系管理员!"
+									)
+									uni
+										.hideLoading();
+									return false
+								}
+							}).catch(() => {
+								uni.hideLoading();
+								toast("check接口报错")
+								return false
+							})
+						}, 5000)
+					}
+				}).catch(() => {
+					uni.hideLoading();
+					toast("check接口报错")
+					return false
+				})
+
+
 			} else {
 
 				iapChannel.finishTransaction(data.transactionIdentifier)
@@ -437,9 +455,9 @@
 			id: orderId.value
 		}).then(res2 => {
 			uni.hideLoading();
-			console.log('res2', res2);
-			if(res2.code !=0){
-				return false
+			console.log('res2', res2);
+			if (res2.code != 0) {
+				return false
 			}
 			uni.requestPayment({
 				"provider": "wxpay",
@@ -514,9 +532,9 @@
 		orderPayAli({
 			id: orderId.value
 		}).then(res2 => {
-			console.log('res2', res2);
-			if(res2.code !=0){
-				return false
+			console.log('res2', res2);
+			if (res2.code != 0) {
+				return false
 			}
 			uni.hideLoading();
 			uni.requestPayment({
@@ -629,7 +647,11 @@
 		console.log('e', e);
 		productData.current = e.currentIndex
 		productData.selectedIds = [] // 清空选中
-		getMore()
+		if (!cacheManager.get('auth')) {
+			getMoreYk()
+		} else {
+			getMore()
+		}
 	}
 
 
@@ -658,6 +680,21 @@
 		})
 	}
 
+	function getMoreYk() {
+		const opt = {
+			subjectId: productData.current + 1
+		}
+		getMallistCom(opt).then(res => {
+			if (res.code == 0) {
+				productData.list = res.data
+
+			}
+		}).catch(err => {
+			toast("获取产品数据失败")
+			return false
+		})
+	}
+
 	function scrollToIdFun(targetId) {
 		const index = productData.list.findIndex(item => item.id == targetId)
 		console.log('index', index);
@@ -672,6 +709,11 @@
 	}
 
 	function addProduct(item) {
+
+		if (!cacheManager.get('auth')) {
+			youkeDialogRef.value.handleShow();
+			return false
+		}
 		console.log('item', item);
 
 		const temp = [...productData.selectedIds]
@@ -689,27 +731,47 @@
 	}
 
 	function goBack() {
-		if (productData.from == 'daoPage') {
+
+
+		if (!cacheManager.get('auth')) {
+			// 游客
 			uni.redirectTo({
-				url: '/pages/study/index'
+				url: `/pages/my/index?levelId=${levelId.value}&typeId=${typeId.value}&subjectId=${subjectId.value}&tipFlag=${tipFlag.value}`
 			})
 		} else {
-			uni.redirectTo({
-				url: '/pages/my/index'
-			})
+			if (productData.from == 'daoPage') {
+				uni.redirectTo({
+					url: '/pages/study/index'
+				})
+			} else {
+				uni.redirectTo({
+					url: '/pages/my/index'
+				})
+			}
 		}
 	}
 
 	onLoad((options) => {
-		if (options.from == 'daoPage') {
+
+		if (!cacheManager.get('auth')) {
+			// 游客
+			levelId.value = options.levelId
+			typeId.value = options.typeId
+			subjectId.value = options.subjectId
+			tipFlag.value = options.tipFlag
 			productData.current = Number(options.subjectId) - 1
-			productData.cardId = options.cardId
-			productData.from = options.from
+			getMoreYk()
 		} else {
-			productData.current = Number(cacheManager.get('auth').subjectId) - 1
+			if (options.from == 'daoPage') {
+				productData.current = Number(options.subjectId) - 1
+				productData.cardId = options.cardId
+				productData.from = options.from
+			} else {
+				productData.current = Number(cacheManager.get('auth').subjectId) - 1
+			}
+			//isIOSorAndroid()
+			getMore();
 		}
-		//isIOSorAndroid()
-		getMore();
 
 	})
 </script>

+ 12 - 4
pages/my/index.vue

@@ -261,10 +261,18 @@
 	}
 	
 	// 产品商城
-	function cpscClick(){
-		uni.redirectTo({
-			url: '/pages/mall/mallPage'
-		});
+	function cpscClick(){
+		
+		if (loginFlag.value) {
+		uni.redirectTo({
+			url: '/pages/mall/mallPage'
+		});
+		} else {
+			uni.redirectTo({
+				url: `/pages/mall/mallPage?levelId=${routerOpt.levelId}&typeId=${routerOpt.typeId}&subjectId=${routerOpt.subjectId}&tipFlag=${routerOpt.tipFlag}`
+			});
+		}
+	
 	}
 
 	// 订单