Browse Source

代码更新

梁沛聪 6 years ago
parent
commit
10e53ae0df

+ 34
- 12
miniapp/app/pages/bookService/index.js View File

@@ -2,17 +2,27 @@ const WxParse = require('../../wxParse/wxParse.js')
2 2
 const $ = global
3 3
 
4 4
 new $.Page({
5
-    onLoad() {
6
-        var article = '<div>我是富文本</div>'
7
-        /**
8
-         * WxParse.wxParse(bindName , type, data, target,imagePadding)
9
-         * 1.bindName绑定的数据名(必填)
10
-         * 2.type可以为html或者md(必填)
11
-         * 3.data为传入的具体数据(必填)
12
-         * 4.target为Page对象,一般为this(必填)
13
-         * 5.imagePadding为当图片自适应是左右的单一padding(默认为0,可选)
14
-         */
15
-        WxParse.wxParse('article', 'html', article, this, 5)
5
+    onLoad(options) {
6
+        if (!options.id) {
7
+            return $.wx.showToast({
8
+                title: '找不到对应id'
9
+            });
10
+        }
11
+        $.request(`server_info/${options.id}`, 'GET', {}).then((res) => {
12
+            var article = res.data && res.data.content || '';
13
+            const fields = res.data.fields || [];
14
+            const options = [];
15
+            WxParse.wxParse('article', 'html', article, this, 5);
16
+            for (let item of fields) {
17
+                const group = item.input_group;
18
+                options.push(group[0].value || '');
19
+            }
20
+            this.setData({
21
+                banner: res.data.photo || '',
22
+                fields,
23
+                options
24
+            });
25
+        });
16 26
     },
17 27
     bookServer() {
18 28
         const {
@@ -53,6 +63,18 @@ new $.Page({
53 63
         });
54 64
     },
55 65
     radioChange(e) {
56
-
66
+        const {
67
+            index
68
+        } = e.currentTarget.dataset || 0;
69
+        const {
70
+            value
71
+        } = e.detail;
72
+        const {
73
+            options
74
+        } = this.data;
75
+        options[index] = value;
76
+        this.setData({
77
+            options
78
+        });
57 79
     }
58 80
 })

+ 14
- 4
miniapp/app/pages/bookService/index.wxml View File

@@ -13,7 +13,17 @@
13 13
         </view>
14 14
         <view class="service">
15 15
             <view class="service-bd">
16
-                <view class="s-item">
16
+                <view class="s-item" wx:for="{{fields}}">
17
+                    <view class="s-item-hd">{{item.name_cn}}</view>
18
+                    <view class="s-item-bd">
19
+                        <radio-group class="radio-group" data-index="{{index}}" bindchange="radioChange">
20
+                            <label class="radio" wx:for="{{item.input_group}}" wx:for-index="idx" wx:for-item="radio">
21
+                                <radio value="{{radio.value}}" checked="{{idx === 0}}" />{{radio.value}}
22
+                            </label>
23
+                        </radio-group>
24
+                    </view>
25
+                </view>
26
+                <!-- <view class="s-item">
17 27
                     <view class="s-item-hd">服务内容</view>
18 28
                     <view class="s-item-bd">
19 29
                         <checkbox-group bindchange="checkboxChange">
@@ -52,8 +62,8 @@
52 62
                             </label>
53 63
                         </checkbox-group>
54 64
                     </view>
55
-                </view>
56
-                <view class="s-item">
65
+                </view> -->
66
+                <!-- <view class="s-item">
57 67
                     <view class="s-item-hd">人口数量</view>
58 68
                     <view class="s-item-bd">
59 69
                         <radio-group class="radio-group" bindchange="radioChange">
@@ -119,7 +129,7 @@
119 129
                             </label>
120 130
                         </radio-group>
121 131
                     </view>
122
-                </view>
132
+                </view> -->
123 133
             </view>
124 134
         </view>
125 135
     </view>

+ 12
- 4
miniapp/app/pages/introduce/index.js View File

@@ -20,20 +20,28 @@ new $.Page({
20 20
             });
21 21
         }
22 22
         this.setData({
23
-            name
23
+            name,
24
+            id
24 25
         });
25 26
     },
26 27
     bookServer() {
27 28
         const {
28
-            name
29
+            name,
30
+            id
29 31
         } = this.data;
30 32
         if (name && name.includes('月嫂')) {
31 33
             $.router.goto({
32
-                path: '/pages/yuesao/index'
34
+                path: '/pages/yuesao/index',
35
+                query: {
36
+                    id
37
+                }
33 38
             });
34 39
         } else {
35 40
             $.router.goto({
36
-                path: '/pages/bookService/index'
41
+                path: '/pages/bookService/index',
42
+                query: {
43
+                    id
44
+                }
37 45
             });
38 46
         }
39 47
     }

+ 3
- 3
miniapp/app/pages/introduce/index.wxml View File

@@ -2,9 +2,9 @@
2 2
 <view class="page">
