许成详 6 年 前
コミット
f207b4dddf

+ 17
- 6
pages/SelfServiceTool/Cyclopedia/Detail.js ファイルの表示

1
 //index.js
1
 //index.js
2
 //获取应用实例
2
 //获取应用实例
3
+import ArticleList from './article.js'
3
 const app = getApp()
4
 const app = getApp()
4
 
5
 
5
 Page({
6
 Page({
8
       title: '购房百科'
9
       title: '购房百科'
9
     })
10
     })
10
   },
11
   },
12
+  onLoad(e) {
13
+    let Detail = null
14
+    ArticleList.ArticleList.map((item) => {
15
+      if (item.Type - 0 === e.type - 0) {
16
+        item.List.map((subItem) => {
17
+          if (subItem.Id - 0 === e.id - 0) {
18
+            Detail = subItem
19
+          }
20
+        })
21
+      }
22
+    })
23
+    this.setData({
24
+      Detail: Detail
25
+    })
26
+  },
11
   data: {
27
   data: {
12
     UserInfo: app.globalData.UserInfo, // 用户信息
28
     UserInfo: app.globalData.UserInfo, // 用户信息
13
-    Detail: {
14
-      Title: '示例标题',
15
-      Publisher: '发布人',
16
-      CreateDate: '2019-02-02',
17
-      Content: ''
18
-    }
29
+    Detail: null
19
   }
30
   }
20
 })
31
 })

+ 6
- 1
pages/SelfServiceTool/Cyclopedia/Detail.wxml ファイルの表示

5
     <text class="flex-item">{{Detail.Publisher}}</text>
5
     <text class="flex-item">{{Detail.Publisher}}</text>
6
     <text>{{Detail.CreateDate}}</text>
6
     <text>{{Detail.CreateDate}}</text>
7
   </view>
7
   </view>
8
-  <rich-text class="content">{{Detail.Content}}</rich-text>
8
+  <view class="banner" style="padding: 0 40rpx;position:relative;overflow:hidden;margin: 40rpx auto 0;">
9
+    <image mode="widthFix" src="{{Detail.MainImg}}" style="width: 100%;"></image>
10
+  </view>
11
+  <view class="richText">
12
+    <rich-text class="content" nodes="{{Detail.Content}}"></rich-text>
13
+  </view>
9
 </view>
14
 </view>

+ 6
- 0
pages/SelfServiceTool/Cyclopedia/Detail.wxss ファイルの表示

27
 
27
 
28
 .subInfo text:first-child{
28
 .subInfo text:first-child{
29
   color: #bb9c79;
29
   color: #bb9c79;
30
+}
31
+
32
+.richText {
33
+  padding: 0 40rpx;
34
+  position: relative;
35
+  overflow: hidden;
30
 }
36
 }

+ 27
- 20
pages/SelfServiceTool/Cyclopedia/article.js ファイルの表示

