wangguoyu hai 1 semana
pai
achega
f97567b0aa
Modificáronse 1 ficheiros con 47 adicións e 16 borrados
  1. 47 16
      pages/mall/mallPage.vue

+ 47 - 16
pages/mall/mallPage.vue

@@ -331,14 +331,14 @@
 					id: orderId.value
 				}).then(res3 => {
 					console.log('res3', res3);
-					if (res3.code == 0&&res3.data.success) {
+					if (res3.code == 0 && res3.data.success) {
 						genggaiVip(res3.data)
 					} else {
 						setTimeout(() => {
 							orderCheck({
 								id: orderId.value
 							}).then(res4 => {
-								if (res4.code == 0&&res4.data.success) {
+								if (res4.code == 0 && res4.data.success) {
 									genggaiVip(res4.data)
 								} else {
 									toast(
@@ -483,7 +483,7 @@
 						id: orderId.value
 					}).then(res3 => {
 						console.log('res3', res3);
-						if (res3.code == 0&&res3.data.success) {
+						if (res3.code == 0 && res3.data.success) {
 
 							genggaiVip(res3.data)
 						} else {
@@ -491,7 +491,7 @@
 								orderCheck({
 									id: orderId.value
 								}).then(res4 => {
-									if (res4.code == 0&&res4.data.success) {
+									if (res4.code == 0 && res4.data.success) {
 										genggaiVip(res4.data)
 									} else {
 										toast(
@@ -551,7 +551,7 @@
 					orderCheck({
 						id: orderId.value
 					}).then(res3 => {
-						if (res3.code == 0&&res3.data.success) {
+						if (res3.code == 0 && res3.data.success) {
 							genggaiVip(res3.data)
 						} else {
 							setTimeout(() => {
@@ -559,7 +559,7 @@
 									id: orderId.value
 								}).then(res4 => {
 									if (res4.code ==
-										0&&res4.data.success) {
+										0 && res4.data.success) {
 										genggaiVip(res4.data)
 									} else {
 										toast(
@@ -708,20 +708,51 @@
 		}
 	}
 
-	function addProduct(item) {
 
+	function addProduct(item) {
 		if (!cacheManager.get('auth')) {
 			youkeDialogRef.value.handleShow();
-			return false
+			return false;
+		}
+		if (item.yigou == 1) {
+			return false;
+		}
+
+		const currentSelected = productData.selectedIds;
+		const isAlreadySelected = currentSelected.includes(item.id);
+		if (currentPlatform.value == 'ios') {
+			if (isAlreadySelected) {
+				productData.selectedIds = currentSelected.filter(id => id !== item.id);
+			} else {
+				if (currentSelected.length >= 1) {
+					toast("只允许单个购买!");
+					return false;
+				}
+				productData.selectedIds = [item.id];
+			}
+		} else {
+			const temp = [...currentSelected];
+			const index = temp.indexOf(item.id);
+			index > -1 ? temp.splice(index, 1) : temp.push(item.id);
+			productData.selectedIds = temp;
 		}
-		console.log('item', item);
 
-		const temp = [...productData.selectedIds]
-		const index = temp.indexOf(item.id)
-		index > -1 ? temp.splice(index, 1) : temp.push(item.id)
-		productData.selectedIds = temp
-		console.log('productData.selectedIds', productData.selectedIds);
 	}
+	// function addProduct(item) {
+
+	// 	if (!cacheManager.get('auth')) {
+	// 		youkeDialogRef.value.handleShow();
+	// 		return false
+	// 	}
+	// 	if (item.yigou == 1) {
+	// 		return false
+	// 	}
+	// 	const temp = [...productData.selectedIds]
+	// 	const index = temp.indexOf(item.id)
+	// 	index > -1 ? temp.splice(index, 1) : temp.push(item.id)
+	// 	productData.selectedIds = temp
+	// 	console.log('productData.selectedIds', productData.selectedIds.length);
+	// }
 
 	function isItemSelected(id) {
 		return productData.cardId ?
@@ -752,7 +783,7 @@
 	}
 
 	onLoad((options) => {
-
+		isIOSorAndroid()
 		if (!cacheManager.get('auth')) {
 			// 游客
 			levelId.value = options.levelId
@@ -769,7 +800,7 @@
 			} else {
 				productData.current = Number(cacheManager.get('auth').subjectId) - 1
 			}
-			//isIOSorAndroid()
+
 			getMore();
 		}