├── .gitignore
├── README.md
├── app.js
├── app.json
├── app.wxss
├── images
├── address.png
├── commodity-1.png
├── commodity-2.png
├── commodity-detail.png
├── commodity-thumb.png
├── commodity.png
├── customer.png
├── delivery.png
├── home.png
├── icon-home-off.png
├── icon-home-on.png
├── icon-user-off.png
├── icon-user-on.png
├── ionic.png
├── location.png
├── logo.png
├── map-marker.png
├── marker.png
├── question.png
├── store.png
├── tabuser.png
├── user.png
└── we.png
├── lib
├── md5.js
└── wxParse
│ ├── html2json.js
│ ├── htmlparser.js
│ ├── showdown.js
│ ├── wxDiscode.js
│ ├── wxParse.js
│ ├── wxParse.wxml
│ └── wxParse.wxss
├── pages
├── beforeOrder
│ ├── beforeOrder.js
│ ├── beforeOrder.json
│ ├── beforeOrder.wxml
│ └── beforeOrder.wxss
├── deliveredOrder
│ ├── deliveredOrder.js
│ ├── deliveredOrder.json
│ ├── deliveredOrder.wxml
│ └── deliveredOrder.wxss
├── deliveryOrder
│ ├── deliveryOrder.js
│ ├── deliveryOrder.json
│ ├── deliveryOrder.wxml
│ └── deliveryOrder.wxss
├── editStoreAddress
│ ├── editStoreAddress.js
│ ├── editStoreAddress.json
│ ├── editStoreAddress.wxml
│ └── editStoreAddress.wxss
├── editUserAddress
│ ├── editUserAddress.js
│ ├── editUserAddress.json
│ ├── editUserAddress.wxml
│ └── editUserAddress.wxss
├── index
│ ├── index.js
│ ├── index.json
│ ├── index.wxml
│ └── index.wxss
├── logs
│ ├── logs.js
│ ├── logs.json
│ ├── logs.wxml
│ └── logs.wxss
├── map
│ ├── map.js
│ ├── map.json
│ ├── map.wxml
│ └── map.wxss
├── pendingOrder
│ ├── pendingOrder.js
│ ├── pendingOrder.json
│ ├── pendingOrder.wxml
│ └── pendingOrder.wxss
├── productDetail
│ ├── productDetail.js
│ ├── productDetail.json
│ ├── productDetail.wxml
│ └── productDetail.wxss
├── receivedOrder
│ ├── receivedOrder.js
│ ├── receivedOrder.json
│ ├── receivedOrder.wxml
│ └── receivedOrder.wxss
├── retreatOrder
│ ├── retreatOrder.js
│ ├── retreatOrder.json
│ ├── retreatOrder.wxml
│ └── retreatOrder.wxss
├── storeOrder
│ ├── storeOrder.js
│ ├── storeOrder.json
│ ├── storeOrder.wxml
│ └── storeOrder.wxss
├── templates
│ ├── homeProduct.wxml
│ ├── orderitem.wxml
│ ├── toast.wxml
│ └── wechatUser.wxml
├── test
│ ├── test.js
│ ├── test.json
│ ├── test.wxml
│ └── test.wxss
├── user
│ ├── user.js
│ ├── user.json
│ ├── user.wxml
│ └── user.wxss
├── userGroup
│ ├── userGroup.js
│ ├── userGroup.json
│ ├── userGroup.wxml
│ └── userGroup.wxss
└── waitingOrder
│ ├── waitingOrder.js
│ ├── waitingOrder.json
│ ├── waitingOrder.wxml
│ └── waitingOrder.wxss
└── utils
└── util.js
/.gitignore:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/highjump0615/Duck_Wechat_MiniProgram/1f12aaf9f884bbd4c4e65367f3ae818e8967fe48/.gitignore
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | 食品农产品交易微信小程序
2 | ======
3 |
4 | > Wechat Mini-Program for food purchase platform, having its own [backend](https://github.com/highjump0615/Duck_Backend_Laravel)
5 |
6 | ## Overview
7 |
8 | ### 1. 主要功能
9 | - 商品浏览
10 | 商品分类、商品列表
11 | - 订单管理
12 | 下单(微信支付)、自提订单、配送订单、拼团
13 | - 基础信息管理
14 | 收货地址
15 |
16 | ### 2. 技术内容
17 | #### 2.1 微信小程序 ( wxml / wxss / js )
18 | - `````` 模板渲染列表
19 | - `````` 做自定义对话框
20 | - ```wx.requestPayment()``` 用为微信付款
21 | - ```wx.openLocation()``` 地图显示
22 |
23 | #### 2.2 Third-Party Libraries
24 | - [Javascript MD5 v2.1](http://pajhome.org.uk/crypt/md5/)
25 | - [微信小程序富文本解析组件 wxParse v0.3](https://github.com/icindy/wxParse)
26 |
27 | ## Need to Improve
28 | - 界面需要优化、完善
29 |
--------------------------------------------------------------------------------
/app.js:
--------------------------------------------------------------------------------
1 | //app.js
2 | var config = require('config/config.js')
3 |
4 | App({
5 | /**
6 | * 获取基础数据
7 | */
8 | getSystemData: function(main) {
9 | var that = this;
10 |
11 | // 已获取,直接跳转下一步
12 | if (this.setting) {
13 | main();
14 | return;
15 | }
16 |
17 | // 检查缓存数据
18 | var setting = wx.getStorageSync('sysSetting');
19 | if (setting) {
20 | this.setting = setting;
21 | }
22 |
23 | // 获取基础参数
24 | wx.request({
25 | url: config.api.baseUrl + '/system/info',//请求地址
26 | data: {
27 | },
28 | header: {//请求头
29 | "Content-Type": "applciation/json"
30 | },
31 | method: "GET",//get为默认方法/POST
32 | success: function (res) {
33 | that.setting = {
34 | customerPhone: res.data.result.phone,
35 | noticeRefund: res.data.result.notice_refund,
36 | noticeGroup: res.data.result.notice_groupbuy
37 | };
38 |
39 | // 保存到缓存
40 | wx.setStorageSync('sysSetting', that.setting);
41 | },
42 | fail: function (err) { },//请求失败
43 | complete: function () {
44 | //调用应用实例的方法获取全局数据
45 | that.getUserInfo(main);
46 | }//请求完成后执行的函数
47 | });
48 | },
49 |
50 | onLaunch: function () {
51 | //调用API从本地缓存中获取数据
52 | var logs = wx.getStorageSync('logs') || [];
53 | logs.unshift(Date.now());
54 | wx.setStorageSync('logs', logs);
55 |
56 | // 收件人
57 | this.receiver = wx.getStorageSync('receiver');
58 | },
59 |
60 | /**
61 | * 获取用户信息
62 | */
63 | getUserInfo: function (main) {
64 | var that = this;
65 |
66 | // 先检查app的user数据
67 | if (this.globalData.userInfo) {
68 | main();
69 | return;
70 | }
71 |
72 | // 下一步检查缓存的user数据
73 | var userInfo = wx.getStorageSync('userInfo');
74 | if (userInfo) {
75 | this.globalData.userInfo = userInfo;
76 | main();
77 | return;
78 | }
79 |
80 | var strLoginCode;
81 | //调用登录接口
82 | wx.login({
83 | success: function (loginCode)
84 | {
85 | strLoginCode = loginCode.code;
86 |
87 | wx.getUserInfo({
88 | success: function (res) {
89 | that.globalData.userInfo = res.userInfo;
90 | that.globalData.userInfo.longitude = 0;
91 | that.globalData.userInfo.latitude = 0;
92 |
93 | // get the customer id
94 | wx.request({
95 | url: config.api.baseUrl + '/customer/set',//请求地址
96 | data: {
97 | login_code: strLoginCode,
98 | name: res.userInfo.nickName,
99 | photo_url: res.userInfo.avatarUrl,
100 | },
101 | header: {//请求头
102 | "Content-Type": "application/x-www-form-urlencoded"
103 | },
104 | method: "POST",//get为默认方法/POST
105 | success: function (res) {
106 | console.log('get custormer id');
107 | console.log(res.data.customer_id);//res.data相当于ajax里面的data,为后台返回的数据
108 |
109 | if (res.data.status == "success") {
110 | that.globalData.userInfo.customerId = res.data.customer_id;
111 |
112 | // 保存
113 | wx.setStorageSync('userInfo', that.globalData.userInfo);
114 | }
115 | else {
116 | wx.showModal({
117 | content: '用户识别获取失败:' + strLoginCode,
118 | showCancel: false
119 | });
120 |
121 | console.log('用户识别获取失败:' + strLoginCode);
122 | }
123 | },
124 | fail: function (err) { },//请求失败
125 | complete: function () { //请求完成后执行的函数
126 | main();
127 | }
128 | })
129 | }
130 | })
131 | }
132 | });
133 | },
134 | globalData: {
135 | userInfo: null,
136 | cnt: 0,
137 | adsCnt: 0,
138 | },
139 | // 系统基础信息
140 | setting: null,
141 |
142 | //自定义Toast
143 | showToast: function(text,o,count){
144 | var _this = o;
145 | count = parseInt(count) ? parseInt(count) : 3000;
146 | _this.setData({
147 | toastText:text,
148 | isShowToast: true,
149 | });
150 | setTimeout(function () {
151 | _this.setData({
152 | isShowToast: false
153 | });
154 | },count);
155 | },
156 | })
--------------------------------------------------------------------------------
/app.json:
--------------------------------------------------------------------------------
1 | {
2 | "pages": [
3 | "pages/index/index",
4 | "pages/productDetail/productDetail",
5 | "pages/user/user",
6 | "pages/storeOrder/storeOrder",
7 | "pages/deliveryOrder/deliveryOrder",
8 | "pages/userGroup/userGroup",
9 | "pages/pendingOrder/pendingOrder",
10 | "pages/editUserAddress/editUserAddress",
11 | "pages/editStoreAddress/editStoreAddress",
12 | "pages/receivedOrder/receivedOrder",
13 | "pages/deliveredOrder/deliveredOrder",
14 | "pages/waitingOrder/waitingOrder",
15 | "pages/retreatOrder/retreatOrder",
16 | "pages/map/map"
17 | ],
18 | "window": {
19 | "backgroundTextStyle": "light",
20 | "navigationBarBackgroundColor": "#fff",
21 | "navigationBarTitleText": "",
22 | "navigationBarTextStyle": "black",
23 | "backgroundColor": "#eeeeee"
24 | },
25 | "tabBar": {
26 | "list": [
27 | {
28 | "pagePath": "pages/index/index",
29 | "text": "首页",
30 | "iconPath": "images/icon-home-off.png",
31 | "selectedIconPath": "images/icon-home-on.png"
32 | },
33 | {
34 | "pagePath": "pages/user/user",
35 | "text": "个人中心",
36 | "iconPath": "images/icon-user-off.png",
37 | "selectedIconPath": "images/icon-user-on.png"
38 | }
39 | ]
40 | }
41 | }
--------------------------------------------------------------------------------
/app.wxss:
--------------------------------------------------------------------------------
1 | /**app.wxss**/
2 | .left {
3 | display: inline-block;
4 | }
5 |
6 | .right {
7 | display: inline-block;
8 | float: right;
9 | }
10 |
11 | .list-item {
12 | padding-left: 50rpx;
13 | padding-right: 30rpx;
14 | padding-top: 20rpx;
15 | padding-bottom: 20rpx;
16 | border: 1px solid #eee;
17 | margin-top: -1px;
18 | background-color: #fff;
19 | line-height: 40rpx;
20 | }
21 |
22 | text.price1 {
23 | margin-right: 10px;
24 | color: #68bc5e;
25 | }
26 |
27 | text.price2 {
28 | margin-right: 10px;
29 | color: #db5078;
30 | }
31 |
32 | button.appbutton3 {
33 | background-color: #fff;
34 | font-size: 14px;
35 | border: 1px solid #68bc5e;
36 | color: #68bc5e;
37 | line-height: 30px;
38 | margin-top: 5px;
39 | }
40 |
41 | button.appbutton1 {
42 | color: #68bc5e;
43 | background-color: white;
44 | }
45 |
46 | button.appbutton2 {
47 | color: white;
48 | background-color: #68bc5e;
49 | }
50 |
51 | button.appbutton2.disabled {
52 | opacity: 0.7
53 | }
54 |
55 | .sub-button {
56 | display: inline-block;
57 | width: 50%;
58 | }
59 |
60 | button.button {
61 | border-radius: 0px;
62 | font-size: 14px;
63 | padding: 10px;
64 | }
65 |
66 | button::after {
67 | border-radius: 0px;
68 | }
69 |
70 | button.appbutton1:hover {
71 | color: white;
72 | background-color: #83d27a;
73 | }
74 |
75 | button.appbutton2:hover {
76 | color: white;
77 | background-color: #83d27a;
78 | }
79 |
80 | .product-item {
81 | border-bottom: 1px solid #eee;
82 | }
83 |
84 | .product-image {
85 | display: inline-block;
86 | vertical-align: middle;
87 | }
88 |
89 | .product-image image {
90 | width: 100px;
91 | height: 100px;
92 | margin: 10px;
93 | }
94 |
95 | .product-info {
96 | display: inline-block;
97 | width: calc(100% - 120px);
98 | vertical-align: middle;
99 | }
100 |
101 | .product-description {
102 | font-size: 15px;
103 | padding: 15px 20px 0px 0px;
104 | min-height: 55px;
105 | }
106 |
107 | .product-price text {
108 | font-size: 14px;
109 | display: inline-block;
110 | font-weight: 600;
111 | }
112 |
113 | text.go-detail {
114 | color: #68bc5e;
115 | float: right;
116 | font-size: 30rpx;
117 | }
118 |
119 | .store-item {
120 | margin-top: 0px;
121 | padding: 10px 0px;
122 | border: 1px solid #eee;
123 | }
124 |
125 | .store-item .index-area {
126 | font-size: 14px;
127 | padding: 0px 15px;
128 | margin-bottom: 10px;
129 | }
130 |
131 | .store-item .commodity-item {
132 | background-color: #eef5ed;
133 | padding: 0px 15px;
134 | }
135 |
136 | .store-item .price {
137 | font-size: 14px;
138 | margin-top: 15px;
139 | }
140 |
141 | .store-item .price .right {
142 | color: #e54142;
143 | font-weight: 600;
144 | }
145 |
146 | .store-item .commodity-image {
147 | display: inline-block;
148 | vertical-align: middle;
149 | }
150 |
151 | .store-item .commodity-image image {
152 | width: 120px;
153 | height: 120px;
154 | margin: 10px;
155 | }
156 |
157 | .store-item .commodity-info {
158 | display: inline-block;
159 | max-width: calc(100% - 140px);
160 | vertical-align: middle;
161 | }
162 |
163 | .store-item .commodity-description {
164 | font-size: 14px;
165 | }
166 |
167 | .store-item .remain {
168 | margin-top: 15px;
169 | }
170 |
171 | .store-item .remain button.appbutton3 {
172 | padding: 0px 10px;
173 | background-color: transparent;
174 | margin-top: 0px;
175 | font-size: 12px;
176 | line-height: 20px;
177 | }
178 |
179 | .store-item .remain button.appbutton2 {
180 | padding: 0px 10px;
181 | font-size: 12px;
182 | line-height: 22px;
183 | }
184 |
185 | .store-item .detail-area {
186 | font-size: 14px;
187 | padding: 10px 15px 0px 15px;
188 | color: #aaa;
189 | }
190 |
191 | .store-item .count-area {
192 | padding-top: 10px;
193 | }
194 |
195 | .store-item .price-area .total {
196 | padding: 5px 0px;
197 | }
198 |
199 | .store-item .price-area .total text {
200 | color: #e54142;
201 | font-weight: 600;
202 | }
203 |
204 | .store-item .price-area .time {
205 | padding: 5px 0px;
206 | }
207 |
208 | .store-item .price-area .store {
209 | padding: 5px 0px;
210 | }
211 |
212 | .store-item button.appbutton4 {
213 | padding: 0px 10px;
214 | background-color: transparent;
215 | margin-top: 5px;
216 | font-size: 12px;
217 | line-height: 20px;
218 | border: 1px solid #68bc5e;
219 | }
220 |
221 | .pending-item {
222 | margin-top: 0px;
223 | }
224 |
225 | .pending-item .commodity-item {
226 | border: 1px solid #eee;
227 | }
228 |
229 | .pending-item .price {
230 | font-size: 14px;
231 | padding: 8px 10px;
232 | }
233 |
234 | .pending-item .price .right {
235 | color: #e54142;
236 | font-weight: 600;
237 | }
238 |
239 | .pending-item .commodity-image {
240 | display: inline-block;
241 | vertical-align: middle;
242 | background-color: #eef5ed;
243 | }
244 |
245 | .pending-item .commodity-image image {
246 | width: 120px;
247 | height: 120px;
248 | margin: 10px;
249 | }
250 |
251 | .pending-item .commodity-info {
252 | display: inline-block;
253 | max-width: calc(100% - 140px);
254 | vertical-align: middle;
255 | }
256 |
257 | .pending-item .commodity-description {
258 | font-size: 14px;
259 | padding: 0px 10px;
260 | }
261 |
262 | .pending-item .remain {
263 | padding: 8px 10px;
264 | }
265 |
266 | .pending-item .remain button.appbutton3 {
267 | padding: 0px 10px;
268 | background-color: transparent;
269 | margin-top: 0px;
270 | font-size: 12px;
271 | line-height: 20px;
272 | }
273 |
274 | .pending-item .remain button.appbutton2 {
275 | padding: 0px 10px;
276 | font-size: 12px;
277 | line-height: 22px;
278 | }
279 |
280 | .pending-item .mode-area {
281 | font-size: 15px;
282 | padding: 10px 20px;
283 | margin-bottom: 10px;
284 | }
285 |
286 | .pending-item .mode-area .left {
287 | font-weight: 600;
288 | margin-top: 10px;
289 | }
290 |
291 | .pending-item button.appbutton4 {
292 | background-color: transparent;
293 | display: inline-block;
294 | padding: 3px 6px;
295 | }
296 |
297 | .pending-item button.appbutton4.active {
298 | background-color: #eef5ed;
299 | color: #68bc5e;
300 | }
301 |
302 | .pending-item .address-area {
303 | font-size: 14px;
304 | padding: 30px 40rpx;
305 | background-color: #eef5ed;
306 | }
307 |
308 | .pending-item .name {
309 | padding: 5px 0px;
310 | }
311 |
312 | .pending-item .address {
313 | padding: 5px 0px;
314 | color: #aaa;
315 | }
316 |
317 | .pending-item .store {
318 | padding: 5px 0px;
319 | color: #aaa;
320 | }
321 |
322 | .pending-item .address-area button.appbutton3 {
323 | line-height: 20px;
324 | padding: 0px 10px;
325 | margin-top: 30px;
326 | background: transparent;
327 | color: #000;
328 | }
329 |
330 | .pending-item .detail-area {
331 | padding:20px 10px;
332 | font-size:15px;
333 | }
334 | .pending-item .detail-area .item {
335 | padding: 10px 0px;
336 | border-bottom: 1px solid #eee;
337 | }
338 | .pending-item .button-area {
339 | text-align: right;
340 | margin-top: 50px;
341 | padding: 40px 10px 10px 10px;
342 | border-top: 1px solid #eee;
343 | }
344 | .pending-item .total {
345 | display: inline-block;
346 | vertical-align: middle;
347 | color: #db5078;
348 | font-size: 15px;
349 | margin-right: 20px;
350 | }
351 | .pending-item .button-area button.appbutton2 {
352 | display: inline-block;
353 | vertical-align: middle;
354 | line-height: 20px;
355 | }
356 | .groupBuying {
357 | line-height:20px;
358 | padding:0px 10px;
359 | margin-left:5px;
360 | display:inline-block;
361 | border-radius:2px;
362 | font-size:14px;
363 | color:white;
364 | background-color:#68bc5e;
365 | }
366 |
367 | .item input {
368 | font-size: 15px;
369 | display: inline-block;
370 | vertical-align: middle;
371 | margin-left: 5px;
372 | color: #555;
373 | }
374 |
375 | .commodity-item .commodity-info {
376 | width: 100%
377 | }
378 |
379 |
380 | /*toast start*/
381 | .wxapp-toast-mask{
382 | opacity: 0;
383 | width: 100%;
384 | height: 100%;
385 | overflow: hidden;
386 | position: fixed;
387 | top: 0;
388 | left: 0;
389 | z-index: 888;
390 | }
391 |
392 | .wxapp-toast-content-box {
393 | display: flex;
394 | width: 100%;
395 | height: 100%;
396 | justify-content: center;
397 | align-items: center;
398 | position: fixed;
399 | z-index: 999;
400 | }
401 |
402 | .wxapp-toast-content {
403 | width: 50%;
404 | padding: 20rpx;
405 | background: rgba(0, 0, 0, 0.7);
406 | border-radius: 20rpx;
407 | }
408 |
409 | .wxapp-toast-content-text {
410 | height: 100%;
411 | width: 100%;
412 | color: #fff;
413 | font-size: 28rpx;
414 | text-align: center;
415 | }
416 | /*toast end*/
417 |
418 | page {
419 | background: white;
420 | }
421 |
422 | text {
423 | font-family: '宋体';
424 | }
425 |
426 | /* 拼团用户头像列表 */
427 | .customer {
428 | padding-left: 20rpx;
429 | }
430 | .text-count {
431 | float: left;
432 | line-height: 60rpx
433 | }
434 | .customer image {
435 | width: 60rpx;
436 | height: 60rpx;
437 | margin-left: 10rpx;
438 | border-radius: 50%;
439 | }
440 |
441 | .no-notice {
442 | text-align: center;
443 | margin-top: 300rpx;
444 | font-size: 28rpx;
445 | color: #a0a0a0;
446 | }
--------------------------------------------------------------------------------
/images/address.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/highjump0615/Duck_Wechat_MiniProgram/1f12aaf9f884bbd4c4e65367f3ae818e8967fe48/images/address.png
--------------------------------------------------------------------------------
/images/commodity-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/highjump0615/Duck_Wechat_MiniProgram/1f12aaf9f884bbd4c4e65367f3ae818e8967fe48/images/commodity-1.png
--------------------------------------------------------------------------------
/images/commodity-2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/highjump0615/Duck_Wechat_MiniProgram/1f12aaf9f884bbd4c4e65367f3ae818e8967fe48/images/commodity-2.png
--------------------------------------------------------------------------------
/images/commodity-detail.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/highjump0615/Duck_Wechat_MiniProgram/1f12aaf9f884bbd4c4e65367f3ae818e8967fe48/images/commodity-detail.png
--------------------------------------------------------------------------------
/images/commodity-thumb.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/highjump0615/Duck_Wechat_MiniProgram/1f12aaf9f884bbd4c4e65367f3ae818e8967fe48/images/commodity-thumb.png
--------------------------------------------------------------------------------
/images/commodity.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/highjump0615/Duck_Wechat_MiniProgram/1f12aaf9f884bbd4c4e65367f3ae818e8967fe48/images/commodity.png
--------------------------------------------------------------------------------
/images/customer.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/highjump0615/Duck_Wechat_MiniProgram/1f12aaf9f884bbd4c4e65367f3ae818e8967fe48/images/customer.png
--------------------------------------------------------------------------------
/images/delivery.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/highjump0615/Duck_Wechat_MiniProgram/1f12aaf9f884bbd4c4e65367f3ae818e8967fe48/images/delivery.png
--------------------------------------------------------------------------------
/images/home.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/highjump0615/Duck_Wechat_MiniProgram/1f12aaf9f884bbd4c4e65367f3ae818e8967fe48/images/home.png
--------------------------------------------------------------------------------
/images/icon-home-off.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/highjump0615/Duck_Wechat_MiniProgram/1f12aaf9f884bbd4c4e65367f3ae818e8967fe48/images/icon-home-off.png
--------------------------------------------------------------------------------
/images/icon-home-on.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/highjump0615/Duck_Wechat_MiniProgram/1f12aaf9f884bbd4c4e65367f3ae818e8967fe48/images/icon-home-on.png
--------------------------------------------------------------------------------
/images/icon-user-off.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/highjump0615/Duck_Wechat_MiniProgram/1f12aaf9f884bbd4c4e65367f3ae818e8967fe48/images/icon-user-off.png
--------------------------------------------------------------------------------
/images/icon-user-on.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/highjump0615/Duck_Wechat_MiniProgram/1f12aaf9f884bbd4c4e65367f3ae818e8967fe48/images/icon-user-on.png
--------------------------------------------------------------------------------
/images/ionic.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/highjump0615/Duck_Wechat_MiniProgram/1f12aaf9f884bbd4c4e65367f3ae818e8967fe48/images/ionic.png
--------------------------------------------------------------------------------
/images/location.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/highjump0615/Duck_Wechat_MiniProgram/1f12aaf9f884bbd4c4e65367f3ae818e8967fe48/images/location.png
--------------------------------------------------------------------------------
/images/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/highjump0615/Duck_Wechat_MiniProgram/1f12aaf9f884bbd4c4e65367f3ae818e8967fe48/images/logo.png
--------------------------------------------------------------------------------
/images/map-marker.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/highjump0615/Duck_Wechat_MiniProgram/1f12aaf9f884bbd4c4e65367f3ae818e8967fe48/images/map-marker.png
--------------------------------------------------------------------------------
/images/marker.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/highjump0615/Duck_Wechat_MiniProgram/1f12aaf9f884bbd4c4e65367f3ae818e8967fe48/images/marker.png
--------------------------------------------------------------------------------
/images/question.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/highjump0615/Duck_Wechat_MiniProgram/1f12aaf9f884bbd4c4e65367f3ae818e8967fe48/images/question.png
--------------------------------------------------------------------------------
/images/store.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/highjump0615/Duck_Wechat_MiniProgram/1f12aaf9f884bbd4c4e65367f3ae818e8967fe48/images/store.png
--------------------------------------------------------------------------------
/images/tabuser.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/highjump0615/Duck_Wechat_MiniProgram/1f12aaf9f884bbd4c4e65367f3ae818e8967fe48/images/tabuser.png
--------------------------------------------------------------------------------
/images/user.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/highjump0615/Duck_Wechat_MiniProgram/1f12aaf9f884bbd4c4e65367f3ae818e8967fe48/images/user.png
--------------------------------------------------------------------------------
/images/we.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/highjump0615/Duck_Wechat_MiniProgram/1f12aaf9f884bbd4c4e65367f3ae818e8967fe48/images/we.png
--------------------------------------------------------------------------------
/lib/md5.js:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
4 |
5 | * Digest Algorithm, as defined in RFC 1321.
6 |
7 | * Version 2.1 Copyright (C) Paul Johnston 1999 - 2002.
8 |
9 | * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
10 |
11 | * Distributed under the BSD License
12 |
13 | * See http://pajhome.org.uk/crypt/md5 for more info.
14 |
15 | */
16 |
17 | /*
18 |
19 | * Configurable variables. You may need to tweak these to be compatible with
20 |
21 | * the server-side, but the defaults work in most cases.
22 |
23 | */
24 | var hexcase = 0; /* hex output format. 0 - lowercase; 1 - uppercase */
25 | var b64pad = ""; /* base-64 pad character. "=" for strict RFC compliance */
26 | var chrsz = 8; /* bits per input character. 8 - ASCII; 16 - Unicode */
27 |
28 | /*
29 |
30 | * These are the functions you'll usually want to call
31 |
32 | * They take string arguments and return either hex or base-64 encoded strings
33 |
34 | */
35 | function hex_md5(s){ return binl2hex(core_md5(str2binl(s), s.length * chrsz));}
36 | function b64_md5(s){ return binl2b64(core_md5(str2binl(s), s.length * chrsz));}
37 | function str_md5(s){ return binl2str(core_md5(str2binl(s), s.length * chrsz));}
38 | function hex_hmac_md5(key, data) { return binl2hex(core_hmac_md5(key, data)); }
39 | function b64_hmac_md5(key, data) { return binl2b64(core_hmac_md5(key, data)); }
40 | function str_hmac_md5(key, data) { return binl2str(core_hmac_md5(key, data)); }
41 | module.exports = {
42 | hex_md5: hex_md5
43 | }
44 |
45 | /*
46 |
47 | * Perform a simple self-test to see if the VM is working
48 |
49 | */
50 | function md5_vm_test()
51 | {
52 | return hex_md5("abc") == "900150983cd24fb0d6963f7d28e17f72";
53 | }
54 |
55 | /*
56 |
57 | * Calculate the MD5 of an array of little-endian words, and a bit length
58 |
59 | */
60 | function core_md5(x, len)
61 | {
62 | /* append padding */
63 | x[len >> 5] |= 0x80 << ((len) % 32);
64 | x[(((len + 64) >>> 9) << 4) + 14] = len;
65 |
66 | var a = 1732584193;
67 | var b = -271733879;
68 | var c = -1732584194;
69 | var d = 271733878;
70 |
71 | for(var i = 0; i < x.length; i += 16)
72 | {
73 | var olda = a;
74 | var oldb = b;
75 | var oldc = c;
76 | var oldd = d;
77 |
78 | a = md5_ff(a, b, c, d, x[i+ 0], 7 , -680876936);
79 | d = md5_ff(d, a, b, c, x[i+ 1], 12, -389564586);
80 | c = md5_ff(c, d, a, b, x[i+ 2], 17, 606105819);
81 | b = md5_ff(b, c, d, a, x[i+ 3], 22, -1044525330);
82 | a = md5_ff(a, b, c, d, x[i+ 4], 7 , -176418897);
83 | d = md5_ff(d, a, b, c, x[i+ 5], 12, 1200080426);
84 | c = md5_ff(c, d, a, b, x[i+ 6], 17, -1473231341);
85 | b = md5_ff(b, c, d, a, x[i+ 7], 22, -45705983);
86 | a = md5_ff(a, b, c, d, x[i+ 8], 7 , 1770035416);
87 | d = md5_ff(d, a, b, c, x[i+ 9], 12, -1958414417);
88 | c = md5_ff(c, d, a, b, x[i+10], 17, -42063);
89 | b = md5_ff(b, c, d, a, x[i+11], 22, -1990404162);
90 | a = md5_ff(a, b, c, d, x[i+12], 7 , 1804603682);
91 | d = md5_ff(d, a, b, c, x[i+13], 12, -40341101);
92 | c = md5_ff(c, d, a, b, x[i+14], 17, -1502002290);
93 | b = md5_ff(b, c, d, a, x[i+15], 22, 1236535329);
94 |
95 | a = md5_gg(a, b, c, d, x[i+ 1], 5 , -165796510);
96 | d = md5_gg(d, a, b, c, x[i+ 6], 9 , -1069501632);
97 | c = md5_gg(c, d, a, b, x[i+11], 14, 643717713);
98 | b = md5_gg(b, c, d, a, x[i+ 0], 20, -373897302);
99 | a = md5_gg(a, b, c, d, x[i+ 5], 5 , -701558691);
100 | d = md5_gg(d, a, b, c, x[i+10], 9 , 38016083);
101 | c = md5_gg(c, d, a, b, x[i+15], 14, -660478335);
102 | b = md5_gg(b, c, d, a, x[i+ 4], 20, -405537848);
103 | a = md5_gg(a, b, c, d, x[i+ 9], 5 , 568446438);
104 | d = md5_gg(d, a, b, c, x[i+14], 9 , -1019803690);
105 | c = md5_gg(c, d, a, b, x[i+ 3], 14, -187363961);
106 | b = md5_gg(b, c, d, a, x[i+ 8], 20, 1163531501);
107 | a = md5_gg(a, b, c, d, x[i+13], 5 , -1444681467);
108 | d = md5_gg(d, a, b, c, x[i+ 2], 9 , -51403784);
109 | c = md5_gg(c, d, a, b, x[i+ 7], 14, 1735328473);
110 | b = md5_gg(b, c, d, a, x[i+12], 20, -1926607734);
111 |
112 | a = md5_hh(a, b, c, d, x[i+ 5], 4 , -378558);
113 | d = md5_hh(d, a, b, c, x[i+ 8], 11, -2022574463);
114 | c = md5_hh(c, d, a, b, x[i+11], 16, 1839030562);
115 | b = md5_hh(b, c, d, a, x[i+14], 23, -35309556);
116 | a = md5_hh(a, b, c, d, x[i+ 1], 4 , -1530992060);
117 | d = md5_hh(d, a, b, c, x[i+ 4], 11, 1272893353);
118 | c = md5_hh(c, d, a, b, x[i+ 7], 16, -155497632);
119 | b = md5_hh(b, c, d, a, x[i+10], 23, -1094730640);
120 | a = md5_hh(a, b, c, d, x[i+13], 4 , 681279174);
121 | d = md5_hh(d, a, b, c, x[i+ 0], 11, -358537222);
122 | c = md5_hh(c, d, a, b, x[i+ 3], 16, -722521979);
123 | b = md5_hh(b, c, d, a, x[i+ 6], 23, 76029189);
124 | a = md5_hh(a, b, c, d, x[i+ 9], 4 , -640364487);
125 | d = md5_hh(d, a, b, c, x[i+12], 11, -421815835);
126 | c = md5_hh(c, d, a, b, x[i+15], 16, 530742520);
127 | b = md5_hh(b, c, d, a, x[i+ 2], 23, -995338651);
128 |
129 | a = md5_ii(a, b, c, d, x[i+ 0], 6 , -198630844);
130 | d = md5_ii(d, a, b, c, x[i+ 7], 10, 1126891415);
131 | c = md5_ii(c, d, a, b, x[i+14], 15, -1416354905);
132 | b = md5_ii(b, c, d, a, x[i+ 5], 21, -57434055);
133 | a = md5_ii(a, b, c, d, x[i+12], 6 , 1700485571);
134 | d = md5_ii(d, a, b, c, x[i+ 3], 10, -1894986606);
135 | c = md5_ii(c, d, a, b, x[i+10], 15, -1051523);
136 | b = md5_ii(b, c, d, a, x[i+ 1], 21, -2054922799);
137 | a = md5_ii(a, b, c, d, x[i+ 8], 6 , 1873313359);
138 | d = md5_ii(d, a, b, c, x[i+15], 10, -30611744);
139 | c = md5_ii(c, d, a, b, x[i+ 6], 15, -1560198380);
140 | b = md5_ii(b, c, d, a, x[i+13], 21, 1309151649);
141 | a = md5_ii(a, b, c, d, x[i+ 4], 6 , -145523070);
142 | d = md5_ii(d, a, b, c, x[i+11], 10, -1120210379);
143 | c = md5_ii(c, d, a, b, x[i+ 2], 15, 718787259);
144 | b = md5_ii(b, c, d, a, x[i+ 9], 21, -343485551);
145 |
146 | a = safe_add(a, olda);
147 | b = safe_add(b, oldb);
148 | c = safe_add(c, oldc);
149 | d = safe_add(d, oldd);
150 | }
151 | return Array(a, b, c, d);
152 |
153 | }
154 |
155 | /*
156 |
157 | * These functions implement the four basic operations the algorithm uses.
158 |
159 | */
160 | function md5_cmn(q, a, b, x, s, t)
161 | {
162 | return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s),b);
163 | }
164 | function md5_ff(a, b, c, d, x, s, t)
165 | {
166 | return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t);
167 | }
168 | function md5_gg(a, b, c, d, x, s, t)
169 | {
170 | return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t);
171 | }
172 | function md5_hh(a, b, c, d, x, s, t)
173 | {
174 | return md5_cmn(b ^ c ^ d, a, b, x, s, t);
175 | }
176 | function md5_ii(a, b, c, d, x, s, t)
177 | {
178 | return md5_cmn(c ^ (b | (~d)), a, b, x, s, t);
179 | }
180 |
181 | /*
182 |
183 | * Calculate the HMAC-MD5, of a key and some data
184 |
185 | */
186 | function core_hmac_md5(key, data)
187 | {
188 | var bkey = str2binl(key);
189 | if(bkey.length > 16) bkey = core_md5(bkey, key.length * chrsz);
190 |
191 | var ipad = Array(16), opad = Array(16);
192 | for(var i = 0; i < 16; i++)
193 | {
194 | ipad[i] = bkey[i] ^ 0x36363636;
195 | opad[i] = bkey[i] ^ 0x5C5C5C5C;
196 | }
197 |
198 | var hash = core_md5(ipad.concat(str2binl(data)), 512 + data.length * chrsz);
199 | return core_md5(opad.concat(hash), 512 + 128);
200 | }
201 |
202 | /*
203 |
204 | * Add integers, wrapping at 2^32. This uses 16-bit operations internally
205 |
206 | * to work around bugs in some JS interpreters.
207 |
208 | */
209 | function safe_add(x, y)
210 | {
211 | var lsw = (x & 0xFFFF) + (y & 0xFFFF);
212 | var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
213 | return (msw << 16) | (lsw & 0xFFFF);
214 | }
215 |
216 | /*
217 |
218 | * Bitwise rotate a 32-bit number to the left.
219 |
220 | */
221 | function bit_rol(num, cnt)
222 | {
223 | return (num << cnt) | (num >>> (32 - cnt));
224 | }
225 |
226 | /*
227 |
228 | * Convert a string to an array of little-endian words
229 |
230 | * If chrsz is ASCII, characters >255 have their hi-byte silently ignored.
231 |
232 | */
233 | function str2binl(str)
234 | {
235 | var bin = Array();
236 | var mask = (1 << chrsz) - 1;
237 | for(var i = 0; i < str.length * chrsz; i += chrsz)
238 | bin[i>>5] |= (str.charCodeAt(i / chrsz) & mask) << (i%32);
239 | return bin;
240 | }
241 |
242 | /*
243 |
244 | * Convert an array of little-endian words to a string
245 |
246 | */
247 | function binl2str(bin)
248 | {
249 | var str = "";
250 | var mask = (1 << chrsz) - 1;
251 | for(var i = 0; i < bin.length * 32; i += chrsz)
252 | str += String.fromCharCode((bin[i>>5] >>> (i % 32)) & mask);
253 | return str;
254 | }
255 |
256 | /*
257 |
258 | * Convert an array of little-endian words to a hex string.
259 |
260 | */
261 | function binl2hex(binarray)
262 | {
263 | var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef";
264 | var str = "";
265 | for(var i = 0; i < binarray.length * 4; i++)
266 | {
267 | str += hex_tab.charAt((binarray[i>>2] >> ((i%4)*8+4)) & 0xF) +
268 | hex_tab.charAt((binarray[i>>2] >> ((i%4)*8 )) & 0xF);
269 | }
270 | return str;
271 | }
272 |
273 | /*
274 |
275 | * Convert an array of little-endian words to a base-64 string
276 |
277 | */
278 | function binl2b64(binarray)
279 | {
280 | var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
281 | var str = "";
282 | for(var i = 0; i < binarray.length * 4; i += 3)
283 | {
284 | var triplet = (((binarray[i >> 2] >> 8 * ( i %4)) & 0xFF) << 16)
285 | | (((binarray[i+1 >> 2] >> 8 * ((i+1)%4)) & 0xFF) << 8 )
286 | | ((binarray[i+2 >> 2] >> 8 * ((i+2)%4)) & 0xFF);
287 | for(var j = 0; j < 4; j++)
288 | {
289 | if(i * 8 + j * 6 > binarray.length * 32) str += b64pad;
290 | else str += tab.charAt((triplet >> 6*(3-j)) & 0x3F);
291 | }
292 | }
293 | return str;
294 | }
--------------------------------------------------------------------------------
/lib/wxParse/html2json.js:
--------------------------------------------------------------------------------
1 | /**
2 | * html2Json 改造来自: https://github.com/Jxck/html2json
3 | *
4 | *
5 | * author: Di (微信小程序开发工程师)
6 | * organization: WeAppDev(微信小程序开发论坛)(http://weappdev.com)
7 | * 垂直微信小程序开发交流社区
8 | *
9 | * github地址: https://github.com/icindy/wxParse
10 | *
11 | * for: 微信小程序富文本解析
12 | * detail : http://weappdev.com/t/wxparse-alpha0-1-html-markdown/184
13 | */
14 |
15 | var __placeImgeUrlHttps = "https";
16 | var __emojisReg = '';
17 | var __emojisBaseSrc = '';
18 | var __emojis = {};
19 | var wxDiscode = require('./wxDiscode.js');
20 | var HTMLParser = require('./htmlparser.js');
21 | // Empty Elements - HTML 5
22 | var empty = makeMap("area,base,basefont,br,col,frame,hr,img,input,link,meta,param,embed,command,keygen,source,track,wbr");
23 | // Block Elements - HTML 5
24 | var block = makeMap("br,a,code,address,article,applet,aside,audio,blockquote,button,canvas,center,dd,del,dir,div,dl,dt,fieldset,figcaption,figure,footer,form,frameset,h1,h2,h3,h4,h5,h6,header,hgroup,hr,iframe,ins,isindex,li,map,menu,noframes,noscript,object,ol,output,p,pre,section,script,table,tbody,td,tfoot,th,thead,tr,ul,video");
25 |
26 | // Inline Elements - HTML 5
27 | var inline = makeMap("abbr,acronym,applet,b,basefont,bdo,big,button,cite,del,dfn,em,font,i,iframe,img,input,ins,kbd,label,map,object,q,s,samp,script,select,small,span,strike,strong,sub,sup,textarea,tt,u,var");
28 |
29 | // Elements that you can, intentionally, leave open
30 | // (and which close themselves)
31 | var closeSelf = makeMap("colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr");
32 |
33 | // Attributes that have their values filled in disabled="disabled"
34 | var fillAttrs = makeMap("checked,compact,declare,defer,disabled,ismap,multiple,nohref,noresize,noshade,nowrap,readonly,selected");
35 |
36 | // Special Elements (can contain anything)
37 | var special = makeMap("wxxxcode-style,script,style,view,scroll-view,block");
38 | function makeMap(str) {
39 | var obj = {}, items = str.split(",");
40 | for (var i = 0; i < items.length; i++)
41 | obj[items[i]] = true;
42 | return obj;
43 | }
44 |
45 | function q(v) {
46 | return '"' + v + '"';
47 | }
48 |
49 | function removeDOCTYPE(html) {
50 | return html
51 | .replace(/<\?xml.*\?>\n/, '')
52 | .replace(/<.*!doctype.*\>\n/, '')
53 | .replace(/<.*!DOCTYPE.*\>\n/, '');
54 | }
55 |
56 |
57 | function html2json(html, bindName) {
58 | //处理字符串
59 | html = removeDOCTYPE(html);
60 | html = wxDiscode.strDiscode(html);
61 | //生成node节点
62 | var bufArray = [];
63 | var results = {
64 | node: bindName,
65 | nodes: [],
66 | images:[],
67 | imageUrls:[]
68 | };
69 | var index = 0;
70 | HTMLParser(html, {
71 | start: function (tag, attrs, unary) {
72 | //debug(tag, attrs, unary);
73 | // node for this element
74 | var node = {
75 | node: 'element',
76 | tag: tag,
77 | };
78 |
79 | if (bufArray.length === 0) {
80 | node.index = index.toString()
81 | index += 1
82 | } else {
83 | var parent = bufArray[0];
84 | if (parent.nodes === undefined) {
85 | parent.nodes = [];
86 | }
87 | node.index = parent.index + '.' + parent.nodes.length
88 | }
89 |
90 | if (block[tag]) {
91 | node.tagType = "block";
92 | } else if (inline[tag]) {
93 | node.tagType = "inline";
94 | } else if (closeSelf[tag]) {
95 | node.tagType = "closeSelf";
96 | }
97 |
98 | if (attrs.length !== 0) {
99 | node.attr = attrs.reduce(function (pre, attr) {
100 | var name = attr.name;
101 | var value = attr.value;
102 | if (name == 'class') {
103 | console.dir(value);
104 | // value = value.join("")
105 | node.classStr = value;
106 | }
107 | // has multi attibutes
108 | // make it array of attribute
109 | if (name == 'style') {
110 | console.dir(value);
111 | // value = value.join("")
112 | node.styleStr = value;
113 | }
114 | if (value.match(/ /)) {
115 | value = value.split(' ');
116 | }
117 |
118 |
119 | // if attr already exists
120 | // merge it
121 | if (pre[name]) {
122 | if (Array.isArray(pre[name])) {
123 | // already array, push to last
124 | pre[name].push(value);
125 | } else {
126 | // single value, make it array
127 | pre[name] = [pre[name], value];
128 | }
129 | } else {
130 | // not exist, put it
131 | pre[name] = value;
132 | }
133 |
134 | return pre;
135 | }, {});
136 | }
137 |
138 | //对img添加额外数据
139 | if (node.tag === 'img') {
140 | node.imgIndex = results.images.length;
141 | var imgUrl = node.attr.src;
142 | if (imgUrl[0] == '') {
143 | imgUrl.splice(0, 1);
144 | }
145 | imgUrl = wxDiscode.urlToHttpUrl(imgUrl, __placeImgeUrlHttps);
146 |
147 | var strDomain = 'https://www.tianjia.net.cn';
148 | if (!imgUrl.startsWith(strDomain)) {
149 | imgUrl = strDomain + imgUrl;
150 | }
151 |
152 | node.attr.src = imgUrl;
153 | node.from = bindName;
154 | results.images.push(node);
155 | results.imageUrls.push(imgUrl);
156 | }
157 |
158 | // 处理font标签样式属性
159 | if (node.tag === 'font') {
160 | var fontSize = ['x-small', 'small', 'medium', 'large', 'x-large', 'xx-large', '-webkit-xxx-large'];
161 | var styleAttrs = {
162 | 'color': 'color',
163 | 'face': 'font-family',
164 | 'size': 'font-size'
165 | };
166 | if (!node.attr.style) node.attr.style = [];
167 | if (!node.styleStr) node.styleStr = '';
168 | for (var key in styleAttrs) {
169 | if (node.attr[key]) {
170 | var value = key === 'size' ? fontSize[node.attr[key]-1] : node.attr[key];
171 | node.attr.style.push(styleAttrs[key]);
172 | node.attr.style.push(value);
173 | node.styleStr += styleAttrs[key] + ': ' + value + ';';
174 | }
175 | }
176 | }
177 |
178 | //临时记录source资源
179 | if(node.tag === 'source'){
180 | results.source = node.attr.src;
181 | }
182 |
183 | if (unary) {
184 | // if this tag dosen't have end tag
185 | // like
186 | // add to parents
187 | var parent = bufArray[0] || results;
188 | if (parent.nodes === undefined) {
189 | parent.nodes = [];
190 | }
191 | parent.nodes.push(node);
192 | } else {
193 | bufArray.unshift(node);
194 | }
195 | },
196 | end: function (tag) {
197 | //debug(tag);
198 | // merge into parent tag
199 | var node = bufArray.shift();
200 | if (node.tag !== tag) console.error('invalid state: mismatch end tag');
201 |
202 | //当有缓存source资源时于于video补上src资源
203 | if(node.tag === 'video' && results.source){
204 | node.attr.src = results.source;
205 | delete result.source;
206 | }
207 |
208 | if (bufArray.length === 0) {
209 | results.nodes.push(node);
210 | } else {
211 | var parent = bufArray[0];
212 | if (parent.nodes === undefined) {
213 | parent.nodes = [];
214 | }
215 | parent.nodes.push(node);
216 | }
217 | },
218 | chars: function (text) {
219 | //debug(text);
220 | var node = {
221 | node: 'text',
222 | text: text,
223 | textArray:transEmojiStr(text)
224 | };
225 |
226 | if (bufArray.length === 0) {
227 | results.nodes.push(node);
228 | } else {
229 | var parent = bufArray[0];
230 | if (parent.nodes === undefined) {
231 | parent.nodes = [];
232 | }
233 | node.index = parent.index + '.' + parent.nodes.length
234 | parent.nodes.push(node);
235 | }
236 | },
237 | comment: function (text) {
238 | //debug(text);
239 | // var node = {
240 | // node: 'comment',
241 | // text: text,
242 | // };
243 | // var parent = bufArray[0];
244 | // if (parent.nodes === undefined) {
245 | // parent.nodes = [];
246 | // }
247 | // parent.nodes.push(node);
248 | },
249 | });
250 | return results;
251 | };
252 |
253 | function transEmojiStr(str){
254 | // var eReg = new RegExp("["+__reg+' '+"]");
255 | // str = str.replace(/\[([^\[\]]+)\]/g,':$1:')
256 |
257 | var emojiObjs = [];
258 | //如果正则表达式为空
259 | if(__emojisReg.length == 0 || !__emojis){
260 | var emojiObj = {}
261 | emojiObj.node = "text";
262 | emojiObj.text = str;
263 | array = [emojiObj];
264 | return array;
265 | }
266 | //这个地方需要调整
267 | str = str.replace(/\[([^\[\]]+)\]/g,':$1:')
268 | var eReg = new RegExp("[:]");
269 | var array = str.split(eReg);
270 | for(var i = 0; i < array.length; i++){
271 | var ele = array[i];
272 | var emojiObj = {};
273 | if(__emojis[ele]){
274 | emojiObj.node = "element";
275 | emojiObj.tag = "emoji";
276 | emojiObj.text = __emojis[ele];
277 | emojiObj.baseSrc= __emojisBaseSrc;
278 | }else{
279 | emojiObj.node = "text";
280 | emojiObj.text = ele;
281 | }
282 | emojiObjs.push(emojiObj);
283 | }
284 |
285 | return emojiObjs;
286 | }
287 |
288 | function emojisInit(reg='',baseSrc="/wxParse/emojis/",emojis){
289 | __emojisReg = reg;
290 | __emojisBaseSrc=baseSrc;
291 | __emojis=emojis;
292 | }
293 |
294 | module.exports = {
295 | html2json: html2json,
296 | emojisInit:emojisInit
297 | };
298 |
299 |
--------------------------------------------------------------------------------
/lib/wxParse/htmlparser.js:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * htmlParser改造自: https://github.com/blowsie/Pure-JavaScript-HTML5-Parser
4 | *
5 | * author: Di (微信小程序开发工程师)
6 | * organization: WeAppDev(微信小程序开发论坛)(http://weappdev.com)
7 | * 垂直微信小程序开发交流社区
8 | *
9 | * github地址: https://github.com/icindy/wxParse
10 | *
11 | * for: 微信小程序富文本解析
12 | * detail : http://weappdev.com/t/wxparse-alpha0-1-html-markdown/184
13 | */
14 | // Regular Expressions for parsing tags and attributes
15 | var startTag = /^<([-A-Za-z0-9_]+)((?:\s+[a-zA-Z_:][-a-zA-Z0-9_:.]*(?:\s*=\s*(?:(?:"[^"]*")|(?:'[^']*')|[^>\s]+))?)*)\s*(\/?)>/,
16 | endTag = /^<\/([-A-Za-z0-9_]+)[^>]*>/,
17 | attr = /([a-zA-Z_:][-a-zA-Z0-9_:.]*)(?:\s*=\s*(?:(?:"((?:\\.|[^"])*)")|(?:'((?:\\.|[^'])*)')|([^>\s]+)))?/g;
18 |
19 | // Empty Elements - HTML 5
20 | var empty = makeMap("area,base,basefont,br,col,frame,hr,img,input,link,meta,param,embed,command,keygen,source,track,wbr");
21 |
22 | // Block Elements - HTML 5
23 | var block = makeMap("a,address,code,article,applet,aside,audio,blockquote,button,canvas,center,dd,del,dir,div,dl,dt,fieldset,figcaption,figure,footer,form,frameset,h1,h2,h3,h4,h5,h6,header,hgroup,hr,iframe,ins,isindex,li,map,menu,noframes,noscript,object,ol,output,p,pre,section,script,table,tbody,td,tfoot,th,thead,tr,ul,video");
24 |
25 | // Inline Elements - HTML 5
26 | var inline = makeMap("abbr,acronym,applet,b,basefont,bdo,big,br,button,cite,del,dfn,em,font,i,iframe,img,input,ins,kbd,label,map,object,q,s,samp,script,select,small,span,strike,strong,sub,sup,textarea,tt,u,var");
27 |
28 | // Elements that you can, intentionally, leave open
29 | // (and which close themselves)
30 | var closeSelf = makeMap("colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr");
31 |
32 | // Attributes that have their values filled in disabled="disabled"
33 | var fillAttrs = makeMap("checked,compact,declare,defer,disabled,ismap,multiple,nohref,noresize,noshade,nowrap,readonly,selected");
34 |
35 | // Special Elements (can contain anything)
36 | var special = makeMap("wxxxcode-style,script,style,view,scroll-view,block");
37 |
38 | function HTMLParser(html, handler) {
39 | var index, chars, match, stack = [], last = html;
40 | stack.last = function () {
41 | return this[this.length - 1];
42 | };
43 |
44 | while (html) {
45 | chars = true;
46 |
47 | // Make sure we're not in a script or style element
48 | if (!stack.last() || !special[stack.last()]) {
49 |
50 | // Comment
51 | if (html.indexOf("");
53 |
54 | if (index >= 0) {
55 | if (handler.comment)
56 | handler.comment(html.substring(4, index));
57 | html = html.substring(index + 3);
58 | chars = false;
59 | }
60 |
61 | // end tag
62 | } else if (html.indexOf("") == 0) {
63 | match = html.match(endTag);
64 |
65 | if (match) {
66 | html = html.substring(match[0].length);
67 | match[0].replace(endTag, parseEndTag);
68 | chars = false;
69 | }
70 |
71 | // start tag
72 | } else if (html.indexOf("<") == 0) {
73 | match = html.match(startTag);
74 |
75 | if (match) {
76 | html = html.substring(match[0].length);
77 | match[0].replace(startTag, parseStartTag);
78 | chars = false;
79 | }
80 | }
81 |
82 | if (chars) {
83 | index = html.indexOf("<");
84 | var text = ''
85 | while (index === 0) {
86 | text += "<";
87 | html = html.substring(1);
88 | index = html.indexOf("<");
89 | }
90 | text += index < 0 ? html : html.substring(0, index);
91 | html = index < 0 ? "" : html.substring(index);
92 |
93 | if (handler.chars)
94 | handler.chars(text);
95 | }
96 |
97 | } else {
98 |
99 | html = html.replace(new RegExp("([\\s\\S]*?)<\/" + stack.last() + "[^>]*>"), function (all, text) {
100 | text = text.replace(/|/g, "$1$2");
101 | if (handler.chars)
102 | handler.chars(text);
103 |
104 | return "";
105 | });
106 |
107 |
108 | parseEndTag("", stack.last());
109 | }
110 |
111 | if (html == last)
112 | throw "Parse Error: " + html;
113 | last = html;
114 | }
115 |
116 | // Clean up any remaining tags
117 | parseEndTag();
118 |
119 | function parseStartTag(tag, tagName, rest, unary) {
120 | tagName = tagName.toLowerCase();
121 |
122 | if (block[tagName]) {
123 | while (stack.last() && inline[stack.last()]) {
124 | parseEndTag("", stack.last());
125 | }
126 | }
127 |
128 | if (closeSelf[tagName] && stack.last() == tagName) {
129 | parseEndTag("", tagName);
130 | }
131 |
132 | unary = empty[tagName] || !!unary;
133 |
134 | if (!unary)
135 | stack.push(tagName);
136 |
137 | if (handler.start) {
138 | var attrs = [];
139 |
140 | rest.replace(attr, function (match, name) {
141 | var value = arguments[2] ? arguments[2] :
142 | arguments[3] ? arguments[3] :
143 | arguments[4] ? arguments[4] :
144 | fillAttrs[name] ? name : "";
145 |
146 | attrs.push({
147 | name: name,
148 | value: value,
149 | escaped: value.replace(/(^|[^\\])"/g, '$1\\\"') //"
150 | });
151 | });
152 |
153 | if (handler.start) {
154 | handler.start(tagName, attrs, unary);
155 | }
156 |
157 | }
158 | }
159 |
160 | function parseEndTag(tag, tagName) {
161 | // If no tag name is provided, clean shop
162 | if (!tagName)
163 | var pos = 0;
164 |
165 | // Find the closest opened tag of the same type
166 | else {
167 | tagName = tagName.toLowerCase();
168 | for (var pos = stack.length - 1; pos >= 0; pos--)
169 | if (stack[pos] == tagName)
170 | break;
171 | }
172 | if (pos >= 0) {
173 | // Close all the open elements, up the stack
174 | for (var i = stack.length - 1; i >= pos; i--)
175 | if (handler.end)
176 | handler.end(stack[i]);
177 |
178 | // Remove the open elements from the stack
179 | stack.length = pos;
180 | }
181 | }
182 | };
183 |
184 |
185 | function makeMap(str) {
186 | var obj = {}, items = str.split(",");
187 | for (var i = 0; i < items.length; i++)
188 | obj[items[i]] = true;
189 | return obj;
190 | }
191 |
192 | module.exports = HTMLParser;
193 |
--------------------------------------------------------------------------------
/lib/wxParse/wxDiscode.js:
--------------------------------------------------------------------------------
1 | // HTML 支持的数学符号
2 | function strNumDiscode(str){
3 | str = str.replace(/∀/g, '∀');
4 | str = str.replace(/∂/g, '∂');
5 | str = str.replace(/&exists;/g, '∃');
6 | str = str.replace(/∅/g, '∅');
7 | str = str.replace(/∇/g, '∇');
8 | str = str.replace(/∈/g, '∈');
9 | str = str.replace(/∉/g, '∉');
10 | str = str.replace(/∋/g, '∋');
11 | str = str.replace(/∏/g, '∏');
12 | str = str.replace(/∑/g, '∑');
13 | str = str.replace(/−/g, '−');
14 | str = str.replace(/∗/g, '∗');
15 | str = str.replace(/√/g, '√');
16 | str = str.replace(/∝/g, '∝');
17 | str = str.replace(/∞/g, '∞');
18 | str = str.replace(/∠/g, '∠');
19 | str = str.replace(/∧/g, '∧');
20 | str = str.replace(/∨/g, '∨');
21 | str = str.replace(/∩/g, '∩');
22 | str = str.replace(/∩/g, '∪');
23 | str = str.replace(/∫/g, '∫');
24 | str = str.replace(/∴/g, '∴');
25 | str = str.replace(/∼/g, '∼');
26 | str = str.replace(/≅/g, '≅');
27 | str = str.replace(/≈/g, '≈');
28 | str = str.replace(/≠/g, '≠');
29 | str = str.replace(/≤/g, '≤');
30 | str = str.replace(/≥/g, '≥');
31 | str = str.replace(/⊂/g, '⊂');
32 | str = str.replace(/⊃/g, '⊃');
33 | str = str.replace(/⊄/g, '⊄');
34 | str = str.replace(/⊆/g, '⊆');
35 | str = str.replace(/⊇/g, '⊇');
36 | str = str.replace(/⊕/g, '⊕');
37 | str = str.replace(/⊗/g, '⊗');
38 | str = str.replace(/⊥/g, '⊥');
39 | str = str.replace(/⋅/g, '⋅');
40 | return str;
41 | }
42 |
43 | //HTML 支持的希腊字母
44 | function strGreeceDiscode(str){
45 | str = str.replace(/Α/g, 'Α');
46 | str = str.replace(/Β/g, 'Β');
47 | str = str.replace(/Γ/g, 'Γ');
48 | str = str.replace(/Δ/g, 'Δ');
49 | str = str.replace(/Ε/g, 'Ε');
50 | str = str.replace(/Ζ/g, 'Ζ');
51 | str = str.replace(/Η/g, 'Η');
52 | str = str.replace(/Θ/g, 'Θ');
53 | str = str.replace(/Ι/g, 'Ι');
54 | str = str.replace(/Κ/g, 'Κ');
55 | str = str.replace(/Λ/g, 'Λ');
56 | str = str.replace(/Μ/g, 'Μ');
57 | str = str.replace(/Ν/g, 'Ν');
58 | str = str.replace(/Ξ/g, 'Ν');
59 | str = str.replace(/Ο/g, 'Ο');
60 | str = str.replace(/Π/g, 'Π');
61 | str = str.replace(/Ρ/g, 'Ρ');
62 | str = str.replace(/Σ/g, 'Σ');
63 | str = str.replace(/Τ/g, 'Τ');
64 | str = str.replace(/Υ/g, 'Υ');
65 | str = str.replace(/Φ/g, 'Φ');
66 | str = str.replace(/Χ/g, 'Χ');
67 | str = str.replace(/Ψ/g, 'Ψ');
68 | str = str.replace(/Ω/g, 'Ω');
69 |
70 | str = str.replace(/α/g, 'α');
71 | str = str.replace(/β/g, 'β');
72 | str = str.replace(/γ/g, 'γ');
73 | str = str.replace(/δ/g, 'δ');
74 | str = str.replace(/ε/g, 'ε');
75 | str = str.replace(/ζ/g, 'ζ');
76 | str = str.replace(/η/g, 'η');
77 | str = str.replace(/θ/g, 'θ');
78 | str = str.replace(/ι/g, 'ι');
79 | str = str.replace(/κ/g, 'κ');
80 | str = str.replace(/λ/g, 'λ');
81 | str = str.replace(/μ/g, 'μ');
82 | str = str.replace(/ν/g, 'ν');
83 | str = str.replace(/ξ/g, 'ξ');
84 | str = str.replace(/ο/g, 'ο');
85 | str = str.replace(/π/g, 'π');
86 | str = str.replace(/ρ/g, 'ρ');
87 | str = str.replace(/ς/g, 'ς');
88 | str = str.replace(/σ/g, 'σ');
89 | str = str.replace(/τ/g, 'τ');
90 | str = str.replace(/υ/g, 'υ');
91 | str = str.replace(/φ/g, 'φ');
92 | str = str.replace(/χ/g, 'χ');
93 | str = str.replace(/ψ/g, 'ψ');
94 | str = str.replace(/ω/g, 'ω');
95 | str = str.replace(/ϑ/g, 'ϑ');
96 | str = str.replace(/ϒ/g, 'ϒ');
97 | str = str.replace(/ϖ/g, 'ϖ');
98 | str = str.replace(/·/g, '·');
99 | return str;
100 | }
101 |
102 | //
103 |
104 | function strcharacterDiscode(str){
105 | // 加入常用解析
106 | str = str.replace(/ /g, ' ');
107 | str = str.replace(/"/g, "'");
108 | str = str.replace(/&/g, '&');
109 | // str = str.replace(/</g, '‹');
110 | // str = str.replace(/>/g, '›');
111 |
112 | str = str.replace(/</g, '<');
113 | str = str.replace(/>/g, '>');
114 |
115 | return str;
116 | }
117 |
118 | // HTML 支持的其他实体
119 | function strOtherDiscode(str){
120 | str = str.replace(/Œ/g, 'Œ');
121 | str = str.replace(/œ/g, 'œ');
122 | str = str.replace(/Š/g, 'Š');
123 | str = str.replace(/š/g, 'š');
124 | str = str.replace(/Ÿ/g, 'Ÿ');
125 | str = str.replace(/ƒ/g, 'ƒ');
126 | str = str.replace(/ˆ/g, 'ˆ');
127 | str = str.replace(/˜/g, '˜');
128 | str = str.replace(/ /g, '');
129 | str = str.replace(/ /g, '');
130 | str = str.replace(/ /g, '');
131 | str = str.replace(//g, '');
132 | str = str.replace(//g, '');
133 | str = str.replace(//g, '');
134 | str = str.replace(//g, '');
135 | str = str.replace(/–/g, '–');
136 | str = str.replace(/—/g, '—');
137 | str = str.replace(/‘/g, '‘');
138 | str = str.replace(/’/g, '’');
139 | str = str.replace(/‚/g, '‚');
140 | str = str.replace(/“/g, '“');
141 | str = str.replace(/”/g, '”');
142 | str = str.replace(/„/g, '„');
143 | str = str.replace(/†/g, '†');
144 | str = str.replace(/‡/g, '‡');
145 | str = str.replace(/•/g, '•');
146 | str = str.replace(/…/g, '…');
147 | str = str.replace(/‰/g, '‰');
148 | str = str.replace(/′/g, '′');
149 | str = str.replace(/″/g, '″');
150 | str = str.replace(/‹/g, '‹');
151 | str = str.replace(/›/g, '›');
152 | str = str.replace(/‾/g, '‾');
153 | str = str.replace(/€/g, '€');
154 | str = str.replace(/™/g, '™');
155 |
156 | str = str.replace(/←/g, '←');
157 | str = str.replace(/↑/g, '↑');
158 | str = str.replace(/→/g, '→');
159 | str = str.replace(/↓/g, '↓');
160 | str = str.replace(/↔/g, '↔');
161 | str = str.replace(/↵/g, '↵');
162 | str = str.replace(/⌈/g, '⌈');
163 | str = str.replace(/⌉/g, '⌉');
164 |
165 | str = str.replace(/⌊/g, '⌊');
166 | str = str.replace(/⌋/g, '⌋');
167 | str = str.replace(/◊/g, '◊');
168 | str = str.replace(/♠/g, '♠');
169 | str = str.replace(/♣/g, '♣');
170 | str = str.replace(/♥/g, '♥');
171 |
172 | str = str.replace(/♦/g, '♦');
173 | str = str.replace(/'/g, '\'');
174 | return str;
175 | }
176 |
177 | function strMoreDiscode(str){
178 | str = str.replace(/\r\n/g,"");
179 | str = str.replace(/\n/g,"");
180 |
181 | str = str.replace(/code/g,"wxxxcode-style");
182 | return str;
183 | }
184 |
185 | function strDiscode(str){
186 | str = strNumDiscode(str);
187 | str = strGreeceDiscode(str);
188 | str = strcharacterDiscode(str);
189 | str = strOtherDiscode(str);
190 | str = strMoreDiscode(str);
191 | return str;
192 | }
193 | function urlToHttpUrl(url,rep){
194 |
195 | var patt1 = new RegExp("^//");
196 | var result = patt1.test(url);
197 | if(result){
198 | url = rep+":"+url;
199 | }
200 | return url;
201 | }
202 |
203 | module.exports = {
204 | strDiscode:strDiscode,
205 | urlToHttpUrl:urlToHttpUrl
206 | }
--------------------------------------------------------------------------------
/lib/wxParse/wxParse.js:
--------------------------------------------------------------------------------
1 | /**
2 | * author: Di (微信小程序开发工程师)
3 | * organization: WeAppDev(微信小程序开发论坛)(http://weappdev.com)
4 | * 垂直微信小程序开发交流社区
5 | *
6 | * github地址: https://github.com/icindy/wxParse
7 | *
8 | * for: 微信小程序富文本解析
9 | * detail : http://weappdev.com/t/wxparse-alpha0-1-html-markdown/184
10 | */
11 |
12 | /**
13 | * utils函数引入
14 | **/
15 | import showdown from './showdown.js';
16 | import HtmlToJson from './html2json.js';
17 | /**
18 | * 配置及公有属性
19 | **/
20 | var realWindowWidth = 0;
21 | var realWindowHeight = 0;
22 | wx.getSystemInfo({
23 | success: function (res) {
24 | realWindowWidth = res.windowWidth
25 | realWindowHeight = res.windowHeight
26 | }
27 | })
28 | /**
29 | * 主函数入口区
30 | **/
31 | function wxParse(bindName = 'wxParseData', type='html', data='
数据不能为空
', target,imagePadding) {
32 | var that = target;
33 | var transData = {};//存放转化后的数据
34 | if (type == 'html') {
35 | transData = HtmlToJson.html2json(data, bindName);
36 | console.log(JSON.stringify(transData, ' ', ' '));
37 | } else if (type == 'md' || type == 'markdown') {
38 | var converter = new showdown.Converter();
39 | var html = converter.makeHtml(data);
40 | transData = HtmlToJson.html2json(html, bindName);
41 | console.log(JSON.stringify(transData, ' ', ' '));
42 | }
43 | transData.view = {};
44 | transData.view.imagePadding = 0;
45 | if(typeof(imagePadding) != 'undefined'){
46 | transData.view.imagePadding = imagePadding
47 | }
48 | var bindData = {};
49 | bindData[bindName] = transData;
50 | that.setData(bindData)
51 | that.wxParseImgLoad = wxParseImgLoad;
52 | that.wxParseImgTap = wxParseImgTap;
53 | }
54 | // 图片点击事件
55 | function wxParseImgTap(e) {
56 | var that = this;
57 | var nowImgUrl = e.target.dataset.src;
58 | var tagFrom = e.target.dataset.from;
59 | if (typeof (tagFrom) != 'undefined' && tagFrom.length > 0) {
60 | wx.previewImage({
61 | current: nowImgUrl, // 当前显示图片的http链接
62 | urls: that.data[tagFrom].imageUrls // 需要预览的图片http链接列表
63 | })
64 | }
65 | }
66 |
67 | /**
68 | * 图片视觉宽高计算函数区
69 | **/
70 | function wxParseImgLoad(e) {
71 | var that = this;
72 | var tagFrom = e.target.dataset.from;
73 | var idx = e.target.dataset.idx;
74 | if (typeof (tagFrom) != 'undefined' && tagFrom.length > 0) {
75 | calMoreImageInfo(e, idx, that, tagFrom)
76 | }
77 | }
78 | // 假循环获取计算图片视觉最佳宽高
79 | function calMoreImageInfo(e, idx, that, bindName) {
80 | var temData = that.data[bindName];
81 | if (!temData || temData.images.length == 0) {
82 | return;
83 | }
84 | var temImages = temData.images;
85 | //因为无法获取view宽度 需要自定义padding进行计算,稍后处理
86 | var recal = wxAutoImageCal(e.detail.width, e.detail.height,that,bindName);
87 | // temImages[idx].width = recal.imageWidth;
88 | // temImages[idx].height = recal.imageheight;
89 | // temData.images = temImages;
90 | // var bindData = {};
91 | // bindData[bindName] = temData;
92 | // that.setData(bindData);
93 | var index = temImages[idx].index
94 | var key = `${bindName}`
95 | for (var i of index.split('.')) key+=`.nodes[${i}]`
96 | var keyW = key + '.width'
97 | var keyH = key + '.height'
98 | that.setData({
99 | [keyW]: recal.imageWidth,
100 | [keyH]: recal.imageheight,
101 | })
102 | }
103 |
104 | // 计算视觉优先的图片宽高
105 | function wxAutoImageCal(originalWidth, originalHeight,that,bindName) {
106 | //获取图片的原始长宽
107 | var windowWidth = 0, windowHeight = 0;
108 | var autoWidth = 0, autoHeight = 0;
109 | var results = {};
110 | var padding = that.data[bindName].view.imagePadding;
111 | windowWidth = realWindowWidth-2*padding;
112 | windowHeight = realWindowHeight;
113 | //判断按照那种方式进行缩放
114 | // console.log("windowWidth" + windowWidth);
115 | if (originalWidth > windowWidth) {//在图片width大于手机屏幕width时候
116 | autoWidth = windowWidth;
117 | // console.log("autoWidth" + autoWidth);
118 | autoHeight = (autoWidth * originalHeight) / originalWidth;
119 | // console.log("autoHeight" + autoHeight);
120 | results.imageWidth = autoWidth;
121 | results.imageheight = autoHeight;
122 | } else {//否则展示原来的数据
123 | results.imageWidth = originalWidth;
124 | results.imageheight = originalHeight;
125 | }
126 | return results;
127 | }
128 |
129 | function wxParseTemArray(temArrayName,bindNameReg,total,that){
130 | var array = [];
131 | var temData = that.data;
132 | var obj = null;
133 | for(var i = 0; i < total; i++){
134 | var simArr = temData[bindNameReg+i].nodes;
135 | array.push(simArr);
136 | }
137 |
138 | temArrayName = temArrayName || 'wxParseTemArray';
139 | obj = JSON.parse('{"'+ temArrayName +'":""}');
140 | obj[temArrayName] = array;
141 | that.setData(obj);
142 | }
143 |
144 | /**
145 | * 配置emojis
146 | *
147 | */
148 |
149 | function emojisInit(reg='',baseSrc="/wxParse/emojis/",emojis){
150 | HtmlToJson.emojisInit(reg,baseSrc,emojis);
151 | }
152 |
153 | module.exports = {
154 | wxParse: wxParse,
155 | wxParseTemArray:wxParseTemArray,
156 | emojisInit:emojisInit
157 | }
158 |
159 |
160 |
--------------------------------------------------------------------------------
/lib/wxParse/wxParse.wxml:
--------------------------------------------------------------------------------
1 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
31 |
32 |
33 |
34 |
35 |
36 | {{item.text}}
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 | \n
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 |
194 |
195 |
196 |
197 |
198 |
199 |
200 |
201 |
202 |
203 |
204 |
205 |
206 |
207 |
208 |
209 |
210 |
211 |
212 |
213 |
214 |
215 |
216 |
217 |
218 |
219 |
220 |
221 |
222 |
223 |
224 |
229 |
230 |
231 |
232 |
233 |
234 |
235 |
236 |
237 |
238 |
239 |
240 |
241 |
242 |
243 |
244 |
245 |
246 |
247 |
248 |
249 |
250 |
251 |
252 |
253 |
254 |
255 |
256 |
257 |
258 |
259 |
260 |
261 |
262 |
263 |
264 |
265 |
266 |
267 |
268 |
269 |
270 |
271 |
272 |
273 |
274 |
275 |
276 |
277 |
278 |
279 |
280 |
281 |
282 |
283 |
284 |
285 |
286 |
287 |
288 |
289 |
290 |
291 |
292 |
293 |
294 |
295 |
296 |
297 |
298 |
299 |
300 |
305 |
306 |
307 |
308 |
309 |
310 |
311 |
312 |
313 |
314 |
315 |
316 |
317 |
318 |
319 |
320 |
321 |
322 |
323 |
324 |
325 |
326 |
327 |
328 |
329 |
330 |
331 |
332 |
333 |
334 |
335 |
336 |
337 |
338 |
339 |
340 |
341 |
342 |
343 |
344 |
345 |
346 |
347 |
348 |
349 |
350 |
351 |
352 |
353 |
354 |
355 |
356 |
357 |
358 |
359 |
360 |
361 |
362 |
363 |
364 |
365 |
366 |
367 |
368 |
369 |
370 |
371 |
372 |
373 |
374 |
375 |
376 |
381 |
382 |
383 |
384 |
385 |
386 |
387 |
388 |
389 |
390 |
391 |
392 |
393 |
394 |
395 |
396 |
397 |
398 |
399 |
400 |
401 |
402 |
403 |
404 |
405 |
406 |
407 |
408 |
409 |
410 |
411 |
412 |
413 |
414 |
415 |
416 |
417 |
418 |
419 |
420 |
421 |
422 |
423 |
424 |
425 |
426 |
427 |
428 |
429 |
430 |
431 |
432 |
433 |
434 |
435 |
436 |
437 |
438 |
439 |
440 |
441 |
442 |
443 |
444 |
445 |
446 |
447 |
448 |
449 |
450 |
451 |
452 |
457 |
458 |
459 |
460 |
461 |
462 |
463 |
464 |
465 |
466 |
467 |
468 |
469 |
470 |
471 |
472 |
473 |
474 |
475 |
476 |
477 |
478 |
479 |
480 |
481 |
482 |
483 |
484 |
485 |
486 |
487 |
488 |
489 |
490 |
491 |
492 |
493 |
494 |
495 |
496 |
497 |
498 |
499 |
500 |
501 |
502 |
503 |
504 |
505 |
506 |
507 |
508 |
509 |
510 |
511 |
512 |
513 |
514 |
515 |
516 |
517 |
518 |
519 |
520 |
521 |
522 |
523 |
524 |
525 |
526 |
527 |
528 |
533 |
534 |
535 |
536 |
537 |
538 |
539 |
540 |
541 |
542 |
543 |
544 |
545 |
546 |
547 |
548 |
549 |
550 |
551 |
552 |
553 |
554 |
555 |
556 |
557 |
558 |
559 |
560 |
561 |
562 |
563 |
564 |
565 |
566 |
567 |
568 |
569 |
570 |
571 |
572 |
573 |
574 |
575 |
576 |
577 |
578 |
579 |
580 |
581 |
582 |
583 |
584 |
585 |
586 |
587 |
588 |
589 |
590 |
591 |
592 |
593 |
594 |
595 |
596 |
597 |
598 |
599 |
600 |
601 |
602 |
603 |
608 |
609 |
610 |
611 |
612 |
613 |
614 |
615 |
616 |
617 |
618 |
619 |
620 |
621 |
622 |
623 |
624 |
625 |
626 |
627 |
628 |
629 |
630 |
631 |
632 |
633 |
634 |
635 |
636 |
637 |
638 |
639 |
640 |
641 |
642 |
643 |
644 |
645 |
646 |
647 |
648 |
649 |
650 |
651 |
652 |
653 |
654 |
655 |
656 |
657 |
658 |
659 |
660 |
661 |
662 |
663 |
664 |
665 |
666 |
667 |
668 |
669 |
670 |
671 |
672 |
673 |
674 |
675 |
676 |
677 |
678 |
679 |
684 |
685 |
686 |
687 |
688 |
689 |
690 |
691 |
692 |
693 |
694 |
695 |
696 |
697 |
698 |
699 |
700 |
701 |
702 |
703 |
704 |
705 |
706 |
707 |
708 |
709 |
710 |
711 |
712 |
713 |
714 |
715 |
716 |
717 |
718 |
719 |
720 |
721 |
722 |
723 |
724 |
725 |
726 |
727 |
728 |
729 |
730 |
731 |
732 |
733 |
734 |
735 |
736 |
737 |
738 |
739 |
740 |
741 |
742 |
743 |
744 |
745 |
746 |
747 |
748 |
749 |
750 |
751 |
752 |
753 |
754 |
755 |
760 |
761 |
762 |
763 |
764 |
765 |
766 |
767 |
768 |
769 |
770 |
771 |
772 |
773 |
774 |
775 |
776 |
777 |
778 |
779 |
780 |
781 |
782 |
783 |
784 |
785 |
786 |
787 |
788 |
789 |
790 |
791 |
792 |
793 |
794 |
795 |
796 |
797 |
798 |
799 |
800 |
801 |
802 |
803 |
804 |
805 |
806 |
807 |
808 |
809 |
810 |
811 |
812 |
813 |
814 |
815 |
816 |
817 |
818 |
819 |
820 |
821 |
822 |
823 |
824 |
825 |
826 |
827 |
828 |
829 |
830 |
831 |
836 |
837 |
838 |
839 |
840 |
841 |
842 |
843 |
844 |
845 |
846 |
847 |
848 |
849 |
850 |
851 |
852 |
853 |
854 |
855 |
856 |
857 |
858 |
859 |
860 |
861 |
862 |
863 |
864 |
865 |
866 |
867 |
868 |
869 |
870 |
871 |
872 |
873 |
874 |
875 |
876 |
877 |
878 |
879 |
880 |
881 |
882 |
883 |
884 |
885 |
886 |
887 |
888 |
889 |
890 |
891 |
892 |
893 |
894 |
895 |
896 |
897 |
898 |
899 |
900 |
901 |
902 |
903 |
904 |
905 |
906 |
907 |
912 |
913 |
914 |
915 |
916 |
917 |
918 |
919 |
920 |
921 |
922 |
923 |
924 |
925 |
926 |
927 |
928 |
929 |
930 |
931 |
932 |
933 |
934 |
935 |
936 |
937 |
938 |
939 |
940 |
941 |
942 |
943 |
944 |
945 |
946 |
947 |
948 |
949 |
950 |
951 |
952 |
953 |
954 |
955 |
956 |
957 |
958 |
959 |
960 |
961 |
962 |
963 |
964 |
965 |
966 |
967 |
968 |
969 |
970 |
971 |
972 |
973 |
974 |
975 |
--------------------------------------------------------------------------------
/lib/wxParse/wxParse.wxss:
--------------------------------------------------------------------------------
1 |
2 | /**
3 | * author: Di (微信小程序开发工程师)
4 | * organization: WeAppDev(微信小程序开发论坛)(http://weappdev.com)
5 | * 垂直微信小程序开发交流社区
6 | *
7 | * github地址: https://github.com/icindy/wxParse
8 | *
9 | * for: 微信小程序富文本解析
10 | * detail : http://weappdev.com/t/wxparse-alpha0-1-html-markdown/184
11 | */
12 |
13 | .wxParse{
14 | margin: 0 5px;
15 | font-family: Helvetica,sans-serif;
16 | font-size: 28rpx;
17 | color: #666;
18 | line-height: 1.8;
19 | }
20 | view{
21 | word-break:break-all; overflow:auto;
22 | }
23 | .wxParse-inline{
24 | display: inline;
25 | margin: 0;
26 | padding: 0;
27 | }
28 | /*//标题 */
29 | .wxParse-div{margin: 0;padding: 0;}
30 | .wxParse-h1{ font-size:2em; margin: .67em 0 }
31 | .wxParse-h2{ font-size:1.5em; margin: .75em 0 }
32 | .wxParse-h3{ font-size:1.17em; margin: .83em 0 }
33 | .wxParse-h4{ margin: 1.12em 0}
34 | .wxParse-h5 { font-size:.83em; margin: 1.5em 0 }
35 | .wxParse-h6{ font-size:.75em; margin: 1.67em 0 }
36 |
37 | .wxParse-h1 {
38 | font-size: 18px;
39 | font-weight: 400;
40 | margin-bottom: .9em;
41 | }
42 | .wxParse-h2 {
43 | font-size: 16px;
44 | font-weight: 400;
45 | margin-bottom: .34em;
46 | }
47 | .wxParse-h3 {
48 | font-weight: 400;
49 | font-size: 15px;
50 | margin-bottom: .34em;
51 | }
52 | .wxParse-h4 {
53 | font-weight: 400;
54 | font-size: 14px;
55 | margin-bottom: .24em;
56 | }
57 | .wxParse-h5 {
58 | font-weight: 400;
59 | font-size: 13px;
60 | margin-bottom: .14em;
61 | }
62 | .wxParse-h6 {
63 | font-weight: 400;
64 | font-size: 12px;
65 | margin-bottom: .04em;
66 | }
67 |
68 | .wxParse-h1, .wxParse-h2, .wxParse-h3, .wxParse-h4, .wxParse-h5, .wxParse-h6, .wxParse-b, .wxParse-strong { font-weight: bolder }
69 |
70 | .wxParse-i,.wxParse-cite,.wxParse-em,.wxParse-var,.wxParse-address{font-style:italic}
71 | .wxParse-pre,.wxParse-tt,.wxParse-code,.wxParse-kbd,.wxParse-samp{font-family:monospace}
72 | .wxParse-pre{white-space:pre}
73 | .wxParse-big{font-size:1.17em}
74 | .wxParse-small,.wxParse-sub,.wxParse-sup{font-size:.83em}
75 | .wxParse-sub{vertical-align:sub}
76 | .wxParse-sup{vertical-align:super}
77 | .wxParse-s,.wxParse-strike,.wxParse-del{text-decoration:line-through}
78 | /*wxparse-自定义个性化的css样式*/
79 | /*增加video的css样式*/
80 | .wxParse-strong,.wxParse-s{display: inline}
81 | .wxParse-a{
82 | color: deepskyblue;
83 | word-break:break-all;
84 | overflow:auto;
85 | }
86 |
87 | .wxParse-video{
88 | text-align: center;
89 | margin: 10px 0;
90 | }
91 |
92 | .wxParse-video-video{
93 | width:100%;
94 | }
95 |
96 | .wxParse-img{
97 | /*background-color: #efefef;*/
98 | overflow: hidden;
99 | }
100 |
101 | .wxParse-blockquote {
102 | margin: 0;
103 | padding:10px 0 10px 5px;
104 | font-family:Courier, Calibri,"宋体";
105 | background:#f5f5f5;
106 | border-left: 3px solid #dbdbdb;
107 | }
108 |
109 | .wxParse-code,.wxParse-wxxxcode-style{
110 | display: inline;
111 | background:#f5f5f5;
112 | }
113 | .wxParse-ul{
114 | margin: 20rpx 10rpx;
115 | }
116 |
117 | .wxParse-li,.wxParse-li-inner{
118 | display: flex;
119 | align-items: baseline;
120 | margin: 10rpx 0;
121 | }
122 | .wxParse-li-text{
123 |
124 | align-items: center;
125 | line-height: 20px;
126 | }
127 |
128 | .wxParse-li-circle{
129 | display: inline-flex;
130 | width: 5px;
131 | height: 5px;
132 | background-color: #333;
133 | margin-right: 5px;
134 | }
135 |
136 | .wxParse-li-square{
137 | display: inline-flex;
138 | width: 10rpx;
139 | height: 10rpx;
140 | background-color: #333;
141 | margin-right: 5px;
142 | }
143 | .wxParse-li-ring{
144 | display: inline-flex;
145 | width: 10rpx;
146 | height: 10rpx;
147 | border: 2rpx solid #333;
148 | border-radius: 50%;
149 | background-color: #fff;
150 | margin-right: 5px;
151 | }
152 |
153 | /*.wxParse-table{
154 | width: 100%;
155 | height: 400px;
156 | }
157 | .wxParse-thead,.wxParse-tfoot,.wxParse-tr{
158 | display: flex;
159 | flex-direction: row;
160 | }
161 | .wxParse-th,.wxParse-td{
162 | display: flex;
163 | width: 580px;
164 | overflow: auto;
165 | }*/
166 |
167 | .wxParse-u {
168 | text-decoration: underline;
169 | }
170 | .wxParse-hide{
171 | display: none;
172 | }
173 | .WxEmojiView{
174 | align-items: center;
175 | }
176 | .wxEmoji{
177 | width: 16px;
178 | height:16px;
179 | }
180 | .wxParse-tr{
181 | display: flex;
182 | border-right:1px solid #e0e0e0;
183 | border-bottom:1px solid #e0e0e0;
184 | border-top:1px solid #e0e0e0;
185 | }
186 | .wxParse-th,
187 | .wxParse-td{
188 | flex:1;
189 | padding:5px;
190 | font-size:28rpx;
191 | border-left:1px solid #e0e0e0;
192 | word-break: break-all;
193 | }
194 | .wxParse-td:last{
195 | border-top:1px solid #e0e0e0;
196 | }
197 | .wxParse-th{
198 | background:#f0f0f0;
199 | border-top:1px solid #e0e0e0;
200 | }
201 | .wxParse-del{
202 | display: inline;
203 | }
204 | .wxParse-figure {
205 | overflow: hidden;
206 | }
207 |
--------------------------------------------------------------------------------
/pages/beforeOrder/beforeOrder.js:
--------------------------------------------------------------------------------
1 | // beforeOrder.js
2 | var calNum = 1 // product num
3 | Page({
4 |
5 | /**
6 | * 页面的初始数据
7 | */
8 | data: {
9 | swiper: {
10 | images: ['1', '2', '3', '4', '5', '6', '7']//TODO get data from server
11 | },
12 | productNum: calNum
13 | },
14 |
15 | /*decrease product number*/
16 | decBtn: function(e) {
17 | calNum -= 1;
18 | if (calNum < 0)
19 | calNum = 0;
20 | this.setData({productNum: calNum})
21 | },
22 |
23 | /*increase product number*/
24 | incBtn: function (e) {
25 | this.setData({ productNum: calNum += 1})
26 | },
27 | /**
28 | * 生命周期函数--监听页面加载
29 | */
30 | onLoad: function (options) {
31 |
32 | },
33 |
34 | /**
35 | * 生命周期函数--监听页面初次渲染完成
36 | */
37 | onReady: function () {
38 |
39 | },
40 |
41 | /**
42 | * 生命周期函数--监听页面显示
43 | */
44 | onShow: function () {
45 |
46 | },
47 |
48 | /**
49 | * 生命周期函数--监听页面隐藏
50 | */
51 | onHide: function () {
52 |
53 | },
54 |
55 | /**
56 | * 生命周期函数--监听页面卸载
57 | */
58 | onUnload: function () {
59 |
60 | },
61 |
62 | /**
63 | * 页面相关事件处理函数--监听用户下拉动作
64 | */
65 | onPullDownRefresh: function () {
66 |
67 | },
68 |
69 | /**
70 | * 页面上拉触底事件的处理函数
71 | */
72 | onReachBottom: function () {
73 |
74 | },
75 |
76 | /**
77 | * 用户点击右上角分享
78 | */
79 | onShareAppMessage: function () {
80 |
81 | }
82 | })
--------------------------------------------------------------------------------
/pages/beforeOrder/beforeOrder.json:
--------------------------------------------------------------------------------
1 | {}
--------------------------------------------------------------------------------
/pages/beforeOrder/beforeOrder.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 | 奶油味夏威夷果 奶油口味特产干货干果 坚果零食小吃袋装
19 |
20 |
21 |
22 | ¥69.00
23 |
24 |
25 | 详情 >
26 |
27 | 拼团价: ¥59.00
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 | 购买数量
40 |
41 | {{productNum}}
42 |
43 |
44 |
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/pages/beforeOrder/beforeOrder.wxss:
--------------------------------------------------------------------------------
1 | /* beforeOrder.wxss */
2 | swiper.swiper {
3 | height: 300px;
4 | }
5 | .swiper-img {
6 | width: 100%;
7 | height: 300px;
8 | }
9 | .product-item {
10 | border-bottom:1px solid #eee;
11 | }
12 | .product-image {
13 | display: inline-block;
14 | vertical-align: top
15 | }
16 | .product-image image {
17 | width:100px;
18 | height:100px;
19 | margin:10px;
20 | }
21 | .product-info{
22 | display: inline-block;
23 | max-width: calc(100% - 120px);
24 | }
25 | .product-description {
26 | font-size:15px;
27 | padding:15px 20px 0px 0px;
28 | min-height:55px;
29 | }
30 | .product-price text{
31 | font-size: 14px;
32 | display: inline-block;
33 | font-weight: 600;
34 | }
35 | text.price1 {
36 | margin-right: 10px;
37 | color: #68bc5e;
38 | }
39 | text.price2 {
40 | margin-right: 10px;
41 | color: #db5078;
42 | }
43 | button.specifibutton {
44 | display: inline-block;
45 | background-color:#68bc5e;
46 | font-size:14px;
47 | border:1px solid #68bc5e;
48 | color:#ffffff;
49 | line-height:30px;
50 | margin-top:10px;
51 | margin-left: 10px;
52 | }
53 | .numDecrease {
54 | float:right;
55 | }
56 | .purchase-number {
57 | display: inline-block;
58 | }
59 | text.purchasenumber {
60 | margin-top: 10px;
61 | margin-left: 10px;
62 | }
63 | text.product-num {
64 | background-color: #808080;
65 | }
66 | .product-specifi {
67 | border-bottom:1px solid #eee;
68 | }
69 | button.decreaseBtn {
70 | display: inline-block;
71 | margin-right: 10px;
72 | background-color: #808080;
73 | line-height: 30px;
74 | }
75 | button.increaseBtn {
76 | display: inline-block;
77 | margin-right: 10px;
78 | background-color: #808080;
79 | line-height: 30px;
80 | }
81 | .purchase-number {
82 | border-bottom:1px solid #eee;
83 | }
84 | button.nextOrderBtn {
85 | margin-top: 10px;
86 | background-color: #68bc5e;
87 | }
--------------------------------------------------------------------------------
/pages/deliveredOrder/deliveredOrder.js:
--------------------------------------------------------------------------------
1 | // pages/deliveredOrder/deliveredOrder.js
2 | var util = require('../../utils/util.js')
3 | Page({
4 |
5 | /**
6 | * 页面的初始数据
7 | */
8 | data: {
9 | groupBuyingHidden: true
10 | },
11 | /**
12 | * 生命周期函数--监听页面显示
13 | */
14 | onShow: function () {
15 | this.setData({
16 | groupBuyingHidden: !util.groupBuyMode
17 | })
18 | },
19 | /*
20 | Called when user click 地图
21 | */
22 | goMap: function (e) {
23 | wx.navigateTo({
24 | url: '../map/map'
25 | });
26 | },
27 | /*
28 | Called when user click 电话
29 | */
30 | goDial: function (e) {
31 |
32 | }
33 | })
--------------------------------------------------------------------------------
/pages/deliveredOrder/deliveredOrder.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarBackgroundColor": "#ffffff",
3 | "navigationBarTextStyle": "black",
4 | "navigationBarTitleText": "待提货的订单",
5 | "backgroundColor": "#eeeeee",
6 | "backgroundTextStyle": "light"
7 | }
--------------------------------------------------------------------------------
/pages/deliveredOrder/deliveredOrder.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 | 奶油味夏威夷果 奶油口味特产干货干果 坚果零食小吃袋装
10 |
11 |
12 | ×1
13 | ¥69.00
14 |
15 |
16 |
17 |
18 |
19 |
20 | 拼团
21 |
22 |
23 |
24 |
25 |
26 |
27 | 配送方式
28 |
29 |
30 | 门店自提
31 |
32 |
33 |
34 |
35 |
36 | 王小萌
37 | 15126489546
38 |
39 | 北工大门店 13031198966
40 | 门店地址 北京工业大学东门
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 | 买家留言
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 | 商品金额
59 |
60 |
61 | ¥69.00
62 |
63 |
64 |
65 |
66 | 状态为: 待提货
67 |
70 |
71 |
72 |
73 |
--------------------------------------------------------------------------------
/pages/deliveredOrder/deliveredOrder.wxss:
--------------------------------------------------------------------------------
1 | /* pages/deliveredOrder/deliveredOrder.wxss */
2 | .pending-item.deliveredOrder .mode-area .left {
3 | font-weight:normal;
4 | margin-top:0px;
5 | }
6 | .pending-item.deliveredOrder .detail-area .item{
7 | padding: 10px 20px;
8 | }
9 | .pending-item.deliveredOrder .button-area {
10 | margin-top:20px;
11 | padding:10px 10px 10px 10px;
12 | border: none;
13 | }
14 | .pending-item.deliveredOrder .total{
15 | color: #000;
16 | }
17 | button.appbutton6 {
18 | line-height: 20px;
19 | padding: 0px 10px;
20 | margin-bottom: 5px;
21 | background-color: #cbe198;
22 | }
23 | .address-area .right {
24 | margin-top: 20px;
25 | }
26 | .groupBuying {
27 | display: block;
28 | line-height: 22px;
29 | }
--------------------------------------------------------------------------------
/pages/deliveryOrder/deliveryOrder.js:
--------------------------------------------------------------------------------
1 | // pages/userDelivery/userDelivery.js
2 |
3 | var util = require('../../utils/util.js')
4 | var config = require('../../config/config.js')
5 | var app = getApp();
6 |
7 | Page({
8 |
9 | /**
10 | * 页面的初始数据
11 | */
12 | data: {
13 | orders:[],
14 | config: config,
15 | showEmptyNotice: false
16 | },
17 |
18 | onShow: function() {
19 |
20 | var that = this;
21 |
22 | // 获取快递订单
23 | wx.request({
24 | url: config.api.baseUrl + '/orders/express',//请求地址
25 | data: {
26 | customer_id: app.globalData.userInfo.customerId
27 | },
28 | header: {//请求头
29 | "Content-Type": "applciation/json"
30 | },
31 | method: "GET",//get为默认方法/POST
32 | success: function (res) {
33 | that.setData({//如果在sucess直接写this就变成了wx.request()的this了.必须为getdata函数的this,不然无法重置调用函数
34 | orders: res.data.result,
35 | showEmptyNotice: res.data.result.length <= 0
36 | })
37 | },
38 | fail: function (err) { },//请求失败
39 | complete: function () { }//请求完成后执行的函数
40 | });
41 | },
42 |
43 | detailClick: function(e) {
44 | // 跳转到订单详情页面
45 | wx.navigateTo({
46 | url: '../receivedOrder/receivedOrder?id=' + e.target.dataset.id
47 | });
48 | },
49 |
50 | /**
51 | * 跳转到商品详情页面
52 | */
53 | productView: function(e) {
54 | wx.navigateTo({
55 | url: '../productDetail/productDetail?id=' + e.currentTarget.dataset.id
56 | });
57 | }
58 |
59 | })
--------------------------------------------------------------------------------
/pages/deliveryOrder/deliveryOrder.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarBackgroundColor": "#ffffff",
3 | "navigationBarTextStyle": "black",
4 | "navigationBarTitleText": "快递配送订单",
5 | "backgroundColor": "#eeeeee",
6 | "backgroundTextStyle": "light"
7 | }
--------------------------------------------------------------------------------
/pages/deliveryOrder/deliveryOrder.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 | 您暂时还没有快递配送订单
14 |
--------------------------------------------------------------------------------
/pages/deliveryOrder/deliveryOrder.wxss:
--------------------------------------------------------------------------------
1 | /* pages/userDelivery/userDelivery.wxss */
--------------------------------------------------------------------------------
/pages/editStoreAddress/editStoreAddress.js:
--------------------------------------------------------------------------------
1 | // pages/editStoreAddress/editStoreAddress.js
2 | Page({
3 |
4 | /**
5 | * 页面的初始数据
6 | */
7 | data: {
8 | storeItems: [
9 | {id: '1', name: '北工大门店', address: '朝阳区平乐园100号', phone: '13031198966', distance: '125', checked: 'true'},
10 | { id: '2', name: '北工大门店', address: '朝阳区平乐园100号', phone: '13031198966', distance: '125'},
11 | { id: '3', name: '北工大门店', address: '朝阳区平乐园100号', phone: '13031198966', distance: '125' },
12 | { id: '4', name: '北工大门店', address: '朝阳区平乐园100号', phone: '13031198966', distance: '125' },
13 | { id: '5', name: '北工大门店', address: '朝阳区平乐园100号', phone: '13031198966', distance: '125' },
14 | { id: '6', name: '北工大门店', address: '朝阳区平乐园100号', phone: '13031198966', distance: '125' },
15 | ]
16 | },
17 | radioChange: function (e) {
18 | var checked = e.detail.value
19 | var changed = {}
20 | for (var i = 0; i < this.data.storeItems.length; i++) {
21 | if (checked.indexOf(this.data.storeItems[i].id) !== -1) {
22 | changed['storeItems[' + i + '].checked'] = true
23 | } else {
24 | changed['storeItems[' + i + '].checked'] = false
25 | }
26 | }
27 | this.setData(changed)
28 | },
29 | /*
30 | Called when user click 保存
31 | */
32 | saveAction: function (e) {
33 | wx.navigateBack({
34 | delta: 1
35 | })
36 | },
37 | /*
38 | Called when user click 取消
39 | */
40 | cancelAction: function (e) {
41 | wx.navigateBack({
42 | delta: 1
43 | })
44 | }
45 | })
--------------------------------------------------------------------------------
/pages/editStoreAddress/editStoreAddress.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarBackgroundColor": "#ffffff",
3 | "navigationBarTextStyle": "black",
4 | "navigationBarTitleText": "编辑自提信息",
5 | "backgroundColor": "#eeeeee",
6 | "backgroundTextStyle": "light"
7 | }
--------------------------------------------------------------------------------
/pages/editStoreAddress/editStoreAddress.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | 姓名: 王小萌
6 |
7 |
8 | 联系电话: 13041096933
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
30 |
31 |
32 |
33 |
34 |
35 |
38 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/pages/editStoreAddress/editStoreAddress.wxss:
--------------------------------------------------------------------------------
1 | /* pages/editStoreAddress/editStoreAddress.wxss */
2 |
3 | .list-area .item {
4 | padding: 15px 25px;
5 | border-top: 1px solid #eee;
6 | font-size: 15px;
7 | color: #333;
8 | }
9 |
10 | .radio-icon {
11 | position: relative;
12 | display: inline-block;
13 | vertical-align: middle;
14 | margin-right: 10px;
15 | width: 18px;
16 | height: 18px;
17 | background: #fcfff4;
18 | border-radius: 50px;
19 | }
20 |
21 | .radio-icon-checked {
22 | position: absolute;
23 | left: 3px;
24 | top: 3px;
25 | width: 12px;
26 | height: 12px;
27 | background: #1aad19;
28 | border-radius: 50%;
29 | }
30 |
31 | .radio-item {
32 | background-color: #eef5ed;
33 | padding: 6px 20px;
34 | border-bottom: 1px solid #ddd;
35 | }
36 |
37 | .select-area {
38 | font-size: 14px;
39 | }
40 |
41 | .radio-text {
42 | display: inline-block;
43 | vertical-align: middle;
44 | width: calc(100% - 50px);
45 | }
46 |
47 | .radio-text .name {
48 | padding: 8px 10px 5px 10px;
49 | font-size: 16px;
50 | }
51 |
52 | .radio-text .address {
53 | padding: 1px 10px;
54 | }
55 |
56 | .radio-text .phone {
57 | padding: 1px 10px;
58 | }
59 |
60 | .radio-text image {
61 | width: 20px;
62 | height: 20px;
63 | }
64 |
65 | .radio-text .distance {
66 | margin: 12px 0px 8px 0px;
67 | }
68 |
69 | .radio-text .marker {
70 | text-align: center;
71 | }
72 |
73 | button.appbutton5 {
74 | background: linear-gradient(#129a3a, #0f7d32);
75 | border-radius: 20px;
76 | border: none;
77 | color: white;
78 | font-size: 19px;
79 | white-space: nowrap;
80 | text-shadow: 0px 2px 1px #056723;
81 | box-shadow: 0px 3px 1px #0c6e27;
82 | width: 90%;
83 | line-height: 20px;
84 | margin: 40px auto;
85 | }
86 |
87 | button.appbutton5:hover {
88 | background: linear-gradient(#42a35a, #3c9f54);
89 | border-radius: 20px;
90 | border: none;
91 | color: white;
92 | }
93 |
--------------------------------------------------------------------------------
/pages/editUserAddress/editUserAddress.js:
--------------------------------------------------------------------------------
1 | // pages/editUserAddress/editUserAddress.js
2 | var util = require('../../utils/util.js');
3 | var app = getApp();
4 |
5 | Page({
6 |
7 | /**
8 | * 页面的初始数据
9 | */
10 | data: {},
11 | showErrorMessage: function(message) {
12 | wx.showModal({
13 | title: message,
14 | showCancel: false
15 | });
16 | },
17 | onLoad: function() {
18 | this.setData({
19 | receiver: app.receiver
20 | });
21 |
22 | if (this.data.receiver) {
23 | this.setData({
24 | username: this.data.receiver.name,
25 | phone: this.data.receiver.phone,
26 | area: this.data.receiver.area,
27 | address: this.data.receiver.address,
28 | zipcode: this.data.receiver.zipcode,
29 | })
30 | }
31 | },
32 | /*
33 | Called when user click 保存
34 | */
35 | saveAction: function(e) {
36 | var newReceiver = this.data.receiver || {};
37 |
38 | // 姓名
39 | if (!this.data.username) {
40 | this.showErrorMessage('请输入收件人姓名');
41 | return;
42 | }
43 | newReceiver.name = this.data.username;
44 |
45 | // 联系电话
46 | if (!this.data.phone) {
47 | this.showErrorMessage('请输入手机号');
48 | return;
49 | }
50 | newReceiver.phone = this.data.phone;
51 |
52 | // 地区
53 | if (!this.data.area) {
54 | this.showErrorMessage('请输入地区');
55 | return;
56 | }
57 | newReceiver.area = this.data.area;
58 |
59 | // 地址
60 | if (!this.data.address) {
61 | this.showErrorMessage('请输入详细地址');
62 | return;
63 | }
64 | newReceiver.address = this.data.address;
65 |
66 | // 邮政编码
67 | newReceiver.zipcode = this.data.zipcode;
68 |
69 | // 保存
70 | this.data.receiver = newReceiver;
71 | app.receiver = this.data.receiver;
72 | wx.setStorageSync('receiver', this.data.receiver)
73 |
74 | wx.navigateBack({
75 | delta: 1
76 | })
77 | },
78 |
79 | userName: function (e) {
80 | this.setData({
81 | username: e.detail.value
82 | })
83 | },
84 | userPhone: function (e) {
85 | this.setData({
86 | phone: e.detail.value
87 | })
88 | },
89 | userArea: function (e) {
90 | this.setData({
91 | area: e.detail.value
92 | })
93 | },
94 | userAddress: function (e) {
95 | this.setData({
96 | address: e.detail.value
97 | })
98 | },
99 | userZipcode: function (e) {
100 | this.setData({
101 | zipcode: e.detail.value
102 | })
103 | },
104 | /*
105 | Called when user click 取消
106 | */
107 | cancelAction: function(e) {
108 | wx.navigateBack({
109 | delta: 1
110 | })
111 | },
112 | })
--------------------------------------------------------------------------------
/pages/editUserAddress/editUserAddress.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarBackgroundColor": "#ffffff",
3 | "navigationBarTextStyle": "black",
4 | "navigationBarTitleText": "编辑收货地址",
5 | "backgroundColor": "#eeeeee",
6 | "backgroundTextStyle": "light"
7 | }
--------------------------------------------------------------------------------
/pages/editUserAddress/editUserAddress.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | 姓名:
7 |
8 |
9 |
10 | 联系电话:
11 |
12 |
13 |
14 |
15 | 收货地区:
16 |
17 |
18 |
19 |
20 | 详细地址:
21 |
22 |
23 |
24 | 邮政编码:
25 |
26 |
27 |
28 |
29 |
32 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/pages/editUserAddress/editUserAddress.wxss:
--------------------------------------------------------------------------------
1 | /* pages/editUserAddress/editUserAddress.wxss */
2 |
3 | .userAddress {
4 | min-height: 100vh;
5 | background-color: #eee;
6 | padding-top: 20px;
7 | }
8 |
9 | .list-area {
10 | background-color: #fff;
11 | padding: 0px 10px;
12 | font-size: 15px;
13 | color: #555;
14 | }
15 |
16 | .list-area .item {
17 | border-bottom: 1px solid #eee;
18 | padding: 10px 0px;
19 | }
20 |
21 | .list-area .item input {
22 | font-size: 15px;
23 | display: inline-block;
24 | vertical-align: middle;
25 | margin-left: 5px;
26 | color: #555;
27 | }
28 |
29 | .button-area {
30 | padding-top: 20px;
31 | }
32 |
33 | button.appbutton5 {
34 | background: linear-gradient(#129a3a, #0f7d32);
35 | border-radius: 20px;
36 | border: none;
37 | color: white;
38 | font-size: 19px;
39 | white-space: nowrap;
40 | text-shadow: 0px 2px 1px #056723;
41 | box-shadow: 0px 3px 1px #0c6e27;
42 | width: 90%;
43 | line-height: 20px;
44 | margin: 40px auto;
45 | }
46 |
47 | button.appbutton5:hover {
48 | background: linear-gradient(#42a35a, #3c9f54);
49 | border-radius: 20px;
50 | border: none;
51 | color: white;
52 | }
53 | .marker image{
54 | width: 20px;
55 | height: 20px;
56 | }
57 | .content {
58 | font-size: 12px;
59 | color: #db5078;
60 | }
61 | .position {
62 | text-align:center;
63 | margin-right:15px;
64 | border-left:1px solid #eee;
65 | padding-left:10px;
66 | margin-top:-5px;
67 | }
--------------------------------------------------------------------------------
/pages/index/index.js:
--------------------------------------------------------------------------------
1 | //index.js
2 | //获取应用实例
3 | var util = require('../../utils/util.js')
4 | var config = require('../../config/config.js')
5 |
6 | var app = getApp()
7 | Page({
8 | data: {
9 | swiperImages: [], // ads images
10 | buttons: [],
11 | productImgs: [],
12 | products: []
13 | },
14 |
15 | /**
16 | * 生命周期函数--监听页面加载
17 | */
18 | loadPage: function () {
19 | console.log('onLoad')
20 |
21 | var that = this;
22 |
23 | // get the ads
24 | wx.request({
25 | url: config.api.baseUrl + '/ads',//请求地址
26 | data: {
27 | },
28 | header: {//请求头
29 | "Content-Type": "applciation/json"
30 | },
31 | method: "GET",//get为默认方法/POST
32 | success: function (res) {
33 | console.log('get ads');
34 | console.log(res.data.result);//res.data相当于ajax里面的data,为后台返回的数据
35 |
36 | that.setData({//如果在sucess直接写this就变成了wx.request()的this了.必须为getdata函数的this,不然无法重置调用函数
37 | swiperImages: res.data.result
38 | })
39 | },
40 | fail: function (err) { },//请求失败
41 | complete: function () { }//请求完成后执行的函数
42 | })
43 |
44 | // get the category
45 | this.getCategory();
46 | },
47 |
48 | onLoad: function() {
49 | app.getSystemData(this.loadPage);
50 | },
51 |
52 | getCategory: function () {//read the category list
53 | var that = this; // 这个地方非常重要,重置data{}里数据时候setData方法的this应为以及函数的this, 如果在下方的sucess直接写this就变成了wx.request()的this了
54 | wx.request({
55 | url: config.api.baseUrl + '/product/categories',//请求地址
56 | data: {
57 | },
58 | header: {//请求头
59 | "Content-Type": "applciation/json"
60 | },
61 | method: "GET",//get为默认方法/POST
62 | success: function (res) {
63 | var categories = res.data.result;
64 |
65 | // 设置显示数据
66 | that.setData({
67 | buttons: res.data.result
68 | })
69 |
70 | // 获取第一个分类的商品
71 | if (categories.length > 0) {
72 | that.getProductList(categories[0].id);
73 | }
74 | },
75 | fail: function (err) { },//请求失败
76 | complete: function () { }//请求完成后执行的函数
77 | })
78 | },
79 | getProductList: function (category) {
80 | var that = this;
81 |
82 | var getCategoryurl = config.api.baseUrl + '/products/' + category;
83 |
84 | wx.request({
85 | url: getCategoryurl,//请求地址
86 | data: {
87 |
88 | },
89 | header: {//请求头
90 | "Content-Type": "applciation/json"
91 | },
92 | method: "GET",//get为默认方法/POST
93 | success: function (res) {
94 | that.setData({//如果在sucess直接写this就变成了wx.request()的this了.必须为getdata函数的this,不然无法重置调用函数
95 | products: res.data.result
96 | })
97 | },
98 | fail: function (err) { },//请求失败
99 | complete: function () { }//请求完成后执行的函数
100 | })
101 |
102 | },
103 | // get the prodcut's detail information
104 | clickCategory: function (e) {
105 | this.getProductList(e.target.dataset.id);
106 | },
107 |
108 | /**
109 | * 点击宣传图片
110 | */
111 | onAdImage: function(e) {
112 | wx.navigateTo({
113 | url: '../productDetail/productDetail?id=' + e.currentTarget.dataset.id
114 | });
115 | },
116 |
117 | /**
118 | * 点击商品
119 | */
120 | detailClick: function (e) {
121 | wx.navigateTo({
122 | url: '../productDetail/productDetail?id=' + e.currentTarget.dataset.id
123 | });
124 | },
125 |
126 | /**
127 | * 生命周期函数--监听页面初次渲染完成
128 | */
129 | onReady: function () {
130 |
131 | },
132 |
133 | /**
134 | * 生命周期函数--监听页面显示
135 | */
136 | onShow: function () {
137 |
138 | },
139 |
140 | /**
141 | * 生命周期函数--监听页面隐藏
142 | */
143 | onHide: function () {
144 |
145 | },
146 |
147 | /**
148 | * 生命周期函数--监听页面卸载
149 | */
150 | onUnload: function () {
151 |
152 | },
153 |
154 | /**
155 | * 页面相关事件处理函数--监听用户下拉动作
156 | */
157 | onPullDownRefresh: function () {
158 |
159 | },
160 |
161 | /**
162 | * 页面上拉触底事件的处理函数
163 | */
164 | onReachBottom: function () {
165 |
166 | },
167 |
168 | /**
169 | * 用户点击右上角分享
170 | */
171 | onShareAppMessage: function () {
172 |
173 | }
174 | })
--------------------------------------------------------------------------------
/pages/index/index.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarTitleText": "田家优鲜"
3 | }
--------------------------------------------------------------------------------
/pages/index/index.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/pages/index/index.wxss:
--------------------------------------------------------------------------------
1 | /**index.wxss**/
2 |
3 | .logo-area {
4 | text-align: center;
5 | }
6 |
7 | #logo-img {
8 | width: 200px;
9 | height: 60px;
10 | }
11 |
12 | swiper.swiper {
13 | height: 320rpx;
14 | }
15 |
16 | .swiper-img {
17 | width: 100%;
18 | height: 100%;
19 | }
20 |
21 | .button-item {
22 | display: inline-block;
23 | }
24 |
25 | .scroll-view_H {
26 | white-space: nowrap;
27 | width: 100%;
28 | background-color: #eee;
29 | padding-bottom: 3px;
30 | }
31 |
32 | .scroll-view-item_H {
33 | display: inline-block;
34 | }
35 |
36 | button.scroll-button {
37 | border-radius: 0px;
38 | margin: 0px 1px;
39 | padding: 10rpx 25rpx;
40 | font-size: 14px;
41 | }
42 |
43 | button.scroll-button::after {
44 | border: none;
45 | }
46 |
47 | /* 商品列表 */
48 | .product-item-list {
49 | padding: 20rpx 40rpx;
50 | width: calc(100% - 80rpx);
51 | display: inline-block;
52 | border-bottom: 1px solid #eee;
53 | }
54 | .product-image-list {
55 | float: left;
56 | }
57 | .product-image-list image {
58 | width: 140rpx;
59 | height: 140rpx;
60 | margin: 0rpx;
61 | }
62 | .product-info-list {
63 | margin-left: 170rpx;
64 | }
65 |
66 | .product-desc-list {
67 | font-size: 30rpx;
68 | height: 104rpx;
69 | }
70 | .product-price-list .price1 {
71 | font-size: 32rpx;
72 | color: #db5078;
73 | }
74 | .product-price-list .price2 {
75 | font-size: 28rpx;
76 | color: #68bc5e;
77 | }
--------------------------------------------------------------------------------
/pages/logs/logs.js:
--------------------------------------------------------------------------------
1 | //logs.js
2 | var util = require('../../utils/util.js')
3 | Page({
4 | data: {
5 | logs: []
6 | },
7 | onLoad: function () {
8 | this.setData({
9 | logs: (wx.getStorageSync('logs') || []).map(function (log) {
10 | return util.formatTime(new Date(log))
11 | })
12 | })
13 | }
14 | })
15 |
--------------------------------------------------------------------------------
/pages/logs/logs.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarTitleText": "查看启动日志"
3 | }
--------------------------------------------------------------------------------
/pages/logs/logs.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | {{index + 1}}. {{log}}
5 |
6 |
7 |
--------------------------------------------------------------------------------
/pages/logs/logs.wxss:
--------------------------------------------------------------------------------
1 | .log-list {
2 | display: flex;
3 | flex-direction: column;
4 | padding: 40rpx;
5 | }
6 | .log-item {
7 | margin: 10rpx;
8 | }
9 |
--------------------------------------------------------------------------------
/pages/map/map.js:
--------------------------------------------------------------------------------
1 | // pages/map/map.js
2 | Page({
3 | data: {
4 | markers: [{
5 | iconPath: "../../images/map-marker.png",
6 | id: 0,
7 | latitude: 23.099994,
8 | longitude: 113.324520,
9 | width: 50,
10 | height: 50
11 | }],
12 | pointLatitude: 23.099994,
13 | pointLongitude: 113.324520,
14 | },
15 |
16 | regionchange(e) {
17 | console.log(e.type)
18 | },
19 | markertap(e) {
20 | console.log(e.markerId)
21 | },
22 | controltap(e) {
23 | console.log(e.controlId)
24 | }
25 | })
--------------------------------------------------------------------------------
/pages/map/map.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarBackgroundColor": "#ffffff",
3 | "navigationBarTextStyle": "black",
4 | "navigationBarTitleText": "门店位置",
5 | "backgroundColor": "#eeeeee",
6 | "backgroundTextStyle": "light"
7 | }
--------------------------------------------------------------------------------
/pages/map/map.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
14 |
15 |
16 | 北工大门店
17 | 地址 朝阳区平乐园100号
18 |
19 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/pages/map/map.wxss:
--------------------------------------------------------------------------------
1 | /* pages/map/map.wxss */
2 | map {
3 | width: 100%;
4 | height: calc(100vh - 60px);
5 | }
6 | button.appbutton2 {
7 | display:inline-block;
8 | vertical-align:middle;
9 | line-height:20px;
10 | float:right;
11 | padding:20px 40px;
12 | }
13 | .navigation {
14 | border-top: 1px solid #eee;
15 | margin-top: 2px;
16 | }
17 | .detail {
18 | display:inline-block;
19 | font-size:14px;
20 | padding:5px 10px;
21 | }
--------------------------------------------------------------------------------
/pages/pendingOrder/pendingOrder.js:
--------------------------------------------------------------------------------
1 | // pages/pendingOrder/pendingOrder.js
2 | var util = require('../../utils/util.js')
3 | var config = require('../../config/config.js')
4 | var md5 = require('../../lib/md5.js')
5 |
6 | var app = getApp();
7 |
8 | var gnStoreId = 0;
9 | var gstrFormId;
10 | var gstrFormIdGroup;
11 |
12 | var gnChannelSet;
13 | var gdPriceSet;
14 |
15 | /**
16 | * 计算距离
17 | * @param {*} lat1
18 | * @param {*} lon1
19 | * @param {*} lat2
20 | * @param {*} lon2
21 | */
22 | function getDistanceFromLatLonInKm(lat1,lon1,lat2,lon2) {
23 | var R = 6371; // Radius of the earth in km
24 | var dLat = deg2rad(lat2-lat1); // deg2rad below
25 | var dLon = deg2rad(lon2-lon1);
26 | var a =
27 | Math.sin(dLat/2) * Math.sin(dLat/2) +
28 | Math.cos(deg2rad(lat1)) * Math.cos(deg2rad(lat2)) *
29 | Math.sin(dLon/2) * Math.sin(dLon/2)
30 | ;
31 | var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
32 | var d = R * c; // Distance in km
33 | return d;
34 | }
35 |
36 | function deg2rad(deg) {
37 | return deg * (Math.PI/180)
38 | }
39 |
40 | Page({
41 |
42 | /**
43 | * 页面的初始数据
44 | */
45 | data: {
46 | deliveryActive: 'active',
47 | storeActive: '',
48 | storeHidden: false,
49 | groupBuyingHidden: true,
50 | productDetails: [],
51 | buyCnt: 0,
52 | priceSum: 0,
53 | totalPrice: 0,
54 | thumbnail: '',
55 | storeList: [],
56 | // 配送渠道
57 | channel: config.channel.delivery,
58 | desc: '',
59 | },
60 | /**
61 | * 生命周期函数--监听页面显示
62 | */
63 | onShow: function () {
64 | this.setData({
65 | groupBuyingHidden: !util.groupBuyMode,
66 | // 收件人
67 | receiver: app.receiver,
68 | name: app.receiver.name,
69 | phone: app.receiver.phone,
70 | });
71 | },
72 | /*
73 | Called when user click 快递配送
74 | */
75 | selectDelivery: function (e) {
76 | this.setData({
77 | deliveryActive: 'active',
78 | storeActive: '',
79 | storeHidden: false,
80 | channel: config.channel.delivery,
81 | totalPrice: parseFloat(util.prepareOrderInfo.totalPrice) + parseFloat(this.data.productDetails.price_deliver)
82 | })
83 | },
84 | /*
85 | Called when user click 门店自提
86 | */
87 | selectStore: function (e) {
88 | this.setData({
89 | deliveryActive: '',
90 | storeActive: 'active',
91 | storeHidden: true,
92 | channel: config.channel.self,
93 | totalPrice: parseFloat(util.prepareOrderInfo.totalPrice)
94 | })
95 | },
96 | /*
97 | Called when user click 编辑
98 | */
99 | editAddress: function (e) {
100 | if(this.data.deliveryActive == 'active'){
101 | wx.navigateTo({
102 | url: '../editUserAddress/editUserAddress'
103 | });
104 | }else if(this.data.storeActive == 'active'){
105 | wx.navigateTo({
106 | url: '../editStoreAddress/editStoreAddress'
107 | });
108 | }
109 | },
110 | /*
111 | Called when user click radio
112 | */
113 | radioChange: function (e) {
114 | gnStoreId = parseInt(e.detail.value);
115 |
116 | for (var i = 0; i < this.data.storeList.length; i++) {
117 | if (gnStoreId === this.data.storeList[i].id) {
118 | this.data.storeList[i].checked = true;
119 | } else {
120 | this.data.storeList[i].checked = false;
121 | }
122 | }
123 |
124 | this.setData({
125 | storeList: this.data.storeList
126 | });
127 | },
128 | /*
129 | Called when user click map marker
130 | */
131 | goMap: function(e) {
132 | var nIndex = e.currentTarget.dataset.index;
133 | var store = this.data.storeList[nIndex];
134 |
135 | wx.openLocation({
136 | latitude: parseFloat(store.latitude),
137 | longitude: parseFloat(store.longitude),
138 | scale: 12,
139 | name: store.name,
140 | address: store.address,
141 | success: function(res) {},
142 | fail: function(err) {
143 | wx.showModal({
144 | content: err.errMsg,
145 | showCancel: false
146 | });
147 | }
148 | });
149 |
150 | // console.log(e.target.dataset.id);
151 | // wx.navigateTo({
152 | // url: '../map/map'
153 | // });
154 | },
155 | /*
156 | * load function
157 | */
158 | onLoad: function (options) {
159 | var that = this;
160 |
161 | gstrFormIdGroup = options.form;
162 |
163 | // 检查数据
164 | if (!util.productDetails.specs) {
165 | wx.showModal({
166 | content: '无法获取产品信息,请稍后再试',
167 | showCancel: false,
168 | success: function(res) {
169 | // 返回到详情页
170 | wx.navigateBack({
171 | delta: 1
172 | })
173 | }
174 | });
175 |
176 | return;
177 | }
178 |
179 | // 规格
180 | var strSpec = '';
181 | for (var i = 0; i < util.productDetails.specs.length; i++) {
182 | if (util.productDetails.specs[i].id == util.prepareOrderInfo.specId) {
183 | strSpec = util.productDetails.specs[i].name;
184 | break;
185 | }
186 | }
187 |
188 | // 获取单价
189 | var dPrice = util.productDetails.price;
190 | if (util.groupBuyMode) {
191 | dPrice = util.productDetails.gb_price;
192 | }
193 |
194 | this.setData({
195 | productDetails: util.productDetails,
196 | buyCnt: util.prepareOrderInfo.count,
197 | spec: strSpec,
198 |
199 | // 价格合计
200 | priceSum: util.prepareOrderInfo.count * dPrice,
201 |
202 | // 价格总计
203 | totalPrice: parseFloat(util.prepareOrderInfo.totalPrice) + parseFloat(util.productDetails.price_deliver)
204 | })
205 |
206 |
207 | console.log('pending order -->');
208 | console.log(that.data.username);
209 | console.log(that.data.phone);
210 | console.log(util.productDetails);
211 | console.log('<---');
212 |
213 | // get the store list
214 | var storeUrl = config.api.baseUrl + '/stores';
215 | wx.request({
216 | url: storeUrl,//请求地址
217 | data: {
218 | latitude: app.globalData.userInfo.latitude,
219 | longitude: app.globalData.userInfo.longitude
220 | },
221 | header: {//请求头
222 | "Content-Type": "applciation/json"
223 | },
224 | method: "GET",//get为默认方法/POST
225 | success: function (res) {
226 | console.log('get store list -->');
227 | console.log(res.data.result);//res.data相当于ajax里面的data,为后台返回的数据
228 |
229 | var stores = res.data.result;
230 | // 默认选择第一家门店
231 | if (stores.length > 0) {
232 | stores[0].checked = true;
233 | gnStoreId = stores[0].id;
234 |
235 | // 计算距离
236 | for (var i = 0; i < stores.length; i++) {
237 | stores[i].distance = getDistanceFromLatLonInKm(
238 | app.globalData.userInfo.latitude,
239 | app.globalData.userInfo.longitude,
240 | stores[i].latitude,
241 | stores[i].longitude
242 | ).toFixed(1);
243 | }
244 | }
245 |
246 | that.setData({//如果在sucess直接写this就变成了wx.request()的this了.必须为getdata函数的this,不然无法重置调用函数
247 | storeList: stores
248 | })
249 | },
250 | fail: function (err) { },//请求失败
251 | complete: function () { }//请求完成后执行的函数
252 | })
253 | },
254 |
255 | /**
256 | * 输入内容
257 | */
258 | // 收件人姓名
259 | userName: function (e) {
260 | this.setData({
261 | name: e.detail.value
262 | })
263 | },
264 | // 手机号
265 | userPhone: function (e) {
266 | this.setData({
267 | phone: e.detail.value
268 | })
269 | },
270 | // 买家留言
271 | desc: function (e) {
272 | this.setData({
273 | desc: e.detail.value
274 | })
275 | },
276 |
277 | showPayemntError: function() {
278 | wx.showModal({
279 | content: '无法开启支付接口!',
280 | showCancel: false
281 | });
282 | },
283 |
284 | showMakeOrderError: function(msg = '') {
285 | wx.showModal({
286 | content: '下单失败! ' + msg,
287 | showCancel: false
288 | });
289 | },
290 |
291 | /*
292 | Called when user click 提交订单
293 | */
294 | submitOrder: function (e) {
295 | var that = this;
296 |
297 | gstrFormId = e.detail.formId;
298 |
299 | // 确认收件人信息
300 | if (this.data.channel == config.channel.delivery) {
301 | if (!this.data.receiver) {
302 | wx.showModal({
303 | content: '请输入收件人信息',
304 | showCancel: false
305 | });
306 |
307 | return;
308 | }
309 | }
310 | else {
311 | if (!this.data.name || !this.data.phone) {
312 | wx.showModal({
313 | content: '请输入提货人信息',
314 | showCancel: false
315 | });
316 |
317 | return;
318 | }
319 | }
320 |
321 | // 将需要的参数固定下来
322 | gnChannelSet = this.data.channel;
323 | gdPriceSet = this.data.totalPrice;
324 |
325 | // this.makeOrder('1111');
326 | // return;
327 |
328 | // 预支付
329 | wx.request({
330 | url: config.api.baseUrl + '/order/prepare',//请求地址
331 | data: {
332 | product_id: util.productDetails.id,
333 | customer_id: app.globalData.userInfo.customerId,
334 | price: gdPriceSet
335 | },
336 | header: {//请求头
337 | "Content-Type": "application/x-www-form-urlencoded"
338 | },
339 | method: "POST",//get为默认方法/POST
340 | success: function (res) {
341 | console.log(res);
342 |
343 | if (res.statusCode > 200) {
344 | // 失败
345 | that.showPayemntError();
346 | return;
347 | }
348 |
349 | var response = res.data.result;
350 | // 发起支付
351 | var appId = response.appid;
352 | var timeStamp = (Date.parse(new Date()) / 1000).toString();
353 | var pkg = 'prepay_id=' + response.prepay_id;
354 | var nonceStr = response.nonce_str;
355 | var paySign = md5.hex_md5('appId='+appId+'&nonceStr='+nonceStr+'&package='+pkg+'&signType=MD5&timeStamp='+timeStamp+"&key=5UkDSKPgHQ6cpsUSwxt2lJnixzQkzQeO").toUpperCase();
356 |
357 | var tradeNo = res.data.trade_no;
358 |
359 | wx.requestPayment({
360 | 'appId': appId,
361 | 'timeStamp': timeStamp,
362 | 'nonceStr': nonceStr,
363 | 'package': pkg,
364 | 'signType': 'MD5',
365 | 'paySign': paySign,
366 | 'success':function(res){
367 | // 生成订单
368 | that.makeOrder(tradeNo);
369 | },
370 | 'fail':function(res){
371 | wx.showModal({
372 | title: '支付失败',
373 | showCancel: false
374 | });
375 | console.log(res);
376 | }
377 | });
378 | },
379 | fail: function (err) {
380 | that.showPayemntError();
381 | },//请求失败
382 | complete: function () { }//请求完成后执行的函数
383 | });
384 |
385 | // }else if(this.data.storeActive == 'active') {
386 | // wx.navigateTo({
387 | // url: '../deliveredOrder/deliveredOrder'
388 | // });
389 | // }
390 | },
391 | /**
392 | * 生成订单
393 | */
394 | makeOrder: function(tradeNo) {
395 |
396 | var that = this;
397 |
398 | var paramData = {
399 | customer_id: app.globalData.userInfo.customerId,
400 | product_id: util.productDetails.id,
401 | count: this.data.buyCnt,
402 | // 规格
403 | spec_id: util.prepareOrderInfo.specId,
404 | channel: gnChannelSet,
405 | desc: this.data.desc,
406 | price: gdPriceSet,
407 | // 商户订单号
408 | trade_no: tradeNo,
409 | formid: gstrFormId,
410 | formid_group: gstrFormIdGroup
411 | };
412 |
413 | // 门店
414 | if (gnChannelSet == config.channel.self) {
415 | paramData.store_id = gnStoreId;
416 | // 收件人
417 | paramData.name = this.data.name;
418 | paramData.phone = this.data.phone;
419 | }
420 | else {
421 | // 地址
422 | paramData.address = this.data.receiver.address;
423 | paramData.area = this.data.receiver.area;
424 | paramData.zipcode = this.data.receiver.zipcode ? this.data.receiver.zipcode : '';
425 |
426 | // 收件人
427 | paramData.name = app.receiver.name;
428 | paramData.phone = app.receiver.phone;
429 | }
430 |
431 | // 拼团
432 | paramData.groupbuy_id = util.prepareOrderInfo.groupBuy;
433 |
434 | wx.request({
435 | url: config.api.baseUrl + '/order/make',//请求地址
436 | data: paramData,
437 | header: {//请求头
438 | "Content-Type": "application/x-www-form-urlencoded"
439 | },
440 | method: "POST",//get为默认方法/POST
441 | success: function (res) {
442 | if (res.statusCode > 200) {
443 | // 失败
444 | that.showMakeOrderError('' + res.statusCode);
445 | return;
446 | }
447 |
448 | // 成功
449 | if (res.data.status == 'success') {
450 | var orderId = res.data.result;
451 |
452 | wx.showToast({
453 | title: '下单成功',
454 | });
455 |
456 | setTimeout(function() {
457 | // 跳转到订单详情页面
458 | wx.redirectTo({
459 | url: '../receivedOrder/receivedOrder?id=' + orderId
460 | });
461 | }, 1000);
462 | }
463 | // 失败
464 | else {
465 | that.showMakeOrderError(res.data.message);
466 | }
467 | },
468 | fail: function (err) {
469 | that.showMakeOrderError(err.errMsg);
470 | },//请求失败
471 | complete: function () { }//请求完成后执行的函数
472 | })
473 | }
474 | })
--------------------------------------------------------------------------------
/pages/pendingOrder/pendingOrder.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarBackgroundColor": "#ffffff",
3 | "navigationBarTextStyle": "black",
4 | "navigationBarTitleText": "待付款订单",
5 | "backgroundColor": "#eeeeee",
6 | "backgroundTextStyle": "light"
7 | }
--------------------------------------------------------------------------------
/pages/pendingOrder/pendingOrder.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 | {{productDetails.name}}
14 |
15 |
16 | ×{{buyCnt}}
17 | ¥{{productDetails.price}}
18 | ¥{{productDetails.gb_price}}
19 |
20 |
21 |
22 |
23 |
24 |
25 | 拼团
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 | 配送方式
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 | 收货人:
46 | {{receiver.name}}
47 | {{receiver.phone}}
48 |
49 | {{receiver.area ? receiver.area : '地区'}} {{zipcode}}
50 | {{receiver.address ? receiver.address : '地址'}}
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 | 姓名:
62 |
63 |
64 | 联系电话:
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 | 买家留言:
100 |
101 |
102 |
103 |
104 |
105 | 快递运费:
106 |
107 |
108 | ¥{{productDetails.price_deliver}}
109 |
110 |
111 |
112 |
113 |
114 | 价格合计:
115 |
116 |
117 | ¥{{priceSum}}
118 |
119 |
120 |
121 |
122 |
123 | 支付方式:
124 |
125 |
126 | 微信支付
127 |
128 |
129 |
130 |
131 |
132 |
133 | 总计: ¥{{totalPrice}}
134 |
139 |
140 |
141 |
--------------------------------------------------------------------------------
/pages/pendingOrder/pendingOrder.wxss:
--------------------------------------------------------------------------------
1 | /* pages/pendingOrder/pendingOrder.wxss */
2 | .groupBuying {
3 | display: block;
4 | line-height: 22px;
5 | }
6 |
7 | /* pages/editStoreAddress/editStoreAddress.wxss */
8 |
9 | .storeAddress .list-area .item {
10 | padding: 15px 25px;
11 | border-top: 1px solid #eee;
12 | font-size: 15px;
13 | color: #333;
14 | }
15 |
16 | .storeAddress .radio-icon {
17 | position: absolute;
18 | top: 50%;
19 | transform: translateY(-50%);
20 | width: 18px;
21 | height: 18px;
22 | background: #fcfff4;
23 | border-radius: 50px;
24 | }
25 |
26 | .storeAddress .radio-icon-checked {
27 | position: absolute;
28 | left: 3px;
29 | top: 3px;
30 | width: 12px;
31 | height: 12px;
32 | background: #1aad19;
33 | border-radius: 50%;
34 | }
35 |
36 | .storeAddress .radio-item {
37 | background-color: #eef5ed;
38 | padding: 6px 20px;
39 | border-bottom: 1px solid #ddd;
40 | position: relative;
41 | }
42 |
43 | .storeAddress .select-area {
44 | font-size: 14px;
45 | }
46 |
47 | .storeAddress .radio-text {
48 | display: block;
49 | }
50 | .storeAddress .radio-text .store-info {
51 | margin-left: 34rpx;
52 | margin-right: 150rpx;
53 | }
54 | .storeAddress .radio-text .store-location {
55 | position: absolute;
56 | top: 50%;
57 | transform: translateY(-50%);
58 | right: 40rpx;
59 | }
60 | .storeAddress .radio-text .name {
61 | padding: 8px 10px 5px 10px;
62 | font-size: 16px;
63 | }
64 |
65 | .storeAddress .radio-text .address {
66 | padding: 1px 10px;
67 | }
68 |
69 | .storeAddress .radio-text .phone {
70 | padding: 1px 10px;
71 | }
72 |
73 | .storeAddress .radio-text image {
74 | width: 20px;
75 | height: 20px;
76 | }
77 |
78 | .storeAddress .radio-text .distance {
79 | margin: 12px 0px 8px 0px;
80 | }
81 |
82 | .storeAddress .radio-text .marker {
83 | text-align: center;
84 | }
85 |
86 | .storeAddress button.appbutton5 {
87 | background: linear-gradient(#129a3a, #0f7d32);
88 | border-radius: 20px;
89 | border: none;
90 | color: white;
91 | font-size: 19px;
92 | white-space: nowrap;
93 | text-shadow: 0px 2px 1px #056723;
94 | box-shadow: 0px 3px 1px #0c6e27;
95 | width: 90%;
96 | line-height: 20px;
97 | margin: 40px auto;
98 | }
99 |
100 | .storeAddress button.appbutton5:hover {
101 | background: linear-gradient(#42a35a, #3c9f54);
102 | border-radius: 20px;
103 | border: none;
104 | color: white;
105 | }
106 |
--------------------------------------------------------------------------------
/pages/productDetail/productDetail.js:
--------------------------------------------------------------------------------
1 | // pages/productDetail/productDetail.js
2 | var util = require('../../utils/util.js');
3 | var config = require('../../config/config.js');
4 |
5 | //在使用的View中引入WxParse模块
6 | var WxParse = require('../../lib/wxParse/wxParse.js');
7 |
8 | var app = getApp();
9 |
10 | var gnProductId;
11 | var gbIsLoading = false;
12 |
13 | var timerGroupbuy;
14 |
15 | Page({
16 | /**
17 | * 页面的初始数据
18 | */
19 | data: {
20 | swiperImages: [],
21 | productArray: [], // each product info array
22 | modalRetreatHidden: true,
23 | modalFireHidden: true,
24 | actionSheetHidden: true,
25 | commodityCount: 1,
26 | groupBuyingHidden: true,
27 | showLoading: false,
28 | specId: 0,
29 |
30 | // loading提示语
31 | loadingMessage: '',
32 | productDetails: [],
33 | groupBuys: [],
34 |
35 | // 图片base url
36 | baseUrl: config.baseUrl,
37 | },
38 |
39 | /**
40 | * 分享
41 | */
42 | onShareAppMessage: function() {
43 | return {
44 | title: this.data.productDetails.name,
45 | desc: this.data.productDetails.name,
46 | path: '/pages/productDetail/productDetail?id=' + gnProductId
47 | };
48 | },
49 |
50 | /*
51 | Called when user click question mark in 七天包退, 十四天包换 to show modal
52 | */
53 | modalRetreat: function (e) {
54 | this.setData({
55 | modalRetreatHidden: false
56 | })
57 | },
58 | /*
59 | Called when user click 确定 to hide modal
60 | */
61 | modalRetreatChange: function (e) {
62 | this.setData({
63 | modalRetreatHidden: true
64 | })
65 | },
66 | /*
67 | Called when user click question mark in 火热拼团 to show modal
68 | */
69 | modalFire: function (e) {
70 | this.setData({
71 | modalFireHidden: false
72 | })
73 | },
74 |
75 | /**
76 | * 邀请好友弹窗
77 | */
78 | modalInvite: function() {
79 | wx.showModal({
80 | title: '邀请好友',
81 | content: '点击小程序右上方“三个点”按钮,点击“转发”,一起邀请你的小伙伴来拼团吧。',
82 | showCancel: false
83 | });
84 | },
85 | /*
86 | Called when user click 确定 to hide modal
87 | */
88 | modalFireChange: function (e) {
89 | this.setData({
90 | modalFireHidden: true
91 | })
92 | },
93 | /*
94 | Called when user click close button in actionsheet
95 | */
96 | actionSheetChange: function (e) {
97 | this.setData({
98 | actionSheetHidden: !this.data.actionSheetHidden
99 | })
100 | },
101 | /*
102 | Called when user click + in actionsheet
103 | */
104 | increaseCount: function (e) {
105 | this.setData({
106 | commodityCount: this.data.commodityCount + 1
107 | })
108 | },
109 | /*
110 | Called when user click - in actionsheet
111 | */
112 | decreaseCount: function (e) {
113 | if (this.data.commodityCount > 1) {
114 | this.setData({
115 | commodityCount: this.data.commodityCount - 1
116 | })
117 | }
118 | },
119 | /*
120 | Called when user click 立即购买
121 | */
122 | goBuyNow: function() {
123 | this.setData({
124 | groupBuyingHidden: true,
125 | actionSheetHidden: !this.data.actionSheetHidden,
126 | commodityCount: 1,
127 | });
128 | util.groupBuyMode = false;
129 |
130 | util.prepareOrderInfo.groupBuy = -1;
131 | },
132 | /*
133 | Called when user click 发起拼团
134 | */
135 | goGroupBuy: function() {
136 | this.setData({
137 | groupBuyingHidden: false,
138 | actionSheetHidden: !this.data.actionSheetHidden,
139 | commodityCount: 1,
140 | })
141 | util.groupBuyMode = true;
142 |
143 | util.prepareOrderInfo.groupBuy = 0;
144 | },
145 |
146 | /**
147 | * 参加拼团
148 | */
149 | inGroupBuy: function(e) {
150 | this.goGroupBuy();
151 | util.prepareOrderInfo.groupBuy = e.target.dataset.id;
152 | },
153 |
154 | /*
155 | Called when user click '下一步' button
156 | */
157 | goPending: function (e) {
158 | // 检查规格
159 | // if (this.data.specId <= 0) {
160 | // wx.showModal({
161 | // title: '请选择规格',
162 | // showCancel: false
163 | // });
164 |
165 | // return;
166 | // }
167 |
168 | // 检查库存
169 | if (this.data.commodityCount > this.data.productDetails.remain) {
170 | wx.showModal({
171 | title: '库存不够',
172 | showCancel: false
173 | });
174 |
175 | return;
176 | }
177 |
178 | //
179 | // 跳转到下单页面
180 | //
181 | this.setData({
182 | actionSheetHidden: !this.data.actionSheetHidden
183 | })
184 | wx.navigateTo({
185 | url: '../pendingOrder/pendingOrder?form=' + e.detail.formId
186 | });
187 |
188 | // 设置数量
189 | util.prepareOrderInfo.count = this.data.commodityCount;
190 | util.prepareOrderInfo.specId = this.data.specId;
191 |
192 | // 获取单价
193 | var dPrice = this.data.productDetails.price;
194 | if (util.groupBuyMode) {
195 | dPrice = this.data.productDetails.gb_price;
196 | }
197 |
198 | util.prepareOrderInfo.totalPrice = parseFloat(this.data.commodityCount * dPrice);
199 | util.productDetails = this.data.productDetails;
200 |
201 | console.log('go buy now -->');
202 | console.log(this.data.commodityCount);
203 | console.log(this.data.productDetails.price);
204 | console.log(util.totalPrice);
205 | console.log('<---');
206 | },
207 | hideLoading() {
208 | this.setData({ showLoading: false, loadingMessage: '' });
209 | },
210 |
211 | setLocation:function() {
212 |
213 | },
214 | /*
215 | * load function
216 | */
217 | onLoad: function (option) {
218 | gnProductId = option.id;
219 |
220 | gbIsLoading = true;
221 | app.getSystemData(this.loadPage);
222 | },
223 |
224 | loadPage: function() {
225 | // 获取当前位置
226 | wx.getLocation({
227 | type: 'wgs84',
228 | success: function (res) {
229 | app.globalData.userInfo.latitude = res.latitude;
230 | app.globalData.userInfo.longitude = res.longitude;
231 | }
232 | });
233 |
234 | this.setData({
235 | noticeRefund: app.setting.noticeRefund,
236 | noticeGroup: app.setting.noticeGroup
237 | });
238 |
239 | // 提示
240 | wx.showModal({
241 | content: '参加已发起的团或分享出去更快成单哦',
242 | showCancel: false
243 | });
244 |
245 | this.getProductInfo();
246 |
247 | gbIsLoading = false;
248 | },
249 |
250 | onHide: function() {
251 | clearTimeout(timerGroupbuy);
252 | },
253 |
254 | onUnload: function() {
255 | clearTimeout(timerGroupbuy);
256 | },
257 |
258 | onShow: function() {
259 | if (!gbIsLoading) {
260 | app.getSystemData(this.getProductInfo);
261 | }
262 | },
263 |
264 | //read the category list
265 | getProductInfo: function () {
266 | var that = this; // 这个地方非常重要,重置data{}里数据时候setData方法的this应为以及函数的this, 如果在下方的sucess直接写this就变成了wx.request()的this了
267 | var productUrl = config.api.baseUrl + '/product/detail/' + gnProductId
268 |
269 | if (!app.globalData.userInfo) {
270 | wx.showModal({
271 | content: '无法获取用户信息',
272 | showCancel: false
273 | });
274 |
275 | return;
276 | }
277 |
278 | wx.request({
279 | url: productUrl,//请求地址
280 | data: {
281 | customer_id: app.globalData.userInfo.customerId
282 | },
283 | header: {//请求头
284 | "Content-Type": "applciation/json"
285 | },
286 | method: "GET",//get为默认方法/POST
287 | success: function (res) {
288 | console.log('product informations');
289 | console.log(res.data.result);//res.data相当于ajax里面的data,为后台返回的数据
290 |
291 | // 默认选择第一个规格
292 | var specId = 0;
293 | if (res.data.result.specs.length > 0) {
294 | specId = res.data.result.specs[0].id;
295 | }
296 |
297 | var detail = res.data.result;
298 | for (var i = 0; i < detail.groupbuys.length; i++) {
299 | detail.groupbuys[i].time_remain_formatted = util.foramtSeconds(detail.groupbuys[i].time_remain);
300 | }
301 |
302 | that.setData({//如果在sucess直接写this就变成了wx.request()的this了.必须为getdata函数的this,不然无法重置调用函数
303 | productDetails: detail,
304 | groupBuys: detail.groupbuys,
305 | specId: specId,
306 | thumbnail: res.data.result.thumbnail,
307 | swiperImages: res.data.result.images,
308 | })
309 |
310 | /**
311 | * WxParse.wxParse(bindName , type, data, target,imagePadding)
312 | * 1.bindName绑定的数据名(必填)
313 | * 2.type可以为html或者md(必填)
314 | * 3.data为传入的具体数据(必填)
315 | * 4.target为Page对象,一般为this(必填)
316 | * 5.imagePadding为当图片自适应是左右的单一padding(默认为0,可选)
317 | */
318 | WxParse.wxParse('article', 'html', res.data.result.rtf_content, that, 10);
319 |
320 | timerGroupbuy = setTimeout(that.updateTimeRemaining, 1000);
321 |
322 | console.log('productdetail->swiperimages')
323 | console.log(that.data.swiperImages)
324 | },
325 | fail: function (err) { },//请求失败
326 | complete: function () { }//请求完成后执行的函数
327 | })
328 | },
329 |
330 | updateTimeRemaining: function() {
331 | var detail = this.data.groupBuys;
332 | for (var i = 0; i < detail.length; i++) {
333 | detail[i].time_remain--;
334 | detail[i].time_remain_formatted = util.foramtSeconds(detail[i].time_remain);
335 | }
336 |
337 | this.setData({//如果在sucess直接写this就变成了wx.request()的this了.必须为getdata函数的this,不然无法重置调用函数
338 | groupBuys: detail
339 | });
340 |
341 | timerGroupbuy = setTimeout(this.updateTimeRemaining, 1000);
342 | },
343 |
344 | /**
345 | * 选择规格
346 | */
347 | selectSpec: function(e) {
348 | var specId = e.target.dataset.id;
349 | this.setData({
350 | specId: specId
351 | });
352 | }
353 | })
--------------------------------------------------------------------------------
/pages/productDetail/productDetail.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarBackgroundColor": "#ffffff",
3 | "navigationBarTextStyle": "black",
4 | "navigationBarTitleText": "商品详情",
5 | "backgroundColor": "#eeeeee",
6 | "backgroundTextStyle": "light"
7 | }
--------------------------------------------------------------------------------
/pages/productDetail/productDetail.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 | {{productDetails.name}}
19 |
20 |
21 | ¥{{productDetails.price}}
22 | 拼团价: ¥{{productDetails.gb_price}}
23 |
24 |
25 |
26 |
27 |
28 | 仅限福州地区
29 | 库存: {{productDetails.remain}}
30 |
31 |
32 | 配送说明
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 | 拼团说明
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 | 拼团价: ¥{{productDetails.gb_price}}
52 |
53 | 规则: {{productDetails.gb_timeout}}小时内{{productDetails.gb_count}}人参与拼团即成功
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 | {{groupbuy.customer.name}}发起了拼团
72 | 人数: {{groupbuy.persons}}人, 倒计时: {{groupbuy.time_remain_formatted}}
73 |
74 |
75 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 | 商品详情
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
102 |
103 |
104 |
107 |
108 |
109 |
110 |
111 |
112 | {{noticeRefund}}
113 |
114 |
115 | {{noticeGroup}}
116 |
117 |
118 |
119 |
120 |
121 | ×
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 | {{productDetails.name}}
133 |
134 |
135 | ¥{{productDetails.price}}
136 | ¥{{productDetails.gb_price}}
137 |
138 | 拼团
139 |
140 |
141 |
142 | 库存
143 | {{productDetails.remain}}件
144 |
145 |
146 |
147 |
148 |
149 |
150 |
153 |
156 |
157 |
158 |
159 |
160 | 购买数量
161 |
162 |
163 |
166 |
169 |
172 |
173 |
174 |
175 |
180 |
181 |
182 |
--------------------------------------------------------------------------------
/pages/productDetail/productDetail.wxss:
--------------------------------------------------------------------------------
1 | /* pages/productDetail/productDetail.wxss */
2 |
3 | .productDetail {
4 | padding-bottom: 60px;
5 | }
6 |
7 | swiper.swiper {
8 | height: 300px;
9 | }
10 |
11 | .swiper-img {
12 | width: 100%;
13 | height: 300px;
14 | }
15 |
16 | .commodity-area {
17 | padding: 10px;
18 | }
19 |
20 | .commodity-info {
21 | font-size: 15px;
22 | color: #555;
23 | }
24 |
25 | .prices {
26 | margin-top: 10px;
27 | }
28 |
29 | text.price1 {
30 | margin-right: 10px;
31 | color: #db5078;
32 | font-size: 16px;
33 | font-weight: 600;
34 | }
35 |
36 | text.price2 {
37 | margin-right: 10px;
38 | color: #68bc5e;
39 | font-size: 14px;
40 | }
41 |
42 | .info-area {
43 | padding: 10px;
44 | font-size: 14px;
45 | }
46 |
47 | .info-area .item {
48 | border-top: 1px solid #eee;
49 | padding: 10px 0px;
50 | }
51 |
52 | image.question {
53 | width: 20px;
54 | height: 20px;
55 | margin-right: 10px;
56 | }
57 |
58 | .group-area {
59 | border-top: 10px solid #eee;
60 | }
61 |
62 | .left.rule {
63 | display: block;
64 | }
65 |
66 | .user-area {
67 | padding: 10px;
68 | }
69 |
70 | .user-item {
71 | padding: 5px;
72 | border-top: 1px solid #eee;
73 | }
74 |
75 | .user-image {
76 | display: inline-block;
77 | width: 50px;
78 | vertical-align: middle;
79 | }
80 |
81 | .user-image image {
82 | width: 50px;
83 | height: 50px;
84 | }
85 |
86 | .user-info {
87 | display: inline-block;
88 | width: calc(100% - 60px);
89 | font-size: 14px;
90 | vertical-align: middle;
91 | padding-left: 10px;
92 | }
93 |
94 | .user-description {
95 | display: inline-block;
96 | }
97 |
98 | .gobutton {
99 | display: inline-block;
100 | float: right;
101 | }
102 |
103 | .user-info .info {
104 | margin-top: 5px;
105 | color: #aaa;
106 | }
107 |
108 | .detail-area {
109 | border-top: 10px solid #eee;
110 | }
111 |
112 | .title {
113 | font-size: 16px;
114 | padding: 10px;
115 | }
116 |
117 | .title .content {
118 | padding: 5px 0px;
119 | border-bottom: 2px solid #eee;
120 | }
121 |
122 | .thumb image {
123 | width: 100%;
124 | height: 300px;
125 | }
126 |
127 | .button-area {
128 | bottom: -5px;
129 | position: fixed;
130 | width: 100%;
131 | }
132 |
133 | .commoditySheet {
134 | padding: 10px 0px;
135 | }
136 |
137 | .commoditySheet .price .price1 {
138 | display: inline-block;
139 | }
140 |
141 | .commoditySheet button.appbutton2 {
142 | line-height: 20px;
143 | padding: 0px 10px;
144 | margin-left: 5px;
145 | display: inline-block;
146 | border-radius: 2px;
147 | }
148 |
149 | .commoditySheet .buttons {
150 | padding: 10px 0px;
151 | border-bottom: 1px solid #eee;
152 | }
153 |
154 | .commoditySheet .buttons button.appbutton2 {
155 | margin: 10px 5px;
156 | }
157 |
158 | .commoditySheet .product-description {
159 | min-height: 50px;
160 | padding-top: 0px;
161 | }
162 |
163 | .commoditySheet .remain {
164 | font-size: 12px;
165 | color: #aaa;
166 | margin-top: 5px;
167 | }
168 |
169 | .commoditySheet .close {
170 | display: inline-block;
171 | position: absolute;
172 | right: 0px;
173 | top: 0px;
174 | padding: 10px;
175 | }
176 |
177 | .commoditySheet .control {
178 | padding: 10px;
179 | font-size: 14px;
180 | border-bottom: 1px solid #eee;
181 | margin-bottom: 20px;
182 | }
183 |
184 | .commoditySheet .control button.appbutton2 {
185 | margin-left: 1px;
186 | background-color: #ddd;
187 | color: #000;
188 | }
189 |
190 | .commoditySheet button.large.appbutton2 {
191 | border-radius: 0px;
192 | margin: 0px;
193 | display: block;
194 | line-height: 50px;
195 | margin-bottom: -10px;
196 | }
197 |
198 | .appbutton2.selected {
199 | background-color: #287c1c !important;
200 | }
201 |
202 | .html-div {
203 | margin-left: 10px;
204 | margin-right: 10px;
205 | }
206 |
207 | .group-price {
208 | width: 100%;
209 | display: inline-block;
210 | }
211 | .groupbuy-desc {
212 | float: left;
213 | }
214 | .groupbuy-invite {
215 | float: right;
216 | }
217 | .groupbuy-invite button {
218 | font-size: 26rpx;
219 | line-height: 60rpx;
220 | padding-top: 0;
221 | padding-bottom: 0;
222 | border-radius: 10rpx;
223 | }
--------------------------------------------------------------------------------
/pages/receivedOrder/receivedOrder.js:
--------------------------------------------------------------------------------
1 | // pages/receivedOrder/receivedOrder.js
2 | var util = require('../../utils/util.js')
3 | var config = require('../../config/config.js')
4 | var app = getApp();
5 |
6 | var gnOrderId;
7 |
8 | Page({
9 |
10 | /**
11 | * 页面的初始数据
12 | */
13 | data: {
14 | order: {},
15 | labelReceive: '收货',
16 | config: config,
17 | refundModal: false,
18 | refundReason: ''
19 | },
20 |
21 | onLoad: function(option) {
22 |
23 | var that = this;
24 |
25 | gnOrderId = option.id;
26 |
27 | // 获取快递订单
28 | wx.request({
29 | url: config.api.baseUrl + '/order/detail/' + option.id,//请求地址
30 | data: {},
31 | header: {//请求头
32 | "Content-Type": "applciation/json"
33 | },
34 | method: "GET",//get为默认方法/POST
35 | success: function (res) {
36 | var order = res.data.result;
37 | var strLabel = '收货';
38 | if (order.channel == config.channel.self) {
39 | strLabel = '提货';
40 | }
41 |
42 | that.setData({//如果在sucess直接写this就变成了wx.request()的this了.必须为getdata函数的this,不然无法重置调用函数
43 | order: res.data.result,
44 | labelReceive: strLabel
45 | })
46 | },
47 | fail: function (err) { },//请求失败
48 | complete: function () { }//请求完成后执行的函数
49 | });
50 | },
51 |
52 | /*
53 | Called when user click 确认收货
54 | */
55 | confirmReceipt: function (e) {
56 | wx.request({
57 | url: config.api.baseUrl + '/order/receive',//请求地址
58 | data: {
59 | order_id: gnOrderId,
60 | },
61 | header: {//请求头
62 | "Content-Type": "application/x-www-form-urlencoded"
63 | },
64 | method: "POST",//get为默认方法/POST
65 | success: function (res) {
66 | if (res.statusCode > 200) {
67 | // 失败
68 | return;
69 | }
70 |
71 | // 返回
72 | wx.navigateBack({
73 | delta: 1
74 | })
75 | },
76 | fail: function (err) {
77 | },//请求失败
78 | complete: function () { }//请求完成后执行的函数
79 | });
80 | },
81 |
82 | /**
83 | * 转到地图
84 | */
85 | navigateMap: function() {
86 | var store = this.data.order.store;
87 |
88 | wx.openLocation({
89 | latitude: parseFloat(store.latitude),
90 | longitude: parseFloat(store.longitude),
91 | scale: 12,
92 | name: store.name,
93 | address: store.address,
94 | success: function() {},
95 | fail: function(err) {
96 | wx.showModal({
97 | content: err.errMsg,
98 | showCancel: false
99 | });
100 | }
101 | });
102 | },
103 |
104 | /**
105 | * 申请退款
106 | */
107 | requestRefund: function() {
108 | // 打开输入理由对话框
109 | this.setData({
110 | refundModal: true
111 | })
112 | },
113 |
114 | /**
115 | * 关闭对话框
116 | */
117 | cancelRefundModal: function() {
118 | this.setData({
119 | refundModal: false
120 | })
121 | },
122 |
123 | /**
124 | * 提交退款
125 | */
126 | submitRefund: function() {
127 | var that = this;
128 |
129 | wx.request({
130 | url: config.api.baseUrl + '/order/refund',//请求地址
131 | data: {
132 | order_id: gnOrderId,
133 | reason: this.data.refundReason
134 | },
135 | header: {//请求头
136 | "Content-Type": "application/x-www-form-urlencoded"
137 | },
138 | method: "POST",//get为默认方法/POST
139 | success: function (res) {
140 |
141 | if (res.statusCode > 200) {
142 | // 失败
143 | wx.showModal({
144 | title: '退款申请失败',
145 | showCancel: false
146 | });
147 |
148 | return;
149 | }
150 |
151 | wx.showToast({
152 | title: '申请退款成功'
153 | });
154 |
155 | // 返回
156 | setTimeout(function() {
157 | wx.navigateBack({
158 | delta: 1
159 | });
160 | }, 1000);
161 | },
162 | fail: function (err) {
163 | },//请求失败
164 | complete: function () {
165 | that.cancelRefundModal();
166 | }
167 | });
168 | },
169 |
170 | /**
171 | * 理由input
172 | */
173 | inputReason: function (e) {
174 | this.setData({
175 | refundReason: e.detail.value
176 | })
177 | },
178 | })
--------------------------------------------------------------------------------
/pages/receivedOrder/receivedOrder.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarBackgroundColor": "#ffffff",
3 | "navigationBarTextStyle": "black",
4 | "navigationBarTitleText": "订单详情",
5 | "backgroundColor": "#eeeeee",
6 | "backgroundTextStyle": "light"
7 | }
--------------------------------------------------------------------------------
/pages/receivedOrder/receivedOrder.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 | {{order.product_name}}
13 |
14 |
15 | ×{{order.count}}
16 | ¥{{order.product_price}}
17 |
18 |
19 |
20 |
21 |
22 |
23 | 拼团
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 | 配送方式
32 |
33 | 快递配送
34 | 门店自提
35 |
36 |
37 |
38 |
39 |
40 |
41 | {{order.name}}
42 | {{order.phone}}
43 |
44 |
45 | {{order.area}} {{order.zipcode}}
46 | {{store.name}} {{store.phone}}
47 |
48 | 详细地址 {{order.address}}
49 | 门店地址 {{order.store.address}}
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 | 买家留言
60 |
61 |
62 | {{order.desc}}
63 |
64 |
65 |
66 |
67 | 订单金额
68 |
69 |
70 | ¥{{order.price}}
71 |
72 |
73 |
74 |
75 | 运费
76 |
77 |
78 | ¥{{order.deliver_cost}}
79 |
80 |
81 |
82 |
83 | 快递单号: {{order.deliver_code}}
84 |
85 |
86 |
87 |
88 |
89 |
90 | 参与人数: {{order.groupbuys.length}}
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 | 状态为: {{order.status}}
101 |
102 | (将退款至微信零钱,请查收)
103 |
104 |
105 | (请24小时后前往自提)
106 |
107 |
108 |
109 |
110 |
115 |
116 |
120 |
125 |
126 |
127 |
128 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
--------------------------------------------------------------------------------
/pages/receivedOrder/receivedOrder.wxss:
--------------------------------------------------------------------------------
1 | /* pages/receivedOrder/receivedOrder.wxss */
2 | .pending-item.receivedOrder .mode-area .left {
3 | font-weight:normal;
4 | margin-top:0px;
5 | }
6 | .pending-item.receivedOrder .detail-area .item{
7 | padding: 10px 20px;
8 | }
9 | .pending-item.receivedOrder .button-area {
10 | margin-top:20px;
11 | padding:10px 10px 10px 10px;
12 | border: none;
13 | }
14 | .pending-item.receivedOrder .total{
15 | color: #000;
16 | text-align: center;
17 | }
18 | .groupBuying {
19 | display: block;
20 | line-height: 22px;
21 | }
22 |
23 |
24 | /* 买家留言 */
25 | .desc {
26 | display: inline-block;
27 | }
28 | .desc .title {
29 | float: left;
30 | }
31 | .desc .content {
32 | margin-left: 140rpx;
33 | }
34 |
35 | /* 自提地址区域 */
36 | .address-area {
37 | display: inline-block;
38 | width: calc(100% - 80rpx);
39 | }
40 | .view-address {
41 | float: left;
42 | width: calc(100% - 80rpx - 70rpx);
43 | }
44 | .view-map {
45 | float: right;
46 | width: 70rpx;
47 | height: 120rpx;
48 | text-align:center;
49 | }
50 | .view-map image {
51 | width: 40rpx;
52 | height: 40rpx;
53 | margin-top: 40rpx;
54 | }
--------------------------------------------------------------------------------
/pages/retreatOrder/retreatOrder.js:
--------------------------------------------------------------------------------
1 | // pages/retreatOrder/retreatOrder.js
2 | Page({
3 |
4 | /**
5 | * 页面的初始数据
6 | */
7 | data: {
8 | modalHidden: true
9 | },
10 | confirmRetreat: function (e) {
11 | this.setData({
12 | modalHidden: false
13 | })
14 | },
15 | modalChange: function (e) {
16 | this.setData({
17 | modalHidden: true
18 | })
19 | },
20 | })
--------------------------------------------------------------------------------
/pages/retreatOrder/retreatOrder.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarBackgroundColor": "#ffffff",
3 | "navigationBarTextStyle": "black",
4 | "navigationBarTitleText": "待提货的订单",
5 | "backgroundColor": "#eeeeee",
6 | "backgroundTextStyle": "light"
7 | }
--------------------------------------------------------------------------------
/pages/retreatOrder/retreatOrder.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 | 奶油味夏威夷果 奶油口味特产干货干果 坚果零食小吃袋装
10 |
11 |
12 | ×1
13 | ¥69.00
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 | 配送方式
28 |
29 |
30 | 门店自提
31 |
32 |
33 |
34 |
35 |
36 | 王小萌
37 | 15126489546
38 |
39 | 北工大门店 13031198966
40 | 门店地址 北京工业大学东门
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 | 买家留言
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 | 商品金额
59 |
60 |
61 | ¥69.00
62 |
63 |
64 |
65 |
66 | 参与人数: 1
67 |
68 |
69 | 已结束: 拼团失败
70 |
71 |
72 |
73 |
74 | 状态为: 己收货
75 |
78 |
79 |
80 |
81 |
82 |
83 | _________
84 |
--------------------------------------------------------------------------------
/pages/retreatOrder/retreatOrder.wxss:
--------------------------------------------------------------------------------
1 | /* pages/retreatOrder/retreatOrder.wxss */
2 | .pending-item.deliveredOrder .mode-area .left {
3 | font-weight:normal;
4 | margin-top:0px;
5 | }
6 | .pending-item.deliveredOrder .detail-area .item{
7 | padding: 10px 20px;
8 | }
9 | .pending-item.deliveredOrder .button-area {
10 | margin-top:20px;
11 | padding:10px 10px 10px 10px;
12 | border: none;
13 | }
14 | .pending-item.deliveredOrder .total{
15 | color: #000;
16 | }
17 | button.appbutton6 {
18 | line-height: 20px;
19 | padding: 0px 10px;
20 | margin-bottom: 5px;
21 | background-color: #cbe198;
22 | }
23 | .address-area .right {
24 | margin-top: 20px;
25 | }
--------------------------------------------------------------------------------
/pages/storeOrder/storeOrder.js:
--------------------------------------------------------------------------------
1 | // pages/userStore/userStore.js
2 |
3 | var util = require('../../utils/util.js')
4 | var config = require('../../config/config.js')
5 | var app = getApp();
6 |
7 |
8 | Page({
9 |
10 | /**
11 | * 页面的初始数据
12 | */
13 | data: {
14 | orders:[],
15 | config: config,
16 | showEmptyNotice: false
17 | },
18 |
19 | onLoad: function() {
20 |
21 | var that = this;
22 |
23 | wx.showToast({
24 | title: '正在加载...',
25 | icon: 'loading',
26 | duration: 1000
27 | });
28 |
29 | // 获取快递订单
30 | wx.request({
31 | url: config.api.baseUrl + '/orders/self',//请求地址
32 | data: {
33 | customer_id: app.globalData.userInfo.customerId
34 | },
35 | header: {//请求头
36 | "Content-Type": "applciation/json"
37 | },
38 | method: "GET",//get为默认方法/POST
39 | success: function (res) {
40 | that.setData({//如果在sucess直接写this就变成了wx.request()的this了.必须为getdata函数的this,不然无法重置调用函数
41 | orders: res.data.result,
42 | showEmptyNotice: res.data.result.length <= 0
43 | })
44 | },
45 | fail: function (err) { },//请求失败
46 | complete: function () { }//请求完成后执行的函数
47 | })
48 |
49 | },
50 |
51 | detailClick: function(e) {
52 | // 跳转到订单详情页面
53 | wx.navigateTo({
54 | url: '../receivedOrder/receivedOrder?id=' + e.target.dataset.id
55 | });
56 | },
57 |
58 | /**
59 | * 跳转到商品详情页面
60 | */
61 | productView: function(e) {
62 | wx.navigateTo({
63 | url: '../productDetail/productDetail?id=' + e.currentTarget.dataset.id
64 | });
65 | }
66 |
67 | })
--------------------------------------------------------------------------------
/pages/storeOrder/storeOrder.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarBackgroundColor": "#ffffff",
3 | "navigationBarTextStyle": "black",
4 | "navigationBarTitleText": "门店自提订单",
5 | "backgroundColor": "#eeeeee",
6 | "backgroundTextStyle": "light"
7 | }
--------------------------------------------------------------------------------
/pages/storeOrder/storeOrder.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 | 您暂时还没有门店自提订单
14 |
--------------------------------------------------------------------------------
/pages/storeOrder/storeOrder.wxss:
--------------------------------------------------------------------------------
1 | /* pages/userStore/userStore.wxss */
--------------------------------------------------------------------------------
/pages/templates/homeProduct.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 | {{name}}
12 |
13 |
14 | ¥ {{price}}
15 | 拼团价: ¥ {{gb_price}}
16 | 详情 >
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/pages/templates/orderitem.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | 订单号: {{number}}
6 |
7 |
8 | {{status}}
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 | {{product_name}}
19 |
20 |
21 | ×{{count}}
22 | ¥{{product_price}}
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 | 合计:
39 | ¥{{price}} (含运费 ¥{{deliver_cost}})
40 |
41 | 下单时间: {{created_at}}
42 | 快递配送
43 | 门店自提: {{store_name}}
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 | 人数: {{groupbuy.persons.length}}
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 | 已到期:拼团失败
64 |
65 |
66 | 己结束: 拼团成功
67 |
68 |
69 | 倒计时: {{remain_time_formatted}}
70 |
71 |
72 |
73 |
74 |
--------------------------------------------------------------------------------
/pages/templates/toast.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | aslkdjflaskdjf{{toastText}}
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/pages/templates/wechatUser.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | 小明发起了拼团
9 | 人数: 1人, 倒计时: 23:35:44
10 |
11 |
12 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/pages/test/test.js:
--------------------------------------------------------------------------------
1 | var order = ['green', 'red', 'yellow', 'blue', 'green']
2 | Page({
3 | data: {
4 | toView: "green"
5 | },
6 | upper: function (e) {
7 | console.log(e)
8 | },
9 | lower: function (e) {
10 | console.log(e)
11 | },
12 | scroll: function (e) {
13 | console.log(e)
14 | },
15 | scrollToTop: function (e) {
16 | this.setAction({
17 | scrollTop: 0
18 | })
19 | },
20 | tap: function (e) {
21 | for (var i = 0; i < order.length; ++i) {
22 | if (order[i] === this.data.toView) {
23 | this.setData({
24 | toView: order[i + 1],
25 | scrollTop: (i + 1) * 200
26 | })
27 | break
28 | }
29 | }
30 | },
31 | tapMove: function (e) {
32 | this.setData({
33 | scrollTop: this.data.scrollTop + 10
34 | })
35 | }
36 | })
--------------------------------------------------------------------------------
/pages/test/test.json:
--------------------------------------------------------------------------------
1 | {}
--------------------------------------------------------------------------------
/pages/test/test.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 | swiper
4 | swiper
5 |
6 |
7 |
8 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 | duration
24 |
25 | interval
26 |
27 |
--------------------------------------------------------------------------------
/pages/test/test.wxss:
--------------------------------------------------------------------------------
1 | .swiper-item{
2 | display: block;
3 | height: 150px;
4 | }
--------------------------------------------------------------------------------
/pages/user/user.js:
--------------------------------------------------------------------------------
1 | // pages/user/user.js
2 | var util = require('../../utils/util.js')
3 | var app = getApp()
4 | Page({
5 | data: {
6 | /*owner: {
7 | image: '../../images/user.png',
8 | name: 'Myname'
9 | }*/
10 |
11 | myName: '',
12 | myImage:'',
13 | },
14 | goStorePage: function (e) {
15 | wx.navigateTo({
16 | url: '../storeOrder/storeOrder'
17 | });
18 | },
19 | goDeliveryPage: function (e) {
20 | wx.navigateTo({
21 | url: '../deliveryOrder/deliveryOrder'
22 | });
23 | },
24 | goWePage: function (e) {
25 | wx.navigateTo({
26 | url: '../userGroup/userGroup'
27 | });
28 | },
29 |
30 | /**
31 | * 管理收货地址
32 | */
33 | goAddressPage: function() {
34 | wx.navigateTo({
35 | url: '../editUserAddress/editUserAddress'
36 | });
37 | },
38 |
39 | /**
40 | * 拨打电话
41 | */
42 | goCustomerPage: function (e) {
43 | wx.makePhoneCall({
44 | phoneNumber: this.data.phone
45 | });
46 | },
47 | /**
48 | * 生命周期函数--监听页面加载
49 | */
50 | onLoad: function () {
51 | console.log('onLoad')
52 | // get the categorylist from backend-server
53 | var that = this
54 | that.setData ({
55 | myName : app.globalData.userInfo.nickName,
56 | myImage : app.globalData.userInfo.avatarUrl,
57 | phone: app.setting.customerPhone
58 | })
59 |
60 | console.log(that.myName);
61 | console.log(that.myImage);
62 | },
63 | })
64 |
--------------------------------------------------------------------------------
/pages/user/user.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarBackgroundColor": "#ffffff",
3 | "navigationBarTextStyle": "black",
4 | "navigationBarTitleText": "个人中心",
5 | "backgroundColor": "#eeeeee",
6 | "backgroundTextStyle": "light"
7 | }
--------------------------------------------------------------------------------
/pages/user/user.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | {{myName}}
7 |
8 |
9 |
10 |
11 |
12 | 门店自提订单
13 | >
14 |
15 |
16 |
17 | 快递配送订单
18 | >
19 |
20 |
21 |
22 | 我的拼团
23 | >
24 |
25 |
26 |
27 | 管理收货地址
28 | >
29 |
30 |
31 |
32 | 客服电话
33 |
34 | {{phone}} >
35 |
36 |
37 |
--------------------------------------------------------------------------------
/pages/user/user.wxss:
--------------------------------------------------------------------------------
1 | /* pages/user/user.wxss */
2 |
3 | .user {
4 | background-color: #eee;
5 | min-height: 100vh;
6 | }
7 |
8 | .header-img {
9 | width: 100%;
10 | height: 200px;
11 | }
12 |
13 | .list-item .list-img {
14 | width: 40rpx;
15 | height: 40rpx;
16 | display: inline-block;
17 | vertical-align: middle;
18 | }
19 |
20 | .list-name {
21 | font-size: 14px;
22 | margin-top: 2px;
23 | margin-left: 15px;
24 | display: inline-block;
25 | color: #555;
26 | }
27 |
28 | .arrow {
29 | font-size: 20px;
30 | float: right;
31 | display: inline-block;
32 | color: #555;
33 | }
34 |
35 | .arrow .phone {
36 | font-size: 32rpx;
37 | }
38 |
39 | #address {
40 | margin-top: 15px;
41 | }
42 |
43 | #customer {
44 | margin-top: 15px;
45 | }
46 |
47 | .profile-area {
48 | text-align: center;
49 | margin-top:-150px;
50 | margin-bottom:30px;
51 | }
52 | .profile-img {
53 | width: 100px;
54 | height: 100px;
55 | border-radius: 50%;
56 | }
--------------------------------------------------------------------------------
/pages/userGroup/userGroup.js:
--------------------------------------------------------------------------------
1 | // pages/userGroup/userGroup.js
2 |
3 | var util = require('../../utils/util.js')
4 | var config = require('../../config/config.js')
5 | var app = getApp();
6 |
7 |
8 | Page({
9 |
10 | /**
11 | * 页面的初始数据
12 | */
13 | data: {
14 | orders:[],
15 | config: config,
16 | showEmptyNotice: false
17 | },
18 |
19 | onLoad: function() {
20 |
21 | var that = this;
22 |
23 | // 获取快递订单
24 | wx.request({
25 | url: config.api.baseUrl + '/orders/groupbuy',//请求地址
26 | data: {
27 | customer_id: app.globalData.userInfo.customerId
28 | },
29 | header: {//请求头
30 | "Content-Type": "applciation/json"
31 | },
32 | method: "GET",//get为默认方法/POST
33 | success: function (res) {
34 | var orders = res.data.result;
35 | for (var i = 0; i < orders.length; i++) {
36 | orders[i].remain_time_formatted = util.formatMinute(orders[i].groupbuy.remain_time);
37 | }
38 |
39 | that.setData({//如果在sucess直接写this就变成了wx.request()的this了.必须为getdata函数的this,不然无法重置调用函数
40 | orders: orders,
41 | showEmptyNotice: res.data.result.length <= 0
42 | })
43 | },
44 | fail: function (err) { },//请求失败
45 | complete: function () { }//请求完成后执行的函数
46 | })
47 | },
48 |
49 | detailClick: function(e) {
50 | // 跳转到订单详情页面
51 | wx.navigateTo({
52 | url: '../receivedOrder/receivedOrder?id=' + e.target.dataset.id
53 | });
54 | },
55 |
56 | /**
57 | * 跳转到商品详情页面
58 | */
59 | productView: function(e) {
60 | wx.navigateTo({
61 | url: '../productDetail/productDetail?id=' + e.currentTarget.dataset.id
62 | });
63 | }
64 |
65 |
66 | })
--------------------------------------------------------------------------------
/pages/userGroup/userGroup.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarBackgroundColor": "#ffffff",
3 | "navigationBarTextStyle": "black",
4 | "navigationBarTitleText": "我的拼团列表",
5 | "backgroundColor": "#eeeeee",
6 | "backgroundTextStyle": "light"
7 | }
--------------------------------------------------------------------------------
/pages/userGroup/userGroup.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 | 您暂时还没有拼团订单
15 |
16 |
--------------------------------------------------------------------------------
/pages/userGroup/userGroup.wxss:
--------------------------------------------------------------------------------
1 | /* pages/userGroup/userGroup.wxss */
2 | .count-area {
3 | border-top: 1px solid #eee;
4 | display: inline-block;
5 | line-height: 60rpx;
6 | width: 100%;
7 | }
8 |
9 | .count-area .left {
10 | float: left;
11 | }
12 | .count-area .customer {
13 | max-width: calc(100% - 140rpx);
14 | float:left;
15 | }
--------------------------------------------------------------------------------
/pages/waitingOrder/waitingOrder.js:
--------------------------------------------------------------------------------
1 | // pages/waitingOrder/waitingOrder.js
2 | Page({
3 |
4 | /**
5 | * 页面的初始数据
6 | */
7 | data: {
8 |
9 | },
10 | /*
11 | Called when user click 地图
12 | */
13 | goMap: function (e) {
14 | wx.navigateTo({
15 | url: '../map/map'
16 | });
17 | },
18 | /*
19 | Called when user click 电话
20 | */
21 | goDial: function (e) {
22 |
23 | },
24 | /*
25 | Called when user click 确认提货
26 | */
27 | confirmDelivery: function (e) {
28 | wx.navigateTo({
29 | url: '../index/index'
30 | });
31 | }
32 | })
--------------------------------------------------------------------------------
/pages/waitingOrder/waitingOrder.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarBackgroundColor": "#ffffff",
3 | "navigationBarTextStyle": "black",
4 | "navigationBarTitleText": "待提货的订单",
5 | "backgroundColor": "#eeeeee",
6 | "backgroundTextStyle": "light"
7 | }
--------------------------------------------------------------------------------
/pages/waitingOrder/waitingOrder.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 | 奶油味夏威夷果 奶油口味特产干货干果 坚果零食小吃袋装
10 |
11 |
12 | ×1
13 | ¥69.00
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 | 配送方式
28 |
29 |
30 | 门店自提
31 |
32 |
33 |
34 |
35 |
36 | 王小萌
37 | 15126489546
38 |
39 | 北工大门店 13031198966
40 | 门店地址 北京工业大学东门
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 | 买家留言
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 | 商品金额
59 |
60 |
61 | ¥69.00
62 |
63 |
64 |
65 |
66 | 参与人数: 1
67 |
68 |
69 | 倒计时: 19:56
70 |
71 |
72 |
73 |
74 | 状态为: 拼团中
75 |
78 |
79 |
80 |
--------------------------------------------------------------------------------
/pages/waitingOrder/waitingOrder.wxss:
--------------------------------------------------------------------------------
1 | /* pages/waitingOrder/waitingOrder.wxss */
2 | .pending-item.deliveredOrder .mode-area .left {
3 | font-weight:normal;
4 | margin-top:0px;
5 | }
6 | .pending-item.deliveredOrder .detail-area .item{
7 | padding: 10px 20px;
8 | }
9 | .pending-item.deliveredOrder .button-area {
10 | margin-top:20px;
11 | padding:10px 10px 10px 10px;
12 | border: none;
13 | }
14 | .pending-item.deliveredOrder .total{
15 | color: #000;
16 | }
17 | button.appbutton6 {
18 | line-height: 20px;
19 | padding: 0px 10px;
20 | margin-bottom: 5px;
21 | background-color: #cbe198;
22 | }
23 | .address-area .right {
24 | margin-top: 20px;
25 | }
--------------------------------------------------------------------------------
/utils/util.js:
--------------------------------------------------------------------------------
1 | function formatTime(date) {
2 | var year = date.getFullYear()
3 | var month = date.getMonth() + 1
4 | var day = date.getDate()
5 |
6 | var hour = date.getHours()
7 | var minute = date.getMinutes()
8 | var second = date.getSeconds()
9 |
10 |
11 | return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':')
12 | }
13 |
14 | function formatNumber(n) {
15 | n = n.toString()
16 | return n[1] ? n : '0' + n
17 | }
18 |
19 |
20 | module.exports = {
21 | formatTime: formatTime,
22 |
23 | /**
24 | * 秒转成mm:ss
25 | */
26 | formatMinute: function(seconds) {
27 | var hour = Math.floor(Math.floor(seconds / 60) / 60);
28 | var min = Math.floor(seconds / 60) % 60;
29 |
30 | return [hour, min].map(formatNumber).join(':')
31 | },
32 |
33 | foramtSeconds: function(seconds) {
34 | var sec = seconds % 60;
35 | return this.formatMinute(seconds) + ':' + formatNumber(sec);
36 | },
37 |
38 | // 商品详情 -> 待付款
39 | prepareOrderInfo: {
40 | channel: 0,
41 | },
42 | }
43 |
44 | var groupBuyMode = false;
45 | var userInfo = [];
46 | var productDetails = [];
47 |
48 | var latitude = 0.0;
49 | var longtitude = 0.0;
--------------------------------------------------------------------------------