list.blade.php 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. @extends('layouts.base')
  2. @section('title', '活动管理')
  3. @section('content')
  4. <style xmlns:v-bind="http://www.w3.org/1999/xhtml">
  5. .rightlist #app .rightlist-head{padding:15px 0;line-height:50px;}
  6. .rightlist #app{margin-left:30px;}
  7. .rightlist-head-con{float:left;padding-right:20px;font-size:16px;color:#888;}
  8. .el-form-item__label{padding-right:30px;}
  9. .mouse-active{cursor:pointer;border:1px dotted #409EFF;border-radius: 4px;}
  10. /* 滑块选择小白点 */
  11. .el-switch.is-checked .el-switch__core::after {left: 100%;margin-left: -17px;}
  12. .el-switch__core::after {content: "";position: absolute;top: 1px;left: 1px;border-radius: 100%;transition: all .3s;width: 16px;height: 16px;background-color: #fff;}
  13. </style>
  14. <link rel="stylesheet" href="//at.alicdn.com/t/font_913727_zrmdutznqpd.css">
  15. <div id="app-share-activity">
  16. <template>
  17. <el-container>
  18. <el-header height="auto">
  19. <div class="">
  20. <h4 class="card-title">活动管理</h4>
  21. <el-button type="primary" icon="el-icon-plus" @click="addActivity()">创建活动</el-button>
  22. <div style="padding-top: 24px">
  23. <el-form v-loading="loading" ref="form" :model="form" :inline="true">
  24. <el-form-item label="活动ID">
  25. <el-input v-model="searchParams.id" placeholder="活动ID"></el-input>
  26. </el-form-item>
  27. <el-form-item label="活动名称">
  28. <el-input v-model="searchParams.name" placeholder="请输入活动名称"></el-input>
  29. </el-form-item>
  30. <el-form-item label="创建时间">
  31. <template>
  32. <div class="block">
  33. <span class="demonstration"></span>
  34. <el-date-picker
  35. v-model="searchParams.create_time"
  36. type="datetimerange"
  37. range-separator="至"
  38. start-placeholder="开始日期"
  39. end-placeholder="结束日期"
  40. align="right">
  41. </el-date-picker>
  42. </div>
  43. </template>
  44. </el-form-item>
  45. <el-button type="primary" icon="el-icon-search" @click="searchData()">搜索</el-button>
  46. </el-form>
  47. </div>
  48. </div>
  49. </el-header>
  50. {{--表格start--}}
  51. <el-main>
  52. <template>
  53. <el-table :data="list">
  54. <el-table-column align="center" align="center" prop="id" label="ID" width="auto"></el-table-column>
  55. <el-table-column align="center" prop="start_time" label="创建时间" width="auto"></el-table-column>
  56. <el-table-column
  57. align="center"
  58. prop="end_time"
  59. label="结束时间">
  60. </el-table-column>
  61. <el-table-column align="center" prop="name" label="活动名称" width="auto"></el-table-column>
  62. <el-table-column align="center" label="创建者" width="auto">
  63. <template slot-scope="scope">
  64. <span v-if="!scope.row.has_one_store_activity">
  65. 平台
  66. </span>
  67. <span v-else-if="scope.row.has_one_store_activity.has_one_store">
  68. [[scope.row.has_one_store_activity.has_one_store.store_name]]<br>
  69. ID:[[scope.row.has_one_store_activity.has_one_store.id]]
  70. </span>
  71. <span v-else>
  72. 无门店信息ID:[[scope.row.has_one_store_activity.store_id ? scope.row.has_one_store_activity.store_id : 0]]
  73. </span>
  74. </template>
  75. </el-table-column>
  76. <el-table-column label="状态">
  77. <template slot-scope="scope">
  78. <el-tooltip :content="scope.row.status?'启用':'禁用'" placement="top">
  79. <el-switch v-model="scope.row.status" :active-value="1" :inactive-value="0" @change="statusChange(scope.$index,scope.row,scope.row.id)"></el-switch>
  80. </el-tooltip>
  81. </template>
  82. </el-table-column>
  83. <el-table-column
  84. align="center"
  85. prop="browse_count"
  86. label="浏览人数">
  87. </el-table-column>
  88. <el-table-column align="center" label="操作">
  89. <template slot-scope="scope">
  90. <a v-bind:href="'{{ yzWebUrl('plugin.share-activity.admin.activity.add', array('id' => '')) }}'+[[scope.row.id]]" title="编辑">
  91. <i class="el-icon-edit" style="font-size:28px;color:#606266"></i>
  92. </a>
  93. <a href="#" title="删除">
  94. <i class="el-icon-delete" style="font-size:28px;color:#606266" @click="del(scope.row.id)"></i>
  95. </a>
  96. <a href="#">
  97. <el-tooltip placement="top">
  98. <div slot="content">
  99. <img :src="scope.row.qr_code" alt="" style="max-width:100px;">
  100. </div>
  101. <i class="iconfont icon-erweima1" style="font-size:28px;color:#606266"></i>
  102. </el-tooltip>
  103. </a>
  104. <a href="#">
  105. <i class="el-icon-share" style="font-size:28px;color:#606266" title="点击复制链接" @click="copy(scope.row,scope.$index)"></i>
  106. <el-input v-model="scope.row.activity_url" :ref="'copy'+scope.$index" style="height: 1px;position: absolute;opacity:0;z-index:-2"></el-input>
  107. </a>
  108. <a href="#">
  109. <i class="el-icon-help" style="font-size:28px;color:#606266" title="点击复制小程序链接" @click="copyMini(scope.row,scope.$index)"></i>
  110. <el-input v-model="scope.row.mini_url" :ref="'copyMini'+scope.$index" style="height: 1px;;position: absolute;opacity:0;z-index:-2"></el-input>
  111. </a>
  112. </template>
  113. </el-table-column>
  114. </el-table>
  115. </template>
  116. </el-main>
  117. {{--表格end--}}
  118. <el-footer>
  119. <el-pagination
  120. layout="prev, pager, next"
  121. @current-change="currentChange"
  122. :current-page.sync="current_page"
  123. :total="page_total"
  124. :page-size="page_size"
  125. background v-loading="loading">
  126. </el-pagination>
  127. </el-footer>
  128. </el-container>
  129. </template>
  130. </div>
  131. <script>
  132. var app = new Vue({
  133. el: '#app-share-activity',
  134. delimiters: ['[[', ']]'],
  135. data() {
  136. let pageList = {!! $pageList ?: '{}'!!};
  137. return {
  138. form : {},
  139. loading : false,
  140. searchParams: {
  141. 'id' : '',
  142. 'name' : '',
  143. 'create_time' : '',
  144. },
  145. real_search_form: {
  146. 'id' : '',
  147. 'name' : '',
  148. 'create_time' : '',
  149. },
  150. list : pageList.data,
  151. current_page : pageList.current_page,
  152. page_total : pageList.total,
  153. page_size : pageList.per_page,
  154. }
  155. },
  156. methods: {
  157. statusChange(index,row,id) {
  158. this.loading = true;
  159. this.$http.post('{!! yzWebFullUrl('plugin.share-activity.admin.activity.change-status') !!}',{id:id,status:row.status}).then(function (response) {
  160. if (response.data.result){
  161. if(row.status){
  162. this.$message({message: '开启成功',type: 'success'});
  163. }
  164. else {
  165. this.$message({message: '关闭成功',type: 'success'});
  166. }
  167. } else {
  168. this.$message({message: response.data.msg,type: 'error'});
  169. if (this.list[index].status==1){
  170. this.list[index].status = 0;
  171. }
  172. else{
  173. this.list[index].status = 1;
  174. }
  175. }
  176. this.loading = false;
  177. },function (response) {
  178. this.$message({message: response.data.msg,type: 'error'});
  179. if (this.list[index].status==1){
  180. this.list[index].status = 0;
  181. } else{
  182. this.list[index].status = 1;
  183. }
  184. this.loading = false;
  185. });
  186. },
  187. del(id) {
  188. this.$confirm('是否删除', '提示', {
  189. confirmButtonText: '确定',
  190. cancelButtonText: '取消',
  191. type: 'warning'
  192. }).then(() => {
  193. this.$http.post('{!! yzWebFullUrl('plugin.share-activity.admin.activity.del') !!}',{id:id}).then(function (response) {
  194. if (response.data.result) {
  195. this.$message({
  196. type: 'success',
  197. message: '删除成功!'
  198. });
  199. window.open("{!! yzWebUrl('plugin.share-activity.admin.activity.index') !!}", '_self');
  200. }
  201. });
  202. }).catch(() => {
  203. this.$message({
  204. type: 'info',
  205. message: '已取消删除'
  206. });
  207. });
  208. },
  209. searchData() {
  210. this.loading = true;
  211. if(this.searchParams.create_time){
  212. this.searchParams.create_time[0] = Math.round(this.searchParams.create_time[0]/1000).valueOf();
  213. this.searchParams.create_time[1] = Math.round(this.searchParams.create_time[1]/1000).valueOf();
  214. }
  215. this.$http.post('{!! yzWebFullUrl('plugin.share-activity.admin.activity.search') !!}',{search:this.searchParams}
  216. ).then(function (response) {
  217. if (response.data.result){
  218. let datas = response.data.data;
  219. this.page_total = datas.total;
  220. this.list = datas.data;
  221. this.page_size = datas.per_page;
  222. this.current_page = datas.current_page;
  223. this.real_search_form = this.searchParams;
  224. }
  225. else {
  226. this.$message({message: response.data.msg,type: 'error'});
  227. }
  228. this.loading = false;
  229. },function (response) {
  230. this.loading = false;
  231. this.$message({message: response.data.msg,type: 'error'});
  232. }
  233. );
  234. },
  235. addActivity(){
  236. window.open("{!! yzWebUrl('plugin.share-activity.admin.activity.add') !!}", '_self');
  237. },
  238. copy(row,index) {
  239. that = this;
  240. let Url = that.$refs['copy'+index];
  241. Url.select(); // 选择对象
  242. document.execCommand("Copy",false);
  243. that.$message({message:"复制成功!",type:"success"});
  244. },
  245. copyMini(row,index) {
  246. let that = this;
  247. let Url = that.$refs['copyMini'+index];
  248. Url.select(); // 选择对象
  249. document.execCommand("Copy",false);
  250. that.$message({message:"复制成功!",type:"success"});
  251. },
  252. currentChange(val) {
  253. this.loading = true;
  254. this.$http.post('{!! yzWebFullUrl('plugin.share-activity.admin.activity.search') !!}',{page:val,search:this.real_search_form}).then(function (response) {
  255. if (response.data.result){
  256. let datas = response.data.data;
  257. this.page_total = datas.total;
  258. this.list = datas.data;
  259. this.page_size = datas.per_page;
  260. this.current_page = datas.current_page;
  261. }
  262. else {
  263. this.$message({message: response.data.msg,type: 'error'});
  264. }
  265. this.loading = false;
  266. },function (response) {
  267. this.loading = false;
  268. this.$message({message: response.data.msg,type: 'error'});
  269. }
  270. );
  271. }
  272. },
  273. });
  274. </script>
  275. @endsection