Baozhangchao 3 年之前
父節點
當前提交
a042d87685

二進制
src/assets/userImag/backImag.png 查看文件


二進制
src/assets/userImag/shoucang.png 查看文件


二進制
src/assets/userImag/user.png 查看文件


二進制
src/assets/userImag/userImag.jpg 查看文件


二進制
src/assets/userImag/userInfo.png 查看文件


二進制
src/assets/userImag/wenjuan.png 查看文件


+ 5
- 8
src/components/Course.vue 查看文件

@@ -2,8 +2,8 @@
2 2
   <div class="Course-box">
3 3
     <div>
4 4
       <van-swipe :autoplay="3000">
5
-        <van-swipe-item v-for="(image, index) in images" :key="index">
6
-          <van-image width="100%" height="25vh" :src="image" />
5
+        <van-swipe-item v-for="(image, index) in HomeBannerImages" :key="index">
6
+          <van-image width="100%" height="25vh" :src="image.thumb" />
7 7
         </van-swipe-item>
8 8
       </van-swipe>
9 9
     </div>
@@ -42,11 +42,7 @@ export default {
42 42
         { name: '课程阿斯好友和用户运营达四方' },
43 43
         { name: '毛概' }
44 44
       ],
45
-      images: [
46
-        'https://img.yzcdn.cn/vant/apple-1.jpg',
47
-        'https://img.yzcdn.cn/vant/apple-2.jpg',
48
-        'https://img.yzcdn.cn/vant/cat.jpeg'
49
-      ]
45
+      HomeBannerImages: []
50 46
     }
51 47
   },
