|
@@ -15,10 +15,10 @@
|
|
|
</el-col>
|
|
|
<el-col :span="20" class="info">
|
|
|
<el-col :span="24" class="name textOver">
|
|
|
- {{ item.name }}
|
|
|
+ {{ item.client_name }}
|
|
|
</el-col>
|
|
|
<el-col :span="24" class="date textOver">
|
|
|
- {{ item.renew_time }}
|
|
|
+ {{ getTime(item) }}
|
|
|
</el-col>
|
|
|
</el-col>
|
|
|
</el-col>
|
|
@@ -78,7 +78,10 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
+const _ = require('lodash');
|
|
|
+const moment = require('moment');
|
|
|
import { mapState, createNamespacedHelpers } from 'vuex';
|
|
|
+const { mapActions: customer } = createNamespacedHelpers('customer');
|
|
|
export default {
|
|
|
name: 'index',
|
|
|
props: {},
|
|
@@ -123,8 +126,14 @@ export default {
|
|
|
},
|
|
|
created() {
|
|
|
this.search();
|
|
|
+ this.toOnline();
|
|
|
+ this.getClientList();
|
|
|
+ },
|
|
|
+ mounted() {
|
|
|
+ this.channel();
|
|
|
},
|
|
|
methods: {
|
|
|
+ ...customer(['online', 'record']),
|
|
|
search({ skip = 0, limit = 10, ...info } = {}) {
|
|
|
if (this.searchName) info.name = this.searchName;
|
|
|
console.log(info);
|
|
@@ -136,9 +145,40 @@ export default {
|
|
|
isSender(data) {
|
|
|
return data.id == '客服';
|
|
|
},
|
|
|
+ //获取客户列表
|
|
|
+ async getClientList() {
|
|
|
+ const res = await this.record({ _tenant: this._tenant, customer_id: this.user.id });
|
|
|
+ if (this.$checkRes(res)) {
|
|
|
+ this.$set(this, `userList`, res.data);
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ channel() {
|
|
|
+ this.$stomp({
|
|
|
+ [`/exchange/${this._tenant}/customer.${this.user.id}`]: this.onMessage,
|
|
|
+ });
|
|
|
+ },
|
|
|
+ onMessage(message) {
|
|
|
+ // customer/5f6ad08fbe2d3b407b41a693
|
|
|
+ console.log('receive a message: ', message.body);
|
|
|
+ if (message.body === 'research') this.getClientList();
|
|
|
+ },
|
|
|
+
|
|
|
+ async toOnline() {
|
|
|
+ console.log('in function:');
|
|
|
+ const time = 5000; //1min 600000
|
|
|
+ setInterval(() => {
|
|
|
+ this.online({ _tenant: this._tenant, customer_id: this.user.id });
|
|
|
+ }, time);
|
|
|
+ },
|
|
|
+ getTime(item) {
|
|
|
+ const ct = _.get(item.meta, 'createdAt');
|
|
|
+ if (!ct) return;
|
|
|
+ return moment(ct).format('YYYY-MM-DD HH:mm:ss');
|
|
|
+ },
|
|
|
},
|
|
|
computed: {
|
|
|
- ...mapState(['user']),
|
|
|
+ ...mapState(['user', '_tenant']),
|
|
|
},
|
|
|
metaInfo() {
|
|
|
return { title: this.$route.meta.title };
|