list-view+若干 bug

This commit is contained in:
2025-02-14 18:21:54 +08:00
parent cc5add80cd
commit 7242ac3709
31 changed files with 472 additions and 117 deletions

View File

@ -4,7 +4,7 @@ const token = wx.getStorageSync('accessToken');
export default { export default {
community:{ community:{
list:()=>request.get('/api/community') list:(data)=>request.get('/api/community',data)
}, },
address:{ address:{
list(commityId){ list(commityId){

View File

@ -2,17 +2,7 @@ import request from './request';
export default { export default {
category:()=>request.get('/api/merchant-categories'), category:()=>request.get('/api/merchant-categories'),
list(category_id,longitude,latitude){ list:(data)=>request.get('/api/merchant',data),
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);
},
detail(id,lng,lat){ detail(id,lng,lat){
const data = {}; const data = {};
if(lng&&lat){ 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}), calculateOrderPrice:(merchant_product_id)=>request.post('/api/merchant/order/calculate-price',{merchant_product_id}),
//计算在线买单赠送积分 //计算在线买单赠送积分

View File

@ -30,9 +30,9 @@ export default {
}, },
pre:(data)=>request.post('/api/order/pre-order',data), pre:(data)=>request.post('/api/order/pre-order',data),
real:(data)=>request.post('/api/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`), 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){ merchantDetail(order_id,longitude,latitude){
const data = {}; const data = {};
if(longitude&&latitude){ if(longitude&&latitude){

View File

@ -2,13 +2,13 @@
page{ page{
font-size:32rpx; font-size:32rpx;
line-height: 1; line-height: 1;
padding-bottom:80rpx;
--main-font-color:#222222; --main-font-color:#222222;
--main-bgclolor:#F5F5F5; --main-bgclolor:#F5F5F5;
--main-color:#FEC400; --main-color:#FEC400;
--main-hover-color:#fcce39; --main-hover-color:#fcce39;
color:var(--main-font-color); color:var(--main-font-color);
background-color:var(--main-bgclolor); background-color:var(--main-bgclolor);
overflow: hidden;
} }
button{ button{
@ -262,7 +262,6 @@ page-container .content{
justify-content: space-between; justify-content: space-between;
background-color: #fff; background-color: #fff;
font-size: 34rpx; font-size: 34rpx;
font-weight: 600;
} }
.tab-bar .item-container{ .tab-bar .item-container{
flex:1; flex:1;
@ -271,7 +270,7 @@ page-container .content{
.tab-bar .item{ .tab-bar .item{
position: relative; position: relative;
padding:40rpx 0; padding:40rpx 0;
color: #7C8695; color: #555555;
transition-duration: .4s; transition-duration: .4s;
display: inline-block; display: inline-block;
} }
@ -286,7 +285,8 @@ page-container .content{
transition-duration: .4s; transition-duration: .4s;
} }
.tab-bar .current .item{ .tab-bar .current .item{
color: var(--main-color); color: var(--main-font-color);
font-weight: 500;
} }
.tab-bar .current .item::before{ .tab-bar .current .item::before{
opacity: 1; opacity: 1;
@ -313,3 +313,7 @@ navigator button{
color: #A1A1A1; color: #A1A1A1;
margin-top:24rpx; margin-top:24rpx;
} }
.scroll-view-dispatch{
height:100rpx;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 198 B

After

Width:  |  Height:  |  Size: 182 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

View File

@ -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');
}
}
}
})

View File

@ -0,0 +1,4 @@
{
"component": true,
"usingComponents": {}
}

View File

@ -0,0 +1,7 @@
<scroll-view scroll-y refresher-enabled="true" bindrefresherrefresh="refreshList" refresher-triggered="{{refresherTriggered}}" style="height:{{height*2}}rpx;" bindscroll="scrolling">
<slot/>
<view class="load-more" wx:if="{{showLoadMore}}">
<label class="text" wx:if="{{loadAll}}">{{loadMoreText}}</label>
<label class="text" wx:else>加载中...</label>
</view>
</scroll-view>

View File

@ -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;
}

View File

@ -34,6 +34,7 @@ Component({
attached(){ attached(){
console.log('1212121212'); console.log('1212121212');
const windowInfo = wx.getWindowInfo(); const windowInfo = wx.getWindowInfo();
this.setData({ this.setData({
statusBarHeight:windowInfo.statusBarHeight statusBarHeight:windowInfo.statusBarHeight
}) })

View File

@ -1,4 +1,5 @@
import commonApi from '../../../api/common'; import commonApi from '../../../api/common';
const app = getApp();
Page({ Page({
@ -7,7 +8,12 @@ Page({
*/ */
data: { data: {
currentCommunity:null, 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){ onSelectItem(event){
const pages = getCurrentPages(); const pages = getCurrentPages();
@ -22,22 +28,72 @@ Page({
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad(options) { onLoad(options) {
console.log(options); const windowInfo = wx.getWindowInfo();
commonApi.community.list().then((data)=>{ 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; const communityList = data.items;
let currentCommunity; let currentCommunity;
data.items.map((item)=>{ 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; 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<this.data.pager.limit){
this.data.pager.loadAll = true;
}
this.setData({ this.setData({
communityList, communityList:this.data.communityList,
currentCommunity currentCommunity,
pager:this.data.pager
}); });
}); });
}, },
/** /**
* 生命周期函数--监听页面初次渲染完成 * 生命周期函数--监听页面初次渲染完成
*/ */

View File

@ -1,4 +1,6 @@
{ {
"usingComponents": {}, "usingComponents": {
"list-view":"/components/listView"
},
"navigationBarTitleText": "开通小区" "navigationBarTitleText": "开通小区"
} }

View File

@ -1,4 +1,8 @@
<view class="community-list"> <list-view class="community-list" bind:refresh="refreshList"
bind:loadMore="loadList" height="{{scrollViewHeight}}"
refresher-triggered="{{pager.refreshTrigger}}"
show-load-more="{{communityList.length!=0}}"
loading="{{pager.loading}}" load-all="{{pager.loadAll}}">
<view class="item {{item.id==currentCommunity.id?'current':''}}" wx:for="{{communityList}}" wx:key="index" <view class="item {{item.id==currentCommunity.id?'current':''}}" wx:for="{{communityList}}" wx:key="index"
bind:tap="onSelectItem" data-item="{{item}}"> bind:tap="onSelectItem" data-item="{{item}}">
<view class="title"> <view class="title">
@ -10,4 +14,4 @@
<label class="value">{{item.distance||''}}</label> <label class="value">{{item.distance||''}}</label>
</view> </view>
</view> </view>
</view> </list-view>

View File

@ -32,4 +32,5 @@
flex: 1; flex: 1;
} }
.community-list .item .sub-title .value{ .community-list .item .sub-title .value{
margin-left:10rpx;
} }

View File

@ -48,7 +48,6 @@ Page({
wx.getStorage({ wx.getStorage({
key:'pre-order', key:'pre-order',
success:(res)=>{ success:(res)=>{
console.log(res.data);
const name = []; const name = [];
let count = 0; let count = 0;
res.data.price_request.packages.map((item)=>{ res.data.price_request.packages.map((item)=>{
@ -61,6 +60,14 @@ Page({
count:count count:count
} }
}) })
},
fail:(res)=>{
this.setData({
package:{
name:'',
count:0
}
})
} }
}); });
if(!this.data.manuallyChangedCommunity){ if(!this.data.manuallyChangedCommunity){
@ -130,6 +137,9 @@ Page({
success:(res)=>{ success:(res)=>{
res.data.addressid = this.data.currentAddress.id; res.data.addressid = this.data.currentAddress.id;
userApi.order.real(res.data).then((data)=>{ userApi.order.real(res.data).then((data)=>{
this.setData({
isShowOrderConfirm:false
});
wx.removeStorage({ wx.removeStorage({
key: 'pre-order', key: 'pre-order',
}); });

View File

@ -12,7 +12,6 @@
.choose-community{ .choose-community{
padding:90rpx 40rpx 70rpx; padding:90rpx 40rpx 70rpx;
position: relative; position: relative;
color:#fff;
font-size:0; font-size:0;
} }
.choose-community .text{ .choose-community .text{

View File

@ -1,4 +1,5 @@
import userApi from '../../../api/user'; import userApi from '../../../api/user';
const app = getApp();
Page({ Page({
@ -6,7 +7,8 @@ Page({
* 页面的初始数据 * 页面的初始数据
*/ */
data: { data: {
list:[] list:[],
userInfo:{}
}, },
/** /**
@ -15,7 +17,12 @@ Page({
onLoad(options) { onLoad(options) {
userApi.point.list().then((data)=>{ userApi.point.list().then((data)=>{
this.setData({ this.setData({
list:data list:data.items
})
});
app.getUserInfo().then((data)=>{
this.setData({
userInfo:data
}) })
}) })
}, },

View File

@ -1,4 +1,4 @@
{ {
"usingComponents": {}, "usingComponents": {},
"navigationBarTitleText": "消费金" "navigationBarTitleText": "蜂蜜"
} }

View File

@ -1,16 +1,16 @@
<view class="consume"> <view class="consume">
<view class="title">蜂蜜 (克)</view> <view class="title">蜂蜜 (克)</view>
<view class="point">0</view> <view class="point">{{userInfo.points}}</view>
<view class="tips">取包裹自动抵扣</view> <view class="tips">取包裹自动抵扣</view>
</view> </view>
<view class="money-list" wx:if="{{list.length>0}}"> <view class="money-list" wx:if="{{list.length>0}}">
<view class="item" wx:for="{{list}}" wx:key="index"> <view class="item" wx:for="{{list}}" wx:key="index">
<view class="left"> <view class="left">
<view class="name">跑腿订单返现</view> <view class="name">{{item.description}}</view>
<view class="desc">2024.03.01 10:12:20</view> <view class="desc">{{item.create_time}}</view>
</view> </view>
<view class="money money-yellow">3.3</view> <view class="points">{{item.points}}</view>
</view> </view>
</view> </view>
<view class="list-empty" wx:else> <view class="list-empty" wx:else>

View File

@ -46,8 +46,10 @@
color: #888888; color: #888888;
margin-top:44rpx; margin-top:44rpx;
} }
.money-list .item .money::before{ .money-list .item .points{
content: '+'; font-size: 40rpx;
font-weight: 500;
color: var(--main-color);
} }
.list-empty{ .list-empty{
padding-top:300rpx; padding-top:300rpx;

View File

@ -7,6 +7,7 @@ Page({
* 页面的初始数据 * 页面的初始数据
*/ */
data: { data: {
scrollViewHeight:0,
tabIndex:0, tabIndex:0,
orderList:[], orderList:[],
merchantOrderList:[], merchantOrderList:[],
@ -19,6 +20,15 @@ Page({
merchantOrderStatus:shopApi.merchantOrderStatus, merchantOrderStatus:shopApi.merchantOrderStatus,
merchantOrderStatusKV:shopApi.merchantOrderStatusKV, 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){ changeTab(event){
const tabIndex = event.currentTarget.dataset.index; const tabIndex = event.currentTarget.dataset.index;
@ -32,10 +42,9 @@ Page({
}, },
goToShopDetail(event){ goToShopDetail(event){
const item = event.currentTarget.dataset.item; const item = event.currentTarget.dataset.item;
//缺少 shopid wx.navigateTo({
// wx.navigateTo({ url: `/pages/shop/detail/index?id=${item.merchant_id}`,
// url: `/pages/shop/detail/index?id=${item.id}`, })
// })
}, },
goToCouponDetail(event){ goToCouponDetail(event){
const id = event.currentTarget.dataset.id; const id = event.currentTarget.dataset.id;
@ -63,33 +72,144 @@ Page({
this.loadOrderList(); this.loadOrderList();
this.loadMerchantOrderList(); this.loadMerchantOrderList();
this.loadMerchantPayOrderList(); 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(){ 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<this.data.pager.tab1.limit){
this.data.pager.tab1.loadAll = true;
}
this.setData({ this.setData({
orderList:data.items orderList:this.data.orderList,
refreshTriggered:{
tab1:false
},
pager:this.data.pager
}) })
}); });
}, },
loadMerchantPayOrderList(){ loadMerchantPayOrderList(){
//消费买单列表 //消费买单列表
shopApi.orderList().then((data)=>{ 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<this.data.pager.tab2.limit){
this.data.pager.tab2.loadAll = true;
}
this.setData({ this.setData({
merchantOrderList:data.items merchantOrderList:this.data.merchantOrderList,
refreshTriggered:{
tab2:false
},
pager:this.data.pager
}) })
}) })
}, },
loadMerchantOrderList(){ loadMerchantOrderList(){
//代金券列表 //代金券列表
userApi.order.merchantList().then((data)=>{ 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)=>{ data.map((item)=>{
if(item.product_tags){ if(item.product_tags){
item.product_tags = item.product_tags.split(','); 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<this.data.pager.tab3.limit){
this.data.pager.tab3.loadAll = true;
}
this.setData({ this.setData({
couponList:data couponList:this.data.couponList,
refreshTriggered:{
tab3:false
},
pager:this.data.pager
}) })
}); });
}, },

View File

@ -1,7 +1,8 @@
{ {
"usingComponents": { "usingComponents": {
"nav-bar":"/components/navbar", "nav-bar":"/components/navbar",
"merchant-order":"/components/merchantOrder" "merchant-order":"/components/merchantOrder",
"list-view":"/components/listView"
}, },
"navigationStyle": "custom" "navigationStyle": "custom"
} }

View File

@ -1,4 +1,5 @@
<nav-bar class="nav-bar"/> <nav-bar class="nav-bar"/>
<view class="tab-bar"> <view class="tab-bar">
<view class="item-container {{tabIndex==0?'current':''}}" bind:tap="changeTab" data-index="0"> <view class="item-container {{tabIndex==0?'current':''}}" bind:tap="changeTab" data-index="0">
<view class="item">跑腿服务</view> <view class="item">跑腿服务</view>
@ -10,8 +11,11 @@
<view class="item">代金券</view> <view class="item">代金券</view>
</view> </view>
</view> </view>
<list-view class="order-list" wx:if="{{tabIndex==0}}"
<view class="order-list" wx:if="{{tabIndex==0}}"> bind:refresh="refreshList" bind:loadMore="loadMore" height="{{scrollViewHeight}}"
refresher-triggered="{{refreshTriggered.tab1}}"
load-more-text="仅展示最近一年的订单" show-load-more="{{orderList.length!=0}}"
loading="{{pager.tab1.loading}}" load-all="{{pager.tab1.loadAll}}">
<view class="item" wx:for="{{orderList}}" wx:key="index" bind:tap="goToDetail" data-id="{{item.orderid}}"> <view class="item" wx:for="{{orderList}}" wx:key="index" bind:tap="goToDetail" data-id="{{item.orderid}}">
<view class="head"> <view class="head">
<view class="icon-con"> <view class="icon-con">
@ -35,9 +39,20 @@
</view> </view>
</view> </view>
</view> </view>
</view>
<view class="bill-list" wx:if="{{tabIndex==1}}" wx:for="{{merchantOrderList}}" wx:key="index">
<view class="item"> <view class="list-empty" wx:if="{{orderList.length==0}}">
<image class="icon" src="/assets/icon/order/empty@2x.png"/>
<view class="text">暂无相关订单</view>
</view>
</list-view>
<list-view class="bill-list" wx:if="{{tabIndex==1}}"
bind:refresh="refreshList" bind:loadMore="loadMore" height="{{scrollViewHeight}}"
refresher-triggered="{{refreshTriggered.tab2}}"
load-more-text="仅展示最近一年的订单" show-load-more="{{merchantOrderList.length!=0}}"
loading="{{pager.tab2.loading}}" load-all="{{pager.tab2.loadAll}}">
<view class="item" wx:for="{{merchantOrderList}}" wx:key="index">
<image class="image" src="{{item.merchant_image}}"/> <image class="image" src="{{item.merchant_image}}"/>
<view class="name">{{item.merchant_name}}</view> <view class="name">{{item.merchant_name}}</view>
<view class="amount">-{{item.amount}}</view> <view class="amount">-{{item.amount}}</view>
@ -66,8 +81,18 @@
<view class="value">{{item.order_id}}</view> <view class="value">{{item.order_id}}</view>
</view> </view>
</view> </view>
</view>
<view class="group-list" wx:if="{{tabIndex==2}}"> <view class="list-empty" wx:if="{{merchantOrderList.length==0}}">
<image class="icon" src="/assets/icon/order/empty@2x.png"/>
<view class="text">暂无相关订单</view>
</view>
</list-view>
<list-view class="group-list" wx:if="{{tabIndex==2}}"
bind:refresh="refreshList" bind:loadMore="loadMore" height="{{scrollViewHeight}}"
refresher-triggered="{{refreshTriggered.tab3}}"
load-more-text="仅展示最近一年的订单" show-load-more="{{couponList.length!=0}}"
loading="{{pager.tab3.loading}}" load-all="{{pager.tab3.loadAll}}">
<view class="item" wx:for="{{couponList}}" wx:key="index" bind:tap="goToCouponDetail" data-id="{{item.order_id}}"> <view class="item" wx:for="{{couponList}}" wx:key="index" bind:tap="goToCouponDetail" data-id="{{item.order_id}}">
<view class="head"> <view class="head">
<view class="name" capture-catch:tap="goToShopDetail" data-item="{{item}}"> <view class="name" capture-catch:tap="goToShopDetail" data-item="{{item}}">
@ -90,11 +115,11 @@
<button class="button button2" plain size="mini" wx:if="{{item.status==merchantOrderStatus.unverified}}">查看券码</button> <button class="button button2" plain size="mini" wx:if="{{item.status==merchantOrderStatus.unverified}}">查看券码</button>
</view> </view>
</view> </view>
</view>
<view class="list-empty" wx:if="{{false}}">
<image class="icon" src="/assets/icon/order/empty@2x.png"/>
<view class="text">暂无相关订单</view>
</view>
<view class="list-empty" wx:if="{{couponList.length==0}}">
<image class="icon" src="/assets/icon/order/empty@2x.png"/>
<view class="text">暂无相关订单</view>
</view>
</list-view>
<merchant-order id="merchantOrderConfirm" bind:orderCreated="orderCreated"/> <merchant-order id="merchantOrderConfirm" bind:orderCreated="orderCreated"/>

View File

@ -1,9 +1,6 @@
.nav-bar{ .nav-bar{
background-color: #fff; background-color: #fff;
} }
.order-list{}
.order-list .item{ .order-list .item{
background-color: #fff; background-color: #fff;
border-radius: 18rpx; border-radius: 18rpx;
@ -150,9 +147,6 @@
margin-left: 20rpx; margin-left: 20rpx;
} }
.bill-list{
}
.bill-list .item{ .bill-list .item{
text-align: center; text-align: center;
background-color: #fff; background-color: #fff;

View File

@ -14,7 +14,9 @@ Page({
productList:[], productList:[],
currentProduct:{}, currentProduct:{},
calculatedPrice:{}, calculatedPrice:{},
calculating:false calculating:false,
scrollViewHeight:0,
windowInfo:{}
}, },
showConfirm(event){ showConfirm(event){
@ -28,6 +30,13 @@ Page({
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad(options) { onLoad(options) {
const windowInfo = wx.getWindowInfo();
console.log(windowInfo);
this.setData({
windowInfo:windowInfo,
scrollViewHeight:windowInfo.screenHeight-251-windowInfo.statusBarHeight-53
})
const shopId = options.id; const shopId = options.id;
app.getLocation().then((data)=>{ app.getLocation().then((data)=>{
@ -39,6 +48,7 @@ Page({
data.items.map((item)=>{ data.items.map((item)=>{
item.tags = item.tags.split(',') item.tags = item.tags.split(',')
}) })
data.items = data.items;
this.setData({ this.setData({
productList:data.items productList:data.items
}); });

View File

@ -1,18 +1,3 @@
<!-- <view class="swiper-container">
<swiper class="swiper" >
<swiper-item class="item">
<image class="image" src="/assets/imgs/for_test/1.jpg" mode="aspectFit"/>
</swiper-item>
<swiper-item class="item">
<image class="image" src="/assets/imgs/for_test/2.jpg" mode="aspectFit"/>
</swiper-item>
</swiper>
<view class="nav">
<image src="/assets/icon/shop/image@2x.png" class="icon"/>
<label class="text">1/2</label>
<image src="/assets/icon/shop/right-arrow@2x.png" class="right-arrow"/>
</view>
</view> -->
<nav-bar background="#fff" share back></nav-bar> <nav-bar background="#fff" share back></nav-bar>
<view class="page-container shop-info"> <view class="page-container shop-info">
<view class="head"> <view class="head">
@ -57,23 +42,26 @@
</navigator> </navigator>
</view> </view>
</view> </view>
<view class="page-container item ticket" wx:for="{{productList}}" wx:key="index"> <scroll-view style="height:{{scrollViewHeight*2}}rpx;" scroll-y class="scroll-view">
<view class="left"> <view class="page-container item ticket" wx:for="{{productList}}" wx:key="index">
<view class="promation"> <view class="left">
<image src="/assets/icon/shop/promation@2x.png" class="image"/> <view class="promation">
<label>{{item.promotion_text}}</label> <image src="/assets/icon/shop/promation@2x.png" class="image"/>
<label>{{item.promotion_text}}</label>
</view>
<view class="title">{{item.name}}</view>
<view class="bl-money">
<label class="money">{{item.sale_price}}</label>
<label class="money-disable">{{item.product_price}}</label>
</view>
</view> </view>
<view class="title">{{item.name}}</view> <view class="right">
<view class="bl-money"> <button class="button" size="mini" type="primary" loading="{{item.loading}}"
<label class="money">{{item.sale_price}}</label> bind:tap="showConfirm" data-item="{{item}}">抢购</button>
<label class="money-disable">{{item.product_price}}</label>
</view> </view>
</view> </view>
<view class="right"> <view class="scroll-view-dispatch"></view>
<button class="button" size="mini" type="primary" loading="{{item.loading}}" </scroll-view>
bind:tap="showConfirm" data-item="{{item}}">抢购</button>
</view>
</view>
</view> </view>
<merchant-order id="merchantOrderConfirm"/> <merchant-order id="merchantOrderConfirm"/>

View File

@ -187,4 +187,3 @@
padding:18rpx 46rpx; padding:18rpx 46rpx;
margin-left:40rpx; margin-left:40rpx;
} }

View File

@ -14,16 +14,57 @@ Page({
shopList:[], shopList:[],
userInfo:{}, userInfo:{},
lng:null, lng:null,
lat:null lat:null,
scrollViewHeight:0,
pager:{limit:10,loading:false,loadAll:false,pageIndex:0,refreshTrigger:false}
}, },
changeTab(event){ changeTab(event){
const tabIndex = event.currentTarget.dataset.index; const tabIndex = event.currentTarget.dataset.index;
const cid = event.currentTarget.dataset.cid; const cid = event.currentTarget.dataset.cid;
this.setData({tabIndex}) this.data.pager.pageIndex = 0;
this.loadList(cid); this.data.pager.loadAll = false;
this.setData({tabIndex,pager:this.data.pager})
this.loadList();
}, },
loadList(cid){ refreshList(){
shopApi.list(cid,this.data.lng,this.data.lat).then((data)=>{ 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<this.data.pager.limit){
this.data.pager.loadAll = true;
}
data.items.map((item)=>{ data.items.map((item)=>{
if(item.distance){ if(item.distance){
if(item.distance>=1000){ if(item.distance>=1000){
@ -34,7 +75,8 @@ Page({
} }
}) })
this.setData({ this.setData({
shopList:data.items shopList:this.data.shopList,
pager:this.data.pager
}) })
}); });
}, },
@ -42,6 +84,10 @@ Page({
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad(options) { onLoad(options) {
const windowInfo = wx.getWindowInfo();
this.setData({
scrollViewHeight:windowInfo.windowHeight-windowInfo.statusBarHeight-44-174
})
app.getLocation().then((data)=>{ app.getLocation().then((data)=>{
this.setData({ this.setData({
lng:data.longitude, lng:data.longitude,

View File

@ -1,7 +1,8 @@
{ {
"usingComponents": { "usingComponents": {
"nav-bar":"/components/navbar", "nav-bar":"/components/navbar",
"shop-item":"/components/shopItem" "shop-item":"/components/shopItem",
"list-view":"/components/listView"
}, },
"navigationStyle": "custom" "navigationStyle": "custom"
} }

View File

@ -12,13 +12,15 @@
</button> </button>
</view> </view>
<view class="shop-list"> <list-view class="shop-list" bind:refresh="refreshList"
<block wx:if="{{shopList.length>0}}"> bind:loadMore="loadList" height="{{scrollViewHeight}}"
<shop-item wx:for="{{shopList}}" shop="{{item}}" data-item="{{item}}" wx:key="index"> refresher-triggered="{{pager.refreshTrigger}}"
show-load-more="{{!(shopList.length==0&&pager.loadAll)}}"
loading="{{pager.loading}}" load-all="{{pager.loadAll}}">
<shop-item wx:for="{{shopList}}" shop="{{item}}" data-item="{{item}}" wx:key="index">
</shop-item> </shop-item>
</block> <view class="list-empty" wx:if="{{shopList.length==0&&pager.loadAll}}">
<view class="list-empty" wx:else>
<view class="title">暂无该分类商铺</view> <view class="title">暂无该分类商铺</view>
</view> </view>
</view> </list-view>