2020-06-11 08:43:51 +08:00
|
|
|
|
<template>
|
|
|
|
|
<view>
|
|
|
|
|
<u-navbar :is-back="false" :title-size="36" title="消息">
|
|
|
|
|
<view class="slot-wrap">
|
2020-07-09 16:35:23 +08:00
|
|
|
|
<image src="../../static/pageD/info(3).png" @click="delMessage()"></image>
|
2020-08-11 10:25:41 +08:00
|
|
|
|
<image src="../../static/pageD/info(2).png" @click="kefu()"></image>
|
2020-06-11 08:43:51 +08:00
|
|
|
|
</view>
|
|
|
|
|
</u-navbar>
|
|
|
|
|
<view class="content">
|
|
|
|
|
<!-- 正文内容 -->
|
|
|
|
|
</view>
|
2020-08-04 19:39:31 +08:00
|
|
|
|
<!-- <view class="sousuo"></view> -->
|
2020-08-11 09:36:03 +08:00
|
|
|
|
<view class="backes" style="border-bottom: 1px #ececec solid;">
|
2020-07-09 16:35:23 +08:00
|
|
|
|
<titles :information="information_dles"></titles>
|
2020-06-11 08:43:51 +08:00
|
|
|
|
</view>
|
|
|
|
|
<!-- 消息通知 -->
|
|
|
|
|
<view class="backes">
|
|
|
|
|
<view id="information">
|
2020-08-06 10:40:26 +08:00
|
|
|
|
<view class="information_dl" v-for="(item,index) in information_dl" :key="index" @click="gochat(item)" >
|
2020-06-11 08:43:51 +08:00
|
|
|
|
<view>
|
2020-08-05 17:00:04 +08:00
|
|
|
|
<image :src="item.avatar"></image>
|
2020-06-11 08:43:51 +08:00
|
|
|
|
</view>
|
2020-08-05 17:00:04 +08:00
|
|
|
|
<view class="title">{{item.name}}</view>
|
2020-08-06 15:57:56 +08:00
|
|
|
|
<view class="contentes u-line-1">{{item.text}}</view>
|
2020-08-05 17:00:04 +08:00
|
|
|
|
<view class="times">{{item.time}}</view>
|
2020-08-07 16:54:54 +08:00
|
|
|
|
<view class="tishi" v-if="item.unReadMessage"></view>
|
|
|
|
|
|
2020-06-11 08:43:51 +08:00
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
2020-07-09 16:35:23 +08:00
|
|
|
|
<u-toast ref="uToast" />
|
2020-06-11 08:43:51 +08:00
|
|
|
|
</view>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
2020-08-05 21:06:29 +08:00
|
|
|
|
import { mapState } from 'vuex';
|
2020-06-15 15:31:31 +08:00
|
|
|
|
import titles from "@/components/informations/titles/titles"
|
2020-06-11 08:43:51 +08:00
|
|
|
|
export default {
|
2020-08-05 21:06:29 +08:00
|
|
|
|
computed: {
|
|
|
|
|
...mapState(["hasLogin,token"])
|
|
|
|
|
},
|
2020-06-11 08:43:51 +08:00
|
|
|
|
data() {
|
|
|
|
|
return {
|
2020-07-09 16:35:23 +08:00
|
|
|
|
information_dles : [{
|
|
|
|
|
id: 0,
|
|
|
|
|
url: '../../static/pageD/info(11).png',
|
|
|
|
|
text: '公告/资讯'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: 0,
|
2020-08-04 19:08:04 +08:00
|
|
|
|
url: '../../static/pageD/info(13).png',
|
2020-07-09 16:35:23 +08:00
|
|
|
|
text: '活动消息'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: 0,
|
|
|
|
|
url: '../../static/pageD/info(14).png',
|
|
|
|
|
text: '交易物流'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: 0,
|
|
|
|
|
url: '../../static/pageD/info(15).png',
|
|
|
|
|
text: '关注消息'
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
],
|
2020-06-11 08:43:51 +08:00
|
|
|
|
// 通知消息
|
2020-08-04 10:41:54 +08:00
|
|
|
|
information_dl: [
|
|
|
|
|
{
|
2020-06-11 08:43:51 +08:00
|
|
|
|
id: 0,
|
|
|
|
|
url: '../../static/pageD/info(11).png',
|
2020-06-15 15:31:31 +08:00
|
|
|
|
text: '通知消息',
|
|
|
|
|
contentes: '亲,您购物车中的 [新鲜盆栽] 降价4.00元。',
|
|
|
|
|
title: '2020-7-21'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: 1,
|
|
|
|
|
url: '../../static/pageD/info(11).png',
|
|
|
|
|
text: '通知消息',
|
|
|
|
|
contentes: '亲,您购物车中的 [新鲜盆栽] 降价4.00元。',
|
|
|
|
|
title: '2020-7-21'
|
2020-06-11 08:43:51 +08:00
|
|
|
|
},
|
|
|
|
|
{
|
2020-06-15 15:31:31 +08:00
|
|
|
|
id: 2,
|
|
|
|
|
url: '../../static/pageD/info(11).png',
|
|
|
|
|
text: '通知消息',
|
|
|
|
|
contentes: '亲,您购物车中的 [新鲜盆栽] 降价4.00元。',
|
|
|
|
|
title: '2020-7-21'
|
|
|
|
|
},
|
|
|
|
|
|
2020-06-11 08:43:51 +08:00
|
|
|
|
],
|
|
|
|
|
value: '',
|
|
|
|
|
login: '登录',
|
|
|
|
|
show: false
|
|
|
|
|
};
|
|
|
|
|
},
|
2020-08-05 17:00:04 +08:00
|
|
|
|
onShow(){
|
|
|
|
|
this.information_dl = this.imService.friends;
|
|
|
|
|
this.imService.onFriendListChange=this.onFriendListChange;
|
|
|
|
|
},
|
2020-07-09 16:35:23 +08:00
|
|
|
|
onLoad() {
|
|
|
|
|
// /消息模块的请求
|
2020-08-05 21:11:32 +08:00
|
|
|
|
if (this.hasLogin) {
|
|
|
|
|
this.messageIndex();
|
|
|
|
|
}
|
2020-08-07 11:40:13 +08:00
|
|
|
|
|
2020-07-09 16:35:23 +08:00
|
|
|
|
},
|
2020-06-11 08:43:51 +08:00
|
|
|
|
methods: {
|
2020-08-11 10:25:41 +08:00
|
|
|
|
kefu(){
|
|
|
|
|
if(!this.$store.state.hasLogin){
|
|
|
|
|
this.$refs.uToast.show({
|
|
|
|
|
title: "请先登录",
|
|
|
|
|
type: 'warning'
|
|
|
|
|
})
|
|
|
|
|
}else{
|
|
|
|
|
function Friend(uuid, name, avatar,time = "", text = "",date = "") {
|
|
|
|
|
this.uuid = uuid;
|
|
|
|
|
this.name = name;
|
|
|
|
|
this.avatar = avatar;
|
|
|
|
|
this.online = false;
|
|
|
|
|
this.unReadMessage = 0;
|
|
|
|
|
this.text = text;
|
|
|
|
|
this.time = time;
|
|
|
|
|
this.date = date
|
|
|
|
|
}
|
|
|
|
|
const token = uni.getStorageSync('token');
|
|
|
|
|
let that = this
|
|
|
|
|
uni.request({
|
|
|
|
|
url:"https://dmmall.sdbairui.com/api/Specialci/getAtwillUserInfo",
|
|
|
|
|
data:{
|
|
|
|
|
userId: 1
|
|
|
|
|
},
|
|
|
|
|
method:"POST",
|
|
|
|
|
header:{
|
|
|
|
|
"Authorization" : 'Bearer' + " " + token
|
|
|
|
|
},
|
|
|
|
|
success(res){
|
|
|
|
|
console.log(res)
|
|
|
|
|
res = res.data
|
|
|
|
|
let user = new Friend(res.data.member_id,res.data.member_nickname,res.data.member_avatar)
|
|
|
|
|
that.$u.route({
|
|
|
|
|
url:"/pageD/privateChat/privateChat",
|
|
|
|
|
params:{
|
|
|
|
|
id:JSON.stringify(user)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
},
|
2020-08-06 10:40:26 +08:00
|
|
|
|
gochat(id){
|
|
|
|
|
this.$u.route({
|
|
|
|
|
url:"/pageD/privateChat/privateChat",
|
|
|
|
|
params:{
|
|
|
|
|
id:JSON.stringify(id)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
|
},
|
2020-08-05 17:00:04 +08:00
|
|
|
|
onFriendListChange(onlineFriends) {
|
|
|
|
|
//todo:比较垃圾的处理方式,因为Uniapp的基于MAP的双向绑定在H5端不稳定,H5端偶尔会抽风
|
|
|
|
|
// 下边这一行删掉,有时候页面可以更新,有时候不行,大家有优雅的方式,也欢迎跟我们沟通
|
2020-08-06 15:57:56 +08:00
|
|
|
|
console.log(onlineFriends,121212)
|
|
|
|
|
this.information_dl = onlineFriends;
|
2020-08-05 17:00:04 +08:00
|
|
|
|
|
|
|
|
|
this.$forceUpdate();
|
|
|
|
|
},
|
2020-06-11 08:43:51 +08:00
|
|
|
|
// 选中某个复选框时,由checkbox时触发
|
|
|
|
|
checkboxChange(e) {
|
|
|
|
|
//console.log(e);
|
|
|
|
|
},
|
|
|
|
|
// 选中任一checkbox时,由checkbox-group触发
|
|
|
|
|
checkboxGroupChange(e) {
|
|
|
|
|
// console.log(e);
|
|
|
|
|
},
|
|
|
|
|
mask_u() {
|
|
|
|
|
this.show = !this.show
|
|
|
|
|
},
|
2020-07-09 16:35:23 +08:00
|
|
|
|
// 消息模块的读取
|
|
|
|
|
messageIndex(){
|
|
|
|
|
console.log("消息模块的读取消息模块的读取消息模块的读取")
|
|
|
|
|
this.$u.api.messageIndex({}).then((res)=>{
|
|
|
|
|
console.log(res)
|
|
|
|
|
let data = res.data.allMessages;
|
|
|
|
|
for(let i in data){
|
|
|
|
|
var type = data[i].type;
|
|
|
|
|
console.log(data[i].type)
|
|
|
|
|
var array = []
|
|
|
|
|
array.push(type)
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
console.log( array)
|
|
|
|
|
// 获取到字段的类型 添加到数据中心
|
|
|
|
|
for(let j = 0; j < this.information_dles.length; j++ ){
|
|
|
|
|
console.log()
|
|
|
|
|
// this.information_dles[j].type = type;
|
|
|
|
|
for(let k = 0; k < array.length; k++ ){
|
|
|
|
|
this.information_dles[j].type = array[k];
|
|
|
|
|
console.log( array[k])
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
console.log(this.information_dles)
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
// 清空消息
|
|
|
|
|
delMessage(){
|
2020-08-07 17:37:23 +08:00
|
|
|
|
|
2020-07-09 16:35:23 +08:00
|
|
|
|
this.$u.api.delMessage({
|
|
|
|
|
type : "all"
|
|
|
|
|
}).then((res)=>{
|
|
|
|
|
console.log(res)
|
2020-08-07 17:37:23 +08:00
|
|
|
|
this.imService.friends = {};
|
|
|
|
|
this.information_dl = [];
|
|
|
|
|
uni.setStorageSync('imlist',JSON.stringify([]));
|
2020-07-09 16:35:23 +08:00
|
|
|
|
if(res.errCode == 0){
|
|
|
|
|
this.$refs.uToast.show({
|
|
|
|
|
title: '清除成功',
|
|
|
|
|
type: 'success'
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
2020-06-15 15:31:31 +08:00
|
|
|
|
|
2020-06-11 08:43:51 +08:00
|
|
|
|
},
|
2020-06-15 15:31:31 +08:00
|
|
|
|
components: {
|
2020-06-11 08:43:51 +08:00
|
|
|
|
titles,
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
2020-08-07 16:54:54 +08:00
|
|
|
|
.tishi{
|
|
|
|
|
position: absolute;
|
|
|
|
|
bottom: 30rpx;
|
|
|
|
|
right: 30rpx;
|
|
|
|
|
width: 12rpx;
|
|
|
|
|
height: 12rpx;
|
|
|
|
|
border-radius: 50%;
|
|
|
|
|
background-color: #FF0000;
|
|
|
|
|
}
|
2020-06-11 08:43:51 +08:00
|
|
|
|
.sousuo {
|
|
|
|
|
height: 113rpx;
|
|
|
|
|
border: 1px #f00 solid;
|
|
|
|
|
}
|
2020-06-15 15:31:31 +08:00
|
|
|
|
|
2020-06-11 08:43:51 +08:00
|
|
|
|
.slot-wrap {
|
2020-06-15 15:31:31 +08:00
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
|
|
|
|
/* 如果您想让slot内容占满整个导航栏的宽度 */
|
|
|
|
|
/* flex: 1; */
|
|
|
|
|
/* 如果您想让slot内容与导航栏左右有空隙 */
|
|
|
|
|
/* padding: 0 30rpx; */
|
|
|
|
|
image {
|
|
|
|
|
width: 60rpx;
|
|
|
|
|
height: 60rpx;
|
|
|
|
|
position: absolute;
|
|
|
|
|
right: 90rpx;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
image:nth-child(2) {
|
|
|
|
|
width: 34rpx;
|
|
|
|
|
height: 40rpx;
|
|
|
|
|
position: absolute;
|
|
|
|
|
right: 30rpx;
|
2020-06-11 08:43:51 +08:00
|
|
|
|
}
|
2020-06-15 15:31:31 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.backes {
|
2020-06-11 08:43:51 +08:00
|
|
|
|
background: #fff;
|
|
|
|
|
margin-bottom: 10rpx;
|
|
|
|
|
}
|
2020-06-15 15:31:31 +08:00
|
|
|
|
|
|
|
|
|
.information_dl {
|
2020-06-11 08:43:51 +08:00
|
|
|
|
width: 710rpx;
|
|
|
|
|
margin: 0 auto;
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
zoom: 1;
|
|
|
|
|
position: relative;
|
|
|
|
|
padding-bottom: 23rpx;
|
|
|
|
|
border-bottom: 1px #ececec solid;
|
|
|
|
|
padding: 20rpx 5rpx 23rpx 5rpx;
|
2020-08-07 16:54:54 +08:00
|
|
|
|
position: relative;
|
2020-06-15 15:31:31 +08:00
|
|
|
|
|
|
|
|
|
image {
|
2020-06-11 08:43:51 +08:00
|
|
|
|
width: 84rpx;
|
|
|
|
|
height: 84rpx;
|
|
|
|
|
margin-right: 16rpx;
|
|
|
|
|
}
|
2020-06-15 15:31:31 +08:00
|
|
|
|
|
|
|
|
|
view {
|
2020-06-11 08:43:51 +08:00
|
|
|
|
float: left;
|
|
|
|
|
display: block;
|
|
|
|
|
}
|
2020-06-15 15:31:31 +08:00
|
|
|
|
|
|
|
|
|
.title {
|
2020-06-11 08:43:51 +08:00
|
|
|
|
font-size: 30rpx;
|
|
|
|
|
color: #333;
|
|
|
|
|
width: 600rpx;
|
|
|
|
|
margin-bottom: 15rpx;
|
|
|
|
|
margin-top: 9rpx;
|
|
|
|
|
}
|
2020-06-15 15:31:31 +08:00
|
|
|
|
|
|
|
|
|
.contentes {
|
2020-06-11 08:43:51 +08:00
|
|
|
|
font-size: 20rpx;
|
|
|
|
|
color: #999;
|
|
|
|
|
width: 600rpx;
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-06-15 15:31:31 +08:00
|
|
|
|
|
|
|
|
|
.times {
|
2020-06-11 08:43:51 +08:00
|
|
|
|
position: absolute;
|
|
|
|
|
top: 30rpx;
|
|
|
|
|
right: 0;
|
|
|
|
|
color: #333333;
|
2020-06-15 15:31:31 +08:00
|
|
|
|
font-size: 20rpx;
|
2020-06-11 08:43:51 +08:00
|
|
|
|
}
|
2020-06-15 15:31:31 +08:00
|
|
|
|
|
|
|
|
|
uni-page-wrapper {}
|
|
|
|
|
|
2020-06-11 08:43:51 +08:00
|
|
|
|
page {
|
2020-06-15 15:31:31 +08:00
|
|
|
|
background: #ececec !important;
|
2020-06-11 08:43:51 +08:00
|
|
|
|
}
|
|
|
|
|
</style>
|