diff --git a/api/common.js b/api/common.js index 6b75dcb..f1b802d 100644 --- a/api/common.js +++ b/api/common.js @@ -4,7 +4,7 @@ const token = wx.getStorageSync('accessToken'); export default { community:{ - list:()=>request.get('/api/community') + list:(data)=>request.get('/api/community',data) }, address:{ list(commityId){ diff --git a/api/shop.js b/api/shop.js index 2eade75..02bda2e 100644 --- a/api/shop.js +++ b/api/shop.js @@ -2,17 +2,7 @@ import request from './request'; export default { category:()=>request.get('/api/merchant-categories'), - list(category_id,longitude,latitude){ - const data = {}; - if(category_id){ - data.category_id = category_id; - } - if(longitude&&latitude){ - data.longitude = longitude; - data.latitude = latitude; - } - return request.get('/api/merchant',data); - }, + list:(data)=>request.get('/api/merchant',data), detail(id,lng,lat){ const data = {}; if(lng&&lat){ @@ -25,7 +15,7 @@ export default { - orderList:()=>request.get('/api/merchant-pay'), + orderList:(data)=>request.get('/api/merchant-pay',data), //计算商品订单金额 calculateOrderPrice:(merchant_product_id)=>request.post('/api/merchant/order/calculate-price',{merchant_product_id}), //计算在线买单赠送积分 diff --git a/api/user.js b/api/user.js index 1f362f5..a8f6647 100644 --- a/api/user.js +++ b/api/user.js @@ -30,9 +30,9 @@ export default { }, pre:(data)=>request.post('/api/order/pre-order',data), real:(data)=>request.post('/api/order',data), - list:()=>request.get('/api/order/user/list'), + list:(data)=>request.get('/api/order/user/list',data), cancel:(orderid)=>request.post(`/api/order/${orderid}/user/cancel`), - merchantList:()=>request.get('/api/merchant/order/user'), + merchantList:(data)=>request.get('/api/merchant/order/user',data), merchantDetail(order_id,longitude,latitude){ const data = {}; if(longitude&&latitude){ diff --git a/app.wxss b/app.wxss index ac5528f..fd44146 100644 --- a/app.wxss +++ b/app.wxss @@ -2,13 +2,13 @@ page{ font-size:32rpx; line-height: 1; - padding-bottom:80rpx; --main-font-color:#222222; --main-bgclolor:#F5F5F5; --main-color:#FEC400; --main-hover-color:#fcce39; color:var(--main-font-color); background-color:var(--main-bgclolor); + overflow: hidden; } button{ @@ -262,7 +262,6 @@ page-container .content{ justify-content: space-between; background-color: #fff; font-size: 34rpx; - font-weight: 600; } .tab-bar .item-container{ flex:1; @@ -271,7 +270,7 @@ page-container .content{ .tab-bar .item{ position: relative; padding:40rpx 0; - color: #7C8695; + color: #555555; transition-duration: .4s; display: inline-block; } @@ -286,7 +285,8 @@ page-container .content{ transition-duration: .4s; } .tab-bar .current .item{ - color: var(--main-color); + color: var(--main-font-color); + font-weight: 500; } .tab-bar .current .item::before{ opacity: 1; @@ -312,4 +312,8 @@ navigator button{ font-size: 26rpx; color: #A1A1A1; margin-top:24rpx; +} + +.scroll-view-dispatch{ + height:100rpx; } \ No newline at end of file diff --git a/assets/icon/help/arrow-down@2x.png b/assets/icon/help/arrow-down@2x.png index c0c6fa1..da14477 100644 Binary files a/assets/icon/help/arrow-down@2x.png and b/assets/icon/help/arrow-down@2x.png differ diff --git a/assets/icon/navbar/lanfeng@2x.png b/assets/icon/navbar/lanfeng@2x.png index 3510f5d..3a22197 100644 Binary files a/assets/icon/navbar/lanfeng@2x.png and b/assets/icon/navbar/lanfeng@2x.png differ diff --git a/components/listView/index.js b/components/listView/index.js new file mode 100644 index 0000000..5178677 --- /dev/null +++ b/components/listView/index.js @@ -0,0 +1,61 @@ +// components/listView/index.js +Component({ + + /** + * 组件的属性列表 + */ + properties: { + "bindrefresherrefresh":{ + type:Function + }, + "refresherTriggered":{ + type:Boolean, + value:false + }, + "height":{ + type:Number + }, + loadMoreText:{ + type:String, + value:'已经到底了' + }, + showLoadMore:{ + type:Boolean, + value:true + }, + loadAll:{ + type:Boolean, + value:false + } + }, + + /** + * 组件的初始数据 + */ + data: { + defaultHeight:'' + }, + lifetimes:{ + attached(){ + const windowInfo = wx.getWindowInfo(); + this.setData({ + defaultHeight:`calc(100vh)` + }) + } + }, + /** + * 组件的方法列表 + */ + methods: { + refreshList(){ + this.triggerEvent('refresh'); + }, + scrolling(event){ + //scrollTop scrollHeight + const bottomHeight = event.detail.scrollHeight-event.detail.scrollTop-this.properties.height; + if(bottomHeight<100){ + this.triggerEvent('loadMore'); + } + } + } +}) \ No newline at end of file diff --git a/components/listView/index.json b/components/listView/index.json new file mode 100644 index 0000000..e8cfaaf --- /dev/null +++ b/components/listView/index.json @@ -0,0 +1,4 @@ +{ + "component": true, + "usingComponents": {} +} \ No newline at end of file diff --git a/components/listView/index.wxml b/components/listView/index.wxml new file mode 100644 index 0000000..3b044a7 --- /dev/null +++ b/components/listView/index.wxml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/components/listView/index.wxss b/components/listView/index.wxss new file mode 100644 index 0000000..6c9d683 --- /dev/null +++ b/components/listView/index.wxss @@ -0,0 +1,21 @@ +.load-more{ + padding:100rpx 0; + text-align: center; + color: #888888; + font-size:24rpx; + position: relative; + width:80%; + margin:0 auto; +} +.load-more .text{ + background-color: var(--main-bgclolor); + padding:0 30rpx; +} +.load-more::before{ + content: ''; + position: absolute; + left:0;top:112rpx; + width:100%;height:1.5rpx; + background-color: rgba(136, 136, 136, 0.25); + z-index: -1; +} \ No newline at end of file diff --git a/components/navbar/index.js b/components/navbar/index.js index 41b9578..28d0974 100644 --- a/components/navbar/index.js +++ b/components/navbar/index.js @@ -34,6 +34,7 @@ Component({ attached(){ console.log('1212121212'); const windowInfo = wx.getWindowInfo(); + this.setData({ statusBarHeight:windowInfo.statusBarHeight }) diff --git a/pages/help/community/index.js b/pages/help/community/index.js index 9739bf6..561ba7b 100644 --- a/pages/help/community/index.js +++ b/pages/help/community/index.js @@ -1,4 +1,5 @@ import commonApi from '../../../api/common'; +const app = getApp(); Page({ @@ -7,7 +8,12 @@ Page({ */ data: { currentCommunity:null, - communityList:[] + defaultCommunityId:null, + communityList:[], + scrollViewHeight:0, + lng:0, + lat:0, + pager:{limit:10,loading:false,loadAll:false,pageIndex:0,refreshTrigger:false} }, onSelectItem(event){ const pages = getCurrentPages(); @@ -22,22 +28,72 @@ Page({ * 生命周期函数--监听页面加载 */ onLoad(options) { - console.log(options); - commonApi.community.list().then((data)=>{ + const windowInfo = wx.getWindowInfo(); + this.setData({ + scrollViewHeight:windowInfo.windowHeight, + defaultCommunityId:options.communityId + }) + app.getLocation().then((res)=>{ + this.setData({ + lng:res.longitude, + lat:res.latitude + }); + this.loadList(); + }).catch(()=>{ + this.loadList(); + }) + }, + loadList(){ + if(this.data.pager.loading||this.data.pager.loadAll){ + return; + } + this.data.pager.loading = true; + this.setData({ + pager:this.data.pager + }); + const data = { + skip:this.data.pager.limit*this.data.pager.pageIndex, + limit:this.data.pager.limit + } + if(this.data.lng&&this.data.lat){ + data.longitude = this.data.lng; + data.latitude = this.data.lat; + } + commonApi.community.list(data).then((data)=>{ const communityList = data.items; let currentCommunity; data.items.map((item)=>{ - if(item.id==options.communityId){ + if(item.distance){ + if(item.distance>=100){ + item.distance = parseFloat(item.distance/1000).toFixed(1)+'km'; + }else{ + item.distance+='m'; + } + } + if(item.id==this.data.defaultCommunityId){ currentCommunity = item; } }) + + if(this.data.pager.pageIndex==0){ + this.data.communityList = data.items; + }else{ + this.data.communityList = this.data.communityList.concat(data.items); + } + this.data.pager.loading = false; + this.data.pager.pageIndex++; + this.data.pager.refreshTrigger = false; + if(data.items.length + @@ -10,4 +14,4 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/pages/help/community/index.wxss b/pages/help/community/index.wxss index 172b9a5..8086726 100644 --- a/pages/help/community/index.wxss +++ b/pages/help/community/index.wxss @@ -32,4 +32,5 @@ flex: 1; } .community-list .item .sub-title .value{ + margin-left:10rpx; } \ No newline at end of file diff --git a/pages/help/index/index.js b/pages/help/index/index.js index 14cc1ca..da082d1 100644 --- a/pages/help/index/index.js +++ b/pages/help/index/index.js @@ -48,7 +48,6 @@ Page({ wx.getStorage({ key:'pre-order', success:(res)=>{ - console.log(res.data); const name = []; let count = 0; res.data.price_request.packages.map((item)=>{ @@ -61,6 +60,14 @@ Page({ count:count } }) + }, + fail:(res)=>{ + this.setData({ + package:{ + name:'', + count:0 + } + }) } }); if(!this.data.manuallyChangedCommunity){ @@ -130,6 +137,9 @@ Page({ success:(res)=>{ res.data.addressid = this.data.currentAddress.id; userApi.order.real(res.data).then((data)=>{ + this.setData({ + isShowOrderConfirm:false + }); wx.removeStorage({ key: 'pre-order', }); diff --git a/pages/help/index/index.wxss b/pages/help/index/index.wxss index 72e944c..b3294e4 100644 --- a/pages/help/index/index.wxss +++ b/pages/help/index/index.wxss @@ -12,7 +12,6 @@ .choose-community{ padding:90rpx 40rpx 70rpx; position: relative; - color:#fff; font-size:0; } .choose-community .text{ diff --git a/pages/my/money/index.js b/pages/my/money/index.js index 096e7e9..8c8f748 100644 --- a/pages/my/money/index.js +++ b/pages/my/money/index.js @@ -1,4 +1,5 @@ import userApi from '../../../api/user'; +const app = getApp(); Page({ @@ -6,7 +7,8 @@ Page({ * 页面的初始数据 */ data: { - list:[] + list:[], + userInfo:{} }, /** @@ -15,7 +17,12 @@ Page({ onLoad(options) { userApi.point.list().then((data)=>{ this.setData({ - list:data + list:data.items + }) + }); + app.getUserInfo().then((data)=>{ + this.setData({ + userInfo:data }) }) }, diff --git a/pages/my/money/index.json b/pages/my/money/index.json index f10332b..756315a 100644 --- a/pages/my/money/index.json +++ b/pages/my/money/index.json @@ -1,4 +1,4 @@ { "usingComponents": {}, - "navigationBarTitleText": "消费金" + "navigationBarTitleText": "蜂蜜" } \ No newline at end of file diff --git a/pages/my/money/index.wxml b/pages/my/money/index.wxml index 910c599..dd5c2d1 100644 --- a/pages/my/money/index.wxml +++ b/pages/my/money/index.wxml @@ -1,16 +1,16 @@ 蜂蜜 (克) - 0 + {{userInfo.points}} 取包裹自动抵扣 - 跑腿订单返现 - 2024.03.01 10:12:20 + {{item.description}} + {{item.create_time}} - 3.3 + {{item.points}} diff --git a/pages/my/money/index.wxss b/pages/my/money/index.wxss index a45111c..1925a41 100644 --- a/pages/my/money/index.wxss +++ b/pages/my/money/index.wxss @@ -46,8 +46,10 @@ color: #888888; margin-top:44rpx; } -.money-list .item .money::before{ - content: '+'; +.money-list .item .points{ + font-size: 40rpx; + font-weight: 500; + color: var(--main-color); } .list-empty{ padding-top:300rpx; diff --git a/pages/order/index/index.js b/pages/order/index/index.js index 837bef3..26eadb8 100644 --- a/pages/order/index/index.js +++ b/pages/order/index/index.js @@ -7,6 +7,7 @@ Page({ * 页面的初始数据 */ data: { + scrollViewHeight:0, tabIndex:0, orderList:[], merchantOrderList:[], @@ -19,6 +20,15 @@ Page({ merchantOrderStatus:shopApi.merchantOrderStatus, merchantOrderStatusKV:shopApi.merchantOrderStatusKV, + + refreshTriggered:{ + tab1:false,tab2:false,tab3:false + }, + pager:{ + tab1:{limit:10,loading:false,loadAll:false,pageIndex:0}, + tab2:{limit:10,loading:false,loadAll:false,pageIndex:0}, + tab3:{limit:4,loading:false,loadAll:false,pageIndex:0} + } }, changeTab(event){ const tabIndex = event.currentTarget.dataset.index; @@ -32,10 +42,9 @@ Page({ }, goToShopDetail(event){ const item = event.currentTarget.dataset.item; - //缺少 shopid - // wx.navigateTo({ - // url: `/pages/shop/detail/index?id=${item.id}`, - // }) + wx.navigateTo({ + url: `/pages/shop/detail/index?id=${item.merchant_id}`, + }) }, goToCouponDetail(event){ const id = event.currentTarget.dataset.id; @@ -63,33 +72,144 @@ Page({ this.loadOrderList(); this.loadMerchantOrderList(); this.loadMerchantPayOrderList(); + + const windowInfo = wx.getWindowInfo(); + this.setData({ + scrollViewHeight:windowInfo.windowHeight-windowInfo.statusBarHeight-44-57 + }) + + }, + refreshList(){ + if(this.data.tabIndex==0){ + this.data.pager.tab1.pageIndex = 0; + this.data.pager.tab1.loadAll = false; + this.setData({ + pager:this.data.pager + }); + this.loadOrderList(); + }else if(this.data.tabIndex==1){ + this.data.pager.tab2.pageIndex = 0; + this.data.pager.tab2.loadAll = false; + this.setData({ + pager:this.data.pager + }); + this.loadMerchantPayOrderList(); + }else if(this.data.tabIndex==2){ + this.data.pager.tab3.pageIndex = 0; + this.data.pager.tab3.loadAll = false; + this.setData({ + pager:this.data.pager + }); + this.loadMerchantOrderList(); + } + }, + loadMore(){ + if(this.data.tabIndex==0){ + this.loadOrderList() + }else if(this.data.tabIndex==1){ + this.loadMerchantPayOrderList(); + }else if(this.data.tabIndex==2){ + this.loadMerchantOrderList(); + } }, loadOrderList(){ //代取快递列表 - userApi.order.list().then((data)=>{ + if(this.data.pager.tab1.loading||this.data.pager.tab1.loadAll){ + return; + } + this.data.pager.tab1.loading = true; + this.setData({ + pager:this.data.pager + }); + userApi.order.list({ + skip:this.data.pager.tab1.pageIndex*this.data.pager.tab1.limit, + limit:this.data.pager.tab1.limit + }).then((data)=>{ + if(this.data.pager.tab1.pageIndex==0){ + this.data.orderList = data.items; + }else{ + this.data.orderList = this.data.orderList.concat(data.items); + } + this.data.pager.tab1.loading = false; + this.data.pager.tab1.pageIndex++; + if(data.items.length{ + if(this.data.pager.tab2.loading||this.data.pager.tab2.loadAll){ + return; + } + this.data.pager.tab2.loading = true; + this.setData({ + pager:this.data.pager + }); + shopApi.orderList({ + skip:this.data.pager.tab2.pageIndex*this.data.pager.tab2.limit, + limit:this.data.pager.tab2.limit + }).then((data)=>{ + if(this.data.pager.tab2.pageIndex==0){ + this.data.merchantOrderList = data.items; + }else{ + this.data.merchantOrderList = this.data.merchantOrderList.concat(data.items); + } + this.data.pager.tab2.loading = false; + this.data.pager.tab2.pageIndex++; + if(data.items.length{ + if(this.data.pager.tab3.loading||this.data.pager.tab3.loadAll){ + return; + } + this.data.pager.tab3.loading = true; + this.setData({ + pager:this.data.pager + }); + userApi.order.merchantList({ + skip:this.data.pager.tab3.pageIndex*this.data.pager.tab3.limit, + limit:this.data.pager.tab3.limit + }).then((data)=>{ data.map((item)=>{ if(item.product_tags){ item.product_tags = item.product_tags.split(','); } - }) + }); + if(this.data.pager.tab3.pageIndex==0){ + this.data.couponList = data; + }else{ + this.data.couponList = this.data.couponList.concat(data); + } + this.data.pager.tab3.loading = false; + this.data.pager.tab3.pageIndex++; + if(data.length + 跑腿服务 @@ -10,8 +11,11 @@ 代金券 - - + @@ -35,9 +39,20 @@ - - - + + + + + 暂无相关订单 + + + + + {{item.merchant_name}} -{{item.amount}} @@ -66,8 +81,18 @@ {{item.order_id}} - - + + + + 暂无相关订单 + + + + @@ -90,11 +115,11 @@ - - - - 暂无相关订单 - + + + 暂无相关订单 + + \ No newline at end of file diff --git a/pages/order/index/index.wxss b/pages/order/index/index.wxss index 583ebf5..473995a 100644 --- a/pages/order/index/index.wxss +++ b/pages/order/index/index.wxss @@ -1,9 +1,6 @@ .nav-bar{ background-color: #fff; } - - -.order-list{} .order-list .item{ background-color: #fff; border-radius: 18rpx; @@ -150,9 +147,6 @@ margin-left: 20rpx; } -.bill-list{ - -} .bill-list .item{ text-align: center; background-color: #fff; diff --git a/pages/shop/detail/index.js b/pages/shop/detail/index.js index f502fd9..056e0cf 100644 --- a/pages/shop/detail/index.js +++ b/pages/shop/detail/index.js @@ -14,7 +14,9 @@ Page({ productList:[], currentProduct:{}, calculatedPrice:{}, - calculating:false + calculating:false, + scrollViewHeight:0, + windowInfo:{} }, showConfirm(event){ @@ -28,6 +30,13 @@ Page({ * 生命周期函数--监听页面加载 */ onLoad(options) { + const windowInfo = wx.getWindowInfo(); + console.log(windowInfo); + this.setData({ + windowInfo:windowInfo, + scrollViewHeight:windowInfo.screenHeight-251-windowInfo.statusBarHeight-53 + }) + const shopId = options.id; app.getLocation().then((data)=>{ @@ -39,6 +48,7 @@ Page({ data.items.map((item)=>{ item.tags = item.tags.split(',') }) + data.items = data.items; this.setData({ productList:data.items }); diff --git a/pages/shop/detail/index.wxml b/pages/shop/detail/index.wxml index 77a9e77..909f7fc 100644 --- a/pages/shop/detail/index.wxml +++ b/pages/shop/detail/index.wxml @@ -1,18 +1,3 @@ - @@ -57,23 +42,26 @@ - - - - - + + + + + + + + {{item.name}} + + + + - {{item.name}} - - - + + - - - - + + diff --git a/pages/shop/detail/index.wxss b/pages/shop/detail/index.wxss index 5c78051..edad673 100644 --- a/pages/shop/detail/index.wxss +++ b/pages/shop/detail/index.wxss @@ -186,5 +186,4 @@ line-height: 1; padding:18rpx 46rpx; margin-left:40rpx; -} - +} \ No newline at end of file diff --git a/pages/shop/index/index.js b/pages/shop/index/index.js index 926d660..9c63579 100644 --- a/pages/shop/index/index.js +++ b/pages/shop/index/index.js @@ -14,16 +14,57 @@ Page({ shopList:[], userInfo:{}, lng:null, - lat:null + lat:null, + scrollViewHeight:0, + pager:{limit:10,loading:false,loadAll:false,pageIndex:0,refreshTrigger:false} }, changeTab(event){ const tabIndex = event.currentTarget.dataset.index; const cid = event.currentTarget.dataset.cid; - this.setData({tabIndex}) - this.loadList(cid); + this.data.pager.pageIndex = 0; + this.data.pager.loadAll = false; + this.setData({tabIndex,pager:this.data.pager}) + this.loadList(); }, - loadList(cid){ - shopApi.list(cid,this.data.lng,this.data.lat).then((data)=>{ + refreshList(){ + this.data.pager.pageIndex = 0; + this.data.pager.loadAll = false; + this.setData({ + pager:this.data.pager + }); + this.loadList(); + }, + loadList(){ + if(this.data.pager.loading||this.data.pager.loadAll){ + return; + } + this.data.pager.loading = true; + this.setData({ + pager:this.data.pager + }); + const cid = this.data.categories.length>0?this.data.categories[this.data.tabIndex].id:0; + const params = { + longitude:this.data.lng, + latitude:this.data.lat, + skip:this.data.pager.pageIndex*this.data.pager.limit, + limit:this.data.pager.limit + } + if(cid){ + params.category_id = cid; + } + shopApi.list(params).then((data)=>{ + if(this.data.pager.pageIndex==0){ + this.data.shopList = data.items; + }else{ + this.data.shopList = this.data.shopList.concat(data.items); + } + this.data.pager.loading = false; + this.data.pager.pageIndex++; + this.data.pager.refreshTrigger = false; + if(data.items.length{ if(item.distance){ if(item.distance>=1000){ @@ -34,7 +75,8 @@ Page({ } }) this.setData({ - shopList:data.items + shopList:this.data.shopList, + pager:this.data.pager }) }); }, @@ -42,6 +84,10 @@ Page({ * 生命周期函数--监听页面加载 */ onLoad(options) { + const windowInfo = wx.getWindowInfo(); + this.setData({ + scrollViewHeight:windowInfo.windowHeight-windowInfo.statusBarHeight-44-174 + }) app.getLocation().then((data)=>{ this.setData({ lng:data.longitude, diff --git a/pages/shop/index/index.json b/pages/shop/index/index.json index eb94160..9e1e791 100644 --- a/pages/shop/index/index.json +++ b/pages/shop/index/index.json @@ -1,7 +1,8 @@ { "usingComponents": { "nav-bar":"/components/navbar", - "shop-item":"/components/shopItem" + "shop-item":"/components/shopItem", + "list-view":"/components/listView" }, "navigationStyle": "custom" } \ No newline at end of file diff --git a/pages/shop/index/index.wxml b/pages/shop/index/index.wxml index 59b65d7..a5fa238 100644 --- a/pages/shop/index/index.wxml +++ b/pages/shop/index/index.wxml @@ -12,13 +12,15 @@ - - - - - - - + + + + + 暂无该分类商铺 - \ No newline at end of file + \ No newline at end of file