<template>
<gracePage :customHeader="false" footerBg="#FFFFFF">
<!-- 页面主体 -->
<view slot="gBody" class="grace-body">
<view class="grace-margin-top">
<text class="grace-title">静态演示</text>
</view>
<view class="grace-comments">
<view class="grace-comments-items">
<image src="https://graceui.oss-cn-beijing.aliyuncs.com/faces/1.png" class="grace-comments-face"></image>
<view class="grace-comments-body">
<view class="grace-comments-header">
<text class="grace-comments-header-text">刘美丽</text>
<text class="grace-comments-info-text">08/10 08:12</text>
</view>
<text class="grace-comments-content">上天呀!我渴望与你相知相惜,长存此心永不褪减。</text>
<text class="grace-comments-replay">某某回复 : 回复文本</text>
<view class="grace-comments-info">
<text class="grace-comments-replay-btn">回复</text>
<text class="grace-comments-header-text grace-icons icon-zan"> 999</text>
</view>
</view>
</view>
<view class="grace-comments-items">
<image src="https://graceui.oss-cn-beijing.aliyuncs.com/faces/2.png" class="grace-comments-face"></image>
<view class="grace-comments-body">
<view class="grace-comments-header">
<text class="grace-comments-header-text">王小宝</text>
</view>
<text class="grace-comments-content">上天呀!我渴望与你相知相惜,长存此心永不褪减。</text>
<view class="grace-comments-imgs">
<view class="grace-comments-image"><image src="https://graceui.oss-cn-beijing.aliyuncs.com/scollimgs/4.png" class="grace-comments-img"></image></view>
<view class="grace-comments-image"><image src="https://graceui.oss-cn-beijing.aliyuncs.com/scollimgs/3.png" class="grace-comments-img"></image></view>
<view class="grace-comments-image"><image src="https://graceui.oss-cn-beijing.aliyuncs.com/scollimgs/2.png" class="grace-comments-img"></image></view>
<view class="grace-comments-image"><image src="https://graceui.oss-cn-beijing.aliyuncs.com/scollimgs/1.png" class="grace-comments-img"></image></view>
<view class="grace-comments-image"><image src="https://graceui.oss-cn-beijing.aliyuncs.com/scollimgs/4.png" class="grace-comments-img"></image></view>
<view class="grace-comments-image"><image src="https://graceui.oss-cn-beijing.aliyuncs.com/scollimgs/3.png" class="grace-comments-img"></image></view>
</view>
<view class="grace-comments-info">
<text class="grace-comments-info-text">08/10 08:1208/10 08:12</text>
<text class="grace-comments-info-text grace-icons icon-zan"> 999</text>
</view>
</view>
</view>
</view>
<view class="grace-margin-top">
<text class="grace-title">动态数据演示</text>
</view>
<view class="grace-comments">
<view class="grace-comments-items" v-for="(item, index) in commentContents" :key="index">
<image :src="item.face" class="grace-comments-face"></image>
<view class="grace-comments-body">
<view class="grace-comments-header">
<text class="grace-comments-header-text">{{item.name}}</text>
<text class="grace-comments-header-text grace-icons"> {{item.zan}}</text>
</view>
<text class="grace-comments-content">{{item.content}}</text>
<view class="grace-comments-imgs" v-if="item.imgs">
<view class="grace-comments-image" v-for="(img, indexImg) in item.imgs" :key="indexImg">
<image :src="img" mode="widthFix" class="grace-comments-img" @click.stop="showImgs(index, indexImg)"></image>
</view>
</view>
<view v-if="item.Reply">
<text v-for="(itemRe, indexRe) in item.Reply" :key="indexRe" class="grace-comments-replay">{{itemRe.name}} : {{itemRe.content}}</text>
</view>
<view class="grace-comments-info">
<text class="grace-comments-replay-btn">回复</text>
<text class="grace-comments-info-text">{{item.date}}</text>
</view>
</view>
</view>
</view>
<!-- 占位视图 用于避开底部遮盖 -->
<view style="height:120rpx;"></view>
<graceComment ref="graceComment" @submit="submit"></graceComment>
</view>
<!-- 底部提交输入框 -->
<view class="grace-nowrap grace-flex-vcenter grace-bg-white" slot="gFooter">
<view class="grace-footer-input-body" style="margin-right:25rpx;" @tap="openComment">
<text class="grace-footer-input-icon grace-icons icon-write"></text>
<input type="text" placeholder="说点什么吧..." class="grace-footer-input" disabled />
</view>
</view>
</gracePage>
</template>
<script>
import gracePage from "../../graceUI/components/gracePage.vue";
import graceComment from '../../graceUI/components/graceComment.vue';
export default {
data() {
return {
// 模拟评论数据 (实际项目来自api请求)
commentContents : [
{
"content":"故国三千里,深宫二十年。一声何满子,双泪落君前。",
"name":"graceUI - 小码",
"face":"https://graceui.oss-cn-beijing.aliyuncs.com/faces/1.png",
"date":"08/10 08:00",
"zan" : 188,
"Reply" : [
{'name' : "张晓曦", "content":"不错不错"},
{'name' : "王大陆", "content":"赞了~"},
]
},
{
"content":"而今渐行渐远,渐觉虽悔难追。漫寄消寄息,终久奚为。也拟重论缱绻,争奈翻覆思维。纵再会,只恐恩情,难似当时。",
"name":"路过繁华",
"face":"https://graceui.oss-cn-beijing.aliyuncs.com/faces/2.png",
"date":"02/10 18:00",
"zan" : 288
},
{
"content":"图片回复,点击图片可以预览......",
"name":"林夕阳",
"imgs" : [
"https://graceui.oss-cn-beijing.aliyuncs.com/scollimgs/4.png",
"https://graceui.oss-cn-beijing.aliyuncs.com/scollimgs/3.png",
"https://graceui.oss-cn-beijing.aliyuncs.com/scollimgs/1.png",
],
"face":"https://graceui.oss-cn-beijing.aliyuncs.com/faces/2.png",
"date":"08/12 09:00",
"zan" : 955
}
]
}
},
methods:{
openComment:function () {
this.$refs.graceComment.open();
this.$refs.graceComment.setAt('GraceUI');// 设置 at 信息
},
submit : function (e) {
console.log(e);
// 评论数据以对象形式报错在 e 变量内,您可以连接 api 进行后续的功能开发
// e.at - at 用户昵称
// e.content 评论内容 , 可以此处进行字数验证
// e.img 评论图片, 临时地址,可以结合 api 进行上传
},
showImgs : function(commentsIndex, imgIndex){
console.log(commentsIndex, imgIndex);
uni.previewImage({
urls:this.commentContents[commentsIndex].imgs,
current:this.commentContents[commentsIndex].imgs[imgIndex]
})
}
},
components:{
gracePage,graceComment
}
}
</script>
<style>
/* 请根据项目来规划自己的图片大小,请对图片进行等比缩放
.grace-comments-image{width:190rpx; height:138rpx; margin:5rpx; font-size:0; overflow:hidden;}
.grace-comments-img{width:190rpx; height:138rpx; border-radius:3rpx;}
*/
</style>
<template>
<gracePage :customHeader="false" footerBg="#FFFFFF">
<!-- 页面主体 -->
<view slot="gBody" class="grace-body">
<view class="grace-margin-top">
<text class="grace-title">静态演示</text>
</view>
<list class="grace-comments">
<cell class="grace-comments-items">
<image src="https://graceui.oss-cn-beijing.aliyuncs.com/faces/1.png" class="grace-comments-face"></image>
<view class="grace-comments-body">
<view class="grace-comments-header">
<text class="grace-comments-header-text">刘美丽</text>
<text class="grace-comments-info-text">08/10 08:12</text>
</view>
<text class="grace-comments-content">上天呀!我渴望与你相知相惜,长存此心永不褪减。</text>
<text class="grace-comments-replay">某某回复 : 回复文本</text>
<view class="grace-comments-info">
<text class="grace-comments-replay-btn">回复</text>
<text class="grace-icons grace-comments-info-text"> 999</text>
</view>
</view>
</cell>
<cell class="grace-comments-items">
<image src="https://graceui.oss-cn-beijing.aliyuncs.com/faces/2.png" class="grace-comments-face"></image>
<view class="grace-comments-body">
<view class="grace-comments-header">
<text class="grace-comments-header-text">王小宝</text>
</view>
<text class="grace-comments-content">上天呀!我渴望与你相知相惜,长存此心永不褪减。</text>
<view class="grace-comments-imgs">
<view class="grace-comments-image"><image src="https://graceui.oss-cn-beijing.aliyuncs.com/scollimgs/4.png" class="grace-comments-img"></image></view>
<view class="grace-comments-image"><image src="https://graceui.oss-cn-beijing.aliyuncs.com/scollimgs/3.png" class="grace-comments-img"></image></view>
<view class="grace-comments-image"><image src="https://graceui.oss-cn-beijing.aliyuncs.com/scollimgs/2.png" class="grace-comments-img"></image></view>
<view class="grace-comments-image"><image src="https://graceui.oss-cn-beijing.aliyuncs.com/scollimgs/1.png" class="grace-comments-img"></image></view>
<view class="grace-comments-image"><image src="https://graceui.oss-cn-beijing.aliyuncs.com/scollimgs/4.png" class="grace-comments-img"></image></view>
<view class="grace-comments-image"><image src="https://graceui.oss-cn-beijing.aliyuncs.com/scollimgs/3.png" class="grace-comments-img"></image></view>
</view>
<view class="grace-comments-info">
<text class="grace-comments-info-text">08/10 08:1208/10 08:12</text>
<text class="grace-icons grace-comments-info-text"> 999</text>
</view>
</view>
</cell>
</list>
<view class="grace-margin-top">
<text class="grace-title">动态数据演示</text>
</view>
<list class="grace-comments">
<cell class="grace-comments-items" v-for="(item, index) in commentContents" :key="index">
<image :src="item.face" class="grace-comments-face"></image>
<view class="grace-comments-body">
<view class="grace-comments-header">
<text class="grace-comments-header-text">{{item.name}}</text>
<text class="grace-comments-info-text grace-icons"> {{item.zan}}</text>
</view>
<text class="grace-comments-content">{{item.content}}</text>
<view class="grace-comments-imgs" v-if="item.imgs">
<view class="grace-comments-image" v-for="(img, indexImg) in item.imgs" :key="indexImg">
<image :src="img" mode="widthFix" class="grace-comments-img" @click.stop="showImgs(index, indexImg)"></image>
</view>
</view>
<view v-if="item.Reply">
<text v-for="(itemRe, indexRe) in item.Reply" :key="indexRe" class="grace-comments-replay">{{itemRe.name}} : {{itemRe.content}}</text>
</view>
<view class="grace-comments-info">
<text class="grace-comments-replay-btn">回复</text>
<text class="grace-comments-info-text">{{item.date}}</text>
</view>
</view>
</cell>
</list>
<!-- 占位视图 用于避开底部遮盖 -->
<view style="height:120rpx;"></view>
<graceComment ref="graceComment" @submit="submit"></graceComment>
</view>
<!-- 底部提交输入框 -->
<view class="grace-nowrap grace-flex-vcenter grace-bg-white" slot="gFooter">
<view class="grace-footer-input-body" style="margin-right:25rpx;" @tap="openComment">
<text class="grace-footer-input-icon grace-icons"></text>
<input type="text" placeholder="说点什么吧..." class="grace-footer-input" disabled />
</view>
</view>
</gracePage>
</template>
<script>
import gracePage from "../../graceUI/weexComponents/gracePage.nvue";
import graceComment from '../../graceUI/weexComponents/graceComment.nvue';
export default {
data() {
return {
// 模拟评论数据 (实际项目来自api请求)
commentContents : [
{
"content":"故国三千里,深宫二十年。一声何满子,双泪落君前。",
"name":"graceUI - 小码",
"face":"https://graceui.oss-cn-beijing.aliyuncs.com/faces/1.png",
"date":"08/10 08:00",
"zan" : 188,
"Reply" : [
{'name' : "张晓曦", "content":"不错不错"},
{'name' : "王大陆", "content":"赞了~"},
]
},
{
"content":"而今渐行渐远,渐觉虽悔难追。漫寄消寄息,终久奚为。也拟重论缱绻,争奈翻覆思维。纵再会,只恐恩情,难似当时。",
"name":"路过繁华",
"face":"https://graceui.oss-cn-beijing.aliyuncs.com/faces/2.png",
"date":"02/10 18:00",
"zan" : 288
},
{
"content":"图片回复,点击图片可以预览......",
"name":"林夕阳",
"imgs" : [
"https://graceui.oss-cn-beijing.aliyuncs.com/scollimgs/4.png",
"https://graceui.oss-cn-beijing.aliyuncs.com/scollimgs/3.png",
"https://graceui.oss-cn-beijing.aliyuncs.com/scollimgs/1.png",
],
"face":"https://graceui.oss-cn-beijing.aliyuncs.com/faces/2.png",
"date":"08/12 09:00",
"zan" : 955
}
]
}
},
methods:{
openComment:function () {
this.$refs.graceComment.open();
this.$refs.graceComment.setAt('GraceUI');// 设置 at 信息
},
submit : function (e) {
console.log(e);
// 评论数据以对象形式报错在 e 变量内,您可以连接 api 进行后续的功能开发
// e.at - at 用户昵称
// e.content 评论内容 , 可以此处进行字数验证
// e.img 评论图片, 临时地址,可以结合 api 进行上传
},
showImgs : function(commentsIndex, imgIndex){
console.log(commentsIndex, imgIndex);
uni.previewImage({
urls:this.commentContents[commentsIndex].imgs,
current:this.commentContents[commentsIndex].imgs[imgIndex]
})
}
},
components:{
gracePage, graceComment
}
}
</script>
<style>
/* 请根据项目来规划自己的图片大小,请对图片进行等比缩放
.grace-comments-image{width:190rpx; height:138rpx; margin:5rpx; font-size:0; overflow:hidden;}
.grace-comments-img{width:190rpx; height:138rpx; border-radius:3rpx;}
*/
</style>
.wxml
<gracePage customHeader="{{false}}" footerBg="#FFFFFF">
<!-- 页面主体 -->
<view slot="gBody" class="grace-body">
<view class="grace-margin-top">
<text class="grace-title">静态演示</text>
</view>
<view class="grace-comments">
<view class="grace-comments-items">
<image src="https://graceui.oss-cn-beijing.aliyuncs.com/faces/1.png" class="grace-comments-face"></image>
<view class="grace-comments-body">
<view class="grace-comments-header">
<text class="grace-comments-header-text">刘美丽</text>
<text class="grace-comments-info-text">08/10 08:12</text>
</view>
<text class="grace-comments-content">上天呀!我渴望与你相知相惜,长存此心永不褪减。</text>
<text class="grace-comments-replay">某某回复 : 回复文本</text>
<view class="grace-comments-info">
<text class="grace-comments-replay-btn">回复</text>
<text class="grace-comments-header-text grace-icons icon-zan"> 999</text>
</view>
</view>
</view>
<view class="grace-comments-items">
<image src="https://graceui.oss-cn-beijing.aliyuncs.com/faces/2.png" class="grace-comments-face"></image>
<view class="grace-comments-body">
<view class="grace-comments-header">
<text class="grace-comments-header-text">王小宝</text>
</view>
<text class="grace-comments-content">上天呀!我渴望与你相知相惜,长存此心永不褪减。</text>
<view class="grace-comments-imgs">
<view class="grace-comments-image"><image src="https://graceui.oss-cn-beijing.aliyuncs.com/scollimgs/4.png" class="grace-comments-img"></image></view>
<view class="grace-comments-image"><image src="https://graceui.oss-cn-beijing.aliyuncs.com/scollimgs/3.png" class="grace-comments-img"></image></view>
<view class="grace-comments-image"><image src="https://graceui.oss-cn-beijing.aliyuncs.com/scollimgs/2.png" class="grace-comments-img"></image></view>
<view class="grace-comments-image"><image src="https://graceui.oss-cn-beijing.aliyuncs.com/scollimgs/1.png" class="grace-comments-img"></image></view>
<view class="grace-comments-image"><image src="https://graceui.oss-cn-beijing.aliyuncs.com/scollimgs/4.png" class="grace-comments-img"></image></view>
<view class="grace-comments-image"><image src="https://graceui.oss-cn-beijing.aliyuncs.com/scollimgs/3.png" class="grace-comments-img"></image></view>
</view>
<view class="grace-comments-info">
<text class="grace-comments-info-text">08/10 08:1208/10 08:12</text>
<text class="grace-comments-info-text grace-icons icon-zan"> 999</text>
</view>
</view>
</view>
</view>
<view class="grace-margin-top">
<text class="grace-title">动态数据演示</text>
</view>
<view class="grace-comments">
<view class="grace-comments-items" wx:for="{{commentContents}}" wx:key="index">
<image src="{{item.face}}" class="grace-comments-face"></image>
<view class="grace-comments-body">
<view class="grace-comments-header">
<text class="grace-comments-header-text">{{item.name}}</text>
<text class="grace-comments-header-text grace-icons icon-zan">{{item.zan}}</text>
</view>
<text class="grace-comments-content">{{item.content}}</text>
<view class="grace-comments-imgs" wx:if="{{item.imgs}}">
<view class="grace-comments-image" wx:for="{{item.imgs}}" wx:for-item="img" wx:for-index="indexImg" wx:key="indexImg">
<image src="{{img}}" mode="widthFix" class="grace-comments-img" data-commentindex="{{index}}" data-imgindex="{{indexImg}}" catchtap="showImgs"></image>
</view>
</view>
<view wx:if="{{item.Reply}}">
<text wx:for="{{item.Reply}}" wx:for-item="itemRe" wx:for-index="indexRe" wx:key="indexRe" class="grace-comments-replay">{{itemRe.name}} : {{itemRe.content}}</text>
</view>
<view class="grace-comments-info">
<text class="grace-comments-replay-btn">回复</text>
<text class="grace-comments-info-text">{{item.date}}</text>
</view>
</view>
</view>
</view>
<!-- 占位视图 用于避开底部遮盖 -->
<view style="height:120rpx;"></view>
<graceComment id="graceComment" bind:submit="submit"></graceComment>
</view>
<!-- 底部提交输入框 -->
<view class="grace-nowrap grace-flex-vcenter grace-bg-white" slot="gFooter">
<view class="grace-footer-input-body" style="margin-right:25rpx;" bindtap="openComment">
<text class="grace-footer-input-icon grace-icons icon-write"></text>
<input type="text" placeholder="说点什么吧..." class="grace-footer-input" disabled />
</view>
</view>
</gracePage>.json
{
"usingComponents": {
"gracePage": "../../graceUI/components/gracePage",
"graceComment": "../../graceUI/components/graceComment"
}
}.js
Page({
data:{
// 模拟评论数据 (实际项目来自api请求)
commentContents: [
{
"content": "故国三千里,深宫二十年。一声何满子,双泪落君前。",
"name": "graceUI - 小码",
"face": "https://graceui.oss-cn-beijing.aliyuncs.com/faces/1.png",
"date": "08/10 08:00",
"zan": 188,
"Reply": [
{ 'name': "张晓曦", "content": "不错不错" },
{ 'name': "王大陆", "content": "赞了~" },
]
},
{
"content": "而今渐行渐远,渐觉虽悔难追。漫寄消寄息,终久奚为。也拟重论缱绻,争奈翻覆思维。纵再会,只恐恩情,难似当时。",
"name": "路过繁华",
"face": "https://graceui.oss-cn-beijing.aliyuncs.com/faces/2.png",
"date": "02/10 18:00",
"zan": 288
},
{
"content": "图片回复,点击图片可以预览......",
"name": "林夕阳",
"imgs": [
"https://graceui.oss-cn-beijing.aliyuncs.com/scollimgs/4.png",
"https://graceui.oss-cn-beijing.aliyuncs.com/scollimgs/3.png",
"https://graceui.oss-cn-beijing.aliyuncs.com/scollimgs/1.png",
],
"face": "https://graceui.oss-cn-beijing.aliyuncs.com/faces/2.png",
"date": "08/12 09:00",
"zan": 955
}
]
},
openComment:function () {
console.log(this.selectComponent('#graceComment'))
this.selectComponent('#graceComment').open();
this.selectComponent('#graceComment').setAt('GraceUI');// 设置 at 信息
},
submit : function (e) {
e = e.detail;
console.log(e);
// 评论数据以对象形式报错在 e 变量内,您可以连接 api 进行后续的功能开发
// e.at - at 用户昵称
// e.content 评论内容 , 可以此处进行字数验证
// e.img 评论图片, 临时地址,可以结合 api 进行上传
},
showImgs: function (e) {
var commentsIndex = e.currentTarget.dataset.commentindex;
var imgIndex = e.currentTarget.dataset.imgindex;
wx.previewImage({
urls: this.data.commentContents[commentsIndex].imgs,
current: this.data.commentContents[commentsIndex].imgs[imgIndex]
})
}
})