3 3
     <view class="page-bd">
4 4
         <view class="introduce">
5
-            <!-- <template is="wxParse" data="{{wxParseData:article.nodes}}" /> -->
6
-            <image class="s" src="/img/demo/test.jpg" style="width:100%"></image>
7
-            <image class="s" src="/img/demo/test2.jpg" style="width:100%"></image>
5
+            <template is="wxParse" data="{{wxParseData:article.nodes}}" />
6
+            <!-- <image class="s" src="/img/demo/test.jpg" style="width:100%"></image>
7
+            <image class="s" src="/img/demo/test2.jpg" style="width:100%"></image> -->
8 8
         </view>
9 9
     </view>
10 10
     <view class="page-ft">

+ 38
- 13
miniapp/app/pages/yuesao/index.js View File

@@ -2,19 +2,29 @@ const WxParse = require('../../wxParse/wxParse.js')
2 2
 const $ = global
3 3
 
4 4
 new $.Page({
5
-    onLoad() {
6
-        var article = '<div>我是富文本</div>'
7
-        /**
8
-         * WxParse.wxParse(bindName , type, data, target,imagePadding)
9
-         * 1.bindName绑定的数据名(必填)
10
-         * 2.type可以为html或者md(必填)
11
-         * 3.data为传入的具体数据(必填)
12
-         * 4.target为Page对象,一般为this(必填)
13
-         * 5.imagePadding为当图片自适应是左右的单一padding(默认为0,可选)
14
-         */
15
-        WxParse.wxParse('article', 'html', article, this, 5);
16
-        $.request('server_fields', 'GET', {}).then((res) => {
17
-
5
+    data: {
6
+        options: []
7
+    },
8
+    onLoad(options) {
9
+        if (!options.id) {
10
+            return $.wx.showToast({
11
+                title: '找不到对应id'
12
+            });
13
+        }
14
+        $.request(`server_info/${options.id}`, 'GET', {}).then((res) => {
15
+            var article = res.data && res.data.content || '';
16
+            const fields = res.data.fields || [];
17
+            const options = [];
18
+            WxParse.wxParse('article', 'html', article, this, 5);
19
+            for (let item of fields) {
20
+                const group = item.input_group;
21
+                options.push(group[0].value || '');
22
+            }
23
+            this.setData({
24
+                banner: res.data.photo || '',
25
+                fields,
26
+                options
27
+            });
18 28
         });
19 29
     },
20 30
     bookServer() {
@@ -54,5 +64,20 @@ new $.Page({
54 64
                 type: $.ROUTER_TYPE.SWITCH_TAB
55 65
             });
56 66
         });
67
+    },
68
+    radioChange(e) {
69
+        const {
70
+            index
71
+        } = e.currentTarget.dataset || 0;
72
+        const {
73
+            value
74
+        } = e.detail;
75
+        const {
76
+            options
77
+        } = this.data;
78
+        options[index] = value;
79
+        this.setData({
80
+            options
81
+        });
57 82
     }
58 83
 })

+ 6
- 18
miniapp/app/pages/yuesao/index.wxml View File

@@ -1,7 +1,7 @@
1 1
 <import src="/wxParse/wxParse.wxml" />
2 2
 <view class="page">
3 3
     <view class="page-hd">
4
-        <image class="hero" src="/img/demo/banner.jpg"></image>
4
+        <image class="hero" src="{{banner}}"></image>
5 5
     </view>
6 6
     <view class="page-bd">
7 7
         <view class="mod">
@@ -13,24 +13,12 @@
13 13
         </view>
14 14
         <view class="service">
15 15
             <view class="service-bd">
16
-                <view class="s-item">
17
-                    <view class="s-item-hd">一价全包</view>
16
+                <view class="s-item" wx:for="{{fields}}">
17
+                    <view class="s-item-hd">{{item.name_cn}}</view>
18 18
                     <view class="s-item-bd">
19
-                        <radio-group class="radio-group" bindchange="radioChange">
20
-                            <label class="radio">
21
-                                <radio value="" checked />8800(初级月嫂)
22
-                            </label>
23
-                            <label class="radio">
24
-                                <radio value="" />9800(普通月嫂)
25
-                            </label>
26
-                            <label class="radio">
27
-                                <radio value="" />12800(高级月嫂)
28
-                            </label>
29
-                            <label class="radio">
30
-                                <radio value="" />15800(金牌月嫂)
31
-                            </label>
32
-                            <label class="radio">
33
-                                <radio value="" />18800(特级月嫂)
19
+                        <radio-group class="radio-group" data-index="{{index}}" bindchange="radioChange">
20
+                            <label class="radio" wx:for="{{item.input_group}}" wx:for-index="idx" wx:for-item="radio">
21
+                                <radio value="{{radio.value}}" checked="{{idx === 0}}" />{{radio.value}}
34 22
                             </label>
35 23
                         </radio-group>
36 24
                     </view>

Loading…
Cancel
Save