xuqiang-97 4 years ago
parent
commit
c91273a94a
7 changed files with 234 additions and 24 deletions
  1. 1 1
      project.config.json
  2. 7 1
      src/components/ReviewSuccess.vue
  3. 6 0
      src/main.js
  4. 52 2
      src/pages/mine.vue
  5. 90 13
      src/pages/store/apply.vue
  6. 56 6
      src/pages/store/review.vue
  7. 22 1
      src/store/index.js

+ 1 - 1
project.config.json

@@ -4,7 +4,7 @@
         "ignore": []
     },
     "setting": {
-        "urlCheck": true,
+        "urlCheck": false,
         "es6": true,
         "enhance": false,
         "postcss": true,

+ 7 - 1
src/components/ReviewSuccess.vue

@@ -12,7 +12,7 @@
                     在个人中心点击“<span>查看我的店铺</span>” 即可管理店铺商品及交易
                 </div>
 
-                <van-button :radius="8" class="go" type="primary">立即进入</van-button>
+                <van-button :radius="8" class="go" type="primary" @click="goStore">立即进入</van-button>
             </div>
 
             <van-button type="info" icon="cross" plaint round> </van-button>
@@ -26,6 +26,12 @@ export default {
         return {
             show: false
         };
+    },
+    methods: {
+        goStore() {
+            this.show = false;
+            this.navigateTo('/pages/store/homePage');
+        }
     }
 };
 </script>

+ 6 - 0
src/main.js

@@ -122,6 +122,12 @@ export default {
             'van-goods-action-icon': 'vant/goods-action-icon/index',
             'van-goods-action-button': 'vant/goods-action-button/index',
             'van-calendar': 'vant/calendar/index'
+        },
+        plugins: {
+            'live-player-plugin': {
+                version: '1.3.0', // 注意填写该直播组件最新版本号,微信开发者工具调试时可获取最新版本号(复制时请去掉注释)
+                provider: 'wx2b03c6e691cd7370' // 必须填该直播组件appid,该示例值即为直播组件appid(复制时请去掉注释)
+            }
         }
     }
 };

+ 52 - 2
src/pages/mine.vue

@@ -32,10 +32,21 @@
             </div>
 
             <van-image
+                v-if="userStoreInfo"
                 class="authentication"
                 width="100%"
+                fit="contain"
                 height="86"
                 src="https://ticket-exchange.oss-cn-hangzhou.aliyuncs.com/wechat/info_img_renzhengdianjia.png"
+                @click="navigateTo('/pages/store/homePage')"
+            />
+
+            <van-image
+                v-else
+                class="authentication"
+                width="100%"
+                height="86"
+                src="https://ticket-exchange.oss-cn-hangzhou.aliyuncs.com/wechat/info_img_renzhengdianjia1.png"
                 fit="contain"
             />
         </div>
@@ -86,7 +97,7 @@
             <van-button type="default" size="small">立即邀请</van-button>
         </div> -->
 
-        <review-success></review-success>
+        <review-success ref="reviewPass"></review-success>
     </div>
 </template>
 
@@ -97,7 +108,7 @@ export default {
     components: { ReviewSuccess },
     name: 'Mine',
     computed: {
-        ...mapState(['userInfo']),
+        ...mapState(['userInfo', 'userStoreInfo']),
         city() {
             if (this.userInfo) {
                 if (/[\u4e00-\u9fa5]/.test(this.userInfo.city)) {
@@ -129,7 +140,46 @@ export default {
                         });
                 }
             });
+        },
+        checkAuthen() {
+            return this.$http
+                .postJson('/storeAuthentication/all', {
+                    query: { userId: this.$store.state.userInfo.id, del: false }
+                })
+                .then(res => {
+                    if (res.empty) {
+                        return Promise.reject();
+                    } else {
+                        return Promise.resolve(res.content[0]);
+                    }
+                });
+        },
+        goAuth() {
+            this.checkAuthen()
+                .then(res => {
+                    this.navigateTo('/pages/store/apply');
+                })
+                .catch(() => {
+                    this.navigateTo('/pages/store/review');
+                });
+        },
+        loginMethods() {
+            this.$nextTick(() => {
+                if (this.isLogin) {
+                    var authStatus = wx.getStorageSync('authStatus');
+                    this.$store.dispatch('getUserStore').then(res => {
+                        console.log(authStatus);
+                        if (authStatus !== res.id + '_PASS') {
+                            this.$refs.reviewPass.show = true;
+                            wx.setStorageSync('authStatus', res.id + '_PASS');
+                        }
+                    });
+                }
+            });
         }
