vip_manager.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. <template>
  2. <div id="vip-manager">
  3. <div
  4. class="title"
  5. >会员数:正常{{whole.total_normal}}, 过期{{whole.total_overdue}}; 初创版会员: 正常{{whole.company_normal}}, 过期{{whole.company_overdue}};企业版会员: 正常{{whole.premium_normal}}, 过期{{whole.premius_overdue}};开发者会员: 正常{{whole.person_normal}}, 过期{{whole.person_overdue}}</div>
  6. <div class="table">
  7. <el-table v-if="tableData.length" border style="width: 100%" :data="tableData">
  8. <el-table-column
  9. v-for="(prop, index) of tableProps"
  10. :key="index"
  11. :prop="prop"
  12. :label="tableHeaders[index]"
  13. >
  14. <template slot-scope="scope">
  15. <el-button
  16. type="text"
  17. class="ctrls"
  18. v-if="prop === 'uid'"
  19. @click="clickUID(scope.row)"
  20. >{{scope.row[prop]}}</el-button>
  21. <el-button
  22. type="text"
  23. class="ctrls"
  24. v-else-if="prop === 'operator_name'"
  25. @click="clickUID({uid:scope.row.operator_id})"
  26. >{{scope.row[prop]}}</el-button>
  27. <template v-else-if="prop === 'action'">
  28. <el-button type="text" v-if="scope.row.status != 0" @click="cancelUserVip(scope.row)" >取消会员</el-button>
  29. </template>
  30. <span v-else>{{scope.row[prop]}}</span>
  31. </template>
  32. </el-table-column>
  33. </el-table>
  34. </div>
  35. <div class="order-footer" style="margin-top: 20px;">
  36. <el-pagination
  37. background
  38. @current-change="changePagination"
  39. @size-change="changePageSize"
  40. :current-page.sync="currentPage"
  41. :page-sizes="[10, 20, 30, 40]"
  42. :page-size="pageSize"
  43. layout="total, sizes, prev, pager, next, jumper"
  44. :total="totalCount"
  45. ></el-pagination>
  46. </div>
  47. </div>
  48. </template>
  49. <script>
  50. const tableHeaders = [
  51. "用户ID",
  52. "昵称",
  53. "会员类型",
  54. "开始时间",
  55. "到期时间",
  56. "取消时间",
  57. "操作人员",
  58. "最新购买",
  59. "累计月数",
  60. "累计金额",
  61. "当前状态",
  62. "操作"
  63. ];
  64. const tableProps = [
  65. "uid",
  66. "nickname",
  67. "type_name",
  68. "start_date",
  69. "end_date",
  70. "cancel_date",
  71. "operator_name",
  72. "pay_date",
  73. "total_month",
  74. "total_price",
  75. "status_name",
  76. "action"
  77. ];
  78. // 现在环境是线上还是测试, 默认线上
  79. let env = "";
  80. export default {
  81. data() {
  82. return {
  83. // 原始数据
  84. listData: {},
  85. // 头部信息
  86. titleInfo: {},
  87. // 数据总条目
  88. totalCount: 0,
  89. // 当前页面
  90. currentPage: 1,
  91. pageSize:20,
  92. // 列表头显示内容
  93. tableHeaders,
  94. // 列表头字段
  95. tableProps,
  96. // 列表数据
  97. tableData: []
  98. };
  99. },
  100. computed: {
  101. whole() {
  102. return this.listData.whole || {};
  103. }
  104. },
  105. mounted() {
  106. this.getTableData();
  107. },
  108. filters: {
  109. toDate(val) {
  110. return new Date(val * 1000).toLocaleDateString();
  111. },
  112. projectLink(i) {
  113. const type = i.entity_type;
  114. let link = "javascript:void(0)";
  115. if (type === "1")
  116. link =
  117. this.$store.state.domainConfig.siteUrl +
  118. `/rooter/outsourceitem/${i.entity_id}>`;
  119. else if (type === "3")
  120. link =
  121. this.$store.state.domainConfig.siteUrl +
  122. `/rooter/wagedetails?job_id=${i.entity_id}`;
  123. return link;
  124. }
  125. },
  126. methods: {
  127. /**
  128. * 点击 uid
  129. */
  130. clickUID({ uid }) {
  131. window.open(
  132. this.$store.state.domainConfig.siteUrl + `/rooter/user/${uid}`
  133. );
  134. },
  135. // 页码变动
  136. changePagination() {
  137. this.getTableData();
  138. },
  139. // 格式化列表数据
  140. formatTableData(data) {
  141. return data.map(i => {
  142. let projectName = "--";
  143. let prePay = "";
  144. let servicePay = "";
  145. let getPay = "";
  146. let realGet = "";
  147. return {
  148. ...i
  149. };
  150. });
  151. },
  152. // 获取列表数据
  153. async getTableData() {
  154. this.tableData = [];
  155. const p = this.currentPage;
  156. const res = await this.$post("/api/admin/vip/getVips", {
  157. page: this.currentPage,
  158. page_size: this.page_size
  159. });
  160. // console.log(res)
  161. const data = res.data;
  162. env = data.current_env;
  163. const list = data.list;
  164. this.listData = data;
  165. this.tableData = list; // this.formatTableData(list, data)
  166. this.totalCount = Number(data.total);
  167. this.totalPage = data.pages;
  168. },
  169. async cancelUserVip(item) {
  170. const res = await this.$post("/api/admin/vip/cancelVips", {uid: item.uid});
  171. if (res.status > 0)
  172. this.$message({
  173. message: res.info,
  174. type: "success"
  175. });
  176. this.getTableData();
  177. }
  178. }
  179. };
  180. </script>
  181. <style scoped>
  182. .table {
  183. height: 100%;
  184. height: calc(100% - 80px);
  185. }
  186. </style>