浏览代码

remove easy code

master
Kobus 5 年前
父节点
当前提交
e7d40da6cc

+ 5
- 1
src/components/timeshare/sell/sellPage.vue 查看文件

521
     DetailIndividual,
521
     DetailIndividual,
522
     Alert,
522
     Alert,
523
   },
523
   },
524
+  mounted() {
525
+    this.getIndividual(this.user.id);
526
+  },
524
   created() {
527
   created() {
525
-    console.log(46);
526
     this.initTimeshare(this.weekId);
528
     this.initTimeshare(this.weekId);
527
   },
529
   },
528
   computed: {
530
   computed: {
539
       'agencies',
541
       'agencies',
540
       'agents',
542
       'agents',
541
     ]),
543
     ]),
544
+    ...mapState('individual', ['item']),
542
     ...mapState('authentication', ['isLoggedIn']),
545
     ...mapState('authentication', ['isLoggedIn']),
543
     ...mapGetters({
546
     ...mapGetters({
544
       user: 'authentication/getUser',
547
       user: 'authentication/getUser',
570
     },
573
     },
571
   },
574
   },
572
   methods: {
575
   methods: {
576
+    ...mapActions('individual', ['getIndividual']),
573
     submitSale() {
577
     submitSale() {
574
       if (this.isLoggedIn) {
578
       if (this.isLoggedIn) {
575
         this.saveWeek(this.sellItem);
579
         this.saveWeek(this.sellItem);

+ 12
- 15
src/components/user/loginPage.vue 查看文件

107
   },
107
   },
108
   data() {
108
   data() {
109
     return {
109
     return {
110
+      username: '',
111
+      password: '',
110
       isPasswordShown: 'password',
112
       isPasswordShown: 'password',
111
       selectItems: [{ text: 'password', value: 0 }],
113
       selectItems: [{ text: 'password', value: 0 }],
112
       selectErrors: 'Some error with the field',
114
       selectErrors: 'Some error with the field',
119
     };
121
     };
120
   },
122
   },
121
   computed: {
123
   computed: {
122
-    ...mapState('authentication', ['token', 'status', 'username', 'password']),
124
+    ...mapState('authentication', ['token', 'status']),
123
   },
125
   },
124
   methods: {
126
   methods: {
125
     ...mapActions('authentication', ['login', 'init']),
127
     ...mapActions('authentication', ['login', 'init']),
129
       } else this.troubleToggle = true;
131
       } else this.troubleToggle = true;
130
     },
132
     },
131
     Login() {
133
     Login() {
132
-      console.log(this.$store.state.authentication);
133
-
134
-      this.login().then(() => {
135
-        console.log('this');
136
-        console.log(this);
137
-        console.log(this.$store.state.authentication.status);
138
-
139
-        if (this.$store.state.authentication.status === 'error') {
140
-          this.$router.push('/user/login');
141
-        } else {
142
-          console.log('yippy tequila');
143
-          this.$router.push('/about/us');
144
-        }
145
-      });
134
+      this.login({ username: this.username, password: this.password }).then(
135
+        () => {
136
+          if (this.$store.state.authentication.status === 'error') {
137
+            this.$router.push('/user/login');
138
+          } else {
139
+            this.$router.push('/about/us');
140
+          }
141
+        },
142
+      );
146
     },
143
     },
147
     togglePassword() {
144
     togglePassword() {
148
       this.showPassword = true;
145
       this.showPassword = true;

+ 3
- 6
src/store/modules/user/authentication.js 查看文件

7
 export default {
7
 export default {
8
   namespaced: true,
8
   namespaced: true,
9
   state: {
9
   state: {
10
-    username: 'kobusb',
11
-    password: '123123',
12
     isLoggedIn: log.isLoggedIn(),
10
     isLoggedIn: log.isLoggedIn(),
13
     flag: false,
11
     flag: false,
14
     status: undefined,
12
     status: undefined,
70
     },
68
     },
71
     login({
69
     login({
72
       commit,
70
       commit,
73
-      state,
74
-    }) {
71
+    }, user) {
75
       axios({
72
       axios({
76
         url: '/api/register/authenticate',
73
         url: '/api/register/authenticate',
77
         data: {
74
         data: {
78
-          username: state.username,
79
-          password: state.password,
75
+          username: user.username,
76
+          password: user.password,
80
         },
77
         },
81
         method: 'POST',
78
         method: 'POST',
82
       })
79
       })

+ 7
- 1
src/store/modules/user/individual.js 查看文件

20
   actions: {
20
   actions: {
21
     getIndividual({
21
     getIndividual({
22
       commit,
22
       commit,
23
+      rootGetters,
23
     }, userId) {
24
     }, userId) {
25
+      let id = 0;
26
+      if (!userId || userId === 0) {
27
+        const rootItem = rootGetters['authentication/getUser'];
28
+        id = rootItem ? rootItem.id : 0;
29
+      } else id = userId;
24
       axios
30
       axios
25
-        .get(`/api/individual/getIndividual/${userId}`)
31
+        .get(`/api/individual/getIndividual/${id}`)
26
         .then(r => commit('setItem', {
32
         .then(r => commit('setItem', {
27
           name: 'item',
33
           name: 'item',
28
           value: r.data,
34
           value: r.data,

+ 1
- 1
vue.config.js 查看文件

2
   devServer: {
2
   devServer: {
3
     proxy: {
3
     proxy: {
4
       '/api': {
4
       '/api': {
5
-        target: 'http://192.168.6.188:5000',
5
+        target: 'http://localhost:57260',
6
         changeOrigin: true,
6
         changeOrigin: true,
7
       },
7
       },
8
       '/nph-srep': {
8
       '/nph-srep': {

正在加载...
取消
保存