浏览代码

分类页逻辑优化

梁沛聪 6 年前
父节点
当前提交
2e8da44fc7

+ 13
- 4
miniapp/app/pages/classify/index.js 查看文件

@@ -8,18 +8,26 @@ const colors = [
8 8
 ];
9 9
 new $.Page({
10 10
     data: {
11
-        toView: '',
12 11
         list: []
13 12
     },
14
-    onLoad() {
13
+    onShow() {
14
+        const meta = $.router.getMeta();
15
+        const type = meta && meta.params && meta.params.type || '';
15 16
         $.request('classifies', 'GET', {}).then((res) => {
16 17
             const data = res.data;
17 18
             const list = [];
18 19
             if (data.length > 0) {
19 20
                 data.forEach(d => {
20 21
                     if (!d.pid) {
21
-                        d.array = [];
22
-                        list.push(d);
22
+                        if (type) {
23
+                            if (d.name.includes(type)) {
24
+                                d.array = [];
25
+                                list.push(d);
26
+                            }
27
+                        } else {
28
+                            d.array = [];
29
+                            list.push(d);
30
+                        }
23 31
                     }
24 32
                 });
25 33
                 data.forEach(d => {
@@ -38,6 +46,7 @@ new $.Page({
38 46
                 this.setData({
39 47
                     list
40 48
                 });
49
+                $.router.clearCurMeta();
41 50
             }
42 51
         });
43 52
     },

+ 17
- 19
miniapp/app/pages/classify/index.wxml 查看文件

@@ -1,25 +1,23 @@
1 1
 <view class="page">
2
-    <scroll-view scroll-y scroll-with-animation scroll-into-view="{{toView}}">
3
-        <view class="page-bd">
4
-            <view class="classify {{item.color}}" wx:for="{{list}}" id="jiazheng">
5
-                <view class="hd">
6
-                    <text class="dot">●</text>{{item.name}}</view>
7
-                <view class="bd">
8
-                    <view class="item" wx:for="{{item.array}}" wx:for-item="l" data-name="{{l.name}}" data-id="{{l.id}}"
9
-                        bindtap="toIntroduce">
10
-                        <!-- <button class="inner" hover-class="none" open-type="contact" session-from="" wx:if="{{l.isConsult}}">
11
-                            <view class="text">{{l.name}}</view>
12
-                            <view class="sub-text">{{l.info}}</view>
13
-                            <image class="icon-arr" src="/img/arr1.png"></image>
14
-                        </button> -->
15
-                        <view class="inner">
16
-                            <view class="text">{{l.name}}</view>
17
-                            <view class="sub-text">{{l.info}}</view>
18
-                            <image class="icon-arr" src="/img/arr1.png"></image>
19
-                        </view>
2
+    <view class="page-bd">
3
+        <view class="classify {{item.color}}" wx:for="{{list}}" id="jiazheng">
4
+            <view class="hd">
5
+                <text class="dot">●</text>{{item.name}}</view>
6
+            <view class="bd">
7
+                <view class="item" wx:for="{{item.array}}" wx:for-item="l" data-name="{{l.name}}" data-id="{{l.id}}"
8
+                    bindtap="toIntroduce">
9
+                    <!-- <button class="inner" hover-class="none" open-type="contact" session-from="" wx:if="{{l.isConsult}}">
10
+                                <view class="text">{{l.name}}</view>
11
+                                <view class="sub-text">{{l.info}}</view>
12
+                                <image class="icon-arr" src="/img/arr1.png"></image>
13
+                            </button> -->
14
+                    <view class="inner">
15
+                        <view class="text">{{l.name}}</view>
16
+                        <view class="sub-text">{{l.info}}</view>
17
+                        <image class="icon-arr" src="/img/arr1.png"></image>
20 18
                     </view>
21 19
                 </view>
22 20
             </view>
23 21
         </view>
24
-    </scroll-view>
22
+    </view>
25 23
 </view>

+ 4
- 1
miniapp/app/pages/home/index.js 查看文件

@@ -33,7 +33,10 @@ new $.Page({
33 33
         if (route) {
34 34
             $.router.goto({
35 35
                 path: `/pages/${route}/index`,
36
-                type: type && parseInt(type)
36
+                type: type && parseInt(type),
37
+                params: {
38
+                    type: target || ''
39
+                }
37 40
             });
38 41
         }
39 42
     },

+ 4
- 4
miniapp/app/pages/home/index.wxml 查看文件

@@ -19,13 +19,13 @@
19 19
             </view>
20 20
         </view>
21 21
         <view class="entrances">
22
-            <view class="item" bindtap="handleJump" data-route="classify" data-target="jiazheng" data-type="5">
22
+            <view class="item" bindtap="handleJump" data-route="classify" data-target="家政" 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>
26 26
                 </view>
27 27
             </view>
28
-            <view class="item" bindtap="handleJump" data-route="classify" data-target="zhongdian" data-type="5">
28
+            <view class="item" bindtap="handleJump" data-route="classify" data-target="钟点" data-type="5">
29 29
                 <view class="entrance">
30 30
                     <image class="img" mode="widthFix" src="/img/entrance2.png"></image>
31 31
                     <view class="name">钟点/家庭保洁服务</view>
@@ -38,7 +38,7 @@
38 38
                 </view>
39 39
             </view>
40 40
             <view class="item">
41
-                <view class="entrance" bindtap="handleJump" data-route="classify" data-target="cuiru" data-type="5">
41
+                <view class="entrance" bindtap="handleJump" data-route="classify" data-target="催乳" data-type="5">
42 42
                     <image class="img" mode="widthFix" src="/img/entrance4.png"></image>
43 43
                     <view class="name">催乳及产后康复</view>
44 44
                 </view>
@@ -55,7 +55,7 @@
55 55
                     <view class="name">月子及育婴知识咨询</view>
56 56
                 </view>
57 57
             </view>
58
-            <view class="item" bindtap="handleJump" data-route="classify" data-target="jiazheng" data-type="5">
58
+            <view class="item" bindtap="handleJump" data-route="classify" data-type="5">
59 59
                 <view class="entrance">
60 60
                     <image class="img" mode="widthFix" src="/img/entrance6.png"></image>
61 61
                     <view class="name">更多</view>

+ 1
- 1
miniapp/app/pages/service/index.js 查看文件

@@ -25,7 +25,7 @@ new $.Page({
25 25
                 },
26 26
                 fail() {
27 27
                     $.wx.showToast({
28
-                        title: '支付失败'
28
+                        title: '打赏失败'
29 29
                     });
30 30
                 }
31 31
             });

Loading…
取消
保存