فهرست منبع

添加用户信息查询

asd123a20 3 سال پیش
والد
کامیت
c1a87a7367
1فایلهای تغییر یافته به همراه15 افزوده شده و 6 حذف شده
  1. 15 6
      src/views/user/userInfo.vue

+ 15 - 6
src/views/user/userInfo.vue

@@ -19,16 +19,23 @@ export default {
   },
   components: {},
   async created () {
-    const userinfo = sessionStorage.getItem('userinfo')
-    if (!userinfo) {
+    const openid = sessionStorage.getItem('openid')
+    if (!openid) {
       this.$router.push('/login/userInfo')
       return false
     }
-    this.info = JSON.parse(userinfo)
+    this.query()
   },
   computed: {},
   methods: {
-    ...mapActions(['userupdate']),
+    ...mapActions(['userupdate', 'userquery']),
+    async query () {
+      const openid = sessionStorage.getItem('openid')
+      const res = await this.userquery({ openid })
+      if (res.errcode === 0) {
+        this.info = res.data[0]
+      }
+    },
     clear () {
       this.info.name = null
     },
@@ -42,8 +49,10 @@ export default {
         return false
       }
       const res = await this.userupdate(this.info)
-      console.log(res)
-      if (res.errcode === 0 || !res.errcode) Toast.success('修改成功')
+      if (res.errcode === 0 || !res.errcode) {
+        Toast.success('修改成功')
+        this.query()
+      }
     }
   }
 }