mp:解决 wx-msg 的 css 问题

This commit is contained in:
YunaiV 2023-01-09 12:20:31 +08:00
parent cc23ca2dcc
commit 9e4a978f85
5 changed files with 239 additions and 145 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@ -0,0 +1,86 @@
.avue-card{
&__item{
margin-bottom: 16px;
border: 1px solid #e8e8e8;
background-color: #fff;
box-sizing: border-box;
color: rgba(0,0,0,.65);
font-size: 14px;
font-variant: tabular-nums;
line-height: 1.5;
list-style: none;
font-feature-settings: "tnum";
cursor: pointer;
height:200px;
&:hover{
border-color: rgba(0,0,0,.09);
box-shadow: 0 2px 8px rgba(0,0,0,.09);
}
&--add{
border:1px dashed #000;
width: 100%;
color: rgba(0,0,0,.45);
background-color: #fff;
border-color: #d9d9d9;
border-radius: 2px;
display: flex;
align-items: center;
justify-content: center;
font-size: 16px;
i{
margin-right: 10px;
}
&:hover{
color: #40a9ff;
background-color: #fff;
border-color: #40a9ff;
}
}
}
&__body{
display: flex;
padding: 24px;
}
&__detail{
flex:1
}
&__avatar{
width: 48px;
height: 48px;
border-radius: 48px;
overflow: hidden;
margin-right: 12px;
img{
width: 100%;
height: 100%;
}
}
&__title{
color: rgba(0,0,0,.85);
margin-bottom: 12px;
font-size: 16px;
&:hover{
color:#1890ff;
}
}
&__info{
color: rgba(0,0,0,.45);
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 3;
overflow: hidden;
height: 64px;
}
&__menu{
display: flex;
justify-content:space-around;
height: 50px;
background: #f7f9fa;
color: rgba(0,0,0,.45);
text-align: center;
line-height: 50px;
&:hover{
color:#1890ff;
}
}
}

View File

@ -0,0 +1,88 @@
/* 来自 https://github.com/nmxiaowei/avue/blob/master/styles/src/element-ui/comment.scss */
.avue-comment{
margin-bottom: 30px;
display: flex;
align-items: flex-start;
&--reverse{
flex-direction:row-reverse;
.avue-comment__main{
&:before,&:after{
left: auto;
right: -8px;
border-width: 8px 0 8px 8px;
}
&:before{
border-left-color: #dedede;
}
&:after{
border-left-color: #f8f8f8;
margin-right: 1px;
margin-left: auto;
}
}
}
&__avatar{
width: 48px;
height: 48px;
border-radius: 50%;
border: 1px solid transparent;
box-sizing: border-box;
vertical-align: middle;
}
&__header{
padding: 5px 15px;
background: #f8f8f8;
border-bottom: 1px solid #eee;
display: flex;
align-items: center;
justify-content: space-between;
}
&__author{
font-weight: 700;
font-size: 14px;
color: #999;
}
&__main{
flex:1;
margin: 0 20px;
position: relative;
border: 1px solid #dedede;
border-radius: 2px;
&:before,&:after{
position: absolute;
top: 10px;
left: -8px;
right: 100%;
width: 0;
height: 0;
display: block;
content: " ";
border-color: transparent;
border-style: solid solid outset;
border-width: 8px 8px 8px 0;
pointer-events: none;
}
&:before {
border-right-color: #dedede;
z-index: 1;
}
&:after{
border-right-color: #f8f8f8;
margin-left: 1px;
z-index: 2;
}
}
&__body{
padding: 15px;
overflow: hidden;
background: #fff;
font-family: Segoe UI,Lucida Grande,Helvetica,Arial,Microsoft YaHei,FreeSans,Arimo,Droid Sans,wenquanyi micro hei,Hiragino Sans GB,Hiragino Sans GB W3,FontAwesome,sans-serif;color: #333;
font-size: 14px;
}
blockquote{
margin:0;
font-family: Georgia,Times New Roman,Times,Kai,Kaiti SC,KaiTi,BiauKai,FontAwesome,serif;
padding: 1px 0 1px 15px;
border-left: 4px solid #ddd;
}
}

View File

