服务端:
public log4net.ILog logInfo = WxV3.Helper.LogHelper.GetInstance().Log;
public void ProcessRequest(HttpContext context)
{
context.Response.Clear();
StreamReader reader = new StreamReader(context.Request.InputStream);
//首次加载
if (context.Request.Form["types"] == "Back2019")
{
context.Response.Write(Back2019());
}
//触底加载
if (context.Request.Form["types"] == "Back2019_1")
{
context.Response.Write(Back2019_1(Convert.ToInt32(context.Request.Form["xiayige"])));
}
context.Response.End();
}
/// <summary>
/// 首页 免费领
/// </summary>
/// <returns></returns>
public string Back2019()
{
BLL.Back2019Manager Back2019_bll = new BLL.Back2019Manager();
List<Model.Back2019> Back2019_list1 = new List<Model.Back2019>();
Back2019_list1 = Back2019_bll.Query_Back2019(" top 10 * ", " and language='China' ", " order by id desc");
List<xiangxizehe> xiangxizehe_List = new List<xiangxizehe>();
if (Back2019_list1.Count > 0)
{
foreach (var BiJi in Back2019_list1)
{
xiangxizehe zh = new xiangxizehe();
zh.id = BiJi.id;//编号
zh.guid = BiJi.guid;//Guid
zh.title = System.Web.HttpUtility.UrlDecode(BiJi.title, System.Text.Encoding.UTF8);//标题
zh.shortcontent = BiJi.shortcontent;//短介绍
zh.content =System.Web.HttpUtility.UrlDecode(BiJi.content, System.Text.Encoding.UTF8);//内容
zh.language = BiJi.language;//语言版本
zh.hot = BiJi.hot;//置顶
zh.grade = BiJi.grade;//排序
zh.img1 = BiJi.img1;//图片小
zh.img1a = BiJi.img1a;//图片大
zh.recommend = BiJi.recommend;//是否推荐
zh.state = BiJi.state;//状态
zh.typeid = BiJi.typeid;//父类
zh.clickcount = BiJi.clickcount;//点击数
zh.author = BiJi.author;//作者
zh.source = BiJi.source;//来源
zh.addTime = BiJi.addTime.ToString();//时间
zh.field1 = BiJi.field1;//库存
zh.field2 = BiJi.field2;//价值
zh.field3 = BiJi.field3;//领取
zh.field4 = BiJi.field4;//
zh.field5 = BiJi.field5;//
zh.field6 = BiJi.field6;
zh.field7 = BiJi.field7;
zh.field8 = BiJi.field8;
zh.field9 = BiJi.field9;
zh.field10 = BiJi.field10;
zh.field11 = BiJi.field11;
zh.field12 = BiJi.field12;
zh.field13 = BiJi.field13;
zh.field14 = BiJi.field14;
zh.field15 = BiJi.field15;
zh.field16 = BiJi.field16;
zh.field17 = BiJi.field17;
zh.field18 = BiJi.field18;
zh.field19 = BiJi.field19;
BLL.Back2019CommentManager Back2019Comment_bll = new BLL.Back2019CommentManager();
int c = Back2019Comment_bll.Query_Back2019Comment(" and typeid=" + BiJi.id);
zh.liuyan = c;
xiangxizehe_List.Add(zh);
}
}
JavaScriptSerializer jss = new JavaScriptSerializer();
return jss.Serialize(xiangxizehe_List);
}
/// <summary>
/// 首页 免费领
/// </summary>
/// <returns></returns>
public string Back2019_1(int xiayige)
{
BLL.Back2019Manager Back2019_bll = new BLL.Back2019Manager();
List<Model.Back2019> Back2019_list1 = new List<Model.Back2019>();
int count = 10;
int stop = (xiayige - 1) * count;
Back2019_list1 = Back2019_bll.Query_Back2019(" top " + count + " * ", " and language='China' and id not in(select top " + stop + " id from [tb_Back2019] order by id desc) ", " order by id desc");
List<xiangxizehe> xiangxizehe_List = new List<xiangxizehe>();
if (Back2019_list1.Count > 0)
{
foreach (var BiJi in Back2019_list1)
{
xiangxizehe zh = new xiangxizehe();
zh.id = BiJi.id;//编号
zh.guid = BiJi.guid;//Guid
zh.title = System.Web.HttpUtility.UrlDecode(BiJi.title, System.Text.Encoding.UTF8);//标题
zh.shortcontent = BiJi.shortcontent;//短介绍
zh.content = System.Web.HttpUtility.UrlDecode(BiJi.content, System.Text.Encoding.UTF8);//内容
zh.language = BiJi.language;//语言版本
zh.hot = BiJi.hot;//置顶
zh.grade = BiJi.grade;//排序
zh.img1 = BiJi.img1;//图片小
zh.img1a = BiJi.img1a;//图片大
zh.recommend = BiJi.recommend;//是否推荐
zh.state = BiJi.state;//状态
zh.typeid = BiJi.typeid;//父类
zh.clickcount = BiJi.clickcount;//点击数
zh.author = BiJi.author;//作者
zh.source = BiJi.source;//来源
zh.addTime = BiJi.addTime.ToString();//时间
zh.field1 = BiJi.field1;//库存
zh.field2 = BiJi.field2;//价值
zh.field3 = BiJi.field3;//领取
zh.field4 = BiJi.field4;//
zh.field5 = BiJi.field5;//
zh.field6 = BiJi.field6;
zh.field7 = BiJi.field7;
zh.field8 = BiJi.field8;
zh.field9 = BiJi.field9;
zh.field10 = BiJi.field10;
zh.field11 = BiJi.field11;
zh.field12 = BiJi.field12;
zh.field13 = BiJi.field13;
zh.field14 = BiJi.field14;
zh.field15 = BiJi.field15;
zh.field16 = BiJi.field16;
zh.field17 = BiJi.field17;
zh.field18 = BiJi.field18;
zh.field19 = BiJi.field19;
BLL.Back2019CommentManager Back2019Comment_bll = new BLL.Back2019CommentManager();
int c = Back2019Comment_bll.Query_Back2019Comment(" and typeid=" + BiJi.id);
zh.liuyan = c;
xiangxizehe_List.Add(zh);
}
}
JavaScriptSerializer jss = new JavaScriptSerializer();
return jss.Serialize(xiangxizehe_List);
}
public class xiangxizehe
{
public int id { get; set; }//编号
public string guid { get; set; }//Guid
public string title { get; set; }//标题
public string shortcontent { get; set; }//短介绍
public string content { get; set; }//内容
public string language { get; set; }//语言版本
public int hot { get; set; }//置顶
public int grade { get; set; }//排序
public string img1 { get; set; }//图片小
public string img1a { get; set; }//图片大
public int recommend { get; set; }//是否推荐
public int state { get; set; }//状态
public int typeid { get; set; }//父类
public int clickcount { get; set; }//点击数
public string author { get; set; }//作者
public string source { get; set; }//来源
public string addTime { get; set; }//时间
public int field1 { get; set; }//库存
public string field2 { get; set; }//价值
public string field3 { get; set; }//领取
public string field4 { get; set; }//
public string field5 { get; set; }//
public string field6 { get; set; }
public string field7 { get; set; }
public string field8 { get; set; }
public string field9 { get; set; }
public string field10 { get; set; }
public string field11 { get; set; }
public string field12 { get; set; }
public string field13 { get; set; }
public string field14 { get; set; }
public string field15 { get; set; }
public string field16 { get; set; }
public string field17 { get; set; }
public string field18 { get; set; }
public string field19 { get; set; }
public int liuyan { get; set; }
}
小程序端:
/**
* 页面的初始数据
*/
data: {
count: 2,meiyou: false,
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
var that = this;
console.log(that.data.meiyou);
if (!that.data.meiyou) {
wx.request({
url: 'https://*****/WX_Back2019.ashx',
method: 'post',
data: {
types: "Back2019_1",
xiayige: that.data.count,
openId: wx.getStorageSync('openId'), //wx.getStorageSync('openId')
},
header: {
'content-type': 'application/x-www-form-urlencoded'
},
success: function (res) {
console.log(res.data);
if (res.data.length > 0) {
var listTem = that.data.Back2019_list;
that.setData({
Back2019_list: listTem.concat(res.data),
count: that.data.count + 1
});
} else {
that.setData({
meiyou: true,
});
wx.showToast({
title: '没有了~~',
duration: 2000
});
}
},
fail: function (e) {
console.log(e);
//wx.showToast({
// title: '网络异常!',
// duration: 2000
//});
},
complete: function () {
}
});
}
},