52 48
   mounted() {
@@ -57,7 +53,8 @@ export default {
57 53
       this.$router.push('/ClockIn')
58 54
     },
59 55
     onBanner() {
60
-      getBanner({ position: 'Training' }).then((e) => {
56
+      getBanner('Training').then((e) => {
57
+        this.HomeBannerImages = e.records
61 58
         console.log(e)
62 59
       })
63 60
     }

+ 13
- 3
src/components/StrongPhoto.vue 查看文件

@@ -3,8 +3,8 @@
3 3
   <div class="Photo-box">
4 4
     <div>
5 5
       <van-swipe :autoplay="3000">
6
-        <van-swipe-item v-for="(image, index) in title.imageList" :key="index">
7
-          <van-image width="100%" height="25vh" :src="image.a" />
6
+        <van-swipe-item v-for="(image, index) in photoBannerImages" :key="index">
7
+          <van-image width="100%" height="25vh" :src="image.thumb" />
8 8
         </van-swipe-item>
9 9
       </van-swipe>
10 10
     </div>
@@ -44,6 +44,8 @@
44 44
 </template>
45 45
 
46 46
 <script>
47
+import { getBanner } from '../util/api'
48
+
47 49
 export default {
48 50
   data() {
49 51
     return {
@@ -60,6 +62,7 @@ export default {
60 62
         '四期2啊啊',
61 63
         '四期0啊啊'
62 64
       ],
65
+      photoBannerImages: [],
63 66
       title: {
64 67
         name: '2022年02月22日',
65 68
         imageList: [
@@ -74,6 +77,8 @@ export default {
74 77
     }
75 78
   },
76 79
   mounted() {
80
+    this.onBanner()
81
+
77 82
     if (this.buttList.length >= 5) {
78 83
       this.iconShow = true
79 84
     } else {
@@ -85,9 +90,14 @@ export default {
85 90
       this.classStyle = !this.classStyle
86 91
     },
87 92
     SeePhotos(i) {
88
-      console.log('🚀 ~ file: StrongPhoto.vue ~ line 64 ~ SeePhotos ~ i', i)
89 93
       this.activeNum = i
90 94
       // this.clickStyle = !this.clickStyle
95
+    },
96
+    onBanner() {
97
+      getBanner('Wonderful').then((e) => {
98
+        this.photoBannerImages = e.records
99
+        console.log(e)
100
+      })
91 101
     }
92 102
   }
93 103
 }

+ 11
- 68
src/components/UserCenter.vue 查看文件

@@ -2,13 +2,13 @@
2 2
   <div class="User-box">
3 3
     <!-- <h1>UserCenter 个人中心</h1> -->
4 4
     <div class="user-info">
5
-      <img src="../assets/userImag/user.png" />
5
+      <img src="../assets/userImag/userImag.jpg" />
6 6
       <div class="info-name">
7 7
         <div>
8
-          <span>旺旺旺</span>
8
+          <span>{{name}}</span>
9 9
         </div>
10 10
         <div>
11
-          <span>18888888888</span>
11
+          <span>{{phone}}</span>
12 12
         </div>
13 13
       </div>
14 14
       <van-icon name="arrow" @click="handLogin()" />
@@ -26,83 +26,26 @@
26 26
 </template>
27 27
 
28 28
 <script>
29
+// import {SetUser} from '../util/api'
29 30
 export default {
30 31
   data() {
31 32
     return {
32 33
       register: require('../assets/icon/register.svg'),
33
-      code: '' // 前端获取 code 传给后端调用相应接口
34
+      name: '',
35
+      phone: ''
34 36
     }
35 37
   },
36
-  created() {
37
-    // 从 window.location.href 中截取 code 并且赋值
38
-    if (window.location.href.indexOf('Code_state') !== -1) {
39
-      this.code = window.location.href.split('?')[1].split('=')[1].split('&')[0]
40
-      this.$store.commit('SET_USER_INFO', { code: this.code })
41
-    }
42
-
43
-    if (this.$store.state.user.code) {
44
-      // 存在 code 直接调用接口
45
-      this.handGetUserInfo(this.code)
46
-    }
38
+  mounted() {
39
+    this.name = this.$store.state.user.name
40
+    this.phone = this.$store.state.user.phone
47 41
   },
48 42
   methods: {
49 43
     handLogin() {
50 44
       this.$router.push('/SetUser')
51 45
       // this.$store.commit('SET_USER_INFO', { code: this.code })
52
-
53
-      // 重定向地址重定到当前页面,在路径获取 code
54
-      if (process.env.NODE_ENV === 'development') {
55
-        console.log(222)
56
-        return
57
-      }
58
-      /**
59
-       * 获取 code
60
-       * @returns
61
-       */
62
-      // function getCode() {
63
-      //   const matched = /[?&]*code=([^&]+)/.exec(location.search)
64
-      //   if (matched) {
65
-      //     return decodeURIComponent(matched[1])
66
-      //   }
67
-      // }
68
-
69
-      const hrefUrl = window.location.href
70
-
71
-      // const originCode = localStorage.getItem('wxcode')
72
-      // const queryCode = getCode()
73
-      // localStorage.setItem('wxcode', queryCode)
74
-      // const local = encodeURIComponent(location.origin + location.pathname)
75
-
76
-      if (this.code === '') {
77
-        window.location.href = `
78
-						https://open.weixin.qq.com/connect/oauth2/authorize
79
-						?appid=${this.$store.state.user.appid}
80
-						&redirect_uri=${encodeURIComponent(hrefUrl)}
81
-						&response_type=code
82
-						&scope=snsapi_userinfo
83
-						&state=Code_state#wechat_redirect
84
-					`
85
-      }
86 46
     },
87
-    handGetUserInfo(code) {
88
-      console.log(
89
-        '🚀 ~ file: UserCenter.vue ~ line 44 ~ handGetUserInfo ~ code',
90
-        code
91
-      )
92
-      // 调用后端接口,参数为 code
93
-      // wxLogin({
94
-      //   data: {
95
-      //     code: code
96
-      //   },
97
-      //   method: 'GET'
98
-      // }).then((res) => {
99
-      //   console.log(
100
-      //     '🚀 ~ file: UserCenter.vue ~ line 47 ~ handGetUserInfo ~ res',
101
-      //     res
102
-      //   )
103
-      //   // res => 登陆成功!
104
-      // })
105
-    }
47
+
48
+    handGetUserInfo() {}
106 49
   }
107 50
 }
108 51
 </script>

+ 186
- 6
src/components/userPages/SetUser.vue 查看文件

@@ -4,8 +4,8 @@
4 4
       <van-nav-bar title="修改个人信息" left-text="返回" left-arrow @click-left="onClickLeft" />
5 5
       <van-form @submit="onSubmit">
6 6
         <van-field
7
-          v-model="username"
8
-          name="username"
7
+          v-model="name"
8
+          name="name"
9 9
           label="姓名"
10 10
           placeholder="姓名"
11 11
           :rules="[{ required: true, message: '请填写姓名' }]"
@@ -19,6 +19,61 @@
19 19
           placeholder="手机号"
20 20
           :rules="[{ required: true, message: '请填写手机号码' }]"
21 21
         />
22
+        <van-field
23
+          readonly
24
+          clickable
25
+          name="sex"
26
+          :value="sex"
27
+          label="性别"
28
+          placeholder="点击选择性别"
29
+          @click="onClickPicker(1)"
30
+        />
31
+        <van-popup v-model="sexShowPicker" position="bottom">
32
+          <van-picker
33
+            show-toolbar
34
+            :columns="sexArry"
35
+            @confirm="onConfirmSex"
36
+            @cancel="sexShowPicker = false"
37
+          />
38
+        </van-popup>
39
+
40
+        <van-field
41
+          readonly
42
+          clickable
43
+          name="Semester"
44
+          :value="Semester"
45
+          label="学期"
46
+          placeholder="点击选择学期"
47
+          @click="onClickPicker(2)"
48
+        />
49
+        <van-popup v-model="SemesterShowPicker" position="bottom">
50
+          <van-picker
51
+            show-toolbar
52
+            value-key="name"
53
+            :columns="SemesterArry"
54
+            @confirm="onConfirmSemester"
55
+            @cancel="SemesterShowPicker = false"
56
+          />
57
+        </van-popup>
58
+
59
+        <van-field
60
+          readonly
61
+          clickable
62
+          name="Classs"
63
+          :value="Classs"
64
+          label="班级"
65
+          placeholder="点击选择班级"
66
+          @click="ClasssShowPicker = true"
67
+        />
68
+        <van-popup v-model="ClasssShowPicker" position="bottom">
69
+          <van-picker
70
+            show-toolbar
71
+            value-key="name"
72
+            :columns="ClasssArry"
73
+            @confirm="onConfirmClasss"
74
+            @cancel="onClickPicker(3)"
75
+          />
76
+        </van-popup>
22 77
         <div style="margin: 20px; margin-top:3em;">
23 78
           <van-button round block type="info" native-type="submit">提交</van-button>
24 79
         </div>
@@ -28,20 +83,145 @@
28 83
 </template>
29 84
 
30 85
 <script>
86
+import { mapState } from 'vuex'
87
+import { SetUser, getSchoolterm, getSchoolClass } from '../../util/api'
31 88
 export default {
32 89
   data() {
33 90
     return {
34
-      username: '',
35
-      phone: ''
91
+      name: '',
92
+      phone: '',
93
+      sexArry: ['男', '女'],
94
+      SemesterArry: [],
95
+      ClasssArry: [],
96
+      sexShowPicker: false,
97
+      SemesterShowPicker: false,
98
+      ClasssShowPicker: false,
99
+      sex: '',
100
+      sexNumber: null,
101
+      Semester: '',
102
+      Classs: '',
103
+      termId: '',
104
+      classId: ''
36 105
     }
37 106
   },
107
+  computed: {
108
+    ...mapState({
109
+      user: (state) => state.user
110
+    })
111
+  },
112
+  watch: {
113
+    user: {
114
+      handler(nw) {
115
+        if (nw) {
116
+          this.name = nw.name
117
+          this.phone = nw.phone
118
+          this.Classs = nw.Classs
119
+          this.Semester = nw.Semester
120
+          this.sex = nw.sex
121
+        }
122
+      },
123
+      immediate: true
124
+    }
125
+  },
126
+  mounted() {
127
+    this.getSemester()
128
+    // if (this.ClasssShowPicker) {
129
+    //   this.getClass()
130
+    // }
131
+  },
38 132
   methods: {
133
+    // 获取学期班级 star
134
+    getSemester() {
135
+      getSchoolterm({ pageSize: 999 }).then((e) => {
136
+        console.log('获取学期', e)
137
+        this.SemesterArry = e.records
138
+      })
139
+    },
140
+
141
+    getClass(termId) {
142
+      getSchoolClass(termId, { pageSize: 999 }).then((e) => {
143
+        console.log('获取班级', e)
144
+        this.ClasssArry = e.records
145
+      })
146
+    },
147
+    // 获取学期班级 end
39 148
     onClickLeft() {
40 149
       this.$router.go(-1)
41 150
     },
151
+    onConfirmSex(e) {
152
+      if (e == '男') {
153
+        this.sexNumber = 1
154
+        this.sex = e
155
+      } else {
156
+        this.sexNumber = 2
157
+
158
+        this.sex = e
159
+      }
160
+
161
+      this.sexShowPicker = false
162
+    },
163
+    //学期区------------------------
164
+
165
+    onConfirmSemester(e, x) {
166
+      const { name, termId } = e
167
+      this.Semester = name
168
+      this.getClass(termId)
169
+      this.termId = termId
170
+      console.log('🚀 ~值,下标 ', e, x)
171
+      this.SemesterShowPicker = false
172
+    },
173
+    //班级区------------------------
174
+    onConfirmClasss(e) {
175
+      const { name, classId } = e
176
+      this.Classs = name
177
+      this.classId = classId
178
+
179
+      this.ClasssShowPicker = false
180
+    },
181
+    // this.showPicker = false
182
+
183
+    onClickPicker(e) {
184
+      switch (e) {
185
+        case 1:
186
+          this.sexShowPicker = true
187
+
188
+          break
189
+        case 2:
190
+          this.SemesterShowPicker = true
191
+          this.Classs = ''
192
+
193
+          break
194
+        case 3:
195
+          this.ClasssShowPicker = true
196
+
197
+          break
198
+        default:
199
+          break
200
+      }
201
+    },
42 202
     onSubmit(values) {
43 203
       console.log('submit', values)
44
-      this.$toast.success('提示文案')
204
+
205
+      this.$toast.success('修改成功!')
206
+      SetUser(this.$store.state.user.personId, {
207
+        classId: this.classId,
208
+        name: this.name,
209
+        personId: this.$store.state.user.personId,
210
+        phone: this.phone,
211
+        sex: this.sexNumber,
212
+        termId: this.termId
213
+      }).then((e) => {
214
+        console.log(e)
215
+        this.$store.commit('SET_USER_INFO', { name: this.name })
216
+        this.$store.commit('SET_USER_INFO', { phone: values.phone })
217
+        this.$store.commit('SET_USER_INFO', { sexNumber: this.sexNumber })
218
+        this.$store.commit('SET_USER_INFO', { termId: this.termId })
219
+        this.$store.commit('SET_USER_INFO', { classId: this.classId })
220
+        this.$store.commit('SET_USER_INFO', { Classs: this.Classs })
221
+        this.$store.commit('SET_USER_INFO', { Semester: this.Semester })
222
+        this.$store.commit('SET_USER_INFO', { sex: this.sex })
223
+        this.$router.go(-1)
224
+      })
45 225
     }
46 226
   }
47 227
 }
@@ -63,7 +243,7 @@ export default {
63 243
     // border-bottom-right-radius: 20px;
64 244
     .van-form {
65 245
       position: relative;
66
-      top: 25vh;
246
+      top: 4vh;
67 247
       .van-field {
68 248
         margin-bottom: 2em;
69 249
         font-size: 17px;

+ 4
- 2
src/main.js 查看文件

@@ -19,8 +19,10 @@ import {
19 19
   Toast,
20 20
   Card,
21 21
   NavBar,
22
-  Image, SwipeItem, Tag, Swipe, Divider
22
+  Image, SwipeItem, Tag, Swipe, Divider, Picker, Popup
23 23
 } from 'vant';
24
+Vue.use(Popup);
25
+Vue.use(Picker);
24 26
 Vue.use(Divider);
25 27
 Vue.use(Swipe);
26 28
 Vue.use(Tag);
@@ -43,7 +45,7 @@ Vue.use(animated)
43 45
 
44 46
 // Vue.use(Tabbar);
45 47
 // Vue.use(TabbarItem);
46
-// Login()
48
+Login()
47 49
 
48 50
 Vue.config.productionTip = false
49 51
 

+ 11
- 3
src/store/index.js 查看文件

@@ -4,19 +4,27 @@ import Vuex from 'vuex'
4 4
 
5 5
 
6 6
 Vue.use(Vuex)
7
-
8 7
 const store = new Vuex.Store({
9 8
 
10 9
   // state 中存放的就是全局共享的数据
11 10
   state: {
12 11
     user: {
13
-
14 12
       appid: 'wxd3bab568bc42d1de',
15 13
       token: '',
16 14
       code: '123',
17
-
15
+      name: '用户',
16
+      phone: '',
17
+      personId: '',
18
+      classId: '',
19
+      sexNumber: null,
20
+      Semester: '',
21
+      sex: '',
22
+      termId: '',
23
+      Classs: ''
18 24
     }
19 25
   },
26
+
27
+
20 28
   // Mutation 用户变更Store数据
21 29
   mutations: {
22 30
     SET_USER_INFO (state, value) {

+ 31
- 1
src/util/api.js 查看文件

@@ -6,7 +6,7 @@ import request from "./request";
6 6
  *
7 7
  */
8 8
 //  /api/wx/login
9
-export const getBanner = (params, data,) => request(`/api/wx/banner`, data, 'GET')
9
+export const getBanner = (params, data,) => request(`/api/wx/banner?position=${params}`, data, 'GET')
10 10
 
11 11
 
12 12
 
@@ -19,3 +19,33 @@ export const getBanner = (params, data,) => request(`/api/wx/banner`, data, 'GET
19 19
 export const UserLogin = (code) => request(`/api/wx/login?code=${code}`, { method: 'post' })
20 20
 
21 21
 
22
+
23
+/**
24
+ * 修改个人信息
25
+ * @param 修改个人信息
26
+ * @returns 
27
+ * loginParam
28
+ */
29
+export const SetUser = (id, data) => request(`/api/wx/person/${id}`, { method: 'put', data })
30
+
31
+
32
+
33
+
34
+
35
+/**
36
+ * 获取学期
37
+ * @param 
38
+ * @returns 
39
+ * loginParam
40
+ */
41
+export const getSchoolterm = (id) => request(`/api/wx/school-term`, { method: 'get' })
42
+
43
+
44
+/**
45
+ * 获取班级
46
+ * @param 
47
+ * @returns 
48
+ * loginParam
49
+ */
50
+export const getSchoolClass = (params) => request(`/api/wx/school-class?termId=${params}`, { method: 'get' })
51
+

+ 66
- 4
src/util/initial.js 查看文件

@@ -1,13 +1,75 @@
1 1
 /**
2 2
  * 登陆
3 3
  */
4
+import Vue from 'vue'
5
+
6
+import Vuex from 'vuex'
7
+import store from '../store'
8
+
4 9
 import { UserLogin } from './api'
5 10
 
11
+
12
+// Vue.use(Vuex)
13
+
6 14
 export function Login () {
15
+  console.log(store);
16
+
7 17
   UserLogin('123',).then(e => {
8 18
     console.log(e);
9
-    console.log(22222222222222222222222);
10
-    let tokens = e.token
11
-    this.$store.commit('SET_USER_INFO', { token: tokens })
19
+    let userInfo = {
20
+      token: e.token,
21
+      name: e.person.name,
22
+      phone: e.person.phone,
23
+      personId: e.person.personId,
24
+
25
+
26
+    }
27
+    store.commit('SET_USER_INFO', userInfo)
12 28
   })
13
-}
29
+
30
+}
31
+
32
+// export function GetCode () {
33
+
34
+//   // 从 window.location.href 中截取 code 并且赋值
35
+//   if (window.location.href.indexOf('Code_state') !== -1) {
36
+//     this.code = window.location.href.split('?')[1].split('=')[1].split('&')[0]
37
+//     store.commit('SET_USER_INFO', { code: this.code })
38
+//   }
39
+
40
+//   if (this.$store.state.user.code) {
41
+//     // 存在 code 直接调用接口
42
+//     this.handGetUserInfo(this.code)
43
+//   }
44
+
45
+
46
+//   // 重定向地址重定到当前页面,在路径获取 code
47
+//   if (process.env.NODE_ENV === 'development') {
48
+//     console.log(222)
49
+//     return
50
+//   }
51
+//   /**
52
+//    * 获取 code
53
+//    * @returns
54
+//    */
55
+//   function getCode () {
56
+//     const matched = /[?&]*code=([^&]+)/.exec(location.search)
57
+//     if (matched) {
58
+//       return decodeURIComponent(matched[1])
59
+//     }
60
+//   }
61
+
62
+//   const hrefUrl = window.location.href
63
+
64
+
65
+//   if (this.code === '') {
66
+//     window.location.href = `
67
+// 						https://open.weixin.qq.com/connect/oauth2/authorize
68
+// 						?appid=${this.$store.state.user.appid}
69
+// 						&redirect_uri=${encodeURIComponent(hrefUrl)}
70
+// 						&response_type=code
71
+// 						&scope=snsapi_userinfo
72
+// 						&state=Code_state#wechat_redirect
73
+// 					`
74
+//   }
75
+// }

+ 48
- 28
src/util/request.js 查看文件

@@ -1,46 +1,66 @@
1
-import axios from "axios";
1
+
2
+
3
+
4
+import axios from 'axios'
5
+
2 6
 import store from '../store'
3 7
 
4
-// import { getQueryString } from ".";
5 8
 
6
-export default (url, options) => {
9
+
10
+
11
+export default function (url, options) {
7 12
   const { params, header, ...leftOptions } = options || {}
8
-  // const queryStr = getQueryString(params)
9
-  const { code, token } = store.state.user
10 13
 
11
-  const authToken = token
14
+  return new Promise((resolve, reject) => {
15
+    const { code, token } = store.state.user
12 16
 
13
-  const tokenHeader = authToken ? { 'X-Authorization-JWT': authToken } : {}
14 17
 
15
-  const nwHeader = {
16
-    ...(header || {}),
17
-    ...tokenHeader,
18
+    let header = {
19
+      'X-Authorization-JWT': token,
20
+    }
18 21
 
19
-  }
20 22
 
21
-  return new Promise((resolve, reject) => {
22 23
     axios.request({
23 24
       ...leftOptions,
24 25
       url: url,
25
-      header: nwHeader,
26
-      success: (res) => {
27
-        const { code, message, data, token } = res.data
28
-        if (token || data?.token) {
29
-          axios.setStorage({ key: 'token', data: token || data?.token })
30
-        }
31
-        if (code === 1000) {
32
-          resolve(data)
33
-        } else {
34
-          console.error(res)
35
-          reject(message?.indexOf('java') > -1 ? '系统内部错误' : message)
26
+      // header: header,
27
+      headers: header,
28
+    }).then(res => {
29
+      const { code, data, } = res.data
30
+
31
+      if (code === 1000) {
32
+        resolve(data)
33
+      } else {
34
+        // Message.error(message)
35
+
36
+        if (code === 1001) {
37
+          // Message.error('请重新登陆')
38
+
39
+          // routerfrom.push('../Login.vue')
40
+
41
+          // this.$router.replace('../Login.vue') //replace  不记录页面 ,无法返回
36 42
         }
37
-      },
38
-      fail: (err) => {
39
-        const message = err.message || err.errMsg || err
43
+      }
44
+
45
+
46
+
47
+    }).catch(err => {
48
+      const message = err.message || err.errMsg || err
49
+      console.error("🚀 错误~ err", err)
50
+      // Message.error('请求错误', err)
51
+
52
+
53
+
54
+
40 55
 
41
-        reject(message)
56
+      if (err.message.includes('timeout')) {
57
+        // 请求超时
58
+        // Message.error('请求超时')
42 59
       }
60
+      reject(message)
61
+    }).finally(() => {
62
+      // 请求结束
43 63
     })
44 64
   })
65
+}
45 66
 
46
-}