+    },
+    onShow() {
+        this.loginMethods();
     }
 };
 </script>

+ 90 - 13
src/pages/store/apply.vue

@@ -17,13 +17,13 @@
             <div class="text1">填写申请资料</div>
             <div class="text2">申请所填信息仅用于平台店家审核使用,决不做其他用途</div>
         </div>
-        <van-form :border="false">
+        <van-cell-group :border="false">
             <van-field
                 name="店家名称"
                 label="店家名称"
                 placeholder="请输入您店铺的名称"
                 :value="form.storeName"
-                :rules="[{ required: true, message: '请输入您店铺的名称' }]"
+                @input="form.storeName = $event.detail"
             />
             <van-field
                 type="phone"
@@ -31,7 +31,7 @@
                 label="手机号码"
                 placeholder="请输入您的手机号码"
                 :value="form.phone"
-                :rules="[{ required: true, message: '请输入您的手机号码' }]"
+                @input="form.phone = $event.detail"
             />
 
             <van-field
@@ -39,28 +39,28 @@
                 label="电子邮箱"
                 placeholder="请输入邮箱"
                 :value="form.email"
-                :rules="[{ required: true, message: '请输入邮箱' }]"
+                @input="form.email = $event.detail"
             />
             <van-field
                 type="text"
                 label="身份证号"
                 placeholder="请输入18位身份证号"
-                :value="form.id"
-                :rules="[{ required: true, message: '请输入18位身份证号' }]"
+                :value="form.idNo"
+                @input="form.idNo = $event.detail"
             />
 
             <van-cell title="身份证照片(正面照)">
-                <img-uploader v-model="form.idImg"></img-uploader>
+                <img-uploader ref="idNoImage" v-model="form.idNoImage"></img-uploader>
             </van-cell>
 
             <van-cell title="营业执照" :border="false">
-                <img-uploader v-model="form.icImg"></img-uploader>
+                <img-uploader ref="licenseImage" v-model="form.licenseImage"></img-uploader>
             </van-cell>
 
             <div class="btn">
-                <van-button block type="primary" native-type="submit">提交审核</van-button>
+                <van-button block type="primary" :disabled="!next" @click="submit">提交审核</van-button>
             </div>
-        </van-form>
+        </van-cell-group>
     </div>
 </template>
 
