Quellcode durchsuchen

前后端联调

梁沛聪 vor 6 Jahren
Ursprung
Commit
e2fdfb5105

+ 2
- 1
miniapp/app/app.json Datei anzeigen

@@ -9,7 +9,8 @@
9 9
         "pages/goodsDetail/index",
10 10
         "pages/introduce/index",
11 11
         "pages/bookService/index",
12
-        "pages/yuesao/index"
12
+        "pages/yuesao/index",
13
+        "pages/detail/index"
13 14
     ],
14 15
     "window": {
15 16
         "backgroundTextStyle": "light",

+ 2
- 2
miniapp/app/base/libs/request.js Datei anzeigen

@@ -28,7 +28,7 @@ const request = (cmd, method = 'POST', params = {}, handleStatus = false) => {
28 28
             data: params,
29 29
             success: res => {
30 30
                 res = res.data;
31
-                if (res.status === 105) {
31
+                if (res.status && res.status === 105) {
32 32
                     // token失效
33 33
                     global.memory.setData('USER_INFO', {}, {
34 34
                         localSave: true
@@ -38,7 +38,7 @@ const request = (cmd, method = 'POST', params = {}, handleStatus = false) => {
38 38
                         type: global.ROUTER_TYPE.CLOSE_ALL
39 39
                     });
40 40
                 } else {
41
-                    if (handleStatus || res.status === 0) {
41
+                    if (handleStatus || !res.status) {
42 42
                         resolve(res);
43 43
                     } else if (res.message) {
44 44
                         global.wx.showToast({

+ 44
- 9
miniapp/app/pages/classify/index.js Datei anzeigen

@@ -1,19 +1,54 @@
1 1
 const $ = global;
2
-
2
+const colors = [
3
+    'blue',
4
+    'green',
5
+    'pink',
6
+    'orange',
7
+    'purple'
8
+];
3 9
 new $.Page({
4 10
     data: {
5
-        toView: ''
11
+        toView: '',
12
+        list: []
6 13
     },
7 14
     onLoad() {
8
-        const meta = $.router.getMeta();
9
-        const target = meta && meta.params && meta.params.target || '';
10
-
11
-        if (target) {
12
-            setTimeout(() => {
15
+        $.request('classifies', 'GET', {}).then((res) => {
16
+            const data = res.data;
17
+            const list = [];
18
+            if (data.length > 0) {
19
+                data.forEach(d => {
20
+                    if (!d.pid) {
21
+                        d.array = [];
22
+                        list.push(d);
23
+                    }
24
+                });
25
+                data.forEach(d => {
26
+                    if (d.pid) {
27
+                        list.forEach((l, index) => {
28
+                            l.color = colors[index];
29
+                            if (l.id === d.pid) {
30
+                                l['array'].push(d);
31
+                            }
32
+                        });
33
+                    }
34
+                });
13 35
                 this.setData({
14
-                    toView: target
36
+                    list
15 37
                 });
16
-            }, 10);
38
+            }
39
+        });
40
+    },
41
+    toIntroduce(e) {
42
+        const {
43
+            id
44
+        } = e.currentTarget.dataset;
45
+        if (id) {
46
+            $.router.goto({
47
+                path: `/pages/introduce/index`,
48
+                query: {
49
+                    id
50
+                }
51
+            });
17 52
         }
18 53
     }
19 54
 });

+ 6
- 107
miniapp/app/pages/classify/index.wxml Datei anzeigen

@@ -1,118 +1,17 @@
1 1
 <view class="page">
2
-    <scroll-view scroll-y scroll-with-animation="true" scroll-into-view="{{toView}}">
2
+    <scroll-view scroll-y scroll-with-animation scroll-into-view="{{toView}}">
3 3
         <view class="page-bd">
4
-            <view class="classify blue">
4
+            <view class="classify {{item.color}}" wx:for="{{list}}" id="jiazheng">
5 5
                 <view class="hd">
6
-                    <text class="dot">●</text>家政</view>
6
+                    <text class="dot">●</text>{{item.name}}</view>
7 7
                 <view class="bd">
8
-                    <view class="item">
8
+                    <view class="item" wx:for="{{item.array}}" wx:for-item="l" data-id="{{l.id}}" bindtap="toIntroduce">
9 9
                         <view class="inner">
10
-                            <view class="text">月嫂</view>
11
-                            <view class="sub-text">月嫂</view>
10
+                            <view class="text">{{l.name}}</view>
11
+                            <view class="sub-text">{{l.info}}</view>
12 12
                             <image class="icon-arr" src="/img/arr1.png"></image>
13 13
                         </view>
14 14
                     </view>
15
-                    <view class="item">
16
-                        <view class="inner">
17
-                            <view class="text">育婴师</view>
18
-                            <view class="sub-text">育婴师</view>
19
-                            <image class="icon-arr" src="/img/arr1.png"></image>
20
-                        </view>
21
-                    </view>
22
-                    <view class="item">
23
-                        <view class="inner">
24
-                            <view class="text">病人护理</view>
25
-                            <view class="sub-text">病人护理</view>
26
-                            <image class="icon-arr" src="/img/arr1.png"></image>
27
-                        </view>
28
-                    </view>
29
-                    <view class="item">
30
-                        <view class="inner">
31
-                            <view class="text">老人看护</view>
32
-                            <view class="sub-text">老人看护</view>
33
-                            <image class="icon-arr" src="/img/arr1.png"></image>
34
-                        </view>
35
-                    </view>
36
-                </view>
37
-            </view>
38
-            <view class="classify green" id="zhongdian">
39
-                <view class="hd">
40
-                    <text class="dot">●</text>钟点/家庭保洁服务</view>
41
-                <view class="bd">
42
-                    <view class="item">
43
-                        <view class="inner">
44
-                            <view class="text">空调清洗</view>
45
-                            <view class="sub-text">空调清洗</view>
46
-                            <image class="icon-arr" src="/img/arr2.png"></image>
47
-                        </view>
48
-                    </view>
49
-                    <view class="item">
50
-                        <view class="inner">
51
-                            <view class="text">冰箱清洁</view>
52
-                            <view class="sub-text">冰箱清洁</view>
53
-                            <image class="icon-arr" src="/img/arr2.png"></image>
54
-                        </view>
55
-                    </view>
56
-                    <view class="item">
57
-                        <view class="inner">
58
-                            <view class="text">抽油烟机清洗</view>
59
-                            <view class="sub-text">抽油烟机清洗</view>
60
-                            <image class="icon-arr" src="/img/arr2.png"></image>
61
-                        </view>
62
-                    </view>
63
-                    <view class="item">
64
-                        <view class="inner">
65
-                            <view class="text">家庭除螨</view>
66
-                            <view class="sub-text">家庭除螨</view>
67
-                            <image class="icon-arr" src="/img/arr2.png"></image>
68
-                        </view>
69
-                    </view>
70
-                    <view class="item">
71
-                        <view class="inner">
72
-                            <view class="text">开荒清洁</view>
73
-                            <view class="sub-text">开荒清洁</view>
74
-                            <image class="icon-arr" src="/img/arr2.png"></image>
75
-                        </view>
76
-                    </view>
77
-                </view>
78
-            </view>
79
-            <view class="classify pink">
80
-                <view class="hd">
81
-                    <text class="dot">●</text>母婴产品</view>
82
-                <view class="bd">
83
-                    <view class="item">
84
-                        <view class="inner">
85
-                            <view class="text">母婴产品</view>
86
-                            <view class="sub-text">母婴产品</view>
87
-                            <image class="icon-arr" src="/img/arr3.png"></image>
88
-                        </view>
89
-                    </view>
90
-                </view>
91
-            </view>
92
-            <view class="classify orange">
93
-                <view class="hd">
94
-                    <text class="dot">●</text>催乳及产后康复</view>
95
-                <view class="bd">
96
-                    <view class="item">
97
-                        <view class="inner">
98
-                            <view class="text">催乳及产后康复</view>
99
-                            <view class="sub-text">催乳及产后康复</view>
100
-                            <image class="icon-arr" src="/img/arr4.png"></image>
101
-                        </view>
102
-                    </view>
103
-                </view>
104
-            </view>
105
-            <view class="classify purple">
106
-                <view class="hd">
107
-                    <text class="dot">●</text>月子及育婴知识咨询</view>
108
-                <view class="bd">
109
-                    <view class="item">
110
-                        <view class="inner">
111
-                            <view class="text">月子及育婴知识咨询</view>
112
-                            <view class="sub-text">月子及育婴咨询</view>
113
-                            <image class="icon-arr" src="/img/arr5.png"></image>
114
-                        </view>
115
-                    </view>
116 15
                 </view>
117 16
             </view>
118 17
         </view>

+ 1
- 0
miniapp/app/pages/classify/index.wxss Datei anzeigen

@@ -71,6 +71,7 @@ page {
71 71
 
72 72
 .bd {
73 73
     margin: 0 10rpx;
74
+    font-size: 0;
74 75
 }
75 76
 
76 77
 .item {

+ 25
- 0
miniapp/app/pages/detail/index.js Datei anzeigen

@@ -0,0 +1,25 @@
1
+const WxParse = require('../../wxParse/wxParse.js')
2
+const $ = global
3
+
4
+new $.Page({
5
+    onLoad(options) {
6
+        const id = options.id;
7
+        if (id) {
8
+            $.request('classifies', 'GET', {
9
+                id
10
+            }).then((res) => {
11
+                var article = '<div>我是富文本</div>'
12
+                /**
13
+                 * WxParse.wxParse(bindName , type, data, target,imagePadding)
14
+                 * 1.bindName绑定的数据名(必填)
15
+                 * 2.type可以为html或者md(必填)
16
+                 * 3.data为传入的具体数据(必填)
17
+                 * 4.target为Page对象,一般为this(必填)
18
+                 * 5.imagePadding为当图片自适应是左右的单一padding(默认为0,可选)
19
+                 */
20
+                WxParse.wxParse('article', 'html', article, this, 5)
21
+            });
22
+        }
23
+    },
24
+    bookServer() {}
25
+})

+ 3
- 0
miniapp/app/pages/detail/index.json Datei anzeigen

@@ -0,0 +1,3 @@
1
+{
2
+    "navigationBarTitleText": "详情页"
3
+}

+ 8
- 0
miniapp/app/pages/detail/index.wxml Datei anzeigen

@@ -0,0 +1,8 @@
1
+<import src="/wxParse/wxParse.wxml" />
2
+<view class="page">
3
+    <view class="page-bd">
4
+        <view class="introduce">
5
+            <template is="wxParse" data="{{wxParseData:article.nodes}}" />
6
+        </view>
7
+    </view>
8
+</view>

+ 21
- 0
miniapp/app/pages/detail/index.wxss Datei anzeigen

@@ -0,0 +1,21 @@
1
+page {
2
+    background-color: #fff;
3
+}
4
+
5
+.introduce {
6
+    margin: 40rpx 20rpx 80rpx;
7
+}
8
+
9
+.btn-book {
10
+    display: block;
11
+    height: 80rpx;
12
+    line-height: 80rpx;
13
+    text-align: center;
14
+    position: fixed;
15
+    bottom: 60rpx;
16
+    background-color: #00a0e9;
17
+    color: #fff;
18
+    font-size: 28rpx;
19
+    left: 40rpx;
20
+    right: 40rpx;
21
+}

+ 27
- 4
miniapp/app/pages/home/index.js Datei anzeigen

@@ -9,7 +9,20 @@ new $.Page({
9 9
         ]
10 10
     },
11 11
     onLoad() {
12
-        WxParse.wxParse('article', 'html', '<div>hello world</div>', this);
12
+        $.request('server_infos', 'GET', {}).then((res) => {
13
+            const {
14
+                bottom,
15
+                top,
16
+                introduce
17
+            } = res;
18
+            WxParse.wxParse('article', 'html', introduce, this);
19
+            this.setData({
20
+                bottom,
21
+                top,
22
+                introduce
23
+            });
24
+        });
25
+
13 26
     },
14 27
     handleJump(e) {
15 28
         const {
@@ -20,9 +33,19 @@ new $.Page({
20 33
         if (route) {
21 34
             $.router.goto({
22 35
                 path: `/pages/${route}/index`,
23
-                type: type && parseInt(type),
24
-                params: {
25
-                    target: target || ''
36
+                type: type && parseInt(type)
37
+            });
38
+        }
39
+    },
40
+    toDetail(e) {
41
+        const {
42
+            id
43
+        } = e.target.dataset;
44
+        if (id) {
45
+            $.router.goto({
46
+                path: `/pages/detail/index`,
47
+                query: {
48
+                    id
26 49
                 }
27 50
             });
28 51
         }

+ 7
- 6
miniapp/app/pages/home/index.wxml Datei anzeigen

@@ -3,9 +3,9 @@
3 3
     <view class="page-hd">
4 4
         <swiper indicator-dots="true" indicator-color="#ffffff" indicator-active-color="#00a0e9" autoplay="true"
5 5
             interval="5000" duration="500">
6
-            <block wx:for="{{imgUrls}}">
6
+            <block wx:for="{{top}}">
7 7
                 <swiper-item>
8
-                    <image src="{{item}}" class="slide-image" />
8
+                    <image src="{{item.photo}}" class="slide-image" data-id="{{item.id}}" bindtap="toDetail" />
9 9
                 </swiper-item>
10 10
             </block>
11 11
         </swiper>
@@ -19,7 +19,7 @@
19 19
             </view>
20 20
         </view>
21 21
         <view class="entrances">
22
-            <view class="item" bindtap="handleJump" data-route="classify" data-type="5">
22
+            <view class="item" bindtap="handleJump" data-route="classify" data-target="jiazheng" data-type="5">
23 23
                 <view class="entrance">
24 24
                     <image class="img" mode="widthFix" src="/img/entrance1.png"></image>
25 25
                     <view class="name">家政</view>
@@ -38,7 +38,7 @@
38 38
                 </view>
39 39
             </view>
40 40
             <view class="item">
41
-                <view class="entrance">
41
+                <view class="entrance" bindtap="handleJump" data-route="classify" data-target="cuiru" data-type="5">
42 42
                     <image class="img" mode="widthFix" src="/img/entrance4.png"></image>
43 43
                     <view class="name">催乳及产后康复</view>
44 44
                 </view>
@@ -49,13 +49,14 @@
49 49
                     <view class="name">月子及育婴知识咨询</view>
50 50
                 </view>
51 51
             </view>
52
-            <view class="item" bindtap="handleJump" data-route="classify" data-type="5">
52
+            <view class="item" bindtap="handleJump" data-route="classify" data-target="jiazheng" data-type="5">
53 53
                 <view class="entrance">
54 54
                     <image class="img" mode="widthFix" src="/img/entrance6.png"></image>
55 55
                     <view class="name">更多</view>
56 56
                 </view>
57 57
             </view>
58 58
         </view>
59
-        <image class="bottom-banner" mode="widthFix" src="/img/demo/banner2.jpg"></image>
59
+        <image class="bottom-banner" wx:if="{{bottom.photo}}" mode="widthFix" src="{{bottom.photo}}" data-id="{{bottom.id}}"
60
+            bindtap="toDetail"></image>
60 61
     </view>
61 62
 </view>

Loading…
Abbrechen
Speichern