张延森 3 年之前
父節點
當前提交
8abb7ea5ea
共有 3 個文件被更改,包括 134 次插入121 次删除
  1. 4
    0
      src/global_style.less
  2. 4
    1
      src/layout/index.vue
  3. 126
    120
      src/views/UserCenter.vue

+ 4
- 0
src/global_style.less 查看文件

@@ -3,6 +3,10 @@
3 3
   display: flex;
4 4
 }
5 5
 
6
+.flex-column {
7
+  flex-direction: column;
8
+}
9
+
6 10
 .flex-1 {
7 11
   flex: 1;
8 12
 }

+ 4
- 1
src/layout/index.vue 查看文件

@@ -61,5 +61,8 @@ export default {
61 61
   components: {}
62 62
 }
63 63
 </script>
64
-<style lang="scss" scoped>
64
+<style lang="less" scoped>
65
+.layout-container {
66
+  height: 100%;
67
+}
65 68
 </style>

+ 126
- 120
src/views/UserCenter.vue 查看文件

@@ -1,76 +1,77 @@
1 1
 <template>
2
-  <div class="User-box">
3
-    <!-- <h1>UserCenter 个人中心</h1> -->
4
-    <img class="User-box-backImage" src="../assets/userImag/backImag.png" />
5
-    <div class="user-info">
6
-      <img src="../assets/userImag/userImag.jpg" v-show="divShow" />
7
-      <div class="info-name" v-show="divShow">
8
-        <div>
9
-          <span>{{name}}</span>
2
+  <div class="User-box flex flex-column">
3
+    <div class="user-card flex-0">
4
+      <div class="profile flex" v-if="divShow">
5
+        <img class="flex-0" src="@/assets/userImag/userImag.jpg" />
6
+        <div class="info-name flex-1">
7
+          <div class="title">
8
+            {{person.name}}
9
+          </div>
10
+          <div class="subtitle">
11
+            {{person.phone}}
12
+          </div>
13
+          <div class="userInfo-button">一期架空线路工1班</div>
10 14
         </div>
11
-        <div>
12
-          <span style="font-weight: 100;">{{phone}}</span>
13
-        </div>
14
-        <div class="userInfo-button">一期架空线路工1班</div>
15 15
       </div>
16 16
 
17
-      <div v-show="buttonShow" class="userInfo-button-zhuce" @click="seeUserInfo()">注册</div>
17
+      <div v-else class="userInfo-button-zhuce" @click="seeUserInfo()">注册</div>
18 18
     </div>
19
-    <div class="button-box">
20
-      <div class="button-box-div" @click="seeUserInfo()">
21
-        <img src="../assets/userImag/userInfo.png" alt />
22
-        <div>我的信息</div>
23
-        <van-icon name="arrow" />
24
-      </div>
25
-      <div class="button-box-div" @click="goMyCollection">
26
-        <img src="../assets/userImag/shoucang.png" alt />
27
-        <div>我的收藏</div>
28
-        <van-icon name="arrow" />
29
-      </div>
30
-      <!-- <div class="button-box-div">
31
-        <img src="../assets/userImag/wenjuan.png" alt />
32
-        <div>我的问卷</div>
33
-        <van-icon name="arrow" />
34
-      </div>-->
19
+
20
+    <div class="menu-list flex-1">
21
+      <van-cell-group>
22
+        <van-cell
23
+          v-for="menu in menus"
24
+          :key="menu.title"
25
+          :icon="menu.icon"
26
+          :title="menu.title"
27
+          is-link
28
+          :to="menu.path"
29
+          title-class="menu-title"
30
+        />
31
+      </van-cell-group>
35 32
     </div>
33
+
36 34
   </div>
37 35
 </template>
38 36
 
39 37
 <script>
38
+import { mapState } from 'vuex'
40 39
 // import {SetUser} from '../util/api'
