more-action-sheet.vue
3.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
<template>
<YohoActionSheet :transfer="transfer" class="more-action-sheet" ref="actionSheet">
<div class="action-wrap">
<div class="action-list">
<div class="action-item" v-for="(i, index) in list" :key="index" v-show="!i.hide" @click="onClick(i.fnName)">
<p class="icon">
<span class="iconfont" :class="i.icon"></span>
</p>
<p class="name">{{i.name}}</p>
</div>
</div>
<div class="cancel" @click="hide">取消</div>
</div>
</YohoActionSheet>
</template>
<script>
import {createNamespacedHelpers} from 'vuex';
const articleStore = createNamespacedHelpers('article');
const userStore = createNamespacedHelpers('user');
export default {
name: 'MoreActionSheetPage',
props: {
transfer: Boolean
},
data() {
return {
list: [
{
icon: 'icon-fav-cancel',
name: '取消关注',
fnName: 'actionCancelFav'
},
{
icon: 'icon-warn',
name: '举报',
fnName: 'actionrReport'
},
{
icon: 'icon-delete',
name: '删除',
fnName: 'actionDelete'
}
]
};
},
methods: {
...articleStore.mapActions(['reportArticle', 'deleteArticle']),
...userStore.mapActions(['followUser']),
show(params, uid, index) {
this.index = index;
params = params || {};
this.list[0].hide = params.hasAttention !== 'Y';
this.list[2].hide = params.authorUid !== uid || params.authorType !== 1;
this.list = [...this.list];
this._params = params;
this.$refs.actionSheet.show();
},
hide() {
this.$refs.actionSheet.hide();
},
actionrReport() {
this.$createToast({
txt: '举报成功',
type: 'correct',
time: 1000
}).show();
this.reportArticle(this._params);
},
actionCancelFav() {
let {authorUid, authorType} = this._params;
return this.$emit('on-follow', this._params);
this.followUser({
followUid: authorUid,
status: false,
authorType
}).then(res => {
if (res.code === 200) {
this.$emit('on-follow', this._params);
}
});
},
actionDelete() {
this.$createDialog({
type: 'confirm',
title: '确认删除该文章?',
confirmBtn: {
text: '确定',
active: true,
disabled: false,
href: 'javascript:;'
},
cancelBtn: {
text: '取消',
active: false,
disabled: false,
href: 'javascript:;'
},
onConfirm: () => {
this.deleteArticle(this._params).then(res => {
if (res.code === 200) {
this.$emit('on-delete', this.index);
} else {
this.$createToast({
type: 'warn',
time: 1000,
txt: '删除失败了'
}).show();
}
});
}
}).show()
},
onClick(name) {
this[name] && this[name]();
this.hide();
}
}
};
</script>
<style scoped lang="scss">
/deep/ .yoho-popup {
&:after,
> .yoho-popup-container {
background-color: rgba(255, 255, 255, 0.9);
}
}
.action-wrap {
color: #444;
.action-list {
width: 100%;
padding: 20px 40px;
border-bottom: 1PX solid #d7d7d7;
display: flex;
justify-content: space-around;
}
.action-item {
width: 128px;
padding: 12px 0;
.icon {
width: 88px;
height: 88px;
line-height: 92px;
border-radius: 50%;
margin: 0 auto 16px;
background-color: #fff;
text-align: center;
overflow: hidden;
}
.iconfont {
font-size: 48px;
color: #b0b0b0;
}
.name {
font-size: 24px;
text-align: center;
transform: scale(0.9, 0.9);
opacity: 0.65;
}
}
.cancel {
line-height: 88px;
font-size: 32px;
letter-spacing: 0.05px;
text-align: center;
}
}
</style>