├── README.md
└── a-takeaway-demo-of-wxapp-master
├── README.md
├── app.js
├── app.json
├── app.wxss
├── imgs
├── index
│ ├── icon_1.jpg
│ ├── icon_10.jpg
│ ├── icon_11.jpg
│ ├── icon_12.jpg
│ ├── icon_13.jpg
│ ├── icon_14.jpg
│ ├── icon_15.jpg
│ ├── icon_16.jpg
│ ├── icon_2.jpg
│ ├── icon_3.jpg
│ ├── icon_4.jpg
│ ├── icon_5.jpg
│ ├── icon_6.jpg
│ ├── icon_7.jpg
│ ├── icon_8.jpg
│ ├── icon_9.jpg
│ ├── icon_location.png
│ └── icon_search.png
├── shop
│ ├── cart.png
│ ├── empty.png
│ └── plus.png
└── tabBar
│ ├── home_1.png
│ ├── home_2.png
│ ├── mine_1.png
│ └── mine_2.png
├── page
├── index
│ ├── index.js
│ ├── index.json
│ ├── index.wxml
│ ├── index.wxss
│ ├── search.js
│ ├── search.json
│ ├── search.wxml
│ └── search.wxss
├── mine
│ ├── mine.js
│ ├── mine.json
│ ├── mine.wxml
│ └── mine.wxss
├── order
│ ├── order.js
│ ├── order.json
│ ├── order.wxml
│ └── order.wxss
└── shop
│ ├── shop.js
│ ├── shop.json
│ ├── shop.wxml
│ └── shop.wxss
└── utils
└── server.js
/README.md:
--------------------------------------------------------------------------------
1 | # wx-app
2 | 仿美团的微信小程序
3 | 页面数据通过Python从官网爬下来
4 | 正常点餐
5 |
--------------------------------------------------------------------------------
/a-takeaway-demo-of-wxapp-master/README.md:
--------------------------------------------------------------------------------
1 | # a takeaway demo of wxapp
2 | 微信小程序的外卖demo
3 |
--------------------------------------------------------------------------------
/a-takeaway-demo-of-wxapp-master/app.json:
--------------------------------------------------------------------------------
1 | {
2 | "pages": [
3 | "page/index/index",
4 | "page/index/search",
5 | "page/shop/shop",
6 | "page/mine/mine",
7 | "page/order/order"
8 | ],
9 | "window": {
10 | "navigationBarBackgroundColor": "#feb70f",
11 | "navigationBarTextStyle": "white",
12 | "backgroundColor": "#efefef",
13 | "backgroundTextStyle": "dark",
14 | "navigationBarTitleText": "外卖订餐"
15 | },
16 | "tabBar": {
17 | "color": "#878787",
18 | "selectedColor": "#000",
19 | "borderStyle": "black",
20 | "backgroundColor": "#fcfcfc",
21 | "list": [
22 | {
23 | "pagePath": "page/index/index",
24 | "iconPath": "imgs/tabBar/home_2.png",
25 | "selectedIconPath": "imgs/tabBar/home_1.png",
26 | "text": "首页"
27 | },
28 | {
29 | "pagePath": "page/mine/mine",
30 | "iconPath": "imgs/tabBar/mine_2.png",
31 | "selectedIconPath": "imgs/tabBar/mine_1.png",
32 | "text": "我的"
33 | }
34 | ]
35 | },
36 | "networkTimeout": {
37 | "request": 10000,
38 | "connectSocket": 10000,
39 | "uploadFile": 10000,
40 | "downloadFile": 10000
41 | },
42 | "debug": true
43 | }
44 |
--------------------------------------------------------------------------------
/a-takeaway-demo-of-wxapp-master/app.wxss:
--------------------------------------------------------------------------------
1 | page {
2 | background-color: #efefef;
3 | font-family: "Microsoft Yahei, Arial, Helvetica, sans-serif";
4 | }
5 | .section {
6 | background: #fff;
7 | border-bottom: 1rpx solid #dedede;
8 | margin-bottom: 15rpx;
9 | padding: 20rpx;
10 | }
11 |
12 | .ellipsis {
13 | white-space: nowrap;
14 | text-overflow: ellipsis;
15 | overflow: hidden;
16 | }
17 |
18 | /*特殊按钮*/
19 | button.yellow {
20 | color: #fff;
21 | background: #feb70f;
22 | }
23 | button.yellow:after {
24 | border-color: rgba(255, 133, 111, 0.3);
25 | }
26 | button.yellow.hover {
27 | background: #e4b203;
28 | }
29 | button.yellow.disabled {
30 | background: #f4e283;
31 | }
32 |
--------------------------------------------------------------------------------
/a-takeaway-demo-of-wxapp-master/imgs/index/icon_1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tangwaikei/wx-app/5f45b28fc197f662b1e8c84eb2b3655d8cbd97a8/a-takeaway-demo-of-wxapp-master/imgs/index/icon_1.jpg
--------------------------------------------------------------------------------
/a-takeaway-demo-of-wxapp-master/imgs/index/icon_10.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tangwaikei/wx-app/5f45b28fc197f662b1e8c84eb2b3655d8cbd97a8/a-takeaway-demo-of-wxapp-master/imgs/index/icon_10.jpg
--------------------------------------------------------------------------------
/a-takeaway-demo-of-wxapp-master/imgs/index/icon_11.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tangwaikei/wx-app/5f45b28fc197f662b1e8c84eb2b3655d8cbd97a8/a-takeaway-demo-of-wxapp-master/imgs/index/icon_11.jpg
--------------------------------------------------------------------------------
/a-takeaway-demo-of-wxapp-master/imgs/index/icon_12.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tangwaikei/wx-app/5f45b28fc197f662b1e8c84eb2b3655d8cbd97a8/a-takeaway-demo-of-wxapp-master/imgs/index/icon_12.jpg
--------------------------------------------------------------------------------
/a-takeaway-demo-of-wxapp-master/imgs/index/icon_13.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tangwaikei/wx-app/5f45b28fc197f662b1e8c84eb2b3655d8cbd97a8/a-takeaway-demo-of-wxapp-master/imgs/index/icon_13.jpg
--------------------------------------------------------------------------------
/a-takeaway-demo-of-wxapp-master/imgs/index/icon_14.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tangwaikei/wx-app/5f45b28fc197f662b1e8c84eb2b3655d8cbd97a8/a-takeaway-demo-of-wxapp-master/imgs/index/icon_14.jpg
--------------------------------------------------------------------------------
/a-takeaway-demo-of-wxapp-master/imgs/index/icon_15.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tangwaikei/wx-app/5f45b28fc197f662b1e8c84eb2b3655d8cbd97a8/a-takeaway-demo-of-wxapp-master/imgs/index/icon_15.jpg
--------------------------------------------------------------------------------
/a-takeaway-demo-of-wxapp-master/imgs/index/icon_16.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tangwaikei/wx-app/5f45b28fc197f662b1e8c84eb2b3655d8cbd97a8/a-takeaway-demo-of-wxapp-master/imgs/index/icon_16.jpg
--------------------------------------------------------------------------------
/a-takeaway-demo-of-wxapp-master/imgs/index/icon_2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tangwaikei/wx-app/5f45b28fc197f662b1e8c84eb2b3655d8cbd97a8/a-takeaway-demo-of-wxapp-master/imgs/index/icon_2.jpg
--------------------------------------------------------------------------------
/a-takeaway-demo-of-wxapp-master/imgs/index/icon_3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tangwaikei/wx-app/5f45b28fc197f662b1e8c84eb2b3655d8cbd97a8/a-takeaway-demo-of-wxapp-master/imgs/index/icon_3.jpg
--------------------------------------------------------------------------------
/a-takeaway-demo-of-wxapp-master/imgs/index/icon_4.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tangwaikei/wx-app/5f45b28fc197f662b1e8c84eb2b3655d8cbd97a8/a-takeaway-demo-of-wxapp-master/imgs/index/icon_4.jpg
--------------------------------------------------------------------------------
/a-takeaway-demo-of-wxapp-master/imgs/index/icon_5.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tangwaikei/wx-app/5f45b28fc197f662b1e8c84eb2b3655d8cbd97a8/a-takeaway-demo-of-wxapp-master/imgs/index/icon_5.jpg
--------------------------------------------------------------------------------
/a-takeaway-demo-of-wxapp-master/imgs/index/icon_6.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tangwaikei/wx-app/5f45b28fc197f662b1e8c84eb2b3655d8cbd97a8/a-takeaway-demo-of-wxapp-master/imgs/index/icon_6.jpg
--------------------------------------------------------------------------------
/a-takeaway-demo-of-wxapp-master/imgs/index/icon_7.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tangwaikei/wx-app/5f45b28fc197f662b1e8c84eb2b3655d8cbd97a8/a-takeaway-demo-of-wxapp-master/imgs/index/icon_7.jpg
--------------------------------------------------------------------------------
/a-takeaway-demo-of-wxapp-master/imgs/index/icon_8.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tangwaikei/wx-app/5f45b28fc197f662b1e8c84eb2b3655d8cbd97a8/a-takeaway-demo-of-wxapp-master/imgs/index/icon_8.jpg
--------------------------------------------------------------------------------
/a-takeaway-demo-of-wxapp-master/imgs/index/icon_9.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tangwaikei/wx-app/5f45b28fc197f662b1e8c84eb2b3655d8cbd97a8/a-takeaway-demo-of-wxapp-master/imgs/index/icon_9.jpg
--------------------------------------------------------------------------------
/a-takeaway-demo-of-wxapp-master/imgs/index/icon_location.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tangwaikei/wx-app/5f45b28fc197f662b1e8c84eb2b3655d8cbd97a8/a-takeaway-demo-of-wxapp-master/imgs/index/icon_location.png
--------------------------------------------------------------------------------
/a-takeaway-demo-of-wxapp-master/imgs/index/icon_search.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tangwaikei/wx-app/5f45b28fc197f662b1e8c84eb2b3655d8cbd97a8/a-takeaway-demo-of-wxapp-master/imgs/index/icon_search.png
--------------------------------------------------------------------------------
/a-takeaway-demo-of-wxapp-master/imgs/shop/cart.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tangwaikei/wx-app/5f45b28fc197f662b1e8c84eb2b3655d8cbd97a8/a-takeaway-demo-of-wxapp-master/imgs/shop/cart.png
--------------------------------------------------------------------------------
/a-takeaway-demo-of-wxapp-master/imgs/shop/empty.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tangwaikei/wx-app/5f45b28fc197f662b1e8c84eb2b3655d8cbd97a8/a-takeaway-demo-of-wxapp-master/imgs/shop/empty.png
--------------------------------------------------------------------------------
/a-takeaway-demo-of-wxapp-master/imgs/shop/plus.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tangwaikei/wx-app/5f45b28fc197f662b1e8c84eb2b3655d8cbd97a8/a-takeaway-demo-of-wxapp-master/imgs/shop/plus.png
--------------------------------------------------------------------------------
/a-takeaway-demo-of-wxapp-master/imgs/tabBar/home_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tangwaikei/wx-app/5f45b28fc197f662b1e8c84eb2b3655d8cbd97a8/a-takeaway-demo-of-wxapp-master/imgs/tabBar/home_1.png
--------------------------------------------------------------------------------
/a-takeaway-demo-of-wxapp-master/imgs/tabBar/home_2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tangwaikei/wx-app/5f45b28fc197f662b1e8c84eb2b3655d8cbd97a8/a-takeaway-demo-of-wxapp-master/imgs/tabBar/home_2.png
--------------------------------------------------------------------------------
/a-takeaway-demo-of-wxapp-master/imgs/tabBar/mine_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tangwaikei/wx-app/5f45b28fc197f662b1e8c84eb2b3655d8cbd97a8/a-takeaway-demo-of-wxapp-master/imgs/tabBar/mine_1.png
--------------------------------------------------------------------------------
/a-takeaway-demo-of-wxapp-master/imgs/tabBar/mine_2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tangwaikei/wx-app/5f45b28fc197f662b1e8c84eb2b3655d8cbd97a8/a-takeaway-demo-of-wxapp-master/imgs/tabBar/mine_2.png
--------------------------------------------------------------------------------
/a-takeaway-demo-of-wxapp-master/page/index/index.js:
--------------------------------------------------------------------------------
1 | var app = getApp();
2 | var server = require('../../utils/server');
3 | Page({
4 | data: {
5 | filterId: 1,
6 | address: '广州天河大厦',
7 | banners: [
8 | {
9 | id: 3,
10 | img: 'http://wxapp.im20.com.cn/impublic/waimai/imgs/index/banner_3.jpg',
11 | url: '',
12 | name: '百亿巨惠任你抢'
13 | },
14 | {
15 | id: 1,
16 | img: 'http://wxapp.im20.com.cn/impublic/waimai/imgs/index/banner_1.jpg',
17 | url: '',
18 | name: '告别午高峰'
19 | },
20 | {
21 | id: 2,
22 | img: 'http://wxapp.im20.com.cn/impublic/waimai/imgs/index/banner_2.jpg',
23 | url: '',
24 | name: '金牌好店'
25 | }
26 | ],
27 | icons: [
28 | [
29 | {
30 | id: 1,
31 | img: '/imgs/index/icon_1.jpg',
32 | name: '美食',
33 | url: ''
34 | },
35 | {
36 | id: 2,
37 | img: '/imgs/index/icon_2.jpg',
38 | name: '超市',
39 | url: ''
40 | },
41 | {
42 | id: 3,
43 | img: '/imgs/index/icon_3.jpg',
44 | name: '鲜果购',
45 | url: ''
46 | },
47 | {
48 | id: 4,
49 | img: '/imgs/index/icon_4.jpg',
50 | name: '下午茶',
51 | url: ''
52 | },
53 | {
54 | id: 5,
55 | img: '/imgs/index/icon_5.jpg',
56 | name: '正餐优选',
57 | url: ''
58 | },
59 | {
60 | id: 6,
61 | img: '/imgs/index/icon_6.jpg',
62 | name: '外卖专送',
63 | url: ''
64 | },
65 | {
66 | id: 7,
67 | img: '/imgs/index/icon_7.jpg',
68 | name: '饮品站',
69 | url: ''
70 | },
71 | {
72 | id: 8,
73 | img: '/imgs/index/icon_8.jpg',
74 | name: '小吃馆',
75 | url: ''
76 | }
77 | ],
78 | [
79 | {
80 | id: 9,
81 | img: '/imgs/index/icon_9.jpg',
82 | name: '新商家',
83 | url: ''
84 | },
85 | {
86 | id: 10,
87 | img: '/imgs/index/icon_10.jpg',
88 | name: '免配送费',
89 | url: ''
90 | },
91 | {
92 | id: 11,
93 | img: '/imgs/index/icon_11.jpg',
94 | name: '鲜花蛋糕',
95 | url: ''
96 | },
97 | {
98 | id: 12,
99 | img: '/imgs/index/icon_12.jpg',
100 | name: '名气餐厅',
101 | url: ''
102 | },
103 | {
104 | id: 13,
105 | img: '/imgs/index/icon_13.jpg',
106 | name: '异国料理',
107 | url: ''
108 | },
109 | {
110 | id: 14,
111 | img: '/imgs/index/icon_14.jpg',
112 | name: '家常菜',
113 | url: ''
114 | },
115 | {
116 | id: 15,
117 | img: '/imgs/index/icon_15.jpg',
118 | name: '能量西餐',
119 | url: ''
120 | },
121 | {
122 | id: 16,
123 | img: '/imgs/index/icon_16.jpg',
124 | name: '无辣不欢',
125 | url: ''
126 | }
127 | ]
128 | ],
129 | shops: app.globalData.shops
130 | },
131 | onLoad: function () {
132 | var self = this;
133 | wx.getLocation({
134 | type: 'gcj02',
135 | success: function (res) {
136 | var latitude = res.latitude;
137 | var longitude = res.longitude;
138 | server.getJSON('dwq/WxAppApi/location.php', {
139 | latitude: latitude,
140 | longitude: longitude
141 | }, function (res) {
142 | console.log(res)
143 | if (res.data.status != -1) {
144 | self.setData({
145 | address: res.data.result.address_component.street_number
146 | });
147 | } else {
148 | self.setData({
149 | address: '定位失败'
150 | });
151 | }
152 | });
153 | }
154 | });
155 | },
156 | onShow: function () {
157 | },
158 | onScroll: function (e) {
159 | if (e.detail.scrollTop > 100 && !this.data.scrollDown) {
160 | this.setData({
161 | scrollDown: true
162 | });
163 | } else if (e.detail.scrollTop < 100 && this.data.scrollDown) {
164 | this.setData({
165 | scrollDown: false
166 | });
167 | }
168 | },
169 | tapSearch: function () {
170 | wx.navigateTo({url: 'search'});
171 | },
172 | toNearby: function () {
173 | var self = this;
174 | self.setData({
175 | scrollIntoView: 'nearby'
176 | });
177 | self.setData({
178 | scrollIntoView: null
179 | });
180 | },
181 | tapFilter: function (e) {
182 | switch (e.target.dataset.id) {
183 | case '1':
184 | this.data.shops.sort(function (a, b) {
185 | return a.id > b.id;
186 | });
187 | break;
188 | case '2':
189 | this.data.shops.sort(function (a, b) {
190 | return a.sales < b.sales;
191 | });
192 | break;
193 | case '3':
194 | this.data.shops.sort(function (a, b) {
195 | return a.distance > b.distance;
196 | });
197 | break;
198 | }
199 | this.setData({
200 | filterId: e.target.dataset.id,
201 | shops: this.data.shops
202 | });
203 | },
204 | tapBanner: function (e) {
205 | var name = this.data.banners[e.target.dataset.id].name;
206 | wx.showModal({
207 | title: '提示',
208 | content: '您点击了“' + name + '”活动链接,活动页面暂未完成!',
209 | showCancel: false
210 | });
211 | }
212 | });
213 |
214 |
--------------------------------------------------------------------------------
/a-takeaway-demo-of-wxapp-master/page/index/index.json:
--------------------------------------------------------------------------------
1 | {}
--------------------------------------------------------------------------------
/a-takeaway-demo-of-wxapp-master/page/index/index.wxml:
--------------------------------------------------------------------------------
1 |
2 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 | {{icon.name}}
28 |
29 |
30 |
31 |
32 |
33 | 附近商家
34 |
35 | 综合排序↓
36 |
37 | 销量最高↓
38 |
39 | 距离最近↓
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 | {{item.restaurant_name}}
48 |
49 | 起送价:¥{{item.start_price}}
50 | 配送费:¥{{item.send_price}}
51 | {{item.send_time}}
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
--------------------------------------------------------------------------------
/a-takeaway-demo-of-wxapp-master/page/index/index.wxss:
--------------------------------------------------------------------------------
1 | page {
2 | height: 100%;
3 | }
4 | .container {
5 | height: 100%;
6 | }
7 | scroll-view {
8 | height: 100%;
9 | }
10 |
11 | .header {
12 | position: fixed;
13 | display: -webkit-flex;
14 | left: 0;
15 | top: 0;
16 | width: 100%;
17 | padding: 20rpx;
18 | box-sizing: border-box;
19 | z-index: 1;
20 | -webkit-transition: background 0.5s ease-in-out;
21 | }
22 | .header.scrolled {
23 | background: #feb70f;
24 | }
25 | .header .icon {
26 | width: 40rpx;
27 | height: 40rpx;
28 | vertical-align: top;
29 | }
30 | .header .location {
31 | color: #fff;
32 | font-size: 30rpx;
33 | line-height: 40rpx;
34 | min-width: 100rpx;
35 | max-width: 340rpx;
36 | padding: 10rpx 20rpx 10rpx 10rpx;
37 | border-radius: 30rpx;
38 | background: rgba(0,0,0,0.3);
39 | margin-right: 20rpx;
40 | vertical-align: middle;
41 | }
42 | .header .search {
43 | -webkit-flex: 1;
44 | color: #888;
45 | font-size: 30rpx;
46 | line-height: 40rpx;
47 | padding: 10rpx;
48 | border-radius: 30rpx;
49 | background: #fff;
50 | /*border-bottom: 1rpx solid #aaa;*/
51 | }
52 |
53 | .banner {
54 | height: 330rpx;
55 | }
56 | .banner image {
57 | width: 100%;
58 | height: 100%;
59 | }
60 |
61 | .icons {
62 | height: 370rpx;
63 | padding: 20rpx 10rpx;
64 | padding-bottom: 0;
65 | }
66 | .icons swiper-item {
67 | width: 100%;
68 | /*display: -webkit-flex;*/
69 | /*flex-direction: row;*/
70 | /*flex-wrap: wrap;*/
71 | /*justify-content: center;*/
72 | }
73 | .icons .icon {
74 | float: left;
75 | display: -webkit-flex;
76 | flex-direction: column;
77 | flex-wrap: wrap;
78 | width: 25%;
79 | text-align: center;
80 | margin: 10rpx 0;
81 | }
82 | .icons .icon image {
83 | margin: 0 auto;
84 | width: 100rpx;
85 | height: 100rpx;
86 | }
87 | .icons .icon text {
88 | color: #000;
89 | font-size: 24rpx;
90 | line-height: 2;
91 | }
92 |
93 | .section-big {
94 | padding: 20rpx;
95 | }
96 | .section-big .title {
97 | position: relative;
98 | text-align: center;
99 | font-size: 32rpx;
100 | font-weight: bold;
101 | line-height: 2;
102 | margin-bottom: 20rpx;
103 | }
104 | .section-big .title:before {
105 | content: " ";
106 | position: absolute;
107 | left: 50%;
108 | top: 50%;
109 | margin-left: -180rpx;
110 | width: 100rpx;
111 | height: 1rpx;
112 | background: #000;
113 | }
114 | .section-big .title:after {
115 | content: " ";
116 | position: absolute;
117 | left: 50%;
118 | top: 50%;
119 | margin-left: 80rpx;
120 | width: 100rpx;
121 | height: 1rpx;
122 | background: #000;
123 | }
124 |
125 | .discount .content {
126 | width: 100%;
127 | height: 450rpx;
128 | }
129 |
130 | .preferred .content {
131 | width: 100%;
132 | height: 556rpx;
133 | }
134 |
135 | .special .content {
136 | width: 100%;
137 | height: 181rpx;
138 | }
139 |
140 | .nearby {
141 | padding-left: 0;
142 | padding-right: 0;
143 | }
144 | .nearby .filters {
145 | display: -webkit-flex;
146 | border-top: 1rpx solid #efefef;
147 | }
148 | .nearby .filters .filter {
149 | -webkit-flex: 1;
150 | text-align: center;
151 | color: #696969;
152 | font-size: 30rpx;
153 | line-height: 3;
154 | }
155 | .nearby .filters .filter .v {
156 | display: none;
157 | }
158 | .nearby .filters .filter.active {
159 | color: #000;
160 | font-weight: bold;
161 | }
162 | .nearby .filters .filter.active .v {
163 | display: inline-block;
164 | }
165 | .nearby .shop {
166 | padding: 10rpx 0;
167 | border-top: 1rpx solid #efefef;
168 | }
169 | .nearby .shop image {
170 | width: 100%;
171 | height: 266rpx;
172 | }
173 |
174 | .loading {
175 | font-size: 32rpx;
176 | text-align: center;
177 | line-height: 2;
178 | margin-bottom: 20rpx;
179 | }
180 | .shop{
181 | display: inline-block;
182 | width: 100%;
183 | height: 200rpx;
184 | }
185 | .shop-container{
186 | font-size: 14px;
187 | height: 100%;
188 | width: 100%;
189 | }
190 | .shop-logo{
191 | float: left;
192 | width: 200rpx;
193 | height: 100%;
194 | background-size: cover;
195 | }
196 | .shop-detail{
197 | height:100%;
198 | overflow: hidden;
199 | padding-left: 30rpx;
200 | }
201 | .shop-name{
202 | color:#313131;
203 | font-size: 16px;
204 | margin-bottom: 15rpx;
205 | line-height: 30px;
206 | }
207 | .shop-data{
208 | color:#707070;
209 | }
210 | .start-price{
211 | float:left;
212 | margin-right: 50rpx;
213 | }
214 | .send-price{
215 | float: left;
216 | }
217 | .send-time{
218 | float: right;
219 | margin-right: 10rpx;
220 | }
221 | .send-time-icon{
222 | background-image: url(http://xs01.meituan.net/waimai_web/img/sprite/icons_559f3531_1.png);
223 | display: inline-block;
224 | background-position: -272px -426px;
225 | background-repeat: no-repeat;
226 | width:14px;
227 | height: 14px;
228 | }
229 | page{
230 | font-family: "Microsoft Yahei, Arial, Helvetica, sans-serif";
231 | font-size: 12px;
232 | }
--------------------------------------------------------------------------------
/a-takeaway-demo-of-wxapp-master/page/index/search.js:
--------------------------------------------------------------------------------
1 | var app = getApp();
2 | var server = require('../../utils/server');
3 | Page({
4 | data: {
5 | filterId: 1,
6 | searchWords: '',
7 | placeholder: '烤鸭',
8 | shops: app.globalData.shops
9 | },
10 | onLoad: function () {
11 | var self = this;
12 | wx.getLocation({
13 | type: 'gcj02',
14 | success: function (res) {
15 | var latitude = res.latitude;
16 | var longitude = res.longitude;
17 | server.getJSON('/waimai/api/location.php', {
18 | latitude: latitude,
19 | longitude: longitude
20 | }, function (res) {
21 | console.log(res)
22 | if (res.data.status != -1) {
23 | self.setData({
24 | address: res.data.result.address_component.street_number
25 | });
26 | } else {
27 | self.setData({
28 | address: '定位失败'
29 | });
30 | }
31 | });
32 | }
33 | })
34 | },
35 | onShow: function () {
36 | //this.setData({
37 | // showResult: false
38 | //});
39 | },
40 | inputSearch: function (e) {
41 | this.setData({
42 | searchWords: e.detail.value
43 | });
44 | },
45 | doSearch: function() {
46 | this.setData({
47 | showResult: true
48 | });
49 | },
50 | tapFilter: function (e) {
51 | switch (e.target.dataset.id) {
52 | case '1':
53 | this.data.shops.sort(function (a, b) {
54 | return a.id > b.id;
55 | });
56 | break;
57 | case '2':
58 | this.data.shops.sort(function (a, b) {
59 | return a.sales < b.sales;
60 | });
61 | break;
62 | case '3':
63 | this.data.shops.sort(function (a, b) {
64 | return a.distance > b.distance;
65 | });
66 | break;
67 | }
68 | this.setData({
69 | filterId: e.target.dataset.id,
70 | shops: this.data.shops
71 | });
72 | }
73 | });
74 |
75 |
--------------------------------------------------------------------------------
/a-takeaway-demo-of-wxapp-master/page/index/search.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarTitleText": "搜索餐厅"
3 | }
--------------------------------------------------------------------------------
/a-takeaway-demo-of-wxapp-master/page/index/search.wxml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
13 | 综合排序↓
14 |
15 | 销量最高↓
16 |
17 | 距离最近↓
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 | 努力加载中…
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/a-takeaway-demo-of-wxapp-master/page/index/search.wxss:
--------------------------------------------------------------------------------
1 | .header {
2 | display: -webkit-flex;
3 | padding: 20rpx;
4 | background: #fff;
5 | }
6 |
7 | .header .icon {
8 | width: 40rpx;
9 | height: 40rpx;
10 | vertical-align: top;
11 | }
12 |
13 | .header .search {
14 | -webkit-flex: 1;
15 | color: #000;
16 | font-size: 30rpx;
17 | line-height: 40rpx;
18 | padding: 10rpx;
19 | border-radius: 10rpx;
20 | background: #eee;
21 | }
22 |
23 | .header .search .icon {
24 | float: left;
25 | margin: 1rpx 5rpx 0 0;
26 | }
27 |
28 | .header button {
29 | margin-left: 20rpx;
30 | font-size: 30rpx;
31 | }
32 |
33 | .header input {
34 | height: 30rpx;
35 | min-height: 40rpx;
36 | }
37 |
38 | .result {
39 | padding: 0;
40 | }
41 |
42 | .result .filters {
43 | z-index: 1;
44 | position: relative;
45 | display: -webkit-flex;
46 | border-top: 1rpx solid #efefef;
47 | border-bottom: 1rpx solid #efefef;
48 | background: #fff;
49 | }
50 |
51 | .result .filters .filter {
52 | -webkit-flex: 1;
53 | text-align: center;
54 | color: #696969;
55 | font-size: 30rpx;
56 | line-height: 3;
57 | }
58 |
59 | .result .filters .filter .v {
60 | display: none;
61 | }
62 |
63 | .result .filters .filter.active {
64 | color: #000;
65 | font-weight: bold;
66 | }
67 |
68 | .result .filters .filter.active .v {
69 | display: inline-block;
70 | }
71 |
72 | .result scroll-view {
73 | position: absolute;
74 | top: 200rpx;
75 | bottom: 0;
76 | left: 0;
77 | right: 0;
78 | background: #fff;
79 | }
80 |
81 | .result .shop {
82 | padding: 10rpx 0;
83 | border-bottom: 1rpx solid #efefef;
84 | }
85 |
86 | .result .shop image {
87 | width: 100%;
88 | height: 266rpx;
89 | }
90 |
91 | .loading {
92 | font-size: 32rpx;
93 | text-align: center;
94 | line-height: 2;
95 | margin-bottom: 20rpx;
96 | }
--------------------------------------------------------------------------------
/a-takeaway-demo-of-wxapp-master/page/mine/mine.js:
--------------------------------------------------------------------------------
1 | var app = getApp();
2 | var server = require('../../utils/server');
3 | Page({
4 | data: {},
5 | onLoad: function () {
6 | var that = this
7 | //调用应用实例的方法获取全局数据
8 | app.getUserInfo(function(userInfo){
9 | //更新数据
10 | that.setData({
11 | userInfo: userInfo
12 | });
13 | that.update();
14 | console.log(userInfo)
15 | });
16 | },
17 | onShow: function () {
18 | this.setData({
19 | userInfo: app.globalData.userInfo
20 | });
21 | console.log(this.data.userInfo);
22 | }
23 | });
24 |
25 |
--------------------------------------------------------------------------------
/a-takeaway-demo-of-wxapp-master/page/mine/mine.json:
--------------------------------------------------------------------------------
1 | {}
--------------------------------------------------------------------------------
/a-takeaway-demo-of-wxapp-master/page/mine/mine.wxml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 | 我的订单
8 | 我的好友
9 | 我的收藏
10 | 我的地址
11 |
12 |
13 | 我的钱包余额:¥0
14 |
15 |
16 | 帮助与反馈
17 |
18 |
19 |
--------------------------------------------------------------------------------
/a-takeaway-demo-of-wxapp-master/page/mine/mine.wxss:
--------------------------------------------------------------------------------
1 | .header {
2 | background: #feb70f;
3 | padding: 30rpx;
4 | }
5 | .header .avatar {
6 | display: block;
7 | margin: 0 auto;
8 | width: 160rpx;
9 | height: 160rpx;
10 | border-radius: 50%;
11 | border: 2px solid #fee767;
12 | }
13 | .header .nickname {
14 | color: #000;
15 | font-size: 22px;
16 | line-height: 2.4;
17 | text-align: center;
18 | }
19 |
20 | .section {
21 | padding: 0;
22 | color: #2e2e2e;
23 | font-size: 30rpx;
24 | }
25 | .section .line {
26 | margin-left: 30rpx;
27 | padding-right: 30rpx;
28 | line-height: 3;
29 | border-bottom: 1px solid #efefef;
30 | }
31 | .section .line:last-child {
32 | border-bottom: none;
33 | }
34 | .section .line:before {
35 | content: '>';
36 | float: right;
37 | color: #aaa;
38 | margin-left: 20rpx;
39 | }
40 | .section .line .tl {
41 | float: right;
42 | color: #aaa;
43 | }
--------------------------------------------------------------------------------
/a-takeaway-demo-of-wxapp-master/page/order/order.js:
--------------------------------------------------------------------------------
1 | var app = getApp()
2 | var common = require('../../utils/server.js');
3 | Page({
4 | data: {
5 | orderList: [],
6 | count: 0,
7 | total: 0,
8 | pay: 0,
9 | is_empty: false
10 | },
11 | onLoad: function (option) {
12 | if(option.pay){
13 | var pay = option.pay;
14 | if(parseFloat(option.total) > 0)
15 | var is_empty = true;
16 | else
17 | var is_empty = false;
18 | }
19 | else{
20 | var pay = 0;
21 | }
22 | var orderList = wx.getStorageSync('orderList');
23 | var cartList = []
24 | for(var index in orderList.cartList)
25 | {
26 | if(pay == 0) var is_empty = false;
27 | if(!common.isEmptyObject(orderList.cartList[index])){
28 |
29 | var total = 0;
30 | if(pay == 0) is_empty = true;
31 | for(var key in orderList.cartList[index]){
32 | total += orderList.cartList[index][key].num * orderList.cartList[index][key].price;
33 | }
34 | var orderDetail = {
35 | name: orderList.cartList[index][0].shopName,
36 | shopId: orderList.cartList[index][0].shopId,
37 | order: orderList.cartList[index],
38 | total: total,
39 | pay: orderList.cartList[index][0].pay,
40 | }
41 | cartList.push(orderDetail);
42 | }
43 | }
44 | this.setData({
45 | total:orderList.total,
46 | count: orderList.count,
47 | orderList: cartList,
48 | pay: pay,
49 | is_empty : is_empty
50 | });
51 | },
52 | onShow: function() {},
53 | confirm: function(){
54 | var templateData = this.data.orderList;
55 | console.log(templateData)
56 | var res = wx.getStorageSync('orderList');
57 | if(res){
58 | var cartList = res.cartList;
59 | }
60 | wx.showToast({
61 | title: '正在为您提交订单',
62 | icon: 'loading',
63 | mask: true,
64 | success: function(){
65 | wx.request({
66 | url: 'https://test2.zuzuche.com/dwq/WxAppApi/sendTemplate.php',
67 | data: {
68 | rd_session: app.rd_session,
69 | nick_name: app.globalData.userInfo.nickName,
70 | avatar_url: app.globalData.userInfo.avatarUrl,
71 | data: templateData,
72 | },
73 | header: {
74 | 'content-type': 'application/json'
75 | },
76 | success: function(res)
77 | {
78 | console.log(res)
79 | if(res.data.errcode){
80 | wx.showModal({
81 | showCancel: false,
82 | title: '恭喜',
83 | content: '订单发送成功!下订单过程顺利完成,你看到的费用暂不包括配送费以及优惠。',
84 | success: function(res) {
85 | if (res.confirm) {
86 | wx.removeStorageSync('orderList');
87 | wx.navigateBack();
88 | }
89 | }
90 | })
91 | // for(var index in cartList){
92 | // if(typeof cartList[index] !== null){
93 | // for(var key in cartList[index]){
94 | // cartList[index]['pay'] = 1;
95 | // }
96 | // }
97 | // }
98 | // wx.setStorage({
99 | // key: 'orderList',
100 | // data: {
101 | // cartList: cartList,
102 | // count: res.count,
103 | // total: res.total,
104 | // }
105 | // });
106 | }
107 | else{
108 | console.log('下单失败');
109 | wx.showModal({
110 | showCancel: false,
111 | title: '提交订单失败',
112 | content: '请在重新授权后提交订单',
113 | success: function(res){
114 | if(res.confirm){
115 | app.getUserInfo();
116 | }
117 | }
118 | })
119 | }
120 | }
121 | })
122 | }
123 | })
124 | }
125 | });
126 |
127 |
--------------------------------------------------------------------------------
/a-takeaway-demo-of-wxapp-master/page/order/order.json:
--------------------------------------------------------------------------------
1 | {}
--------------------------------------------------------------------------------
/a-takeaway-demo-of-wxapp-master/page/order/order.wxml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 | (未提交)
8 |
9 | {{item.name}}
10 |
11 |
12 |
13 |
14 |
15 | {{order.name}}
16 | x{{order.num}}
17 |
18 |
19 |
20 | 合计
21 | ¥{{item.total}}
22 |
23 |
24 |
25 |
26 | 合计:¥{{total}}
27 | 去结算
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/a-takeaway-demo-of-wxapp-master/page/order/order.wxss:
--------------------------------------------------------------------------------
1 | .container{
2 | background: #fff;
3 | }
4 | page{
5 | font-family: "Microsoft Yahei, Arial, Helvetica, sans-serif";
6 | font-size: 15px;
7 | }
8 | .header{
9 | display: block;
10 | margin: 0 auto;
11 | height: 120rpx;
12 | background: #feb70f;
13 | padding: 30rpx;
14 | color: #000;
15 | line-height: 2.4;
16 | }
17 | .title{
18 | text-align: center;
19 | font-size: 20px;
20 | }
21 | .order{
22 | display: inline-block;
23 | width: 100%;
24 | height: auto;
25 | }
26 | .order-container{
27 | width: 100%;
28 | height: 60rpx;
29 | margin-top:2px;
30 | }
31 | .inside-container{
32 | width: 70%;
33 | height:100%;
34 | font-size: 15px;
35 | font-family: "Microsoft Yahei, Arial, Helvetica, sans-serif";
36 | float: right;
37 | }
38 | .order-name{
39 | padding-left: 15px;
40 | float: left;
41 | padding-top: 5px;
42 | }
43 | .order-count{
44 | padding-left: 170px;
45 | padding-top: 5px;
46 | }
47 | .order-total{
48 | padding-left:110px;
49 | padding-top: 5px;
50 | }
51 | .shop-name{
52 | font-weight: bold;
53 | font-size: 18px;
54 | font-family: "Microsoft Yahei, Arial, Helvetica, sans-serif";
55 | width: 100%;
56 | height: 50rpx;
57 | padding-left: 10px;
58 | padding-top:10px;
59 | }
60 | .line{
61 | border-bottom: 1px dashed #000;
62 | width: 62%;
63 | height: 1px;
64 | margin-left: 3%;
65 | padding-right: 15%
66 | }
67 | .line-cut{
68 | border-bottom: 1px dashed #000;
69 | width: 80%;
70 | height: 1px;
71 | margin-left: 3%;
72 | padding-right: 15%
73 | }
74 | .total{
75 | width: 60%;
76 | float: right;
77 | height: 50rpx;
78 | font-size: 15px;
79 | }
80 | .confirm-btn{
81 | width: 135rpx;
82 | height: 66rpx;
83 | float: right;
84 | margin-right: 20px;
85 | color: #fff;
86 | background-color:#feb70f;
87 | font-size: 15px;
88 | clear: both;
89 | text-align: center;
90 | border-radius: 8%;
91 | line-height: 36px;
92 | }
93 | .img-container{
94 | width: 100%;
95 | height: 335px;
96 | }
97 | .empty-container{
98 | margin-left: 145px;
99 | margin-top: 200px;
100 | }
101 | .empty{
102 | width: 100px;
103 | height: 100px;
104 | }
105 | .confirm-container{
106 | width: 100%;
107 | display: inline-block;
108 | margin-bottom: 5px;
109 | margin-top: 10px;
110 | }
111 | .left-container{
112 | float: left;
113 | margin-left: 69px;
114 | line-height: 35px;
115 | font-size: 15px;
116 | }
117 | .right-container{
118 | float: left;
119 | margin-left: 85px;
120 | }
121 | .tip{
122 | display: inline-block;
123 | color: orangered;
124 | margin-left: 20px;
125 | }
--------------------------------------------------------------------------------
/a-takeaway-demo-of-wxapp-master/page/shop/shop.js:
--------------------------------------------------------------------------------
1 | var app = getApp();
2 | var server = require('../../utils/server.js');
3 | Page({
4 | data: {
5 | cart: {
6 | count: 0,
7 | total: 0
8 | },
9 | cartList : [],
10 | localList: [],
11 | showCartDetail: false,
12 | defaultImg: 'http://global.zuzuche.com/assets/images/common/zzc-logo.png',
13 | },
14 | onLoad: function (options) {
15 | var shopId = options.id;
16 | var shop = server.selectedShopDetail(shopId) // throw Exception
17 | this.setData({
18 | shopId: shopId,
19 | shop: shop
20 | })
21 | var res = wx.getStorageSync('orderList');
22 | if(res)
23 | {
24 | this.setData({
25 | cart: {
26 | count: res.count,
27 | total: res.total
28 | }
29 | });
30 | if(!server.isEmptyObject(res.cartList))
31 | {
32 | this.setData({
33 | cartList:res.cartList,
34 | localList: server.filterEmptyObject(res.cartList)
35 | })
36 | }
37 | }
38 | if(typeof this.data.cartList[this.data.shopId] == 'undefined' || server.isEmptyObject(this.data.cartList[this.data.shopId]))
39 | {
40 | var cartList = this.data.cartList;
41 | cartList[this.data.shopId] = [];
42 | this.setData({
43 | cartList: cartList
44 | })
45 | }
46 | console.log(this.data.localList, this.data.cartList)
47 | },
48 | onShow: function () {
49 | this.setData({
50 | classifySeleted: 1
51 | });
52 | },
53 | checkOrderSame: function(name){
54 | var list = this.data.cartList[this.data.shopId];
55 | for(var index in list){
56 | if(list[index].name === name){
57 | return index;
58 | }
59 | }
60 | return false;
61 | },
62 | tapAddCart: function (e) {
63 | var price = parseFloat(e.target.dataset.price);
64 | var name = e.target.dataset.name;
65 | var img = e.target.dataset.pic;
66 | var list = this.data.cartList;
67 | var sortedList = [];
68 | var index;
69 | if(index = this.checkOrderSame(name)){
70 | sortedList = list[this.data.shopId][index];
71 | var num = list[this.data.shopId][index].num;
72 | list[this.data.shopId][index].num = num + 1;
73 | }
74 | else{
75 | var order = {
76 | "price" : price,
77 | "num" : 1,
78 | "name": name,
79 | 'img': img,
80 | "shopId": this.data.shopId,
81 | "shopName": this.data.shop.restaurant_name,
82 | "pay": 0,
83 | }
84 | list[this.data.shopId].push(order);
85 | sortedList = order;
86 | }
87 | this.setData({
88 | cartList: list,
89 | localList: server.filterEmptyObject(list)
90 | });
91 | this.addCount( sortedList);
92 | },
93 | tapReduceCart: function (e) {
94 | var name = e.target.dataset.name;
95 | var price = parseFloat(e.target.dataset.price);
96 | var list = this.data.cartList;
97 | var index, sortedList = [];
98 | if(index = this.checkOrderSame(name)){
99 | var num = list[this.data.shopId][index].num
100 | if(num > 1){
101 | sortedList = list[this.data.shopId][index];
102 | list[this.data.shopId][index].num = num - 1;
103 | }
104 | else{
105 | sortedList = list[this.data.shopId][index]
106 | list[this.data.shopId].splice(index, 1);
107 | }
108 | }
109 | this.setData({
110 | cartList: list,
111 | localList: server.filterEmptyObject(list)
112 | });
113 | this.deduceCount(sortedList);
114 | },
115 | addCount: function (list) {
116 | var count = this.data.cart.count + 1,
117 | total = this.data.cart.total + list.price;
118 | total = Math.round(parseFloat(total));
119 | this.saveCart(count, total);
120 | },
121 | deduceCount: function(list){
122 | var count = this.data.cart.count - 1,
123 | total = this.data.cart.total - list.price;
124 | total = Math.round(parseFloat(total));
125 | this.saveCart(count, total);
126 | },
127 | saveCart: function(count, total){
128 | total = Math.round(parseFloat(total));
129 | if(typeof total == null)
130 | total = 0;
131 | this.setData({
132 | cart: {
133 | count: count,
134 | total: total
135 | }
136 | });
137 | wx.setStorage({
138 | key: 'orderList',
139 | data: {
140 | cartList: this.data.cartList,
141 | count: this.data.cart.count,
142 | total: this.data.cart.total,
143 | }
144 | })
145 | },
146 | follow: function () {
147 | this.setData({
148 | followed: !this.data.followed
149 | });
150 | },
151 | onGoodsScroll: function (e) {
152 | if (e.detail.scrollTop > 10 && !this.data.scrollDown) {
153 | this.setData({
154 | scrollDown: true
155 | });
156 | } else if (e.detail.scrollTop < 10 && this.data.scrollDown) {
157 | this.setData({
158 | scrollDown: false
159 | });
160 | }
161 |
162 | var scale = e.detail.scrollWidth / 570,
163 | scrollTop = e.detail.scrollTop / scale,
164 | h = 0,
165 | classifySeleted,
166 | len = this.data.shop.menu.length;
167 | this.data.shop.menu.forEach(function (classify, i) {
168 | var _h = 70 + classify.menu.length * (46 * 3 + 20 * 2);
169 | if (scrollTop >= h - 100 / scale) {
170 | classifySeleted = classify.id;
171 | }
172 | h += _h;
173 | });
174 | this.setData({
175 | classifySeleted: classifySeleted
176 | });
177 | },
178 | tapClassify: function (e) {
179 | var id = e.target.dataset.id;
180 | console.log(id);
181 | this.setData({
182 | classifyViewed: id
183 | });
184 | console.log(this.data.classifyViewed)
185 | var self = this;
186 | setTimeout(function () {
187 | self.setData({
188 | classifySeleted: id
189 | });
190 | }, 100);
191 | },
192 | showCartDetail: function () {
193 | this.setData({
194 | showCartDetail: !this.data.showCartDetail
195 | });
196 | },
197 | hideCartDetail: function () {
198 | this.setData({
199 | showCartDetail: false
200 | });
201 | },
202 | submit: function (e) {
203 | var total = this.data.cart.total
204 | wx.navigateTo({
205 | url: '/page/order/order?pay=1&total=' + total
206 | })
207 | }
208 | });
209 |
210 |
--------------------------------------------------------------------------------
/a-takeaway-demo-of-wxapp-master/page/shop/shop.json:
--------------------------------------------------------------------------------
1 | {}
--------------------------------------------------------------------------------
/a-takeaway-demo-of-wxapp-master/page/shop/shop.wxml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
12 | {{classify.package}}
13 |
14 |
15 |
16 |
17 | {{classify.package}}
18 |
19 |
20 | {{menu.name}}
21 | 月售{{menu.sales}}单
22 | ¥{{menu.price}} ({{menu.like > 0 ? menu.like : 0}})
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 | {{order.name}}
36 | -
37 | {{order.num}}
38 | +
39 | ¥{{order.price * order.num}}
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 | {{cart.count}}
49 |
50 | ¥{{cart.total}}
51 |
52 |
56 |
57 |
58 |
--------------------------------------------------------------------------------
/a-takeaway-demo-of-wxapp-master/page/shop/shop.wxss:
--------------------------------------------------------------------------------
1 | page {
2 | height: 100%;
3 | overflow: hidden;
4 | }
5 | .container {
6 | height: 100%;
7 | overflow: hidden;
8 | }
9 |
10 | .header {
11 | position: relative;
12 | background: #feb70f;
13 | padding: 20rpx 40rpx;
14 | color: #000;
15 | -webkit-transition: all 0.6s ease-in-out;
16 | }
17 | .header.hidden {
18 | /*-webkit-transform: translate3d(0,-290rpx,0);*/
19 | margin-top: -290rpx;
20 | }
21 | .header .logo {
22 | float: left;
23 | width: 160rpx;
24 | height: 160rpx;
25 | border: 2rpx solid #fff;
26 | border-radius: 50%;
27 | margin-right: 10px;
28 | }
29 | .header .name {
30 | padding-top: 20rpx;
31 | font-size: 36rpx;
32 | line-height: 60rpx;
33 | }
34 | .header .welcome {
35 | color: #333;
36 | font-size: 30rpx;
37 | width: 360rpx;
38 | line-height: 70rpx;
39 | }
40 | .header .follow {
41 | position: absolute;
42 | right: 20px;
43 | top: 50px;
44 | font-size: 30rpx;
45 | line-height: 2;
46 | padding: 0 0.7em;
47 | border: 1rpx solid;
48 | border-radius: 30rpx;
49 | }
50 | .header .line {
51 | clear: both;
52 | width: 100%;
53 | height: 1px;
54 | border-bottom: 1px dashed #000;
55 | padding-top: 20rpx;
56 | }
57 | .header .desc {
58 | color: #333;
59 | font-size: 30rpx;
60 | line-height: 40rpx;
61 | padding-top: 20rpx;
62 | }
63 |
64 | .content-container {
65 | display: -webkit-flex;
66 | height: 100%;
67 | box-sizing: border-box;
68 | padding-bottom: 100rpx;
69 | }
70 | .classify-container {
71 | width: 180rpx;
72 | background: #efefef;
73 | height: 100%;
74 | }
75 | .classify-container .classify {
76 | padding: 50rpx 30rpx;
77 | text-align: center;
78 | border-bottom: 1px dashed #aaa;
79 | }
80 | .classify-container .classify.active {
81 | background: #fff;
82 | }
83 | .classify-container .classify .name {
84 | display: inline-block;
85 | font-size: 30rpx;
86 | color: #646464;
87 | line-height: 1.2;
88 | text-align: left;
89 | pointer-events: none;
90 | }
91 |
92 | .goods-container {
93 | -webkit-flex: 1;
94 | background: #ffffff;
95 | height: 100%;
96 | }
97 | .goods-container .title {
98 | padding: 20rpx 25rpx;
99 | color: #646464;
100 | font-size: 30rpx;
101 | line-height: 30rpx;
102 | background: #f7f7f7;
103 | }
104 | .goods-container .goods {
105 | position: relative;
106 | padding: 20rpx 30rpx;
107 | font-size: 36rpx;
108 | line-height: 40rpx;
109 | border-bottom: 1px solid #f7f7f7;
110 | }
111 | .goods-container .goods .pic {
112 | float: left;
113 | width: 130rpx;
114 | height: 130rpx;
115 | margin-right: 20rpx;
116 | }
117 | .goods-container .goods .name {
118 | color: #000;
119 | font-size: 36rpx;
120 | line-height: 46rpx;
121 | }
122 | .goods-container .goods .sold {
123 | color: #989898;
124 | font-size: 30rpx;
125 | line-height: 46rpx;
126 | }
127 | .goods-container .goods .price {
128 | color: #f45044;
129 | font-size: 36rpx;
130 | line-height: 46rpx;
131 | }
132 | .goods-container .goods .addCart {
133 | position: absolute;
134 | right: 30rpx;
135 | bottom: 30rpx;
136 | width: 64rpx;
137 | height: 64rpx;
138 | background: #feb70f;
139 | border-radius: 50%;
140 | }
141 | .goods-container .goods .addCart image {
142 | pointer-events: none;
143 | position: absolute;
144 | left: 20rpx;
145 | top: 20rpx;
146 | width: 24rpx;
147 | height: 24rpx;
148 | }
149 |
150 | .cart-detail, .cart-detail .mask {
151 | position: absolute;
152 | left: 0;
153 | top: 0;
154 | width: 100%;
155 | height: 100%;
156 | }
157 | .cart-detail .mask {
158 | background: rgba(0,0,0,0.7);
159 | }
160 | .cart-detail .list {
161 | position: absolute;
162 | left: 0;
163 | bottom: 100rpx;
164 | width: 100%;
165 | background: #f7f7f7;
166 | }
167 | .cart-detail .list .item {
168 | color: #333;
169 | font-size: 36rpx;
170 | line-height: 50rpx;
171 | padding: 20rpx;
172 | }
173 | .cart-detail .list .item .name {
174 | -webkit-flex: 1;
175 | }
176 | .cart-detail .list .item .total {
177 | width: 120rpx;
178 | }
179 | .cart-detail .list .item .reduce,
180 | .cart-detail .list .item .add {
181 | font-size: 50rpx;
182 | background: #feb70f;
183 | width: 50rpx;
184 | height: 50rpx;
185 | text-align: center;
186 | border-radius: 50%;
187 | }
188 | .inside-content{
189 | float: left;
190 | }
191 | .cart-detail .list .item .num {
192 | width: 50rpx;
193 | text-align: center;
194 | margin: 0 5rpx;
195 | }
196 | .cart {
197 | display: -webkit-flex;
198 | position: absolute;
199 | left: 0;
200 | bottom: 0;
201 | width: 100%;
202 | height: 100rpx;
203 | background: #fff;
204 | }
205 | .cart .data {
206 | -webkit-flex: 1;
207 | /*border-top: 1rpx solid #e7e7e7;*/
208 | }
209 | .cart .data .icon {
210 | position: absolute;
211 | left: 40rpx;
212 | top: -20rpx;
213 | width: 100rpx;
214 | height: 100rpx;
215 | background: #feb70f;
216 | border-radius: 50%;
217 | }
218 | .cart .data .icon image {
219 | position: absolute;
220 | left: 15rpx;
221 | top: 15rpx;
222 | width: 70rpx;
223 | height: 70rpx;
224 | }
225 | .cart .data .icon .count {
226 | position: absolute;
227 | left: 70rpx;
228 | top: -10rpx;
229 | font-size: 30rpx;
230 | line-height: 40rpx;
231 | padding: 0 12rpx;
232 | color: #fff;
233 | background: #f45044;
234 | border-radius: 20rpx;
235 | }
236 | .cart .data .total {
237 | color: #f45044;
238 | font-size: 36rpx;
239 | line-height: 100rpx;
240 | padding-left: 160rpx;
241 | }
242 | .cart button {
243 | margin-top: 10rpx;
244 | margin-right: 20rpx;
245 | width: 200rpx;
246 | height: 100%;
247 | font-size: 36rpx;
248 | }
249 | .like{
250 | background-image: url(http://xs01.meituan.net/waimai_web/img/sprite/icons_559f3531_1.png);
251 | display: inline-block;
252 | width: 15px;
253 | height: 15px;
254 | background-position: -416px -63px;
255 | }
256 | .cartList{
257 | width: 100%;
258 | height: auto;
259 | display: inline-block;
260 | }
261 | .order-price{
262 | margin-left: 60px;
263 | }
264 | .right-content{
265 | float: right;
266 | }
267 |
--------------------------------------------------------------------------------
/a-takeaway-demo-of-wxapp-master/utils/server.js:
--------------------------------------------------------------------------------
1 | function __args() {
2 | var setting = {};
3 | if (arguments.length === 1 && typeof arguments[0] !== 'string') {
4 | setting = arguments[0];
5 | } else {
6 | setting.url = arguments[0];
7 | if (typeof arguments[1] === 'object') {
8 | setting.data = arguments[1];
9 | setting.success = arguments[2];
10 | } else {
11 | setting.success = arguments[1];
12 | }
13 | }
14 | if (setting.url.indexOf('https://') !== 0) {
15 | setting.url = 'https://test2.zuzuche.com/' + setting.url;
16 | }
17 | return setting;
18 | }
19 | function __json(method, setting) {
20 | setting.method = method;
21 | setting.header = {
22 | 'content-type': 'application/json'
23 | };
24 | wx.request(setting);
25 | }
26 |
27 | function formatTime(date) {
28 | const year = date.getFullYear()
29 | var month = date.getMonth() + 1
30 | var day = date.getDate()
31 |
32 | var hour = date.getHours()
33 | var minute = date.getMinutes()
34 | var second = date.getSeconds();
35 |
36 | return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':')
37 | }
38 |
39 | function formatNumber(n) {
40 | n = n.toString()
41 | return n[1] ? n : '0' + n
42 | }
43 |
44 | function isEmptyObject(obj)
45 | {
46 | if ((typeof obj === "object" && !(obj instanceof Array)) || ((obj instanceof Array) && obj.length <= 0 )){
47 | var isEmpty = true;
48 | for (var prop in obj){
49 | isEmpty = false;
50 | break;
51 | }
52 | return isEmpty;
53 | }
54 | return false;
55 | }
56 |
57 | function filterEmptyObject(list){
58 | var cartList = [];
59 | for(var index in list)
60 | {
61 | if(!this.isEmptyObject(list[index])){
62 | cartList.push(list[index])
63 | }
64 | }
65 | return cartList;
66 | }
67 |
68 | function selectedShopDetail(shopId){
69 | var app = getApp();
70 | for (var i = 0; i < app.globalData.shops.length; ++i) {
71 | if (app.globalData.shops[i].id == shopId) {
72 | return app.globalData.shops[i]
73 | }
74 | }
75 |
76 | return null;
77 | }
78 |
79 | module.exports = {
80 | getJSON: function () {
81 | __json('GET', __args.apply(this, arguments));
82 | },
83 | postJSON: function () {
84 | __json('POST', __args.apply(this, arguments));
85 | },
86 | formatTime: formatTime,
87 | isEmptyObject: isEmptyObject,
88 | selectedShopDetail: selectedShopDetail,
89 | filterEmptyObject: filterEmptyObject
90 | }
91 |
--------------------------------------------------------------------------------