Просмотр исходного кода

Merge branch 'dev' of http://git.izouma.com/xiongzhu/raex_front into dev

panhui 4 лет назад
Родитель
Сommit
0584abc2c7
9 измененных файлов с 191 добавлено и 108 удалено
  1. 4 1
      .eslintrc.js
  2. 1 0
      package.json
  3. 131 94
      src/main.js
  4. 5 1
      src/store/index.js
  5. 2 2
      src/views/Discover.vue
  6. 2 2
      src/views/Mine.vue
  7. 35 4
      src/views/Submit.vue
  8. 6 4
      src/views/asset/Detail.vue
  9. 5 0
      yarn.lock

+ 4 - 1
.eslintrc.js

@@ -5,7 +5,10 @@ module.exports = {
     },
     extends: ['plugin:vue/vue3-essential', 'eslint:recommended', '@vue/prettier'],
     parserOptions: {
-        parser: 'babel-eslint'
+        parser: 'babel-eslint',
+        ecmaFeatures: {
+            globalReturn: true
+        }
     },
     rules: {
         'no-console': 'off',

+ 1 - 0
package.json

@@ -23,6 +23,7 @@
         "html2canvas": "^1.3.2",
         "lodash": "^4.17.21",
         "mathjs": "^9.5.1",
+        "mitt": "^3.0.0",
         "qrcode": "^1.4.4",
         "query-string": "^7.0.1",
         "register-service-worker": "^1.7.1",

+ 131 - 94
src/main.js

@@ -20,6 +20,8 @@ import VueClipboard from 'vue-clipboard2';
 import queryString from 'query-string';
 import PageBar from './components/PageBar';
 import eruda from 'eruda';
+import mitt from 'mitt';
+const emitter = mitt();
 
 let showConsole = localStorage.getItem('showConsole');
 if (showConsole && parseInt(showConsole) > new Date().getTime()) {
@@ -44,6 +46,7 @@ const app = createApp(App)
     .component('page-bar', PageBar)
     .use(store)
     .use(router);
+app.config.globalProperties.emitter = emitter;
 
 let query = queryString.parse(location.search);
 if (query.code) {
@@ -67,117 +70,151 @@ if (navigator.userAgent.includes('#cordova#')) {
     document.addEventListener(
         'deviceready',
         function () {
-            window.$vm = app.mount('#app');
-            StatusBar.overlaysWebView(false);
-            StatusBar.hide();
-            setTimeout(() => {
-                navigator.splashscreen.hide();
-                StatusBar.show();
-                StatusBar.backgroundColorByHexString('#F5F7FA');
-                StatusBar.styleDefault();
-            }, 2000);
+            new Promise((resolve, reject) => {
+                if (navigator.appInfo) {
+                    http.http.get(`/appVersion/checkIosReview?version=${navigator.appInfo.version}`).then(res => {
+                        store.commit('setReview', res.review);
+                        if (res.review) {
+                            if (location.host !== 'test.raex.vip') {
+                                location.href = 'https://test.raex.vip';
+                                return;
+                            }
+                        }
+                        resolve();
+                    });
+                } else {
+                    resolve();
+                }
+            }).then(() => {
+                window.$vm = app.mount('#app');
+                StatusBar.overlaysWebView(false);
+                StatusBar.hide();
+                setTimeout(() => {
+                    navigator.splashscreen.hide();
+                    StatusBar.show();
+                    StatusBar.backgroundColorByHexString('#F5F7FA');
+                    StatusBar.styleDefault();
+                }, 2000);
 
-            if (/iphone|ipad|ipod/i.test(navigator.userAgent)) {
-                style.setProperty('--safe-top', 'env(safe-area-inset-top)');
-                style.setProperty('--safe-bottom', 'env(safe-area-inset-bottom)');
-                style.setProperty('--safe-left', 'env(safe-area-inset-left)');
-                style.setProperty('--safe-right', 'env(safe-area-inset-right)');
-            } else {
-                if (window.AndroidNotch) {
-                    window.AndroidNotch.getInsetTop(
-                        px => {
-                            style.setProperty('--safe-top', px + 'px');
-                        },
-                        err => console.error('Failed to get insets top:', err)
-                    );
+                if (/iphone|ipad|ipod/i.test(navigator.userAgent)) {
+                    style.setProperty('--safe-top', 'env(safe-area-inset-top)');
+                    style.setProperty('--safe-bottom', 'env(safe-area-inset-bottom)');
+                    style.setProperty('--safe-left', 'env(safe-area-inset-left)');
+                    style.setProperty('--safe-right', 'env(safe-area-inset-right)');
+                } else {
+                    if (window.AndroidNotch) {
+                        window.AndroidNotch.getInsetTop(
+                            px => {
+                                style.setProperty('--safe-top', px + 'px');
+                            },
+                            err => console.error('Failed to get insets top:', err)
+                        );
 
-                    window.AndroidNotch.getInsetRight(
-                        px => {
-                            style.setProperty('--safe-right', px + 'px');
-                        },
-                        err => console.error('Failed to get insets right:', err)
-                    );
+                        window.AndroidNotch.getInsetRight(
+                            px => {
+                                style.setProperty('--safe-right', px + 'px');
+                            },
+                            err => console.error('Failed to get insets right:', err)
+                        );
 
-                    window.AndroidNotch.getInsetBottom(
-                        px => {
-                            style.setProperty('--safe-bottom', px + 'px');
-                        },
-                        err => console.error('Failed to get insets bottom:', err)
-                    );
+                        window.AndroidNotch.getInsetBottom(
+                            px => {
+                                style.setProperty('--safe-bottom', px + 'px');
+                            },
+                            err => console.error('Failed to get insets bottom:', err)
+                        );
 
-                    window.AndroidNotch.getInsetLeft(
-                        px => {
-                            style.setProperty('--safe-left', px + 'px');
-                        },
-                        err => console.error('Failed to get insets left:', err)
-                    );
+                        window.AndroidNotch.getInsetLeft(
+                            px => {
+                                style.setProperty('--safe-left', px + 'px');
+                            },
+                            err => console.error('Failed to get insets left:', err)
+                        );
+                    }
                 }
-            }
 
-            let t = 0;
-            document.addEventListener(
-                'backbutton',
-                e => {
-                    if (window.$vm.$route.matched.find(i => i.name === 'index')) {
-                        e.preventDefault();
-                        let t1 = new Date().getTime();
-                        console.log(t1 - t);
-                        if (t1 - t < 1000) {
-                            navigator.app.exitApp();
+                let t = 0;
+                document.addEventListener(
+                    'backbutton',
+                    e => {
+                        if (window.$vm.$route.matched.find(i => i.name === 'index')) {
+                            e.preventDefault();
+                            let t1 = new Date().getTime();
+                            console.log(t1 - t);
+                            if (t1 - t < 1000) {
+                                navigator.app.exitApp();
+                            } else {
+                                t = t1;
+                                window.$vm.$toast('再按一次退出');
+                            }
                         } else {
-                            t = t1;
-                            window.$vm.$toast('再按一次退出');
+                            window.$vm.$router.go(-1);
                         }
-                    } else {
-                        window.$vm.$router.go(-1);
-                    }
-                },
-                false
-            );
+                    },
+                    false
+                );
 
-            if (!(location.host === 'www.raex.vip' || location.host === 'test.raex.vip')) {
-                if (!/iphone|ipad|ipod/i.test(navigator.userAgent)) {
-                    window.$vm.$dialog
-                        .alert({
+                if (
+                    !(
+                        location.host === 'www.raex.vip' ||
+                        location.host === 'test.raex.vip' ||
+                        /^http:\/\/192\.168\.\d{1,3}\.\d{1,3}((:\d+)?)$/.test(location.host)
+                    )
+                ) {
+                    if (!/iphone|ipad|ipod/i.test(navigator.userAgent)) {
+                        window.$vm.$dialog.alert({
                             message: '检测到新版本,请下载更新',
+                            confirmButtonText: '下载更新',
                             beforeClose(action, done) {
-                                if (action === 'confirm') {
-                                    setTimeout(done, 1000);
+                                console.log(action);
+                                if (/iphone|ipad|ipod/.test(navigator.userAgent)) {
+                                    //location.href = 'https://apps.apple.com/cn/app/id1598469798';
                                 } else {
-                                    done();
+                                    location.href = 'http://download.raex.vip';
                                 }
                             }
-                        })
-                        .then(() => {
-                            if (/iphone|ipad|ipod/.test(navigator.userAgent)) {
-                                //location.href = 'https://apps.apple.com/cn/app/id1598469798';
-                            } else {
-                                location.href = 'http://download.raex.vip';
-                            }
                         });
+                    }
                 }
-            }
 
-            if (
-                !(
-                    location.host === 'www.raex.vip' ||
-                    location.host === 'test.raex.vip' ||
-                    /^http:\/\/192\.168\.\d{1,3}\.\d{1,3}((:\d+)?)$/.test(location.host)
-                )
-            ) {
-                window.$vm.$dialog.alert({
-                    message: '检测到新版本,请下载更新',
-                    confirmButtonText: '下载更新',
-                    beforeClose(action, done) {
-                        console.log(action);
-                        if (/iphone|ipad|ipod/.test(navigator.userAgent)) {
-                            //location.href = 'https://apps.apple.com/cn/app/id1598469798';
-                        } else {
-                            location.href = 'http://download.raex.vip';
-                        }
-                    }
-                });
-            }
+                if (window.store && /iphone|ipad|ipod/i.test(navigator.userAgent)) {
+                    window.store.register({
+                        id: '358',
+                        alias: 'my_consumable1',
+                        type: window.store.CONSUMABLE
+                    });
+
+                    window.store.error(function (error) {
+                        console.log('ERROR ' + error.code + ': ' + error.message);
+                    });
+                    window.store
+                        .when('358')
+                        .updated(product => {
+                            console.log(product, 'updated');
+                            emitter.emit('iapEvent', { event: 'updated', product });
+                        })
+                        .requested(product => {
+                            emitter.emit('iapEvent', { event: 'requested', product });
+                        })
+                        .initiated(product => {
+                            emitter.emit('iapEvent', { event: 'initiated', product });
+                        })
+                        .cancelled(product => {
+                            emitter.emit('iapEvent', { event: 'cancelled', product });
+                        })
+                        .approved(product => {
+                            emitter.emit('iapEvent', { event: 'approved', product });
+                            window.store.get('358').finish();
+                        })
+                        .verified(product => {
+                            emitter.emit('iapEvent', { event: 'verified', product });
+                        })
+                        .finished(product => {
+                            emitter.emit('iapEvent', { event: 'finished', product });
+                        });
+                    window.store.refresh();
+                }
+            });
         },
         false
     );

+ 5 - 1
src/store/index.js

@@ -7,7 +7,8 @@ export default createStore({
         userInfo: null,
         firstUrl: '',
         couponInfo: null,
-        invitor: null
+        invitor: null,
+        review: false
     },
     mutations: {
         setFinished(state, finished) {
@@ -24,6 +25,9 @@ export default createStore({
         },
         setInvitor(state, invitor) {
             state.invitor = invitor;
+        },
+        setReview(state, review) {
+            state.review = review;
         }
     },
     actions: {

+ 2 - 2
src/views/Discover.vue

@@ -17,7 +17,7 @@
             </swiper-slide>
         </swiper>
 
-        <van-grid :border="false" column-num="5">
+        <van-grid :border="false" :column-num="$store.state.review ? 4 : 5">
             <van-grid-item text="精选推荐" :to="{ path: '/productList' }">
                 <template v-slot:icon>
                     <img class="grid-img" src="@assets/info_icon_jingxuanxilie.png" />
@@ -33,7 +33,7 @@
                     <img class="grid-img" src="@assets/info_icon_zhuzaozhe.png" />
                 </template>
             </van-grid-item>
-            <van-grid-item text="拍卖系列" @click="wait">
+            <van-grid-item text="拍卖系列" @click="wait" v-if="!$store.state.review">
                 <template v-slot:icon>
                     <img class="grid-img" src="@assets/info_icon_paimaixilie.png" />
                 </template>

+ 2 - 2
src/views/Mine.vue

@@ -120,7 +120,7 @@
                     <van-icon :name="require('@assets/icon_yinhangka.png')" class="search-icon" />
                 </template>
             </van-grid-item>
-            <van-grid-item text="我的积分" @click="wait">
+            <van-grid-item text="我的积分" @click="wait" v-if="!$store.state.review">
                 <template #icon>
                     <van-icon :name="require('@assets/icon-jifen.png')" class="search-icon" />
                 </template>
@@ -130,7 +130,7 @@
                     <van-icon :name="require('@assets/icon-dianzan1.png')" class="search-icon" />
                 </template>
             </van-grid-item>
-            <van-grid-item text="地址管理" @click="wait">
+            <van-grid-item text="地址管理" @click="wait" v-if="!$store.state.review">
                 <template #icon>
                     <van-icon :name="require('@assets/icon_dizhi.png')" class="search-icon" />
                 </template>

+ 35 - 4
src/views/Submit.vue

@@ -30,7 +30,7 @@
 
                 <!-- <van-field type="text" label="订单留言" placeholder="选填" v-model="message" /> -->
 
-                <div class="pay">
+                <div class="pay" v-if="iosPrice === 0">
                     <div class="pay-item" @click="payType = item.type" v-for="(item, index) in payInfos" :key="index">
                         <img :src="item.icon" alt="" />
                         <span>{{ item.name }}</span>
@@ -49,7 +49,7 @@
                         round
                         :color="`linear-gradient(135deg, ${$colors.prim} 0%, ${$colors.warn} 100%)`"
                         @click="submit"
-                        :disabled="orderId"
+                        :disabled="!!orderId"
                     >
                         立即支付
                     </van-button>
@@ -193,6 +193,10 @@ export default {
         }
 
         this.bottom = this.$refs.bottom;
+        this.emitter.on('iapEvent', this.iapEvent);
+    },
+    beforeUnmount() {
+        this.emitter.off('iapEvent', this.iapEvent);
     },
     methods: {
         getOrder(next = false) {
@@ -258,9 +262,12 @@ export default {
                     if (this.money) {
                         this.$toast.clear();
                         this.orderId = res.id;
-                        this.$router.replace('/submit?orderId=' + res.id);
+                        this.$router.replace({ query: { ...this.$route.query, orderId: res.id } });
                         this.$nextTick(() => {
-                            if (this.payType === 'ALIPAY') {
+                            if (this.$store.state.review) {
+                                window.store.order('358');
+                                this.getOrder(true);
+                            } else if (this.payType === 'ALIPAY') {
                                 if (this.inWeixin) {
                                     document.location.replace(
                                         resolveUrl(this.$baseUrl, '/payOrder/alipay_wx?id=' + res.id)
@@ -371,6 +378,30 @@ export default {
             if (!this.orderId) {
                 this.$router.push('/couponList?collectionId=' + this.info.id);
             }
+        },
+        iapEvent(e) {
+            console.log(e);
+            switch (e.event) {
+                case 'initiated':
+                    this.$toast.loading({
+                        duration: 0,
+                        forbidClick: true,
+                        message: '加载中'
+                    });
+                    break;
+                case 'finished':
+                    this.$toast.clear();
+                    this.$http.post('/notify/order/iap', {
+                        receiptData: e.product.transaction.appStoreReceipt,
+                        orderId: this.orderId
+                    });
+                    console.log(e.product.transaction.appStoreReceipt);
+                    break;
+                case 'cancelled':
+                    this.$toast.clear();
+                    this.orderId = null;
+                    break;
+            }
         }
     }
 };

+ 6 - 4
src/views/asset/Detail.vue

@@ -467,7 +467,7 @@ export default {
                 })
                 .then(() => {
                     if (dayjs().isSameOrBefore(dayjs(this.orderInfo.payTime).add(this.holdDays, 'days'))) {
-                        this.$toast(this.holdDays + '天才能寄售');
+                        this.$toast('持有满' + this.holdDays + '天才能寄售');
                     } else if (!this.info.consignment) {
                         Dialog.confirm({
                             title: '寄售上架',
@@ -493,9 +493,7 @@ export default {
                 });
         },
         Add() {
-            if (this.userInfo.authStatus === 'SUCCESS') {
-                this.$router.push('/giveSearch?id=' + this.info.id);
-            } else if (this.userInfo.authStatus === 'PENDING' || this.userInfo.authStatus === 'FAIL') {
+            if (this.userInfo.authStatus === 'PENDING' || this.userInfo.authStatus === 'FAIL') {
                 Dialog.confirm({
                     title: '认证信息',
                     message: '用户认证中,是否查看认证'
@@ -509,6 +507,10 @@ export default {
                 }).then(() => {
                     this.$router.push('/Authentication');
                 });
+            } else if (dayjs().isSameOrBefore(dayjs(this.orderInfo.payTime).add(this.holdDays, 'days'))) {
+                this.$toast('持有满' + this.holdDays + '天才能转赠');
+            } else if (this.userInfo.authStatus === 'SUCCESS') {
+                this.$router.push('/giveSearch?id=' + this.info.id);
             }
         },
         Exhibition() {

+ 5 - 0
yarn.lock

@@ -6068,6 +6068,11 @@ mississippi@^3.0.0:
     stream-each "^1.1.0"
     through2 "^2.0.0"
 
+mitt@^3.0.0:
+  version "3.0.0"
+  resolved "https://registry.nlark.com/mitt/download/mitt-3.0.0.tgz#69ef9bd5c80ff6f57473e8d89326d01c414be0bd"
+  integrity sha1-ae+b1cgP9vV0c+jYkybQHEFL4L0=
+
 mixin-deep@^1.2.0:
   version "1.3.2"
   resolved "https://registry.npmjs.org/mixin-deep/-/mixin-deep-1.3.2.tgz"