Commit fcea69eb by jscat

nyx: discover发现模块

同步更新发现模块的功能,包括
1. discover.wxml页面的数据载入和category切换
2. note-info.wxml页面的数据载入
3. tbl_post添加新的测试数据
parent dbf780cc
USE rockwell_key; USE rockwell_key;
...@@ -21,6 +21,15 @@ CREATE TABLE tbl_post ( ...@@ -21,6 +21,15 @@ CREATE TABLE tbl_post (
INSERT INTO `tbl_post`(`post_id`, `tag`, `title`, `num_like`, `note_image`, `content`, `user_id`, `create_datetime`,`update_datetime`) INSERT INTO `tbl_post`(`post_id`, `tag`, `title`, `num_like`, `note_image`, `content`, `user_id`, `create_datetime`,`update_datetime`)
VALUES VALUES
('pid_001', '复工,饮事', '便携香水加香一天', '10','https://img.xiaohongshu.com/items/c1a0056ba9ba17b30446a0e040dc9e30@800w_90Q_1x_2o.jpg::https://img.xiaohongshu.com/items/c1a0056ba9ba17b30446a0e040dc9e30@800w_90Q_1x_2o.jpg', '在欧洲国家中,目前意大利的新冠肺炎疫情形势最为严峻。截至当地时间21日18时,意大利累计确诊病例达到53578例,累计死亡病例达4825例。旅意侨胞和留学生如何保证安全?回国还是不回国?大使馆能提供哪些帮助?今天下午(北京时间3月22日17时),中国驻意大利大使李军华同旅意侨胞、留学生代表一起在线交流。', 'uid_5b443d4a-3575-452c-93f0-2df6569a4274', '2019-11-20 11:24:45', '2019-11-20 11:24:45'), ('pid_001', '复工,饮事', '便携香水加香一天', '10','https://img.xiaohongshu.com/items/c1a0056ba9ba17b30446a0e040dc9e30@800w_90Q_1x_2o.jpg::https://img.xiaohongshu.com/items/c1a0056ba9ba17b30446a0e040dc9e30@800w_90Q_1x_2o.jpg', '在欧洲国家中,目前意大利的新冠肺炎疫情形势最为严峻。截至当地时间21日18时,意大利累计确诊病例达到53578例,累计死亡病例达4825例。旅意侨胞和留学生如何保证安全?回国还是不回国?大使馆能提供哪些帮助?今天下午(北京时间3月22日17时),中国驻意大利大使李军华同旅意侨胞、留学生代表一起在线交流。', 'uid_5b443d4a-3575-452c-93f0-2df6569a4274', '2020-03-27 11:24:45', '2020-03-27 11:24:45'),
('pid_002', '酒单', '精酿五小杯', '10','https://img.xiaohongshu.com/items/c1a0056ba9ba17b30446a0e040dc9e30@800w_90Q_1x_2o.jpg', '最好的精酿五小杯','uid_bff21c9a-6e0e-4181-b5ab-baf32e27eeb3', '2019-11-20 11:24:45', '2019-11-20 11:24:45') ('pid_002', '酒单', '酒单-精酿五小杯', '10','https://img.xiaohongshu.com/items/c1a0056ba9ba17b30446a0e040dc9e30@800w_90Q_1x_2o.jpg', '最好的精酿五小杯','uid_bff21c9a-6e0e-4181-b5ab-baf32e27eeb3', '2020-03-27 11:24:45', '2020-03-27 11:24:45'),
('pid_003', '复工', '复工-精酿五小杯', '10','https://img.xiaohongshu.com/items/c1a0056ba9ba17b30446a0e040dc9e30@800w_90Q_1x_2o.jpg', '最好的精酿五小杯','uid_bff21c9a-6e0e-4181-b5ab-baf32e27eeb3', '2020-03-27 11:24:45', '2020-03-27 11:24:45'),
('pid_004', '心情', '心情-精酿五小杯', '10','https://img.xiaohongshu.com/items/c1a0056ba9ba17b30446a0e040dc9e30@800w_90Q_1x_2o.jpg', '最好的精酿五小杯','uid_bff21c9a-6e0e-4181-b5ab-baf32e27eeb3', '2020-03-27 11:24:45', '2020-03-27 11:24:45'),
('pid_005', '音乐', '音乐-精酿五小杯', '10','https://img.xiaohongshu.com/items/c1a0056ba9ba17b30446a0e040dc9e30@800w_90Q_1x_2o.jpg', '最好的精酿五小杯','uid_bff21c9a-6e0e-4181-b5ab-baf32e27eeb3', '2020-03-27 11:24:45', '2020-03-27 11:24:45'),
('pid_006', '饮事', '饮事-精酿五小杯', '10','https://img.xiaohongshu.com/items/c1a0056ba9ba17b30446a0e040dc9e30@800w_90Q_1x_2o.jpg', '最好的精酿五小杯','uid_bff21c9a-6e0e-4181-b5ab-baf32e27eeb3', '2020-03-27 11:24:45', '2020-03-27 11:24:45'),
('pid_007', '饮事', '饮事-精酿五小杯', '10','https://img.xiaohongshu.com/items/c1a0056ba9ba17b30446a0e040dc9e30@800w_90Q_1x_2o.jpg', '最好的精酿五小杯','uid_bff21c9a-6e0e-4181-b5ab-baf32e27eeb3', '2020-03-27 11:24:45', '2020-03-27 11:24:45'),
('pid_008', '心情', '心情-精酿五小杯', '10','https://img.xiaohongshu.com/items/c1a0056ba9ba17b30446a0e040dc9e30@800w_90Q_1x_2o.jpg', '最好的精酿五小杯','uid_bff21c9a-6e0e-4181-b5ab-baf32e27eeb3', '2020-03-27 11:24:45', '2020-03-27 11:24:45'),
('pid_009', '心情', '心情-精酿五小杯', '10','https://img.xiaohongshu.com/items/c1a0056ba9ba17b30446a0e040dc9e30@800w_90Q_1x_2o.jpg', '最好的精酿五小杯','uid_bff21c9a-6e0e-4181-b5ab-baf32e27eeb3', '2020-03-27 11:24:45', '2020-03-27 11:24:45'),
('pid_010', '心情', '心情-精酿五小杯', '10','https://img.xiaohongshu.com/items/c1a0056ba9ba17b30446a0e040dc9e30@800w_90Q_1x_2o.jpg', '最好的精酿五小杯','uid_bff21c9a-6e0e-4181-b5ab-baf32e27eeb3', '2020-03-27 11:24:45', '2020-03-27 11:24:45'),
('pid_011', '心情', '心情-精酿五小杯', '10','https://img.xiaohongshu.com/items/c1a0056ba9ba17b30446a0e040dc9e30@800w_90Q_1x_2o.jpg', '最好的精酿五小杯','uid_bff21c9a-6e0e-4181-b5ab-baf32e27eeb3', '2020-03-27 11:24:45', '2020-03-27 11:24:45')
; ;
\ No newline at end of file
//config.js API全局域名配置 //config.js API全局域名配置
//config.js API全局域名配置 //config.js API全局域名配置
var prod = 0; var prod = 0;
var local = 0; var local = 1;
var test = 1; var test = 0;
var debug = 0; //是否打印调试信息 var debug = 0; //是否打印调试信息
var host_key = "https://fun.hisuhong.com"; var host_key = "https://fun.hisuhong.com";
...@@ -47,7 +47,7 @@ var config={ ...@@ -47,7 +47,7 @@ var config={
match_add_item_url: host_key + "/api/nyx/match/add/item", match_add_item_url: host_key + "/api/nyx/match/add/item",
user_reg_url: host_key + "/api/nyx/user/reg", user_reg_url: host_key + "/api/nyx/user/reg",
userinfo_query_url: host_key + "/api/nyx/userinfo/query", userinfo_query_url: host_key + "/api/nyx/userinfo/query",
notes_query_url: host_key + "/api/nyx/notes/query", notes_query_url: host_key + "/api/nyx/post/query",
socket_url: socket_url, socket_url: socket_url,
} }
module.exports=config; module.exports=config;
\ No newline at end of file
// pages/kinds/kinds.js // pages/kinds/kinds.js
...@@ -9,54 +9,62 @@ Page({ ...@@ -9,54 +9,62 @@ Page({
*/ */
data: { data: {
category: [ // 导航栏内容数据 category: [ // 导航栏内容数据
{ name: '推荐', id: 'tuijian' }, { name: '推荐', id: 'top' },
{ name: '复工', id: 'fugong' }, { name: '复工', id: 'fugong' },
{ name: '心情', id: 'xinqing' },
{ name: '酒单', id: 'jiudan' }, { name: '酒单', id: 'jiudan' },
{ name: '音乐', id: 'yinyue' }, { name: '音乐', id: 'yinyue' },
{ name: '饮事', id: 'yinshi' }, { name: '饮事', id: 'yinshi' },
], ],
curIndex: 0, // 给选中的tab加粗 curIndex: 0, // 给选中的tab加粗
notes: [ notes: [
{ // {
note_image: [ "https://img.xiaohongshu.com/items/c1a0056ba9ba17b30446a0e040dc9e30@800w_90Q_1x_2o.jpg", // note_image: [ "https://img.xiaohongshu.com/items/c1a0056ba9ba17b30446a0e040dc9e30@800w_90Q_1x_2o.jpg",
"https://img.xiaohongshu.com/items/c1a0056ba9ba17b30446a0e040dc9e30@800w_90Q_1x_2o.jpg", // "https://img.xiaohongshu.com/items/c1a0056ba9ba17b30446a0e040dc9e30@800w_90Q_1x_2o.jpg",
], // ],
title: "便携香水加香一天", // title: "便携香水加香一天",
like: 10, // like: 10,
writer_name: "无敌花木兰", // writer_name: "无敌花木兰",
writer_image: "../../icon/icon_avatar3.png" // writer_image: "../../icon/icon_avatar3.png"
}, // },
{ // {
note_image: [ "https://img.xiaohongshu.com/items/c1a0056ba9ba17b30446a0e040dc9e30@800w_90Q_1x_2o.jpg", // note_image: [ "https://img.xiaohongshu.com/items/c1a0056ba9ba17b30446a0e040dc9e30@800w_90Q_1x_2o.jpg",
], // ],
title: "便携香水加香一天", // title: "便携香水加香一天",
like: 10, // like: 10,
writer_name: "无敌花木兰", // writer_name: "无敌花木兰",
writer_image: "../../icon/icon_avatar3.png" // writer_image: "../../icon/icon_avatar3.png"
}, // },
{ // {
note_image: ["https://img.xiaohongshu.com/items/c1a0056ba9ba17b30446a0e040dc9e30@800w_90Q_1x_2o.jpg", // note_image: ["https://img.xiaohongshu.com/items/c1a0056ba9ba17b30446a0e040dc9e30@800w_90Q_1x_2o.jpg",
], // ],
title: "便携香水加香一天", // title: "便携香水加香一天",
like: 10, // like: 10,
writer_name: "无敌花木兰", // writer_name: "无敌花木兰",
writer_image: "../../icon/icon_avatar3.png" // writer_image: "../../icon/icon_avatar3.png"
}, // },
{ // {
note_image: ["https://img.xiaohongshu.com/items/c1a0056ba9ba17b30446a0e040dc9e30@800w_90Q_1x_2o.jpg", // note_image: ["https://img.xiaohongshu.com/items/c1a0056ba9ba17b30446a0e040dc9e30@800w_90Q_1x_2o.jpg",
], // ],
title: "便携香水加香一天", // title: "便携香水加香一天",
like: 10, // like: 10,
writer_name: "无敌花木兰", // writer_name: "无敌花木兰",
writer_image: "../../icon/icon_avatar3.png" // writer_image: "../../icon/icon_avatar3.png"
}, // },
], ],
//分页加载部分
isHideLoadMore: false,
pageIndex: 1, //分页搜索的page index
}, },
switchCategory(e) { switchCategory(e) {
var _this = this;
var curIndex = e.currentTarget.dataset.index ? e.currentTarget.dataset.index : 0
this.setData({ this.setData({
curIndex: e.currentTarget.dataset.index?e.currentTarget.dataset.index:0, curIndex: curIndex,
}) })
_this.getNotes(0, 1, 4, curIndex);
}, },
// 搜索点击事件 // 搜索点击事件
entrySearch(e) { entrySearch(e) {
...@@ -75,11 +83,11 @@ Page({ ...@@ -75,11 +83,11 @@ Page({
}) })
//初始载入四个推荐notes //初始载入四个推荐notes
if(_this.__data.notes.length == 0) if(_this.__data__.notes.length == 0)
{ {
//getNotes(strCategory) //getNotes(strCategory)
var strCategory = _this.__data__.category[curIndex].name var curIndex = _this.__data__.curIndex
_this.getNotes(strCategory); _this.getNotes(0, 1, 4, curIndex);
} }
}, },
...@@ -124,26 +132,20 @@ Page({ ...@@ -124,26 +132,20 @@ Page({
*/ */
onReachBottom: function () { onReachBottom: function () {
console.log('页面上拉触底') console.log('页面上拉触底')
var _that = this; var _this = this;
var isHideLoadMore = _that.__data__.isHideLoadMore; var curIndex = _this.__data__.curIndex
var pageIndex = _that.__data__.pageIndex; var isHideLoadMore = _this.__data__.isHideLoadMore;
var strSearchName = _that.__data__.strSearchName; var pageIndex = _this.__data__.pageIndex;
//控制逻辑, 在onClick之后或者onGetComment事件之后再允许下拉更新操作
//判断是否已经全部加载完毕 //判断是否已经全部加载完毕
//没有则加载更多 //没有则加载更多
if (!isHideLoadMore) { if (!isHideLoadMore) {
console.log('加载更多') console.log('加载更多')
//如果是全部搜索状态 setTimeout(() => {
if (strSearchName.length > 0) { _this.getNotes(1, pageIndex, 4, curIndex);
setTimeout(() => { }, 1000)
_that.getBookGlobal(1, strSearchName, pageIndex, 4);
}, 1000)
}
else {
setTimeout(() => {
_that.getBook(1, pageIndex, 4);
}, 1000)
}
} }
else { else {
console.log('没有更多') console.log('没有更多')
...@@ -162,11 +164,16 @@ Page({ ...@@ -162,11 +164,16 @@ Page({
* *
*/ */
// 获取notes数据 // 获取notes数据
getNotes: function (strCategory) { // scrollType: 是否是翻页
getNotes: function (scrollType,pageNum, pageCount, curIndex) {
var _this = this; var _this = this;
config.debug == 1 ? console.log("===getNotes strCategory is: \"" + strCategory + "\"") : "" var strCategory = _this.__data__.category[curIndex].name
var query_url = strCategory == "推荐" ? '&top=1' : '&tag=' + strCategory
var strUrl = config.notes_query_url + "?pageCount=" + pageCount
+ "&pageNum=" + pageNum + query_url
config.debug == 1 ? console.log("===strUrl is: \"" + strUrl + "\"") : ""
wx.request({ wx.request({
url: config.notes_query_url + '?tag=' + strCategory, url: strUrl,
method: 'GET', method: 'GET',
header: { header: {
'Cookie': wx.getStorageSync('cookieKey'), 'Cookie': wx.getStorageSync('cookieKey'),
...@@ -174,15 +181,32 @@ Page({ ...@@ -174,15 +181,32 @@ Page({
success: function (res) { success: function (res) {
if (res.data.resultCode == 200) { if (res.data.resultCode == 200) {
//表示HTTP请求成功 //表示HTTP请求成功
console.log(res.data); console.log(res.data);
var result = res.data.data var list = []
var bisHideLoadMoreType = false;
for (var j = 0; j < result.length; j++) { if (res.data.data.length < pageCount) {
var list = result[i].note_image.split("::") bisHideLoadMoreType = true;
result[i]["note_image"] = list }
for (var i = 0; i < res.data.data.length; i++) {
var result = {}
result["note_image"] = res.data.data[i].noteImage.split("::")
result["title"] = res.data.data[i].title
result["tag"] = res.data.data[i].tag
result["content"] = res.data.data[i].content
result["like"] = res.data.data[i].numLike
result["writer_name"] = res.data.data[i].nickName
result["writer_image"] = res.data.data[i].avatarUrl
list.push(result)
}
//进行翻页设置(加载更多)
if (scrollType == 1) {
var notesList = _this.__data__.notes;
list = notesList.concat(list)
} }
_this.setData({ _this.setData({
notes: result, notes: list,
pageIndex: pageNum + 1,
isHideLoadMore: bisHideLoadMoreType,
}) })
} }
} }
......
<view class="page"> <view class="page">
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
<!-- 文章封面内容 --> <!-- 文章封面内容 -->
<view class="notes-block" wx:for="{{notes}}" wx:for-item="item" wx:key="{{index}}"> <view class="notes-block" wx:for="{{notes}}" wx:for-item="item" wx:key="{{index}}">
<view class="note-info"> <view class="note-info">
<navigator url="../discover/note-info/note-info?bookId={{item.bookId}}&channelId={{item.channelId}}&imgUrl={{item.imgUrl}}&channelType={{item.channelType}}&channelName={{item.channelName}}" > <navigator url="../discover/note-info/note-info?title={{item.title}}&content={{item.content}}&like={{item.like}}&note_image={{item.note_image}}&writer_name={{item.writer_name}}&writer_image={{item.writer_image}}" >
<view class="home-note-img"> <view class="home-note-img">
<image src="{{item.note_image[0]}}"/> <image src="{{item.note_image[0]}}"/>
</view> </view>
......
// pages/index/note-info/note-info.js // pages/index/note-info/note-info.js
...@@ -11,20 +11,7 @@ Page({ ...@@ -11,20 +11,7 @@ Page({
contentHeight: "", contentHeight: "",
scrollLeft: 0, //切换栏的滚动条位置 scrollLeft: 0, //切换栏的滚动条位置
curIndex : 0, curIndex : 0,
notes: notes: {},
{
note_image: [
"https://img.xiaohongshu.com/items/c1a0056ba9ba17b30446a0e040dc9e30@800w_90Q_1x_2o.jpg",
"https://www.youmeitu.com/Upload/20200122/1579681098726876.jpg",
"https://www.youmeitu.com/Upload/20200302/1583123627387901.jpg",
"https://www.youmeitu.com/Upload/20200122/1579680900787352.jpg",
],
title: "便携香水加香一天",
writer_name: "无敌花木兰",
like: 10,
writer_image: "../../../icon/icon_avatar3.png",
note_content: "在欧洲国家中,目前意大利的新冠肺炎疫情形势最为严峻。截至当地时间21日18时,意大利累计确诊病例达到53578例,累计死亡病例达4825例。旅意侨胞和留学生如何保证安全?回国还是不回国?大使馆能提供哪些帮助?今天下午(北京时间3月22日17时),中国驻意大利大使李军华同旅意侨胞、留学生代表一起在线交流。",
},
}, },
...@@ -32,7 +19,7 @@ Page({ ...@@ -32,7 +19,7 @@ Page({
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad: function (options) { onLoad: function (options) {
var _this = this;
var windowHeight = wx.getSystemInfoSync().windowHeight;//获取设备高度,小程序自带的方法 var windowHeight = wx.getSystemInfoSync().windowHeight;//获取设备高度,小程序自带的方法
var windowWidth = wx.getSystemInfoSync().windowWidth;//获取设备高度,小程序自带的方法 var windowWidth = wx.getSystemInfoSync().windowWidth;//获取设备高度,小程序自带的方法
this.setData({ this.setData({
...@@ -41,10 +28,27 @@ Page({ ...@@ -41,10 +28,27 @@ Page({
contentHeight : windowHeight * 0.675, contentHeight : windowHeight * 0.675,
}) })
var notes = _this.__data__.notes
if (Object.keys(notes).length==0 && options.title != "")
{
notes['title'] = options.title;
notes['content'] = options.content;
notes['note_image'] = options.note_image.split(",");
notes['like'] = options.like;
notes['writer_name'] = options.writer_name;
notes['writer_image'] = options.writer_image;
}
wx.setNavigationBarTitle({ wx.setNavigationBarTitle({
title: '发现', title: '发现',
}) })
_this.setData(
{
notes: notes,
}
)
}, },
/** /**
...@@ -119,10 +123,9 @@ Page({ ...@@ -119,10 +123,9 @@ Page({
curIndex : curIndex, curIndex : curIndex,
}); });
} }
// console.log("itemWidth: ",itemWidth)
console.log("itemWidth: ",itemWidth) // console.log("scrollLeft: ", scrollLeft)
console.log("scrollLeft: ", scrollLeft) // console.log("curIndex: ", curIndex)
console.log("curIndex: ", curIndex) // console.log("newScrollLeft: ", newScrollLeft)
console.log("newScrollLeft: ", newScrollLeft)
}, },
}) })
\ No newline at end of file
<view class="page"> <view class="page">
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
<!-- 文字内容 --> <!-- 文字内容 -->
<view class="note"> <view class="note">
<view class="note-info"> <view class="note-info">
{{notes.note_content}} {{notes.content}}
</view> </view>
</view> </view>
</view> </view>
package cn.com.fun.nyxkey.api.service; package cn.com.fun.nyxkey.api.service;
...@@ -41,7 +41,7 @@ public interface Rockwell_keyService { ...@@ -41,7 +41,7 @@ public interface Rockwell_keyService {
void Rockwell_keyServiceGenT_match_rank(String matchSeason); void Rockwell_keyServiceGenT_match_rank(String matchSeason);
/* post api */ /* post api */
JSONResult Rockwell_keyServiceGetV_post_info(String tag, String title, String top); JSONResult Rockwell_keyServiceGetV_post_info(String tag, String title, String top, int pageNum, int pageCount);
// testing // testing
void Rockwell_keyServiceTest(List<Rockwell_keyT_match> listRockwell_keyT_match); void Rockwell_keyServiceTest(List<Rockwell_keyT_match> listRockwell_keyT_match);
......
package cn.com.fun.nyxkey.api.service.impl; package cn.com.fun.nyxkey.api.service.impl;
...@@ -268,11 +268,12 @@ public class Rockwell_keyServiceImpl implements Rockwell_keyService { ...@@ -268,11 +268,12 @@ public class Rockwell_keyServiceImpl implements Rockwell_keyService {
/* post api */ /* post api */
// getV_post_info // getV_post_info
public JSONResult Rockwell_keyServiceGetV_post_info(String tag, String title, String top) public JSONResult Rockwell_keyServiceGetV_post_info(String tag, String title, String top, int pageNum, int pageCount)
{ {
Rockwell_keyT_postQuery rockwell_keyT_postQuery = new Rockwell_keyT_postQuery(); Rockwell_keyT_postQuery rockwell_keyT_postQuery = new Rockwell_keyT_postQuery();
rockwell_keyT_postQuery.setTag(tag); rockwell_keyT_postQuery.setTag(tag);
rockwell_keyT_postQuery.setTitle(title); rockwell_keyT_postQuery.setTitle(title);
rockwell_keyT_postQuery.setPagination(new Pagination(pageNum, pageCount));
if(top.equals("1")) if(top.equals("1"))
{ {
Calendar before7 = Calendar.getInstance(); Calendar before7 = Calendar.getInstance();
......
package cn.com.fun.nyxkey.api.web.controller; package cn.com.fun.nyxkey.api.web.controller;
...@@ -260,7 +260,7 @@ public class NyxApiController { ...@@ -260,7 +260,7 @@ public class NyxApiController {
@RequestParam(value = "pageCount", required = false, defaultValue = "5") int pageCount @RequestParam(value = "pageCount", required = false, defaultValue = "5") int pageCount
) { ) {
return keyService.Rockwell_keyServiceGetV_post_info(tag, title, top); return keyService.Rockwell_keyServiceGetV_post_info(tag, title, top, pageNum, pageCount);
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论