许成详 6 年之前
父節點
當前提交
f207b4dddf

+ 17
- 6
pages/SelfServiceTool/Cyclopedia/Detail.js 查看文件

@@ -1,5 +1,6 @@
1 1
 //index.js
2 2
 //获取应用实例
3
+import ArticleList from './article.js'
3 4
 const app = getApp()
4 5
 
5 6
 Page({
@@ -8,13 +9,23 @@ Page({
8 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 27
   data: {
12 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,5 +5,10 @@
5 5
     <text class="flex-item">{{Detail.Publisher}}</text>
6 6
     <text>{{Detail.CreateDate}}</text>
7 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 14
 </view>

+ 6
- 0
pages/SelfServiceTool/Cyclopedia/Detail.wxss 查看文件

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

+ 42
- 0
pages/SelfServiceTool/Cyclopedia/articleContent.js
文件差異過大導致無法顯示
查看文件


+ 17
- 30
pages/SelfServiceTool/Cyclopedia/index.js 查看文件

@@ -11,6 +11,9 @@ Page({
11 11
       title: '购房百科'
12 12
     })
13 13
   },
14
+  onLoad() {
15
+    this.ReturnList()
16
+  },
14 17
   data: {
15 18
     UserInfo: app.globalData.UserInfo, // 用户信息
16 19
     NavList: [{
@@ -27,44 +30,28 @@ Page({
27 30
       id: '4'
28 31
     }],
29 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 35
   CutNav(e) {
61 36
     this.setData({
62 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 52
   TapItem(e) {
66 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,13 +9,13 @@
9 9
   </view>
10 10
   <view class="MainPage">
11 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 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 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 19
         </view>
20 20
       </view>
21 21
     </view>