whychdw
2019-07-05 7ab97c4ada45550abc7f440d60549b249726a9ff
src/views/login.vue
@@ -20,7 +20,7 @@
                        <Checkbox v-model="user.remember">记住密码</Checkbox>
                    </FormItem>
                    <FormItem style="text-align:right">
                        <Button type="primary" long @click="handleSubmit('user')">登陆</Button>
                        <Button type="primary" long @click="handleSubmit('user')">登录</Button>
                    </FormItem>
                </Form>
            </div>
@@ -46,12 +46,16 @@
            }
        }
    },
    created: function() {
        sessionStorage.removeItem('store');
    },
    methods: {
        handleSubmit(name) {
            this.$refs[name].validate((valid) => {
                if (valid) {
                    this.$store.commit('setLogin', true);
                    this.$store.commit('setUserName', this.user.name);
                    sessionStorage.setItem("store",JSON.stringify(this.$store.state))
                    this.$router.push('/index');
                } else {
                    this.$Message.error('登录失败!用户名/密码错误');