Commit dbf780cc by jscat

nyx: discover相关功能接口更新

parent 876b8820
//config.js API全局域名配置
//config.js API全局域名配置
......@@ -47,6 +47,7 @@ var config={
match_add_item_url: host_key + "/api/nyx/match/add/item",
user_reg_url: host_key + "/api/nyx/user/reg",
userinfo_query_url: host_key + "/api/nyx/userinfo/query",
notes_query_url: host_key + "/api/nyx/notes/query",
socket_url: socket_url,
}
module.exports=config;
\ No newline at end of file
// pages/kinds/kinds.js
// pages/kinds/kinds.js
// pages/kinds/kinds.js
const app = getApp()
var config = wx.getStorageSync("config");
Page({
......@@ -9,62 +10,52 @@ Page({
data: {
category: [ // 导航栏内容数据
{ name: '推荐', id: 'tuijian' },
{ name: '附近', id: 'fujin' },
{ name: '复工', id: 'fugong' },
{ name: '酒单', id: 'jiudan' },
{ name: 'DJ', id: 'dj' },
{ name: '音乐', id: 'yinyue' },
{ name: '饮事', id: 'yinshi' },
],
curIndex: 0,
detail: [
curIndex: 0, // 给选中的tab加粗
notes: [
{
id : "tuijian",
notes: [
{
note_image: "https://img.xiaohongshu.com/items/c1a0056ba9ba17b30446a0e040dc9e30@800w_90Q_1x_2o.jpg",
title: "便携香水加香一天",
writer: "无敌花木兰",
like: 10,
writer_image: "../../icon/icon_avatar3.png"
},
{
note_image: "https://img.xiaohongshu.com/items/c1a0056ba9ba17b30446a0e040dc9e30@800w_90Q_1x_2o.jpg",
title: "便携香水加香一天",
writer: "无敌花木兰",
like: 10,
writer_image: "../../icon/icon_avatar3.png"
}
]
note_image: [ "https://img.xiaohongshu.com/items/c1a0056ba9ba17b30446a0e040dc9e30@800w_90Q_1x_2o.jpg",
"https://img.xiaohongshu.com/items/c1a0056ba9ba17b30446a0e040dc9e30@800w_90Q_1x_2o.jpg",
],
title: "便携香水加香一天",
like: 10,
writer_name: "无敌花木兰",
writer_image: "../../icon/icon_avatar3.png"
},
{
id: "fujin",
notes: [
{
note_image: "https://img.xiaohongshu.com/items/c1a0056ba9ba17b30446a0e040dc9e30@800w_90Q_1x_2o.jpg",
title: "便携香水加香一天",
writer: "大小姐嫁到",
like: 10,
writer_image: "https://img.xiaohongshu.com/seller/0d1b063d887360fc5a3779bd6784a453"
},
{
note_image: "https://img.xiaohongshu.com/items/c1a0056ba9ba17b30446a0e040dc9e30@800w_90Q_1x_2o.jpg",
title: "便携香水加香一天",
writer: "百里玄策",
like: 10,
writer_image: "https://img.xiaohongshu.com/seller/0d1b063d887360fc5a3779bd6784a453"
}
]
}
note_image: [ "https://img.xiaohongshu.com/items/c1a0056ba9ba17b30446a0e040dc9e30@800w_90Q_1x_2o.jpg",
],
title: "便携香水加香一天",
like: 10,
writer_name: "无敌花木兰",
writer_image: "../../icon/icon_avatar3.png"
},
{
note_image: ["https://img.xiaohongshu.com/items/c1a0056ba9ba17b30446a0e040dc9e30@800w_90Q_1x_2o.jpg",
],
title: "便携香水加香一天",
like: 10,
writer_name: "无敌花木兰",
writer_image: "../../icon/icon_avatar3.png"
},
{
note_image: ["https://img.xiaohongshu.com/items/c1a0056ba9ba17b30446a0e040dc9e30@800w_90Q_1x_2o.jpg",
],
title: "便携香水加香一天",
like: 10,
writer_name: "无敌花木兰",
writer_image: "../../icon/icon_avatar3.png"
},
],
toView: 'tuijian',
scroll: true
},
switchCategory(e) {
this.setData({
curIndex: e.currentTarget.dataset.index?e.currentTarget.dataset.index:0,
toView: e.currentTarget.dataset.index,
})
},
// 搜索点击事件
......@@ -73,22 +64,24 @@ Page({
url: '../index/searchbar/searchbar',
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
var _this = this;
wx.setNavigationBarTitle({
title: '发现',
})
// 请求数据
// wx.request({
// url: 'https://www.easy-mock.com/mock/5b1e17a0d4a14a3247a6cd6b/',
// success: (res) => {
// this.setData({
// detail: res.data.data
// })
// }
// })
//初始载入四个推荐notes
if(_this.__data.notes.length == 0)
{
//getNotes(strCategory)
var strCategory = _this.__data__.category[curIndex].name
_this.getNotes(strCategory);
}
},
/**
......@@ -130,7 +123,31 @@ Page({
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
console.log('页面上拉触底')
var _that = this;
var isHideLoadMore = _that.__data__.isHideLoadMore;
var pageIndex = _that.__data__.pageIndex;
var strSearchName = _that.__data__.strSearchName;
//判断是否已经全部加载完毕
//没有则加载更多
if (!isHideLoadMore) {
console.log('加载更多')
//如果是全部搜索状态
if (strSearchName.length > 0) {
setTimeout(() => {
_that.getBookGlobal(1, strSearchName, pageIndex, 4);
}, 1000)
}
else {
setTimeout(() => {
_that.getBook(1, pageIndex, 4);
}, 1000)
}
}
else {
console.log('没有更多')
}
},
/**
......@@ -138,6 +155,38 @@ Page({
*/
onShareAppMessage: function () {
}
},
/**
* 用户自定义函数
*
*/
// 获取notes数据
getNotes: function (strCategory) {
var _this = this;
config.debug == 1 ? console.log("===getNotes strCategory is: \"" + strCategory + "\"") : ""
wx.request({
url: config.notes_query_url + '?tag=' + strCategory,
method: 'GET',
header: {
'Cookie': wx.getStorageSync('cookieKey'),
},
success: function (res) {
if (res.data.resultCode == 200) {
//表示HTTP请求成功
console.log(res.data);
var result = res.data.data
for (var j = 0; j < result.length; j++) {
var list = result[i].note_image.split("::")
result[i]["note_image"] = list
}
_this.setData({
notes: result,
})
}
}
})
},
})
<view class="page">
<view class="page">
......@@ -14,35 +14,42 @@
bindtap="switchCategory">{{item.name}}</view>
</scroll-view>
</view>
<!-- 文章列表 -->
<swiper class="notes" current="{{toView}}">
<swiper-item class="category" wx:for="{{detail}}" wx:key="{{item.id}}">
<scroll-view class="cate-box" id="{{item.id}}" scroll-y>
<!-- 文章封面内容 -->
<view class="note" wx:for="{{item.notes}}" wx:for-item="notes" wx:key="{{index}}">
<view class="note-info">
<navigator url="../discover/note-info/note-info" >
<view class="home-note-img">
<image src="{{notes.note_image}}"/>
</view>
<span>{{notes.title}}</span>
</navigator>
</view>
<!-- 作者信息 -->
<view class="note-handle">
<navigator class="writer" url="../discover/note-writer/note-writer">
<image class="photo-img" src="{{notes.writer_image}}"/>
<span class="name">{{notes.writer}}</span>
</navigator>
<view class="like">
<image class="like-icon" src="../../icon/discover/like.png"/>
<span>{{notes.like}}</span>
</view>
</view>
<scroll-view class="list-block" scroll-y="true">
<!-- 文章封面内容 -->
<view class="notes-block" wx:for="{{notes}}" wx:for-item="item" wx:key="{{index}}">
<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}}" >
<view class="home-note-img">
<image src="{{item.note_image[0]}}"/>
</view>
</scroll-view>
</swiper-item>
</swiper>
<span>{{item.title}}</span>
</navigator>
</view>
<!-- 作者信息 -->
<view class="note-handle">
<navigator class="writer" url="../discover/note-writer/note-writer">
<image class="photo-img" src="{{item.writer_image}}"/>
<span class="name">{{item.writer_name}}</span>
</navigator>
<view class="like">
<image class="like-icon" src="../../icon/discover/like.png"/>
<span>{{item.like}}</span>
</view>
</view>
</view>
</scroll-view>
<!-- 加载更多 -->
<view class="weui-loadmore" hidden="{{isHideLoadMore}}">
<view class="weui-loading"></view>
<view class="weui-loadmore__tips">正在加载</view>
</view>
<view class="weui-loadmore" hidden="{{!isHideLoadMore}}">
<view class="weui-loadmore__tips">没有更多啦 {{'>'}}_{{'<'}} </view>
</view>
</view>
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论