quanwei
18 hours ago c441dea81bd86bdfb12dff35821fed51f4cc91c2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
<template>
  <!--
    作者:luoyiming
    时间:2020-06-25
    描述:插件中心-直播-微信直播
  -->
  <div>
    <div class="common-form d-s-c">
      <span>直播同步</span>
      <div class="ml20 flex-1 d-b-c">
        <el-button type="primary" size="small" icon="el-icon-plus" @click="synLive">同步直播</el-button>
        <el-form size="small" :inline="true" :model="searchForm" class="demo-form-inline">
          <el-form-item label=""><el-input v-model="searchForm.search" placeholder="请输入直播间名称/主播昵称"></el-input></el-form-item>
          <el-form-item><el-button type="primary" icon="el-icon-search" @click="onSubmit">查询</el-button></el-form-item>
        </el-form>
      </div>
    </div>
 
    <!--内容-->
    <div class="live-list">
      <div class="table-wrap">
        <el-table size="small" :data="tableData" border style="width: 100%" v-loading="loading">
          <el-table-column prop="live_id" label="直播间ID"></el-table-column>
          <el-table-column prop="name" label="直播间名称"></el-table-column>
          <el-table-column prop="anchor_name" label="主播昵称"></el-table-column>
          <el-table-column prop="start_time_text" label="直播开始时间"></el-table-column>
          <el-table-column prop="end_time_text" label="直播结束时间"></el-table-column>
          <el-table-column prop="live_status" label="直播间状态">
            <template slot-scope="scope">
              {{ scope.row.live_status | convertStatus }}
            </template>
          </el-table-column>
          <el-table-column prop="is_top" label="置顶">
            <template slot-scope="scope">
              <span v-if="scope.row.is_top == 0" class="gray">未置顶</span>
              <span v-else class="red">已置顶</span>
            </template>
          </el-table-column>
          <el-table-column prop="create_time" label="更新时间"></el-table-column>
          <el-table-column fixed="right" label="操作" width="80">
            <template slot-scope="scope">
              <!-- <el-button @click="editClick(scope.row)" type="text" size="small" v-auth="'/product/product/edit'">编辑</el-button>
              <el-button @click="delClick(scope.row)" type="text" size="small" v-auth="'/product/product/delete'">删除</el-button> -->
              <el-button @click="setTop(scope.row)" type="text" size="small">
                {{scope.row.is_top == 0?'设为置顶':'取消置顶'}}
              </el-button>
            </template>
          </el-table-column>
        </el-table>
      </div>
    </div>
    <!--分页-->
    <div class="pagination">
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        background
        :current-page="curPage"
        :page-size="pageSize"
        layout="total, prev, pager, next, jumper"
        :total="totalDataNumber"
      ></el-pagination>
    </div>
  </div>
</template>
 
<script>
import LiveApi from '@/api/live.js';
export default {
  data() {
    return {
      /*搜索表单对象*/
      searchForm: {},
      /*是否正在加载*/
      loading: true,
      /*一页多少条*/
      pageSize: 10,
      /*一共多少条数据*/
      totalDataNumber: 0,
      /*当前是第几页*/
      curPage: 1,
      /*列表数据*/
      tableData: []
    };
  },
  created() {
    this.getData();
  },
  filters: {
    convertStatus: function(num) {
      let str = '';
      switch (num) {
        case 101:
          str = '直播中';
          break;
        case 102:
          str = '未开始';
          break;
        case 103:
          str = '已结束';
          break;
        case 104:
          str = '禁播';
          break;
        case 105:
          str = '暂停';
          break;
        case 106:
          str = '异常';
          break;
        case 107:
          str = '已过期';
          break;
      }
      return str;
    }
  },
  methods: {
    /*查询*/
    onSubmit() {
      this.curPage = 1;
      this.getData();
    },
 
    /*选择第几页*/
    handleCurrentChange(val) {
      let self = this;
      self.curPage = val;
      self.getData();
    },
 
    /*每页多少条*/
    handleSizeChange(val) {
      this.pageSize = val;
      this.getData();
    },
 
    /*获取列表*/
    getData() {
      let self = this;
      let Params = self.searchForm;
      Params.page = self.curPage;
      Params.list_rows = self.pageSize;
      self.loading = true;
      LiveApi.getList(Params, true)
        .then(res => {
          self.tableData = res.data.list.data;
          self.totalDataNumber=res.data.list.total;
          self.loading = false;
        })
        .catch(error => {
          self.loading = false;
        });
    },
 
    /*直播同步*/
    synLive() {
      let self = this;
      self.loading = true;
      LiveApi.syn({}, true)
        .then(res => {
          self.loading = false;
        })
        .catch(error => {
          self.loading = false;
        });
    },
 
    /*设置是否置顶*/
    setTop(row) {
      let self = this;
      LiveApi.settop({
        live_id: row.live_id,
        is_top: row.is_top == 0 ? 1 : 0
      }).then(data => {
        self.$message({
          message: '置顶成功',
          type: 'success'
        });
        self.getData();
      });
    },
 
    /*编辑*/
    editClick() {},
 
    /*删除*/
    delClick: function(row) {
      let self = this;
      self
        .$confirm('删除后不可恢复,确认删除该记录吗?', '提示', {
          type: 'warning'
        })
        .then(() => {
          LiveApi.del({
            live_id: row.live_id
          }).then(data => {
            self.$message({
              message: '删除成功',
              type: 'success'
            });
            self.getData();
          });
        });
    }
  }
};
</script>
 
<style scoped="scoped"></style>