소스 검색

列表渲染

xcx 4 년 전
부모
커밋
d2b19372fe

+ 1
- 1
project.config.json 파일 보기

@@ -27,7 +27,7 @@
27 27
 			"outputPath": ""
28 28
 		},
29 29
 		"useIsolateContext": true,
30
-		"useCompilerModule": false,
30
+		"useCompilerModule": true,
31 31
 		"userConfirmedUseCompilerModuleSwitch": false
32 32
 	},
33 33
 	"compileType": "miniprogram",

+ 2
- 1
src/app.config.js 파일 보기

@@ -1,5 +1,6 @@
1 1
 export default {
2 2
   pages: [
3
+
3 4
     'pages/HuiShengHuo/index', // 荟生活
4 5
     'pages/HuiShengHuo/ActivityList/index', // 荟生活-活动列表
5 6
     'pages/HuiShengHuo/ActivityList/ActivityDetail/index', // 荟生活-活动列表-活动详情
@@ -18,8 +19,8 @@ export default {
18 19
     'pages/HuiAiXin/EnergyStory/EnergyStoryDetail/index', // 荟爱心-正能量事迹-详情
19 20
 
20 21
     'pages/WoDe/index', // 我的
21
-    'pages/WoDe/MyActivityList/index', // 我的-活动列表
22 22
     'pages/WoDe/Feedback/index', // 我的-反馈
23
+    'pages/WoDe/MyActivityList/index', // 我的-活动列表
23 24
 
24 25
     'pages/SignIn/index' // 登录页
25 26
 

+ 117
- 0
src/components/GetUserIcon/index.vue 파일 보기

@@ -0,0 +1,117 @@
1
+<template>
2
+  <view class="GetUserIcon" v-show="Show">
3
+    <view class="centerLabel">
4
+      <image mode="widthFix" src="https://cjgw.oss-cn-hangzhou.aliyuncs.com/ygcxxfb/image/morentouxiang.png"></image>
5
+      <text>授权头像</text>
6
+      <button open-type="getUserInfo" @tap="ToGetUserIcon">授权头像</button>
7
+    </view>
8
+  </view>
9
+</template>
10
+
11
+<script>
12
+import { createNamespacedHelpers } from 'vuex'
13
+const { mapState: mapUserState, mapMutations: mapUserMutations } = createNamespacedHelpers('user')
14
+export default {
15
+  name: 'GetUserIcon',
16
+  data () {
17
+    return {
18
+      Show: false
19
+    }
20
+  },
21
+  computed: {
22
+    ...mapUserState({
23
+      UserInfo: x => x.UserInfo // 用户信息
24
+    })
25
+  },
26
+  created () {
27
+    this.Init() // 初始化
28
+  },
29
+  methods: {
30
+    ...mapUserMutations([
31
+      'EditUserInfo'
32
+    ]),
33
+    Init () { // 初始化
34
+      let _that = this
35
+      wx.getSetting({ // 校验用户是否已授权
36
+        success (res) {
37
+          if (res.authSetting['scope.userInfo']) { // 已授权时,获取用户信息
38
+            wx.authorize({
39
+              scope: 'scope.userInfo',
40
+              success () {
41
+                wx.getUserInfo({ // 授权成功时,获取用户信息
42
+                  success (res) {
43
+                    _that.EditUserInfo({ name: 'Icon', value: res.userInfo.avatarUrl })
44
+                    _that.EditUserInfo({ name: 'Name', value: res.userInfo.nickName })
45
+                  }
46
+                })
47
+              }
48
+            })
49
+          } else { // 未授权时,显示弹窗
50
+            _that.Show = true
51
+          }
52
+        }
53
+      })
54
+    },
55
+    ToGetUserIcon () { // 获取用户头像
56
+      let _that = this
57
+      wx.authorize({
58
+        scope: 'scope.userInfo',
59
+        success () {
60
+          wx.getUserInfo({ // 授权成功时,获取用户信息
61
+            success (res) {
62
+              _that.EditUserInfo({ name: 'Icon', value: res.userInfo.avatarUrl })
63
+              _that.EditUserInfo({ name: 'Name', value: res.userInfo.nickName })
64
+              _that.Show = false
65
+            }
66
+          })
67
+        }
68
+      })
69
+    }
70
+  }
71
+}
72
+</script>
73
+
74
+<style lang="scss">
75
+.GetUserIcon {
76
+  width: 100%;
77
+  position: fixed;
78
+  left: 0;
79
+  top: 0;
80
+  bottom: 0;
81
+  z-index: 100;
82
+  background: rgba(0, 0, 0, 0.6);
83
+  > view {
84
+    width: 60%;
85
+    padding: 20px 0 0;
86
+    background: #fff;
87
+    border-radius: 10px;
88
+    overflow: hidden;
89
+    > image {
90
+      width: 120px;
91
+      margin: 0 auto;
92
+      display: block;
93
+    }
94
+    > text {
95
+      font-size: 32px;
96
+      color: #07c160;
97
+      line-height: 80px;
98
+      display: block;
99
+      text-align: center;
100
+      border-top: 2px solid #f5f5f5;
101
+      margin-top: 40px;
102
+      &:active {
103
+        background: #f5f5f5;
104
+      }
105
+    }
106
+    > button {
107
+      width: 100%;
108
+      height: 80px;
109
+      opacity: 0;
110
+      display: block;
111
+      position: absolute;
112
+      left: 0;
113
+      bottom: 0;
114
+    }
115
+  }
116
+}
117
+</style>

+ 43
- 4
src/pages/SignIn/index.vue 파일 보기

@@ -2,12 +2,13 @@
2 2
   <view class="page DengLu">
3 3
     <image mode="widthFix" src="https://cjgw.oss-cn-hangzhou.aliyuncs.com/ygcxxfb/image/signinbg.png"></image>
4 4
     <view class="Btn flex-h">
5
-      <view class="flex-item"><text>取消登录</text></view>
5
+      <view class="flex-item"><text @tap="Back">取消登录</text></view>
6 6
       <view class="flex-item"><text>授权登录</text></view>
7
+      <button open-type="getPhoneNumber" v-if="Agree && UserInfo !== null && UserInfo.PersonId !== undefined" @getphonenumber="GetPhoneNumber">授权登录</button>
7 8
     </view>
8 9
     <view class="Agree flex-h">
9
-      <text class="iconfont icongouxuan"></text>
10
-      <text class="iconfont iconweigouxuan"></text>
10
+      <text class="iconfont icongouxuan" v-if="Agree" @tap="Agree = false"></text>
11
+      <text class="iconfont iconweigouxuan" v-else @tap="Agree = true"></text>
11 12
       <view class="flex-item">
12 13
         <text>我已认真阅读,理解并同意<text>《用户协议及隐私政策》</text></text>
13 14
       </view>
@@ -16,20 +17,58 @@
16 17
 </template>
17 18
 
18 19
 <script>
20
+import { createNamespacedHelpers } from 'vuex'
21
+const { mapState: mapUserState, mapMutations: mapUserMutations } = createNamespacedHelpers('user')
19 22
 export default {
20 23
   name: 'DengLu',
21 24
   data () {
22 25
     return {
23
-
26
+      DataLock: false,
27
+      Agree: false
24 28
     }
25 29
   },
30
+  computed: {
31
+    ...mapUserState({
32
+      UserInfo: x => x.UserInfo // 用户信息
33
+    })
34
+  },
26 35
   components: {
27 36
   },
28 37
   created () {
29 38
     this.Init()
30 39
   },
31 40
   methods: {
41
+    ...mapUserMutations([
42
+      'EditUserInfo'
43
+    ]),
32 44
     Init () {
45
+      this.ToLogin()
46
+    },
47
+    Back () {
48
+      wx.navigateBack({ changed: true })
49
+    },
50
+    ToLogin () {
51
+      let _that = this
52
+      wx.login({
53
+        success (res) {
54
+          wx.request({ // 获取用户信息
55
+            url: `https://dev.fangdeal.cn/liyuanhui/wx/login?code=${res.code}`,
56
+            method: 'post',
57
+            success: (res) => {
58
+              _that.EditUserInfo({ name: 'PersonId', value: res.data.data.person.personId })
59
+              _that.EditUserInfo({ name: 'OpenId', value: res.data.data.person.openId })
60
+            }
61
+          })
62
+        }
63
+      })
64
+    },
65
+    GetPhoneNumber (e) {
66
+      if (this.DataLock) return
67
+      this.DataLock = true
68
+      console.log(e)
69
+      console.log(e.detail.errMsg)
70
+      console.log(e.detail.iv)
71
+      console.log(e.detail.encryptedData)
33 72
     }
34 73
   }
35 74
 }

+ 13
- 1
src/pages/SignIn/page.scss 파일 보기

@@ -11,7 +11,9 @@
11 11
     margin-top: 40px;
12 12
     align-items: center;
13 13
     overflow: visible;
14
+    position: relative;
14 15
     > view {
16
+      position: relative;
15 17
       margin-left: 40px;
16 18
       overflow: visible;
17 19
       &:nth-child(1) {
@@ -35,6 +37,16 @@
35 37
         text-align: center;
36 38
       }
37 39
     }
40
+    > button {
41
+      width: 40%;
42
+      display: block;
43
+      position: absolute;
44
+      font-size: 28px;
45
+      line-height: 80px;
46
+      right: 76px;
47
+      top: 0;
48
+      opacity: 0;
49
+    }
38 50
   }
39 51
   > .Agree {
40 52
     padding: 0 76px;
@@ -52,7 +64,7 @@
52 64
         font-size: 24px;
53 65
         color: #333;
54 66
         line-height: 40px;
55
-        >text {
67
+        > text {
56 68
           display: inline-block;
57 69
           font-size: 24px;
58 70
           color: #333;

+ 31
- 10
src/pages/WoDe/index.vue 파일 보기

@@ -7,12 +7,13 @@
7 7
       <view class="centerLabel">
8 8
         <view class="flex-h">
9 9
           <view class="Icon">
10
-            <image mode="widthFix" src="https://cjgw.oss-cn-hangzhou.aliyuncs.com/ygcxxfb/image/morentouxiang.png"></image>
10
+            <image mode="widthFix" v-if="this.UserInfo === null || this.UserInfo.Icon === undefined || this.UserInfo.Icon === null" src="https://cjgw.oss-cn-hangzhou.aliyuncs.com/ygcxxfb/image/morentouxiang.png"></image>
11
+            <image mode="widthFix" v-else :src="this.UserInfo.Icon"></image>
11 12
           </view>
12 13
           <view class="flex-item">
13
-            <!-- <navigator url="../SignIn/index" hover-class="other-navigator-hover" class="SiginIn">立即登录</navigator> -->
14
-            <text>用户名</text>
15
-            <text>123456789</text>
14
+            <navigator url="../SignIn/index" hover-class="other-navigator-hover" class="SiginIn" v-if="UserInfo === null || UserInfo.Phone === undefined || UserInfo.Phone === null">立即登录</navigator>
15
+            <text v-else>{{UserInfo.Name}}</text>
16
+            <text v-else>{{UserInfo.Phone}}</text>
16 17
           </view>
17 18
         </view>
18 19
       </view>
@@ -21,36 +22,56 @@
21 22
     <!-- tab -->
22 23
     <view class="TabList">
23 24
       <navigator url="./MyActivityList/index" hover-class="other-navigator-hover" class="flex-h">
24
-        <view><image mode="heightFix" src="https://cjgw.oss-cn-hangzhou.aliyuncs.com/ygcxxfb/image/wodeicon1.png"></image></view>
25
+        <view>
26
+          <image mode="heightFix" src="https://cjgw.oss-cn-hangzhou.aliyuncs.com/ygcxxfb/image/wodeicon1.png"></image>
27
+        </view>
25 28
         <text class="flex-item">我的报名</text>
26 29
         <text class="iconfont iconjiantouright"></text>
27 30
       </navigator>
28 31
       <navigator url="./Feedback/index" hover-class="other-navigator-hover" class="flex-h">
29
-        <view><image mode="heightFix" src="https://cjgw.oss-cn-hangzhou.aliyuncs.com/ygcxxfb/image/wodeicon2.png"></image></view>
32
+        <view>
33
+          <image mode="heightFix" src="https://cjgw.oss-cn-hangzhou.aliyuncs.com/ygcxxfb/image/wodeicon2.png"></image>
34
+        </view>
30 35
         <text class="flex-item">意见反馈</text>
31 36
         <text class="iconfont iconjiantouright"></text>
32 37
       </navigator>
33 38
     </view>
34 39
 
40
+    <!-- 授权头像获取弹窗 -->
41
+    <GetUserIcon></GetUserIcon>
42
+
35 43
   </view>
36 44
 </template>
37 45
 
38 46
 <script>
39
-
47
+import GetUserIcon from '../../components/GetUserIcon/index'
48
+import { createNamespacedHelpers } from 'vuex'
49
+const { mapState: mapUserState, mapActions: mapUserActions, mapMutations: mapUserMutations } = createNamespacedHelpers('user')
40 50
 export default {
41 51
   name: 'WoDe',
42 52
   data () {
43 53
     return {
44
-
45 54
     }
46 55
   },
56
+  computed: {
57
+    ...mapUserState({
58
+      UserInfo: x => x.UserInfo // 用户信息
59
+    })
60
+  },
47 61
   components: {
62
+    GetUserIcon
48 63
   },
49 64
   created () {
50
-    this.Init()
65
+    this.Init() // 初始化
51 66
   },
52 67
   methods: {
53
-    Init () {
68
+    ...mapUserActions([
69
+      ''
70
+    ]),
71
+    ...mapUserMutations([
72
+      ''
73
+    ]),
74
+    Init () { // 初始化
54 75
     }
55 76
   }
56 77
 }

+ 9
- 0
src/pages/WoDe/page.scss 파일 보기

@@ -87,4 +87,13 @@
87 87
       }
88 88
     }
89 89
   }
90
+  > .GetUserIconPopup {
91
+    width: 100%;
92
+    position: fixed;
93
+    left: 0;
94
+    top: 0;
95
+    bottom: 0;
96
+    z-index: 100;
97
+    background: rgba(0, 0, 0, 0.5);
98
+  }
90 99
 }

+ 5
- 1
src/store/user/index.js 파일 보기

@@ -5,11 +5,15 @@ import ToolClass from '../../util/PublicMethod/index'
5 5
 export default {
6 6
   namespaced: true,
7 7
   state: {
8
-    UserPlaylist: [] // 用户片单
8
+    UserInfo: null // 用户信息
9 9
   },
10 10
   mutations: {
11 11
     UpdateUserPlaylist (state, data) {
12 12
       state.UserPlaylist = data || []
13
+    },
14
+    EditUserInfo (state, data) { // 编辑用户信息
15
+      state.UserInfo = state.UserInfo === null ? {} : state.UserInfo
16
+      state.UserInfo[data.name] = data.value
13 17
     }
14 18
   },
15 19
   actions: {

+ 10
- 10
src/util/Api/index.js 파일 보기

@@ -4,43 +4,43 @@ const prefix = process.env.NODE_ENV === 'production' ? '' : ''
4 4
 const Api = {
5 5
   GetIndexBanner: { // 获取首页banner
6 6
     method: 'get',
7
-    url: `${prefix}/pieceGroup/listGroup`
7
+    url: `${prefix}/news`
8 8
   },
9 9
   GetPhotoList: { // 获取照片墙列表
10 10
     method: 'get',
11
-    url: `${prefix}/pieceGroup/listGroup`
11
+    url: `${prefix}/news`
12 12
   },
13 13
   GetActivityList: { // 获取活动列表
14 14
     method: 'get',
15
-    url: `${prefix}/pieceGroup/listGroup`
15
+    url: `${prefix}/news`
16 16
   },
17 17
   GetHuiQuanYiBanner: { // 获取荟权益banner
18 18
     method: 'get',
19
-    url: `${prefix}/pieceGroup/listGroup`
19
+    url: `${prefix}/news`
20 20
   },
21 21
   GetYeZhuZiXunList: { // 获取业主资讯列表
22 22
     method: 'get',
23
-    url: `${prefix}/pieceGroup/listGroup`
23
+    url: `${prefix}/news`
24 24
   },
25 25
   GetHuiAiXinBanner: { // 获取荟爱心banner
26 26
     method: 'get',
27
-    url: `${prefix}/pieceGroup/listGroup`
27
+    url: `${prefix}/news`
28 28
   },
29 29
   GetMingXingYeZhuList: { // 获取明星业主列表
30 30
     method: 'get',
31
-    url: `${prefix}/pieceGroup/listGroup`
31
+    url: `${prefix}/news`
32 32
   },
33 33
   GetZhengNengLiangShiJiList: { // 获取正能量事迹列表
34 34
     method: 'get',
35
-    url: `${prefix}/pieceGroup/listGroup`
35
+    url: `${prefix}/news`
36 36
   },
37 37
   GetHuoDongNavList: { // 获取活动类型列表
38 38
     method: 'get',
39
-    url: `${prefix}/pieceGroup/listGroup`
39
+    url: `${prefix}/news`
40 40
   },
41 41
   GetUserActivityList: { // 获取我的活动列表
42 42
     method: 'get',
43
-    url: `${prefix}/pieceGroup/listGroup`
43
+    url: `${prefix}/news`
44 44
   }
45 45
 }
46 46
 

+ 19
- 2
src/util/PublicMethod/index.js 파일 보기

@@ -13,7 +13,6 @@ const ToolClass = {
13 13
   WxRequest (config) { // 网络请求
14 14
     let urlData = qs.stringify(config.urlData)
15 15
     let queryData = qs.stringify(config.queryData)
16
-    // 判断是通过斜杠传参
17 16
     if (config.url.indexOf(':') > -1) {
18 17
       if (typeof config.urlData === 'object') {
19 18
         config.url = this.ReplaceURLParams(config.url, config.urlData)
@@ -24,16 +23,34 @@ const ToolClass = {
24 23
     if (queryData) {
25 24
       config.url += '?' + queryData
26 25
     }
26
+    let Header = {}
27
+    if (wx.getStorageSync('token') !== '') { // 本地获取token
28
+      Header['X-Authorization-JWT'] = wx.getStorageSync('token')
29
+    }
27 30
     wx.request({
28
-      url: `http://121.40.96.72:91${config.url}`,
31
+      url: `https://dev.fangdeal.cn/liyuanhui/wx${config.url}`,
29 32
       method: config.method,
30 33
       ...(config.data || {}),
34
+      header: { ...Header },
31 35
       success: (res) => {
36
+        console.log(res)
37
+        if (res.header['X-Authorization-JWT'] !== undefined) { // 更新本地存储token
38
+          wx.setStorageSync('token', res.header['X-Authorization-JWT'])
39
+        }
40
+        if (res.data.code - 0 === 1001) { // token失效
41
+          wx.navigateTo({url: '../../SignIn/index'})
42
+        }
32 43
         if (config.success !== undefined) {
33 44
           config.success(res)
34 45
         }
35 46
       },
36 47
       fail: (res) => {
48
+        if (res.header['X-Authorization-JWT'] !== undefined) { // 更新本地存储token
49
+          wx.setStorageSync('token', res.header['X-Authorization-JWT'])
50
+        }
51
+        if (res.data.code - 0 === 1001) { // token失效
52
+          wx.navigateTo({url: '../../SignIn/index'})
53
+        }
37 54
         if (config.error !== undefined) {
38 55
           config.error(res)
39 56
         }