Skip to content

Commit

Permalink
-2.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
QlQlqiqi committed Oct 6, 2021
1 parent 67c1519 commit 0bb5385
Show file tree
Hide file tree
Showing 14 changed files with 115 additions and 76 deletions.
2 changes: 2 additions & 0 deletions src/behavior/share-chat-behavior.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ module.exports = Behavior({
// 这里同步不会 get ,只是 post
let { comment: commentLocal, chatId } = e.detail;
let chats = this.data.chats, chat;
console.log(commentLocal, chatId)
for(let i = 0; i < chats.length; i++) {
chat = chats[i];
if(chat.id === chatId) {
Expand All @@ -211,6 +212,7 @@ module.exports = Behavior({
this.setData({
[key]: chat.comments
})
break;
}
}
// 下面是 post
Expand Down
57 changes: 37 additions & 20 deletions src/components/share-message/share-message.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,13 @@ Component({
date(data) {
return util.dateInToOut(data.chat.pic.date);
},
// 评论输入框的占位字符
commnetPlaceHolder(data) {
return data.replyIndex === -1
? '请输入...'
: ' 回复 ' + (data.chat.owner === app.globalData.owner)
? '洞主'
: app.globalData.anames[data.chat.comments[data.replyIndex].fromUser % app.globalData.anames.length].name;
},
chatFilter(data) {
console.log(data.chat)
let owner = app.globalData.owner;
let chat = JSON.parse(JSON.stringify(data.chat));
let idx = 0;
chat.comments.forEach(item => {
item.title = util.getCommentTitle(chat.owner, item.fromUser, item.toUser, owner);
item.title = util.getCommentTitle(chat.owner, item.fromUser, item.toUser, owner, chat.pic.name);
item.oldIndex = idx++;
});
chat.comments = chat.comments.filter(item => {
Expand All @@ -54,7 +46,26 @@ Component({
|| (item.fromUser === item.toUser && item.fromUser === chat.owner);
})
return chat;
}
},
// 评论输入框的占位字符
commnetPlaceHolder(data) {
if(data.replyIndex === -1)
return '请输入...';
let {fromUser, toUser} = data.chatFilter.comments[data.replyIndex];
return fromUser === app.globalData.owner
? '请输入...'
: ' 回复 ' +
((data.chat.owner === fromUser)
? '洞主'
: util.getCommentTitle(
data.chat.owner,
fromUser,
toUser,
app.globalData.owner,
data.chat.pic.name,
).split(' 回复 ')[0]);

},
},

/**
Expand Down Expand Up @@ -82,10 +93,9 @@ Component({
// 点击相关功能,告诉父组件
handleSelectOption(e) {
let index = e.currentTarget.dataset.index;
console.log(this.data.chat)
this.triggerEvent('handleSelectOption', {
index,
chatId: this.data.chat.id
chatId: this.data.chatFilter.id
});
this.setData({
optionsShow: !this.data.optionsShow
Expand All @@ -109,31 +119,38 @@ Component({
// 点击回复,显示回复谁,并拉起键盘
handleReplyWho(e) {
let {index} = e.currentTarget.dataset;
console.log(index)
this.setData({
replyIndex: index,
commentFocus: true,
})
});
},
// 发送评论
handleEnsureComment(e) {
let {chat, replyIndex, commentValue} = this.data;
let {chatFilter, replyIndex, commentValue} = this.data;
let {anames, owner} = app.globalData;
let title = replyIndex === -1
? util.getCommentTitle(chat.owner, owner, owner, owner)
: util.getCommentTitle(chat.owner, chat.comments[replyIndex].fromUser, chat.comments[replyIndex].toUser, owner);
? util.getCommentTitle(chatFilter.owner, owner, owner, owner, chatFilter.pic.name)
: util.getCommentTitle(
chatFilter.owner,
chatFilter.comments[replyIndex].fromUser,
chatFilter.comments[replyIndex].toUser,
owner,
chatFilter.pic.name,
);
let comment = {
id: util.getUniqueId(),
title,
content: commentValue,
chatId: chat.id,
fromUser: chat.owner,
chatId: chatFilter.id,
fromUser: app.globalData.owner,
toUser: replyIndex === -1
? app.globalData.owner
: chat.comments[replyIndex].fromUser
: chatFilter.comments[replyIndex].fromUser
}
this.triggerEvent('handleEnsureComment', {
comment,
chatId: chat.id
chatId: chatFilter.id
})
// 清空输入框
this.setData({
Expand Down
20 changes: 12 additions & 8 deletions src/pages/add-chat/add-chat.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,17 @@ Component({
if (!data.finishedTasks.length) starsNum = 0;
return starsNum;
},
// 缩略图
review(data) {
return {
starsNum: data.starsNumber,
tasks: data.finishedTasks.map(item => {
return {
content: item.content
}
})
};
}
},

/**
Expand Down Expand Up @@ -347,15 +358,8 @@ Component({
ratio: 750 / windowWidth,
bottomLineHeight,
tasks,
review: {
starsNum: this.data.starsNumber,
tasks: this.data.finishedTasks.map(item => {
return {
content: item.content
}
})
}
});
console.log(this.data)
// 保留上一次的数据
let last = wx.getStorageSync('add-chat-last-data');
if(last) {
Expand Down
2 changes: 1 addition & 1 deletion src/pages/add-chat/add-chat.wxml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
>
<image src="/src/image/reivew-abridge-delete.svg" catchtap="handleCloseReviewAbridge" mode="aspectFit" class="image"></image>
<review-abridge componentWidthMax="{{ windowWidth }}" componentHeightMin="{{ 100 }}"
starsNum="{{ review.starsNum }}" tasks="{{ review.tasks }}" safeAreaBottom="{{ bottomLineHeight }}"
starsNum="{{ starsNumber }}" tasks="{{ review.tasks }}" safeAreaBottom="{{ bottomLineHeight }}"
></review-abridge>
</view>
<view wx:if="{{ repeatTipShow }}" class="repeat-tip" style="top: {{ repeatTipTop }}px;">已添加,请勿重复操作!</view>
Expand Down
10 changes: 6 additions & 4 deletions src/pages/collection/collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,9 @@ Component({
for (let item of this.data.tasks) {
if (item.id === e.currentTarget.dataset.id) {
item.finish = !item.finish;
if (item.finish) item.finishDate = util.formatDate(new Date());
if (item.finish)
item.finishDate = util.formatDate(new Date());
console.log(item)
await store.saveTasksToSql([item], this.data.lists, { owner, token });
}
tasks.push(item);
Expand Down Expand Up @@ -150,11 +152,11 @@ Component({
// 从本地获取全部数据
_getAllDataFromLocal: function () {
// 获取任务
let tasks = JSON.parse(wx.getStorageSync("tasks"));
let tasks = JSON.parse(wx.getStorageSync("tasks") || JSON.stringify([]));
// 获取清单
let lists = JSON.parse(wx.getStorageSync("lists"));
let lists = JSON.parse(wx.getStorageSync("lists") || JSON.stringify([]));
// 用户昵称
let signText = JSON.parse(wx.getStorageSync("signText"));
let signText = JSON.parse(wx.getStorageSync("signText") || JSON.stringify(''));
this.setData({
tasks: tasks,
lists: lists,
Expand Down
1 change: 1 addition & 0 deletions src/pages/editor/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ Component({
tasks = util.mergeById(tasks, [task]);
let {owner, token} = await util.getTokenAndOwner(app.globalData.url + 'login/login/');
await store.saveTasksToSql([task], this.data.lists, {owner, token});
console.log(task)
wx.setStorageSync('tasks', JSON.stringify(tasks));
wx.hideLoading({
success: () => {
Expand Down
21 changes: 1 addition & 20 deletions src/pages/message-remind/message-remind.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,6 @@ Component({

},

computed: {
// chatFilter(data) {
// let owner = app.globalData.owner;
// let chat = JSON.parse(JSON.stringify(data.chat));
// let idx = 0;
// chat.comments.forEach(item => {
// item.title = util.getCommentTitle(chat.owner, item.fromUser, item.toUser, owner);
// item.oldIndex = idx++;
// });
// chat.comments = chat.comments.filter(item => {
// return chat.owner === owner
// || item.fromUser === owner
// || item.toUser === owner
// || (item.fromUser === item.toUser && item.fromUser === chat.owner);
// })
// return chat;
// }
},

/**
* 组件的初始数据
*/
Expand Down Expand Up @@ -177,7 +158,7 @@ Component({
res.open = false;
let idx = 0;
chat.comments.forEach(item => {
item.title = util.getCommentTitle(chat.owner, item.fromUser, item.toUser, owner);
item.title = util.getCommentTitle(chat.owner, item.fromUser, item.toUser, owner, item.pic.name);
item.oldIndex = idx++;
});
chat.comments = chat.comments.filter(item => {
Expand Down
6 changes: 3 additions & 3 deletions src/pages/review/review.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,11 +191,11 @@ Component({
// 从本地获取全部数据
_getAllDataFromLocal: function () {
// 获取任务
let tasks = JSON.parse(wx.getStorageSync("tasks"));
let tasks = JSON.parse(wx.getStorageSync("tasks") || JSON.stringify([]));
// 获取清单
let lists = JSON.parse(wx.getStorageSync("lists"));
let lists = JSON.parse(wx.getStorageSync("lists") || JSON.stringify([]));
// 用户昵称
let signText = JSON.parse(wx.getStorageSync("signText"));
let signText = JSON.parse(wx.getStorageSync("signText") || JSON.stringify(''));
this.setData({
tasks: tasks,
lists: lists,
Expand Down
30 changes: 23 additions & 7 deletions src/pages/share/share.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,19 @@ Component({
},
pageNameCurrent: function (pageNameCurrent) {
// [树洞区,个人空间]
let chats = this.data.chats;
chats.forEach(item => {
if((pageNameCurrent && item.owner === app.globalData.owner)
|| (!pageNameCurrent && !item.pic.shareRange)
) {
item.show = true;
}
else item.show = false;
})
this.setData({
chats,
})
wx.setStorageSync('chats', JSON.stringify(chats));
},
},

Expand Down Expand Up @@ -200,10 +213,13 @@ Component({
chats.forEach(item => {
item.id = util.getUniqueId();
});
console.log(chats.length && chats[chats.length - 1].id)
chats = chats.filter(item => {
return (item.owner === app.globalData.owner)
|| (!this.data.pageNameCurrent && !item.pic.shareRange);
chats.forEach(item => {
if((this.data.pageNameCurrent && item.owner === app.globalData.owner)
|| (!this.data.pageNameCurrent && !item.pic.shareRange)
) {
item.show = true;
}
else item.show = false;
})
console.log(chats)
let gallerys = dataSql[1].map(item => {
Expand Down Expand Up @@ -247,11 +263,11 @@ Component({
// 从本地获取全部数据
_getAllDataFromLocal: function () {
// 获取任务
let tasks = JSON.parse(wx.getStorageSync("tasks"));
let tasks = JSON.parse(wx.getStorageSync("tasks") || JSON.stringify([]));
// 获取清单
let lists = JSON.parse(wx.getStorageSync("lists"));
let lists = JSON.parse(wx.getStorageSync("lists") || JSON.stringify([]));
// 用户昵称
let signText = JSON.parse(wx.getStorageSync("signText"));
let signText = JSON.parse(wx.getStorageSync("signText") || JSON.stringify(''));
let chats = JSON.parse(wx.getStorageSync('chats') || JSON.stringify([]));
let gallerys = JSON.parse(wx.getStorageSync('gallerys') || JSON.stringify([]));
let chatsRemind = JSON.parse(wx.getStorageSync('chatsRemind') || JSON.stringify([]));
Expand Down
1 change: 1 addition & 0 deletions src/pages/share/share.less
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
}
}
.head-icon-background {
height: 360rpx;
position: relative;
.vir-image {
position: absolute;
Expand Down
12 changes: 7 additions & 5 deletions src/pages/share/share.wxml
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,13 @@
<!-- 说说 -->
<view style="padding-top: 30rpx; margin-bottom: 300rpx;">
<view class="chat-wrap" wx:for="{{ chats }}" wx:key="index">
<share-message chat="{{ item }}" options="{{ optionsSelect }}" componentWidthMax="{{ 616 / ratio }}"
bind:handleEnsureComment="handleEnsureComment" bindhandleSelectOption="handleSelectOption"
></share-message>
<image src="/src/image/task-circle.png" mode="aspectFit" class="left-circle-icon"></image>
<view class="task-left-line"></view>
<view wx:if="{{ item.show }}">
<share-message chat="{{ item }}" options="{{ optionsSelect }}" componentWidthMax="{{ 616 / ratio }}"
bind:handleEnsureComment="handleEnsureComment" bindhandleSelectOption="handleSelectOption"
></share-message>
<image src="/src/image/task-circle.png" mode="aspectFit" class="left-circle-icon"></image>
<view class="task-left-line"></view>
</view>
</view>
</view>
</scroll-view>
Expand Down
1 change: 1 addition & 0 deletions src/pages/share/share.wxss
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
width: 100%;
}
.share-wrap .head-icon-background {
height: 360rpx;
position: relative;
}
.share-wrap .head-icon-background .vir-image {
Expand Down
3 changes: 2 additions & 1 deletion src/store/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const saveTasksToSql = async function (
let tasksPostPr = util
.formatTasksFromLocalToSql(tasksPost, listsLocal, { owner, token })
.map(item => {
console.log("post", item);
console.log("post", item, JSON.stringify(item));
let pr = util
.myRequest({
url:
Expand Down Expand Up @@ -78,6 +78,7 @@ const saveTasksToSql = async function (
);
tasksSql.forEach(taskSql => {
for (let tmpTask of tasksPost) {
console.log(tmpTask, taskSql)
if (tmpTask.id === taskSql.task_num) {
tmpTask.urlSql = taskSql.url;
break;
Expand Down
Loading

0 comments on commit 0bb5385

Please sign in to comment.