index.php 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553
  1. <style>
  2. .header {
  3. padding: 18px 20px;
  4. background: #fff;
  5. margin-bottom: 10px;
  6. border-radius: 5px;
  7. border: 1px solid #EBEEF5;
  8. }
  9. .el-card {
  10. box-shadow: none !important;
  11. }
  12. .inquires_box {
  13. flex-wrap: wrap;
  14. }
  15. .condition {
  16. width: 450px;
  17. }
  18. .condition2 {
  19. margin-right: 30px;
  20. margin-bottom: 20px;
  21. }
  22. .operat_btn_list .el-button {
  23. padding: 8px 20px;
  24. }
  25. .table_box {
  26. margin-top: 30px;
  27. }
  28. .give_btn {
  29. border-radius: 5px;
  30. background: #fff;
  31. padding: 2px 0;
  32. border: 1px solid #DCDFE6;
  33. width: 80px;
  34. cursor: pointer;
  35. }
  36. .el-table .cell {
  37. /*display: flex;*/
  38. justify-content: center;
  39. }
  40. .operat1 {
  41. color: #3399FF;
  42. margin-right: 20px;
  43. cursor: pointer;
  44. }
  45. .operat2 {
  46. color: #FF336E;
  47. cursor: pointer;
  48. }
  49. .pagination_box {
  50. margin-top: 30px;
  51. justify-content: flex-end;
  52. }
  53. .types:hover {
  54. cursor: pointer;
  55. color: #409eff;
  56. }
  57. .coupon_type_list_box {
  58. flex-wrap: wrap;
  59. }
  60. .coupon_type_list_expired {
  61. width: 100px;
  62. position: absolute;
  63. top: 50%;
  64. left: 50%;
  65. transform: translate(-50%, -50%);
  66. opacity: 0.2;
  67. zoom: 1.05;
  68. }
  69. .coupon_type_list {
  70. background: #F4F4F4;
  71. border-radius: 4px;
  72. padding: 8px 6px;
  73. width: 110px;
  74. margin-bottom: 15px;
  75. margin-right: 15px;
  76. }
  77. /* .coupon_type_list:last-child */
  78. .coupon_type_list_box :nth-child(5n) {
  79. margin-right: 0px;
  80. }
  81. .coupon_type_title {
  82. font-size: 16px;
  83. margin-bottom: 10px;
  84. }
  85. .coupon_type_content {
  86. font-size: 12px;
  87. margin-bottom: 4px;
  88. }
  89. .el-dialog__body {
  90. padding: 20px 20px 10px;
  91. }
  92. .switchStyle .el-switch__label {
  93. position: absolute;
  94. display: none;
  95. color: #fff;
  96. }
  97. .switchStyle .el-switch__label--left {
  98. z-index: 9;
  99. left: 6px;
  100. }
  101. .switchStyle .el-switch__label--right {
  102. z-index: 9;
  103. left: -14px;
  104. }
  105. .switchStyle .el-switch__label.is-active {
  106. display: block;
  107. }
  108. .switchStyle.el-switch .el-switch__core,
  109. .el-switch .el-switch__label {
  110. width: 56px !important;
  111. }
  112. .coupon_box {
  113. padding-left: 20px;
  114. }
  115. .line {
  116. width: 5px;
  117. height: 20px;
  118. margin-right: 6px;
  119. background: #2E8FF4;
  120. }
  121. .coupon_content {
  122. flex-wrap: wrap;
  123. margin-top: 25px;
  124. padding-left: 10px;
  125. overflow: hidden;
  126. }
  127. .coupon_content2 {
  128. flex-wrap: wrap;
  129. margin-top: 20px;
  130. padding-left: 10px;
  131. padding-bottom: 30px;
  132. }
  133. .coupon_content_item {
  134. width: 130px;
  135. background: #F4F4F4;
  136. border-radius: 5px;
  137. padding: 10px 6px;
  138. margin-right: 15px;
  139. margin-bottom: 20px;
  140. position: relative;
  141. }
  142. .item_name {
  143. font-size: 16px;
  144. margin-bottom: 15px;
  145. }
  146. .item_content {
  147. font-size: 12px;
  148. }
  149. .more_btn {
  150. text-align: center;
  151. cursor: pointer;
  152. margin-bottom: 10px;
  153. }
  154. .more_icon {
  155. transform: rotate(0deg);
  156. transition: all 0.7s;
  157. }
  158. .coupon_content_active {
  159. height: auto;
  160. }
  161. .show_more_icon {
  162. transform: rotate(180deg);
  163. }
  164. .el-divider {
  165. background-color: #C8C8C8;
  166. position: relative;
  167. }
  168. .el-divider--horizontal {
  169. margin: 0;
  170. }
  171. .middle-line {
  172. height: 100%;
  173. position: absolute;
  174. left: 50.5%;
  175. transform: translateX(-50%);
  176. width: 1px;
  177. background: #C8C8C8;
  178. }
  179. /* 公共样式 */
  180. .flex {
  181. display: -webkit-box;
  182. display: -webkit-flex;
  183. /* #ifndef APP-NVUE */
  184. display: flex;
  185. /* #endif */
  186. }
  187. .flex-x-center {
  188. display: -webkit-box;
  189. display: -webkit-flex;
  190. /* #ifndef APP-NVUE */
  191. display: flex;
  192. /* #endif */
  193. -webkit-box-pack: center;
  194. -webkit-justify-content: center;
  195. -ms-flex-pack: center;
  196. justify-content: center;
  197. }
  198. .flex-x-between {
  199. display: -webkit-box;
  200. display: -webkit-flex;
  201. /* #ifndef APP-NVUE */
  202. display: flex;
  203. /* #endif */
  204. -webkit-box-pack: space-between;
  205. -webkit-justify-content: space-between;
  206. -ms-flex-pack: space-between;
  207. justify-content: space-between;
  208. }
  209. .flex-y-center {
  210. display: -webkit-box;
  211. display: -webkit-flex;
  212. /* #ifndef APP-NVUE */
  213. display: flex;
  214. /* #endif */
  215. -webkit-box-align: center;
  216. -webkit-align-items: center;
  217. -ms-flex-align: center;
  218. -ms-grid-row-align: center;
  219. align-items: center;
  220. }
  221. /* 溢出隐藏 */
  222. .over1 {
  223. text-overflow: -o-ellipsis-lastline;
  224. overflow: hidden;
  225. text-overflow: ellipsis;
  226. display: -webkit-box;
  227. -webkit-line-clamp: 1;
  228. -webkit-box-orient: vertical;
  229. }
  230. .over2 {
  231. text-overflow: -o-ellipsis-lastline;
  232. overflow: hidden;
  233. text-overflow: ellipsis;
  234. display: -webkit-box;
  235. -webkit-line-clamp: 2;
  236. -webkit-box-orient: vertical;
  237. }
  238. </style>
  239. <div id='app' v-cloak>
  240. <div class="header">
  241. <span>规则列表</span>
  242. <div style="float: right;margin-top: -5px">
  243. <el-button type="primary" @click="addDialog=true" size="small">添加规则</el-button>
  244. </div>
  245. </div>
  246. <el-card v-loading='loading'>
  247. <!-- 表格 -->
  248. <div class="table_box">
  249. <el-table :data="list" stripe style="width: 100%;font-size:13px">
  250. <el-table-column prop="gift_type" label="类型" width="180" align="center">
  251. <template slot-scope="scope">
  252. <!-- {{ gift_type_arr[scope.row.gift_type] }}-->
  253. <div class="types" @click="showPop(gift_type_arr[scope.row.gift_type],scope.row.gift_type)">
  254. {{ gift_type_arr[scope.row.gift_type] }}
  255. </div>
  256. </template>
  257. </el-table-column>
  258. <el-table-column label="状态" align="center">
  259. <template slot-scope="scope">
  260. <el-tag type="success" v-if="scope.row.status == 1">启用中</el-tag>
  261. <el-tag type="danger" v-if="scope.row.status == 0">已关闭</el-tag>
  262. </template>
  263. </el-table-column>
  264. <el-table-column label="操作" fixed="right" align="center">
  265. <template slot-scope="scope">
  266. <el-button type="text" @click="handle('edit',scope.row)">编辑</el-button>
  267. </template>
  268. </el-table-column>
  269. </el-table>
  270. </div>
  271. <!-- 券类型弹窗 -->
  272. <el-dialog :visible.sync="dialogVisible" width="1000px" top="200px">
  273. <span slot="title">等级名称:{{level_name}}</span>
  274. <div v-loading='loading2'>
  275. <div class="flex" style="padding-left:10px;flex-wrap:wrap;position:relative;min-height:100px">
  276. <!-- 优惠券 -->
  277. <div style="width:50%;border-bottom: 1px solid #C8C8C8;" v-if='award_data.coupon'>
  278. <div class='coupon_box'>
  279. <div class='title flex flex-y-center'>
  280. <div class='line'></div>
  281. <div>优惠券</div>
  282. </div>
  283. <div class="coupon_content flex" :class="{coupon_content_active:is_coupon_more}">
  284. <div class='coupon_content_item' v-for="(item,index) in award_data.coupon" :key='index'>
  285. <div class='item_name'>{{item.name}}</div>
  286. <div class='item_content'>
  287. <div style="margin-bottom: 5px;">优惠方式:{{item.discount_method}}</div>
  288. <div>发放数量:{{item.num}}</div>
  289. </div>
  290. <img v-if='item.status != 1' class='coupon_type_list_expired' src="/resources/img/common/gq.jpg" alt="" srcset="">
  291. </div>
  292. </div>
  293. </div>
  294. <!-- <div class="more_btn flex flex-y-center flex-x-center" v-if='Object.keys(award_data.coupon).length > 3' @click="showMore('coupon')">-->
  295. <!-- <div style="margin-right: 2px;" v-if="is_coupon_more">收起</div>-->
  296. <!-- <div style="margin-right: 2px;" v-else>更多</div>-->
  297. <!-- <i class="el-icon-arrow-down more_icon" :class="{show_more_icon:is_coupon_more}" style="font-size: 18px;"></i>-->
  298. <!-- </div>-->
  299. </div>
  300. <!-- 积分 -->
  301. <div style="width:50%;padding-top:30px;border-bottom: 1px solid #C8C8C8;" v-if='award_data.score'>
  302. <div class='coupon_box'>
  303. <div class='title flex flex-y-center'>
  304. <div class='line'></div>
  305. <div>积分</div>
  306. </div>
  307. <div class="coupon_content2">
  308. <div style="margin-bottom: 10px;">积分赠送:{{ award_data.score[0].prize }}</div>
  309. <div>积分备注:{{ award_data.score[0].remark }}</div>
  310. </div>
  311. </div>
  312. </div>
  313. <!-- 余额 -->
  314. <div style="width:50%;padding-top:30px;border-bottom: 1px solid #C8C8C8;" v-if='award_data.balance'>
  315. <div class='coupon_box'>
  316. <div class='title flex flex-y-center'>
  317. <div class='line'></div>
  318. <div>余额</div>
  319. </div>
  320. <div class="coupon_content2">
  321. <div style="margin-bottom: 10px;">余额赠送:{{award_data.balance[0].prize}}</div>
  322. <div>余额备注:{{award_data.balance[0].remark}}</div>
  323. </div>
  324. </div>
  325. </div>
  326. <div class='middle-line'></div>
  327. </div>
  328. <div class='flex flex-x-center' style="margin-top: 30px;">
  329. <el-button type="primary" @click="dialogVisible = false" style="width: 150px;">确定</el-button>
  330. </div>
  331. </div>
  332. </el-dialog>
  333. <el-dialog title="新增规则" :visible.sync="addDialog" >
  334. <div>
  335. <el-form :model="form" size="small" label-width="150px">
  336. <el-form-item label="礼包类型">
  337. <el-select v-model="gift_type" placeholder="请选择礼包类型">
  338. <el-option
  339. v-for="(name,index) in gift_type_arr"
  340. :key="name"
  341. :label="name"
  342. :value="index"
  343. :disabled="has_gift_type.indexOf(index) != -1">
  344. </el-option>
  345. </el-select>
  346. </el-form-item>
  347. </el-form>
  348. </div>
  349. <span slot="footer" class="dialog-footer">
  350. <el-button @click="addDialog=false" type="default" size="small">取消</el-button>
  351. <el-button type="primary" style="margin-bottom: 10px;" size="small" @click="handle('add')">编辑</el-button>
  352. </span>
  353. </el-dialog>
  354. </el-card>
  355. </div>
  356. <script>
  357. new Vue({
  358. el: '#app',
  359. data() {
  360. return {
  361. loading: false,
  362. loading2: false,
  363. gift_type_arr: {},
  364. searchForm:{
  365. gift_type:null,
  366. status:null,
  367. },
  368. has_gift_type: [],
  369. list: [],
  370. form: {},
  371. dialogVisible: false,
  372. addDialog: false,
  373. level_name: '',
  374. gift_type: '',
  375. is_coupon_more: false,
  376. is_etc_more: false,
  377. award_data: '',
  378. }
  379. },
  380. mounted() {
  381. this.getList();
  382. },
  383. computed: {
  384. show_clear_search_btn: function() {
  385. return !isEmpty(this.searchForm.gift_type) ||
  386. !isEmpty(this.searchForm.status);
  387. },
  388. },
  389. methods: {
  390. search() {// 清空查询条件
  391. this.page = 1;
  392. this.getList(this.searchForm);
  393. },
  394. resetSearch() {// 清空查询条件
  395. this.searchForm = {
  396. gift_type: null,
  397. status: null,
  398. };
  399. this.page = 1;
  400. this.getList();
  401. },
  402. getList(search = null) {
  403. let self = this;
  404. this.loading = true;
  405. let basic_params = {
  406. r: 'user-gift/default/index',
  407. page: self.page,
  408. };
  409. var params = Object.assign(basic_params, search);
  410. self.$request({
  411. params: params,
  412. method: 'get',
  413. }).then(e => {
  414. this.loading = false;
  415. if (e.data.code == 0) {
  416. self.list = e.data.data.list;
  417. self.gift_type_arr = e.data.data.gift_type_arr;
  418. self.has_gift_type = e.data.data.has_gift_type;
  419. }
  420. });
  421. },
  422. handle(type, data = null) {
  423. let id = data ? parseInt(data.id) : '';
  424. switch (type) {
  425. case 'edit':
  426. let params = {
  427. r: 'user-gift/default/edit'
  428. };
  429. params = Object.assign(params, {
  430. gift_type: data.gift_type,
  431. });
  432. navigateTo(params);
  433. break;
  434. case 'destroy':
  435. param = {id: data.id,type:type,status:-1};
  436. this.$confirm('删除该条数据后不可以恢复, 是否继续?', '警告', {type: 'warning'}).then(() => {this.send(param,'user-gift/default/handle')})
  437. break;
  438. case 'add':
  439. if (!this.gift_type) {
  440. this.$message.error('请选择礼包类型');
  441. return false;
  442. }
  443. param = {
  444. r: 'user-gift/default/edit',
  445. gift_type: this.gift_type
  446. };
  447. navigateTo(param);
  448. break;
  449. }
  450. },
  451. send(params, url = '', callback) {
  452. let self = this;
  453. request({
  454. params: {
  455. r: url,
  456. },
  457. method: 'post',
  458. data: params
  459. }).then(e => {
  460. if (e.data.code == 0) {
  461. self.$message.success(e.data.msg);
  462. self.getList();
  463. } else {
  464. self.$message.error(e.data.msg);
  465. }
  466. if (callback) callback(e.data);
  467. }).catch(e => {
  468. console.log(e);
  469. });
  470. },
  471. getReward(gift_type) {
  472. this.loading2 = true;
  473. request({
  474. params: {
  475. r: 'user-gift/default/rule-detail',
  476. },
  477. data: {
  478. gift_type:gift_type
  479. },
  480. method: 'post',
  481. }).then(e => {
  482. this.loading2 = false;
  483. if (e.data.code == 0) {
  484. this.award_data = e.data.data;
  485. } else {
  486. this.$message.error(e.data.msg);
  487. }
  488. });
  489. },
  490. showMore(str) { //展示更多
  491. if (str == 'coupon') {
  492. this.is_coupon_more = !this.is_coupon_more;
  493. } else {
  494. this.is_etc_more = !this.is_etc_more;
  495. }
  496. },
  497. showPop(level_name, gift_type) {
  498. this.dialogVisible = true;
  499. this.level_name = level_name;
  500. this.getReward(gift_type);
  501. }
  502. }
  503. })
  504. </script>