Kaynağa Gözat

Merge branch 'dev' of xiongzhu/paimaide into master

panhui 2 yıl önce
ebeveyn
işleme
3eec9da7d2

+ 16 - 2
src/components/OrderItem.vue

@@ -161,13 +161,27 @@ export default {
         ...mapState(useUserStore, ['user']),
         ...mapState(useSystemStore, ['platformCommission', 'saleBatches']),
         riseRate() {
-            return this.saleBatches.find(item => item.id == this.info.batchId)?.riseRate || 0
+            let info = this.saleBatches.find(item => item.id == this.info.batchId)
+            let _back = null
+            if (info) {
+                _back = info.extensions.find(item => {
+                    return item.minPrice <= this.info.totalPrice && this.info.totalPrice <= item.maxPrice
+                })
+            }
+            return _back?.riseRate || 0
         },
         riseRatePercent() {
             return this.riseRate * 100
         },
         platformCommission() {
-            return this.saleBatches.find(item => item.id == this.info.batchId)?.serviceCharge || 0
+            let info = this.saleBatches.find(item => item.id == this.info.batchId)
+            let _back = null
+            if (info) {
+                _back = info.extensions.find(item => {
+                    return item.minPrice <= this.info.totalPrice && this.info.totalPrice <= item.maxPrice
+                })
+            }
+            return _back?.serviceCharge || 0
         },
         productInfo() {
             return this.info.productInfo || {}

+ 2 - 2
src/components/ProductItem.vue

@@ -23,13 +23,13 @@
                     </div>
                     <div class="name">{{ $t('product.priceNow') }}</div>
                 </div>
-                <div class="data">
+                <!-- <div class="data">
                     <div class="val" v-if="!noSale">{{ riseRatePercent }}%</div>
                     <div class="val" v-else>
                         <span>***</span>
                     </div>
                     <div class="name">{{ $t('product.dailyEarning') }}</div>
-                </div>
+                </div> -->
                 <div class="data">
                     <div class="val" v-if="!noSale">
                         <span>{{ $t('balance.symbol') }}</span>

+ 1 - 1
src/components/ProductItemSmall.vue

@@ -8,7 +8,7 @@
             <div class="text1 van-ellipsis">{{ getLocaleString(info.name) }}</div>
             <div class="badges">
                 <div class="badge">{{ category.name }}</div>
-                <div class="badge">{{ riseRatePercent }}%&nbsp;{{ $t('product.riseDesc') }}</div>
+                <!-- <div class="badge">{{ riseRatePercent }}%&nbsp;{{ $t('product.riseDesc') }}</div> -->
                 <!-- <div class="badge">{{ $t('product.tag') }}</div> -->
             </div>
             <div class="datas">

+ 6 - 3
src/locales/en.json

@@ -259,13 +259,13 @@
         "walletPay": "Wallet payment"
     },
     "product": {
-        "dailyEarning": "Daily Income",
+        "dailyEarning": "Income",
         "detail": "Product Details",
         "hot": "IN FULL SWING!",
         "nowPrice": "Current",
         "owner": "Current Holder",
         "priceNow": "Current",
-        "riseDesc": "Daily Income",
+        "riseDesc": "Income",
         "search": "Search",
         "searchNo": "No products were found~",
         "searchPla": "Enter search keywords",
@@ -340,6 +340,9 @@
         "togglePrompt": "Are you sure you want to {status} automatic acquisition?",
         "closed": "Closed successfully",
         "errorInterval": "Please enter the correct interval",
-        "opened": "Opened successfully"
+        "opened": "Opened successfully",
+        "autoTime": "Auto buy {times}x",
+        "closeSu": "closed successfully",
+        "openSu": "Open successfully"
     }
 }

+ 2 - 1
src/locales/zh.json

@@ -217,7 +217,8 @@
         "togglePrompt": "确认要{status}自动收购吗?",
         "closeSu": "关闭成功",
         "errorInterval": "请输入正确区间",
