panhui 3 лет назад
Родитель
Сommit
59935e41b4

+ 2 - 2
src/components/OrderInfo.vue

@@ -307,7 +307,7 @@ export default {
                         riseRate: this.value / 100
                     })
                     .then(res => {
-                        this.$toast.clear()
+                        this.$toast.dismiss()
                         this.loading = false
                         wx.chooseWXPay({
                             appId: res.appId,
@@ -322,7 +322,7 @@ export default {
                         })
                     })
                     .catch(e => {
-                        this.$toast.clear()
+                        this.$toast.dismiss()
                         this.loading = false
                         return this.$toast.error(e.error)
                     })

+ 2 - 2
src/components/OrderItem.vue

@@ -312,7 +312,7 @@ export default {
                         riseRate: this.value / 100
                     })
                     .then(res => {
-                        this.$toast.clear()
+                        this.$toast.dismiss()
                         this.loading = false
                         wx.chooseWXPay({
                             appId: res.appId,
@@ -327,7 +327,7 @@ export default {
                         })
                     })
                     .catch(e => {
-                        this.$toast.clear()
+                        this.$toast.dismiss()
                         this.loading = false
                         return this.$toast.error(e.error)
                     })

+ 3 - 1
src/locales/en.json

@@ -1 +1,3 @@
-{}
+{
+  "ping-tai-xie-yi": "Platform agreement"
+}

+ 86 - 85
src/locales/zh.json

@@ -1,92 +1,93 @@
 {
+  "cancel": "取消",
+  "login": "登录",
+  "title": {
+    "balanceRecord": "交易明细",
+    "distribution": "收益中心"
+  },
+  "common": {
     "cancel": "取消",
-    "login": "登录",
-    "title": {
-        "balanceRecord": "交易明细",
-        "distribution": "收益中心"
+    "confirm": "确定",
+    "pullRefresh": "下拉刷新",
+    "loadFinish": "加载完成",
+    "home": "首页",
+    "mine": "我的"
+  },
+  "order": {
+    "id": "订单编号",
+    "my": "我的订单",
+    "detail": "订单详情",
+    "payMethod": "支付方式",
+    "status": {
+      "ALL": "全部",
+      "NOT_PAID": "待付款",
+      "CANCELED": "已取消",
+      "NOT_CONFIRMED": "待卖家确认收款",
+      "CONFIRMED": "待委托",
+      "SELLING": "委托中",
+      "SOLD_NOT_PAID": "待买家付款",
+      "SOLD_NOT_CONFIRMED": "待确认收款",
+      "SOLD": "已售出",
+      "NOT_SHIPPED": "待发货",
+      "SHIPPED": "已发货",
+      "RECEIVED": "已收货"
     },
-    "common": {
-        "cancel": "取消",
-        "confirm": "确定",
-        "pullRefresh": "下拉刷新",
-        "loadFinish": "加载完成",
-        "home": "首页",
-        "mine": "我的"
+    "statusDesc": {
+      "NOT_PAID": "请尽快支付,超时未支付订单将自动取消",
+      "CANCELED": "订单已取消,如有疑问请联系客服",
+      "NOT_CONFIRMED": "待卖家确认收款",
+      "CONFIRMED": "待委托,委托后将在24小时内上架",
+      "SELLING": "委托中,如有疑问请联系客服",
+      "SOLD_NOT_PAID": "待买家付款",
+      "SOLD_NOT_CONFIRMED": "待确认收款",
+      "SOLD": "已售出,如有疑问请联系客服",
+      "NOT_SHIPPED": "待发货",
+      "SHIPPED": "已发货",
+      "RECEIVED": "已收货"
     },
-    "order": {
-        "id": "订单编号",
-        "my": "我的订单",
-        "detail": "订单详情",
-        "payMethod": "支付方式",
-        "status": {
-            "ALL": "全部",
-            "NOT_PAID": "待付款",
-            "CANCELED": "已取消",
-            "NOT_CONFIRMED": "待卖家确认收款",
-            "CONFIRMED": "待委托",
-            "SELLING": "委托中",
-            "SOLD_NOT_PAID": "待买家付款",
-            "SOLD_NOT_CONFIRMED": "待确认收款",
-            "SOLD": "已售出",
-            "NOT_SHIPPED": "待发货",
-            "SHIPPED": "已发货",
-            "RECEIVED": "已收货"
-        },
-        "statusDesc": {
-            "NOT_PAID": "请尽快支付,超时未支付订单将自动取消",
-            "CANCELED": "订单已取消,如有疑问请联系客服",
-            "NOT_CONFIRMED": "待卖家确认收款",
-            "CONFIRMED": "待委托,委托后将在24小时内上架",
-            "SELLING": "委托中,如有疑问请联系客服",
-            "SOLD_NOT_PAID": "待买家付款",
-            "SOLD_NOT_CONFIRMED": "待确认收款",
-            "SOLD": "已售出,如有疑问请联系客服",
-            "NOT_SHIPPED": "待发货",
-            "SHIPPED": "已发货",
-            "RECEIVED": "已收货"
-        },
-        "payMethodName": {
-            "balance": "余额支付"
-        },
-        "payNow": "立即支付",
-        "totalPayment": "实际支付"
+    "payMethodName": {
+      "balance": "余额支付"
     },
-    "balance": {
-        "symbol": "¥",
-        "balance": "账户余额",
-        "chooseAmount": "选择金额",
-        "inputCustomAmount": "请输入自定义金额",
-        "withdraw": "提现",
-        "recharge": "充值",
-        "totalWithdraw": "累计提现",
-        "record": {
-            "pay": "支付",
-            "receipt": "收款",
-            "recharge": "充值",
-            "withdraw": "提现"
-        },
-        "withdrawModalTitle": "申请提现",
-        "confirmWithdraw": "确认提现",
-        "withdrawAmount": "提现金额",
-        "availableWidthdrawAmount": "可提现金额",
-        "withdrawInputTip": "请输入提现金额",
-        "withdrawAmountError": "请输入正确的提现金额",
-        "withdrawing": "提现中",
-        "withdrawSuccess": "提现成功",
-        "withdrawFeeTip0": "注: 购买总流水的1/3手续费是",
-        "withdrawFeeTip1": ",超出部分手续费",
-        "withdrawFee": "提现手续费",
-        "realReceipt": "实际到账"
+    "payNow": "立即支付",
+    "totalPayment": "实际支付"
+  },
+  "balance": {
+    "symbol": "¥",
+    "balance": "账户余额",
+    "chooseAmount": "选择金额",
+    "inputCustomAmount": "请输入自定义金额",
+    "withdraw": "提现",
+    "recharge": "充值",
+    "totalWithdraw": "累计提现",
+    "record": {
+      "pay": "支付",
+      "receipt": "收款",
+      "recharge": "充值",
+      "withdraw": "提现"
     },
-    "user": {
-        "wallet": "我的钱包",
-        "profile": "编辑资料"
-    },
-    "product": {
-        "detail": "商品详情",
-        "dailyEarning": "日化收益"
-    },
-    "delegate": {
-        "title": "委托代卖"
-    }
+    "withdrawModalTitle": "申请提现",
+    "confirmWithdraw": "确认提现",
+    "withdrawAmount": "提现金额",
+    "availableWidthdrawAmount": "可提现金额",
+    "withdrawInputTip": "请输入提现金额",
+    "withdrawAmountError": "请输入正确的提现金额",
+    "withdrawing": "提现中",
+    "withdrawSuccess": "提现成功",
+    "withdrawFeeTip0": "注: 购买总流水的1/3手续费是",
+    "withdrawFeeTip1": ",超出部分手续费",
+    "withdrawFee": "提现手续费",
+    "realReceipt": "实际到账"
+  },
+  "user": {
+    "wallet": "我的钱包",
+    "profile": "编辑资料"
+  },
+  "product": {
+    "detail": "商品详情",
+    "dailyEarning": "日化收益"
+  },
+  "delegate": {
+    "title": "委托代卖"
+  },
+  "ping-tai-xie-yi": "平台协议"
 }

+ 3 - 0
src/mixins/common.js

@@ -25,6 +25,9 @@ export default {
             } else {
                 return true
             }
+        },
+        wait() {
+            this.$toast('敬请期待...')
         }
     }
 }

+ 3 - 7
src/mixins/phone.js

@@ -18,7 +18,7 @@ export default {
             return this.$http.get('/captcha/get').then(res => {
                 this.captchaKey = res.key
                 this.codeImg = res.image
-                this.$toast.clear()
+                this.$toast.dismiss()
                 this.emitter.emit('phoneShow')
             })
         },
@@ -27,16 +27,12 @@ export default {
             this.isSend = true
             this.setTime(60)
             return this.$http
-                .get('/sms/sendSecureVerify', {
-                    phone: phone,
-                    captcha: this.captcha,
-                    captchaKey: this.captchaKey
+                .get('/sms/sendVerify', {
+                    phone: phone
                 })
                 .then(res => {
                     this.msgCode = res
                     this.$toast.success('发送成功')
-                    this.captcha = ''
-                    this.captchaKey = ''
                     return Promise.resolve()
                 })
                 .catch(e => {

+ 1 - 1
src/stores/user.js

@@ -54,7 +54,7 @@ export const useUserStore = defineStore('user', () => {
     }
     const register = (phone, code, password) => {
         return new Promise((resolve, reject) => {
-            http.post('/auth/phoneRegister', { phone, code, password })
+            http.post('/auth/register', { phone, code, password })
                 .then(token => {
                     http.setToken(token)
                     return http.get('/user/my')

+ 3 - 0
src/styles/main.less

@@ -9,6 +9,9 @@
     --red: #ff0000;
     --green: #00b016;
 }
+ion-back-button {
+    --ion-color-primary: #000;
+}
 
 ion-content {
     &::-webkit-scrollbar {

+ 38 - 8
src/views/HomePage.vue

@@ -93,17 +93,25 @@
                             <product-info :info="hotInfo"></product-info>
                         </div>
 
-                        <div class="status hot">
+                        <div class="status hot" v-if="getStatus(item) === '抢购中'">
                             <img src="../assets/info_icon_qianggouzhong.png" alt="" />
                             <span>火爆抢购中…</span>
                         </div>
+                        <div class="status" v-else-if="getStatus(item)">
+                            <img src="../assets/info_icon_shijian.png" alt="" />
+                            <span>{{ getStatus(item) }}</span>
+                        </div>
                     </div>
                     <div class="second" v-else>
                         <van-image @click="goList(item.id)" :src="item.icon || secondImg" fit="cover" />
 
-                        <div class="status">
+                        <div class="status hot" v-if="getStatus(item) === '抢购中'">
+                            <img src="../assets/info_icon_qianggouzhong.png" alt="" />
+                            <span>火爆抢购中…</span>
+                        </div>
+                        <div class="status" v-else-if="getStatus(item)">
                             <img src="../assets/info_icon_shijian.png" alt="" />
-                            <span>15:00 开启</span>
+                            <span>{{ getStatus(item) }}</span>
                         </div>
                     </div>
                 </div>
@@ -112,7 +120,7 @@
             <div class="tools">
                 <div class="tool">
                     <img src="../assets/home_icon_pingtaixieyi.png" alt="" />
-                    <span>平台协议</span>
+                    <span>{{ $t('ping-tai-xie-yi') }}</span>
                 </div>
                 <div class="tool">
                     <img src="../assets/home_icon_liucheng.png" alt="" />
@@ -138,6 +146,7 @@ import firstImg from '../assets/p1.png'
 import secondImg from '../assets/bg2.png'
 
 import productInfo from '../components/ProductInfo.vue'
+import { isAfter, isBefore, parse, getYear, getMonth, getDate } from 'date-fns'
 
 const router = useRouter()
 function navigate() {
@@ -162,7 +171,7 @@ const setSecondSwiper = swiper => {
 
 const topBanners = ref([])
 function getBanner() {
-    global.$http.post('/banner/all', {}, { body: 'json' }).then(res => {
+    return global.$http.post('/banner/all', {}, { body: 'json' }).then(res => {
         topBanners.value = res.content.filter(item => {
             return item.type === 'TOP'
         })
@@ -172,7 +181,7 @@ function getBanner() {
 const saleBatchs = ref([])
 const hotInfo = ref({})
 function getSaleBatch() {
-    global.$http.post('saleBatch/all', {}, { body: 'json' }).then(res => {
+    return global.$http.post('saleBatch/all', {}, { body: 'json' }).then(res => {
         saleBatchs.value = res.content
         if (!res.empty) {
             global.$http
@@ -208,9 +217,30 @@ const goList = id => {
 }
 
 onMounted(() => {
-    getBanner()
-    getSaleBatch()
+    global.$toast.loading({
+        message: '加载中...',
+        forbidClick: true
+    })
+    Promise.all([getBanner(), getSaleBatch()]).then(() => {
+        console.log(global.$toast)
+        global.$toast.dismiss()
+    })
 })
+
+const getStatus = info => {
+    let date1 = getYear(new Date()) + '/' + (getMonth(new Date()) + 1) + '/' + getDate(new Date())
+    if (info && info.saleStart) {
+        if (
+            isAfter(new Date(), new Date(date1 + ' ' + info.saleStart)) &&
+            isBefore(new Date(), new Date(date1 + ' ' + info.saleEnd))
+        ) {
+            return '抢购中'
+        } else {
+            return info.saleStart + ' 开抢'
+        }
+    }
+    return ''
+}
 </script>
 
 <style lang="less" scoped>

+ 51 - 8
src/views/LoginPhonePage.vue

@@ -9,10 +9,10 @@
         </ion-header>
         <ion-content class="login">
             <van-form ref="form" @submit="onSubmit">
-                <div class="title">码登录</div>
+                <div class="title">验证码登录</div>
                 <van-cell-group :border="false">
                     <van-field
-                        v-model="form.phone"
+                        v-model="formData.phone"
                         name="手机号"
                         placeholder="请输入手机号"
                         type="tel"
@@ -30,7 +30,7 @@
                         </template>
                     </van-field>
                     <van-field
-                        v-model="form.password"
+                        v-model="formData.code"
                         :type="showPsd ? 'text' : 'password'"
                         name="密码"
                         placeholder="请输入密码"
@@ -59,6 +59,7 @@
                 </div>
 
                 <div class="btns">
+                    <div class="btn-left">暂无账号?<span @click="$router.replace('/register')">立即注册</span></div>
                     <div class="btn-right" @click="$router.replace('/login')">密码登录</div>
                 </div>
             </van-form>
@@ -69,19 +70,27 @@
 import phone from '../mixins/phone'
 import { ref } from 'vue'
 import { closeOutline } from 'ionicons/icons'
+import { useUserStore } from '../stores/user'
+let fromRoute = null
 export default {
     mixins: [phone],
     setup() {
-        const form = ref({
+        const formData = ref({
             phone: '',
-            password: ''
+            code: ''
         })
 
         const checked = ref(false)
 
         const showPsd = ref(false)
 
-        return { form, checked, showPsd, closeOutline }
+        const userStore = useUserStore()
+
+        return { formData, checked, showPsd, closeOutline, loginByCode: userStore.loginByCode }
+    },
+    beforeRouteEnter(to, from) {
+        fromRoute = from
+        console.log(to, from)
     },
     methods: {
         sendPhone(e) {
@@ -89,8 +98,41 @@ export default {
                 if (!this.checkWebDriver(e)) {
                     return
                 }
-                this.sendMsg(this.form.phone)
+                this.sendMsg(this.formData.phone)
+            })
+        },
+
+        onSubmit(e) {
+            if (!this.checked) {
+                this.$toast('请先阅读并同意注册协议')
+                return
+            }
+            if (!this.checkWebDriver(e)) {
+                return
+            }
+            this.$toast.loading({
+                message: '加载中...',
+                forbidClick: true
             })
+            this.loginByCode(this.formData.phone, this.formData.code)
+                .then(() => {
+                    this.$toast.success('登录成功')
+                    if (
+                        !fromRoute.name ||
+                        fromRoute.name === 'register' ||
+                        fromRoute.name === 'login' ||
+                        fromRoute.name === 'loginPhone'
+                    ) {
+                        this.$router.replace('/home')
+                    } else {
+                        this.$router.back()
+                    }
+                })
+                .catch(e => {
+                    if (e) {
+                        this.$toast.error(e.error)
+                    }
+                })
         }
     }
 }
@@ -180,7 +222,7 @@ ion-back-button {
 
 .btns {
     .f();
-    justify-content: center;
+    justify-content: space-between;
     padding-top: 20px;
     .btn-left {
         font-size: 12px;
@@ -195,6 +237,7 @@ ion-back-button {
         font-size: 12px;
         color: #000000;
         line-height: 24px;
+        text-decoration: underline;
         font-weight: bold;
     }
 }

+ 1 - 1
src/views/MinePage.vue

@@ -84,7 +84,7 @@
             </van-cell-group>
 
             <van-cell-group class="menu" :border="false">
-                <van-cell title="收货地址" is-link>
+                <van-cell title="收货地址" is-link @click="wait">
                     <template #icon>
                         <img class="menu-icon" src="../assets/info_icon_dizhi.png" alt="" />
                     </template>

+ 2 - 2
src/views/OrderDetailPage.vue

@@ -383,7 +383,7 @@ export default {
                         riseRate: this.value / 100
                     })
                     .then(res => {
-                        this.$toast.clear()
+                        this.$toast.dismiss()
                         this.loading = false
                         wx.chooseWXPay({
                             appId: res.appId,
@@ -398,7 +398,7 @@ export default {
                         })
                     })
                     .catch(e => {
-                        this.$toast.clear()
+                        this.$toast.dismiss()
                         this.loading = false
                         return this.$toast.error(e.error)
                     })

+ 1 - 1
src/views/ProductDetailPage.vue

@@ -3,7 +3,7 @@
         <ion-header>
             <ion-toolbar>
                 <ion-buttons slot="start">
-                    <ion-back-button default-href="#" @click="$router.back()"></ion-back-button>
+                    <ion-back-button default-href="#" text="" @click="$router.back()"></ion-back-button>
                 </ion-buttons>
                 <ion-title>{{ $t('product.detail') }}</ion-title>
             </ion-toolbar>

+ 9 - 5
src/views/ProductListPage.vue

@@ -1,17 +1,21 @@
 <template>
     <ion-page>
         <ion-header>
-            <ion-toolbar>
+            <ion-toolbar class="head">
                 <ion-buttons slot="start">
-                    <ion-back-button default-href="#" @click="$router.back()"></ion-back-button>
+                    <ion-back-button default-href="#" text="" @click="$router.back()"></ion-back-button>
+                </ion-buttons>
+                <ion-title>{{ batchInfo.name }}</ion-title>
+                <ion-buttons slot="end">
+                    <img class="search" src="../assets/search.png" alt="" />
                 </ion-buttons>
             </ion-toolbar>
         </ion-header>
         <ion-content>
-            <div class="head">
+            <!-- <div class="head">
                 <div class="text">{{ batchInfo.name }}</div>
                 <img class="search" src="../assets/search.png" alt="" />
-            </div>
+            </div> -->
             <div class="status hot" v-if="status === '抢购中'">
                 <img src="../assets/info_icon_qianggouzhong.png" alt="" />
                 <span>火爆抢购中…</span>
@@ -86,7 +90,7 @@ onMounted(() => {
     height: 50px;
     background-color: var(--ion-color-dark-contrast);
     .f();
-    padding: 0 16px;
+    padding: 0;
     font-size: 16px;
     .text {
         flex-grow: 1;

+ 1 - 1
src/views/RegisterPage.vue

@@ -30,7 +30,7 @@
                         </template>
                     </van-field>
                     <van-field
-                        v-model="formData.password"
+                        v-model="formData.code"
                         type="digit"
                         name="验证码"
                         placeholder="请输入验证码"

+ 2 - 2
src/views/SettingPage.vue

@@ -129,7 +129,7 @@ export default {
             })
             this.updateFile(e, 'avatar', 300).then(img => {
                 this.updateUser({ avatar: img }).then(res => {
-                    this.$toast.clear()
+                    this.$toast.dismiss()
                 })
             })
         },
@@ -140,7 +140,7 @@ export default {
             })
             this.updateFile(e, 'bg', 1200).then(img => {
                 this.updateUser({ bg: img }).then(res => {
-                    this.$toast.clear()
+                    this.$toast.dismiss()
                 })
             })
         },