index.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. <template>
  2. <div class="mine">
  3. <div class="table">
  4. <el-input
  5. class="search-input"
  6. placeholder="请输入内容"
  7. prefix-icon="el-icon-search"
  8. size="mini"
  9. v-model="searckItem"
  10. ></el-input>
  11. <div class="search-button" @click="getUserList">搜索</div>
  12. <div class="coupon">选择优惠券</div>
  13. <el-select
  14. class="coupon-select"
  15. v-model="coupon"
  16. size="mini"
  17. placeholder="选择优惠券"
  18. >
  19. <el-option
  20. v-for="item in couponList"
  21. :key="item.id"
  22. :label="item.name"
  23. :value="item.id"
  24. ></el-option>
  25. </el-select>
  26. <div class="num-tips">数量</div>
  27. <div class="coupon-num">
  28. <div class="reduce" @click="reduceNum">-</div>
  29. <div class="num">{{ couponNum }}</div>
  30. <div class="add" @click="couponNum++">+</div>
  31. </div>
  32. <div class="send-coupon" style="margin-left: 39px" @click="sendCoupon">
  33. 发送
  34. </div>
  35. </div>
  36. <div class="user-list">
  37. <el-table
  38. ref="multipleTable"
  39. :data="tableData"
  40. tooltip-effect="dark"
  41. height="500"
  42. style="width: 100%; border-radius: 8px"
  43. @selection-change="handleSelectionChange"
  44. @row-click="goDetail"
  45. >
  46. <el-table-column type="selection" width="55"></el-table-column>
  47. <el-table-column label="头像" width="120">
  48. <template slot-scope="scope">
  49. <div class="head-img">
  50. <img :src="scope.row.avatar_url" alt />
  51. </div>
  52. </template>
  53. </el-table-column>
  54. <el-table-column
  55. prop="nickname"
  56. label="昵称"
  57. width="120"
  58. ></el-table-column>
  59. <el-table-column
  60. prop="mobile"
  61. label="联系电话"
  62. show-overflow-tooltip
  63. ></el-table-column>
  64. <el-table-column
  65. prop="create_time"
  66. label="注册时间"
  67. show-overflow-tooltip
  68. ></el-table-column>
  69. </el-table>
  70. <div class="pagin">
  71. <el-pagination
  72. background
  73. layout="prev, pager, next"
  74. @size-change="handleSizeChange"
  75. @current-change="handleCurrentChange"
  76. :current-page.sync="currentPage1"
  77. :total="total"
  78. ></el-pagination>
  79. </div>
  80. </div>
  81. </div>
  82. </template>
  83. <script>
  84. import api from "../../server/home";
  85. export default {
  86. components: {},
  87. data() {
  88. return {
  89. searckItem: "",
  90. couponList: [],
  91. tableData: [],
  92. multipleSelection: [], //选中的列表
  93. coupon: "",
  94. couponNum: 1, //优惠券数量
  95. currentPage1: 1,
  96. total: 0,
  97. limit: 10,
  98. };
  99. },
  100. computed: {},
  101. watch: {},
  102. methods: {
  103. // 发券中心点击用户跳转到用户详情
  104. goDetail(row, column, event) {
  105. console.log(1);
  106. this.$router.push({
  107. path: "/customerMan/details",
  108. query: {
  109. id: row.id,
  110. },
  111. });
  112. },
  113. reduceNum() {
  114. this.couponNum > 1 ? this.couponNum-- : (this.couponNum = 1);
  115. },
  116. handleSelectionChange(val) {
  117. this.multipleSelection = val;
  118. },
  119. // 发送优惠券
  120. sendCoupon() {
  121. let selectIds = "";
  122. for (let i = 0; i < this.multipleSelection.length; i++) {
  123. selectIds = selectIds + "," + this.multipleSelection[i].id;
  124. }
  125. let params = {
  126. id: this.coupon,
  127. user_ids: selectIds.substring(1, selectIds.length),
  128. num: this.couponNum,
  129. };
  130. api.sendCoupon(params).then((res) => {
  131. if (res.code == 200) {
  132. this.$message({
  133. message: "发送成功",
  134. type: "success",
  135. });
  136. }
  137. });
  138. },
  139. // 获取订单列表
  140. getUserList() {
  141. let params = {
  142. page: this.currentPage1,
  143. limit: this.limit,
  144. keywords: this.searckItem,
  145. };
  146. api.getUserList(params).then((res) => {
  147. if (res.code == 200) {
  148. // 将用户手机号中间四位变成****
  149. res.data.list.map((item) => {
  150. item.mobile =
  151. item.mobile.substring(0, 3) + "****" + item.mobile.substring(7);
  152. });
  153. this.tableData = res.data.list;
  154. this.total = res.data.total;
  155. }
  156. });
  157. },
  158. // 获取优惠券列表
  159. getCouponInfo() {
  160. let params = {
  161. page: this.currentPage1,
  162. limit: 100,
  163. };
  164. api.getCouponInfo(params).then((res) => {
  165. if (res.code == 200) {
  166. this.couponList = res.data.list;
  167. }
  168. });
  169. },
  170. handleCurrentChange(e) {
  171. this.currentPage1 = e;
  172. this.getUserList();
  173. },
  174. handleSizeChange(val) {},
  175. },
  176. created() {
  177. this.getUserList();
  178. this.getCouponInfo();
  179. },
  180. mounted() {},
  181. };
  182. </script>
  183. <style lang='less' scoped>
  184. .mine {
  185. .table {
  186. display: flex;
  187. align-items: center;
  188. font-size: 14px;
  189. font-family: PingFangSC-Regular, PingFang SC;
  190. font-weight: 400;
  191. color: #333333;
  192. line-height: 20px;
  193. .search-input {
  194. width: 152px;
  195. }
  196. .search-button,
  197. .send-coupon {
  198. margin-left: 16px;
  199. width: 68px;
  200. height: 28px;
  201. line-height: 28px;
  202. background: #fa7d22;
  203. border-radius: 2px;
  204. font-size: 14px;
  205. font-family: PingFangSC-Medium, PingFang SC;
  206. font-weight: 500;
  207. color: #ffffff;
  208. text-align: center;
  209. }
  210. .coupon {
  211. margin-left: 40px;
  212. }
  213. .coupon-select {
  214. margin-left: 12px;
  215. width: 174px;
  216. }
  217. .num-tips {
  218. margin-left: 40px;
  219. }
  220. .coupon-num {
  221. margin-left: 12px;
  222. background: #ffffff;
  223. display: flex;
  224. div {
  225. width: 28px;
  226. height: 28px;
  227. line-height: 28px;
  228. text-align: center;
  229. }
  230. .reduce,
  231. .add {
  232. border: 1px solid #d9d9d9;
  233. line-height: 26px;
  234. font-size: 18px;
  235. }
  236. .num {
  237. border-top: 1px solid #d9d9d9;
  238. border-bottom: 1px solid #d9d9d9;
  239. }
  240. }
  241. }
  242. .user-list {
  243. margin-top: 18px;
  244. padding: 0 12px;
  245. width: 100%;
  246. background: #ffffff;
  247. box-shadow: 0px 2px 4px 0px rgba(184, 191, 198, 0.2);
  248. border-radius: 8px;
  249. .head-img {
  250. width: 36px;
  251. height: 36px;
  252. border-radius: 50%;
  253. img {
  254. width: 100%;
  255. height: 100%;
  256. }
  257. }
  258. .pagin {
  259. padding: 20px 0;
  260. .el-pagination {
  261. text-align: center;
  262. }
  263. }
  264. /deep/ .el-table th > .cell {
  265. font-size: 14px !important;
  266. font-family: PingFangSC-Regular, PingFang SC;
  267. font-weight: 400;
  268. color: #999999;
  269. line-height: 20px;
  270. }
  271. /deep/ .el-table td,
  272. .el-table th.is-leaf {
  273. border-bottom: none;
  274. }
  275. }
  276. }
  277. </style>