Browse Source

许成祥

许成详 6 years ago
parent
commit
0d1a442f8c

+ 10
- 5
app.js View File

@@ -1,6 +1,6 @@
1 1
 //app.js
2
-const HttpSever = require('/utils/http.js')
3
-const $api = require('/config/api.js')
2
+const HttpSever = require('/utils/http.js').HttpSever
3
+const $api = require('/config/api.js').$api
4 4
 
5 5
 App({
6 6
   onLaunch: function() {
@@ -9,9 +9,14 @@ App({
9 9
       success(res) {
10 10
         if (res.code) {
11 11
           // 发起网络请求
12
-          // HttpSever.Ajax({
13
-          //   url: $api.User.GetUserInfo.url.replace(':openid', )
14
-          // })
12
+          HttpSever.Ajax({
13
+            url: $api.user.getCode.url + '?code=' + res.code,
14
+            method: $api.user.getCode.method
15
+          }).then((res) => {
16
+            if (res.code === 200) {
17
+              _self.globalData.OpenID = res.data.openid
18
+            }
19
+          })
15 20
         } else {
16 21
           console.log('登录失败!' + res.errMsg)
17 22
         }

+ 36
- 9
config/api.js View File

@@ -1,24 +1,51 @@
1 1
 // api基础域名
2 2
 const BaseAPIURl = require('./baseUrl.js').basePath.BASE_API_URL;
3 3
 const $api = {
4
-  User: {
5
-    Register: { // 用户注册
4
+  user: {
5
+    login: { // 模拟用户登陆
6 6
       methods: 'POST',
7
-      url: `${BaseAPIURl}/api/wx/registered`
7
+      url: `${BaseAPIURl}/wx/registered`
8 8
     },
9
-    GetUserInfo: { // 获取用户信息
9
+    info: {
10 10
       methods: 'GET',
11
-      url: `${BaseAPIURl}/api/wx/info/:openid`
11
+      url: `${BaseAPIURl}/wx/info/:appid`
12
+    },
13
+    getCode: {
14
+      methods: 'GET',
15
+      url: `${BaseAPIURl}/wx/getOpenid`
12 16
     }
13 17
   },
14
-  Project: {
15
-    GetProjectList: { // 获取项目列表
18
+  banner: {
19
+    list: {
20
+      methods: 'GET',
21
+      url: `${BaseAPIURl}/wx/banner`
22
+    }
23
+  },
24
+  building: {
25
+    list: {
26
+      methods: 'GET',
27
+      url: `${BaseAPIURl}/wx/building/list`
28
+    },
29
+  },
30
+  dynamic: { // 项目
31
+    list: { // 项目列表
32
+      methods: 'GET',
33
+      url: `${BaseAPIURl}/wx/buildingDynamiceList`
34
+    },
35
+    detail: { // 项目详情
16 36
       methods: 'GET',
17
-      url: `${BaseAPIURl}/api/wx/buildingDynamiceList`
37
+      url: `${BaseAPIURl}/wx/buildingDynamiceInfo/:id`
18 38
     }
19 39
   },
20 40
   activity: {
21
-    
41
+    list: { // 活动列表
42
+      methods: 'GET',
43
+      url: `${BaseAPIURl}/wx/activity`
44
+    },
45
+    detail: { // 活动详情
46
+      methods: 'GET',
47
+      url: `${BaseAPIURl}/wx/activity/:id`
48
+    }
22 49
   }
23 50
 }
24 51
 

+ 95
- 38
pages/ActivityDetail/index.js View File

@@ -1,15 +1,30 @@
1 1
 //index.js
2 2
 //获取应用实例
3 3
 const app = getApp()
4
+const HttpSever = require('../../utils/http.js').HttpSever
5
+const $api = require('../../config/api.js').$api
4 6
 
5 7
 Page({
6
-  onShow() {
7
-    wx.setNavigationBarTitle({
8
-      title: '活动详情'
8
+  onShow() {},
9
+  onLoad(e) {
10
+    this.setData({
11
+      Id: e.id,
12
+      Type: e.type - 0
9 13
     })
14
+    if (e.type - 0 === 1) {
15
+      wx.setNavigationBarTitle({
16
+        title: '项目详情'
17
+      })
18
+    } else {
19
+      wx.setNavigationBarTitle({
20
+        title: '活动详情'
21
+      })
22
+    }
10 23
   },
11 24
   data: {
12 25
     UserInfo: app.globalData.UserInfo,
26
+    Id: null,
27
+    Type: null,
13 28
     ShowPopup: false,
14 29
     FormData: {
15 30
       Name: '',
@@ -21,47 +36,54 @@ Page({
21 36
       Title: '示例标题',
22 37
       Publisher: '示例发布人',
23 38
       CreateDate: '2019-02-02',
24
-      Content: '',
25
-      CommentList: [{
26
-        FloorUserIcon: '/assets/images/img1.jpg',
27
-        FloorUserName: '楼主姓名',
28
-        CreateDate: '2019-02-02 22:05',
29
-        Content: '就看到杰卡斯大姐大就看到杰卡斯大姐大就看到杰卡斯大姐大就看到杰卡斯大姐大',
30
-        ImgList: ['/assets/images/img1.jpg', '/assets/images/img2.jpg', '/assets/images/img5.jpg'],
31
-        LikeNum: '0',
32
-        Childs: [{
33
-          Name: '回复人姓名',
34
-          CreateDate: '2019-02-02 22:07',
35
-          Content: 'us很大很大声',
36
-          LikeNum: '15',
37
-          ImgList: ['/assets/images/img1.jpg']
38
-        }, {
39
-          Name: '回复人姓名',
40
-          CreateDate: '2019-02-02 22:07',
41
-          Content: 'us很大很大声',
42
-          LikeNum: '15',
43
-          ImgList: []
44
-        }]
39
+      Content: ''
40
+    },
41
+    CommentList: [{
42
+      FloorUserIcon: '/assets/images/img1.jpg',
43
+      FloorUserName: '楼主姓名',
44
+      CreateDate: '2019-02-02 22:05',
45
+      Content: '就看到杰卡斯大姐大就看到杰卡斯大姐大就看到杰卡斯大姐大就看到杰卡斯大姐大',
46
+      ImgList: ['/assets/images/img1.jpg', '/assets/images/img2.jpg', '/assets/images/img5.jpg'],
47
+      LikeNum: '0',
48
+      Childs: [{
49
+        Name: '回复人姓名',
50
+        CreateDate: '2019-02-02 22:07',
51
+        Content: 'us很大很大声',
52
+        LikeNum: '15',
53
+        ImgList: ['/assets/images/img1.jpg']
45 54
       }, {
46
-        FloorUserIcon: '/assets/images/img1.jpg',
47
-        FloorUserName: '楼主姓名',
48
-        CreateDate: '2019-02-02 22:05',
49
-        Content: '就看到杰卡斯大姐大',
50
-        ImgList: [],
51
-        LikeNum: '0',
52
-        Childs: [{
53
-          Name: '回复人姓名',
54
-          CreateDate: '2019-02-02 22:07',
55
-          Content: 'us很大很大声',
56
-          LikeNum: '15',
57
-          ImgList: []
58
-        }]
55
+        Name: '回复人姓名',
56
+        CreateDate: '2019-02-02 22:07',
57
+        Content: 'us很大很大声',
58
+        LikeNum: '15',
59
+        ImgList: []
60
+      }]
61
+    }, {
62
+      FloorUserIcon: '/assets/images/img1.jpg',
63
+      FloorUserName: '楼主姓名',
64
+      CreateDate: '2019-02-02 22:05',
65
+      Content: '就看到杰卡斯大姐大',
66
+      ImgList: [],
67
+      LikeNum: '0',
68
+      Childs: [{
69
+        Name: '回复人姓名',
70
+        CreateDate: '2019-02-02 22:07',
71
+        Content: 'us很大很大声',
72
+        LikeNum: '15',
73
+        ImgList: []
59 74
       }]
75
+    }]
76
+  },
77
+  onReady() {
78
+    if (this.data.Type === 1) {
79
+      this.GetProjectDetail()
80
+    } else {
81
+      this.GetActivityDetail()
60 82
     }
61 83
   },
62 84
   AddComment() { // 添加评论
63 85
     wx.navigateTo({
64
-      url: '/pages/ActivityDetail/comment?id='
86
+      url: '/pages/ActivityDetail/comment?id=' + this.data.Id
65 87
     })
66 88
   },
67 89
   ShowSignUpPopup() { // 打开报名弹窗
@@ -94,5 +116,40 @@ Page({
94 116
       })
95 117
 
96 118
     }
119
+  },
120
+  GetActivityDetail() { // 获取活动详情
121
+    HttpSever.Ajax({
122
+      url: $api.activity.detail.url.replace(':id', this.data.Id),
123
+      method: $api.activity.detail.method
124
+    }).then((res) => {
125
+      if (res.code === 200) {
126
+        console.log(res.data)
127
+        this.setData({
128
+          ActivityDetail: {
129
+            Title: res.data.title,
130
+            Publisher: '江北公司',
131
+            CreateDate: res.data.activityDate,
132
+            Content: res.data.context
133
+          }
134
+        })
135
+      }
136
+    })
137
+  },
138
+  GetProjectDetail() { // 获取项目详情
139
+    HttpSever.Ajax({
140
+      url: $api.dynamic.detail.url.replace(':id', this.data.Id),
141
+      method: $api.dynamic.detail.method
142
+    }).then((res) => {
143
+      if (res.code === 200) {
144
+        this.setData({
145
+          ActivityDetail: {
146
+            Title: res.data.title,
147
+            Publisher: '发布人',
148
+            CreateDate: res.data.createDate,
149
+            Content: res.data.url
150
+          }
151
+        })
152
+      }
153
+    })
97 154
   }
98 155
 })

+ 4
- 3
pages/ActivityDetail/index.wxml View File

@@ -1,7 +1,8 @@
1 1
 <!--index.wxml-->
2 2
 <view class="container">
3 3
   <view class="container" style="z-index: 1;">
4
-    <view class="MainPage">
4
+    <web-view wx:if="{{Type === 1}}" src="{{ActivityDetail.Content}}"></web-view>
5
+    <view class="MainPage" wx:if="{{Type === 2}}">
5 6
 
6 7
       <!-- 文章主体 -->
7 8
       <view class="article">
@@ -25,7 +26,7 @@
25 26
 
26 27
         <!-- 评论列表 -->
27 28
         <view class="list">
28
-          <view class="flex-h" wx:for="{{ActivityDetail.CommentList}}" wx:for-item="item" wx:for-index="idx" wx:key="key">
29
+          <view class="flex-h" wx:for="{{CommentList}}" wx:for-item="item" wx:for-index="idx" wx:key="key">
29 30
 
30 31
             <!-- 头像 -->
31 32
             <view class="userIcon">
@@ -89,7 +90,7 @@
89 90
 
90 91
     </view>
91 92
   </view>
92
-  <view class="SignUp">
93
+  <view class="SignUp" hidden="{{Type !== 2}}">
93 94
     <view>
94 95
       <text bindtap="ShowSignUpPopup">我要报名</text>
95 96
     </view>

+ 68
- 83
pages/components/Concessions/index.js View File

@@ -17,98 +17,80 @@ Component({
17 17
       id: ''
18 18
     }],
19 19
     NavActiveIndex: 0,
20
-    ListA: [{
21
-      Title: '示例数据A',
22
-      CreateDate: '09-02-12',
23
-      Org: '悦见山',
24
-      Img: '/assets/images/img1.jpg',
25
-      Id: ''
26
-    }, {
27
-      Title: '示例数据A',
28
-      CreateDate: '09-02-12',
29
-      Org: '悦见山',
30
-      Img: '/assets/images/img1.jpg',
31
-      Id: ''
32
-    }, {
33
-      Title: '示例数据A',
34
-      CreateDate: '09-02-12',
35
-      Org: '悦见山',
36
-      Img: '/assets/images/img1.jpg',
37
-      Id: ''
38
-    }, {
39
-      Title: '示例数据A',
40
-      CreateDate: '09-02-12',
41
-      Org: '悦见山',
42
-      Img: '/assets/images/img1.jpg',
43
-      Id: ''
44
-    }, {
45
-      Title: '示例数据A',
46
-      CreateDate: '09-02-12',
47
-      Org: '悦见山',
48
-      Img: '/assets/images/img1.jpg',
49
-      Id: ''
50
-    }, {
51
-      Title: '示例数据A',
52
-      CreateDate: '09-02-12',
53
-      Org: '悦见山',
54
-      Img: '/assets/images/img1.jpg',
55
-      Id: ''
56
-    }],
57
-    ListB: [{
58
-      Title: '示例数据B',
59
-      CreateDate: '09-02-12',
60
-      Org: '悦见山',
61
-      Img: '/assets/images/img1.jpg',
62
-      Id: ''
63
-    }, {
64
-      Title: '示例数据B',
65
-      CreateDate: '09-02-12',
66
-      Org: '悦见山',
67
-      Img: '/assets/images/img1.jpg',
68
-      Id: ''
69
-    }, {
70
-      Title: '示例数据B',
71
-      CreateDate: '09-02-12',
72
-      Org: '悦见山',
73
-      Img: '/assets/images/img1.jpg',
74
-      Id: ''
75
-    }, {
76
-      Title: '示例数据B',
77
-      CreateDate: '09-02-12',
78
-      Org: '悦见山',
79
-      Img: '/assets/images/img1.jpg',
80
-      Id: ''
81
-    }, {
82
-      Title: '示例数据B',
83
-      CreateDate: '09-02-12',
84
-      Org: '悦见山',
85
-      Img: '/assets/images/img1.jpg',
86
-      Id: ''
87
-    }, {
88
-      Title: '示例数据B',
89
-      CreateDate: '09-02-12',
90
-      Org: '悦见山',
91
-      Img: '/assets/images/img1.jpg',
92
-      Id: ''
93
-    }],
94
-    PostData: {
20
+    ListA: [],
21
+    ListB: [],
22
+    PostDataA: {
23
+      PageNum: 1,
24
+      PageSize: 15
25
+    },
26
+    PostDataB: {
95 27
       PageNum: 1,
96 28
       PageSize: 15
97 29
     }
98 30
   },
99 31
   lifetimes: {},
100 32
   ready: function() {
101
-    HttpSever.Ajax({
102
-      url: $api.Project.GetProjectList.url + '?pageNum=' + this.data.PostData.PageNum + '&pageSize=' + this.data.PostData.PageSize,
103
-      method: $api.Project.GetProjectList.method
104
-    }).then((res) => {
105
-      console.log(res)
106
-    })
33
+    this.GetProjectList()
34
+    this.GetActivityList()
107 35
   },
108 36
   pageLifetimes: {
109 37
     show: function() {},
110 38
   },
111 39
   methods: {
40
+    GetActivityList() { // 获取活动列表
41
+      HttpSever.Ajax({
42
+        url: $api.activity.list.url + '?pageNum=' + this.data.PostDataB.PageNum + '&pageSize=' + this.data.PostDataB.PageSize,
43
+        method: $api.activity.list.method
44
+      }).then((res) => {
45
+        if (res.code === 200) {
46
+          let arr = res.data.records || []
47
+          let pArr = this.data.ListB
48
+          arr.map((item) => {
49
+            pArr.push({
50
+              Title: item.title,
51
+              CreateDate: item.activityDate,
52
+              Org: item.buildingName,
53
+              Img: item.imgUrl,
54
+              Id: item.activityId
55
+            })
56
+          })
57
+          this.setData({
58
+            ListB: pArr,
59
+            PostDataB: {
60
+              PageNum: res.data.total === this.data.ListB.length ? this.data.PostDataB.PageNum : this.data.PostDataB.PageNum + 1,
61
+              PageSize: this.data.PostDataB.PageSize
62
+            }
63
+          })
64
+        }
65
+      })
66
+    },
67
+    GetProjectList() { // 获取项目动态列表
68
+      HttpSever.Ajax({
69
+        url: $api.dynamic.list.url + '?pageNum=' + this.data.PostDataA.PageNum + '&pageSize=' + this.data.PostDataA.PageSize,
70
+        method: $api.dynamic.list.method
71
+      }).then((res) => {
72
+        if (res.code === 200) {
73
+          let arr = res.data.records || []
74
+          let pArr = this.data.ListA
75
+          arr.map((item) => {
76
+            pArr.push({
77
+              Title: item.title,
78
+              CreateDate: item.createDate,
79
+              Org: item.buildingName,
80
+              Img: item.imgUrl,
81
+              Id: item.dynamicId
82
+            })
83
+          })
84
+          this.setData({
85
+            ListA: pArr,
86
+            PostDataA: {
87
+              PageNum: res.data.total === this.data.ListA.length ? this.data.PostDataA.PageNum : this.data.PostDataA.PageNum + 1,
88
+              PageSize: this.data.PostDataA.PageSize
89
+            }
90
+          })
91
+        }
92
+      })
93
+    },
112 94
     CutNav(e) { // 切换nav
113 95
       if (e.target.dataset.index !== undefined) {
114 96
         this.setData({
@@ -116,8 +98,11 @@ Component({
116 98
         })
117 99
       }
118 100
     },
119
-    ItemClick() {
120
-      console.log(111)
101
+    ItemTap(e) {
102
+      // console.log(e.target.dataset)
103
+      wx.navigateTo({
104
+        url: '/pages/ActivityDetail/index?type=' + e.target.dataset.type + '&id=' + e.target.dataset.id
105
+      })
121 106
     }
122 107
   }
123 108
 })

+ 2
- 2
pages/components/Concessions/index.wxml View File

@@ -7,10 +7,10 @@
7 7
   </view>
8 8
   <view class="content">
9 9
     <view hidden="{{NavActiveIndex !== 0}}">
10
-      <ConcessionsListItem wx:for="{{ListA}}" wx:for-item="item" wx:for-index="index" wx:key="key" Params="{{item}}" />
10
+      <ConcessionsListItem wx:for="{{ListA}}" wx:for-item="item" wx:for-index="index" wx:key="key" Params="{{item}}" data-id="{{item.Id}}" data-type="1" bindtap="ItemTap" />
11 11
     </view>
12 12
     <view hidden="{{NavActiveIndex !== 1}}">
13
-      <ConcessionsListItem wx:for="{{ListB}}" wx:for-item="item" wx:for-index="index" wx:key="key" Params="{{item}}" />
13
+      <ConcessionsListItem wx:for="{{ListB}}" wx:for-item="item" wx:for-index="index" wx:key="key" Params="{{item}}" data-id="{{item.Id}}" data-type="2" bindtap="ItemTap" />
14 14
     </view>
15 15
   </view>
16 16
 </view>

+ 3
- 3
pages/components/ConcessionsListItem/index.js View File

@@ -14,9 +14,9 @@ Component({
14 14
   },
15 15
   methods: {
16 16
     TapItem() {
17
-      wx.navigateTo({
18
-        url: '/pages/ActivityDetail/index'
19
-      })
17
+      // wx.navigateTo({
18
+      //   url: '/pages/ActivityDetail/index'
19
+      // })
20 20
     }
21 21
   }
22 22
 })