index.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606
  1. <style>
  2. .table-body {
  3. padding: 20px;
  4. background-color: #fff;
  5. }
  6. .input-item {
  7. display: inline-block;
  8. width: 250px;
  9. margin: 0 0 20px;
  10. }
  11. .input-item .el-input__inner {
  12. border-right: 0;
  13. }
  14. .input-item .el-input__inner:hover {
  15. border: 1px solid #dcdfe6;
  16. border-right: 0;
  17. outline: 0;
  18. }
  19. .input-item .el-input__inner:focus {
  20. border: 1px solid #dcdfe6;
  21. border-right: 0;
  22. outline: 0;
  23. }
  24. .input-item .el-input-group__append {
  25. background-color: #fff;
  26. border-left: 0;
  27. width: 10%;
  28. padding: 0;
  29. }
  30. .input-item .el-input-group__append .el-button {
  31. padding: 0;
  32. }
  33. .input-item .el-input-group__append .el-button {
  34. margin: 0;
  35. }
  36. .table-body .el-button {
  37. padding: 0 !important;
  38. border: 0;
  39. margin: 0 5px;
  40. }
  41. .el-table th > .cell {
  42. color: #333;
  43. font-weight: bold;
  44. font-size: 14px;
  45. }
  46. .el-table__footer-wrapper, .el-table__header-wrapper {
  47. border-bottom: 1.4px solid #D6D6D6;
  48. }
  49. .label {
  50. margin-right: 10px;
  51. }
  52. .default-goods{
  53. max-width: 50px;
  54. max-height: 50px;
  55. }
  56. .flex-x-between {
  57. display: -webkit-box;
  58. display: -webkit-flex;
  59. display: flex;
  60. -webkit-box-pack: space-between;
  61. -webkit-justify-content: space-between;
  62. -ms-flex-pack: space-between;
  63. justify-content: space-between;
  64. }
  65. .cont-title {
  66. font-size: 15px;
  67. padding-top: 20px;
  68. padding-bottom: 10px;
  69. font-weight: 700;
  70. }
  71. .cont-num {
  72. font-size: 14px;
  73. font-weight: 700;
  74. padding-bottom: 10px;
  75. }
  76. .center {
  77. text-align: center;
  78. }
  79. .el-dialog__header .el-dialog__title{
  80. font-size: 18px;
  81. }
  82. .el-dialog__wrapper .el-dialog__body{
  83. padding: 3px 20px;
  84. }
  85. /*头像样式 start*/
  86. .default-avatar{
  87. width: 50px;
  88. height: 50px;
  89. border-radius: 50%;
  90. }
  91. .user_img{
  92. position: relative;
  93. margin-right: 8px;
  94. height: 50px;
  95. width: 50px;
  96. }
  97. .el-table_2_column_8 .cell { /*-2 表示在第二行*/
  98. display: flex;
  99. }
  100. /*头像样式 end*/
  101. #qrcode-info{
  102. margin: 20px 31%;
  103. }
  104. </style>
  105. <div id="app" v-cloak>
  106. <el-card shadow="never" body-style="background-color: #f3f3f3;padding: 10px 0 0;">
  107. <div slot="header">
  108. <div>
  109. <span>活动列表</span>
  110. <div style="float: right; margin: -5px 0">
  111. <el-button type="primary" @click="add()" size="small">创建活动</el-button>
  112. </div>
  113. </div>
  114. </template>
  115. </div>
  116. <div class="table-body el-input--small">
  117. <el-form size="small" :inline="true" flex="dir:left cross:center" style="margin-bottom: 12px;">
  118. <div class="item-box" flex="dir:left cross:center">
  119. <div class="label">创建时间</div>
  120. <el-date-picker
  121. v-model="time"
  122. type="datetimerange"
  123. value-format="yyyy-MM-dd HH:mm:ss"
  124. range-separator="至"
  125. start-placeholder="开始日期"
  126. end-placeholder="结束日期">
  127. </el-date-picker>
  128. </div>
  129. <div class="item-box" flex="dir:left cross:center" style="margin-right: 20px; margin-left: 20px;">
  130. <div class="label">活动ID</div>
  131. <el-input style="width: 80px" v-model="search.id" placeholder="活动ID"></el-input>
  132. </div>
  133. <div class="item-box" flex="dir:left cross:center" style="margin-right: 20px">
  134. <div class="label">活动昵称</div>
  135. <el-input style="width: 150px" v-model="search.title" placeholder="活动昵称"></el-input>
  136. </div>
  137. <div class="item-box" flex="dir:left cross:center">
  138. <el-button type="primary" style="padding: 10px 20px !important;" @click="searchs">搜索
  139. </el-button>
  140. <el-button type="danger" size="small" style="padding: 10px 20px !important;" @click="resetSearch" v-if="show_clear_search_btn">清除条件</el-button>
  141. </div>
  142. </el-form>
  143. <el-table v-loading="listLoading" :data="list" stripe style="width: 100%">
  144. <el-table-column label="ID" min-width="80" align="center">
  145. <template slot-scope="scope">
  146. <p>{{scope.row.id}}</p>
  147. </template>
  148. </el-table-column>
  149. <el-table-column label="活动名称" min-width="80" align="center">
  150. <template slot-scope="scope">
  151. <p>{{scope.row.title}}</p>
  152. </template>
  153. </el-table-column>
  154. <el-table-column label="积分类型" min-width="80" align="center">
  155. <template slot-scope="scope">
  156. <p>{{integral_type[scope.row.integral_type]}}</p>
  157. </template>
  158. </el-table-column>
  159. <el-table-column label="状态" min-width="80" align="center">
  160. <template slot-scope="scope">
  161. <div v-if="scope.row.status == 0">失效</div>
  162. <div v-else>
  163. <p v-if="scope.row.start_time < new_time && scope.row.end_time > new_time">进行中</p>
  164. <p v-if="scope.row.end_time < new_time">已经结束</p>
  165. <p v-if="scope.row.start_time > new_time">未开始</p>
  166. </div>
  167. </template>
  168. </el-table-column>
  169. <el-table-column prop="scope" width="160" label="创建时间">
  170. <template slot-scope="scope">
  171. {{scope.row.created_at|dateTimeFormat('Y-m-d H:i:s')}}
  172. </template>
  173. </el-table-column>
  174. <el-table-column
  175. label="操作"
  176. min-width="180"
  177. align="center">
  178. <template slot-scope="scope">
  179. <el-button circle size="mini" type="text" @click="statistics(scope.row)">
  180. 数据
  181. </el-button>
  182. <el-button circle size="mini" type="text" @click="handle('edit',scope.row)">
  183. 编辑
  184. </el-button>
  185. <el-button circle size="mini" type="text" @click="handle('qrode',scope.row)">
  186. 推广
  187. </el-button>
  188. <el-button circle size="mini" type="text" @click="handle('copy',scope.row)">
  189. 复制
  190. </el-button>
  191. <el-button v-if="scope.row.status == 1" circle size="mini" type="text" @click="handle('unenable',scope.row)">
  192. 失效
  193. </el-button>
  194. <el-button v-if="scope.row.status == 0" circle size="mini" type="text" @click="handle('enable',scope.row)">
  195. 启用
  196. </el-button>
  197. <el-button circle size="mini" type="text" @click="handle('delete',scope.row)">
  198. 删除
  199. </el-button>
  200. </template>
  201. </el-table-column>
  202. </el-table>
  203. <div style="text-align: right;margin: 20px 0;">
  204. <el-pagination v-if="pagination" :page-size="pagination.pageSize"
  205. style="display: inline-block;float: right;" background @current-change="pageChange"
  206. layout="prev, pager, next" :total="pagination.total_count">
  207. </el-pagination>
  208. </div>
  209. </div>
  210. </el-card>
  211. <!-- “数据”弹窗 -->
  212. <!-- <el-dialog title="数据(数据更新于2021-02-12 12:11)" :visible.sync="dialogFormVisible"> -->
  213. <el-dialog title="数据统计" :visible.sync="dialogFormVisible">
  214. <div class="dialog-cont" :data="data_list">
  215. <el-row :gutter="20" style="padding: 10px 0">
  216. <el-col :span="6">
  217. <div class="cont-num center">{{data_list.grab_user_num}}</div>
  218. <div class="center">已抢积分人数</div>
  219. </el-col>
  220. <el-col :span="6">
  221. <div class="cont-num center">{{data_list.grab_integral}}</div>
  222. <div class="center">已抢积分</div>
  223. </el-col>
  224. <el-col :span="6">
  225. <div class="cont-num center">{{data_list.award}}</div>
  226. <div class="center">剩余未抢积分</div>
  227. </el-col>
  228. </el-row>
  229. </div>
  230. <div class="table-body el-input--small">
  231. <el-table v-loading="listLoading" :data="user_grab_list" stripe style="width: 100%">
  232. <el-table-column label="ID" min-width="80" align="center">
  233. <template slot-scope="scope">
  234. <p>{{scope.row.id}}</p>
  235. </template>
  236. </el-table-column>
  237. <el-table-column label="会员" width="180" class="user_data" >
  238. <template slot-scope="scope">
  239. <div class="user_img">
  240. <el-image class="default-avatar" :src="scope.row.user.avatar_url">
  241. <div slot="error" class="image-slot">
  242. <com-image src="/resources/img/common/default-avatar.png"></com-image>
  243. </div>
  244. </el-image>
  245. </div>
  246. <div>
  247. <div style="color:#000;">{{scope.row.user.nickname}}</div>
  248. <div style="font-size: 13px;">{{scope.row.user.mobile}}</div>
  249. </div>
  250. </template>
  251. </el-table-column>
  252. <el-table-column label="已抢红包" min-width="80" align="center">
  253. <template slot-scope="scope">
  254. <p>{{scope.row.grab_integral}}</p>
  255. </template>
  256. </el-table-column>
  257. <el-table-column label="已抢次数" min-width="80" align="center">
  258. <template slot-scope="scope">
  259. <p>{{scope.row.grab_num}}</p>
  260. </template>
  261. </el-table-column>
  262. <el-table-column prop="scope" width="160" label="最后抢红包时间">
  263. <template slot-scope="scope">
  264. {{scope.row.grab_time|dateTimeFormat('Y-m-d H:i:s')}}
  265. </template>
  266. </el-table-column>
  267. </el-table>
  268. <div style="text-align: right;margin: 20px 20px;">
  269. <el-pagination v-if="grab_pagination" :page-size="grab_pagination.pageSize"
  270. style="display: inline-block;float: right;" background @current-change="grabPageChange"
  271. layout="prev, pager, next" :total="grab_pagination.total_count">
  272. </el-pagination>
  273. </div>
  274. </div>
  275. <div style="width: 100%; height: 20px; clear: both;"></div>
  276. </el-dialog>
  277. <el-dialog title="推广链接" :visible.sync="qrodestatus" >
  278. <div class="dialog-cont">
  279. <div style="margin-left: 67px;">
  280. <div class="pay-msg">
  281. <el-input v-model.number="redpack_url" style="width: 50%" disabled type="text" placeholder="红包链接"></el-input>
  282. <el-button class="button-item" v-on:click="copyText">复制链接</el-button>
  283. </div>
  284. <div id="qrcode-info">
  285. <div id="qrcode">
  286. </div>
  287. </div>
  288. </div>
  289. </div>
  290. </el-dialog>
  291. </div>
  292. <script>
  293. const app = new Vue({
  294. el: '#app',
  295. data() {
  296. return {
  297. qrodestatus:false,
  298. listLoading: false,
  299. page: 1,
  300. pageCount: 0,
  301. //基础数据
  302. editBasisData: {
  303. materialTypeList: [],
  304. },
  305. //本地存时间,请求时不发送
  306. time: [],
  307. search: {
  308. id: '',
  309. title: '',
  310. date_start: null,
  311. date_end: null,
  312. },
  313. list: [],
  314. user_grab_list:[],
  315. integral_type:[],
  316. new_time:[],
  317. //弹框配置
  318. addForm: {
  319. id: '',
  320. name: '',
  321. },
  322. title: "",
  323. dialogFormVisible: false, //数据弹窗
  324. data_list: {},//数据
  325. goods_data:[],//详细数据
  326. dialogAddgsVisible: false,
  327. redpack_links:'',//前端红包链接
  328. redpack_url:'',//前端红包链接
  329. // 对话框显示与否
  330. dialogVisible: false,
  331. dataloading: false,
  332. pagination:null,
  333. grab_list:'', //红包记录
  334. grab_pagination:null,
  335. grab_page: 1,
  336. grab_pageCount: 0,
  337. };
  338. },
  339. computed: {
  340. show_clear_search_btn: function() {
  341. return !isEmpty(this.search.id)
  342. || !isEmpty(this.search.title)
  343. || !isEmpty(this.time)
  344. }
  345. },
  346. methods: {
  347. resetSearch(){
  348. this.search = {
  349. id: '',
  350. title: '',
  351. mobile: '',
  352. }
  353. this.time = '';
  354. },
  355. searchs() {
  356. this.page = 1;
  357. this.getList();
  358. },
  359. copyText(){
  360. if (!this.redpack_url) {
  361. alert('请输入要复制的内容')
  362. } else {
  363. var url = this.redpack_url;
  364. // createElement() 方法通过指定名称创建一个元素
  365. var copyInput = document.createElement('input')
  366. copyInput.setAttribute('value', url)
  367. document.body.appendChild(copyInput)
  368. copyInput.select()
  369. try {
  370. var copyed = document.execCommand('copy')
  371. if (copyed) {
  372. document.body.removeChild(copyInput)
  373. this.$message.success('复制成功')
  374. }
  375. } catch {
  376. this.$message.success('复制失败,请检查浏览器兼容')
  377. }
  378. }
  379. },
  380. statistics(data){
  381. this.dialogFormVisible = true;
  382. this.data_list = data;
  383. let self = this;
  384. self.listLoading = true;
  385. request({
  386. params: {
  387. r: 'score-expansion/user-grab/index',
  388. },
  389. method: 'post',
  390. data: {id:data.id,page:this.grab_page},
  391. }).then(e => {
  392. self.listLoading = false;
  393. this.user_grab_list = e.data.data.list;
  394. this.grab_pagination = e.data.data.pagination;
  395. this.grab_pagination.pageSize = e.data.data.page_size;
  396. this.grab_pagination.total_count = e.data.data.count;
  397. }).catch(e => {
  398. console.log(e);
  399. });
  400. console.log(this.data_list,5555);
  401. },
  402. grabPageChange(currentPage) {
  403. let self = this;
  404. self.grab_page = currentPage;
  405. self.statistics();
  406. },
  407. createQrcode(url){
  408. // 获取二维码生成的图片信息
  409. return new Promise((req, rej) => {
  410. setTimeout(() => {
  411. let qrcodeInfo = document.getElementById("qrcode-info");
  412. document.getElementById("qrcode").remove(); //删除生成的二维码
  413. let addCodeDom = document.createElement("div");
  414. addCodeDom.setAttribute("id", "qrcode");
  415. addCodeDom.setAttribute("style", "width:200px; height:200px;");
  416. qrcodeInfo.appendChild(addCodeDom) //添加标签
  417. let qrCodeDom = document.getElementById("qrcode");
  418. var qrcode = new QRCode(qrCodeDom, {
  419. width: 200,
  420. height: 200,
  421. });
  422. qrcode.makeCode(url);
  423. src = qrCodeDom.getElementsByTagName("img")[0].src;
  424. req(src);
  425. }, 200);
  426. })
  427. },
  428. pageChange(currentPage) {
  429. let self = this;
  430. self.page = currentPage;
  431. self.getList();
  432. },
  433. getList() {
  434. let self = this;
  435. self.listLoading = true;
  436. // 检查是否选择了搜索时间
  437. if (!self.time) {
  438. self.search.date_start = '';
  439. self.search.date_end = '';
  440. } else {
  441. self.search.date_start = self.time[0];
  442. self.search.date_end = self.time[1];
  443. }
  444. request({
  445. method: 'post',
  446. params: {
  447. r: 'score-expansion/default/index',
  448. },
  449. data: {
  450. page: self.page,
  451. id: self.search.id,
  452. date_start: self.search.date_start,
  453. date_end: self.search.date_end,
  454. title: self.search.title,
  455. },
  456. }).then(e => {
  457. self.listLoading = false;
  458. self.list = e.data.data.list;
  459. this.pagination = e.data.data.pagination;
  460. this.pagination.pageSize = e.data.data.page_size;
  461. this.pagination.total_count = e.data.data.count;
  462. this.integral_type = e.data.data.integral_type;
  463. this.new_time = e.data.data.new_time;
  464. this.redpack_links = e.data.data.redpacklinks;
  465. console.log(this.pagination);
  466. }).catch(e => {
  467. console.log(e);
  468. });
  469. },
  470. detail(data) {
  471. console.log(data);
  472. this.data_list = [];
  473. this.goods_data = [];
  474. this.dialogFormVisible = true;
  475. this.data_list = data;
  476. this.goods_data.push(data);
  477. },
  478. handle(type,data = null){
  479. switch (type) {
  480. case 'edit':// 编辑
  481. navigateTo({
  482. r: 'score-expansion/default/edit',
  483. id:data.id,
  484. });
  485. break;
  486. case 'copy':// 复制
  487. navigateTo({
  488. r: 'score-expansion/default/edit',
  489. id:data.id,
  490. type:1,
  491. });
  492. break;
  493. case 'qrode'://推广二维码
  494. this.qrodestatus = true;
  495. this.redpack_url = this.redpack_links + '&id=' + data.id;
  496. this.createQrcode(this.redpack_url);
  497. break;
  498. case 'delete':// 删除
  499. data.type = -1;
  500. this.$confirm('\n' +
  501. '删除该条数据后不可以恢复, 是否继续?', '警告', {type: 'warning'}).then(() => {this.delect(data);})
  502. break;
  503. case 'unenable':// 删除
  504. data.type = 0;
  505. this.$confirm('该活动将会失效, 是否继续?', '警告', {type: 'warning'}).then(() => {this.delect(data);})
  506. break;
  507. case 'enable':
  508. data.type = 1;
  509. this.delect(data);
  510. break;
  511. }
  512. },
  513. add(){
  514. navigateTo({
  515. r: 'score-expansion/default/edit',
  516. });
  517. },
  518. delect(data){
  519. let self = this;
  520. self.listLoading = true;
  521. request({
  522. params: {
  523. r: 'score-expansion/default/del-or-enable',
  524. },
  525. method: 'post',
  526. data: {id:data.id,type:data.type},
  527. }).then(e => {
  528. self.listLoading = false;
  529. if (e.data.code === 0) {
  530. self.$message.success(e.data.msg);
  531. } else {
  532. self.$message.error(e.data.msg);
  533. }
  534. self.getList();
  535. }).catch(e => {
  536. console.log(e);
  537. });
  538. },
  539. send(data){
  540. let self = this;
  541. self.listLoading = true;
  542. request({
  543. params: {
  544. r: 'score-expansion/default/edit',
  545. },
  546. method: 'post',
  547. data:data,
  548. }).then(e => {
  549. self.listLoading = false;
  550. if (e.data.code === 0) {
  551. self.$message.success(e.data.msg);
  552. } else {
  553. self.$message.error(e.data.msg);
  554. }
  555. self.getList();
  556. }).catch(e => {
  557. console.log(e);
  558. });
  559. },
  560. /**
  561. *关闭或取消模态框,清空值
  562. * @param
  563. */
  564. closeDialogAddgsVisible() {
  565. this.$refs.addForm.resetFields();//element封装的方法,清空模态框的值
  566. this.title = "" //初始化title的值
  567. this.addForm = {//初始化addForm中的值
  568. title: "",
  569. }
  570. },
  571. },
  572. mounted: function () {
  573. this.getList();
  574. }
  575. });
  576. </script>