@@ -72,12 +72,89 @@ export default {
     data() {
         return {
             form: {
-                idImg: '',
-                icImg: ''
+                storeName: '',
+                phone: '',
+                email: '',
+                idNo: '',
+                idNoImage: '',
+                licenseImage: ''
             }
         };
     },
-    onPageScroll() {}
+    computed: {
+        next() {
+            return (
+                !!this.form.storeName &&
+                !!this.form.phone &&
+                !!this.form.email &&
+                !!this.form.idNo &&
+                !!this.form.idNoImage &&
+                !!this.form.licenseImage
+            );
+        }
+    },
+    onPageScroll() {},
+    methods: {
+        submit() {
+            if (!this.form.storeName) {
+                this.toast('请输入店家名称');
+                return;
+            }
+            if (!/^1[3~9]\d{9}$/.test(this.form.phone)) {
+                this.toast('请输入正确手机号');
+                return;
+            }
+
+            if (!/^(\w-*\.*)+@(\w-?)+(\.\w{2,})+$/.test(this.form.email)) {
+                this.toast('请输入正确邮箱');
+                return;
+            }
+
+            if (!/(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/.test(this.form.idNo)) {
+                this.toast('请输入正确身份证');
+                return;
+            }
+
+            if (!this.form.idNoImage) {
+                this.toast('请上传身份证照片(正面照)');
+                return;
+            }
+
+            if (!this.form.licenseImage) {
+                this.toast('请上传营业执照');
+                return;
+            }
+            let data = { ...this.form };
+            if (!data.id) {
+                data.userId = this.$store.state.userInfo.id;
+            }
+            data.status = 'CREATED';
+            this.showLoading();
+            this.$http.postJson('/storeAuthentication/save', data).then(res => {
+                this.toast('申请成功', 'success');
+
+                setTimeout(() => {
+                    wx.redirectTo({
+                        url: '/pages/store/review'
+                    });
+                }, 1500);
+            });
+        },
+        loginMethods() {
+            console.log('init');
+            this.$http
+                .postJson('/storeAuthentication/all', {
+                    query: { userId: this.$store.state.userInfo.id, del: false }
+                })
+                .then(res => {
+                    if (!res.empty) {
+                        this.form = res.content[0];
+                        this.$refs.idNoImage.setFile(res.content[0].idNoImage);
+                        this.$refs.licenseImage.setFile(res.content[0].licenseImage);
+                    }
+                });
+        }
+    }
 };
 </script>
 

+ 56 - 6
src/pages/store/review.vue

@@ -12,8 +12,15 @@
             <div class="text1">{{ title }}</div>
             <div class="text2">{{ desc }}</div>
 
-            <van-button type="primary" block>返回</van-button>
-            <van-button type="primary" plain block>取消申请</van-button>
+            <template v-if="status === 'CREATED'">
+                <van-button type="primary" block @click="navigateBack">返回</van-button>
+                <van-button type="primary" plain block @click="cancel">取消申请</van-button>
+            </template>
+
+            <template v-else>
+                <van-button type="primary" block @click="back">重新申请</van-button>
+                <van-button type="primary" plain block @click="navigateBack">返回</van-button>
+            </template>
         </div>
     </div>
 </template>
@@ -21,26 +28,69 @@
 <script>
 export default {
     data() {
-        return {};
+        return {
+            authentication: null
+        };
     },
     computed: {
+        status() {
+            return this.authentication ? this.authentication.status : '';
+        },
         img() {
             const imgs = [
                 'https://ticket-exchange.oss-cn-hangzhou.aliyuncs.com/wechat/kong_png_shenghezhong.png',
                 'https://ticket-exchange.oss-cn-hangzhou.aliyuncs.com/wechat/kong_png_shengheshibai.png'
             ];
-            return imgs[0];
+            return imgs[this.status === 'CREATED' ? 0 : 1];
         },
         title() {
             const list = ['资料审核中!', '资料审核失败'];
-            return list[0];
+            return list[this.status === 'CREATED' ? 0 : 1];
         },
         desc() {
             const list = [
                 '平台将于3日内完成资料审核,并将审核结果以短信的形式通知您',
                 '很遗憾,您的资料审核失败,请检查您填写的资料是否正确以及上传照片是否清晰'
             ];
-            return list[0];
+            return list[this.status === 'CREATED' ? 0 : 1];
+        }
+    },
+    methods: {
+        loginMethods() {
+            this.$http
+                .postJson('/storeAuthentication/all', {
+                    query: { userId: this.$store.state.userInfo.id, del: false }
+                })
+                .then(res => {
+                    console.log(res);
+                    if (!res.empty) {
+                        this.authentication = res.content[0];
+                        if (res.content[0].status === 'PASS') {
+                            this.navigateBack();
+                        }
+                    }
+                });
+        },
+        cancel() {
+            wx.showModal({
+                content: '确定要取消申请吗?',
+                confirmColor: this.$colors.prim,
+                success: res => {
+                    if (res.confirm) {
+                        this.$http.post('/storeAuthentication/del/' + this.authentication.id).then(res => {
+                            this.toast('取消成功', 'success');
+                            setTimeout(() => {
+                                this.navigateBack();
+                            }, 1500);
+                        });
+                    }
+                }
+            });
+        },
+        back() {
+            wx.redirectTo({
+                url: '/pages/store/apply'
+            });
         }
     }
 };

+ 22 - 1
src/store/index.js

@@ -10,7 +10,8 @@ export default new Vuex.Store({
         systemInfo: {
             statusBarHeight: 44
         },
-        userInfo: null
+        userInfo: null,
+        userStoreInfo: null
     },
     mutations: {
         setUserInfo(state, userInfo) {
@@ -21,6 +22,9 @@ export default new Vuex.Store({
         },
         setSystemInfo(state, systemInfo) {
             state.systemInfo = systemInfo;
+        },
+        setUserStoreInfo(state, userStoreInfo) {
+            state.userStoreInfo = userStoreInfo;
         }
     },
     actions: {
@@ -34,6 +38,23 @@ export default new Vuex.Store({
 
                 return Promise.resolve(res);
             });
+        },
+        getUserStore(context) {
+            return http.http
+                .postJson('/store/all', {
+                    query: {
+                        userId: context.state.userInfo.id
+                    }
+                })
+                .then(res => {
+                    if (res.empty) {
+                        context.commit('setUserStoreInfo', null);
+                        return Promise.reject();
+                    } else {
+                        context.commit('setUserStoreInfo', res.content[0]);
+                        return Promise.resolve(res.content[0]);
+                    }
+                });
         }
     }
 });