index.php 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532
  1. <?php
  2. use common\helpers\ComponentHelper;
  3. ComponentHelper::loadComponentView('com-user-info');
  4. ?>
  5. <style>
  6. .set-el-button {
  7. padding: 0!important;
  8. border: 0;
  9. margin: 0 5px;
  10. }
  11. .sort-input {
  12. width: 100%;
  13. background-color: #F3F5F6;
  14. height: 32px;
  15. }
  16. .sort-input span {
  17. height: 32px;
  18. width: 100%;
  19. line-height: 32px;
  20. display: inline-block;
  21. padding: 0 10px;
  22. font-size: 13px;
  23. }
  24. .sort-input .el-input__inner {
  25. height: 32px;
  26. line-height: 32px;
  27. background-color: #F3F5F6;
  28. float: left;
  29. padding: 0 10px;
  30. border: 0;
  31. }
  32. .table-body {
  33. padding: 20px;
  34. background-color: #fff;
  35. }
  36. .table-info .el-button {
  37. padding: 0 !important;
  38. border: 0;
  39. margin: 0 5px;
  40. }
  41. .input-item {
  42. display: inline-block;
  43. width: 250px;
  44. margin: 0 0 20px;
  45. }
  46. .input-item .el-input__inner {
  47. border-right: 0;
  48. }
  49. .input-item .el-input__inner:hover{
  50. border: 1px solid #dcdfe6;
  51. border-right: 0;
  52. outline: 0;
  53. }
  54. .input-item .el-input__inner:focus{
  55. border: 1px solid #dcdfe6;
  56. border-right: 0;
  57. outline: 0;
  58. }
  59. .input-item .el-input-group__append {
  60. background-color: #fff;
  61. border-left: 0;
  62. width: 10%;
  63. padding: 0;
  64. }
  65. .input-item .el-input-group__append .el-button {
  66. padding: 0;
  67. }
  68. .input-item .el-input-group__append .el-button {
  69. margin: 0;
  70. }
  71. .el-table th>.cell {
  72. color: #333;
  73. font-weight: bold;
  74. font-size: 14px;
  75. }
  76. .table1 .el-table__footer-wrapper,
  77. .table1 .el-table__header-wrapper {
  78. border-bottom: 1.4px solid #D6D6D6;
  79. }
  80. .user_img{
  81. position: relative;
  82. margin-right: 8px;
  83. /* height: 50px;
  84. width: 50px; */
  85. }
  86. .default-avatar{
  87. width: 50px;
  88. height: 50px;
  89. border-radius: 50%;
  90. margin-right: 8px;
  91. }
  92. .uer-nickname {
  93. flex: 1;
  94. }
  95. .trans-block {
  96. padding: 0 15px;
  97. }
  98. .status-search .el-input__inner{
  99. border: 1px solid #DCDFE6 !important;
  100. }
  101. </style>
  102. <div id="app" v-cloak>
  103. <el-card shadow="never" style="border:0" body-style="background-color: #f3f3f3;padding: 10px 0 0;">
  104. <div slot="header">
  105. <span>会员优惠券</span>
  106. </div>
  107. <div class="table-body">
  108. <el-form :inline="true" :model="search_data" size="small" class="demo-form-inline">
  109. <div class="input-item">
  110. <el-input @keyup.enter.native="search" size="small" placeholder="请输入优惠券名称搜索" v-model="keyword" clearable @clear="search">
  111. <el-button slot="append" icon="el-icon-search" @click="search"></el-button>
  112. </el-input>
  113. </div>
  114. <div class="input-item">
  115. <el-input @keyup.enter.native="search" size="small" placeholder="请输入会员ID" v-model="user_id" clearable @clear="search">
  116. <el-button slot="append" icon="el-icon-search" @click="search"></el-button>
  117. </el-input>
  118. </div>
  119. <div class="input-item">
  120. <el-input @keyup.enter.native="search" size="small" placeholder="请输入手机号" v-model="mobile" clearable @clear="search">
  121. <el-button slot="append" icon="el-icon-search" @click="search"></el-button>
  122. </el-input>
  123. </div>
  124. <div class="input-item status-search">
  125. <el-select v-model="status" placeholder="请选择" size="small">
  126. <el-option label="全部" :value="0"></el-option>
  127. <el-option v-for="(item,index) in status_text" :key="index" :label="item" :value="index">{{item}}
  128. </el-option>
  129. </el-select>
  130. </div>
  131. <div class="input-item">
  132. <el-button type="primary" size="small" @click="search" style="margin-left: 15px;">搜索</el-button>
  133. <el-button type="warning" @click="clereSearch" v-if="keyword || user_id || mobile || status" style="padding: 9px 15px !important;">清除搜索条件</el-button>
  134. </div>
  135. </el-form>
  136. <el-button @click="allDeleteBatch" size="mini">批量删除</el-button>
  137. <el-table v-loading="loading" :data="list" style="width: 100%;margin-bottom: 15px" @selection-change="handleSelectionChange">
  138. <el-table-column type="selection" align="center" width="60"></el-table-column>
  139. <el-table-column prop="id" label="ID"></el-table-column>
  140. <el-table-column prop="user_id" label="会员ID"></el-table-column>
  141. <el-table-column label="会员" width="180">
  142. <template slot-scope="scope">
  143. <div class="user_img" flex="cross:center">
  144. <el-image class="default-avatar" :src="scope.row.avatar_url">
  145. <div slot="error" class="image-slot">
  146. <com-image src="/resources/img/common/default-avatar.png"></com-image>
  147. </div>
  148. </el-image>
  149. <div class="uer-nickname over1" v-if="scope.row.nickname">{{scope.row.nickname}}</div>
  150. <div class="uer-nickname over1" v-else>--</div>
  151. </div>
  152. </template>
  153. </el-table-column>
  154. <el-table-column prop="name" label="优惠券名称"></el-table-column>
  155. <el-table-column prop="min_price" label="最低消费金额(元)"></el-table-column>
  156. <el-table-column prop="sub_price" label="优惠方式">
  157. <template slot-scope="scope">
  158. <!-- <div v-if="scope.row.type == 2">优惠:{{scope.row.sub_price}}元</div>
  159. <div v-if="scope.row.type == 1">{{scope.row.discount}}折</div> -->
  160. <div>{{scope.row.content}}</div>
  161. </template>
  162. </el-table-column>
  163. <el-table-column prop="sub_price" label="使用范围">
  164. <template slot-scope="scope">
  165. <span v-if="scope.row.appoint_type == 1">指定商品类目</span>
  166. <span v-if="scope.row.appoint_type == 2">指定商品</span>
  167. <span v-if="scope.row.appoint_type == 3">全场通用</span>
  168. <span v-if="scope.row.appoint_type == 4">当面付</span>
  169. <span v-if="scope.row.appoint_type == 6">指定门店商品</span>
  170. </template>
  171. </el-table-column>
  172. <!-- <el-table-column prop="expire_type" label="过期时间">
  173. <template slot-scope="scope">
  174. <span v-if="scope.row.expire_type == 1">
  175. {{scope.row.end_time|dateTimeFormat('Y-m-d H:i:s')}}
  176. </span>
  177. <span v-else-if="scope.row.expire_type == 2">
  178. {{scope.row.begin_at|dateTimeFormat('Y-m-d H:i:s')}}至/
  179. {{scope.row.end_at|dateTimeFormat('Y-m-d H:i:s')}}
  180. </span>
  181. </template>
  182. </el-table-column> -->
  183. <!-- <el-table-column prop="receive_type" label="领取场景">
  184. <template slot-scope="scope">
  185. <span>{{scope.row.receive_type}}</span>
  186. </template>
  187. </el-table-column> -->
  188. <el-table-column prop="receive_platform" label="领取来源">
  189. <template slot-scope="scope">
  190. <span>{{scope.row.receive_type}}</span>
  191. </template>
  192. </el-table-column>
  193. <el-table-column prop="is_use" label="是否使用">
  194. <template slot-scope="scope">
  195. <span v-if="scope.row.is_use == 1">
  196. 已使用
  197. </span>
  198. <span v-else-if="scope.row.is_use == 0">
  199. 未使用
  200. </span>
  201. </template>
  202. </el-table-column>
  203. <el-table-column prop="created_at" label="领取时间">
  204. <template slot-scope="scope">
  205. {{scope.row.created_at|dateTimeFormat('Y-m-d H:i:s')}}
  206. </template>
  207. </el-table-column>
  208. <el-table-column prop="created_at" label="使用时间" align="center">
  209. <template slot-scope="scope">
  210. <span v-if="scope.row.is_use == 1">
  211. {{scope.row.used_time|dateTimeFormat('Y-m-d H:i:s')}}
  212. </span>
  213. <span v-else>--</span>
  214. </template>
  215. </el-table-column>
  216. <el-table-column label="状态">
  217. <template slot-scope="scope">
  218. <div v-if="scope.row.is_giving == 0">
  219. <el-tag v-if="scope.row.coupon_status == 1">未开始</el-tag>
  220. <el-tag v-if="scope.row.coupon_status == 2">已领取</el-tag>
  221. <el-tag v-if="scope.row.coupon_status == 3" type="info">已过期</el-tag>
  222. <el-tag v-if="scope.row.coupon_status == 4" type="info">已失效</el-tag>
  223. </div>
  224. <div v-else>
  225. <el-tag type="warning" v-if="scope.row.giving_status == 1">转赠中</el-tag>
  226. <el-tooltip v-if="scope.row.giving_status == 2" class="item" effect="dark" :content="scope.row.giving_user" placement="top-end">
  227. <el-tag type="danger">已转赠</el-tag>
  228. </el-tooltip>
  229. </div>
  230. </template>
  231. </el-table-column>
  232. <el-table-column label="操作" align="center" width="140">
  233. <template slot-scope="scope">
  234. <el-button type="text" @click="handleFrom(scope.row)">来源</el-button>
  235. <el-button type="text" @click="invalid(scope.row)" v-if="scope.row.is_use == 0 && scope.row.coupon_status == 2">失效</el-button>
  236. <!-- <el-button type="text" @click="handle('destroy', scope.row)">删除</el-button> -->
  237. </template>
  238. </el-table-column>
  239. </el-table>
  240. <div flex="box:last cross:center">
  241. <div style="visibility: hidden">
  242. <el-button plain type="primary" size="small">批量操作1</el-button>
  243. <el-button plain type="primary" size="small">批量操作2</el-button>
  244. </div>
  245. <div>
  246. <el-pagination v-if="pagination" :page-size="page_size" style="float: right;" background @current-change="pageChange" layout="prev, pager, next" :total="pagination.totalCount">
  247. </el-pagination>
  248. </div>
  249. </div>
  250. </div>
  251. <el-dialog title="优惠券转赠记录追溯" :visible.sync="dialogTableVisible">
  252. <div class="trans-block" v-loading="transLoad">
  253. <template v-if="transList.length > 0">
  254. <el-timeline>
  255. <el-timeline-item
  256. :timestamp="item.timestamp"
  257. :color="item.color"
  258. placement="top"
  259. v-for="(item, index) in transList"
  260. :key="index"
  261. >
  262. <el-card>
  263. <com-user-info :user="item.user"></com-user-info>
  264. </el-card>
  265. </el-timeline-item>
  266. </el-timeline>
  267. </template>
  268. <el-empty description="暂无记录" v-if="transList.length == 0"></el-empty>
  269. </div>
  270. </el-dialog>
  271. </el-card>
  272. </div>
  273. <script>
  274. const app = new Vue({
  275. el: '#app',
  276. data() {
  277. return {
  278. loading: false,
  279. list: [],
  280. keyword: '',
  281. user_id: '',
  282. mobile:'',
  283. pagination: null,
  284. page: 1,
  285. page_size: 10,
  286. search_data: { // 筛选条件
  287. },
  288. chooseList: [],
  289. dialogTableVisible: false,
  290. gridData: [],
  291. transId: '', // 当前查询ID
  292. transLoad: false,
  293. status: 0,
  294. status_text: {
  295. 1: '已过期',
  296. 2: '已领取',
  297. 3: '转增中',
  298. 4: '已转增'
  299. },
  300. };
  301. },
  302. computed: {
  303. /**
  304. * 优惠券转赠记录追溯
  305. */
  306. transList: function () {
  307. return this.gridData.map(item => {
  308. return {
  309. timestamp: item.created_at,
  310. user: item.user,
  311. color: this.transId == item.id ? '#0bbd87' : '',
  312. }
  313. })
  314. },
  315. },
  316. methods: {
  317. //搜索
  318. search() {
  319. this.page = 1;
  320. this.loadData();
  321. },
  322. // 清除搜索条件
  323. clereSearch() {
  324. this.keyword = '';
  325. this.user_id = null;
  326. this.mobile = '';
  327. this.status = 0;
  328. this.loadData();
  329. },
  330. //分页
  331. pageChange(page) {
  332. this.page = page;
  333. this.loadData();
  334. },
  335. // 根据参数获取请求信息
  336. loadData() {
  337. this.loading = true;
  338. console.log(this.keyword)
  339. request({
  340. params: {
  341. r: 'coupon/user-coupon/index',
  342. keyword: this.keyword,
  343. user_id: this.user_id,
  344. mobile: this.mobile,
  345. page: this.page,
  346. status: this.status
  347. },
  348. }).then(e => {
  349. this.loading = false;
  350. if (e.data.code === 0) {
  351. this.list = e.data.data.list;
  352. this.pagination = e.data.data.pagination;
  353. this.page_size = e.data.data.page_size;
  354. } else {
  355. this.listLoading = false;
  356. this.$message({
  357. message: e.data.msg,
  358. type: 'error'
  359. });
  360. }
  361. }).catch(e => {
  362. this.listLoading = false;
  363. });
  364. },
  365. invalid(row) { // 优惠券失效
  366. if (row.id === '' || row.id === undefined || row.id === null) {
  367. this.$message.error('请选择要失效的优惠券');
  368. return;
  369. }
  370. this.$confirm(
  371. '优惠券失效后将不能使用并不可恢复,是否继续?',
  372. '警告',
  373. {type: 'warning'}
  374. ).then(() => {
  375. const loading = this.$loading({
  376. lock: true,
  377. text: 'Loading',
  378. spinner: 'el-icon-loading',
  379. background: 'rgba(0, 0, 0, 0.7)'
  380. });
  381. const url = 'coupon/user-coupon/transfer'
  382. request({
  383. params: {
  384. r: url,
  385. id: row.id
  386. },
  387. method: 'get'
  388. }).then(res => {
  389. loading.close();
  390. if (res.data.code === 0) {
  391. this.$message({
  392. message: res.data.msg,
  393. type: 'success',
  394. duration: 2000,
  395. onClose: () => {
  396. window.location.reload();
  397. }
  398. });
  399. } else {
  400. this.$message.error(res.data.msg);
  401. }
  402. }).catch(e => {});
  403. }).catch(() => {});
  404. },
  405. // 操作处理
  406. handle(type, data = null) {
  407. let id = data ? parseInt(data.id) : '';
  408. switch (type) {
  409. case 'destroy':
  410. params = {id: data.id, status: -1};
  411. this.$confirm('删除该条数据后不可以恢复, 是否继续?', '警告', {type: 'warning'}).then(() => {
  412. this.send(params,'coupon/user-coupon/handle',(resp) => {
  413. if (resp.code == 0) {
  414. navigateTo({r: 'coupon/user-coupon/index'});
  415. }
  416. })
  417. })
  418. break;
  419. }
  420. },
  421. send(params,url,callback) {
  422. let self = this;
  423. let basic_params = {
  424. r: url
  425. };
  426. params = Object.assign(basic_params, params);
  427. request({
  428. params: params,
  429. method: 'get'
  430. }).then(e => {
  431. if (e.data.code == 0) {
  432. self.$message.success(e.data.msg);
  433. } else {
  434. self.$message.error(e.data.msg);
  435. }
  436. if (callback) callback(e.data);
  437. }).catch(e => {
  438. console.log(e);
  439. });
  440. },
  441. allDeleteBatch() {
  442. this.$confirm('警告:是否确认删除所选会员优惠券?').then(() => {
  443. let self = this;
  444. let ids = this.getIds();
  445. if(ids.length==0){
  446. return false;
  447. }
  448. request({
  449. params: {
  450. r: 'coupon/user-coupon/del-batch',
  451. },
  452. method: 'post',
  453. data: {
  454. id:ids
  455. }
  456. }).then(e => {
  457. if (e.data.code == 0) {
  458. self.$message.success(e.data.msg);
  459. self.loadData();
  460. } else {
  461. self.$message.error(e.data.msg);
  462. }
  463. }).catch(e => {
  464. console.log(e);
  465. });
  466. });
  467. },
  468. getIds(){
  469. let self = this;
  470. console.log(1111,this.chooseList)
  471. if(this.chooseList.length==0){
  472. self.$message.error('请选择会员优惠券');
  473. return [];
  474. }
  475. let listMap = [];
  476. self.list.forEach(function (value, k) {
  477. listMap[value.id] = value;
  478. });
  479. let ids = [];
  480. this.chooseList.forEach(function (id, index){
  481. var value = listMap[id]
  482. ids.push(id);
  483. });
  484. return ids
  485. },
  486. handleSelectionChange(val) {
  487. let self = this;
  488. self.chooseList = [];
  489. val.forEach(function(item) {
  490. self.chooseList.push(item.id);
  491. })
  492. },
  493. handleFrom(row) {
  494. if (this.dialogTableVisible) return
  495. this.dialogTableVisible = true
  496. this.gridData = []
  497. this.transId = row.id
  498. this.transLoad = true
  499. request({
  500. params: {
  501. r: 'coupon/user-coupon/trans-log',
  502. id: row.id
  503. },
  504. method: 'get',
  505. }).then(e => {
  506. if (e.data.code == 0) {
  507. this.transLoad = false
  508. this.gridData = e.data.data
  509. }
  510. })
  511. },
  512. },
  513. created() {
  514. this.loadData();
  515. }
  516. })
  517. </script>