Commit e7fc7c0c by jscat

nyx weapp: 调整流程

parent 5e5035d4
{
{
{
"pages": [
"pages/activity/activity",
"pages/activity/quiz-detail/quiz-detail",
"pages/activity/quiz-result/quiz-result",
"pages/activity/quiz-info/quiz-info",
"pages/key/key",
"pages/activity/act-address/act-address",
"pages/activity/act-writer/act-writer",
"pages/my/my",
"pages/key/matchDaily/matchDaily",
"pages/key/matchTest/matchTest",
"pages/my/points/points",
"pages/my/user/user",
"pages/my/myposts/myposts",
......
//config.js API全局域名配置
//config.js API全局域名配置
......@@ -44,6 +44,7 @@ var config={
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/post/query",
activity_query_url: host_key + "/api/nyx/activity/query",
points_query_url: host_key + "/api/nyx/match/point/query",
bonus_query_url: host_key + "/api/nyx/match/bonus/query/id",
socket_url: socket_url,
......
// pages/activity/activity.js
// pages/activity/activity.js
......@@ -10,10 +10,10 @@ Page({
data: {
category: [ // 导航栏内容数据
{ name: '竞答', id: 'jingda' },
{ name: '饮事', id: 'yinshi' },
{ name: '活动', id: 'huodong' },
],
curIndex: 0, // 给选中的tab加粗
notes: [
activities: [],
// {
// note_image: [ "https://1.jpg", "https://2.jpg"],
// title: "一天",
......@@ -21,7 +21,6 @@ Page({
// writer_name: "无敌花木兰",
// writer_image: "../../icon/icon_avatar3.png"
// },
],
//分页加载部分
isHideLoadMore: false,
......@@ -54,7 +53,7 @@ Page({
this.setData({
curIndex: curIndex,
})
_this.getNotes(0, 1, 4, strCategory);
_this.getActivities(0, 1, 4, strCategory);
},
// 搜索点击事件
entrySearch(e) {
......@@ -87,13 +86,13 @@ Page({
title: '酒肆活动',
})
//初始载入四个推荐notes
if(_this.__data__.notes.length == 0)
//初始载入四个推荐的竞答活动
if(_this.__data__.activities.length == 0)
{
//getNotes(strCategory)
var curIndex = _this.__data__.curIndex
var strCategory = _this.__data__.category[curIndex].name
_this.getNotes(0, 1, 4, strCategory);
_this.getActivities(0, 1, 4, strCategory);
}
},
......@@ -151,7 +150,7 @@ Page({
console.log('加载更多')
setTimeout(() => {
_this.getNotes(1, pageIndex, 4, strSearch);
_this.getActivities(1, pageIndex, 4, strSearch);
}, 1000)
}
else {
......@@ -170,17 +169,22 @@ Page({
* 用户自定义函数
*
*/
// 获取notes数据
// 获取Activities数据
// scrollType: 是否是翻页
getNotes: function (scrollType,pageNum, pageCount, strSearch) {
/*
搜索逻辑:
1. 搜索框, tag=strSearch + title=strSearch
2. tab, tag=strSearch
3. 新增的search tab, '搜索'tab的时候,需要转换为搜索的关键词(_this.__data__.strSearch)
*/
getActivities: function (scrollType, pageNum, pageCount, strSearch) {
var _this = this;
//如果是"推荐"和"搜索",需要单独处理
//搜索时候,需要转换为搜索的关键词
// 如果是"推荐"和"搜索",需要单独处理
// '搜索'tab的时候,需要转换为搜索的关键词(_this.__data__.strSearch)
strSearch = strSearch == "搜索" ? _this.__data__.strSearch : strSearch
var query_url = strSearch == "推荐" ? '&top=1' : '&tag=' + strSearch + '&title=' + strSearch
var query_url = '&tag=' + strSearch + '&title=' + strSearch
var strUrl = config.notes_query_url + "?pageCount=" + pageCount
var strUrl = config.activity_query_url + "?pageCount=" + pageCount
+ "&pageNum=" + pageNum + query_url
config.debug == 1 ? console.log("===strUrl is: \"" + strUrl + "\"") : ""
wx.request({
......@@ -200,25 +204,39 @@ Page({
}
for (var i = 0; i < res.data.data.length; i++) {
var result = {}
result["post_id"] = res.data.data[i].postId
result["note_image"] = res.data.data[i].noteImage.split("::")
result["title"] = res.data.data[i].title
result["activity_id"] = res.data.data[i].activityId
result["member_name"] = res.data.data[i].memberName
result["member_slogan"] = res.data.data[i].memberSlogan
result["member_id"] = res.data.data[i].memberId
result["member_status"] = res.data.data[i].memberStatus
result["tag"] = res.data.data[i].tag
result["title"] = res.data.data[i].title
result["num_like"] = res.data.data[i].numLike
result["content"] = res.data.data[i].content
result["like"] = res.data.data[i].numLike
result["writer_name"] = res.data.data[i].nickName == null ? "匿名用户" : res.data.data[i].nickName
result["writer_image"] = res.data.data[i].avatarUrl == null ? '/icon/icon_avatar1.png' : res.data.data[i].avatarUrl
result["quiz"] = res.data.data[i].quiz
result["point"] = res.data.data[i].point
result["product_desc"] = res.data.data[i].productDesc
result["price"] = res.data.data[i].price
result["note_image"] = res.data.data[i].noteImage.split("::")
var url = "../activity/quiz-info/quiz-info?"
+"&note_image="+res.data.data[i].noteImage //传递原始string数据, List不正确
+"&title="+result["title"]
+"&content="+result["content"]
+"&like="+result["num_like"]
+"&quiz="+result["quiz"]
+"&member_name="+result["member_name"]
+"&member_slogan="+result["member_slogan"]
result["url"] = url
list.push(result)
}
//进行翻页设置(加载更多)
if (scrollType == 1) {
var notesList = _this.__data__.notes;
list = notesList.concat(list)
var activitiesList = _this.__data__.activities;
list = activitiesList.concat(list)
}
_this.setData({
notes: list,
activities: list,
pageIndex: pageNum + 1,
isHideLoadMore: bisHideLoadMoreType,
})
......@@ -247,7 +265,7 @@ Page({
curIndex: 1,
});
var strCategory = _this.__data__.category[1].name
_this.getNotes(0, 1, 4, strCategory);
_this.getActivities(0, 1, 4, strCategory);
},
// * 删除输入字符串
clearInput: function(){
......@@ -262,7 +280,7 @@ Page({
var strSearch = e.detail.value
var cat = _this.__data__.category
console.log("===input search text_" + strSearch)
_this.getNotes(0, 1, 4, strSearch);
_this.getActivities(0, 1, 4, strSearch);
if(cat[cat.length-1].name != "搜索")
{
cat.push({
......@@ -293,16 +311,16 @@ Page({
if (res.statusCode == 200) {
//表示查询成功
console.log(res.data);
var notesList = _this.data.notes
var activitiesList = _this.data.activities
var likeDict = _this.data.likeDict
for (var j = 0; j < notesList.length; j++) {
if (notesList[j].post_id == postId)
notesList[j].like = parseInt(notesList[j].like) + 1
for (var j = 0; j < activitiesList.length; j++) {
if (activitiesList[j].post_id == postId)
activitiesList[j].like = parseInt(activitiesList[j].like) + 1
likeDict[postId] = 1
}
_this.setData({
likeDict: likeDict,
notes: notesList,
activities: activitiesList,
})
}
}
......
<view class="page">
<view class="page">
......@@ -61,9 +61,9 @@
<!-- 文章列表 -->
<scroll-view class="list-block" scroll-y="true" style="height:{{noteHeight}}px">
<!-- 文章封面内容 -->
<view class="notes-block" wx:for="{{notes}}" wx:for-item="item" wx:key="{{index}}">
<view class="notes-block" wx:for="{{activities}}" wx:for-item="item" wx:key="{{index}}">
<view class="note-info">
<navigator url="../activity/quiz-info/quiz-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}}" >
<navigator url="{{item.url}}" >
<view class="note-img">
<image src="{{item.note_image[0]}}"/>
</view>
......@@ -74,10 +74,15 @@
<view class="note-handle">
<navigator class="writer" url="../activity/act-writer/act-writer">
</navigator>
<span class="name">{{item.writer_name}}</span>
<block wx:if="{{item.tag=='竞答'}}" >
<span class="name">{{item.member_name}}</span>
</block>
<block wx:else>
<span class="price">¥{{item.price}}</span>
</block>
<view class="like" bindtap="onSubmitLike" data-post-id="{{item.post_id}}">
<image class="like-icon" src="../../icon/activity/like.png" style="width:30rpx;height:30rpx"/>
<span>{{item.like}}</span>
<span>{{item.num_like}}</span>
</view>
</view>
</view>
......
/*
/*
......@@ -82,10 +82,20 @@
}
.name{
margin-left: 0px;
margin-right : 40rpx;
text-align: center;
line-height: 38px;
font-size: 28rpx;
}
.price{
margin-left: 0px;
margin-right : 40rpx;
text-align: center;
line-height: 38px;
font-size: 28rpx;
color: #F00;
font-weight: bold;
}
.writer image{
width: 30px;
height: 30px;
......
// pages/index/note-info/note-info.js
// pages/index/note-info/note-info.js
......@@ -11,7 +11,7 @@ Page({
contentHeight: "",
scrollLeft: 0, //切换栏的滚动条位置
curIndex : 0,
notes: {},
quiz: {},
},
......@@ -28,15 +28,18 @@ Page({
contentHeight : windowHeight * 0.675,
})
var notes = _this.__data__.notes
if (Object.keys(notes).length==0 && options.title != "")
var quiz = _this.__data__.quiz
if (Object.keys(quiz).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 == "null" ? "匿名用户" : options.writer_name;
notes['writer_image'] = options.writer_image == "null" ? '/icon/icon_avatar1.png' : options.writer_image;
quiz['note_image'] = options.note_image.split("::");
quiz['title'] = options.title;
quiz['content'] = options.content.split("::");
quiz['like'] = options.like;
quiz['quiz'] = options.quiz;
quiz['member_name'] = options.member_name;
quiz['member_slogan'] = options.member_slogan;
quiz['writer_name'] = options.writer_name == "null" ? "匿名用户" : options.writer_name;
quiz['writer_image'] = options.writer_image == "null" ? '/icon/icon_avatar1.png' : options.writer_image;
}
wx.setNavigationBarTitle({
......@@ -45,7 +48,7 @@ Page({
_this.setData(
{
notes: notes,
quiz: quiz,
}
)
......@@ -120,13 +123,13 @@ Page({
getSelectItem: function (e) {
var that = this;
var preCurIndex = that.data.curIndex;
var itemWidth = e.detail.scrollWidth / that.data.notes.note_image.length;//每个商品的宽度
var itemWidth = e.detail.scrollWidth / that.data.quiz.note_image.length;//每个商品的宽度
var scrollLeft = e.detail.scrollLeft;//滚动宽度
var curIndex = Math.round(scrollLeft / itemWidth);//通过Math.round方法对滚动大于一半的位置进行进位
var newScrollLeft = 0
// 目标: 始终让图片居中显示
if (curIndex != preCurIndex
|| (curIndex == that.data.notes.note_image.length - 1 && scrollLeft > that.data.windowWidth * (that.data.notes.note_image.length - 1))
|| (curIndex == that.data.quiz.note_image.length - 1 && scrollLeft > that.data.windowWidth * (that.data.quiz.note_image.length - 1))
)
{
newScrollLeft = that.data.windowWidth * curIndex
......@@ -144,7 +147,7 @@ Page({
//跳转到知识竞答页面
toGame: function (e) {
wx.navigateTo({
url: "/pages/key/matchDaily/matchDaily"
url: "/pages/key/matchTest/matchTest"
});
},
......
<view class="page">
<view class="page">
......@@ -2,7 +2,7 @@
<!-- 图片 -->
<scroll-view class="scroll-view_H" scroll-x scroll-with-animation style="width: 100%;height: 90%;" bindscroll="getSelectItem" scroll-left="{{scrollLeft}}">
<block wx:for="{{notes.note_image}}" wx:key="unique" wx:for-index="id" wx:for-item="item">
<block wx:for="{{quiz.note_image}}" wx:key="unique" wx:for-index="id" wx:for-item="item">
<view class="scroll_item {{item.selected ? 'selected' : ''}}" data-index='{{item.index}}' bindtap='selectProItem'>
<image src="{{item}}" mode="widthFix"/>
</view>
......@@ -13,22 +13,22 @@
<view class="note">
<view class="note-title" style="font-weight: bold">
Renaissance Bar知识竞答
{{quiz.member_name}} {{quiz.title}}
</view>
<view class="note-content">
共10题
{{quiz.content[0]}}
</view>
<view class="note-content">
可获得5积分
</view>
{{quiz.content[1]}}
</view>
</view>
<!-- 企业信息 -->
<view class="note-row">
<image class="writer-image" src="{{notes.writer_image}}"/>
<image class="writer-image" src="{{quiz.writer_image}}"/>
<view class="note-column">
<span class="name">Renaissance Bar</span>
<span class="name">充满爱与温度,自由放松的bar</span>
<span class="name">{{quiz.member_name}}</span>
<span class="name">{{quiz.member_slogan}}</span>
</view>
</view>
......
// pages/index/note-info/note-info.js
// pages/index/note-info/note-info.js
......@@ -104,7 +104,7 @@ Page({
//跳转到知识竞答页面
toGame: function (e) {
wx.navigateTo({
url: "/pages/key/matchDaily/matchDaily"
url: "/pages/key/matchTest/matchTest"
});
},
......
<!--pages/key/key.wxml-->
<!--pages/key/key.wxml-->
......@@ -3,7 +3,7 @@
<!-- start key view -->
<view class="weui-cells">
<scroll-view scroll-y="true" style="height:{{keyHeight}}px;position:fixed; top:0;">
<navigator class="weui-cell weui-cell_access" hover-class="weui-cell_active" url="/pages/key/matchDaily/matchDaily">
<navigator class="weui-cell weui-cell_access" hover-class="weui-cell_active" url="/pages/key/matchTest/matchTest">
<view class="weui-cell__hd">
<image src="/icon/daily.png" />
</view>
......
// pages/key/matchDaily/matchDaily.js
// pages/key/matchTest/matchTest.js
// pages/key/matchDaily/matchDaily.js
// pages/key/matchTest/matchTest.js
var item_list = [];
var choiceString = [];
......
<!--pages/key/matchTest/matchTest.wxml-->
<!--pages/key/matchTest/matchTest.wxml-->
......@@ -67,12 +67,12 @@
<view class="weui-flex">
<view class="weui-flex__item" bindtap="{{button_disabled==0?'onGetComment':'onTypeNext'}}">
<view class="placeholder-button">
<image src="{{button_disabled==0?(comment_hidden_type==1?'/icon/matchDaily/checkComment.png':'/icon/matchDaily/checkComment.png'):'/icon/matchDaily/next.png'}}" style="vertical-align:middle;width:60rpx;height:60rpx" />
<image src="{{button_disabled==0?(comment_hidden_type==1?'/icon/matchTest/checkComment.png':'/icon/matchTest/checkComment.png'):'/icon/matchTest/next.png'}}" style="vertical-align:middle;width:60rpx;height:60rpx" />
{{button_disabled==0?(comment_hidden_type==1?"查看评论":"隐藏评论"):"下一题"}}</view>
</view>
<view class="weui-flex__item"><view class="{{button_disabled==0?'placeholder-button':'placeholder-button-disabled'}}" bind:tap="onReportBug">
<image src="{{button_disabled==0?'/icon/matchDaily/question.png':'/icon/matchDaily/question_0.png'}}" style="vertical-align:middle;width:60rpx;height:60rpx" />这题有问题</view>
<image src="{{button_disabled==0?'/icon/matchTest/question.png':'/icon/matchTest/question_0.png'}}" style="vertical-align:middle;width:60rpx;height:60rpx" />这题有问题</view>
</view>
</view>
......@@ -101,7 +101,7 @@
<view class="weui-media-box__desc" style="font-size:30rpx">
{{item.numLike}}
<view bindtap="onSubmitLike" data-comment-id="{{item.commentId}}">
<image src="/icon/matchDaily/like.png" style="width:30rpx;height:30rpx" />
<image src="/icon/matchTest/like.png" style="width:30rpx;height:30rpx" />
</view>
</view>
<!-- end 点赞数 + 图标 -->
......
// pages/post/post.js
// pages/post/post.js
......@@ -94,7 +94,7 @@ Page({
2. 进行图片编辑
3. 点击下一步验证图片是否合法合规 navigateToEdit
通过size或其他方式判断是否进行图片处理(裁切,填满,留白,充满)
1) > 2M会出现45002, content size out of limit错误
1) > 2M会出现 45002, content size out of limit 错误
2) 自动裁剪成4:3 或 1:1
*/
......@@ -194,7 +194,7 @@ Page({
// 通过size或其他方式判断是否进行图片处理(裁切,填满,留白,充满)
// 1) > 2M会出现45002, content size out of limit错误
// 2) 自动裁剪成4:3(高/宽 1080) 或 1:1
// 2) 自动裁剪成4:3(高/宽 1080) 或 1:1 有品默认1:1
// refer1 微信小程序图片压缩 https://www.jianshu.com/p/1b8a1e96a6d5
// refer2 小程序压缩图片(canvas) https://www.jianshu.com/p/ec1f95008dce
onEditPic(res, canvasId) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论