diff --git a/app/app.json b/app/app.json
index a128b06..8f9a0c3 100644
--- a/app/app.json
+++ b/app/app.json
@@ -1,6 +1,8 @@
{
"pages": [
"pages/index/index",
+ "pages/index/category",
+ "pages/index/search",
"pages/shop/show",
"pages/order/list",
"pages/order/show",
@@ -10,9 +12,7 @@
"pages/address/list",
"pages/index/address",
"pages/address/add",
- "pages/login/login",
- "pages/shop/category",
- "pages/shop/search"
+ "pages/login/login"
],
"window": {
"backgroundColor": "#f8f8f8",
diff --git a/app/pages/index/category.js b/app/pages/index/category.js
new file mode 100644
index 0000000..7bff39d
--- /dev/null
+++ b/app/pages/index/category.js
@@ -0,0 +1,126 @@
+// pages/index/category.js
+import {
+ getSellersByCategory
+} from '../../utils/apis'
+
+Page({
+
+ /**
+ * 页面的初始数据
+ */
+ data: {
+ page: 0,
+ hasMore: true,
+ loading: false
+ },
+
+ /**
+ * 生命周期函数--监听页面加载
+ */
+ onLoad: function (options) {
+ this.id = options.id || 1
+ this.loadData()
+ },
+
+ /**
+ * 生命周期函数--监听页面初次渲染完成
+ */
+ onReady: function () {
+
+ },
+
+ /**
+ * 生命周期函数--监听页面显示
+ */
+ onShow: function () {
+
+ },
+
+ /**
+ * 生命周期函数--监听页面隐藏
+ */
+ onHide: function () {
+
+ },
+
+ /**
+ * 生命周期函数--监听页面卸载
+ */
+ onUnload: function () {
+
+ },
+
+ /**
+ * 页面相关事件处理函数--监听用户下拉动作
+ */
+ onPullDownRefresh: function () {
+
+ },
+
+ /**
+ * 页面上拉触底事件的处理函数
+ */
+ onReachBottom: function () {
+
+ },
+
+ /**
+ * 用户点击右上角分享
+ */
+ onShareAppMessage: function () {
+
+ },
+
+ /**
+ * 页面上拉触底事件的处理函数
+ */
+ onReachBottom: function () {
+ var {loading, hasMore} = this.data
+ if (hasMore && !loading) {
+ this.loadData()
+ }
+ },
+
+ /**
+ * 页面相关事件处理函数--监听用户下拉动作
+ */
+ onPullDownRefresh: function () {
+
+ },
+
+ loadData() {
+ var that = this
+ var {id: category_id} = this
+ var {loading, page} = this.data
+ if (loading) {
+ return
+ }
+ that.setData({
+ loading: true
+ })
+
+ getSellersByCategory({
+ category_id, page,
+ success(data) {
+ var {list} = that.data
+ var {
+ list: list2, count, page
+ } = data
+ list2 = list2.map(item => {
+ item['distanceFormat'] = (item.distance / 1000).toFixed(2)
+ return item
+ })
+ that.setData({
+ loading: false,
+ list: list ? list.concat(list2) : list2,
+ hasMore: count == 10,
+ page: page + 1
+ })
+ wx.setNavigationBarTitle({
+ title: data.title,
+ })
+ }
+ })
+
+ }
+})
\ No newline at end of file
diff --git a/app/pages/shop/category.json b/app/pages/index/category.json
similarity index 100%
rename from app/pages/shop/category.json
rename to app/pages/index/category.json
diff --git a/app/pages/index/category.wxml b/app/pages/index/category.wxml
new file mode 100644
index 0000000..8f73e58
--- /dev/null
+++ b/app/pages/index/category.wxml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/pages/index/category.wxss b/app/pages/index/category.wxss
new file mode 100644
index 0000000..92375e6
--- /dev/null
+++ b/app/pages/index/category.wxss
@@ -0,0 +1,7 @@
+/* pages/index/category.wxss */
+@import '/templates/load-more.wxss';
+@import './templates/shop.wxss';
+
+.shop-list {
+ margin-top: 10px;
+}
\ No newline at end of file
diff --git a/app/pages/index/index.js b/app/pages/index/index.js
index 573eb9c..eef7e7e 100644
--- a/app/pages/index/index.js
+++ b/app/pages/index/index.js
@@ -76,7 +76,7 @@ Page({
}
var that = this
var {
- page, currentAddress,
+ page,
} = this.data
this.setData({
@@ -84,7 +84,6 @@ Page({
})
getSellers({
page,
- address: currentAddress,
success(data) {
var {
shopList
diff --git a/app/pages/index/index.wxml b/app/pages/index/index.wxml
index ff40cb0..79b7dd1 100644
--- a/app/pages/index/index.wxml
+++ b/app/pages/index/index.wxml
@@ -1,5 +1,5 @@
-
+
@@ -11,7 +11,7 @@
-
+
@@ -20,36 +20,7 @@
-
-
-
-
-
- {{item.seller_name}}
-
-
-
-
-
- 月售 {{item.sales}} 单
-
-
-
-
- 起送 ¥{{item.min_price}}
-
- {{item.distanceFormat}}km |
- {{item.reach_time}}分钟
-
-
-
-
-
- {{item.info}}
-
-
-
-
+
\ No newline at end of file
diff --git a/app/pages/index/index.wxss b/app/pages/index/index.wxss
index 66d7a0f..02a0dba 100644
--- a/app/pages/index/index.wxss
+++ b/app/pages/index/index.wxss
@@ -1,7 +1,6 @@
/**index.wxss**/
-@import './shop.wxss';
-@import '/templates/star-rate.wxss';
+@import './templates/shop.wxss';
@import '/templates/load-more.wxss';
.topbar {
diff --git a/app/pages/index/search.js b/app/pages/index/search.js
new file mode 100644
index 0000000..1fe2621
--- /dev/null
+++ b/app/pages/index/search.js
@@ -0,0 +1,80 @@
+// pages/index/search.js
+Page({
+
+ /**
+ * 页面的初始数据
+ */
+ data: {
+
+ },
+
+ /**
+ * 生命周期函数--监听页面加载
+ */
+ onLoad: function (options) {
+
+ },
+
+ /**
+ * 生命周期函数--监听页面初次渲染完成
+ */
+ onReady: function () {
+
+ },
+
+ /**
+ * 生命周期函数--监听页面显示
+ */
+ onShow: function () {
+
+ },
+
+ /**
+ * 生命周期函数--监听页面隐藏
+ */
+ onHide: function () {
+
+ },
+
+ /**
+ * 生命周期函数--监听页面卸载
+ */
+ onUnload: function () {
+
+ },
+
+ /**
+ * 页面相关事件处理函数--监听用户下拉动作
+ */
+ onPullDownRefresh: function () {
+
+ },
+
+ /**
+ * 页面上拉触底事件的处理函数
+ */
+ onReachBottom: function () {
+
+ },
+
+ /**
+ * 用户点击右上角分享
+ */
+ onShareAppMessage: function () {
+
+ },
+
+ /**
+ * 页面上拉触底事件的处理函数
+ */
+ onReachBottom: function () {
+
+ },
+
+ /**
+ * 页面相关事件处理函数--监听用户下拉动作
+ */
+ onPullDownRefresh: function () {
+
+ }
+})
\ No newline at end of file
diff --git a/app/pages/shop/search.json b/app/pages/index/search.json
similarity index 100%
rename from app/pages/shop/search.json
rename to app/pages/index/search.json
diff --git a/app/pages/index/search.wxml b/app/pages/index/search.wxml
new file mode 100644
index 0000000..2e49c82
--- /dev/null
+++ b/app/pages/index/search.wxml
@@ -0,0 +1,2 @@
+
+pages/index/search.wxml
diff --git a/app/pages/index/search.wxss b/app/pages/index/search.wxss
new file mode 100644
index 0000000..7f4a7fb
--- /dev/null
+++ b/app/pages/index/search.wxss
@@ -0,0 +1 @@
+/* pages/index/search.wxss */
\ No newline at end of file
diff --git a/app/pages/index/templates/shop.wxml b/app/pages/index/templates/shop.wxml
new file mode 100644
index 0000000..d4922be
--- /dev/null
+++ b/app/pages/index/templates/shop.wxml
@@ -0,0 +1,34 @@
+
+
+
+
+
+
+
+
+ {{seller_name}}
+
+
+
+
+
+ 月售 {{sales}} 单
+
+
+
+
+ 起送 ¥{{min_price}}
+
+ {{distanceFormat}}km |
+ {{reach_time}}分钟
+
+
+
+
+
+ {{item.info}}
+
+
+
+
+
\ No newline at end of file
diff --git a/app/pages/index/shop.wxss b/app/pages/index/templates/shop.wxss
similarity index 82%
rename from app/pages/index/shop.wxss
rename to app/pages/index/templates/shop.wxss
index 6d5040a..1213d30 100644
--- a/app/pages/index/shop.wxss
+++ b/app/pages/index/templates/shop.wxss
@@ -1,5 +1,8 @@
+@import '/templates/star-rate.wxss';
+
.shop__item {
align-items: flex-start;
+ background-color: #fff;
}
.shop__sales {
diff --git a/app/pages/shop/category.js b/app/pages/shop/category.js
deleted file mode 100644
index fbf4e8f..0000000
--- a/app/pages/shop/category.js
+++ /dev/null
@@ -1,19 +0,0 @@
-// pages/shop/category.js
-Page({
- data:{},
- onLoad:function(options){
- // 页面初始化 options为页面跳转所带来的参数
- },
- onReady:function(){
- // 页面渲染完成
- },
- onShow:function(){
- // 页面显示
- },
- onHide:function(){
- // 页面隐藏
- },
- onUnload:function(){
- // 页面关闭
- }
-})
\ No newline at end of file
diff --git a/app/pages/shop/category.wxml b/app/pages/shop/category.wxml
deleted file mode 100644
index 4d9137e..0000000
--- a/app/pages/shop/category.wxml
+++ /dev/null
@@ -1,2 +0,0 @@
-
-pages/shop/category.wxml
diff --git a/app/pages/shop/category.wxss b/app/pages/shop/category.wxss
deleted file mode 100644
index 3523e2e..0000000
--- a/app/pages/shop/category.wxss
+++ /dev/null
@@ -1 +0,0 @@
-/* pages/shop/category.wxss */
\ No newline at end of file
diff --git a/app/pages/shop/search.js b/app/pages/shop/search.js
deleted file mode 100644
index 12dc670..0000000
--- a/app/pages/shop/search.js
+++ /dev/null
@@ -1,19 +0,0 @@
-// pages/shop/search.js
-Page({
- data:{},
- onLoad:function(options){
- // 页面初始化 options为页面跳转所带来的参数
- },
- onReady:function(){
- // 页面渲染完成
- },
- onShow:function(){
- // 页面显示
- },
- onHide:function(){
- // 页面隐藏
- },
- onUnload:function(){
- // 页面关闭
- }
-})
\ No newline at end of file
diff --git a/app/pages/shop/search.wxml b/app/pages/shop/search.wxml
deleted file mode 100644
index 16c1f6c..0000000
--- a/app/pages/shop/search.wxml
+++ /dev/null
@@ -1,2 +0,0 @@
-
-pages/shop/search.wxml
diff --git a/app/pages/shop/search.wxss b/app/pages/shop/search.wxss
deleted file mode 100644
index 6a05c40..0000000
--- a/app/pages/shop/search.wxss
+++ /dev/null
@@ -1 +0,0 @@
-/* pages/shop/search.wxss */
\ No newline at end of file
diff --git a/app/utils/apis.js b/app/utils/apis.js
index bba9c70..f3ec774 100644
--- a/app/utils/apis.js
+++ b/app/utils/apis.js
@@ -6,23 +6,25 @@ import {
// 获取商店列表
export function getSellers(options) {
var {
- page, address,
+ page,
success
} = options
page = page || 0
- var location = 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
+ getApp().getCurrentAddress(address => {
+ var location = 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
+ })
})
}
@@ -483,4 +485,35 @@ export function getPayment(options) {
})
})
-}
\ No newline at end of file
+}
+
+
+// 获取分组列表
+export function getSellersByCategory(options) {
+ var {
+ category_id, page,
+ success, error
+ } = options
+ page = page || 0
+ getApp().getCurrentAddress(address => {
+ var {
+ location,
+ city_id,
+ city: city_name,
+ district_id,
+ district: district_name
+ } = address
+ fetch({
+ url: 'index.php?m=Mall&c=Seller&a=getSellersByCategory',
+ data: {
+ category_id,
+ city_id, city_name,
+ district_id, district_name,
+ page,
+ gps: `${location.longitude},${location.latitude}`,
+ },
+ success, error
+ })
+
+ })
+}