index.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  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. <!-- <div class="input-item">
  75. <el-input @keyup.enter.native="search" size="small" placeholder="请输入广告名称" v-model="keyword" @clear="search">
  76. <el-button slot="append" icon="el-icon-search" @click="search"></el-button>
  77. </el-input>
  78. </div> -->
  79. <!-- <div style="margin-bottom: 15px;" flex>
  80. <div flex>
  81. <div flex="cross:center" class="input-search">
  82. <div style="flex-shrink: 0;">课程名称:</div>
  83. <el-input @keyup.enter.native="search" size="small" placeholder="请输入课程名称" v-model="keyword" @clear="search"></el-input>
  84. </div>
  85. <div flex="cross:center" class="input-search">
  86. <div class="input-item-name">状态:</div>
  87. <div>
  88. <el-select v-model="searchData.status" placeholder="请选择" size="small">
  89. <el-option label="全部" :value="0"></el-option>
  90. <el-option v-for="(item,index) in status_text" :key="index" :label="item" :value="index">{{item}}
  91. </el-option>
  92. </el-select>
  93. </div>
  94. </div>
  95. </div>
  96. <div>
  97. <el-button type="primary" size="small" @click="search" style="padding: 9px 15px !important;">搜索</el-button>
  98. <el-button type="warning" @click="clereSearch" v-if="keyword" style="padding: 9px 15px !important;">清除搜索条件</el-button>
  99. </div>
  100. </div> -->
  101. <el-table v-loading="listLoading" :data="list" stripe style="width: 100%">
  102. <!-- <el-table-column label="ID" prop="id" width="80">
  103. <template slot-scope="scope">
  104. <div size="small">{{scope.row.id}}</div>
  105. </template>
  106. </el-table-column>
  107. <el-table-column label="商城ID" prop="mall_id">
  108. <template slot-scope="scope">
  109. <div size="small">{{scope.row.mall_id}}</div>
  110. </template>
  111. </el-table-column> -->
  112. <!-- <el-table-column label="分类ID" prop="id" min-width="80" align="center">
  113. <template slot-scope="scope">
  114. <div size="small">{{scope.row.id}}</div>
  115. </template>
  116. </el-table-column>
  117. <el-table-column label="分类 LOGO " prop="logo" min-width="80" align="center">
  118. <template slot-scope="scope">
  119. <div size="small">
  120. <com-image width='80px' height='80px' :src=scope.row.logo></com-image>
  121. </div>
  122. </template>
  123. </el-table-column> -->
  124. <el-table-column label="排序" prop="sort" min-width="80" align="center">
  125. <template slot-scope="scope">
  126. <div size="small">{{scope.row.sort}}</div>
  127. </template>
  128. </el-table-column>
  129. <el-table-column label="名称" prop="title" min-width="80" align="center">
  130. <template slot-scope="scope">
  131. <div size="small">{{scope.row.title}}</div>
  132. </template>
  133. </el-table-column>
  134. <el-table-column label="图片" prop="pic_path" min-width="80" align="center">
  135. <template slot-scope="scope">
  136. <div size="small">
  137. <com-image width='50px' height='50px' :src=scope.row.pic_path></com-image>
  138. </div>
  139. </template>
  140. </el-table-column>
  141. <el-table-column label="是否启用" prop="content" min-width="100" align="center">
  142. <template slot-scope="scope">
  143. <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>
  144. </template>
  145. </el-table-column>
  146. <el-table-column label="创建时间" prop="created_at" min-width="100" align="center">
  147. <template slot-scope="scope">
  148. <div size="small">{{scope.row.created_at|dateTimeFormat('Y-m-d H:i:s')}}</div>
  149. </template>
  150. </el-table-column>
  151. <el-table-column label="操作" min-width="100" align="center">
  152. <template slot-scope="scope">
  153. <el-button circle type="text" size="mini" @click="bannarEdit(scope.row.id, scope.$index)"> 编辑 </el-button>
  154. <el-button circle type="text" size="mini" @click="bannarDelete(scope.row.id, scope.$index)"> 删除 </el-button>
  155. </template>
  156. </el-table-column>
  157. </el-table>
  158. <div style="text-align: right;margin: 20px 0;">
  159. <el-pagination @current-change="pagination" background layout="prev, pager, next" :page-count="pageCount"></el-pagination>
  160. </div>
  161. </div>
  162. </el-card>
  163. </div>
  164. <script>
  165. const app = new Vue({
  166. el: '#app',
  167. data() {
  168. return {
  169. status: 0,
  170. list: [],
  171. keyword: '',
  172. listLoading: false,
  173. page: 1,
  174. pageCount: 0,
  175. dialogFormVisible: false, //充值弹窗
  176. lableLoading: false,
  177. btnLoading: false,
  178. addStatus: 1, //默认是增加
  179. selectIndex: 0, //充值item的索引
  180. selectRow: {},
  181. form: {
  182. sort: null,
  183. title: '',
  184. created_at: null,
  185. }
  186. };
  187. },
  188. methods: {
  189. search() {
  190. this.page = 1;
  191. this.getList();
  192. },
  193. clereSearch() {
  194. this.keyword = '';
  195. this.page = 1;
  196. this.getList();
  197. },
  198. pagination(currentPage) {
  199. let self = this;
  200. self.page = currentPage;
  201. self.getList();
  202. },
  203. // 获取广告列表
  204. getList() {
  205. let self = this;
  206. self.listLoading = true;
  207. request({
  208. params: {
  209. r: 'course/default/bannars',
  210. page: self.page,
  211. keyword: this.keyword
  212. },
  213. method: 'get',
  214. }).then(e => {
  215. self.listLoading = false;
  216. self.list = e.data.data.list;
  217. self.pageCount = e.data.data.page_count;
  218. }).catch(e => {
  219. console.log(e);
  220. });
  221. },
  222. // 新建
  223. add() {
  224. navigateTo({
  225. r: 'course/bannar/storage',
  226. });
  227. },
  228. // 编辑
  229. bannarEdit(id) {
  230. navigateTo({
  231. r: 'course/bannar/storage',
  232. id: id,
  233. });
  234. },
  235. // 屏蔽状态切换
  236. isUse($event, id) {
  237. let self = this;
  238. self.listLoading = true;
  239. request({
  240. params: {
  241. r: 'course/bannar/switch-status'
  242. },
  243. method: 'post',
  244. data: {
  245. id: id,
  246. val: $event
  247. }
  248. }).then(e => {
  249. self.listLoading = false;
  250. if (e.data.code === 0) {
  251. self.$message.success(e.data.msg);
  252. } else {
  253. self.$message.error(e.data.msg);
  254. }
  255. }).catch(e => {
  256. console.log(e);
  257. });
  258. },
  259. bannarDelete(id, index) {
  260. let self = this;
  261. self.$confirm('是否删除广告?', '提示', {
  262. confirmButtonText: '确定',
  263. cancelButtonText: '取消',
  264. type: 'warning'
  265. }).then(() => {
  266. self.listLoading = true;
  267. // console.log(id,'1111')
  268. request({
  269. params: {
  270. r: 'course/bannar/delete',
  271. },
  272. method: 'post',
  273. data: {
  274. id: id,
  275. }
  276. }).then(e => {
  277. self.listLoading = false;
  278. if (e.data.code === 0) {
  279. self.$message.success(e.data.msg);
  280. self.list.splice(index, 1);
  281. } else {
  282. self.$message.error(e.data.msg);
  283. }
  284. }).catch(e => {
  285. console.log(e);
  286. });
  287. }).catch(() => {
  288. // self.$message.info('已取消删除')
  289. });
  290. }
  291. },
  292. mounted: function() {
  293. this.getList();
  294. }
  295. });
  296. </script>