index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388
  1. <template>
  2. <el-container class="box-all" v-loading="loading">
  3. <el-header>
  4. <div class="flex-box" style="height: 60px;">
  5. <div class="logo-box flex-box flex-center-center">
  6. <img src="./assets/image/logo.png" class="logo" />
  7. <div>功道云积分制</div>
  8. </div>
  9. <div class="flex-1 hea-right flex-box flex-v-ce" v-if="info.name">
  10. <div class="name flex-1">{{ info.name }}</div>
  11. <div class="flex-box flex-v-ce">
  12. <div>您当前为 <span class="blue">"{{corpMessage.package_name}}"</span>,有效期至<span style="color:#FF9600">{{corpMessage.expire_time}}</span></div>
  13. <el-button size="small" @click="isTz=true" class="upgrade" type="primary" icon="el-icon-upload">续费升级</el-button>
  14. <el-tooltip class="item" effect="dark" content="设置向导" placement="bottom" v-if="!this.$authoritys('employee') && !this.$authoritys('dept_manager')">
  15. <img src="./assets/image/wn.png" class="wn" @click="showWn">
  16. </el-tooltip>
  17. <userImage :user_name="userData.name" :img_url="userData.img_url" width="44px" height="44px"></userImage>
  18. </div>
  19. </div>
  20. </div>
  21. </el-header>
  22. <el-container class="main">
  23. <el-aside>
  24. <el-menu :default-active="defaultActive" class="el-menu-vertical-demo" :router="true" @select="activeRouter" >
  25. <template v-for="(item, index) in routers">
  26. <div v-if="item.children.length!=0" :key="index">
  27. <el-submenu :index="index.toString()" :key="index" v-if="item.children.length>=1 && item.name!='首页'">
  28. <template slot="title"><span class="iconfont titleIcon" :class="item.icon" style="font-size: 20px;"></span><span style="margin-left: 5px;">{{item.name}}</span></template>
  29. <template v-for="(item2, index2) in item.children">
  30. <el-menu-item :index="returnIndex(index,index2)" :ref="item2.path" :route="item2.path" :key="index2" class="font-flex-word">
  31. <span slot="title" style="margin-left: 10px;width:120px">{{ item2.name }}</span>
  32. </el-menu-item>
  33. </template>
  34. </el-submenu>
  35. <el-menu-item :index="returnIndex(index,index)" :route="item.children[0].path" :ref="item.children[0].path" v-else>
  36. <span class="iconfont titleIcon" :class="item.icon" style="font-size: 20px;"></span>
  37. <span slot="title" style="margin-left: 5px;">{{ item.children[0].name }}</span>
  38. </el-menu-item>
  39. </div>
  40. </template>
  41. </el-menu>
  42. </el-aside>
  43. <el-main>
  44. <router-view />
  45. <div class="fontColorF" style="text-align: center;margin: 20px 0;">Copyright © 2020 广东功道云数字科技有限公司 All Rights Reserved</div>
  46. </el-main>
  47. </el-container>
  48. <!-- 续费升级 -->
  49. <el-dialog class="续费升级" :visible.sync="isTz" width="400px">
  50. <div style="border-radius: 15px;border: 1px solid #f1f1f1;padding: 10px; width: 276px;box-sizing: border-box;margin: 0 auto;">
  51. <img src="./assets/image/code.png"/>
  52. </div>
  53. <div class="fontColorF" style="text-align: center;margin-top: 15px;font-size: 18px;">手机钉钉扫码,付费升级</div>
  54. </el-dialog>
  55. <el-dialog title="设置向导" :visible.sync="wn_show" width="600px">
  56. <div>
  57. <div class="wn-title fontColorF">三步轻松搭建积分管理体系:定人员、分责权、建制度</div>
  58. <div class="flex-box flex-v-ce wn-box">
  59. <div class="flex-1 flex-box-v flex-v-ce" @click="openView(0)">
  60. <div><span class="iconfont " :class="routers_one[0].meta.icon"></span></div>
  61. <div>1、确定{{routers_one[0].name}}</div>
  62. </div>
  63. <div class="flex-1 flex-box-v flex-v-ce" @click="openView(1)">
  64. <div><span class="iconfont " :class="routers_one[1].meta.icon"></span></div>
  65. <div>2、分配{{routers_one[1].name}}</div>
  66. </div>
  67. <div class="flex-1 flex-box-v flex-v-ce" @click="openView(2)">
  68. <div><span class="iconfont " :class="routers_one[2].meta.icon"></span></div>
  69. <div>3、建立{{routers_one[2].name}}</div>
  70. </div>
  71. </div>
  72. </div>
  73. <div>
  74. <div class="wn-title fontColorF">更有效地做好积分激励和认可,你还可以设置以下3项</div>
  75. <div class="flex-box flex-v-ce wn-box">
  76. <div class="flex-1 flex-box-v flex-v-ce" @click="openView(3)">
  77. <div><span class="iconfont " :class="routers_one[3].meta.icon"></span></div>
  78. <div>{{routers_one[3].name}}</div>
  79. </div>
  80. <div class="flex-1 flex-box-v flex-v-ce" @click="openView(4)">
  81. <div><span class="iconfont " :class="routers_one[4].meta.icon"></span></div>
  82. <div>{{routers_one[4].name}}</div>
  83. </div>
  84. <div class="flex-1 flex-box-v flex-v-ce" @click="openView(5)">
  85. <div><span class="iconfont " :class="routers_one[5].meta.icon"></span></div>
  86. <div>{{routers_one[5].name}}</div>
  87. </div>
  88. </div>
  89. </div>
  90. </el-dialog>
  91. <!-- <el-drawer
  92. title="我是标题"
  93. :visible.sync="isTz"
  94. :direction="direction"
  95. >
  96. <span>我来啦!</span>
  97. </el-drawer> -->
  98. </el-container>
  99. </template>
  100. <script>
  101. export default {
  102. data() {
  103. return {
  104. loading: false,
  105. userData: {},
  106. routers:[],
  107. routers_one:[],
  108. info: {},
  109. wn_show:false,
  110. defaultActive:"0-0",
  111. isShowWn:true,
  112. isTz:false,
  113. direction: 'rtl',
  114. corpMessage:{},//企业套餐信息
  115. };
  116. },
  117. created() {
  118. this.routers=[
  119. {name:'首页',children:this.returnRoutersArr('home'),icon:'icon-xuanzhong_shouye'},
  120. {name:'A/B分',children:this.returnRoutersArr('abPoint'),icon:'icon-PC_gongzuotai_ABfen'},
  121. {name:'任务',children:this.returnRoutersArr('task'),icon:'icon-PC_gongzuotai_renwu'},
  122. {name:'统计',children:this.returnRoutersArr('ranking'),icon:'icon-dingdingPC_tongji'},
  123. // {name:'设置',children:this.returnRoutersArr('set'),icon:'icon-dingdingPC_shezhi'},
  124. ];
  125. //this.$authoritys('权限名') 判断权限
  126. if(this.$authoritys('creator') || this.$authoritys('admin') || this.$authoritys('point_manager')){
  127. this.routers.push({name:'设置',children:this.returnRoutersArr('set'),icon:'icon-dingdingPC_shezhi'})
  128. }
  129. //this.returnRoutersArr('set',true) 加true表示不限制路由
  130. this.routers_one=this.returnRoutersArr('set',true);
  131. this.userData=this.$getUserData();
  132. if(this.$route.path!='/home'){//当刷新页面是控制左边导航栏的选中
  133. this.defaultActive=localStorage.getItem("path");
  134. }
  135. },
  136. mounted() {
  137. this.getTypes();
  138. this.getInfo();
  139. var url = window.location.href;
  140. var str = this.GetRequest(url).corpId || '123';
  141. var corpId = str.split('#')[0];
  142. if (corpId) {
  143. this.getCorp(corpId);
  144. }
  145. this.$nextTick(function() {
  146. if(!this.$authoritys('employee') && !this.$authoritys('dept_manager')){
  147. if (localStorage.getItem('wn_show')) {
  148. this.wn_show = false;
  149. this.isShowWn=false;
  150. } else {
  151. this.wn_show = true;
  152. localStorage.setItem('wn_show','true');
  153. }
  154. }
  155. });
  156. },
  157. watch:{
  158. $route(to,from){
  159. //多一层判断,防止误入或乱跳页面,判断对应路由是否有权限
  160. // if(to.meta.jurisdiction.indexOf(this.$supremeAuthority())==-1){
  161. // this.$router.push({ path: '/home' })
  162. // this.defaultActive = '0-0'
  163. // localStorage.setItem("path",'0-0');
  164. // }else{
  165. // }
  166. let routes = this.routers[to.meta.identification].children
  167. let paths = ''
  168. for(let i in routes){
  169. if(routes[i].path == to.path){
  170. paths = to.meta.identification+'-'+i
  171. // paths = this.returnIndex(to.meta.identification,i)
  172. }
  173. }
  174. this.defaultActive = paths
  175. localStorage.setItem("path",paths);
  176. }
  177. },
  178. methods: {
  179. GetRequest(urlStr) {
  180. if (typeof urlStr == 'undefined') {
  181. var url = decodeURI(location.search); //获取url中"?"符后的字符串
  182. } else {
  183. var url = '?' + urlStr.split('?')[1];
  184. }
  185. var theRequest = new Object();
  186. var strs;
  187. if (url.indexOf('?') != -1) {
  188. var str = url.substr(1);
  189. strs = str.split('&');
  190. for (var i = 0; i < strs.length; i++) {
  191. theRequest[strs[i].split('=')[0]] = decodeURI(strs[i].split('=')[1]);
  192. }
  193. }
  194. return theRequest;
  195. },
  196. //获取套餐信息
  197. getCorp(corpId) {
  198. this.$axios('get',"api/order/corp", {corp_id:corpId}).then((res) => {
  199. this.corpMessage = res.data.data;
  200. })
  201. },
  202. getSku(){
  203. var that = this;
  204. this.$axios('get','api/order/goods/sku',{callback: "https://test-ding.g107.com/#/index", goods_code: 'DD_GOODS-610003' }).then(res => {
  205. });
  206. },
  207. //当刷新页面是控制左边导航栏的选中
  208. activeRouter(index,indexPath){
  209. // console.log(index,indexPath)
  210. localStorage.setItem("path",indexPath[1]?indexPath[1]:indexPath[0]);
  211. },
  212. routerAstrict(data){//限制路由
  213. let obj = []
  214. let supAuthority = this.$supremeAuthority()
  215. data.forEach(item=>{
  216. if(!item.meta.jurisdiction){
  217. obj.push(item)
  218. }else{
  219. if(item.meta.jurisdiction.indexOf(supAuthority)==-1){
  220. obj.push(item)
  221. }
  222. }
  223. })
  224. return obj
  225. },
  226. returnRoutersArr(str,bool){
  227. var routers = this.$router.options.routes[0].children;
  228. var routersArr=[];
  229. routers.forEach(item=>{
  230. if(item.meta.groupCode==str){
  231. routersArr.push(item);
  232. }
  233. })
  234. if(bool){
  235. return routersArr;
  236. }
  237. return this.routerAstrict(routersArr);
  238. },
  239. returnIndex(str,str2){
  240. return str+"-"+str2;
  241. },
  242. openView(e){
  243. this.wn_show=false;
  244. this.isShowWn=false;
  245. this.$router.push({path:this.routers_one[e].path})
  246. this.defaultActive="2-"+(e).toString();
  247. localStorage.setItem("path",this.defaultActive);
  248. },
  249. showWn(){
  250. this.wn_show=true;
  251. },
  252. getInfo() {
  253. var that = this;
  254. this.$axios('get','/api/site/info').then(res => {
  255. that.info = res.data.data;
  256. });
  257. },
  258. getTypes() {
  259. var that = this;
  260. this.$axios('get','/api/integral/types').then(res => {
  261. that.$setTyps(res.data.data.list);
  262. });
  263. },
  264. }
  265. };
  266. </script>
  267. <style scoped="scoped" lang="scss">
  268. .wn-box{
  269. padding: 20px 0;
  270. }
  271. .wn-box .flex-1{
  272. cursor: pointer;
  273. }
  274. .wn-box .flex-1 div:nth-child(1){
  275. width: 55px;
  276. height: 55px;
  277. border-radius: 50%;
  278. text-align: center;
  279. line-height: 55px;
  280. background-color: #E0F2FF;
  281. color: #26A2FF;
  282. margin-bottom: 20px;
  283. }
  284. .wn-box .flex-1 div:nth-child(2){
  285. width: 110px;
  286. border-radius: 25px;
  287. border: 1px solid #26A2FF;
  288. padding:7px 10px;
  289. text-align: center;
  290. color: #26A2FF;
  291. }
  292. .wn-box .flex-1:hover div:nth-child(1){
  293. color: #fff;
  294. background-color: #26A2FF;
  295. }
  296. .wn-box .flex-1:hover div:nth-child(2){
  297. color: #fff;
  298. background-color: #26A2FF;
  299. }
  300. .el-menu-vertical-demo:not(.el-menu--collapse) {
  301. width: 180px;
  302. // min-height: 400px;
  303. }
  304. .el-header {
  305. background-color: #fff;
  306. // line-height: 60px;
  307. padding: 0 !important;
  308. border-bottom: 1px solid #f1f1f1;
  309. }
  310. .el-menu {
  311. overflow: hidden;
  312. border: none;
  313. }
  314. .el-aside {
  315. transition: width 0.28s;
  316. width: 180px !important;
  317. background-color: #fff;
  318. height: calc(100vh - 60px);
  319. }
  320. .el-aside::-webkit-scrollbar {
  321. width: 0px;
  322. background-color: #fff;
  323. }
  324. .el-aside::-webkit-scrollbar-thumb {
  325. background-color: #ccc;
  326. }
  327. .con_nav_left {
  328. background: #fff;
  329. overflow-y: scroll;
  330. }
  331. .box-all {
  332. height: 100%;
  333. overflow: hidden;
  334. }
  335. .el-main {
  336. background-color: #f4f6f9;
  337. height: calc(100vh - 60px);
  338. overflow-y: scroll;
  339. padding: 10px;
  340. }
  341. .el-main::-webkit-scrollbar{
  342. width: 3px;
  343. height: 10px;
  344. background-color: #fff;
  345. }
  346. .el-main::-webkit-scrollbar-thumb {
  347. background-color: #D9D9D9;
  348. }
  349. .logo-box {
  350. width: 180px;
  351. }
  352. .logo-box .logo {
  353. width: 30px;
  354. height: 30px;
  355. margin-right: 5px;
  356. border-radius: 6px;
  357. }
  358. .logo-box div {
  359. font-size: 16px;
  360. font-weight: 600;
  361. }
  362. .wn {
  363. height: 26px;
  364. width: 26px;
  365. margin-right: 12px;
  366. cursor: pointer;
  367. }
  368. .hea-right {
  369. padding: 0 20px;
  370. }
  371. .upgrade {
  372. margin-left: 10px;
  373. margin-right: 10px;
  374. }
  375. ::v-deep .el-menu-item{
  376. padding-right: 10px !important;
  377. }
  378. ::v-deep .el-menu-item.is-active {
  379. color: #26A2FF;
  380. background-color: #ecf5ff;
  381. }
  382. </style>