index_old.php 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: 阿源
  5. * Date: 2020/11/26
  6. * Time: 11:06
  7. */
  8. ?>
  9. <div id="app" v-cloak>
  10. <el-card v-loading="loading">
  11. <div class="nav">店铺装修</div>
  12. <div class="header_box">
  13. <div class="add_temp_box flex flex-x-between flex-y-center">
  14. <div class="add_temp_left flex flex-y-center">
  15. <p style="margin-right: 30px;">页面管理</p>
  16. <el-button type="primary" style="width: 162px;height:40px" @click="$navigate({r: 'mall/diy/edit'})">新建页面</el-button>
  17. </div>
  18. <div class="add_temp_right">
  19. <el-input placeholder="输入页面关键词搜索" v-model='title' suffix-icon="el-icon-search" @change='changeName'></el-input>
  20. </div>
  21. </div>
  22. </div>
  23. <div class="template_body">
  24. <div class="flex" style="flex-wrap: wrap;">
  25. <div class='template_item' v-for="(item,index) in temp_list">
  26. <div class="template_img_box">
  27. <div class="template_img_block">
  28. <img class="template_img" :src="item.cover" alt="">
  29. </div>
  30. <!-- <img :src="item.image" alt="" style="width:100%"> -->
  31. <div class='mask flex flex-x-center flex-y-center'>
  32. <div class="flex">
  33. <div class="temp_preview_small" @click="handle('edit', item)" style="margin-right: 10px;margin-bottom:8px;">编辑页面</div>
  34. <div class="temp_preview_small" @click="previewTemp(item)">预览页面</div>
  35. </div>
  36. <div class="flex" style="margin-bottom: 10px;">
  37. <div class="temp_preview_small" @click="handle('copy_page', item)" style="margin-right: 10px;margin-bottom:8px;">复制页面</div>
  38. <div class="temp_preview_small" @click="handle('destroy', item)">删除页面</div>
  39. </div>
  40. <div class="temp_preview copy_btn" @click="handle('copy_link', item)">复制链接</div>
  41. <div class="temp_preview" @click="handle('set_home', item)" v-if='item.is_home_page == 0 && item.type == 1'>设为首页</div>
  42. <div class="temp_preview" @click="handle('set_home', item)" v-if="item.is_home_page == 0 && item.template == 'home_page'">设为首页</div>
  43. </div>
  44. </div>
  45. <div class="template_text">
  46. <div class="template_title flex flex-y-center">
  47. <div style="margin-right: 12px;"> 名称:{{item.title}}</div>
  48. </div>
  49. <div class="use_number flex">
  50. <el-tag v-if="item.template == 'custom_page' && item.is_home_page == 1" effect="plain" size="medium" style="margin-right: 5px;"> 首页 </el-tag>
  51. <el-tag effect="plain" size="medium"> {{template[item.template]}} </el-tag>
  52. </div>
  53. <div class="use_number flex">
  54. <div>创建时间:{{item.created_at | dateTimeFormat('Y-m-d H:i')}}</div>
  55. </div>
  56. </div>
  57. </div>
  58. </div>
  59. <div class="pagination flex flex-x-between">
  60. <el-pagination background layout="prev, pager, next" :total="total_count" :hide-on-single-page="true" @current-change='currentChange'></el-pagination>
  61. </div>
  62. </div>
  63. <!-- 预览框 -->
  64. <el-dialog :visible.sync="dialogVisible" width="24%" :before-close="handleClose">
  65. <div class="preview_box">
  66. <div class="preview_content" ref='uContent' @mouseover='enterImg' @mouseout='is_begin = false'>
  67. <img @mousemove='imgMove' ref='uImg' class="preview_img" :src="selectObj.image" alt="">
  68. </div>
  69. </div>
  70. </el-dialog>
  71. </el-card>
  72. </div>
  73. <script>
  74. new Vue({
  75. el: '#app',
  76. data() {
  77. return {
  78. loading: '',
  79. temp_list: [],
  80. template: [],
  81. cate_index: 0,
  82. temp_index: -1,
  83. page: 1,
  84. dialogVisible: false,
  85. scrolltop: 0,
  86. timer: '', //图片定时滚动任务
  87. clientY: 0, //用来判断鼠标方向
  88. speed: 1, //图片滚动的速度
  89. is_begin: false, //是否开始滚动
  90. direction: '',
  91. timerDown: '',
  92. timerUp: '',
  93. title: null,
  94. total_count: 0,
  95. selectObj: '',
  96. }
  97. },
  98. watch: {
  99. direction(newVal) { //控制图片随鼠标上下滑动而滑动
  100. if (newVal == 'up') { //分成两个方法为了方便控制上下滚动
  101. clearInterval(this.timerDown)
  102. this.rollingUp();
  103. } else {
  104. clearInterval(this.timerUp)
  105. this.rollingDown();
  106. }
  107. }
  108. },
  109. created() {
  110. this.getList();
  111. },
  112. methods: {
  113. handle(type, data = null) {
  114. let id = data ? parseInt(data.id) : '';
  115. switch (type) {
  116. case 'edit':
  117. let params = {
  118. r: 'mall/diy/edit'
  119. };
  120. if (id) params = Object.assign(params, {
  121. id: id
  122. });
  123. navigateTo(params);
  124. break;
  125. case 'destroy':
  126. if (data.type == 2) {
  127. this.$message.error('该页面不允许删除!');
  128. return false;
  129. }
  130. param = {id: data.id};
  131. this.$confirm('删除该条数据后不可以恢复, 是否继续?', '警告', {type: 'warning'}).then(() => {this.send(param, 'mall/diy/delete')})
  132. break;
  133. case 'copy_page':
  134. param = {
  135. id: data.id
  136. };
  137. this.send(param, 'mall/diy/copy-page');
  138. break;
  139. case 'set_home':
  140. param = {
  141. id: data.id,
  142. };
  143. this.send(param, 'mall/diy/set-home');
  144. break;
  145. case 'copy_link':
  146. this.copyLink(data);
  147. break;
  148. }
  149. },
  150. send(params, url = '') {
  151. let self = this;
  152. request({
  153. params: {
  154. r: url,
  155. },
  156. method: 'post',
  157. data: params
  158. }).then(e => {
  159. if (e.data.code == 0) {
  160. self.$message.success(e.data.msg);
  161. self.getList();
  162. } else {
  163. self.$message.error(e.data.msg);
  164. }
  165. }).catch(e => {
  166. console.log(e);
  167. });
  168. },
  169. copyLink(data) { //复制链接
  170. var arr = window.location.href.split('/');
  171. if (data.is_home_page == 0) {
  172. var url = arr[0] + '//' + arr[2] + `/h5/#/pages/diy/diy?mall_id=${data.mall_id}&id=${data.id}`;
  173. } else {
  174. var url = arr[0] + '//' + arr[2] + `/h5/#/?mall_id=${data.mall_id}`;
  175. }
  176. var clipboard = new ClipboardJS('.copy_btn', {
  177. text: function() {
  178. return url;
  179. }
  180. });
  181. clipboard.on('success', (e) => {
  182. this.$message.success('复制成功!');
  183. e.clearSelection()
  184. clipboard.destroy()
  185. });
  186. clipboard.on('error', (e) => {
  187. this.$message.error('复制失败!');
  188. this.clipboard.destroy()
  189. });
  190. },
  191. changeName(e) {
  192. this.title = e;
  193. this.getList();
  194. },
  195. previewTemp(obj) {
  196. this.selectObj = obj;
  197. this.dialogVisible = true;
  198. },
  199. getList() {
  200. this.loading = true;
  201. this.$request({
  202. params: {
  203. r: 'mall/diy/index',
  204. },
  205. method: 'post',
  206. data: {
  207. title: this.title,
  208. page: this.page
  209. }
  210. }).then(e => {
  211. this.loading = false;
  212. if (e.data.code == 0) {
  213. this.temp_list = e.data.data.list;
  214. this.template = e.data.data.template;
  215. this.total_count = e.data.data.pagination.total_count;
  216. }
  217. });
  218. },
  219. currentChange(e) { //分页点击
  220. this.page = e;
  221. this.getList();
  222. console.log(e, '这是他点击了那个页面');
  223. },
  224. handleClose(done) {
  225. this.dialogVisible = false;
  226. clearInterval(this.timerUp);
  227. clearInterval(this.timerDown);
  228. this.scrolltop = 0;
  229. this.$refs.uContent.scrollTop = 0;
  230. },
  231. enterImg() { //进入图片事件
  232. setTimeout(() => { //加一个延时,防止鼠标刚移进去图片就开始动
  233. this.is_begin = true;
  234. }, 1000)
  235. },
  236. imgMove(e) { //图片滚动事件
  237. if (!this.is_begin) return;
  238. if (this.clientY != 0) {
  239. if (this.clientY > e.clientY) {
  240. this.direction = 'up';
  241. } else {
  242. this.direction = 'down';
  243. }
  244. };
  245. this.clientY = e.clientY;
  246. },
  247. rollingDown() {
  248. this.timerDown = setInterval(() => {
  249. if (this.$refs.uContent.scrollHeight - 696 >= this.scrolltop) {
  250. this.scrolltop = this.scrolltop + this.speed;
  251. this.$refs.uContent.scrollTop = this.scrolltop;
  252. } else {
  253. clearInterval(this.timerDown);
  254. }
  255. }, 2)
  256. },
  257. rollingUp() {
  258. this.timerUp = setInterval(() => {
  259. if (this.$refs.uContent.scrollTop <= 0) {
  260. clearInterval(this.timerUp);
  261. } else {
  262. this.scrolltop = this.scrolltop - this.speed;
  263. this.$refs.uContent.scrollTop = this.scrolltop;
  264. }
  265. }, 2)
  266. }
  267. }
  268. })
  269. </script>
  270. <style scoped>
  271. img {
  272. display: block;
  273. }
  274. .nav {
  275. background: #ffffff;
  276. border-radius: 5px;
  277. padding: 26px 24px;
  278. margin-bottom: 10px;
  279. /*color: #808695;*/
  280. }
  281. .cate_header {
  282. font-size: 14px;
  283. color: #808695;
  284. }
  285. .cate_title {
  286. margin-right: 24px;
  287. }
  288. .cate_item_active {
  289. color: #2DB7F5;
  290. background: #EDF6FF;
  291. }
  292. .template_body {
  293. background: #fff;
  294. border-radius: 0px 0 5px 5px;
  295. padding: 0px 49px 70px;
  296. }
  297. .template_item {
  298. width: 220px;
  299. margin: 0 38px 60px 0;
  300. cursor: pointer;
  301. }
  302. .template_img_box {
  303. width: 220px;
  304. height: 430px;
  305. /* border: 1px solid #BFBFBF; */
  306. border-radius: 18px;
  307. overflow: hidden;
  308. position: relative;
  309. background: url('resources/img/mall/decorate/duihuakuang240.png');
  310. background-size: 100% 100%;
  311. }
  312. .template_img_block {
  313. width: 95.7%;
  314. height: 399px;
  315. position: absolute;
  316. left: 50%;
  317. transform: translateX(-50%);
  318. top: 26px;
  319. border-radius: 0 0 15px 15px;
  320. overflow: hidden;
  321. }
  322. .template_img {
  323. width: 100%;
  324. position: absolute;
  325. left: 50%;
  326. transform: translateX(-50%);
  327. }
  328. .mask {
  329. background: rgba(0, 0, 0, 0.5);
  330. width: 100%;
  331. height: 100%;
  332. position: absolute;
  333. top: 0;
  334. left: 0;
  335. z-index: 5;
  336. opacity: 0;
  337. transition: all 0.3s;
  338. flex-direction: column;
  339. }
  340. .template_item:hover .mask {
  341. opacity: 1;
  342. }
  343. .temp_preview_small {
  344. width: 80px;
  345. height: 30px;
  346. border-radius: 5px;
  347. text-align: center;
  348. line-height: 30px;
  349. background: #ffffff;
  350. color: #313131;
  351. font-size: 12px;
  352. }
  353. .temp_preview {
  354. width: 170px;
  355. height: 30px;
  356. border-radius: 30px;
  357. background: #2DB7F5;
  358. color: #ffffff;
  359. text-align: center;
  360. line-height: 30px;
  361. font-size: 12px;
  362. margin-bottom: 8px;
  363. }
  364. .template_text {
  365. font-size: 14px;
  366. color: #515A6E;
  367. padding: 0 12px;
  368. }
  369. .template_title {
  370. margin: 10px 0 6px;
  371. }
  372. .use_number {
  373. font-size: 14px;
  374. align-items: center;
  375. color: #C5C8CE;
  376. margin-top: 10px;
  377. }
  378. /* 公共样式 */
  379. .flex {
  380. display: -webkit-box;
  381. display: -webkit-flex;
  382. /* #ifndef APP-NVUE */
  383. display: flex;
  384. /* #endif */
  385. }
  386. .flex-x-center {
  387. display: -webkit-box;
  388. display: -webkit-flex;
  389. /* #ifndef APP-NVUE */
  390. display: flex;
  391. /* #endif */
  392. -webkit-box-pack: center;
  393. -webkit-justify-content: center;
  394. -ms-flex-pack: center;
  395. justify-content: center;
  396. }
  397. .flex-x-between {
  398. display: -webkit-box;
  399. display: -webkit-flex;
  400. /* #ifndef APP-NVUE */
  401. display: flex;
  402. /* #endif */
  403. -webkit-box-pack: space-between;
  404. -webkit-justify-content: space-between;
  405. -ms-flex-pack: space-between;
  406. justify-content: space-between;
  407. }
  408. .flex-y-center {
  409. display: -webkit-box;
  410. display: -webkit-flex;
  411. /* #ifndef APP-NVUE */
  412. display: flex;
  413. /* #endif */
  414. -webkit-box-align: center;
  415. -webkit-align-items: center;
  416. -ms-flex-align: center;
  417. -ms-grid-row-align: center;
  418. align-items: center;
  419. }
  420. /* 溢出隐藏 */
  421. .over1 {
  422. text-overflow: -o-ellipsis-lastline;
  423. overflow: hidden;
  424. text-overflow: ellipsis;
  425. display: -webkit-box;
  426. -webkit-line-clamp: 1;
  427. -webkit-box-orient: vertical;
  428. }
  429. .over2 {
  430. text-overflow: -o-ellipsis-lastline;
  431. overflow: hidden;
  432. text-overflow: ellipsis;
  433. display: -webkit-box;
  434. -webkit-line-clamp: 2;
  435. -webkit-box-orient: vertical;
  436. }
  437. .pagination {
  438. width: 100%;
  439. flex-direction: row-reverse;
  440. }
  441. .pop {
  442. position: absolute;
  443. width: 100%;
  444. height: 100%;
  445. top: 0;
  446. left: 0;
  447. background: rgba(0, 0, 0, 0.5);
  448. }
  449. /* 预览框 */
  450. .preview_box {
  451. width: 377px;
  452. height: 760px;
  453. background: url('statics/img/mall/decorate/duihuakuang.png')no-repeat;
  454. position: relative;
  455. }
  456. .preview_content {
  457. background: #ffffff;
  458. width: 357px;
  459. height: 696px;
  460. position: absolute;
  461. top: 56px;
  462. left: 50.2%;
  463. transform: translateX(-50%);
  464. border-radius: 0 0 37px 36px;
  465. scrollbar-width: none;
  466. /* firefox */
  467. -ms-overflow-style: none;
  468. /* IE 10+ */
  469. overflow-x: hidden;
  470. overflow-y: auto;
  471. }
  472. .preview_content::-webkit-scrollbar {
  473. display: none;
  474. /* Chrome Safari */
  475. }
  476. .preview_img {
  477. width: 100%;
  478. }
  479. .el-dialog__body {
  480. padding: 0;
  481. width: 377px;
  482. height: 760px;
  483. }
  484. .el-dialog__header {
  485. display: none;
  486. }
  487. .el-dialog {
  488. min-width: 377px;
  489. max-width: 377px;
  490. background: transparent;
  491. border: 0;
  492. box-shadow: none;
  493. }
  494. .header_box {
  495. padding: 25px;
  496. background: #fff;
  497. border-radius: 5px 5px 0 0;
  498. color: #808695;
  499. }
  500. .add_temp_right {
  501. width: 400px;
  502. }
  503. .el-card {
  504. background: transparent;
  505. box-shadow: none !important;
  506. border: 0;
  507. }
  508. .el-card__body {
  509. padding: 0;
  510. }
  511. .logo_text {
  512. width: 56px;
  513. height: 21px;
  514. border-radius: 30px;
  515. background: #FF7161;
  516. text-align: center;
  517. line-height: 21px;
  518. color: #fff;
  519. }
  520. .logo_text2 {
  521. background: #C5C8CE;
  522. }
  523. </style>