123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320 |
- <template>
- <div class="message">
- <div class="conten">
- <h2 class="title">留 言 板</h2>
- <ul class="liuyan" v-if="data.length > 0">
- <li v-for="item in data" :key="item.id">
- <div class="name">{{ item.creatorName }}</div>
- <div class="con">{{ item.content }}</div>
- <div class="time">{{ item.createTime }}</div>
- </li>
- </ul>
- <!-- 没有数据的时候提示 -->
- <div class="liuyan noneTxt" v-else>暂无数据</div>
- <!-- 分页器 -->
- <div class="pagination">
- <el-pagination
- layout="prev, pager, next"
- :total="total"
- @current-change="currentChange"
- >
- </el-pagination>
- </div>
- <!-- 文本域和按钮 -->
- <div class="bottmInp">
- <div class="texe">
- <el-input
- maxlength="100"
- show-word-limit
- resize="none"
- type="textarea"
- :rows="3"
- placeholder="欢迎提交您的珍贵留言,100字以内~"
- v-model="textarea"
- >
- </el-input>
- </div>
- <div class="button">
- <div class="button_left">
- <div class="biaoji"></div>
- <el-input
- style="width: 270px"
- type="text"
- placeholder="请填写您的姓名"
- v-model="name"
- maxlength="8"
- show-word-limit
- >
- </el-input>
- </div>
- <el-button
- style="width: 120px; color: #d7b07e"
- type="primary"
- @click="commentSave"
- >提 交</el-button
- >
- </div>
- </div>
- </div>
- <ul>
- <li>
- <span></span>
- </li>
- </ul>
- </div>
- </template>
- <script>
- import { commentSave, commentWebList } from '@/apis/tab7'
- export default {
- name: 'message',
- components: {},
- data () {
- // 这里存放数据
- return {
- textarea: '',
- name: '',
- data: [],
- total: 0,
- formData: {
- startTime: '',
- endTime: '',
- pageNum: 1,
- pageSize: 10,
- searchKey: '',
- status: 2
- }
- }
- },
- // 监听属性 类似于data概念
- computed: {},
- // 监控data中的数据变化
- watch: {},
- // 方法集合
- methods: {
- // 分页器方法
- currentChange (val) {
- // console.log('当前页改变了', val)
- this.formData.pageNum = val
- this.commentWebList(this.formData)
- },
- // 点击提交留言
- async commentSave () {
- if (this.textarea.trim() === '') { return this.$message.warning('内容不能为空!') }
- if (this.name.trim() === '') { return this.$message.warning('名字不能为空!') }
- const res = await commentSave({
- content: this.textarea,
- creatorName: this.name
- })
- if (res.code === 0) {
- this.textarea = this.name = ''
- this.$message.success('提交成功,等待审核.')
- } else this.$message.warning(res.msg)
- },
- // 封装获取列表的方法
- async commentWebList (data) {
- const res = await commentWebList(data)
- this.total = res.data.total
- res.data.records.forEach((v) => {
- v.createTime = v.createTime.substring(0, v.createTime.length - 3)
- })
- this.data = res.data.records
- }
- },
- // 生命周期 - 创建完成(可以访问当前this实例)
- created () {
- this.commentWebList(this.formData)
- },
- // 生命周期 - 挂载完成(可以访问DOM元素)
- mounted () {},
- beforeCreate () {}, // 生命周期 - 创建之前
- beforeMount () {}, // 生命周期 - 挂载之前
- beforeUpdate () {}, // 生命周期 - 更新之前
- updated () {}, // 生命周期 - 更新之后
- beforeDestroy () {}, // 生命周期 - 销毁之前
- destroyed () {}, // 生命周期 - 销毁完成
- activated () {} // 如果页面有keep-alive缓存功能,这个函数会触发
- }
- </script>
- <style lang='less' scoped>
- /deep/.el-input__inner::-webkit-input-placeholder {
- color: #878787 !important;
- }
- /deep/.el-input__inner:-moz-placeholder {
- color: #878787 !important;
- }
- /deep/.el-input__inner::-moz-placeholder {
- color: #878787 !important;
- }
- /deep/.el-input__inner:-ms-input-placeholder {
- /* Internet Explorer 10+ */
- color: #878787 !important;
- }
- /deep/.el-textarea__inner::-webkit-input-placeholder {
- color: #878787 !important;
- }
- /deep/.el-textarea__inner:-moz-placeholder {
- color: #878787 !important;
- }
- /deep/.el-textarea__inner::-moz-placeholder {
- color: #878787 !important;
- }
- /deep/.el-textarea__inner:-ms-input-placeholder {
- /* Internet Explorer 10+ */
- color: #878787 !important;
- }
- .message {
- position: relative;
- margin: 0 auto;
- width: 1000px;
- height: 100vh;
- min-height: 650px;
- .conten {
- background: url("../../assets/img/mesBac.png");
- background-size: 100% 100%;
- border-top: 8px solid #be1220;
- border-bottom: 8px solid #be1220;
- /deep/.el-button--primary {
- background-color: #b92e2e;
- width: 100%;
- height: 40px;
- }
- /deep/.el-pager li {
- background-color: transparent;
- color: #333333;
- }
- /deep/.el-pager li.active {
- color: #b92e2e;
- }
- /deep/.el-pagination button {
- background-color: transparent;
- }
- /deep/.el-pagination button:disabled {
- background-color: transparent;
- }
- position: absolute;
- top: 50%;
- left: 0;
- transform: translateY(-50%);
- width: 100%;
- height: 650px;
- background-color: #fff;
- padding: 20px;
- .title {
- padding-left: 20px;
- color: #fff;
- }
- .liuyan::-webkit-scrollbar {
- /*滚动条整体样式*/
- width: 3px; /*高宽分别对应横竖滚动条的尺寸*/
- height: 1px;
- }
- .liuyan::-webkit-scrollbar-thumb {
- /*滚动条里面小方块*/
- border-radius: 10px;
- box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
- background: rgba(185, 46, 46, 0.3);
- }
- .liuyan::-webkit-scrollbar-track {
- /*滚动条里面轨道*/
- // box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
- border-radius: 10px;
- background: transparent;
- }
- .liuyan {
- background-color: rgba(255, 255, 255, 0.3);
- padding-right: 20px;
- margin: 20px 20px 0;
- padding: 15px;
- height: 320px;
- overflow-y: auto;
- li {
- border-bottom: 1px dashed #b92e2e;
- color: #878787;
- font-size: 16px;
- display: flex;
- & > div {
- padding: 12px 0;
- }
- .name {
- width: 140px;
- }
- .con {
- flex: 1;
- margin-right: 20px;
- }
- .time {
- width: 140px;
- }
- }
- }
- .noneTxt {
- display: flex;
- justify-content: center;
- align-items: center;
- font-size: 26px;
- }
- .pagination {
- padding: 20px;
- margin: 0 auto;
- width: 920px;
- display: flex;
- justify-content: center;
- align-items: center;
- background-color: rgba(255, 255, 255, 0.3);
- }
- .bottmInp {
- /deep/.el-textarea__inner:focus {
- border-color: #b9412e;
- }
- /deep/.el-textarea__inner {
- background-color: rgba(255, 255, 255, 0.3);
- }
- /deep/.el-input__inner {
- background-color: rgba(255, 255, 255, 0.3);
- }
- /deep/.el-textarea .el-input__count {
- background-color: transparent;
- color: #878787;
- }
- /deep/.el-input__count-inner {
- background-color: transparent;
- color: #878787;
- }
- margin-top: 15px;
- width: 100%;
- padding: 0 20px;
- }
- .button {
- margin-top: 15px;
- display: flex;
- justify-content: space-between;
- .button_left {
- width: 300px;
- display: flex;
- align-items: center;
- .biaoji {
- position: relative;
- margin-right: 10px;
- width: 20px;
- height: 20px;
- border-radius: 50%;
- border: 1px solid #b9412e;
- &::after {
- content: "";
- position: absolute;
- top: 50%;
- left: 50%;
- transform: translate(-50%, -50%);
- width: 15px;
- height: 15px;
- border-radius: 50%;
- background-color: #b9412e;
- }
- }
- }
- }
- }
- }
- </style>
|