agent.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489
  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.15.14/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: 120px;
  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. min-height: 800px;
  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="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. mall_info: {
  199. logo: ""
  200. },
  201. defaultStoreLogo:_diy_img_prefix+'/static/addons/Store/default_store.png',
  202. menuCacheKey:'store_agent_menus'
  203. };
  204. },
  205. methods: {
  206. getMenus() {
  207. let data = localStorage.getItem(this.menuCacheKey);
  208. if (data) {
  209. try {
  210. data = JSON.parse(data);
  211. } catch (e) {
  212. data = false;
  213. }
  214. }
  215. if (data && data.menus) {
  216. this.leftMenus = data.menus;
  217. } else {
  218. this.leftMenuLoading = true;
  219. }
  220. this.currentStoreCleintMenu.opened_1 = localStorage.getItem('open_menu_1_id');
  221. this.currentStoreCleintMenu.opened_2 = localStorage.getItem('open_menu_2_id');
  222. this.currentStoreCleintMenu.opened_3 = localStorage.getItem('open_menu_3_id');
  223. this.currentStoreCleintMenu.unfold_id_1 = localStorage.getItem('unfold_id_1');
  224. this.currentStoreCleintMenu.unfold_id_2 = localStorage.getItem('unfold_id_2');
  225. this.setMenus();
  226. let self = this;
  227. /**优化点:只在首页请求最新菜单其他页面不需要再次请求 */
  228. if (this.leftMenuLoading == true) {
  229. this.$request({
  230. params: {
  231. r: 'happiness/agent/menu/list',
  232. route: getQuery('r'),
  233. catid: 2
  234. },
  235. method: 'get'
  236. }).then(e => {
  237. // 设置缓存
  238. localStorage.setItem(this.menuCacheKey, JSON.stringify(e.data.data));
  239. self.leftMenuLoading = false;
  240. self.leftMenus = e.data.data.menus;
  241. // 这里遍历侧边导航数组
  242. self.leftMenus.forEach(function(item) {
  243. if (item.is_active) {
  244. self.currentStoreCleintMenu.opened_1 = item.id;
  245. localStorage.setItem('open_menu_1_id', self.currentStoreCleintMenu.opened_1);
  246. if (item.children) {
  247. item.children.forEach(function(cItem1) {
  248. if (cItem1.is_active) {
  249. if (cItem1.children) {
  250. self.currentStoreCleintMenu.unfold_id_1 = cItem1.id;
  251. localStorage.setItem('unfold_id_1', self.currentStoreCleintMenu.unfold_id_1);
  252. cItem1.children.forEach(function(cItem2) {
  253. if (cItem2.is_active) {
  254. if (cItem2.children) {
  255. self.currentStoreCleintMenu.unfold_id_2 = cItem2.id;
  256. localStorage.setItem('unfold_id_2', self.currentStoreCleintMenu.unfold_id_2);
  257. cItem2.children.forEach(function(cItem3) {
  258. if (cItem3.is_active) {
  259. self.currentStoreCleintMenu.opened_2 = cItem3.id;
  260. localStorage.setItem('open_menu_2_id', self.currentStoreCleintMenu.opened_2);
  261. }
  262. })
  263. } else {
  264. self.currentStoreCleintMenu.opened_2 = cItem2.id;
  265. localStorage.setItem('open_menu_2_id', self.currentStoreCleintMenu.opened_2);
  266. }
  267. }
  268. })
  269. } else {
  270. self.currentStoreCleintMenu.opened_2 = cItem1.id;
  271. localStorage.setItem('open_menu_2_id', self.currentStoreCleintMenu.opened_2);
  272. }
  273. }
  274. })
  275. }
  276. }
  277. });
  278. self.setMenus();
  279. }).catch(e => {
  280. console.log(e);
  281. });
  282. }
  283. },
  284. openUrl(menu) {
  285. localStorage.setItem('unfold_id_1', this.currentStoreCleintMenu.unfold_id_1);
  286. localStorage.setItem('unfold_id_2', this.currentStoreCleintMenu.unfold_id_2);
  287. if (menu) {
  288. let args = {
  289. r: menu.url,
  290. sign:menu.mall_sign
  291. };
  292. if (menu.params) {
  293. for (let i in menu.params) {
  294. args[i] = menu.params[i];
  295. }
  296. }
  297. navigateTo(args)
  298. }
  299. },
  300. setMenus() {
  301. let self = this;
  302. if (!self.currentStoreCleintMenu.opened_2 && !self.currentStoreCleintMenu.unfold_id_1) {
  303. self.currentStoreCleintMenu.opened_1 = 0;
  304. }
  305. if (self.leftMenus && self.leftMenus.length > 0) {
  306. self.leftMenus.forEach(function(item) {
  307. if (item.id == self.currentStoreCleintMenu.opened_1) {
  308. self.currentStoreCleintMenu.list = item;
  309. }
  310. });
  311. }
  312. },
  313. // 点击一级菜单
  314. menuClick1(menu) {
  315. this.clearMenuStorage();
  316. this.currentStoreCleintMenu.opened_1 = menu.id;
  317. this.currentStoreCleintMenu.list = menu;
  318. localStorage.setItem('open_menu_1_id', menu.id);
  319. console.log(menu);
  320. if (!menu.children) {
  321. this.openUrl(menu);
  322. } else {
  323. if (menu.key == 'app-manage') {
  324. return
  325. }
  326. if (menu.children[0].children && menu.children[0].children.length > 0) {
  327. this.openUrl(menu.children[0].children[0]);
  328. localStorage.setItem('unfold_id_1', menu.children[0].id);
  329. localStorage.setItem('open_menu_3_id', menu.children[0].children[0].id);
  330. } else {
  331. this.openUrl(menu.children[0]);
  332. localStorage.setItem('open_menu_2_id', menu.children[0].id);
  333. }
  334. }
  335. },
  336. // 点击二级菜单
  337. menuClick2(menu) {
  338. if (menu.children) {
  339. let unfoldId1 = null;
  340. if (this.currentStoreCleintMenu.unfold_id_1 == menu.id) {
  341. unfoldId1 = 0;
  342. } else {
  343. unfoldId1 = menu.id;
  344. }
  345. this.currentStoreCleintMenu.unfold_id_1 = unfoldId1;
  346. localStorage.setItem('unfold_id_1', unfoldId1);
  347. } else {
  348. this.currentStoreCleintMenu.opened_2 = menu.id;
  349. let temporary = this.currentStoreCleintMenu.temporary_opened_1;
  350. if (temporary) {
  351. localStorage.setItem('open_menu_1_id', temporary);
  352. }
  353. localStorage.setItem('open_menu_2_id', menu.id);
  354. localStorage.setItem('open_menu_3_id', 0);
  355. this.openUrl(menu);
  356. }
  357. },
  358. // 点击三级菜单
  359. menuClick3(menu) {
  360. if (menu.children) {
  361. let unfoldId2 = null;
  362. if (this.currentStoreCleintMenu.unfold_id_2 == menu.id) {
  363. unfoldId2 = 0;
  364. } else {
  365. unfoldId2 = menu.id;
  366. }
  367. this.currentStoreCleintMenu.unfold_id_2 = unfoldId2;
  368. } else {
  369. this.currentStoreCleintMenu.opened_3 = menu.id;
  370. let temporary = this.currentStoreCleintMenu.temporary_opened_1;
  371. if (temporary) {
  372. localStorage.setItem('open_menu_1_id', temporary);
  373. }
  374. localStorage.setItem('open_menu_2_id', 0);
  375. localStorage.setItem('open_menu_3_id', menu.id);
  376. this.openUrl(menu);
  377. }
  378. },
  379. indexClick() {
  380. navigateTo({
  381. r: 'happiness/agent/index/index'
  382. })
  383. this.clearMenuStorage();
  384. },
  385. clearMenuStorage() {
  386. localStorage.removeItem('open_menu_1_id');
  387. localStorage.removeItem('open_menu_2_id');
  388. localStorage.removeItem('open_menu_3_id');
  389. localStorage.removeItem('unfold_id_1');
  390. localStorage.removeItem('unfold_id_2');
  391. },
  392. mouseenterEvent2() {
  393. let self = this;
  394. if (self.currentStoreCleintMenu.temporary_opened_1 > 0) {
  395. self.leftMenus.forEach(function(item) {
  396. if (self.currentStoreCleintMenu.temporary_opened_1 === item.id) {
  397. self.currentStoreCleintMenu.list = item;
  398. }
  399. })
  400. }
  401. },
  402. mouseleaveEvent2() {
  403. let self = this;
  404. self.currentStoreCleintMenu.temporary_opened_1 = 0;
  405. self.leftMenus.forEach(function(item) {
  406. if (item.id === self.currentStoreCleintMenu.opened_1) {
  407. self.currentStoreCleintMenu.list = item;
  408. }
  409. });
  410. self.currentStoreCleintMenu.unfold_id_1 = localStorage.getItem('unfold_id_1');
  411. self.currentStoreCleintMenu.unfold_id_2 = localStorage.getItem('unfold_id_2');
  412. if (this.currentStoreCleintMenu.opened_1 <= 0) {
  413. this.currentStoreCleintMenu.list = {};
  414. }
  415. },
  416. initHeight() {
  417. // 获取html可视区域高度:--这里需要按F5
  418. let agentHeight = `${document.documentElement.agentHeight}`;
  419. let mainHeight = agentHeight - 60;
  420. // 动态设置元素高度:
  421. var main = document.getElementById('_main'); //获取元素存储在变量中
  422. main.style.cssText = 'height: ' + mainHeight + 'px !important';
  423. }
  424. },
  425. mounted: function() {
  426. this.initHeight()
  427. window.addEventListener('resize', () => {
  428. this.initHeight()
  429. })
  430. if (this.currentRoute == 'happiness/agent/index/index') {
  431. localStorage.removeItem(this.menuCacheKey);
  432. }
  433. this.getMenus();
  434. },
  435. destroyed() {
  436. window.removeEventListener('resize', this.onResizEvent)
  437. }
  438. });
  439. _header = new Vue({
  440. el: '#_header'
  441. });
  442. //二级导航
  443. _main = new Vue({
  444. el: '#_aside_2',
  445. data() {
  446. return {
  447. currentStoreCleintMenu: _aside.currentStoreCleintMenu,
  448. }
  449. },
  450. });
  451. </script>
  452. <?php $this->endBody() ?>
  453. </body>
  454. <?= ComponentHelper::loadComponentView('com-image') ?>
  455. <?= ComponentHelper::loadComponentView('com-ellipsis') ?>
  456. </html>
  457. <?php $this->endPage() ?>