diff --git a/index.html b/index.html index bf027e0..795e642 100644 --- a/index.html +++ b/index.html @@ -17,7 +17,7 @@ right: 20px; width: 60px; height: 60px; - background-color: #25D366; + background-color: #ffffff; border-radius: 50%; display: flex; justify-content: center; @@ -42,8 +42,8 @@
- - + + diff --git a/src/assets/img/rubika.webp b/src/assets/img/rubika.webp new file mode 100644 index 0000000..744caa6 Binary files /dev/null and b/src/assets/img/rubika.webp differ diff --git a/src/main.ts b/src/main.ts index 86847a1..7fc31a0 100644 --- a/src/main.ts +++ b/src/main.ts @@ -73,8 +73,8 @@ function goToLogin(to: RouteLocationNormalized, next: NavigationGuardNext) { } function goToHome(to: RouteLocationNormalized, next: NavigationGuardNext) { - if (to.name !== 'home') { - return next({ name: 'home' }) // Redirect to login + if (to.name !== 'buyProduct') { + return next({ name: 'buyProduct' }) // Redirect to login } else { return next() // If already on the login page, don't redirect } @@ -151,7 +151,7 @@ router.beforeEach(async (to, from, next) => { if (fingerPosition) { if (getToken()) { if (to.name === 'login') { - return next({ name: from.name || 'home' }) // Redirect to home if trying to access login after authentication + return next({ name: from.name || 'buyProduct' }) // Redirect to home if trying to access login after authentication } return next() // Proceed to the intended route } else { diff --git a/src/models/products.ts b/src/models/products.ts index a39b04c..dd237fc 100644 --- a/src/models/products.ts +++ b/src/models/products.ts @@ -26,6 +26,7 @@ export interface Product { description: string wallet: Wallet similar?:Product[] + inventory:number } export interface PInventory { diff --git a/src/utils/inputRules.ts b/src/utils/inputRules.ts index 90abd41..19e1bdd 100644 --- a/src/utils/inputRules.ts +++ b/src/utils/inputRules.ts @@ -169,6 +169,39 @@ const checkNumber = async (_rule: Rule, value: number) => { return Promise.resolve() } +} +const checkNumber2 = async (_rule: Rule, value: number) => { + + + if (!value) { + return Promise.reject('تعداد محصول را مشخص کنید') + } + if (value % 1 !== 0) { + return Promise.reject('استفاده از اعداد اعشاری مجاز نمی باشد') + } + if (isBuyP) { + // Skip wallet balance check if gateway is enabled + if (!gatewayP && isToken()) { + // if (!walletCash?.walletInfo?.cash && methodP == 'cash') { + // return Promise.reject('موجودی کیف پول ناکافی است') + // } + // if (!walletCash?.walletInfo?.gold && methodP == 'gold') { + // return Promise.reject('موجودی کیف طلا ناکافی است') + // } + // if (priceP * value > walletCash?.walletInfo?.cash && methodP == 'cash') + // return Promise.reject('موجودی کیف پول ناکافی است') + // if (amountP * value > walletCash?.walletInfo?.gold && methodP == 'gold') + // return Promise.reject('موجودی کیف طلا ناکافی است') + } + return Promise.resolve() + } else { + if (value > NumP) + + return Promise.reject('موجودی محصول ناکافی است') + else + return Promise.resolve() + } + } export const justNumber2 = (price: number, method?: string, amount?: number, isBuy?: boolean, gateway?: boolean) => { priceP = price @@ -193,6 +226,17 @@ export const justNumber3 = (price: number, Num?: number, isBuy?: boolean) => { trigger: 'change' } +} +export const justNumber4 = (price: number, Num?: number, isBuy?: boolean) => { + priceP = price + NumP = Num + isBuyP = isBuy + return { + required: true, + validator: checkNumber2, + trigger: 'change' + } + } export const ruleNumber = () => { diff --git a/src/views/base/about/index.vue b/src/views/base/about/index.vue index 6e7fa45..300d6e4 100644 --- a/src/views/base/about/index.vue +++ b/src/views/base/about/index.vue @@ -66,12 +66,12 @@ -
- +
+ تماس با پشتیبانی - - + +
diff --git a/src/views/base/cart/index.vue b/src/views/base/cart/index.vue index 6d84edb..d52c89a 100644 --- a/src/views/base/cart/index.vue +++ b/src/views/base/cart/index.vue @@ -34,7 +34,7 @@ >
-
+
{ // Update item price and total price item.price = newPrice + (product.cash_fee_buy ?? 0) - item.totalPrice = item.price * item.quantity + item.totalPrice = parseInt(item.price * item.quantity) }) // Save updated prices to storage @@ -162,7 +162,7 @@ watch(lastPrice, () => { // Computed total price that updates with price changes const totalPrice = computed(() => { - return cartStore.cartItems.reduce((sum, item) => sum + item.totalPrice, 0) + return parseInt(cartStore.cartItems.reduce((sum, item) => sum + item.totalPrice, 0)) }) function getProductImage(product: any) { @@ -255,7 +255,7 @@ async function handleCheckout() { // Check wallet balance for cash method items (without gateway) const cashItemsTotal = cartStore.cartItems .filter(item => item.method === 'cash' && !item.gateway) - .reduce((sum, item) => sum + item.totalPrice, 0) + .reduce((sum, item) => parseInt(sum + item.totalPrice), 0) if (cashItemsTotal > 0) { // Ensure wallet info is loaded @@ -308,7 +308,7 @@ async function handleCheckout() { return { direction: 1, // 1 for buy (cart items are always buy orders) price: productPrice, - amount: item.quantity, + amount: product.amount, gateway: item.gateway, product_id: product.id, method: item.method, @@ -374,7 +374,7 @@ async function initPrice() { // Update item price and total price item.price = newPrice + (product.cash_fee_buy ?? 0) - item.totalPrice = item.price * item.quantity + item.totalPrice =parseInt(item.price * item.quantity) }) // Save updated prices to storage diff --git a/src/views/base/index.vue b/src/views/base/index.vue index 4d3752e..fa6378a 100644 --- a/src/views/base/index.vue +++ b/src/views/base/index.vue @@ -22,27 +22,27 @@
حساب کاربری
- -
- -
هشدار قیمت
-
-
- -
- -
انتقال قطره
-
-
- -
- -
دریافت طلای فیزیکی
-
-
+ + + + + + + + + + + + + + + + + + + + +
@@ -100,9 +100,13 @@
-
- -
صفحه اصلی
+ + + + +
+ +
فروشگاه
diff --git a/src/views/base/products/components/DealProduct.vue b/src/views/base/products/components/DealProduct.vue index 1779a8d..b57a7a9 100644 --- a/src/views/base/products/components/DealProduct.vue +++ b/src/views/base/products/components/DealProduct.vue @@ -60,7 +60,7 @@ + :rules="[justNumber4(props?.ProductItem?.price , form.method , props?.ProductItem?.amount, true, form.gateway)]"> { function calculateCash(val: number) { priceErrorVisible.value = false - // console.log(val) + console.log("val",val,props?.ProductItem) if (price.value) { - form.value.goldVazn = parseFloat((val * (( props?.ProductItem?.price) + (props?.ProductItem?.cash_fee_buy)))/lastPrice.value?.buy).toFixed(1) + form.value.goldVazn = parseFloat((val * props?.ProductItem?.amount).toFixed(3)) console.log(val,props?.ProductItem?.price,props?.ProductItem?.cash_fee_buy,lastPrice.value?.buy) if (isBuy.value) { if (val){ @@ -579,7 +579,7 @@ console.log(val,props?.ProductItem?.price,props?.ProductItem?.cash_fee_buy,lastP form.value.goldVazn = 0 } } - console.log(form.value.goldVazn) + console.log('goldVazn',form.value.goldVazn) } } diff --git a/src/views/base/products/components/ProductItem.vue b/src/views/base/products/components/ProductItem.vue index b7bca38..44a4eec 100644 --- a/src/views/base/products/components/ProductItem.vue +++ b/src/views/base/products/components/ProductItem.vue @@ -95,7 +95,7 @@
ناموجود diff --git a/src/views/base/products/components/ProductItemVertical.vue b/src/views/base/products/components/ProductItemVertical.vue index b5468dd..b8fd897 100644 --- a/src/views/base/products/components/ProductItemVertical.vue +++ b/src/views/base/products/components/ProductItemVertical.vue @@ -30,7 +30,7 @@
ناموجود diff --git a/src/views/base/products/index.vue b/src/views/base/products/index.vue index 4448788..199eafb 100644 --- a/src/views/base/products/index.vue +++ b/src/views/base/products/index.vue @@ -18,11 +18,10 @@
-
- - +
+ +
-
diff --git a/src/views/base/products/product/[id].vue b/src/views/base/products/product/[id].vue index 9006a11..3a20fbd 100644 --- a/src/views/base/products/product/[id].vue +++ b/src/views/base/products/product/[id].vue @@ -1,13 +1,13 @@