上拉刷新更多。类似分页操作。你从小程序传入分页参数到接口,让接口来处理就ok,我给你贴一段代码。[public static List<near_business_couponModel> Get_Near_Business_Coupon(string sh_name, double longitude, double latitude, int pageindex, int pagesize)
{
//附近优惠商家
var sql = @"select a.wid,
b.busiName as business_name,
b.Address as business_adr,
isnull(b.headerpic,'') as headerpic,
isnull(b.latitude,0) as latitude,
isnull(b.longitude,0) as longitude,
dbo.fnGetDistance(" + latitude + "," + longitude + @",b.latitude,b.longitude) as range_line
from wx_yyhz_yh_relation a
left join wx_userweixin b on a.wid=b.id
left join wx_yyhz_yh_coupon c on a.coupon_guid=c.guid
where a.isclose=0 and c.isdelete=0 and b.isdelete=0
and c.coupon_close=0 --0正常发放 1优惠券暂停发放
and (CONVERT(varchar(10),c.coupon_starttime,120)<= CONVERT(varchar(10),GETDATE(),120)
and CONVERT(varchar(10),c.coupon_endtime,120)>= CONVERT(varchar(10),GETDATE(),120))
group by a.wid,
b.busiName,
b.Address,
b.headerpic,
b.latitude,b.longitude";
using (MAction action = new MAction(sql))
{
List<near_business_couponModel> listmode = new List<near_business_couponModel>();
if (!string.IsNullOrEmpty(sh_name))
{
listmode = action.Select(pageindex, pagesize, "charindex('" + sh_name + "',business_name)>0 order by range_line asc,business_name asc ").ToList<near_business_couponModel>();
}
else
{
listmode = action.Select(pageindex, pagesize, " order by range_line asc,business_name asc ").ToList<near_business_couponModel>();
}
foreach (var nearBusinessCouponModel in listmode)
{
// 显示距离
nearBusinessCouponModel.range_line = MapHelper.GetDistance(nearBusinessCouponModel.latitude, nearBusinessCouponModel.longitude, latitude, longitude);
//获取该店最新优惠券
var top1sql = @"select top 1 coupon_name from wx_yyhz_yh_coupon
where coupon_wid='" + nearBusinessCouponModel.wid + @"'
and isdelete = 0
and (CONVERT(varchar(10),coupon_starttime,120)<= CONVERT(varchar(10),GETDATE(),120)
and CONVERT(varchar(10),coupon_endtime,120)>= CONVERT(varchar(10),GETDATE(),120))
order by coupon_sendtime desc";
action.ResetTable(top1sql);
var dt = action.Select().ToDataTable();
if (dt.Rows.Count > 0)
{
//最新优惠券名称
nearBusinessCouponModel.coupon_name = dt.Rows[0]["coupon_name"].ToString();
}
else
{
nearBusinessCouponModel.coupon_name = "";
}