vip_manager.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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" height="100%" 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. <span v-else>{{scope.row[prop]}}</span>
  22. </template>
  23. </el-table-column>
  24. </el-table>
  25. </div>
  26. <el-pagination
  27. @current-change="changePagination"
  28. :current-page.sync="currentPage"
  29. :page-size="10"
  30. layout="total, prev, pager, next"
  31. :total="totalCount"
  32. ></el-pagination>
  33. </div>
  34. </template>
  35. <script>
  36. const tableHeaders = [
  37. "用户ID",
  38. "昵称",
  39. "会员类型",
  40. "开始时间",
  41. "到期时间",
  42. "最新购买",
  43. "累计月数",
  44. "累计金额",
  45. "当前状态",
  46. ]
  47. const tableProps = [
  48. "uid",
  49. "nickname",
  50. "type_name",
  51. "start_date",
  52. "end_date",
  53. "pay_date",
  54. "total_month",
  55. "total_price",
  56. "status_name",
  57. ]
  58. // 现在环境是线上还是测试, 默认线上
  59. let env = ''
  60. export default {
  61. data() {
  62. return {
  63. // 原始数据
  64. listData: {},
  65. // 头部信息
  66. titleInfo: {},
  67. // 数据总条目
  68. totalCount: 0,
  69. // 当前页面
  70. currentPage: 1,
  71. // 列表头显示内容
  72. tableHeaders,
  73. // 列表头字段
  74. tableProps,
  75. // 列表数据
  76. tableData: [],
  77. }
  78. },
  79. computed: {
  80. whole() {
  81. return this.listData.whole || {}
  82. }
  83. },
  84. mounted() {
  85. this.getTableData()
  86. },
  87. filters: {
  88. toDate(val) {
  89. return new Date(val * 1000).toLocaleDateString()
  90. },
  91. projectLink(i) {
  92. const type = i.entity_type
  93. let link = 'javascript:void(0)'
  94. if(type === '1') link = `/rooter/outsourceitem/${i.entity_id}>`
  95. else if(type === '3') link = `/rooter/wagedetails?job_id=${i.entity_id}`
  96. return link
  97. }
  98. },
  99. methods: {
  100. /**
  101. * 点击 uid
  102. */
  103. clickUID({uid}) {
  104. if(env === 'test') window.open(`https://dev.test.proginn.com/rooter/user/${uid}`)
  105. else window.open(`https://www.proginn.com/rooter/user/${uid}`)
  106. },
  107. // 页码变动
  108. changePagination() {
  109. this.getTableData()
  110. },
  111. // 格式化列表数据
  112. formatTableData(data) {
  113. return data.map(i => {
  114. let projectName = '--'
  115. let prePay = ''
  116. let servicePay = ''
  117. let getPay = ''
  118. let realGet = ''
  119. return {
  120. ...i,
  121. }
  122. })
  123. },
  124. // 获取列表数据
  125. async getTableData() {
  126. this.tableData = []
  127. const p = this.currentPage
  128. const res = await this.$post("/api/admin/vip/getVips", { page: this.currentPage, page_size: 10 })
  129. // console.log(res)
  130. const data = res.data
  131. env = data.current_env
  132. const list = data.list
  133. this.listData = data
  134. this.tableData = list // this.formatTableData(list, data)
  135. this.totalCount = Number(data.total)
  136. this.totalPage = data.pages
  137. }
  138. }
  139. }
  140. </script>
  141. <style scoped>
  142. .table {
  143. height: 100%;
  144. height: calc(100% - 80px);
  145. }
  146. </style>