Commit e9cffd77 by biao

11

parent 55be83bd
...@@ -30,7 +30,7 @@ if(empty($userList)) { ...@@ -30,7 +30,7 @@ if(empty($userList)) {
$userId = $userList[0]->id; $userId = $userList[0]->id;
//获取用户消息列表 //获取用户消息列表
$rowCount = 10; $rowCount = 15;
$offset = $page * $rowCount; $offset = $page * $rowCount;
$param = array(); $param = array();
...@@ -42,14 +42,15 @@ if($readFlg == 2) { ...@@ -42,14 +42,15 @@ if($readFlg == 2) {
$param['is_read'] = true; $param['is_read'] = true;
} }
$param['delete_flg'] = false; $param['delete_flg'] = false;
$userMessageList = UserMessageDat::getList($param,'id','desc', $offset, $rowCount); $messageList = UserMessageDat::getList($param,'id','desc', $offset, $rowCount);
$allCount = UserMessageDat::getListCount($param); $allCount = UserMessageDat::getListCount($param);
$pageCount = ceil($allCount/$rowCount);
//接口返回数据 //接口返回数据
$result["allCount"] = $allCount; $result["pageCount"] = $pageCount;
$result["page"] = $page; $result["page"] = $page;
$result["rowCount"] = $rowCount; $result["rowCount"] = $rowCount;
$result["list"] = $userMessageList; $result["messageList"] = $messageList;
ErrorLogger::doOutput("Compass...ajax_get_user_message.php....End.", 0); ErrorLogger::doOutput("Compass...ajax_get_user_message.php....End.", 0);
......
...@@ -5,6 +5,7 @@ App({ ...@@ -5,6 +5,7 @@ App({
this.checkUser(); this.checkUser();
var config = wx.getStorageSync('config'); var config = wx.getStorageSync('config');
var that = this; var that = this;
//获取用户的经纬度信息
wx.getLocation({ wx.getLocation({
type: 'wgs84', type: 'wgs84',
success: function (res) { success: function (res) {
......
...@@ -6,86 +6,87 @@ Page({ ...@@ -6,86 +6,87 @@ Page({
* 页面的初始数据 * 页面的初始数据
*/ */
data: { data: {
list:[] page:0,
pageCount:0,
messageList:[]
}, },
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad: function (options) { onLoad: function (options) {
var that=this; this.getNewsList();
var config = wx.getStorageSync('config');
wx:wx.request({
url: app.url +'ajax_get_user_message.php',
header: { 'content-type': 'application/json'},
data:{
unionId: config.unionId,
page:0
},
method: 'GET',
dataType: 'json',
success: function(res) {
console.log(res.data)
if(res.statusCode==200){
that.setData({
list:res.data.result.list
})
}
},
fail: function(res) {},
complete: function(res) {},
})
}, },
/** /**
* 生命周期函数--监听页面初次渲染完成 * 生命周期函数--监听页面初次渲染完成
*/ */
onReady: function () { onReady: function () {
}, },
/** /**
* 生命周期函数--监听页面显示 * 生命周期函数--监听页面显示
*/ */
onShow: function () { onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
}, },
/** /**
* 页面上拉触底事件的处理函数 * 页面上拉触底事件的处理函数
*/ */
onReachBottom: function () { onReachBottom: function () {
//触底以后加载更多
if ((this.data.page+1) < this.data.pageCount) {
var pageIndex = this.data.page + 1
this.setData({
page: pageIndex
})
this.getNewsList();
} else {
wx.showToast({
title: '没有更多消息啦。',
icon: 'success',
duration: 2000
});
}
}, },
/** /**
* 用户点击右上角分享 * 用户点击右上角分享
*/ */
onShareAppMessage: function () { onShareAppMessage: function () {
},
//获取用户消息列表
getNewsList() {
var that = this;
var config = wx.getStorageSync('config');
//获取用户消息列表
wx.request({
url: app.url + 'ajax_get_user_message.php',
header: { 'content-type': 'application/json' },
data: {
unionId: config.unionId,
page: that.data.page,
readFlg: 0,
}, },
myNewsDetail(){ method: 'GET',
dataType: 'json',
success: function (res) {
console.log(res.data)
if (res.statusCode == 200) {
that.setData({
pageCount: res.data.result.pageCount,
messageList: that.data.messageList.concat(res.data.result.messageList)
})
}
},
fail: function (res) { },
complete: function (res) { },
})
},
//消息详细页面
newsDetail(e){
wx.navigateTo({ wx.navigateTo({
url: '../myNewsDetail/myNewsDetail', url: '../myNewsDetail/myNewsDetail',
}) })
......
{ {
"usingComponents": {} "usingComponents": {},
"onReachBottomDistance":100
} }
\ No newline at end of file
<!--pages/myNews/myNews.wxml--> <!--pages/myNews/myNews.wxml-->
<view class='myNews'> <view class="myNews">
<view bindtap='myNewsDetail' wx:for="{{list}}" wx:key="{{index}}">{{item.title}}</view> <view bindtap='newsDetail' wx:for="{{messageList}}" wx:if="{{!item.is_read}}" class="newsUnread" data-index="{{item.id}}">
</view> {{item.title}}
</view>
<view bindtap='newsDetail' wx:for="{{messageList}}" wx:if="{{item.is_read}}" class="newsReaded" data-index="{{item.id}}">
{{item.title}}
</view>
</view>
/* pages/myNews/myNews.wxss */ /* pages/myNews/myNews.wxss */
.myNews>view{ .myNews{
margin: 10px auto; margin: 1%;
box-sizing: border-box; width:98%;
white-space:nowrap;
padding: 10px; padding: 10px;
} }
.newsUnread{
height:35px;
line-height: 35px;
padding: 2px;
font-weight: bold;
border-bottom: 1rpx solid #F0F0F0;
}
.newsReaded{
height:35px;
line-height: 35px;
padding: 2px;
font-weight: normal;
border-bottom: 1rpx solid #F0F0F0;
}
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
"compileType": "miniprogram", "compileType": "miniprogram",
"libVersion": "2.10.0", "libVersion": "2.10.0",
"appid": "wxeef50c5d0ef117d1", "appid": "wxeef50c5d0ef117d1",
"projectname": "zhiNanZhen", "projectname": "Compass",
"debugOptions": { "debugOptions": {
"hidedInDevtools": [] "hidedInDevtools": []
}, },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment