|
@@ -32,7 +32,8 @@
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script>
|
|
<script>
|
|
-const _ = require('lodash');
|
|
|
|
|
|
+var moment = require('moment');
|
|
|
|
+import _ from 'lodash';
|
|
import { mapState, createNamespacedHelpers } from 'vuex';
|
|
import { mapState, createNamespacedHelpers } from 'vuex';
|
|
const { mapActions: dockChat } = createNamespacedHelpers('dockChat');
|
|
const { mapActions: dockChat } = createNamespacedHelpers('dockChat');
|
|
export default {
|
|
export default {
|
|
@@ -45,14 +46,7 @@ export default {
|
|
data: function() {
|
|
data: function() {
|
|
return {
|
|
return {
|
|
active: 'first',
|
|
active: 'first',
|
|
- list: [
|
|
|
|
- {
|
|
|
|
- send_time: '2020-12-12 12:00:00',
|
|
|
|
- sender_name: '发言人',
|
|
|
|
- content: '发言内容发言内容发言内容发言内容发言内容发言内容发言内容发言内容',
|
|
|
|
- },
|
|
|
|
- { send_time: '2020-12-12 12:00:00', sender_name: '发言人', content: '发言内容' },
|
|
|
|
- ],
|
|
|
|
|
|
+ list: [],
|
|
// 发言内容
|
|
// 发言内容
|
|
text: '',
|
|
text: '',
|
|
};
|
|
};
|
|
@@ -74,14 +68,19 @@ export default {
|
|
async sendMessage() {
|
|
async sendMessage() {
|
|
if (this.text != '') {
|
|
if (this.text != '') {
|
|
const content = _.cloneDeep(this.text);
|
|
const content = _.cloneDeep(this.text);
|
|
- const obj = { content, dock_id: this.id, sender_id: this.user.id, sender_name: this.user.name };
|
|
|
|
|
|
+ let obj = {};
|
|
|
|
+ if (this.user) {
|
|
|
|
+ obj = { content, dock_id: this.id, sender_id: this.user.id, sender_name: this.user.name };
|
|
|
|
+ } else {
|
|
|
|
+ obj = { content, dock_id: this.id, sender_id: this.getData(), sender_name: this.getData() + '游客' };
|
|
|
|
+ }
|
|
const check = Object.values(obj).every(f => f);
|
|
const check = Object.values(obj).every(f => f);
|
|
if (!check) {
|
|
if (!check) {
|
|
this.$message.error('发言所需信息不全,请联系管理人员');
|
|
this.$message.error('发言所需信息不全,请联系管理人员');
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
const res = await this.create(obj);
|
|
const res = await this.create(obj);
|
|
- this.$checkRes(res, null, res.errmsg || '发言失败');
|
|
|
|
|
|
+ this.$checkRes(res, null, '发言成功' || '发言失败');
|
|
this.$set(this, 'text', '');
|
|
this.$set(this, 'text', '');
|
|
} else this.$message.error('请输入信息后发送');
|
|
} else this.$message.error('请输入信息后发送');
|
|
},
|
|
},
|
|
@@ -101,6 +100,11 @@ export default {
|
|
this.list.push(body);
|
|
this.list.push(body);
|
|
}
|
|
}
|
|
},
|
|
},
|
|
|
|
+ // 获取时间戳
|
|
|
|
+ getData() {
|
|
|
|
+ let date = moment(new Date()).valueOf();
|
|
|
|
+ if (date) return date;
|
|
|
|
+ },
|
|
},
|
|
},
|
|
computed: {
|
|
computed: {
|
|
...mapState(['user']),
|
|
...mapState(['user']),
|