index.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. <template>
  2. <div class="app-container">
  3. <!-- 搜索区域 -->
  4. <div class="filter-container">
  5. <span>手机号:</span>
  6. <el-input
  7. v-model="listQuery.mobile"
  8. placeholder="手机号"
  9. style="width: 200px"
  10. class="filter-item"
  11. @keyup.enter.native="getList"
  12. />
  13. <span>状态:</span>
  14. <el-select
  15. v-model="listQuery.status"
  16. placeholder="邀请码状态"
  17. clearable
  18. style="width: 200px"
  19. class="filter-item"
  20. @change="getList"
  21. >
  22. <el-option label="全部" value="" />
  23. <el-option label="已绑定" :value="1" />
  24. <el-option label="未绑定" :value="0" />
  25. <el-option label="已过期" :value="2" />
  26. </el-select>
  27. <el-button type="primary" icon="el-icon-search" @click="getList">查询</el-button>
  28. <el-button icon="el-icon-thumb" type="primary" @click="handleMakeGenerate">生成邀请码</el-button>
  29. </div>
  30. <!-- 搜索区域END -->
  31. <!-- 表格区域 -->
  32. <el-table
  33. v-loading="listLoading"
  34. :data="list"
  35. style="width: 100%"
  36. border
  37. fit
  38. highlight-current-row
  39. cell-class-name="table-cell"
  40. >
  41. <el-table-column label="序号" :index="indexMethod" type="index" width="80px" align="center" />
  42. <el-table-column label="邀请码" prop="invitationCode" width="100px" align="center" />
  43. <el-table-column label="状态" width="100px" align="center">
  44. <template slot-scope="{ row }">
  45. <el-tag v-if="row.status === 0" size="small" type="warning">未绑定</el-tag>
  46. <el-tag v-if="row.status === 1" size="small" type="success">已绑定</el-tag>
  47. <el-tag v-if="row.status === 2" size="small" type="danger">已过期</el-tag>
  48. </template>
  49. </el-table-column>
  50. <el-table-column label="添加时间" width="200px" align="center">
  51. <template slot-scope="{row}">
  52. <span>{{ row.addTime | formatTime }}</span>
  53. </template>
  54. </el-table-column>
  55. <el-table-column label="微信昵称" align="center">
  56. <template slot-scope="{row}">
  57. <span v-if="row.nickName">{{ row.nickName }}</span>
  58. <span v-else>—</span>
  59. </template>
  60. </el-table-column>
  61. <el-table-column label="手机号" width="140" align="center">
  62. <template slot-scope="{row}">
  63. <span v-if="row.mobile">{{ row.mobile }}</span>
  64. <span v-else>—</span>
  65. </template>
  66. </el-table-column>
  67. <el-table-column label="openID" width="280" align="center">
  68. <template slot-scope="{row}">
  69. <span v-if="row.openId">{{ row.openId }}</span>
  70. <span v-else>—</span>
  71. </template>
  72. </el-table-column>
  73. <el-table-column label="绑定时间" width="200px" align="center">
  74. <template slot-scope="{row}">
  75. <span v-if="row.bindTime">{{ row.bindTime | formatTime }}</span>
  76. <span v-else>—</span>
  77. </template>
  78. </el-table-column>
  79. <el-table-column label="操作" width="200px" align="center">
  80. <template slot-scope="{row}">
  81. <el-button v-if="row.status === 1" type="danger" size="mini" style="margin-right:5px" @click="handleUnbindGenerate(row)">解绑邀请码</el-button>
  82. <el-button v-else type="primary" size="mini" style="margin-right:5px" @click="handleUpdateGenerate(row)">更新邀请码</el-button>
  83. </template>
  84. </el-table-column>
  85. </el-table>
  86. <!-- 表格区域END -->
  87. <pagination v-show="total>0" :total="total" :page.sync="listQuery.pageNum" :limit.sync="listQuery.pageSize" @pagination="getList(listQuery)" />
  88. </div>
  89. </template>
  90. <script>
  91. import Pagination from '@/components/Pagination' // secondary package based on el-pagination
  92. import { formatDate } from '@/utils'
  93. import { mapGetters } from 'vuex'
  94. import { getAuthUserList, makeGenerate, unbindGenerate, updateGenerate } from '@/api/auth'
  95. export default {
  96. components: { Pagination },
  97. filters: {
  98. formatTime(time) {
  99. if (!time) {
  100. return ''
  101. }
  102. return formatDate(time, 'yyyy-MM-DD HH:mm:ss')
  103. }
  104. },
  105. data() {
  106. return {
  107. total: 0,
  108. authId: '', // 机构id
  109. listLoading: false,
  110. listQuery: {
  111. authId: '', // 机构id
  112. mobile: '', // 手机号
  113. status: '', // 邀请码状态
  114. pageNum: 0, // 页码
  115. pageSize: 10 // 分页大小
  116. },
  117. list: [],
  118. srcList: []
  119. }
  120. },
  121. computed: {
  122. ...mapGetters(['authUserId'])
  123. },
  124. created() {
  125. this.authId = this.$route.query.id
  126. this.getList()
  127. },
  128. methods: {
  129. // 获取列表数据
  130. getList() {
  131. this.listLoading = true
  132. this.listQuery.authId = this.authId
  133. getAuthUserList(this.listQuery)
  134. .then(res => {
  135. if (res.code !== 0) return
  136. this.list = res.data.list
  137. this.total = res.data.total
  138. console.log(res)
  139. })
  140. .finally(() => {
  141. this.listLoading = false
  142. })
  143. },
  144. // 生成邀请码
  145. handleMakeGenerate() {
  146. makeGenerate({ authId: this.authId })
  147. .then(res => {
  148. console.log(res)
  149. if (res.code !== 0) return
  150. this.$message({
  151. type: 'success',
  152. message: res.data,
  153. duration: 500
  154. })
  155. this.getList()
  156. })
  157. },
  158. // 更新邀请码
  159. handleUpdateGenerate(row) {
  160. updateGenerate({ clubUserId: row.clubUserId })
  161. .then(res => {
  162. if (res.code !== 0) return
  163. console.log(res)
  164. this.$message({
  165. type: 'success',
  166. message: res.data,
  167. duration: 500
  168. })
  169. this.getList()
  170. })
  171. },
  172. // 解绑邀请码
  173. handleUnbindGenerate(row) {
  174. unbindGenerate({ clubUserId: row.clubUserId })
  175. .then(res => {
  176. if (res.code !== 0) return
  177. console.log(res)
  178. this.$message({
  179. type: 'success',
  180. message: res.data,
  181. duration: 500
  182. })
  183. this.getList()
  184. })
  185. },
  186. indexMethod(index) {
  187. return index + this.listQuery.pageSize * (this.listQuery.pageNum - 1) + 1
  188. }
  189. }
  190. }
  191. </script>
  192. <style lang="scss" scoped>
  193. .filter-container {
  194. span {
  195. display: inline-block;
  196. margin-bottom: 10px;
  197. vertical-align: middle;
  198. font-size: 14px;
  199. }
  200. .el-button {
  201. display: inline-block;
  202. margin-bottom: 10px;
  203. vertical-align: middle;
  204. }
  205. .el-input,
  206. .el-select {
  207. margin-right: 10px;
  208. margin-left: 10px;
  209. }
  210. }
  211. .el-table .cell {
  212. overflow: visible;
  213. }
  214. .el-badge{
  215. margin: 0 6px;
  216. }
  217. </style>