-        "openSu": "开启成功"
+        "openSu": "开启成功",
+        "autoTime": "自动收购{times}次"
     },
     "news": {
         "newsNull": "没有任何新闻哦~"

+ 184 - 72
src/views/HomePage.vue

@@ -1,6 +1,6 @@
 <template>
     <ion-page>
-        <ion-content fullscreen class="home">
+        <ion-content :scrollEvents="true" fullscreen class="home" @ionScroll="handleScroll()">
             <van-swipe class="mySwiper" :autoplay="5000" :style="{ height: '65vw' }">
                 <van-swipe-item v-for="(item, index) in topBanners" :key="index">
                     <van-image :src="item.pic" fit="cover" width="100vw" height="65vw" />
@@ -118,46 +118,6 @@
                 </div>
             </div>
 
-            <!-- 初级场 -->
-
-            <template v-for="(item, index) in saleBatches" :key="index">
-                <div class="level">
-                    <van-cell :title="item.name" :value="$t('home.all')" @click="goList(item)" :border="false" is-link>
-                        <template #title>
-                            <div class="cell-title" :class="[`level_` + index]">
-                                <span>
-                                    <span>{{ item.name }}</span>
-                                    <img class="title-bg" src="@/assets/title-bg.png" alt="" />
-                                </span>
-                            </div>
-                        </template>
-                        <template #right-icon>
-                            <ion-icon class="right-icon" :icon="intoIcon"></ion-icon>
-                        </template>
-                    </van-cell>
-
-                    <div class="second">
-                        <van-image @click="goList(item)" :src="item.cover" fit="scale-down" />
-
-                        <!-- <img class="second-btn" v-if="index === 0" src="../assets/TUTORIAL.png" alt="" /> -->
-                        <template v-if="item.empty !== null && item.id != 11547">
-                            <div
-                                class="status hot animate__animated animate__tada animate__infinite"
-                                v-if="getStatus(item) === '抢购中'"
-                            >
-                                <img src="../assets/info_icon_qianggouzhong.png" alt="" />
-                                <span>{{ $t('product.hot') }}</span>
-                            </div>
-                            <div class="status" v-else-if="getStatus(item)">
-                                <img src="../assets/info_icon_shijian.png" alt="" />
-                                <span>{{ $t('product.start', { time: formatTime(item.saleStart) }) }}</span>
-                                <span v-if="getStatus(item) === '已抢光'">({{ $t('blf.finish') }})</span>
-                            </div>
-                        </template>
-                    </div>
-                </div>
-            </template>
-
             <div class="vip-content" v-if="isVip">
                 <img class="vip-bg" src="@/assets/png-cishu.png" alt="" />
                 <div class="vip-box">
@@ -170,22 +130,82 @@
                 </div>
             </div>
 
-            <div class="tools">
-                <!-- <div class="tool">
-                    <img src="../assets/home_icon_pingtaixieyi.png" alt="" />
-                    <span>{{ $t('common.eula') }}</span>
-                </div>
-                <div class="tool">
-                    <img src="../assets/home_icon_liucheng.png" alt="" />
-                    <span>{{ $t('common.guide') }}</span>
-                </div> -->
-                <div class="tool-info" @click="showTutorialVideo">
-                    <img src="../assets/png-TUTORIAL.png" alt="" />
-                </div>
-                <div class="tool-info" @click="showIntroVideo">
-                    <img src="../assets/png-AGREEMENT.png" alt="" />
+            <!-- 初级场 -->
+
+            <template v-if="batchId">
+                <van-list
+                    v-model:loading="loading"
+                    :finished="finished"
+                    :finished-text="$t('common.loadFinish')"
+                    @load="getData"
+                    ref="listRef"
+                    :immediate-check="false"
+                >
+                    <div class="product" v-for="item in list" :key="item.id">
+                        <product-small-info
+                            list
+                            :info="item"
+                            :stopOfficial="stopOfficial"
+                            :batchStatus="batchStatus"
+                        ></product-small-info>
+                    </div>
+                </van-list>
+            </template>
+
+            <template v-else>
+                <template v-for="(item, index) in saleBatches" :key="index">
+                    <div class="level">
+                        <van-cell
+                            :title="item.name"
+                            :value="$t('home.all')"
+                            @click="goList(item)"
+                            :border="false"
+                            is-link
+                        >
+                            <template #title>
+                                <div class="cell-title" :class="[`level_` + index]">
+                                    <span>
+                                        <span>{{ item.name }}</span>
+                                        <img class="title-bg" src="@/assets/title-bg.png" alt="" />
+                                    </span>
+                                </div>
+                            </template>
+                            <template #right-icon>
+                                <ion-icon class="right-icon" :icon="intoIcon"></ion-icon>
+                            </template>
+                        </van-cell>
+
+                        <div class="second">
+                            <van-image @click="goList(item)" :src="item.cover" fit="scale-down" />
+
+                            <!-- <img class="second-btn" v-if="index === 0" src="../assets/TUTORIAL.png" alt="" /> -->
+                            <template v-if="item.empty !== null && item.id != 11547">
+                                <div
+                                    class="status hot animate__animated animate__tada animate__infinite"
+                                    v-if="getStatus(item) === '抢购中'"
+                                >
+                                    <img src="../assets/info_icon_qianggouzhong.png" alt="" />
+                                    <span>{{ $t('product.hot') }}</span>
+                                </div>
+                                <div class="status" v-else-if="getStatus(item)">
+                                    <img src="../assets/info_icon_shijian.png" alt="" />
+                                    <span>{{ $t('product.start', { time: formatTime(item.saleStart) }) }}</span>
+                                    <span v-if="getStatus(item) === '已抢光'">({{ $t('blf.finish') }})</span>
+                                </div>
+                            </template>
+                        </div>
+                    </div>
+                </template>
+
+                <div class="tools">
+                    <div class="tool-info" @click="showTutorialVideo">
+                        <img src="../assets/png-TUTORIAL.png" alt="" />
+                    </div>
+                    <div class="tool-info" @click="showIntroVideo">
+                        <img src="../assets/png-AGREEMENT.png" alt="" />
+                    </div>
                 </div>
-            </div>
+            </template>
         </ion-content>
     </ion-page>
 </template>
@@ -212,6 +232,8 @@ import NewsModal from '@/components/NewsModal.vue'
 import { UseElementBounding } from '@vueuse/components'
 import { onIonViewWillEnter } from '@ionic/vue'
 import { storeToRefs } from 'pinia'
+import productSmallInfo from '../components/ProductItemSmall.vue'
+import useList from '../plugins/list'
 
 const promptLogin = inject('promptLogin')
 const router = useRouter()
@@ -228,26 +250,54 @@ function getBanner() {
 }
 
 const saleBatches = ref([])
+const batchInfo = ref({})
+const batchId = ref(0)
 function getSaleBatch() {
-    return http.post('saleBatch/all', {}, { body: 'json' }).then(res => {
-        saleBatches.value = res.content.map(item => {
-            return {
-                ...item,
-                empty: false,
-                hotInfo: {}
-            }
-        })
-        if (!res.empty) {
-            saleBatches.value.forEach((item, index) => {
-                if (item.id == 11547) {
-                    item.empty = true
-                    return
+    return http.get('sysConfig/get/home_batch_id').then(res => {
+        if (res.value === '0') {
+            return http.post('saleBatch/all', {}, { body: 'json' }).then(res => {
+                saleBatches.value = res.content.map(item => {
+                    return {
+                        ...item,
+                        empty: false,
+                        hotInfo: {}
+                    }
+                })
+                if (!res.empty) {
+                    saleBatches.value.forEach((item, index) => {
+                        if (item.id == 11547) {
+                            item.empty = true
+                            return
+                        }
+                        http.post(
+                            '/product/list',
+                            {
+                                query: {
+                                    batchId: item.id,
+                                    status: 'IN_STOCK'
+                                },
+                                size: 1,
+                                sort: 'modifiedAt,desc'
+                            },
+                            { body: 'json' }
+                        ).then(res => {
+                            saleBatches.value[index].empty = res.empty
+                        })
+                    })
+                }
+            })
+        } else {
+            batchId.value = res.value
+            return http.get('/saleBatch/get/' + batchId.value).then(res => {
+                batchInfo.value = {
+                    ...res,
+                    empty: false
                 }
                 http.post(
                     '/product/list',
                     {
                         query: {
-                            batchId: item.id,
+                            batchId: batchId.value,
                             status: 'IN_STOCK'
                         },
                         size: 1,
@@ -255,12 +305,62 @@ function getSaleBatch() {
                     },
                     { body: 'json' }
                 ).then(res => {
-                    saleBatches.value[index].empty = res.empty
+                    batchInfo.value.empty = res.empty
+                    getData(true)
                 })
             })
         }
     })
 }
+const { empty, size, loading, finished, list, getData } = useList('/product/list', () => {
+    if (batchStatus.value !== '抢购中' && batchId.value) {
+        return {
+            query: {
+                batchId: batchId.value,
+                status: 'IN_STOCK,SOLD_OUT'
+            },
+            sort: 'status,asc;delayTo,asc;sales,desc;'
+        }
+    } else {
+        return {
+            query: {
+                batchId: batchId.value,
+                status: 'IN_STOCK'
+            },
+            sort: 'delayTo,asc;sales,desc;'
+        }
+    }
+})
+const batchStatus = computed(() => {
+    let date1 = getYear(new Date()) + '/' + (getMonth(new Date()) + 1) + '/' + getDate(new Date())
+    let startDate = getUtcTime(new Date(date1 + ' ' + batchInfo.value.saleStart))
+    let endDate = getUtcTime(new Date(date1 + ' ' + batchInfo.value.saleEnd))
+    if (batchInfo.value && batchInfo.value.saleStart) {
+        if (isAfter(new Date(), startDate) && isBefore(new Date(), endDate) && !batchInfo.value.empty) {
+            return '抢购中'
+        } else if (isBefore(new Date(), startDate)) {
+            return formatTime(batchInfo.value.saleStart)
+        } else if (batchInfo.value.empty && isBefore(new Date(), endDate)) {
+            return '已抢光'
+        } else {
+            return formatTime(batchInfo.value.saleStart)
+        }
+    }
+    return ''
+})
+const stopOfficial = computed(() => {
+    let flag = false
+    list.value.forEach(item => {
+        if (item.sales > 0) {
+            flag = true
+        }
+    })
+    return flag
+})
+const listRef = ref(null)
+function handleScroll() {
+    listRef.value.check()
+}
 
 const recentWidthdraw = ref([])
 function getRecentWidthdraw() {
@@ -295,8 +395,8 @@ const recentNews = computed(() => {
 const refresh = () => {
     getRecentWidthdraw()
     getBanner()
-    getSaleBatch()
     getNews()
+    getSaleBatch()
 }
 
 const isVip = computed(() => {
@@ -311,6 +411,7 @@ function getMineVip() {
 }
 onIonViewWillEnter(() => {
     getMineVip()
+    getSaleBatch()
 })
 
 const turtorialShown = useStorage('turtorialShown', false)
@@ -814,4 +915,15 @@ ion-content {
         }
     }
 }
+.van-list {
+    padding: 8px 8px 8px;
+    .product {
+        margin: 8px;
+        background: var(--ion-color-step-50);
+        border-radius: 8px;
+        width: calc(50vw - 24px);
+        display: inline-block;
+        overflow: hidden;
+    }
+}
 </style>

+ 5 - 0
src/views/MinePage.vue

@@ -268,6 +268,7 @@
                                             <small>{{ $t('balance.symbol') }}</small
                                             >{{ item.price }}
                                         </div>
+                                        <div class="text3">{{ $t('vip.autoTime', { times: item.dailyLimit }) }}</div>
                                     </div>
                                 </div>
                             </div>
@@ -1053,6 +1054,10 @@ ion-content {
                             margin-top: 5px;
                         }
                     }
+
+                    .text3 {
+                        font-size: 10px;
+                    }
                 }
 
                 &:last-child {

+ 17 - 2
src/views/OrderDetailPage.vue

@@ -200,13 +200,28 @@ export default {
         ...mapState(useUserStore, ['user']),
         ...mapState(useSystemStore, ['saleBatches', 'getSysConfigs']),
         riseRate() {
-            return this.saleBatches.find(item => item.id == this.orderInfo.batchId)?.riseRate || 0
+            // return this.saleBatches.find(item => item.id == this.orderInfo.batchId)?.riseRate || 0
+            let info = this.saleBatches.find(item => item.id == this.orderInfo.batchId)
+            let _back = null
+            if (info) {
+                _back = info.extensions.find(item => {
+                    return item.minPrice <= this.orderInfo.totalPrice && this.orderInfo.totalPrice <= item.maxPrice
+                })
+            }
+            return _back?.riseRate || 0
         },
         riseRatePercent() {
             return this.riseRate * 100
         },
         platformCommission() {
-            return this.saleBatches.find(item => item.id == this.orderInfo.batchId)?.serviceCharge || 0
+            let info = this.saleBatches.find(item => item.id == this.orderInfo.batchId)
+            let _back = null
+            if (info) {
+                _back = info.extensions.find(item => {
+                    return item.minPrice <= this.orderInfo.totalPrice && this.orderInfo.totalPrice <= item.maxPrice
+                })
+            }
+            return _back?.serviceCharge || 0
         },
         pic() {
             if (this.productInfo.pic && this.productInfo.pic.length > 0) {

+ 17 - 2
src/views/ProductDetailPage.vue

@@ -179,11 +179,26 @@ onMounted(() => {
 })
 
 const riseRate = computed(() => {
-    return useSystemStore().saleBatches.find(item => item.id == info.value.batchId)?.riseRate || 0
+    let _info = useSystemStore().saleBatches.find(item => item.id == info.value.batchId)
+    let _back = null
+    if (_info) {
+        _back = _info.extensions.find(item => {
+            return item.minPrice <= info.value.currentPrice && info.value.currentPrice <= item.maxPrice
+        })
+    }
+    // return useSystemStore().saleBatches.find(item => item.id == info.value.batchId)?.riseRate || 0
+    return _back?.riseRate || 0
 })
 
 const riseRatePercent = computed(() => {
-    return useSystemStore().saleBatches.find(item => item.id == info.value.batchId)?.riseRate * 100 || 0
+    let _info = useSystemStore().saleBatches.find(item => item.id == info.value.batchId)
+    let _back = null
+    if (_info) {
+        _back = _info.extensions.find(item => {
+            return item.minPrice <= info.value.currentPrice && info.value.currentPrice <= item.maxPrice
+        })
+    }
+    return _back?.riseRate * 100 || 0
 })
 
 const nextPrice = computed(() => {