MessagePop.vue
4.43 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
<template>
<uni-popup ref="popup" type="bottom" border-radius="16px" :mask-click="false">
<view class="kf-box" :class="{'system-height': type=='system'}">
<template v-if="type=='attendance'">
<image class="message-bg" :src="require('@//assets/images/common/message-bg.webp')"></image>
<view class="text text-first">本周优秀话术推送</view>
<view class="text">你有{{messageData.total}}条消息待查看</view>
<view class="btn" @click="toMessage">去查看</view>
</template>
<!-- 当前有 3 个学习任务待完成,请及时处理。
坚持学习助您能力提升! -->
<template v-else-if="type=='study'">
<image class="message-bg" :src="require('@//assets/images/common/study-center-bg.webp')"></image>
<view class="text text-first study-title">学习提醒</view>
<view class="text study-text">当前有{{messageData.count}}个学习任务待完成,请及时处理。</view>
<view class="text study-text">坚持学习助您能力提升!</view>
<view class="btn study-btn" @click="jumpStudyCenter">去查看</view>
</template>
<template v-else-if="type=='system'">
<image class="message-bg" :src="require('@//assets/images/common/system-bg.webp')"></image>
<view class="text text-first study-title">系统消息</view>
<view class="text study-text">
您有新的消息【
{{ messageData.title && messageData.title.length > 8 ? messageData.title.slice(0, 8) + '...' : messageData.title }}
】,请点击查看
</view>
<view class="text study-text"></view>
<view class="btn study-btn" @click="jumpSystem">去查看</view>
</template>
</view>
</uni-popup>
</template>
<script type='text/ecmascript-6'>
export default {
name: 'MessagePop',
props: {
messageData: Object,
type: String,
},
data() {
return {
}
},
inject: ['showPage'],
mounted() {
},
methods: {
open() {
this.$refs.popup.open("center");
},
close() {
this.$refs.popup.close()
},
toMessage() {
const {messageData} = this
this.showPage('MessageDetail', {...messageData, type: 'read'})
this.close()
},
jumpStudyCenter() {
uni.$emit('studyCenter')
this.close()
},
jumpSystem() {
try {
this.getDetailById(this.messageData.businessIds[0])
} catch (e) {
uni.showToast({
title: '系统消息跳转失败',
icon: 'none'
})
this.close()
throw e
}
this.close()
},
async getDetailById(id) {
const res = await uni.$api.commonApi.getTaskById({ id })
const _row = encodeURIComponent(JSON.stringify(res))
if (res.contentType == 1) {
uni.navigateTo({
url: `/pages/common/systemDetail?row=${_row}`
})
} else if (res.contentType == 2) {
console.log(JSON.parse(res.content))
const _content = res.content ? JSON.parse(res.content) : []
const url = _content[0]
const { content, title, id } = res
uni.navigateTo({
// url: `/pages/common/msgwebview?url=${url}&title=${title}&id=${id}`
url: `/pages/common/imgPreview?tabName=${title}&sourceType=2&detailUrl=${url}&row=${_row}`
})
} else if (res.contentType == 3) {
const _content = res.content ? JSON.parse(res.content) : []
console.log(_content, 'res.contentType == 3')
const url = _content[0].image
const { content, title, id } = res
uni.navigateTo({
url: `/pages/common/msgwebview?fileUrl=${url}&title=${title}&id=${id}&row=${_row}`
})
}
},
}
}
</script>
<style scoped lang='scss'>
.kf-box {
position: relative;
width: toRpx(848);
height: toRpx(720);
background: #ffffff;
border-radius: toRpx(48);
// padding: 0 toRpx(48);
box-sizing: border-box;
&.system-height {
height: toRpx(664);
}
.message-bg {
width: toRpx(848);
height: toRpx(346);
border-radius: toRpx(48);
}
.text {
text-align: center;
color: #333333;
font-size: toRpx(32);
line-height: toRpx(64);
&.text-first {
margin-top: toRpx(40);
}
&.study-text {
line-height: toRpx(48);
}
&.study-title {
font-weight: 500;
font-size: toRpx(40);
margin-top: toRpx(30);
}
}
.btn {
margin: toRpx(70) auto;
width: toRpx(784);
height: toRpx(80);
border-radius: toRpx(48);
opacity: 1;
background: linear-gradient(0deg, #2c66f7 0%, #48a6ff 100%);
color: #ffffff;
font-size: toRpx(28);
font-weight: 500;
text-align: center;
line-height: toRpx(80);
&.study-btn {
margin: toRpx(48) auto;
}
}
}
</style>