index.php 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558
  1. <?php
  2. //画册列表
  3. ?>
  4. <div id="app"></div>
  5. <template id="main">
  6. <el-card shadow="never" style="border:0;min-width: 800px;" body-style="background-color: #f3f3f3;padding: 10px 0 0;">
  7. <div class="flex text-bold text-sm justify-between align-center" slot="header">画册管理</div>
  8. <div class="padding-xs solid-gray">
  9. <components :$route="route" @router="route = $event" :is="route.path"></components>
  10. </div>
  11. </el-card>
  12. </template>
  13. <template id="mtmlt">
  14. <div>
  15. <div class="flex">
  16. <div class="solid-bottom flex align-center padding-bottom-xs">
  17. <el-button type="primary" @click="openalbum()" class="el-button--small">新增画册</el-button>
  18. </div>
  19. </div>
  20. <div style="min-height: 70vh;" v-loading="loading">
  21. <el-row>
  22. <el-col :key="index" v-for="(item,index) in albumList" :lg="4" :md="8" :sm="12">
  23. <div class="album">
  24. <div class="album-content">
  25. <el-image style="width: 240px; height: 150px" fit="cover" fit="cover" :src="item.album_image" @click="handle('edit',item)"></el-image>
  26. <div class="list_title">
  27. <div>{{item.title}}</div>
  28. <div>
  29. <span>创建时间:{{item.created_at|dateTimeFormat('Y-m-d H:i:s')}}</span>
  30. <dl>共{{item.page_num}}页</dl>
  31. </div>
  32. <div class="button_erea">
  33. <el-button type="primary" class="el-button--small small_button" @click="handle('edit',item)">编辑</el-button>
  34. <el-button type="primary" class="el-button--small small_button" @click="openstatistics(item)">数据</el-button>
  35. <el-button type="primary" class="el-button--small small_button" @click="handle('copy',item)">复制</el-button>
  36. <el-button type="danger" class="el-button--small small_button" @click="handle('delete',item)">删除</el-button>
  37. </div>
  38. </div>
  39. </div>
  40. </div>
  41. </el-col>
  42. </el-row>
  43. </div>
  44. <div style="text-align: right;margin: 20px 0;">
  45. <el-pagination v-if="pagination" :page-size="pagination.pageSize"
  46. style="display: inline-block;float: right;" background @current-change="pageChange"
  47. layout="prev, pager, next" :total="pagination.total_count">
  48. </el-pagination>
  49. </div>
  50. <!-- 弹框添加相册-->
  51. <el-dialog title="创建画册" width="30%" :visible.sync="dialogAddgsVisible"
  52. @close="closeDialogAddgsVisible" :modal-append-to-body="false">
  53. <el-form :model="addForm" ref="addForm" :rules="addRule" :inline="true" @submit.native.prevent label-width="100px">
  54. <el-form-item label="相册名称" prop="name">
  55. <el-input v-model="addForm.name" placeholder="请填写相册名称"></el-input>
  56. </el-form-item>
  57. </el-form>
  58. <span slot="footer" class="dialog-footer">
  59. <el-button @click="dialogAddgsVisible = false">取 消</el-button>
  60. <el-button type="primary" :loading="btnLoading" @click="handle('add','addForm')">确 定</el-button>
  61. </span>
  62. </el-dialog>
  63. <!-- 弹框添加相册结束-->
  64. <!-- “数据”弹窗 -->
  65. <!-- <el-dialog title="数据(数据更新于2021-02-12 12:11)" :visible.sync="dialogFormVisible"> -->
  66. <el-dialog :title="title" :visible.sync="dialogFormVisible" >
  67. <div class="flex-x-between">
  68. <div class="statistics_name">画册名称:{{data_list.title}}</div>
  69. <div class="statistics_created_at" v-if="data_list.created_at">
  70. 发布时间:{{data_list.created_at | dateTimeFormat("Y-m-d H:i:s")}}
  71. </div>
  72. </div>
  73. <div class="dialog-cont" :data="data_list">
  74. <div class="cont-title">互动数据</div>
  75. <el-row :gutter="20" style="padding: 10px 0;background-color: #f3f2f2;">
  76. <el-col :span="4">
  77. <div class="cont-num center">{{data_list.views_count||"0"}}</div>
  78. <div class="center">浏览次数</div>
  79. </el-col>
  80. <el-col :span="4">
  81. <div class="cont-num center">{{data_list.visit_count||"0"}}</div>
  82. <div class="center">浏览人数</div>
  83. </el-col>
  84. <el-col :span="4">
  85. <div class="cont-num center" >{{data_list.stop_time||"0"}}</div>
  86. <div class="center">平均浏览时长(秒)</div>
  87. </el-col>
  88. <el-col :span="4">
  89. <div class="cont-num center">{{data_list.shares_count||"0"}}</div>
  90. <div class="center">分享次数</div>
  91. </el-col>
  92. <el-col :span="4">
  93. <div class="cont-num center">{{data_list.shares_click_count||"0"}}</div>
  94. <div class="center">分享访问</div>
  95. </el-col>
  96. </el-row>
  97. </div>
  98. <div class="dialog-cont">
  99. <div class="cont-title">商品数据</div>
  100. <el-table :data = "goods_data" height="250" style="width: 100%" :header-cell-style="{'text-align':'center'}" :cell-style="{'text-align':'center'}">
  101. <el-table-column label="商品名称" align="left">
  102. <template slot-scope="scope">
  103. <div v-if="scope.row.goods != ''&& scope.row.goods != null">
  104. <div style="float: left; width:60px">
  105. <img width='60px' height='60px'
  106. style="float: left;"
  107. v-if="scope.row.goods.cover_pic"
  108. :src="scope.row.goods.cover_pic"
  109. />
  110. </div>
  111. <div style="float: left; width: 50%;margin-left: 10px; text-align: left;">
  112. <com-ellipsis :line="1" :title="scope.row.goods.goods_name">{{scope.row.goods.goods_name}}</com-ellipsis>
  113. <p style="color: red;">¥{{scope.row.goods.price}}</p>
  114. </div>
  115. </div>
  116. <samp v-else>--</samp>
  117. </template>
  118. </el-table-column>
  119. <el-table-column prop="view_number" label="引导进详情页人数" width="180">
  120. <template slot-scope="scope">
  121. <span :title="scope.row.view_number" class="">{{scope.row.visit_count||0}}</span>
  122. </template>
  123. </el-table-column>
  124. <el-table-column prop="bought_number" label="引导付款人数">
  125. <template slot-scope="scope">
  126. <span :title="scope.row.bought_number" class="">{{scope.row.pay_count||0}}</span>
  127. </template>
  128. </el-table-column>
  129. <el-table-column prop="amount" label="引导付款金额">
  130. <template slot-scope="scope">
  131. <span :title="scope.row.amount" class="">{{scope.row.amount||0}}</span>
  132. </template>
  133. </el-table-column>
  134. </el-table>
  135. </div>
  136. </el-dialog>
  137. </div>
  138. </template>
  139. <script>
  140. // 无路由通过Prop 模拟路由
  141. const VueRoute = {
  142. props: {
  143. $route: {
  144. type: Object,
  145. required: true
  146. }
  147. },
  148. methods: {
  149. $router(path) {
  150. if (typeof path === 'string') {
  151. this.$emit('router', {
  152. path,
  153. query: {}
  154. })
  155. } else {
  156. this.$emit('router', path)
  157. }
  158. }
  159. }
  160. }
  161. const components = {
  162. ManagementAlbum: {
  163. template: '#mtmlt',
  164. extends: VueRoute,
  165. created() {
  166. this.getAlbumList()
  167. },
  168. data() {
  169. var validatePass = (rule, value, callback) => {
  170. var reg = /^[\u4e00-\u9fa5\w]+$/;
  171. if (reg.test(value)) {
  172. callback();
  173. }else{
  174. callback(new Error('规则名不能含有特殊字符'));
  175. }
  176. };
  177. return {
  178. page: 1,
  179. page_count: 0,
  180. page_size: 0,
  181. title:'',
  182. btnLoading: false,
  183. total: 0,
  184. addForm:{
  185. name:'',
  186. },
  187. data_list:{
  188. },
  189. dialogFormVisible: false, //数据弹窗
  190. dialogAddgsVisible:false, //添加相册弹窗
  191. loading: false,
  192. pagination:[],
  193. goods_data:[],
  194. albumList: [],
  195. api_url:'',
  196. addRule: {
  197. name: [
  198. {required: true, message: '请填写相册名称', trigger: 'change'},
  199. {
  200. validator: (rule, value, callback) => {
  201. if(value.length>12||value.length<0){
  202. callback('最大长度在1-12个字内');
  203. }
  204. callback();
  205. }
  206. },
  207. {
  208. validator:validatePass,
  209. trigger: 'blur'
  210. },
  211. ],
  212. },
  213. }
  214. },
  215. methods: {
  216. /**
  217. *关闭或取消模态框,清空值
  218. * @param
  219. */
  220. closeDialogAddgsVisible() {
  221. this.$refs.addForm.resetFields();//element封装的方法,清空模态框的值
  222. this.title = "" //初始化title的值
  223. this.addForm = {//初始化addForm中的值
  224. title: "",
  225. }
  226. },
  227. openalbum(){
  228. //this.addForm.name = '';
  229. this.dialogAddgsVisible = true;
  230. },
  231. openstatistics(data){
  232. this.dialogFormVisible = true;
  233. this.data_list = data;
  234. let self = this;
  235. self.btnLoading = true;
  236. request({
  237. params: {
  238. r: 'album/statistics/statistics',
  239. },
  240. method: 'post',
  241. data:{id:data.id},
  242. }).then(e => {
  243. this.btnLoading = false;
  244. if (e.data.code == 0) {
  245. this.data_list = e.data.data;
  246. this.goods_data = e.data.data.goods;
  247. if(this.data_list.created_at){
  248. this.title = "数据(数据自"+this.data_list.created_at+"日开始统计)";
  249. }else{
  250. this.title = "数据统计";
  251. }
  252. this.data_list.title = data.title;
  253. this.data_list.created_at = data.created_at;
  254. this.data_list.updated_at = data.updated_at;
  255. } else {
  256. self.$message.error(e.data.msg);
  257. }
  258. this.dialogAddgsVisible = false;
  259. }).catch(e => {
  260. console.log(e);
  261. });
  262. },
  263. handle(type,data = null){
  264. switch (type) {
  265. case 'delete':// 删除
  266. this.$confirm('删除该条数据后不可以恢复, 是否继续?', '警告', {type: 'warning'}).then(() => {this.send({id: data.id,status:-1,type:'1'});})
  267. break;
  268. case 'enable':
  269. var status = 0;
  270. if(data.status=='0') status = 1;
  271. this.send({id: data.id,status: status,type:'1'});
  272. break;
  273. case 'sort':
  274. this.send({sort:this.sort,id:this.id});
  275. this.id = '';
  276. break;
  277. case 'edit':
  278. let info = {r: 'album/default/edit',album_id: data.id};
  279. navigateTo(info);
  280. break;
  281. case 'copy':
  282. let copy = {r: 'album/default/edit',album_id: data.id,type:2};
  283. navigateTo(copy);
  284. break;
  285. case 'add':
  286. this.$refs[data].validate((valid) => {
  287. let self = this;
  288. if (valid) {
  289. let copy = {r: 'album/default/edit',name: self.addForm.name};
  290. navigateTo(copy);
  291. } else {
  292. console.log('error submit!!');
  293. return false;
  294. }
  295. });
  296. break;
  297. }
  298. },
  299. send(data,type=''){
  300. let self = this;
  301. self.btnLoading = true;
  302. request({
  303. params: {
  304. r: 'album/default/edit',
  305. },
  306. method: 'post',
  307. data:data,
  308. }).then(e => {
  309. this.dialogAddgsVisible = false;
  310. this.btnLoading = false;
  311. if (e.data.code == 0) {
  312. if(type == 1){
  313. let copy = {r: 'album/default/edit',album_id: e.data.data.id};
  314. navigateTo(copy);
  315. }else{
  316. self.$message.success(e.data.msg);
  317. self.getAlbumList();
  318. }
  319. } else {
  320. self.$message.error(e.data.msg);
  321. }
  322. }).catch(e => {
  323. console.log(e);
  324. });
  325. },
  326. pageChange(currentPage) {
  327. let self = this;
  328. self.page = currentPage;
  329. self.getAlbumList();
  330. },
  331. getAlbumList(page = 1) {
  332. let self = this;
  333. self.btnLoading = true;
  334. request({
  335. params: {
  336. r: 'album/default/index',
  337. },
  338. method: 'post',
  339. data: {
  340. page:this.page,
  341. },
  342. }).then(e => {
  343. this.btnLoading = false;
  344. this.albumList = e.data.data.list;
  345. this.api_url = e.data.data.api_url;
  346. this.pagination = e.data.data.pagination;
  347. this.pagination.pageSize = e.data.data.page_size;
  348. this.pagination.total_count = e.data.data.count;
  349. }).catch(e => {
  350. console.log(e);
  351. });
  352. },
  353. },
  354. },
  355. }
  356. new Vue({
  357. el: '#app',
  358. template: '#main',
  359. data() {
  360. return {
  361. // 模拟路由
  362. route: {
  363. // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  364. path: 'ManagementAlbum',
  365. query: {
  366. }
  367. }
  368. }
  369. },
  370. method: {
  371. delAlbum() {
  372. console.log(11)
  373. }
  374. },
  375. components
  376. })
  377. </script>
  378. <style>
  379. /* 下部分可抽离 */
  380. .flex {
  381. display: flex;
  382. }
  383. .align-center {
  384. align-items: center;
  385. }
  386. .justify-between {
  387. justify-content: space-between;
  388. }
  389. .margin-top-xs {
  390. margin-top: 10px;
  391. }
  392. .padding-xs {
  393. padding: 10px;
  394. }
  395. .padding-bottom-xs {
  396. padding-bottom: 10px;
  397. }
  398. .text-sm {
  399. font-size: 16px;
  400. }
  401. .text-bold {
  402. font-weight: bold;
  403. }
  404. </style>
  405. <style>
  406. /* 数据 */
  407. .el-dialog__body{
  408. padding: 20px;
  409. }
  410. .flex-x-between{
  411. width: 100%;
  412. height: 30px;
  413. line-height: 30px;
  414. }
  415. .dialog-cont{
  416. margin-top: 20px;
  417. clear: both;
  418. }
  419. .cont-title {
  420. font-size: 15px;
  421. padding-top: 20px;
  422. padding-bottom: 10px;
  423. font-weight: 700;
  424. }
  425. .cont-num {
  426. font-size: 14px;
  427. font-weight: 700;
  428. padding-bottom: 10px;
  429. }
  430. .center {
  431. text-align: center;
  432. }
  433. .el-dialog__header .el-dialog__title{
  434. font-size: 18px;
  435. }
  436. .el-dialog__wrapper .el-dialog__body{
  437. padding: 3px 20px;
  438. }
  439. .statistics_name{
  440. width: 55%;
  441. float: left;
  442. }
  443. .statistics_created_at{
  444. width: 25%;
  445. font-size: 12px;
  446. color: #999999;
  447. float: right;
  448. }
  449. .statistics_update_at{
  450. width: 20%;
  451. color: #999999;
  452. font-size: 12px;
  453. float: left;
  454. }
  455. /* 列表 */
  456. .list_title{
  457. width: 100%;
  458. height: 30px;
  459. line-height: 20px;
  460. text-align: left;
  461. font-size: 15px;
  462. margin-top: 10px;
  463. }
  464. .list_title span{
  465. color: #999999;
  466. font-size: 12px;
  467. }
  468. .list_title dl{
  469. margin: 0;
  470. padding: 0;
  471. color: #999999;
  472. font-size: 12px;
  473. float: right;
  474. width: 50px;
  475. text-align: right;
  476. }
  477. .solid-gray {
  478. background-color: #FFFFFF;
  479. }
  480. .button_erea .small_button{
  481. margin: 0;
  482. color: #ffffff;
  483. }
  484. .button_erea .small_button span{
  485. color: #ffffff;
  486. }
  487. .button_erea{
  488. margin-top: 10px;
  489. }
  490. .album {
  491. background-color: white;
  492. width: 250px;
  493. height: 260px;
  494. border-radius: 5px;
  495. margin-top: 10px;
  496. padding: 5px;
  497. margin: 5px auto;
  498. cursor: pointer;
  499. position: relative;
  500. border: 1px solid #efefef;
  501. }
  502. .album-content {
  503. height: 100%;
  504. width: 100%;
  505. }
  506. .album-content>.el-image {
  507. width: 100%;
  508. display: block;
  509. height: 90%;
  510. }
  511. .album-mask {
  512. display: flex;
  513. justify-content: center;
  514. flex-direction: column;
  515. height: 100%;
  516. width: 100%;
  517. left: 0;
  518. top: 0;
  519. position: absolute;
  520. background-color: rgba(0, 0, 0, .3);
  521. }
  522. .bg-white {
  523. background-color: white;
  524. }
  525. </style>