1
+import ArticleContentList from './articleContent.js'
2
+
1
 const ArticleList = [{
3
 const ArticleList = [{
2
   Type: 1,
4
   Type: 1,
3
   List: [{
5
   List: [{
4
     Id: '1',
6
     Id: '1',
5
-    MainImg: '',
7
+    MainImg: 'https://whole-estate.oss-cn-beijing.aliyuncs.com/notebaike-1.jpg',
6
     Title: '如何选择靠谱的房地产开发商?',
8
     Title: '如何选择靠谱的房地产开发商?',
7
-    Content: '',
9
+    Remark: '居民购置房产时,从看房、选房、购房、交房到入住及后期管理维护,最经常打交道的就是开发商',
10
+    Content: ArticleContentList.ArticleContentList[0],
8
     Publisher: '银城江北公司',
11
     Publisher: '银城江北公司',
9
     CreateDate: '2019-03-28 14:05:02',
12
     CreateDate: '2019-03-28 14:05:02',
10
-    Banner: []
13
+    Type: 1
11
   }, {
14
   }, {
12
     Id: '2',
15
     Id: '2',
13
-    MainImg: '',
16
+    MainImg: 'https://whole-estate.oss-cn-beijing.aliyuncs.com/notebaike-2.jpg',
14
     Title: '何为土地使用年限&产权年限?',
17
     Title: '何为土地使用年限&产权年限?',
15
-    Content: '',
18
+    Remark: '对于大多数人来说,房子这最重要的财产可不容一点马虎!70年后,我们的房子还属于我们吗?到期后,我们又该做点啥?',
19
+    Content: ArticleContentList.ArticleContentList[1],
16
     Publisher: '银城江北公司',
20
     Publisher: '银城江北公司',
17
     CreateDate: '2019-03-28 14:05:02',
21
     CreateDate: '2019-03-28 14:05:02',
18
-    Banner: []
22
+    Type: 1
19
   }]
23
   }]
20
 }, {
24
 }, {
21
   Type: 2,
25
   Type: 2,
22
   List: [{
26
   List: [{
23
     Id: '3',
27
     Id: '3',
24
-    MainImg: '',
28
+    MainImg: 'https://whole-estate.oss-cn-beijing.aliyuncs.com/notebaike-3.jpg',
25
     Title: '到底地段重要还是户型重要呢?',
29
     Title: '到底地段重要还是户型重要呢?',
26
-    Content: '',
30
+    Remark: '每位购房者在选房时都会考虑很多因素。其中常常让很多人纠结的一个问题就是:到底地段重要还是户型重要呢?',
31
+    Content: ArticleContentList.ArticleContentList[2],
27
     Publisher: '银城江北公司',
32
     Publisher: '银城江北公司',
28
     CreateDate: '2019-03-28 14:05:02',
33
     CreateDate: '2019-03-28 14:05:02',
29
-    Banner: []
34
+    Type: 2
30
   }, {
35
   }, {
31
     Id: '4',
36
     Id: '4',
32
-    MainImg: '',
37
+    MainImg: 'https://whole-estate.oss-cn-beijing.aliyuncs.com/notebaike-4.jpg',
33
     Title: '买房是应该买精装房还是毛坯房?',
38
     Title: '买房是应该买精装房还是毛坯房?',
34
-    Content: '',
39
+    Remark: '购买精装房还是毛坯房,哪个更划算呢?很多人在面临这个问题时不知道怎样选择,也不知道哪个更适合自己,精装房省时省力',
40
+    Content: ArticleContentList.ArticleContentList[3],
35
     Publisher: '银城江北公司',
41
     Publisher: '银城江北公司',
36
     CreateDate: '2019-03-28 14:05:02',
42
     CreateDate: '2019-03-28 14:05:02',
37
-    Banner: []
43
+    Type: 2
38
   }]
44
   }]
39
 }, {
45
 }, {
40
   Type: 3,
46
   Type: 3,
41
   List: [{
47
   List: [{
42
     Id: '5',
48
     Id: '5',
43
-    MainImg: '',
49
+    MainImg: 'https://whole-estate.oss-cn-beijing.aliyuncs.com/notebaike-5.jpg',
44
     Title: '解读购房签约',
50
     Title: '解读购房签约',
45
-    Content: '',
51
+    Remark: '在我们买房签合同后,还需要网签,很多人并不了解网签是什么?下面小编就为大家介绍下网签的好处以及一些注意事项,以供参考',
52
+    Content: ArticleContentList.ArticleContentList[4],
46
     Publisher: '银城江北公司',
53
     Publisher: '银城江北公司',
47
     CreateDate: '2019-03-28 14:05:02',
54
     CreateDate: '2019-03-28 14:05:02',
48
-    Banner: []
55
+    Type: 3
49
   }]
56
   }]
50
 }, {
57
 }, {
51
   Type: 4,
58
   Type: 4,
52
   List: [{
59
   List: [{
53
     Id: '6',
60
     Id: '6',
54
-    MainImg: '',
61
+    MainImg: 'https://whole-estate.oss-cn-beijing.aliyuncs.com/notebaike-6.jpg',
55
     Title: '新手必备收房攻略',
62
     Title: '新手必备收房攻略',
56
-    Content: '',
63
+    Remark: '通常情况下,我们购买的房子就是毛坯房,一般小区建好以后,就会交房,而交房重要的一步就是要验收,只有质量合格的房子才能够交房',
64
+    Content: ArticleContentList.ArticleContentList[5],
57
     Publisher: '银城江北公司',
65
     Publisher: '银城江北公司',
58
     CreateDate: '2019-03-28 14:05:02',
66
     CreateDate: '2019-03-28 14:05:02',
59
-    Banner: []
67
+    Type: 4
60
   }]
68
   }]
61
 }]
69
 }]
62
 
70
 
63
 module.exports = {
71
 module.exports = {
64
   ArticleList: ArticleList
72
   ArticleList: ArticleList
65
-}
66
-
73
+}

+ 42
- 0
pages/SelfServiceTool/Cyclopedia/articleContent.js
ファイル差分が大きすぎるため省略します
ファイルの表示


