| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205 |
- <template>
- <view class="msg-box">
- <Nav title="留言反馈" :left-show="false" titleColor="#fff"></Nav>
- <view class="mui-content">
- <view class="ln-public">
- 留言内容
- </view>
- <view class="msg-text" contenteditable="true" placeholder="在此输入留言内容,限200字。"></view>
- <view class="msg-btn" @click="sendMsg">提交</view>
- <view class="msg-list">
- <view class="msg-item" v-for="(msgItem,index) in list">
- <view class="msg-list-con">
- <view class="msg-list-tit">
- <view class="msg-list-name">
- {{msgItem.username}}
- </view>
- <view class="msg-list-time">{{msgItem.created_at}}</view>
- </view>
- <view class="msg-list-intro">{{msgItem.content}}</view>
- </view>
- <view class="msg-list-con" v-if="msgItem.reply!==''">
- <view class="msg-list-tit">
- <view class="msg-list-name">
- 回复
- </view>
- <view class="msg-list-time">{{msgItem.updated_at}}</view>
- </view>
- <view class="msg-list-intro">{{msgItem.reply}}</view>
- </view>
- </view>
- </view>
- <en-blank v-if="list.length<=0"></en-blank>
- </view>
- </view>
- </template>
- <script>
- import $ from 'jquery/src/jquery'
- import {addMsg, getMsgList} from "@/api/news";
- import tools from "@/common/js/tools";
- import EnBlank from "@/components/en-utils/en-blank/en-blank";
- export default {
- name: "index",
- components: {EnBlank},
- props: {},
- data() {
- return {
- isAjax:false,
- page:1,
- list:[],
- total:null
- }
- },
- watch: {},
- mounted() {
- this.startList()
- },
- onReachBottom() {
- this.getMsgList()
- },
- methods: {
- startList(){
- this.page=1;
- this.list=[];
- this.total=null;
- this.getMsgList()
- },
- getMsgList(){
- if(this.isAjax){
- return;
- }
- if(this.total!==null && this.total>=this.list.length){
- return;
- }
- getMsgList({'page':this.page}).then((res)=>{
- if(res.code===1){
- this.total=res.data.total
- this.list.push(...res.data.items)
- ++this.page
- }
- })
- },
- sendMsg(){
- let msg = $('.msg-text').text();
- if(msg===''){
- tools.error('请输入留言内容')
- return;
- }
- if(this.isAjax){
- return;
- }
- this.isAjax=true
- addMsg({'content':msg}).then((res)=>{
- this.isAjax=false
- if(res.code===1){
- this.list.unshift(res.data)
- $('.msg-text').text('');
- tools.success(res.msg)
- }else {
- tools.error(res.msg)
- }
- }).catch((e)=>{
- this.isAjax=false
- })
- }
- }
- }
- </script>
- <style scoped lang="scss">
- .msg-box{
- background: #131E30;
- min-height: calc(100vh - 50px);
- .mui-content{
- padding:0 10px;
- .ln-public {
- width: 100%;
- padding: 0 10px;
- font-size: 20px;
- line-height: 28px;
- font-weight: 600;
- margin: 20px auto;
- color: #D9E4F6;
- word-break: break-all;
- }
- .msg-text {
- width: calc(100% - 20px);
- min-height: 98px;
- line-height: 24px;
- color: #D9E4F6;
- padding: 10px 0;
- background: #061623;
- border: 1px solid rgba(39,60,83,0.5);
- margin: 10px;
- }
- .msg-btn {
- display: block;
- width: 82%;
- height: 42px;
- line-height: 42px;
- border: 0;
- border-radius: 3px;
- text-align: center;
- padding: 0;
- font-size: 16px;
- background: #007AFF;
- color: #FFFFFF;
- margin: 15px auto;
- margin-top: 60px;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- }
- .msg-list {
- width: calc(100% - 20px);
- line-height: 20px;
- padding: 0 10px;
- border-top: 1px solid rgba(39,60,83,0.5);
- list-style-type: none;
- margin: 0;
- -webkit-padding-start: 0;
- .msg-item{
- padding: 2px 0;
- border-bottom: 1px solid rgba(39,60,83,0.5);
- color: #D9E4F6;
- .msg-list-con {
- width: 100%;
- overflow: auto;
- margin: 15px 0;
- .msg-list-tit {
- width: 100%;
- height: 30px;
- line-height: 30px;
- .msg-list-name {
- max-width: calc(100% - 120px);
- height: 30px;
- float: left;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- color: #D9E4F6;
- }
- .msg-list-time {
- max-width: 130px;
- height: 30px;
- font-size: 12px;
- color: #495B73;
- text-align: right;
- float: right;
- overflow: hidden;
- }
- }
- .msg-list-intro {
- width: 100%;
- line-height: 20px;
- color: #495B73;
- text-align: justify;
- }
- }
- }
- }
- }
- }
- </style>
|