index.php 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  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. .form-body {
  42. background-color: #fff;
  43. margin-bottom: 20px;
  44. }
  45. .el-tabs__header {
  46. background-color: #fff;
  47. }
  48. .el-tabs__item {
  49. width: 100px;
  50. text-align: center;
  51. }
  52. .el-table th>.cell {
  53. color: #333;
  54. font-weight: bold;
  55. font-size: 14px;
  56. }
  57. .el-table__footer-wrapper,
  58. .el-table__header-wrapper {
  59. border-bottom: 1.4px solid #D6D6D6;
  60. }
  61. </style>
  62. <div id="app" v-cloak>
  63. <el-card shadow="never" body-style="background-color: #f3f3f3;padding: 10px 0 0;">
  64. <div slot="header">
  65. <div>
  66. <span>轮播图管理</span>
  67. <div style="float: right">
  68. <el-button type="primary" size="small" style="padding: 9px 15px !important;" @click="add">创建轮播图
  69. </el-button>
  70. </div>
  71. </div>
  72. </div>
  73. <div class="table-body">
  74. <el-table v-loading="listLoading" :data="list" stripe style="width: 100%">
  75. <el-table-column label="排序" prop="sort" min-width="80" align="center">
  76. <template slot-scope="scope">
  77. <div size="small">{{scope.row.sort}}</div>
  78. </template>
  79. </el-table-column>
  80. <el-table-column label="图片" prop="pic_path" min-width="80" align="center">
  81. <template slot-scope="scope">
  82. <div size="small">
  83. <com-image width='50px' height='50px' :src=scope.row.pic_path></com-image>
  84. </div>
  85. </template>
  86. </el-table-column>
  87. <el-table-column label="是否启用" prop="content" min-width="100" align="center">
  88. <template slot-scope="scope">
  89. <el-switch v-model="scope.row.is_show" :active-value="1" :inactive-value="0" active-text="启用" inactive-text="不启用" @change="isUse($event, scope.row.id)"> </el-switch>
  90. </template>
  91. </el-table-column>
  92. <el-table-column label="创建时间" prop="created_at" min-width="100" align="center">
  93. <template slot-scope="scope">
  94. <div size="small">{{scope.row.created_at|dateTimeFormat('Y-m-d H:i:s')}}</div>
  95. </template>
  96. </el-table-column>
  97. <el-table-column label="操作" min-width="100" align="center">
  98. <template slot-scope="scope">
  99. <el-button circle type="text" size="mini" @click="bannerEdit(scope.row.id, scope.$index)"> 编辑 </el-button>
  100. <el-button circle type="text" size="mini" @click="bannerDelete(scope.row.id, scope.$index)"> 删除 </el-button>
  101. </template>
  102. </el-table-column>
  103. </el-table>
  104. <div style="text-align: right;margin: 20px 0;">
  105. <el-pagination @current-change="pagination" background layout="prev, pager, next" :page-count="pageCount"></el-pagination>
  106. </div>
  107. </div>
  108. </el-card>
  109. </div>
  110. <script>
  111. const app = new Vue({
  112. el: '#app',
  113. data() {
  114. return {
  115. status: 0,
  116. list: [],
  117. keyword: '',
  118. listLoading: false,
  119. page: 1,
  120. pageCount: 0,
  121. dialogFormVisible: false, //充值弹窗
  122. lableLoading: false,
  123. btnLoading: false,
  124. addStatus: 1, //默认是增加
  125. selectIndex: 0, //充值item的索引
  126. selectRow: {},
  127. form: {
  128. sort: null,
  129. title: '',
  130. created_at: null,
  131. }
  132. };
  133. },
  134. methods: {
  135. search() {
  136. this.page = 1;
  137. this.getList();
  138. },
  139. clereSearch() {
  140. this.keyword = '';
  141. this.page = 1;
  142. this.getList();
  143. },
  144. pagination(currentPage) {
  145. let self = this;
  146. self.page = currentPage;
  147. self.getList();
  148. },
  149. // 获取广告列表
  150. getList() {
  151. let self = this;
  152. self.listLoading = true;
  153. request({
  154. params: {
  155. r: 'bargain/banner/index',
  156. page: self.page,
  157. keyword: this.keyword
  158. },
  159. method: 'get',
  160. }).then(e => {
  161. self.listLoading = false;
  162. self.list = e.data.data.list;
  163. self.pageCount = e.data.data.page_count;
  164. }).catch(e => {
  165. console.log(e);
  166. });
  167. },
  168. // 新建
  169. add() {
  170. navigateTo({
  171. r: 'bargain/banner/storage',
  172. });
  173. },
  174. // 编辑
  175. bannerEdit(id) {
  176. navigateTo({
  177. r: 'bargain/banner/storage',
  178. id: id,
  179. });
  180. },
  181. // 屏蔽状态切换
  182. isUse($event, id) {
  183. let self = this;
  184. self.listLoading = true;
  185. request({
  186. params: {
  187. r: 'bargain/banner/switch-status'
  188. },
  189. method: 'post',
  190. data: {
  191. id: id,
  192. val: $event
  193. }
  194. }).then(e => {
  195. self.listLoading = false;
  196. if (e.data.code === 0) {
  197. self.$message.success(e.data.msg);
  198. } else {
  199. self.$message.error(e.data.msg);
  200. }
  201. }).catch(e => {
  202. console.log(e);
  203. });
  204. },
  205. bannerDelete(id, index) {
  206. let self = this;
  207. self.$confirm('是否删除轮播图?', '提示', {
  208. confirmButtonText: '确定',
  209. cancelButtonText: '取消',
  210. type: 'warning'
  211. }).then(() => {
  212. self.listLoading = true;
  213. // console.log(id,'1111')
  214. request({
  215. params: {
  216. r: 'bargain/banner/delete',
  217. },
  218. method: 'post',
  219. data: {
  220. id: id,
  221. }
  222. }).then(e => {
  223. self.listLoading = false;
  224. if (e.data.code === 0) {
  225. self.$message.success(e.data.msg);
  226. self.list.splice(index, 1);
  227. } else {
  228. self.$message.error(e.data.msg);
  229. }
  230. }).catch(e => {
  231. console.log(e);
  232. });
  233. }).catch(() => {
  234. // self.$message.info('已取消删除')
  235. });
  236. }
  237. },
  238. mounted: function() {
  239. this.getList();
  240. }
  241. });
  242. </script>