+ 17
- 30
pages/SelfServiceTool/Cyclopedia/index.js ファイルの表示

11
       title: '购房百科'
11
       title: '购房百科'
12
     })
12
     })
13
   },
13
   },
14
+  onLoad() {
15
+    this.ReturnList()
16
+  },
14
   data: {
17
   data: {
15
     UserInfo: app.globalData.UserInfo, // 用户信息
18
     UserInfo: app.globalData.UserInfo, // 用户信息
16
     NavList: [{
19
     NavList: [{
27
       id: '4'
30
       id: '4'
28
     }],
31
     }],
29
     ActiveIndex: 0,
32
     ActiveIndex: 0,
30
-    List: [{
31
-      Img: '/assets/images/img5.jpg',
32
-      Name: '示例标题',
33
-      Remark: '示例副标题'
34
-    }, {
35
-      Img: '/assets/images/img5.jpg',
36
-      Name: '示例标题',
37
-      Remark: '示例副标题'
38
-    }, {
39
-      Img: '/assets/images/img5.jpg',
40
-      Name: '示例标题',
41
-      Remark: '示例副标题'
42
-    }, {
43
-      Img: '/assets/images/img5.jpg',
44
-      Name: '示例标题',
45
-      Remark: '示例副标题'
46
-    }, {
47
-      Img: '/assets/images/img5.jpg',
48
-      Name: '示例标题',
49
-      Remark: '示例副标题'
50
-    }, {
51
-      Img: '/assets/images/img5.jpg',
52
-      Name: '示例标题',
53
-      Remark: '示例副标题'
54
-    }, {
55
-      Img: '/assets/images/img5.jpg',
56
-      Name: '示例标题',
57
-      Remark: '示例副标题'
58
-    }]
33
+    List: []
59
   },
34
   },
60
   CutNav(e) {
35
   CutNav(e) {
61
     this.setData({
36
     this.setData({
62
       ActiveIndex: e.target.dataset.index
37
       ActiveIndex: e.target.dataset.index
63
     })
38
     })
39
+    this.ReturnList()
40
+  },
41
+  ReturnList() {
42
+    let aArr = []
43
+    ArticleList.ArticleList.map((item) => {
44
+      if (item.Type - 0 === this.data.NavList[this.data.ActiveIndex].id - 0) {
45
+        aArr = item.List
46
+      }
47
+    })
48
+    this.setData({
49
+      List: aArr
50
+    })
64
   },
51
   },
65
   TapItem(e) {
52
   TapItem(e) {
66
     wx.navigateTo({
53
     wx.navigateTo({
67
-      url: '/pages/SelfServiceTool/Cyclopedia/Detail?id=' + e.target.dataset.id,
54
+      url: '/pages/SelfServiceTool/Cyclopedia/Detail?id=' + e.target.dataset.id + '&type=' + e.target.dataset.type,
68
     })
55
     })
69
   }
56
   }
70
 })
57
 })

+ 5
- 5
pages/SelfServiceTool/Cyclopedia/index.wxml ファイルの表示

9
   </view>
9
   </view>
10
   <view class="MainPage">
10
   <view class="MainPage">
11
     <view class="list">
11
     <view class="list">
12
-      <view class="flex-h" wx:for="{{List}}" wx:for-item="item" wx:for-index="idx" wx:key="key" data-id="{{item.id}}" bindtap="TapItem">
12
+      <view class="flex-h" wx:for="{{List}}" wx:for-item="item" wx:for-index="idx" wx:key="key" data-type="{{item.Type}}" data-id="{{item.Id}}" bindtap="TapItem">
13
         <view class="img">
13
         <view class="img">
14
-          <image mode="aspectFill" src="{{item.Img}}" class="centerLabel cover"></image>
14
+          <image mode="aspectFill" src="{{item.MainImg}}" class="centerLabel cover" data-type="{{item.Type}}" data-id="{{item.Id}}"></image>
15
         </view>
15
         </view>
16
-        <view class="flex-item">
17
-          <text>{{item.Name}}</text>
18
-          <text>{{item.Remark}}</text>
16
+        <view class="flex-item" data-type="{{item.Type}}" data-id="{{item.Id}}">
17
+          <text data-type="{{item.Type}}" data-id="{{item.Id}}">{{item.Title}}</text>
18
+          <text data-type="{{item.Type}}" data-id="{{item.Id}}">{{item.Remark}}</text>
19
         </view>
19
         </view>
20
       </view>
20
       </view>
21
     </view>
21
     </view>