diff --git a/app/app.js b/app/app.js
index ad18266..b611492 100644
--- a/app/app.js
+++ b/app/app.js
@@ -2,9 +2,6 @@
App({
onLaunch: function () {
//调用API从本地缓存中获取数据
- var logs = wx.getStorageSync('logs') || []
- logs.unshift(Date.now())
- wx.setStorageSync('logs', logs)
},
getUserInfo:function(cb){
var that = this
diff --git a/app/app.json b/app/app.json
index 2f7a1c2..a8adad0 100644
--- a/app/app.json
+++ b/app/app.json
@@ -1,15 +1,15 @@
{
"pages": [
- "pages/mine/mine",
- "pages/shop/show",
"pages/index/index",
+ "pages/shop/show",
+ "pages/index/address",
+ "pages/mine/mine",
"pages/order/show",
"pages/order/quasi",
"pages/order/list",
"pages/address/list",
"pages/address/add",
"pages/address/select",
- "pages/index/address",
"pages/shop/category",
"pages/shop/search"
],
diff --git a/app/app.wxss b/app/app.wxss
index 4303ccf..4d32cea 100644
--- a/app/app.wxss
+++ b/app/app.wxss
@@ -42,18 +42,6 @@ page {
button[type=primary], .weui-btn_primary {
position: relative;
- display: block;
- margin-left: auto;
- margin-right: auto;
- padding-left: 14px;
- padding-right: 14px;
- box-sizing: border-box;
- font-size: 18px;
- text-align: center;
- text-decoration: none;
- line-height: 2.55555556;
- border-radius: 5px;
- -webkit-tap-highlight-color: transparent;
color: #fff;
background-color: #ff5801;
}
diff --git a/app/images/location-arrow.png b/app/images/location-arrow.png
new file mode 100644
index 0000000..0866261
Binary files /dev/null and b/app/images/location-arrow.png differ
diff --git a/app/images/takeout_ic_address.png b/app/images/takeout_ic_address.png
index 2e2204e..5c7319f 100644
Binary files a/app/images/takeout_ic_address.png and b/app/images/takeout_ic_address.png differ
diff --git a/app/pages/index/address.js b/app/pages/index/address.js
index dadce45..deb7c0a 100644
--- a/app/pages/index/address.js
+++ b/app/pages/index/address.js
@@ -1,19 +1,125 @@
// pages/index/address.js
+import {
+ getCurrentAddressList,
+ searchAddressList,
+ splitByKeyword
+} from '../../utils/util'
+import debounce from '../../utils/debounce'
+
+
+
+var initReLocateLabel = '重新定位'
Page({
- data:{},
- onLoad:function(options){
- // 页面初始化 options为页面跳转所带来的参数
+ data: {
+ reLocateLabel: initReLocateLabel,
+ addressList: [
+ {
+ "addr_id": "170",
+ "user_id": "4",
+ "city_id": "330300",
+ "district_id": null,
+ "addr": "龙华大厦",
+ "detail": "",
+ "longitude": "120.69101",
+ "latitude": "28.002974",
+ "receiver": "test4",
+ "phone": "13000000005",
+ "create_time": "2017-02-20 10:38:11",
+ "delete": "0",
+ "district_name": "",
+ "city_name": "温州市"
+ },
+ {
+ "addr_id": "160",
+ "user_id": "4",
+ "city_id": "330300",
+ "district_id": null,
+ "addr": "电商大厦",
+ "detail": "",
+ "longitude": "120.737561",
+ "latitude": "27.979617",
+ "receiver": "test4",
+ "phone": "13000000004",
+ "create_time": "2016-12-16 13:37:10",
+ "delete": "0",
+ "district_name": "",
+ "city_name": "温州市"
+ }
+ ],
+
+ poiList: [],
+
+ showSearchList: false,
+ searchKey: '',
+ searchList: []
},
- onReady:function(){
+ onLoad: function (options) {
+ // 页面初始化 options为页面跳转所带来的参数
+ this.initPoiList()
+ this.onSearchInput = debounce(this.onSearchInput, 300)
+ },
+ onReady: function () {
// 页面渲染完成
},
- onShow:function(){
+ onShow: function () {
// 页面显示
},
- onHide:function(){
+ onHide: function () {
// 页面隐藏
},
- onUnload:function(){
+ onUnload: function () {
// 页面关闭
+ },
+
+ reLocate(e) {
+ this.initPoiList()
+ },
+
+ onSearchInput(e) {
+ var that = this
+ var {value} = e.detail
+ this.setData({
+ searchKey: value,
+ showSearchList: !!value
+ })
+
+ if (value) {
+ searchAddressList({
+ keyword: value,
+ success(data) {
+ data = data.map(item => {
+ item['titleSplit'] = splitByKeyword(item.title, value)
+ return item
+ })
+ that.setData({
+ searchList: data
+ })
+ }
+ })
+ }
+ },
+ clearSearchKey(e) {
+ this.setData({
+ searchKey: '',
+ showSearchList: false
+ })
+ },
+ onSearchItemTap(e) {
+ console.log(e)
+ },
+
+ initPoiList() {
+ var that = this
+ this.setData({
+ reLocateLabel: '定位中...'
+ })
+ getCurrentAddressList({
+ success(addressList) {
+ that.setData({
+ poiList: addressList,
+ reLocateLabel: initReLocateLabel
+ })
+ }
+ })
}
})
\ No newline at end of file
diff --git a/app/pages/index/address.wxml b/app/pages/index/address.wxml
index 0c08448..ea0720f 100644
--- a/app/pages/index/address.wxml
+++ b/app/pages/index/address.wxml
@@ -1,2 +1,55 @@
+
-pages/index/address.wxml
+
+
+
+
+
+
+
+
+
+
+
+
+ {{item.text}}
+
+ {{item.address}}
+
+
+
+
+
+
+ 您的收货地址
+
+
+
+ {{item.addr}}
+
+ {{item.receiver}} {{item.phone}}
+
+
+
+
+
+
+ 定位地址
+
+
+
+ {{item.title}}
+
+
+ 当前定位地址
+
+
+
+ {{reLocateLabel}}
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/pages/index/address.wxss b/app/pages/index/address.wxss
index 47a5f2c..753788c 100644
--- a/app/pages/index/address.wxss
+++ b/app/pages/index/address.wxss
@@ -1 +1,94 @@
-/* pages/index/address.wxss */
\ No newline at end of file
+/* pages/index/address.wxss */
+page {
+ background-color: #fff;
+}
+
+.container {
+ display: flex;
+ flex-direction: column;
+ height: 100vh;
+}
+
+.content {
+ flex: 1;
+ overflow: auto;
+}
+
+.search-box {
+ display: flex;
+ align-items: center;
+ padding: 10px;
+ border-bottom: 1rpx solid #e8e8e8;
+}
+
+.search-box__input-wrap {
+ position: relative;
+ flex: 1;
+ padding-right: 40px;
+}
+
+.search-box__input-clear {
+ position: absolute;
+ top: 50%;
+ right: 10px;
+ transform: translateY(-50%);
+}
+
+.weui-btn_search {
+ margin: 0;
+}
+
+/*address-box*/
+.address-box {
+ margin-top: 15px;
+}
+.address-box__title {
+ padding: 5px 10px;
+ font-size: 14px;
+ color: #999;
+}
+.address-box__title-img {
+ margin-top: -2px;
+ width: 15px;
+ height: 15px;
+ vertical-align: middle;
+}
+
+.address-list {
+ margin-left: 30px;
+}
+
+.address-item {
+ position: relative;
+ padding: 10px 0;
+ border-bottom: 1rpx solid #e8e8e8;
+}
+
+.re-locate {
+ position: absolute;
+ right: 10px;
+ top: 10px;
+ min-width: 5em;
+ text-align: center;
+}
+
+.re-locate__img {
+ height: 15px;
+ width: 15px;
+}
+
+/* search-list */
+.search-list {
+ margin-left: 10px;
+}
+
+.search-item {
+ padding: 10px 0 10px 0;
+ border-bottom: 1rpx solid #e8e8e8;
+}
+
+
+.search-item__address {
+ font-size: 0.8em;
+ color: #999;
+}
\ No newline at end of file
diff --git a/app/pages/index/index.js b/app/pages/index/index.js
index a97db55..4502d22 100644
--- a/app/pages/index/index.js
+++ b/app/pages/index/index.js
@@ -1,6 +1,13 @@
//index.js
//获取应用实例
-var app = getApp()
+import {
+ getCurrentAddress
+} from '../../utils/util'
+
+import {
+ getSellers
+} from '../../utils/apis'
+
Page({
data: {
category: [
@@ -45,81 +52,59 @@ Page({
"icon": "/images/category/8.png"
}
],
- shop: [
- {
- "seller_id": "2",
- "seller_name": "鲜极道",
- "state": "1",
- "city_id": "330300",
- "address": "温州龙湾区衢江路2011号",
- "pic_url": "http://mtest.ipaotui.com/Uploadfile/Img/seller/20170314/1489479032148947903230424.png",
- "pic_hd": "http://mtest.ipaotui.com/Uploadfile/Img/seller/20170314/hd_1489479032148947903230424.png",
- "longitude": "120.748973",
- "latitude": "27.984401",
- "phone": "88888888",
- "start_sell_time": "08:00:00",
- "end_sell_time": "09:00:00",
- "sell_time": "08:00-20:00,08:00-20:00",
- "is_rest": "0",
- "notice": "东池便当,好吃西",
- "reach_time": "30",
- "reserve_day": "0",
- "min_price": "5",
- "sales": "73",
- "service": "0.0",
- "quality": "0.0",
- "overall": "0.0",
- "distance": "11",
- "favorite": "0",
- "promotion": [
- {
- "pic_url": "http://mtest.ipaotui.com/Uploadfile/Img/seller_promotion/first_cut.png",
- "info": "新用户在线支付满15元减10元,满20元减13元"
- },
- {
- "pic_url": "http://mtest.ipaotui.com/Uploadfile/Img/seller_promotion/cut.png",
- "info": "在线支付满15元减5元,满20元减8元"
- }
- ]
- },
- {
- "seller_id": "24",
- "seller_name": "测试",
- "state": "1",
- "city_id": "330300",
- "address": "skldfjhkls",
- "pic_url": "http://mtest.ipaotui.com/Uploadfile/Img/seller/1468462647146846264750782.jpg",
- "pic_hd": "http://mtest.ipaotui.com/Uploadfile/Img/seller/hd_1468462647146846264750782.jpg",
- "longitude": "120.70507",
- "latitude": "28.003041",
- "phone": "13900000000",
- "start_sell_time": "08:00:00",
- "end_sell_time": "22:00:00",
- "sell_time": "08:00-22:00",
- "is_rest": "0",
- "notice": null,
- "reach_time": "30",
- "reserve_day": "0",
- "min_price": "5",
- "sales": "0",
- "service": "0.0",
- "quality": "0.0",
- "overall": "0.0",
- "distance": "4784",
- "favorite": "0",
- "promotion": []
- },
- ]
+ page: 0,
+ hasMore: true,
+ loading: false
},
onLoad: function () {
- console.log('onLoad')
+ this.initAddress()
+ },
+
+ initAddress() {
var that = this
- //调用应用实例的方法获取全局数据
- app.getUserInfo(function (userInfo) {
- //更新数据
+ getCurrentAddress(function(address) {
that.setData({
- userInfo: userInfo
+ currentAddress: address
})
+ that.loadData()
})
- }
+ },
+ loadData() {
+ if (this.data.loading) {
+ return;
+ }
+ var that = this
+ var {
+ page, currentAddress,
+ } = this.data
+
+ this.setData({
+ loading: true
+ })
+ getSellers({
+ page,
+ address: currentAddress,
+ success(data) {
+ var {
+ shopList
+ } = that.data
+
+ var list = data.list.map(item => {
+ item['distanceFormat'] = (item.distance / 1000).toFixed(2)
+ return item
+ })
+ that.setData({
+ shopList: shopList ? shopList.concat(list) : list,
+ page: page + 1,
+ hasMore: data.count == 10,
+ loading: false
+ })
+ }
+ })
+ },
+ onReachBottom(e) {
+ if (this.data.hasMore) {
+ this.loadData()
+ }
+ },
})
diff --git a/app/pages/index/index.wxml b/app/pages/index/index.wxml
index 67cdf13..167820d 100644
--- a/app/pages/index/index.wxml
+++ b/app/pages/index/index.wxml
@@ -1,10 +1,10 @@
+
-
- 电商大厦电商大厦(兴区路)
+ {{currentAddress ? currentAddress.title : '定位中...'}}
搜索
@@ -19,9 +19,8 @@
- 推荐商家
-
+
@@ -39,7 +38,7 @@
起送 ¥{{item.min_price}}
- {{item.distance/1000}}km |
+ {{item.distanceFormat}}km |
{{item.reach_time}}分钟
@@ -52,4 +51,5 @@
-
\ No newline at end of file
+
+
\ No newline at end of file
diff --git a/app/pages/index/index.wxss b/app/pages/index/index.wxss
index 744c6cd..9231287 100644
--- a/app/pages/index/index.wxss
+++ b/app/pages/index/index.wxss
@@ -2,6 +2,7 @@
@import './shop.wxss';
@import '/templates/star-rate.wxss';
+@import '/templates/load-more.wxss';
.topbar {
display: flex;
@@ -11,7 +12,7 @@
.address {
position: relative;
- padding: 3px 5px;
+ padding: 3px 15px 3px 5px;
min-width: 40%;
max-width: 50%;
font-size: 14px;
diff --git a/app/pages/index/shop.wxss b/app/pages/index/shop.wxss
index 461025c..6d5040a 100644
--- a/app/pages/index/shop.wxss
+++ b/app/pages/index/shop.wxss
@@ -33,7 +33,8 @@
}
.shop__promotion-icon {
- width: 20px;
- height: 20px;
+ margin-top: -2px;
+ width: 18px;
+ height: 18px;
vertical-align: middle;
}
\ No newline at end of file
diff --git a/app/pages/shop/show.js b/app/pages/shop/show.js
index 251bc4f..009a760 100644
--- a/app/pages/shop/show.js
+++ b/app/pages/shop/show.js
@@ -1,6 +1,16 @@
// pages/shop/show.js
-import {makePhoneCall} from '../../utils/util'
+import {
+ makePhoneCall,
+ getCurrentAddress,
+ datetimeFormat
+} from '../../utils/util'
+
+import {
+ getSellerInfo,
+ getReviews
+} from '../../utils/apis'
+
var initOrder = {
totalNum: 0,
@@ -14,7 +24,7 @@ var initOrder = {
Page({
data: {
tabs: ["商品", "评价", "商家"],
- activeIndex: 1,
+ activeIndex: 0,
activeMenuIndex: 0,
showCart: false,
@@ -24,607 +34,18 @@ Page({
order: initOrder,
review: {
- "list": [
- {
- "order_id": "1272",
- "user_id": "4",
- "seller_id": "1",
- "service": "5",
- "reach_time": "0",
- "quality": "5",
- "content": "",
- "pic_url": null,
- "time": "1488951898",
- "nick": "te***",
- "head_pic": null
- },
- {
- "order_id": "1271",
- "user_id": "4",
- "seller_id": "1",
- "service": "5",
- "reach_time": "0",
- "quality": "5",
- "content": "123455",
- "pic_url": null,
- "time": "1488944987",
- "nick": "te***",
- "head_pic": null
- },
- {
- "order_id": "1270",
- "user_id": "4",
- "seller_id": "1",
- "service": "4",
- "reach_time": "0",
- "quality": "4",
- "content": "hoohoo",
- "pic_url": null,
- "time": "1488944700",
- "nick": "te***",
- "head_pic": null
- },
- {
- "order_id": "1267",
- "user_id": "4",
- "seller_id": "1",
- "service": "5",
- "reach_time": "0",
- "quality": "5",
- "content": "hoho",
- "pic_url": null,
- "time": "1488936939",
- "nick": "te***",
- "head_pic": null
- },
- {
- "order_id": "1266",
- "user_id": "5",
- "seller_id": "1",
- "service": "5",
- "reach_time": "0",
- "quality": "5",
- "content": "",
- "pic_url": "",
- "time": "1488863802",
- "nick": "te***",
- "head_pic": null
- }
- ],
- "count": 10,
- "page": 0
+ hasMore: true,
+ loading: false,
+ page: 0,
},
- info: {
- "seller_id": "2",
- "seller_name": "鲜极道",
- "state": "1",
- "city_id": "330300",
- "address": "温州龙湾区衢江路2011号",
- "pic_url": "http://mtest.ipaotui.com/Uploadfile/Img/seller/20170314/1489479032148947903230424.png",
- "pic_hd": "http://mtest.ipaotui.com/Uploadfile/Img/seller/20170314/hd_1489479032148947903230424.png",
- "longitude": "120.748973",
- "latitude": "27.984401",
- "phone": "88888888",
- "start_sell_time": "08:00:00",
- "end_sell_time": "09:00:00",
- "sell_time": "08:00-20:00,08:00-20:00",
- "is_rest": "0",
- "notice": "东池便当,好吃西",
- "reach_time": "30",
- "reserve_day": "0",
- "min_price": "5",
- "sales": "74",
- "service": "4.2",
- "quality": "3.5",
- "overall": "4.5",
- "distance": "20434",
- "delivery_fee": 45,
- "favorite": "0",
- "promotion": [
- {
- "pic_url": "http://mtest.ipaotui.com/Uploadfile/Img/seller_promotion/first_cut.png",
- "info": "新用户在线支付满15元减10元,满20元减13元"
- },
- {
- "pic_url": "http://mtest.ipaotui.com/Uploadfile/Img/seller_promotion/cut.png",
- "info": "在线支付满15元减5元,满20元减8元"
- }
- ],
- "menus": [
- {
- "menu_id": "10",
- "menu_name": "热销排行",
- "seller_id": "2",
- "sort": "0",
- "is_use": "1",
- "goods": "29,32,31,30,46",
- "goods2": [
- {
- "goods_id": "29",
- "goods_name": "鸡腿饭",
- "seller_id": "2",
- "pic_url": "http://mtest.ipaotui.com/Uploadfile/Img/seller_goods/1461034075146103407535640.jpg",
- "pic_hd1": "http://mtest.ipaotui.com/Uploadfile/Img/seller_goods/hd1_1461034075146103407535640.jpg",
- "pic_hd2": "http://mtest.ipaotui.com/Uploadfile/Img/seller_goods/hd2_1461034075146103407535640.jpg",
- "detail": "鸡腿饭 xx",
- "price": "22.00",
- "packing_fee": "2.00",
- "sales": "46",
- "praise": "0",
- "stock": "76",
- "sub_goods": [
- {
- "sub_id": "50",
- "sub_name": "大",
- "price": "22.98",
- "packing_fee": "2.00",
- "stock": "74"
- },
- {
- "sub_id": "51",
- "sub_name": "小",
- "price": "22.00",
- "packing_fee": "2.00",
- "stock": "76"
- }
- ]
- },
- {
- "goods_id": "32",
- "goods_name": "鸡翅饭",
- "seller_id": "2",
- "pic_url": null,
- "pic_hd1": null,
- "pic_hd2": null,
- "detail": "鸡翅饭 xx",
- "price": "20.00",
- "packing_fee": "2.00",
- "sales": "41",
- "praise": "0",
- "stock": "59",
- "sub_goods": []
- },
- {
- "goods_id": "31",
- "goods_name": "招牌饭",
- "seller_id": "2",
- "pic_url": "http://mtest.ipaotui.com/Uploadfile/Img/seller_goods/1461033463146103346359875.jpg",
- "pic_hd1": "http://mtest.ipaotui.com/Uploadfile/Img/seller_goods/hd1_1461033463146103346359875.jpg",
- "pic_hd2": "http://mtest.ipaotui.com/Uploadfile/Img/seller_goods/hd2_1461033463146103346359875.jpg",
- "detail": "招牌饭 xx",
- "price": "20.00",
- "packing_fee": "0.00",
- "sales": "14",
- "praise": "0",
- "stock": "86",
- "sub_goods": []
- },
- {
- "goods_id": "30",
- "goods_name": "排骨饭",
- "seller_id": "2",
- "pic_url": "http://mtest.ipaotui.com/Uploadfile/Img/seller_goods/1461034058146103405829482.jpg",
- "pic_hd1": "http://mtest.ipaotui.com/Uploadfile/Img/seller_goods/hd1_1461034058146103405829482.jpg",
- "pic_hd2": "http://mtest.ipaotui.com/Uploadfile/Img/seller_goods/hd2_1461034058146103405829482.jpg",
- "detail": "排骨饭 xx",
- "price": "20.00",
- "packing_fee": "0.00",
- "sales": "10",
- "praise": "0",
- "stock": "0",
- "sub_goods": []
- },
- {
- "goods_id": "46",
- "goods_name": "香肠2",
- "seller_id": "2",
- "pic_url": "http://mtest.ipaotui.com/Uploadfile/Img/seller_goods/1466411009146641100940750.jpg",
- "pic_hd1": "http://mtest.ipaotui.com/Uploadfile/Img/seller_goods/hd1_1466411009146641100940750.jpg",
- "pic_hd2": "http://mtest.ipaotui.com/Uploadfile/Img/seller_goods/hd2_1466411009146641100940750.jpg",
- "detail": "",
- "price": "2.00",
- "packing_fee": "0.00",
- "sales": "13",
- "praise": "0",
- "stock": "187",
- "sub_goods": []
- }
- ]
- },
- {
- "menu_id": "11",
- "menu_name": "便当",
- "seller_id": "2",
- "sort": "0",
- "is_use": "1",
- "goods": "29,33,32,31,30,46",
- "goods2": [
- {
- "goods_id": "29",
- "goods_name": "鸡腿饭",
- "seller_id": "2",
- "pic_url": "http://mtest.ipaotui.com/Uploadfile/Img/seller_goods/1461034075146103407535640.jpg",
- "pic_hd1": "http://mtest.ipaotui.com/Uploadfile/Img/seller_goods/hd1_1461034075146103407535640.jpg",
- "pic_hd2": "http://mtest.ipaotui.com/Uploadfile/Img/seller_goods/hd2_1461034075146103407535640.jpg",
- "detail": "鸡腿饭 xx",
- "price": "22.00",
- "packing_fee": "2.00",
- "sales": "46",
- "praise": "0",
- "stock": "76",
- "sub_goods": [
- {
- "sub_id": "50",
- "sub_name": "大",
- "price": "22.98",
- "packing_fee": "2.00",
- "stock": "74"
- },
- {
- "sub_id": "51",
- "sub_name": "小",
- "price": "22.00",
- "packing_fee": "2.00",
- "stock": "76"
- }
- ]
- },
- {
- "goods_id": "33",
- "goods_name": "香肠饭",
- "seller_id": "2",
- "pic_url": null,
- "pic_hd1": null,
- "pic_hd2": null,
- "detail": "香肠饭 xx",
- "price": "20.00",
- "packing_fee": "0.00",
- "sales": "0",
- "praise": "0",
- "stock": "100",
- "sub_goods": []
- },
- {
- "goods_id": "32",
- "goods_name": "鸡翅饭",
- "seller_id": "2",
- "pic_url": null,
- "pic_hd1": null,
- "pic_hd2": null,
- "detail": "鸡翅饭 xx",
- "price": "20.00",
- "packing_fee": "0.00",
- "sales": "41",
- "praise": "0",
- "stock": "59",
- "sub_goods": []
- },
- {
- "goods_id": "31",
- "goods_name": "招牌饭",
- "seller_id": "2",
- "pic_url": "http://mtest.ipaotui.com/Uploadfile/Img/seller_goods/1461033463146103346359875.jpg",
- "pic_hd1": "http://mtest.ipaotui.com/Uploadfile/Img/seller_goods/hd1_1461033463146103346359875.jpg",
- "pic_hd2": "http://mtest.ipaotui.com/Uploadfile/Img/seller_goods/hd2_1461033463146103346359875.jpg",
- "detail": "招牌饭 xx",
- "price": "20.00",
- "packing_fee": "0.00",
- "sales": "14",
- "praise": "0",
- "stock": "86",
- "sub_goods": []
- },
- {
- "goods_id": "30",
- "goods_name": "排骨饭",
- "seller_id": "2",
- "pic_url": "http://mtest.ipaotui.com/Uploadfile/Img/seller_goods/1461034058146103405829482.jpg",
- "pic_hd1": "http://mtest.ipaotui.com/Uploadfile/Img/seller_goods/hd1_1461034058146103405829482.jpg",
- "pic_hd2": "http://mtest.ipaotui.com/Uploadfile/Img/seller_goods/hd2_1461034058146103405829482.jpg",
- "detail": "排骨饭 xx",
- "price": "20.00",
- "packing_fee": "0.00",
- "sales": "10",
- "praise": "0",
- "stock": "0",
- "sub_goods": []
- },
- {
- "goods_id": "46",
- "goods_name": "香肠2",
- "seller_id": "2",
- "pic_url": "http://mtest.ipaotui.com/Uploadfile/Img/seller_goods/1466411009146641100940750.jpg",
- "pic_hd1": "http://mtest.ipaotui.com/Uploadfile/Img/seller_goods/hd1_1466411009146641100940750.jpg",
- "pic_hd2": "http://mtest.ipaotui.com/Uploadfile/Img/seller_goods/hd2_1466411009146641100940750.jpg",
- "detail": "",
- "price": "2.00",
- "packing_fee": "0.00",
- "sales": "13",
- "praise": "0",
- "stock": "187",
- "sub_goods": []
- }
- ]
- },
- ],
- "goods_map": {
- "29": {
- "goods_id": "29",
- "goods_name": "鸡腿饭",
- "seller_id": "2",
- "pic_url": "http://mtest.ipaotui.com/Uploadfile/Img/seller_goods/1461034075146103407535640.jpg",
- "pic_hd1": "http://mtest.ipaotui.com/Uploadfile/Img/seller_goods/hd1_1461034075146103407535640.jpg",
- "pic_hd2": "http://mtest.ipaotui.com/Uploadfile/Img/seller_goods/hd2_1461034075146103407535640.jpg",
- "detail": "鸡腿饭 xx",
- "price": "22.00",
- "packing_fee": "2.00",
- "sales": "46",
- "praise": "0",
- "stock": "76",
- "sub_goods": [
- {
- "sub_id": "50",
- "sub_name": "大",
- "price": "22.98",
- "packing_fee": "2.00",
- "stock": "74"
- },
- {
- "sub_id": "51",
- "sub_name": "小",
- "price": "22.00",
- "packing_fee": "2.00",
- "stock": "76"
- }
- ],
- "sub_goods_map": {
- "50": {
- "sub_id": "50",
- "sub_name": "大",
- "price": "22.98",
- "packing_fee": "2.00",
- "stock": "74"
- },
- "51": {
- "sub_id": "51",
- "sub_name": "小",
- "price": "22.00",
- "packing_fee": "2.00",
- "stock": "76"
- }
- }
- },
- "30": {
- "goods_id": "30",
- "goods_name": "排骨饭",
- "seller_id": "2",
- "pic_url": "http://mtest.ipaotui.com/Uploadfile/Img/seller_goods/1461034058146103405829482.jpg",
- "pic_hd1": "http://mtest.ipaotui.com/Uploadfile/Img/seller_goods/hd1_1461034058146103405829482.jpg",
- "pic_hd2": "http://mtest.ipaotui.com/Uploadfile/Img/seller_goods/hd2_1461034058146103405829482.jpg",
- "detail": "排骨饭 xx",
- "price": "20.00",
- "packing_fee": "0.00",
- "sales": "10",
- "praise": "0",
- "stock": "0",
- "sub_goods": [],
- "sub_goods_map": []
- },
- "31": {
- "goods_id": "31",
- "goods_name": "招牌饭",
- "seller_id": "2",
- "pic_url": "http://mtest.ipaotui.com/Uploadfile/Img/seller_goods/1461033463146103346359875.jpg",
- "pic_hd1": "http://mtest.ipaotui.com/Uploadfile/Img/seller_goods/hd1_1461033463146103346359875.jpg",
- "pic_hd2": "http://mtest.ipaotui.com/Uploadfile/Img/seller_goods/hd2_1461033463146103346359875.jpg",
- "detail": "招牌饭 xx",
- "price": "20.00",
- "packing_fee": "0.00",
- "sales": "15",
- "praise": "0",
- "stock": "85",
- "sub_goods": [],
- "sub_goods_map": []
- },
- "32": {
- "goods_id": "32",
- "goods_name": "鸡翅饭",
- "seller_id": "2",
- "pic_url": null,
- "pic_hd1": null,
- "pic_hd2": null,
- "detail": "鸡翅饭 xx",
- "price": "20.00",
- "packing_fee": "0.00",
- "sales": "43",
- "praise": "0",
- "stock": "57",
- "sub_goods": [],
- "sub_goods_map": []
- },
- "33": {
- "goods_id": "33",
- "goods_name": "香肠饭",
- "seller_id": "2",
- "pic_url": null,
- "pic_hd1": null,
- "pic_hd2": null,
- "detail": "香肠饭 xx",
- "price": "20.00",
- "packing_fee": "0.00",
- "sales": "0",
- "praise": "0",
- "stock": "100",
- "sub_goods": [],
- "sub_goods_map": []
- },
- "34": {
- "goods_id": "34",
- "goods_name": "咸蛋",
- "seller_id": "2",
- "pic_url": null,
- "pic_hd1": null,
- "pic_hd2": null,
- "detail": "咸蛋 xx",
- "price": "20.00",
- "packing_fee": "0.00",
- "sales": "0",
- "praise": "0",
- "stock": "100",
- "sub_goods": [],
- "sub_goods_map": []
- },
- "35": {
- "goods_id": "35",
- "goods_name": "可乐",
- "seller_id": "2",
- "pic_url": null,
- "pic_hd1": null,
- "pic_hd2": null,
- "detail": "可乐 xx",
- "price": "3.00",
- "packing_fee": "0.00",
- "sales": "0",
- "praise": "0",
- "stock": "100",
- "sub_goods": [],
- "sub_goods_map": []
- },
- "36": {
- "goods_id": "36",
- "goods_name": "雪碧",
- "seller_id": "2",
- "pic_url": null,
- "pic_hd1": null,
- "pic_hd2": null,
- "detail": "雪碧 xx",
- "price": "3.00",
- "packing_fee": "0.00",
- "sales": "0",
- "praise": "0",
- "stock": "100",
- "sub_goods": [],
- "sub_goods_map": []
- },
- "37": {
- "goods_id": "37",
- "goods_name": "香肠",
- "seller_id": "2",
- "pic_url": null,
- "pic_hd1": null,
- "pic_hd2": null,
- "detail": "香肠 xx",
- "price": "3.00",
- "packing_fee": "0.00",
- "sales": "0",
- "praise": "0",
- "stock": "100",
- "sub_goods": [],
- "sub_goods_map": []
- },
- "40": {
- "goods_id": "40",
- "goods_name": "香蕉",
- "seller_id": "2",
- "pic_url": "http://mtest.ipaotui.com/",
- "pic_hd1": null,
- "pic_hd2": null,
- "detail": "",
- "price": "6.00",
- "packing_fee": "0.00",
- "sales": "0",
- "praise": "0",
- "stock": "100",
- "sub_goods": [],
- "sub_goods_map": []
- },
- "41": {
- "goods_id": "41",
- "goods_name": "香蕉2",
- "seller_id": "2",
- "pic_url": "http://mtest.ipaotui.com/",
- "pic_hd1": null,
- "pic_hd2": null,
- "detail": "",
- "price": "6.00",
- "packing_fee": "0.00",
- "sales": "0",
- "praise": "0",
- "stock": "100",
- "sub_goods": [],
- "sub_goods_map": []
- },
- "42": {
- "goods_id": "42",
- "goods_name": "香蕉3",
- "seller_id": "2",
- "pic_url": "http://mtest.ipaotui.com/",
- "pic_hd1": null,
- "pic_hd2": null,
- "detail": "",
- "price": "6.00",
- "packing_fee": "0.00",
- "sales": "0",
- "praise": "0",
- "stock": "100",
- "sub_goods": [],
- "sub_goods_map": []
- },
- "43": {
- "goods_id": "43",
- "goods_name": "香蕉3",
- "seller_id": "2",
- "pic_url": "http://mtest.ipaotui.com/",
- "pic_hd1": null,
- "pic_hd2": null,
- "detail": "",
- "price": "6.00",
- "packing_fee": "0.00",
- "sales": "0",
- "praise": "0",
- "stock": "100",
- "sub_goods": [],
- "sub_goods_map": []
- },
- "44": {
- "goods_id": "44",
- "goods_name": "香蕉3",
- "seller_id": "2",
- "pic_url": "http://mtest.ipaotui.com/",
- "pic_hd1": null,
- "pic_hd2": null,
- "detail": "",
- "price": "6.00",
- "packing_fee": "0.00",
- "sales": "0",
- "praise": "0",
- "stock": "100",
- "sub_goods": [],
- "sub_goods_map": []
- },
- "46": {
- "goods_id": "46",
- "goods_name": "香肠2",
- "seller_id": "2",
- "pic_url": "http://mtest.ipaotui.com/Uploadfile/Img/seller_goods/1466411009146641100940750.jpg",
- "pic_hd1": "http://mtest.ipaotui.com/Uploadfile/Img/seller_goods/hd1_1466411009146641100940750.jpg",
- "pic_hd2": "http://mtest.ipaotui.com/Uploadfile/Img/seller_goods/hd2_1466411009146641100940750.jpg",
- "detail": "",
- "price": "2.00",
- "packing_fee": "0.00",
- "sales": "13",
- "praise": "0",
- "stock": "187",
- "sub_goods": [],
- "sub_goods_map": []
- }
- }
- }
},
onLoad: function (options) {
// 页面初始化 options为页面跳转所带来的参数
+ this.id = options.id || 1
+ this.loadData()
+ this.loadReview()
},
onReady: function () {
// 页面渲染完成
@@ -639,17 +60,65 @@ Page({
// 页面关闭
},
- initTab: function () {
- var that = this;
- wx.getSystemInfo({
- success: function (res) {
- that.setData({
- sliderLeft: (res.windowWidth / that.data.tabs.length - sliderWidth) / 2,
- sliderOffset: res.windowWidth / that.data.tabs.length * that.data.activeIndex
- });
- }
- });
+ loadData() {
+ var that = this
+ var id = this.id;
+ wx.showNavigationBarLoading()
+ getCurrentAddress(function (address) {
+ getSellerInfo({
+ address,
+ seller_id: id,
+ success(data) {
+ data['distanceFormat'] = +(data['distance'] / 1000).toFixed(2)
+ that.setData({
+ info: data
+ })
+ wx.setNavigationBarTitle({
+ title: data.seller_name
+ })
+ },
+ complete() {
+ wx.hideNavigationBarLoading()
+ }
+ })
+ })
},
+
+ loadReview() {
+ var that = this;
+ var id = this.id
+ var {review: {
+ page, loading
+ }} = this.data
+ if (loading) {
+ return;
+ }
+
+ this.setData({
+ 'review.loading': true
+ })
+ getReviews({
+ page,
+ seller_id: id,
+ success(data) {
+ var {review: {
+ list
+ }} = that.data
+ var list2 = data.list.map(item => {
+ item['timeFormat'] = datetimeFormat(item['time']);
+ return item
+ })
+
+ that.setData({
+ 'review.list': list ? list.concat(list2) : list2,
+ 'review.loading': false,
+ 'review.page': page + 1,
+ 'review.hasMore': data.count == 10
+ })
+ }
+ })
+ },
+
tabClick: function (e) {
this.setData({
activeIndex: e.currentTarget.id
@@ -853,5 +322,14 @@ Page({
onPhoneTap(e) {
var {phone} = e.currentTarget.dataset
makePhoneCall(phone)
+ },
+
+ onScrolltolower(e) {
+ var {
+ hasMore, loading
+ } = this.data.review
+ if (hasMore && !loading) {
+ this.loadReview()
+ }
}
})
\ No newline at end of file
diff --git a/app/pages/shop/show.wxml b/app/pages/shop/show.wxml
index 1585329..06a8762 100644
--- a/app/pages/shop/show.wxml
+++ b/app/pages/shop/show.wxml
@@ -1,4 +1,5 @@
+
@@ -15,7 +16,7 @@
{{info.seller_name}}
- {{info.min_price}}元起送 | {{info.reach_time}}分钟 | 距离{{info.distance / 1000}}km
+ {{info.min_price}}元起送 | {{info.reach_time}}分钟 | 距离{{info.distanceFormat}}km
公告: {{info.notice}}
@@ -93,46 +94,49 @@
-
-
- {{info.overall}}
- 综合评分
-
-
-
- 商家评分
-
- {{info.quality}}
+
+
+
+ {{info.overall}}
+ 综合评分
-
- 配送评分
-
- {{info.service}}
-
-
-
-
-
-
-
-
+
+
+ 商家评分
+
+ {{info.quality}}
-
-
- {{item.time}}
- {{item.nick}}
-
-
- 及时到达
+
+ 配送评分
+
+ {{info.service}}
+
+
+
+
+
+
+
+
+
+
+
+ {{item.timeFormat}}
+ {{item.nick}}
+
+
+ 及时到达
+
+
+
+ {{item.content}}
-
- {{item.content}}
-
-
+
+
@@ -169,7 +173,6 @@
{{info.address}}
-
营业时间
diff --git a/app/pages/shop/show.wxss b/app/pages/shop/show.wxss
index 13525fd..4e0420c 100644
--- a/app/pages/shop/show.wxss
+++ b/app/pages/shop/show.wxss
@@ -1,5 +1,6 @@
/* pages/shop/show.wxss */
@import '/templates/star-rate.wxss';
+@import '/templates/load-more.wxss';
@import './templates/goods-actions.wxss';
@import './templates/cart-box.wxss';
@import './templates/sub-goods.wxss';
@@ -240,6 +241,9 @@
.weui-tab__content_review {
background-color: #f8f8f8;
}
+.scroll-view_review{
+ height: 100%;
+}
.shop-rate {
display: flex;
diff --git a/app/templates/load-more.wxml b/app/templates/load-more.wxml
new file mode 100644
index 0000000..f32e0bf
--- /dev/null
+++ b/app/templates/load-more.wxml
@@ -0,0 +1,14 @@
+
+
+
+ 正在加载
+
+
+ 加载更多
+
+
+
+ {{noMoreLabel ? noMoreLabel : '没有更多数据'}}
+
+
+
\ No newline at end of file
diff --git a/app/templates/load-more.wxss b/app/templates/load-more.wxss
new file mode 100644
index 0000000..dddb7e2
--- /dev/null
+++ b/app/templates/load-more.wxss
@@ -0,0 +1,3 @@
+.weui-loadmore__tips_in-line {
+ background-color: #f8f8f8;
+}
\ No newline at end of file
diff --git a/app/utils/apis.js b/app/utils/apis.js
new file mode 100644
index 0000000..faf4c3f
--- /dev/null
+++ b/app/utils/apis.js
@@ -0,0 +1,61 @@
+import {
+ fetch, coordFormat,
+ alert, confirm
+} from './util'
+
+// 获取商店列表
+export function getSellers(options) {
+ var {
+ page, address,
+ success
+ } = options
+ page = page || 0
+ var location = coordFormat(address.location)
+ fetch({
+ url: 'index.php?m=Mall&c=Seller&a=getSellers',
+ data: {
+ page,
+ city_name: address.city,
+ city_id: address.city_id,
+ district_name: address.district,
+ district_id: address.district_id,
+ longitude: location.longitude,
+ latitude: location.latitude
+ },
+ success
+ })
+}
+
+// 获取商店详情
+export function getSellerInfo(options) {
+ var {
+ seller_id, address,
+ success, complete
+ } = options
+ var location = coordFormat(address.location)
+ fetch({
+ url: 'index.php?m=Mall&c=Seller&a=getSellerInfo',
+ data: {
+ seller_id,
+ longitude: location.longitude,
+ latitude: location.latitude
+ },
+ success, complete
+ })
+}
+
+// 获取商店评论
+export function getReviews(options) {
+ var {
+ seller_id, page,
+ success
+ } = options
+ page = page || 0
+ fetch({
+ url: 'index.php?m=Mall&c=Seller&a=getReviews',
+ data: {
+ seller_id, page
+ },
+ success
+ })
+}
\ No newline at end of file
diff --git a/app/utils/debounce.js b/app/utils/debounce.js
new file mode 100644
index 0000000..b898427
--- /dev/null
+++ b/app/utils/debounce.js
@@ -0,0 +1,56 @@
+/**
+ * Returns a function, that, as long as it continues to be invoked, will not
+ * be triggered. The function will be called after it stops being called for
+ * N milliseconds. If `immediate` is passed, trigger the function on the
+ * leading edge, instead of the trailing. The function also has a property 'clear'
+ * that is a function which will clear the timer to prevent previously scheduled executions.
+ *
+ * @source underscore.js
+ * @see http://unscriptable.com/2009/03/20/debouncing-javascript-methods/
+ * @param {Function} function to wrap
+ * @param {Number} timeout in ms (`100`)
+ * @param {Boolean} whether to execute at the beginning (`false`)
+ * @api public
+ */
+
+module.exports = function debounce(func, wait, immediate){
+ var timeout, args, context, timestamp, result;
+ if (null == wait) wait = 100;
+
+ function later() {
+ var last = Date.now() - timestamp;
+
+ if (last < wait && last >= 0) {
+ timeout = setTimeout(later, wait - last);
+ } else {
+ timeout = null;
+ if (!immediate) {
+ result = func.apply(context, args);
+ context = args = null;
+ }
+ }
+ };
+
+ var debounced = function(){
+ context = this;
+ args = arguments;
+ timestamp = Date.now();
+ var callNow = immediate && !timeout;
+ if (!timeout) timeout = setTimeout(later, wait);
+ if (callNow) {
+ result = func.apply(context, args);
+ context = args = null;
+ }
+
+ return result;
+ };
+
+ debounced.clear = function() {
+ if (timeout) {
+ clearTimeout(timeout);
+ timeout = null;
+ }
+ };
+
+ return debounced;
+};
diff --git a/app/utils/util.js b/app/utils/util.js
index b57f9bd..40efd89 100644
--- a/app/utils/util.js
+++ b/app/utils/util.js
@@ -36,7 +36,7 @@ export function reverseGeocoder(options) {
}
// 获取当前地理位置
-export function getCurrentAddress(options) {
+export function getCurrentAddressList(options) {
const {
success, complete
} = options
@@ -50,25 +50,93 @@ export function getCurrentAddress(options) {
},
success, complete
})
+ },
+ fail(e) {
+ console.log(res.errMsg)
+ alert('获取用户地址失败')
}
})
}
+// 地点搜索
+export function searchAddressList(options) {
+ const {
+ keyword, success
+ } = options
+ getCurrentCity(function (cityName) {
+ qqmap.getSuggestion({
+ region: cityName,
+ keyword,
+ success(res) {
+ success && success(res.data)
+ }
+ })
+ })
+}
+
+// 获取当期地址
+var currentAddress;
+export function getCurrentAddress(callback) {
+ if(currentAddress) {
+ return callback && callback(currentAddress)
+ }
+
+ getCurrentAddressList({
+ success(addressList) {
+ if(addressList.length > 0) {
+ currentAddress = addressList[0]
+ callback(currentAddress)
+ }
+ }
+ })
+}
+
+
+// 获取当前城市
+var cityName;
+export function getCurrentCity(callback) {
+ if (cityName) {
+ return callback && callback(cityName)
+ }
+ wx.getLocation({
+ type: 'gcj02',
+ success(res) {
+ qqmap.reverseGeocoder({
+ location: {
+ longitude: res.longitude,
+ latitude: res.latitude
+ },
+ success: function (res) {
+ cityName = res.result.address_component.city
+ callback && callback(cityName)
+ }
+ })
+ },
+ fail(res) {
+ console.log(res.errMsg)
+ alert('获取用户地址失败')
+ }
+ })
+}
+
+
// 根据坐标获取地址信息
export function getAddressFromLocation(options) {
const {location, success} = options
getPois({
location,
success(pois) {
- var poi = pois[0]
- if (poi) {
- var address = Object.assign({
- address_name: poi.title,
- location,
- }, resolveAdInfo(poi.ad_info))
-
- success && success(address)
- }
+ var addressList = []
+ pois.forEach(poi => {
+ var {
+ title, location,
+ address, ad_info
+ } = poi
+ addressList.push(Object.assign({
+ title, location, address
+ }, resolveAdInfo(ad_info)))
+ })
+ success && success(addressList)
}
})
}
@@ -100,7 +168,7 @@ export function fetch(options) {
wx.request({
url: `https://${host}/${options.url}`,
data: Object.assign(options.data, {
- 'app_v': 'ipaotui_mini'
+ 'app_v': 'ipaotui_mall'
}),
method: options.method || 'POST',
header: {
@@ -179,8 +247,18 @@ export function datetimeFormat(unix_timestamp) {
// 坐标格式化
export function coordFormat(location) {
+ if(location.lat && location.lng) {
+ location = {
+ longitude: location.lng,
+ latitude: location.lat
+ }
+ }
// gcj02 转 bd09
- return gcj02tobd09(location.longitude, location.latitude).join(',')
+ var location = gcj02tobd09(location.longitude, location.latitude)
+ return {
+ longitude: location[0],
+ latitude: location[1]
+ }
}
// 倒计时格式化
@@ -189,4 +267,28 @@ export function countdownFormat(count) {
count = Math.floor(count / 60)
var minutes = count % 60
return `${minutes}分钟${seconds}秒`
+}
+
+// 字符串关键字分组
+
+export function splitByKeyword(text, keyword) {
+ if (!text) {
+ return []
+ }
+ var arr = text.split(keyword)
+ var res = []
+ res.push({
+ text: arr[0],
+ isKeyword: false
+ })
+ for (let i = 1, len = arr.length; i < len; i++) {
+ res.push({
+ text: keyword,
+ isKeyword: true
+ }, {
+ text: arr[i],
+ isKeyword: false
+ })
+ }
+ return res
}
\ No newline at end of file