@ -1,9 +1,12 @@
<!-- <!--
- Copyright (C) 2018-2019 - Copyright (C) 2018-2019
- All rights reserved, Designed By www.joolun.com - All rights reserved, Designed By www.joolun.com
芋道源码
移除暂时用不到的 websocket
代码优化补充注释提升阅读性
--> -->
<template> <template>
<div class="msg-main" v-loading="mainLoading"> <div class="msg-main">
<div class="msg-div" :id="'msg-div' + nowStr"> <div class="msg-div" :id="'msg-div' + nowStr">
<!-- 加载更多 --> <!-- 加载更多 -->
<div v-loading="tableLoading"></div> <div v-loading="tableLoading"></div>
@ -15,9 +18,8 @@
<div class="execution" v-for="item in tableData" :key='item.id'> <div class="execution" v-for="item in tableData" :key='item.id'>
<div class="avue-comment" :class="item.sendFrom === 2 ? 'avue-comment--reverse' : ''"> <div class="avue-comment" :class="item.sendFrom === 2 ? 'avue-comment--reverse' : ''">
<div class="avatar-div"> <div class="avatar-div">
<img :src="item.sendFrom === 1 ? item.headimgUrl : item.appLogo" class="avue-comment__avatar"> <img :src="item.sendFrom === 1 ? user.avatar : mp.avatar" class="avue-comment__avatar">
<!-- <div class="avue-comment__author">{{item.sendFrom === 1 ? item.nickName : item.appName}}</div>--> <div class="avue-comment__author">{{item.sendFrom === 1 ? user.nickname : mp.nickname }}</div>
<div class="avue-comment__author">{{item.sendFrom === 1 ? '用户' : '公众号' }}</div>
</div> </div>
<div class="avue-comment__main"> <div class="avue-comment__main">
<div class="avue-comment__header"> <div class="avue-comment__header">
@ -62,6 +64,7 @@
</el-link> </el-link>
<div class="avue-card__info" style="height: unset">{{item.description}}</div> <div class="avue-card__info" style="height: unset">{{item.description}}</div>
</div> </div>
<!-- TODO 芋艿待完善 -->
<!-- <div v-if="item.repType == 'location'">--> <!-- <div v-if="item.repType == 'location'">-->
<!-- <el-link type="primary" target="_blank" :href="'https://map.qq.com/?type=marker&isopeninfowin=1&markertype=1&pointx='+item.repLocationY+'&pointy='+item.repLocationX+'&name='+item.repContent+'&ref=joolun'">--> <!-- <el-link type="primary" target="_blank" :href="'https://map.qq.com/?type=marker&isopeninfowin=1&markertype=1&pointx='+item.repLocationY+'&pointy='+item.repLocationX+'&name='+item.repContent+'&ref=joolun'">-->
<!-- <img :src="'https://apis.map.qq.com/ws/staticmap/v2/?zoom=10&markers=color:blue|label:A|'+item.repLocationX+','+item.repLocationY+'&key='+qqMapKey+'&size=250*180'">--> <!-- <img :src="'https://apis.map.qq.com/ws/staticmap/v2/?zoom=10&markers=color:blue|label:A|'+item.repLocationX+','+item.repLocationY+'&key='+qqMapKey+'&size=250*180'">-->
@ -118,28 +121,25 @@
}, },
data() { data() {
return { return {
nowStr: new Date().getTime(), nowStr: new Date().getTime(), // :id="'msg-div' + nowStr"
objData:{ objData:{
repType: 'text' repType: 'text'
}, },
mainLoading:false, sendLoading: false, //
sendLoading:false, tableLoading: false, //
tableLoading:false, loadMore: true, //
loadMore: true,
tableData: [], // tableData: [], //
page: { page: {
total: 0, //
pageNo: 1, // pageNo: 1, //
pageSize: 14, // pageSize: 14, //
ascs:[],//
descs:'create_time'//
}, },
option: { user: { // 使
props: { nickname: '用户',
avatar: 'avatar', avatar: require("@/assets/images/profile.jpg"),
author: 'author', },
body: 'body' mp: {
} nickname: '公众号',
avatar: require("@/assets/images/wechat.png"),
} }
} }
}, },
@ -149,7 +149,7 @@
methods:{ methods:{
sendMsg(){ sendMsg(){
if (this.objData) { if (this.objData) {
if(this.objData.repType == 'news'){ if(this.objData.repType === 'news'){
this.objData.content.articles = [this.objData.content.articles[0]] this.objData.content.articles = [this.objData.content.articles[0]]
this.$message({ this.$message({
showClose: true, showClose: true,
@ -173,12 +173,6 @@
}) })
} }
}, },
scrollToBottom: function () {
this.$nextTick(() => {
let div = document.getElementById('msg-div'+this.nowStr)
div.scrollTop = div.scrollHeight
})
},
loadingMore() { loadingMore() {
this.page.pageNo++ this.page.pageNo++
this.getPage(this.page) this.getPage(this.page)
@ -188,35 +182,35 @@
getMessagePage(Object.assign({ getMessagePage(Object.assign({
pageNo: page.pageNo, pageNo: page.pageNo,
pageSize: page.pageSize, pageSize: page.pageSize,
descs:page.descs,
ascs: page.ascs,
wxUserId: this.wxUserId wxUserId: this.wxUserId
}, params)).then(response => { }, params)).then(response => {
let msgDiv = document.getElementById('msg-div'+this.nowStr) //
const msgDiv = document.getElementById('msg-div' + this.nowStr);
let scrollHeight = 0 let scrollHeight = 0
if(msgDiv){ if(msgDiv){
scrollHeight = msgDiv.scrollHeight scrollHeight = msgDiv.scrollHeight
} }
let data = response.data.list.reverse()
//
const data = response.data.list.reverse();
this.tableData = [...data, ...this.tableData] this.tableData = [...data, ...this.tableData]
this.page.total = response.data.total
this.tableLoading = false this.tableLoading = false
if (data.length < this.page.pageSize || data.length === 0){ if (data.length < this.page.pageSize || data.length === 0){
this.loadMore = false this.loadMore = false
} }
if(this.page.pageNo == 1){// this.page.pageNo = page.pageNo
this.page.pageSize = page.pageSize
//
if(this.page.pageNo === 1) { //
this.scrollToBottom() this.scrollToBottom()
}else{ } else if (data.length !== 0) { //
if(data.length != 0){ this.$nextTick(() => {
this.$nextTick(() => {// if (scrollHeight !== 0){
if(scrollHeight != 0){
msgDiv.scrollTop = document.getElementById('msg-div'+this.nowStr).scrollHeight - scrollHeight - 100 msgDiv.scrollTop = document.getElementById('msg-div'+this.nowStr).scrollHeight - scrollHeight - 100
} }
}) })
} }
}
this.page.pageNo = page.pageNo
this.page.pageSize = page.pageSize
}) })
}, },
/** /**
@ -224,102 +218,22 @@
*/ */
refreshChange() { refreshChange() {
this.getPage(this.page) this.getPage(this.page)
} },
/** 定位到消息底部 */
scrollToBottom: function () {
this.$nextTick(() => {
let div = document.getElementById('msg-div' + this.nowStr)
div.scrollTop = div.scrollHeight
})
},
} }
}; };
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
/* 来自 https://github.com/nmxiaowei/avue/blob/master/styles/src/element-ui/comment.scss */ /* 因为 joolun 实现依赖 avue 组件,该页面使用了 comment.scss、card.scc */
/* 因为 joolun 实现依赖 avue 组件,该页面使用了 comment.scss */ @import './comment.scss';
.avue-comment{ @import './card.scss';
margin-bottom: 30px;
display: flex;
align-items: flex-start;
&--reverse{
flex-direction:row-reverse;
.avue-comment__main{
&:before,&:after{
left: auto;
right: -8px;
border-width: 8px 0 8px 8px;
}
&:before{
border-left-color: #dedede;
}
&:after{
border-left-color: #f8f8f8;
margin-right: 1px;
margin-left: auto;
}
}
}
&__avatar{
width: 48px;
height: 48px;
border-radius: 50%;
border: 1px solid transparent;
box-sizing: border-box;
vertical-align: middle;
}
&__header{
padding: 5px 15px;
background: #f8f8f8;
border-bottom: 1px solid #eee;
display: flex;
align-items: center;
justify-content: space-between;
}
&__author{
font-weight: 700;
font-size: 14px;
color: #999;
}
&__main{
flex:1;
margin: 0 20px;
position: relative;
border: 1px solid #dedede;
border-radius: 2px;
&:before,&:after{
position: absolute;
top: 10px;
left: -8px;
right: 100%;
width: 0;
height: 0;
display: block;
content: " ";
border-color: transparent;
border-style: solid solid outset;
border-width: 8px 8px 8px 0;
pointer-events: none;
}
&:before {
border-right-color: #dedede;
z-index: 1;
}
&:after{
border-right-color: #f8f8f8;
margin-left: 1px;
z-index: 2;
}
}
&__body{
padding: 15px;
overflow: hidden;
background: #fff;
font-family: Segoe UI,Lucida Grande,Helvetica,Arial,Microsoft YaHei,FreeSans,Arimo,Droid Sans,wenquanyi micro hei,Hiragino Sans GB,Hiragino Sans GB W3,FontAwesome,sans-serif;color: #333;
font-size: 14px;
}
blockquote{
margin:0;
font-family: Georgia,Times New Roman,Times,Kai,Kaiti SC,KaiTi,BiauKai,FontAwesome,serif;
padding: 1px 0 1px 15px;
border-left: 4px solid #ddd;
}
}
</style>
<style lang="scss" scoped>
.msg-main { .msg-main {
margin-top: -30px; margin-top: -30px;
padding: 10px; padding: 10px;

View File

@ -40,6 +40,12 @@
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="消息类型" align="center" prop="type" width="80"/> <el-table-column label="消息类型" align="center" prop="type" width="80"/>
<el-table-column label="发送方" align="center" prop="sendFrom" width="80">
<template slot-scope="scope">
<el-tag v-if="scope.row.sendFrom === 1" type="success">用户</el-tag>
<el-tag v-else type="info">公众号</el-tag>
</template>
</el-table-column>
<el-table-column label="用户标识" align="center" prop="openid" width="300" /> <el-table-column label="用户标识" align="center" prop="openid" width="300" />
<!-- TODO 芋艿发送/接收 --> <!-- TODO 芋艿发送/接收 -->
<el-table-column label="内容" prop="content"> <el-table-column label="内容" prop="content">