Skip to content
This repository was archived by the owner on Jul 30, 2020. It is now read-only.

Commit e9e15a7

Browse files
committed
修复几处样式,添加帖子热帖,发帖添加markdown预览,通知添加一键已读和点击已读
1 parent aeca876 commit e9e15a7

File tree

5 files changed

+114
-40
lines changed

5 files changed

+114
-40
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ API来自于[cnode社区](https://cnodejs.org/api)
1212

1313
线上版本更新日志
1414

15+
v0.0.4 修复几处样式,添加帖子热帖,发帖添加markdown预览,通知添加一键已读和点击已读 // markdown发布的预览有bug。。。没发布
16+
1517
v0.0.3 添加扫码登陆
1618

1719
v0.0.2 帖子评论框修复、通知点击详情跳转修复
@@ -57,8 +59,6 @@ npm run dev
5759

5860
todo
5961

60-
- 帖子收藏和取消收藏功能 // API字段有问题
61-
- 评论点赞和收藏的UI同步 // API那个字段有点问题
6262
- 编辑自己发过的主题
6363
- 展示未读消息数和消息已读
6464

src/components/card.vue

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
<span>{{item.author.loginname}}</span>
77
<span class='time' v-if='!hidden'>{{formatCreateAt}}</span>
88
</div>
9+
<span class="top" v-if="item.top">置顶</span>
910
</div>
1011
<div class='body'>
1112
<p>{{item.title}}</p>
@@ -82,6 +83,11 @@ export default {
8283
color: $borderColor;
8384
}
8485
}
86+
.top {
87+
position: absolute;
88+
right: 40rpx;
89+
color: red;
90+
}
8591
}
8692
.body {
8793
color: $color;

src/pages/detail/index.vue

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,14 @@ export default {
7676
7777
methods: {
7878
async getData() {
79+
const accesstoken = wx.getStorageSync("accesstoken");
7980
//this.id = wx.getStorageSync("topicid");
8081
wx.showLoading({
8182
title: "加载中"
8283
});
8384
const res = await this.$http.get(`${api}/topic/${this.id}`, {
84-
mdrender: false
85+
mdrender: false,
86+
accesstoken
8587
});
8688
wx.hideLoading();
8789
if (res.data.success) {
@@ -150,7 +152,7 @@ export default {
150152
},
151153
async upOrCancel(e) {
152154
// / todo 防抖
153-
// console.log(e);
155+
console.log(e);
154156
const accesstoken = wx.getStorageSync("accesstoken");
155157
if (accesstoken) {
156158
try {
@@ -166,8 +168,10 @@ export default {
166168
icon: "none",
167169
duration: 2000
168170
});
171+
// e.currentTarget.dataset.originindex
172+
this.currentReplies[e.currentTarget.dataset.originindex].is_uped = res.data.action === 'up';
169173
}
170-
this.getData();
174+
// this.getData();
171175
} catch (e) {
172176
wx.showToast({
173177
title: e.response.data.error_msg,
@@ -245,6 +249,9 @@ export default {
245249
width: 64rpx;
246250
height: 64rpx;
247251
}
252+
.name{
253+
margin-left: 20rpx;
254+
}
248255
}
249256
.list {
250257
display: flex;

src/pages/notice/index.vue

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
<login :visible='visible' v-on:modalClose='closeModalEvent'></login>
44
<div class='body'>
55
<div class='tabs'>
6-
<div :class='{selected:tab==="unread"}' @click.stop='changeTab($event)' data-tab='unread'>未读消息</div>
6+
<div :class='{selected:tab==="unread"}' @click.stop='changeTab($event)' data-tab='unread'>未读消息:{{unread.length}}</div>
77
<div :class='{selected:tab==="read"}' @click.stop='changeTab($event)' data-tab='read'>已读消息</div>
88
</div>
99
<div>
10+
<button v-show="tab==='unread'" class='read-all' @click.stop='readAll'>一键已读</button>
1011
<div class='notice' v-for='item in currentData' :key='item.id' :data-id='item.id'>
1112
<div>
1213
{{item.author.loginname}}在<span style='color:$color;' @click.stop='goDetail($event)' :data-topicid='item.topic.id'>{{item.topic.title}}</span>回复了你
@@ -78,6 +79,19 @@ export default {
7879
}
7980
},
8081
methods: {
82+
async readAll() {
83+
const accesstoken = wx.getStorageSync("accesstoken");
84+
const res = await this.$http.post(`${api}/message/mark_all`, {
85+
accesstoken
86+
});
87+
if (res.data.success) {
88+
wx.showToast({
89+
title: "全部已读成功",
90+
icon: "none",
91+
duration: 2000
92+
});
93+
}
94+
},
8195
closeModalEvent() {
8296
this.visible = false;
8397
this.getData();
@@ -132,6 +146,18 @@ export default {
132146
margin: 10rpx 0;
133147
}
134148
}
149+
.read-all {
150+
color: $color;
151+
border: 2rpx solid $color;
152+
font-size: 20rpx;
153+
width: 99rpx;
154+
border-radius: 20rpx;
155+
height: 46rpx;
156+
line-height: 46rpx;
157+
text-align: center;
158+
padding: 0;
159+
margin: 10rpx;
160+
}
135161
}
136162
}
137163
.selected {

src/pages/publish/index.vue

Lines changed: 69 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -5,34 +5,55 @@
55
<span>标题:</span>
66
<input class='input' type="text" placeholder="最少10个字" v-model="title">
77
</div>
8-
<picker class='picker' @change="bindPickerChange($event)" :value="index" :range="pickerData">
9-
<span>选择主题:</span><span style='margin-left:400rpx;'>{{pickerData[index]}}</span>
10-
</picker>
11-
<textarea class='textarea' v-model="content" ></textarea>
8+
<picker class='picker' @change="bindPickerChange($event)" :value="index" :range="pickerData">
9+
<span>选择主题:</span><span style='margin-left:400rpx;'>{{pickerData[index]}}</span>
10+
</picker>
11+
<div class='tabs'>
12+
<div :class='{selected:tab==="markdown"}' @click.stop='changeTab($event)' data-tab='markdown'>markdown</div>
13+
<div :class='{selected:tab==="preview"}' @click.stop='changeTab($event)' data-tab='preview'>预览</div>
14+
</div>
15+
<textarea v-show="tab==='markdown'" class='textarea' v-model="content"></textarea>
16+
<div v-show="tab==='preview'" style="min-height:500rpx;background-color:white;margin-top:-20rpx;margin-bottom:30rpx;">
17+
<wemark mdData='bug待修复'></wemark>
18+
</div>
1219
<button @click.stop="handle">发帖</button>
1320
</div>
1421
</template>
22+
1523
<script>
1624
import login from "../../components/login";
25+
//import wemark from "mpvue-wemark";
26+
import wemark from "mpvue-wemark";
1727
import { api } from "../../const";
1828
export default {
1929
components: {
20-
login
30+
login,
31+
wemark
32+
},
33+
34+
watch: {
35+
content(next) {
36+
console.log(next);
37+
}
2138
},
2239
data() {
2340
return {
2441
pickerData: ["提问", "招聘", "分享", "开发"],
2542
index: "3",
2643
title: "",
2744
content: "",
28-
visible: false
45+
visible: false,
46+
tab: "markdown" // or preview
2947
};
3048
},
3149
methods: {
3250
bindPickerChange(e) {
3351
// console.log(e)
3452
this.index = e.mp.detail.value;
3553
},
54+
changeTab(e) {
55+
this.tab = e.target.dataset.tab;
56+
},
3657
async handle() {
3758
const trans = ["ask", "job", "share", "dev"];
3859
const accesstoken = wx.getStorageSync("accesstoken");
@@ -72,38 +93,52 @@ export default {
7293
}
7394
};
7495
</script>
96+
7597
<style lang='scss' scoped>
7698
.container {
7799
height: 100vh;
78100
background-color: rgb(245, 245, 249);
101+
.list {
102+
display: flex;
103+
justify-content: space-between;
104+
background-color: white;
105+
margin-bottom: 30rpx;
106+
height: 90rpx;
107+
padding: 0 30rpx;
108+
line-height: 90rpx;
109+
.input {
110+
height: 90rpx;
111+
line-height: 90rpx;
112+
}
113+
}
114+
.picker {
115+
display: flex;
116+
justify-content: space-between;
117+
background-color: white;
118+
margin-bottom: 30rpx;
119+
height: 90rpx;
120+
line-height: 90rpx;
121+
padding: 0 30rpx;
122+
}
123+
.tabs {
124+
display: flex;
125+
background-color: white;
126+
& > div {
127+
width: 50%;
128+
text-align: center;
129+
}
130+
}
131+
.textarea {
132+
width: 100%;
133+
background-color: white;
134+
margin-bottom: 30rpx;
135+
height: 500rpx;
136+
padding: 0 30rpx;
137+
box-sizing: border-box;
138+
}
79139
}
80-
.list {
81-
display: flex;
82-
justify-content: space-between;
83-
background-color: white;
84-
margin-bottom: 30rpx;
85-
height: 90rpx;
86-
padding: 0 30rpx;
87-
line-height: 90rpx;
88-
}
89-
.picker {
90-
display: flex;
91-
justify-content: space-between;
92-
background-color: white;
93-
margin-bottom: 30rpx;
94-
height: 90rpx;
95-
line-height: 90rpx;
96-
padding: 0 30rpx;
97-
}
98-
.input {
99-
height: 90rpx;
100-
line-height: 90rpx;
101-
}
102-
.textarea {
103-
width: 100%;
104-
background-color: white;
105-
margin-bottom: 30rpx;
106-
height: 500rpx;
107-
padding: 0 30rpx;
140+
.selected {
141+
color: $color;
142+
border-bottom: 2rpx solid $color;
108143
}
109144
</style>

0 commit comments

Comments
 (0)