client.php 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514
  1. <?php
  2. /**
  3. * @var \yii\web\View $this
  4. * @var string $content
  5. */
  6. use common\helpers\ComponentHelper;
  7. $isAdmin = false;
  8. $isSuperAdmin = false;
  9. $currentRoute = Yii::$app->controller->route;
  10. ?>
  11. <?php $this->beginPage(); ?>
  12. <!DOCTYPE html>
  13. <html lang="zh-CN">
  14. <head>
  15. <meta charset="UTF-8">
  16. <meta name="renderer" content="webkit">
  17. <meta http-equiv="X-UA-Compatible" content="IE=Edge">
  18. <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=0">
  19. <meta name="format-detection" content="telephone=no,email=no,address=no">
  20. <title><?= $this->title ? ($this->title . ' - ') : '' ?>商城管理</title>
  21. <link rel="stylesheet" href="/resources/unpkg/element-ui@2.15.14/lib/theme-chalk/index.css">
  22. <link rel="stylesheet" href="/resources/css/flex.css">
  23. <link rel="stylesheet" href="/resources/css/qimall.css?t=<?= Yii::$app->params['css_cache_time'] ?>"">
  24. <link rel=" stylesheet" href="/resources/css/iconfont.css?t=<?= Yii::$app->params['css_cache_time'] ?>"">
  25. <link href=" /../favicon.ico" mce_href="/../favicon.ico" rel="shortcut icon" />
  26. <script>
  27. let _layout = null;
  28. let _aside = null;
  29. const _csrf = '<?= Yii::$app->request->csrfToken ?>';
  30. const _scriptUrl = '<?= Yii::$app->request->scriptUrl ?>';
  31. const _baseUrl = '<?= \Yii::$app->request->hostInfo . \Yii::$app->request->baseUrl ?>';
  32. const _requestRoute = '<?= Yii::$app->requestedRoute ?>';
  33. let _isWe7 = 'false';
  34. let _isInd = 'true';
  35. let _isAdmin = <?= $isAdmin ? 'true' : 'false' ?>;
  36. let _isSuperAdmin = <?= $isSuperAdmin ? 'true' : 'false' ?>;
  37. let _diy_img_prefix = "<?= Yii::getAlias('@attachurl') ?>";
  38. </script>
  39. <script src="/resources/unpkg/jquery@3.3.1/dist/jquery.min.js"></script>
  40. <script src="/resources/unpkg/vue@2.6.10/dist/vue.js"></script>
  41. <script src="/resources/js/vueInit.js?t=<?= Yii::$app->params['js_cache_time'] ?>"></script>
  42. <script src="/resources/unpkg/element-ui@2.12.0/lib/index.js"></script>
  43. <script src="/resources/unpkg/qs@6.5.2/dist/qs.js"></script>
  44. <script src="/resources/unpkg/axios@0.18.0/dist/axios.min.js"></script>
  45. <script src="/resources/unpkg/clipboard@1.0.0/dist/clipboard.min.js"></script>
  46. <script src="/resources/unpkg/dom-to-image@2.6.0/dom-to-image.js"></script>
  47. <script src="/resources/unpkg/vue-line-clamp@1.2.4/dist/vue-line-clamp.umd.js"></script>
  48. <script src="/resources/js/common.js?t=<?= Yii::$app->params['js_cache_time'] ?>"></script>
  49. <script src="/resources/js/dayjs.min.js"></script>
  50. <script src="/resources/js/echarts.min.js"></script>
  51. <script type="text/javascript" src="/resources/js/china.js"></script>
  52. <script type="text/javascript" src="/resources/js/world.js"></script>
  53. <script type="text/javascript" src="/resources/js/bmap.min.js"></script>
  54. <script type="text/javascript" src="/resources/js/hotzone.js"></script>
  55. <script src="/resources/js/qrcode.min.js"></script>
  56. <style>
  57. #_header {
  58. /*background-color: #24303c;*/
  59. background-color: #313131;
  60. height: 60px;
  61. }
  62. .left-menu-1 {
  63. width: 96px;
  64. background-color: #313131
  65. }
  66. .menu-item {
  67. height: 45px;
  68. padding: 15px;
  69. }
  70. .aside-logo {
  71. height: 60px;
  72. }
  73. .left-menu {
  74. height: auto;
  75. }
  76. .menu-item-box.active {
  77. height: 100%;
  78. }
  79. .menu-item-1.active {
  80. color: #000000;
  81. background: #ffffff;
  82. }
  83. ::-webkit-scrollbar {
  84. width: 0px;
  85. }
  86. </style>
  87. </head>
  88. <?= ComponentHelper::loadComponentView('com-attachment') ?>
  89. <?= ComponentHelper::loadComponentView('com-gallery') ?>
  90. <?= ComponentHelper::loadComponentView('com-attachment') ?>
  91. <?= ComponentHelper::loadComponentView('com-gallery') ?>
  92. <?= ComponentHelper::loadComponentView('com-pick-link') ?>
  93. <?= ComponentHelper::loadComponentView('com-upload') ?>
  94. <body>
  95. <?php $this->beginBody() ?>
  96. <div id="_layout"></div>
  97. <div class="el-container">
  98. <div v-cloak id="_aside" flex="dir:left">
  99. <div @click="isShowMenu = true" v-if="!isShowMenu" class="is-show-menu-2">
  100. <i class="el-icon-s-unfold"></i>
  101. </div>
  102. <!-- 一级菜单 -->
  103. <div class="left-menu left-menu-1">
  104. <div class="aside-logo" flex="main:center cross:center" @click="">
  105. <template>
  106. <img class="icon" :src="store_info.logo_img ? store_info.logo_img : defaultStoreLogo" style="width: 38px;height: 38px;background-size: 100%;background-repeat: no-repeat">
  107. </template>
  108. </div>
  109. <div @click="menuClick1(leftMenu)" v-for="leftMenu in leftMenus" :key="leftMenu.id" class="menu-item menu-item-1" :class="{'active': currentStoreCleintMenu.opened_1 == leftMenu.id || currentStoreCleintMenu.temporary_opened_1 == leftMenu.id ? true : false,
  110. 'hover':currentStoreCleintMenu.temporary_opened_1 == leftMenu.id && currentStoreCleintMenu.opened_1 != leftMenu.id ? true : false ,'menu-top': leftMenu.key == 'plugin-center' ? true : false }" flex="dir:left cross:center">
  111. <i :class="leftMenu.icon" style="margin-right: 5px;"></i>
  112. {{leftMenu.title}}
  113. </div>
  114. </div>
  115. </div>
  116. <div id="_layout_body" class="el-container is-vertical">
  117. <!-- 顶部工具栏 组件 -->
  118. <?= ComponentHelper::loadComponentView('header', __DIR__) ?>
  119. <div id="_header">
  120. <mall-header></mall-header>
  121. </div>
  122. <!-- style="height: 100%;" -->
  123. <div id="_main" flex ref="_main">
  124. <div v-cloak id="_aside_2" ref="asideTwo">
  125. <!-- 二级菜单 -->
  126. <transition name="slide">
  127. <div v-if="!_aside.overview && currentStoreCleintMenu.list && currentStoreCleintMenu.list.children && currentStoreCleintMenu.list.children.length > 0 && _aside.isShowMenu" @mouseenter="_aside.mouseenterEvent2()" @mouseleave="_aside.mouseleaveEvent2()" class="left-menu left-menu-2" :class="{'left-menu-2-show': !_aside.isShowMenu}">
  128. <!-- 展示收起按钮 -->
  129. <div @click="_aside.isShowMenu = false" v-if="_aside.isShowMenu" class="is-show-menu-1">
  130. <i class="el-icon-s-fold"></i>
  131. </div>
  132. <div class="menu-item menu-item-2-title" flex="dir:left cross:center">
  133. {{currentStoreCleintMenu.list.title}}
  134. </div>
  135. <div v-for="menu_1 in currentStoreCleintMenu.list.children" :key="menu_1.id" flex="dir:top">
  136. <div @click="_aside.menuClick2(menu_1)" class="menu-item menu-item-2" :class="{'active': currentStoreCleintMenu.opened_2 == menu_1.id ? true : false}" flex="dir:left cross:center">
  137. <div class="menu-item-box" flex="dir:left cross:center">
  138. <div class="icon-box">
  139. <div v-if="menu_1.children">
  140. <i v-if="currentStoreCleintMenu.unfold_id_1 == menu_1.id" class="el-icon-arrow-down"></i>
  141. <i v-else class="el-icon-arrow-right"></i>
  142. </div>
  143. </div>
  144. {{menu_1.title}}
  145. </div>
  146. </div>
  147. <!-- 三级菜单 -->
  148. <div v-if="currentStoreCleintMenu.unfold_id_1 == menu_1.id && menu_1.children" v-for="menu_2 in menu_1.children" :key="menu_2.id" flex="dir:top">
  149. <div @click="_aside.menuClick3(menu_2)" class="menu-item menu-item-3" :class="{'active': currentStoreCleintMenu.opened_3 == menu_2.id ? true : false}" flex="dir:left cross:center">
  150. <div class="menu-item-box" flex="dir:left cross:center">
  151. <div class="icon-box">
  152. <div v-if="menu_2.children">
  153. <i v-if="currentStoreCleintMenu.unfold_id_2 == menu_2.id" class="el-icon-arrow-down"></i>
  154. <i v-else class="el-icon-arrow-right"></i>
  155. </div>
  156. </div>
  157. {{menu_2.title}}
  158. </div>
  159. </div>
  160. </div>
  161. </div>
  162. </div>
  163. </transition>
  164. </div>
  165. <!-- 主页面部分 -->
  166. <main class="el-main" style="background: #f3f3f3">
  167. <?= $content ?>
  168. <!-- <components :is='content'></components> -->
  169. </main>
  170. </div>
  171. </div>
  172. </div>
  173. <script>
  174. _layout = new Vue({
  175. el: '#_layout',
  176. created() {},
  177. });
  178. _aside = new Vue({
  179. el: '#_aside',
  180. data() {
  181. return {
  182. mall: null,
  183. leftMenuLoading: false,
  184. leftMenus: {},
  185. defaultRoute: null,
  186. currentStoreCleintMenu: {
  187. list: null,
  188. opened_1: 0,
  189. temporary_opened_1: 0,
  190. opened_2: 0,
  191. opened_3: 0,
  192. unfold_id_1: 0,
  193. unfold_id_2: 0,
  194. },
  195. currentRoute: "<?= $currentRoute ?>",
  196. isShowMenu: true,
  197. overview: false,
  198. mallInfo: {
  199. logo: ""
  200. },
  201. store_info: {
  202. logo_img: ""
  203. },
  204. defaultStoreLogo:document.location.protocol+'//'+_diy_img_prefix+'/static/addons/Store/default_store.png',
  205. menuCacheKey:'store_client_menus'
  206. };
  207. },
  208. methods: {
  209. getMenus() {
  210. let data = localStorage.getItem(this.menuCacheKey);
  211. if (data) {
  212. try {
  213. data = JSON.parse(data);
  214. } catch (e) {
  215. data = false;
  216. }
  217. }
  218. if (data && data.menus) {
  219. this.leftMenus = data.menus;
  220. } else {
  221. this.leftMenuLoading = true;
  222. }
  223. this.currentStoreCleintMenu.opened_1 = localStorage.getItem('open_menu_1_id');
  224. this.currentStoreCleintMenu.opened_2 = localStorage.getItem('open_menu_2_id');
  225. this.currentStoreCleintMenu.opened_3 = localStorage.getItem('open_menu_3_id');
  226. this.currentStoreCleintMenu.unfold_id_1 = localStorage.getItem('unfold_id_1');
  227. this.currentStoreCleintMenu.unfold_id_2 = localStorage.getItem('unfold_id_2');
  228. this.setMenus();
  229. let self = this;
  230. /**优化点:只在首页请求最新菜单其他页面不需要再次请求 */
  231. if (this.leftMenuLoading == true) {
  232. this.$request({
  233. params: {
  234. r: 'mch/client/menu/list',
  235. route: getQuery('r'),
  236. catid: 2
  237. },
  238. method: 'get'
  239. }).then(e => {
  240. // 设置缓存
  241. localStorage.setItem(this.menuCacheKey, JSON.stringify(e.data.data));
  242. self.leftMenuLoading = false;
  243. self.leftMenus = e.data.data.menus;
  244. // 这里遍历侧边导航数组
  245. self.leftMenus.forEach(function(item) {
  246. if (item.is_active) {
  247. self.currentStoreCleintMenu.opened_1 = item.id;
  248. localStorage.setItem('open_menu_1_id', self.currentStoreCleintMenu.opened_1);
  249. if (item.children) {
  250. item.children.forEach(function(cItem1) {
  251. if (cItem1.is_active) {
  252. if (cItem1.children) {
  253. self.currentStoreCleintMenu.unfold_id_1 = cItem1.id;
  254. localStorage.setItem('unfold_id_1', self.currentStoreCleintMenu.unfold_id_1);
  255. cItem1.children.forEach(function(cItem2) {
  256. if (cItem2.is_active) {
  257. if (cItem2.children) {
  258. self.currentStoreCleintMenu.unfold_id_2 = cItem2.id;
  259. localStorage.setItem('unfold_id_2', self.currentStoreCleintMenu.unfold_id_2);
  260. cItem2.children.forEach(function(cItem3) {
  261. if (cItem3.is_active) {
  262. self.currentStoreCleintMenu.opened_2 = cItem3.id;
  263. localStorage.setItem('open_menu_2_id', self.currentStoreCleintMenu.opened_2);
  264. }
  265. })
  266. } else {
  267. self.currentStoreCleintMenu.opened_2 = cItem2.id;
  268. localStorage.setItem('open_menu_2_id', self.currentStoreCleintMenu.opened_2);
  269. }
  270. }
  271. })
  272. } else {
  273. self.currentStoreCleintMenu.opened_2 = cItem1.id;
  274. localStorage.setItem('open_menu_2_id', self.currentStoreCleintMenu.opened_2);
  275. }
  276. }
  277. })
  278. }
  279. }
  280. });
  281. self.setMenus();
  282. }).catch(e => {
  283. console.log(e);
  284. });
  285. }
  286. },
  287. openUrl(menu) {
  288. localStorage.setItem('unfold_id_1', this.currentStoreCleintMenu.unfold_id_1);
  289. localStorage.setItem('unfold_id_2', this.currentStoreCleintMenu.unfold_id_2);
  290. if (menu) {
  291. let args = {
  292. r: menu.url,
  293. sign:menu.mall_sign
  294. };
  295. if (menu.params) {
  296. for (let i in menu.params) {
  297. args[i] = menu.params[i];
  298. }
  299. }
  300. navigateTo(args)
  301. }
  302. },
  303. setMenus() {
  304. let self = this;
  305. if (!self.currentStoreCleintMenu.opened_2 && !self.currentStoreCleintMenu.unfold_id_1) {
  306. self.currentStoreCleintMenu.opened_1 = 0;
  307. }
  308. if (self.leftMenus && self.leftMenus.length > 0) {
  309. self.leftMenus.forEach(function(item) {
  310. if (item.id == self.currentStoreCleintMenu.opened_1) {
  311. self.currentStoreCleintMenu.list = item;
  312. }
  313. });
  314. }
  315. },
  316. // 点击一级菜单
  317. menuClick1(menu) {
  318. this.clearMenuStorage();
  319. this.currentStoreCleintMenu.opened_1 = menu.id;
  320. this.currentStoreCleintMenu.list = menu;
  321. localStorage.setItem('open_menu_1_id', menu.id);
  322. console.log(menu);
  323. if (!menu.children) {
  324. this.openUrl(menu);
  325. } else {
  326. if (menu.key == 'app-manage') {
  327. return
  328. }
  329. if (menu.children[0].children && menu.children[0].children.length > 0) {
  330. this.openUrl(menu.children[0].children[0]);
  331. localStorage.setItem('unfold_id_1', menu.children[0].id);
  332. localStorage.setItem('open_menu_3_id', menu.children[0].children[0].id);
  333. } else {
  334. this.openUrl(menu.children[0]);
  335. localStorage.setItem('open_menu_2_id', menu.children[0].id);
  336. }
  337. }
  338. },
  339. // 点击二级菜单
  340. menuClick2(menu) {
  341. if (menu.children) {
  342. let unfoldId1 = null;
  343. if (this.currentStoreCleintMenu.unfold_id_1 == menu.id) {
  344. unfoldId1 = 0;
  345. } else {
  346. unfoldId1 = menu.id;
  347. }
  348. this.currentStoreCleintMenu.unfold_id_1 = unfoldId1;
  349. localStorage.setItem('unfold_id_1', unfoldId1);
  350. } else {
  351. this.currentStoreCleintMenu.opened_2 = menu.id;
  352. let temporary = this.currentStoreCleintMenu.temporary_opened_1;
  353. if (temporary) {
  354. localStorage.setItem('open_menu_1_id', temporary);
  355. }
  356. localStorage.setItem('open_menu_2_id', menu.id);
  357. localStorage.setItem('open_menu_3_id', 0);
  358. this.openUrl(menu);
  359. }
  360. },
  361. // 点击三级菜单
  362. menuClick3(menu) {
  363. if (menu.children) {
  364. let unfoldId2 = null;
  365. if (this.currentStoreCleintMenu.unfold_id_2 == menu.id) {
  366. unfoldId2 = 0;
  367. } else {
  368. unfoldId2 = menu.id;
  369. }
  370. this.currentStoreCleintMenu.unfold_id_2 = unfoldId2;
  371. } else {
  372. this.currentStoreCleintMenu.opened_3 = menu.id;
  373. let temporary = this.currentStoreCleintMenu.temporary_opened_1;
  374. if (temporary) {
  375. localStorage.setItem('open_menu_1_id', temporary);
  376. }
  377. localStorage.setItem('open_menu_2_id', 0);
  378. localStorage.setItem('open_menu_3_id', menu.id);
  379. this.openUrl(menu);
  380. }
  381. },
  382. indexClick() {
  383. navigateTo({
  384. r: 'mch/client/index/index'
  385. })
  386. this.clearMenuStorage();
  387. },
  388. clearMenuStorage() {
  389. localStorage.removeItem('open_menu_1_id');
  390. localStorage.removeItem('open_menu_2_id');
  391. localStorage.removeItem('open_menu_3_id');
  392. localStorage.removeItem('unfold_id_1');
  393. localStorage.removeItem('unfold_id_2');
  394. },
  395. mouseenterEvent2() {
  396. let self = this;
  397. if (self.currentStoreCleintMenu.temporary_opened_1 > 0) {
  398. self.leftMenus.forEach(function(item) {
  399. if (self.currentStoreCleintMenu.temporary_opened_1 === item.id) {
  400. self.currentStoreCleintMenu.list = item;
  401. }
  402. })
  403. }
  404. },
  405. mouseleaveEvent2() {
  406. let self = this;
  407. self.currentStoreCleintMenu.temporary_opened_1 = 0;
  408. self.leftMenus.forEach(function(item) {
  409. if (item.id === self.currentStoreCleintMenu.opened_1) {
  410. self.currentStoreCleintMenu.list = item;
  411. }
  412. });
  413. self.currentStoreCleintMenu.unfold_id_1 = localStorage.getItem('unfold_id_1');
  414. self.currentStoreCleintMenu.unfold_id_2 = localStorage.getItem('unfold_id_2');
  415. if (this.currentStoreCleintMenu.opened_1 <= 0) {
  416. this.currentStoreCleintMenu.list = {};
  417. }
  418. },
  419. getBaseInfo() {
  420. const cacheKey = 'store_info'; //缓存key
  421. let data = localStorage.getItem(cacheKey);
  422. // if (!data) {
  423. this.$request({
  424. params: {
  425. r: 'mch/client/mch/index',
  426. },
  427. method: 'post'
  428. }).then(e => {
  429. this.store_info = e.data.data;
  430. localStorage.setItem(cacheKey, JSON.stringify(e.data.data));
  431. }).catch(e => {
  432. console.log(e);
  433. });
  434. // } else {
  435. // this.store_info = JSON.parse(data);
  436. // console.log(this.store);
  437. // }
  438. },
  439. initHeight() {
  440. // 获取html可视区域高度:--这里需要按F5
  441. let clientHeight = `${document.documentElement.clientHeight}`;
  442. let mainHeight = clientHeight - 60;
  443. // 动态设置元素高度:
  444. var main = document.getElementById('_main'); //获取元素存储在变量中
  445. main.style.cssText = 'height: ' + mainHeight + 'px !important';
  446. }
  447. },
  448. mounted: function() {
  449. this.initHeight()
  450. window.addEventListener('resize', () => {
  451. this.initHeight()
  452. })
  453. this.getBaseInfo();
  454. if (this.currentRoute == 'mch/client/index/index') {
  455. localStorage.removeItem(this.menuCacheKey);
  456. }
  457. this.getMenus();
  458. },
  459. destroyed() {
  460. window.removeEventListener('resize', this.onResizEvent)
  461. }
  462. });
  463. _header = new Vue({
  464. el: '#_header'
  465. });
  466. //二级导航
  467. _main = new Vue({
  468. el: '#_aside_2',
  469. data() {
  470. return {
  471. currentStoreCleintMenu: _aside.currentStoreCleintMenu,
  472. }
  473. },
  474. });
  475. </script>
  476. <?php $this->endBody() ?>
  477. </body>
  478. <?= ComponentHelper::loadComponentView('com-image') ?>
  479. <?= ComponentHelper::loadComponentView('com-ellipsis') ?>
  480. </html>
  481. <?php $this->endPage() ?>