41 40
 export default {
42 41
   data() {
43 42
     return {
44
-      register: require('../assets/icon/register.svg'),
45
-      name: '',
46
-      phone: '',
47
-      divShow: false,
48
-      buttonShow: true
43
+      register: require('@/assets/icon/register.svg'),
44
+      buttonShow: true,
45
+      menus: [
46
+        {
47
+          icon: require('@/assets/userImag/userInfo.png'),
48
+          title: '我的信息',
49
+          path: '/SetUser',
50
+        },
51
+        {
52
+          icon: require('@/assets/userImag/shoucang.png'),
53
+          title: '我的收藏',
54
+          path: '/MyCollection',
55
+        },
56
+        {
57
+          icon: require('@/assets/userImag/wenjuan.png'),
58
+          title: '我的问卷',
59
+          path: '',
60
+        }
61
+      ]
49 62
     }
50 63
   },
51
-  mounted() {
52
-    this.name = this.$store.state.user.name
53
-    this.phone = this.$store.state.user.phone
54
-    if (this.$store.state.user.phone) {
55
-      this.divShow = true
56
-      this.buttonShow = false
57
-    } else {
58
-      this.divShow = false
59
-      this.buttonShow = true
64
+  computed: {
65
+    ...mapState({
66
+      person: s => s.user,
67
+    }),
68
+    divShow() {
69
+      return false; // !!this.person?.phone
60 70
     }
61 71
   },
72
+  mounted() {
73
+  },
62 74
   methods: {
63
-    seeUserInfo() {
64
-      this.$router.push('/SetUser')
65
-      // this.$store.commit('SET_USER_INFO', { code: this.code })
66
-    },
67
-    goMyCollection() {
68
-      this.$router.push('/MyCollection')
69
-
70
-      // this.$store.commit('SET_USER_INFO', { code: this.code })
71
-    },
72
-
73
-    handGetUserInfo() {}
74 75
   }
75 76
 }
76 77
 </script>
@@ -80,96 +81,101 @@ export default {
80 81
   width: 100%;
81 82
   height: 100%;
82 83
   background-color: #fff;
84
+  background-image: url('~@/assets/userImag/backImag.png');
85
+  background-size: 100%;
86
+  background-repeat: no-repeat;
83 87
 
84
-  &-backImage {
85
-    width: 100%;
86
-  }
87
-  .user-info {
88
-    margin-bottom: 10px;
88
+  .user-card {
89 89
     display: flex;
90
-    height: 20%;
91
-    padding-left: 24px;
90
+    align-items: center;
91
+    width: 100vw;
92
+    box-sizing: border-box;
93
+    padding: 2em;
92 94
     position: relative;
93
-    top: -25vh;
94
-    > img {
95
-      width: 70px;
96
-      height: 70px;
97
-      border-radius: 50%;
98
-      position: relative;
99
-      top: 5vh;
100
-      box-shadow: 0px 8px 38px 0px rgba(0, 0, 0, 0.2);
101
-    }
102
-    .info-name {
103
-      font-weight: 600;
104
-      top: 5vh;
105
-      left: 6vw;
106
-      position: relative;
107
-      font-size: 17px;
108
-      height: 20%;
109
-      > div {
110
-        margin-top: 10px;
111
-        color: #fff;
95
+    min-height: 136px;
96
+
97
+    .profile {
98
+      width: 100%;
99
+      
100
+      > img {
101
+        width: 70px;
102
+        height: 70px;
103
+        border-radius: 50%;
104
+        position: relative;
105
+        box-shadow: 0px 8px 38px 0px rgba(0, 0, 0, 0.2);
112 106
       }
113
-      .userInfo-button {
114
-        // border: 1px solid red;
115
-        width: 120px;
116
-        color: rgb(255, 255, 255);
117
-        font-weight: 100;
118
-        border-top-left-radius: 20px; /* 左上角 */
119
-        border-bottom-left-radius: 20px; /* 左下角 */
120
-        position: absolute;
121
-        padding: 8px 0;
122
-        right: -41vw;
123
-        top: 0vh;
124
-        font-size: 5px;
125
-        text-align: center;
126
-        background-color: #2cb698;
107
+      .info-name {
108
+        margin-left: 1em;
109
+        position: relative;
110
+
111
+        > div {
112
+          margin-top: 10px;
113
+          color: #fff;
114
+        }
115
+
116
+        .title {
117
+          font-size: 17px;
118
+          font-weight: 700;
119
+        }
120
+
121
+        .subtitle {
122
+          font-size: 16px;
123
+          letter-spacing: 1px;
124
+        }
125
+
126
+        .userInfo-button {
127
+          color: rgb(255, 255, 255);
128
+          font-weight: 100;
129
+          border-top-left-radius: 20px; /* 左上角 */
130
+          border-bottom-left-radius: 20px; /* 左下角 */
131
+          position: absolute;
132
+          padding: 8px 10px;
133
+          right: -3em;
134
+          top: 1em;
135
+          font-size: 10px;
136
+          letter-spacing: 1px;
137
+          background-color: #2cb698;
138
+        }
139
+
127 140
       }
141
+
128 142
     }
129 143
     .userInfo-button-zhuce {
130 144
       width: 80px;
131 145
       letter-spacing: 4px;
132
-      position: relative;
133
-      top: 5vh;
134
-      text-align: center;
135 146
       color: #fff;
136
-      font-weight: 700;
137
-      margin: 0 auto;
138 147
       border-radius: 20px;
139 148
       line-height: 30px;
140
-      height: 30px;
141 149
       background-color: #2cb798;
150
+      margin: 0 auto;
151
+      text-align: center;
142 152
     }
143 153
   }
144
-  .button-box {
154
+  .menu-list {
145 155
     width: 90%;
146 156
     border-radius: 20px;
147 157
     margin: 0 auto;
148
-    box-shadow: 0px 8px 38px 0px rgba(0, 0, 0, 0.12);
158
+    box-shadow: 0px 0 2px 2px rgba(0, 0, 0, 0.12);
149 159
     background-color: #fff;
160
+    overflow: hidden;
150 161
 
151
-    height: 80vh;
152 162
     position: relative;
153
-    top: -28vh;
154
-    display: flex;
155 163
 
156
-    flex-direction: column;
164
+    .menu-title {
165
+      margin-left: 1em;
166
+      font-size: 18px;
167
+    }
157 168
 
158
-    &-div {
159
-      display: flex;
160
-      margin: 20px auto;
169
+    .van-cell {
170
+      padding-top: 28px;
171
+      padding-bottom: 28px;
172
+    }
161 173
 
162
-      width: 80%;
163
-      padding-bottom: 30px;
164
-      align-items: center;
165
-      border-bottom: 1px solid rgb(235, 235, 235);
166
-      > img {
167
-        width: 22px;
168
-        margin-right: 2em;
169
-      }
170
-      .van-icon {
171
-        position: absolute;
172
-        right: 20px;
174
+    .van-icon {
175
+      font-size: 20px;
176
+      
177
+      & > img {
178
+        padding-top: 2px;
173 179
       }
174 180
     }
175 181
   }