Browse Source

主业显示由权限配置

zhouzhujun 3 months ago
parent
commit
93d0d5e13a
2 changed files with 50 additions and 12 deletions
  1. 9 2
      src/api/index.js
  2. 41 10
      src/pages/index.vue

+ 9 - 2
src/api/index.js

@@ -183,8 +183,15 @@ export function storeMail(data) {
     })
 }
 
-
-
+// 获取权限
+export function getRole(data) {
+    return request({
+        url: '/tianzong/client/user/getRole',
+        method: 'post',
+        data: data,
+        emulateJSON: true
+    })
+}
 
 
 

+ 41 - 10
src/pages/index.vue

@@ -4,7 +4,7 @@
 		<banner></banner>
 		<!-- 寄件按钮 -->
 		<div class="btn-two">
-			<a @click="goPage(1)">
+			<a @click="goPage(1)" v-if="role.express">
 				<span class="iconfont icon-delTask_slt iconStyle"></span>
 				<!-- <img src="../assets/images/jkd.png" alt=""> -->
 				<span>
@@ -12,7 +12,7 @@
 					<!-- <p>放心寄 丢必赔</p> -->
 				</span>
 			</a>
-			<a @click="goPage('trans')">
+			<a @click="goPage('trans')" v-if="role.trans">
 				<span class="iconfont icon-delTask_slt iconStyle"></span>
 				<!-- <img src="../assets/images/jkd.png" alt=""> -->
 				<span>
@@ -20,7 +20,7 @@
 					<!-- <p>放心寄 丢必赔</p> -->
 				</span>
 			</a>
-			<router-link to="Inexpress">
+			<router-link to="Inexpress" v-if="role.inexpress">
 				<span class="iconfont icon-neibujianpeizhi iconStyle"></span>
 				<!-- <img src="../assets/images/nbj.png" alt=""> -->
 				<span>
@@ -50,14 +50,24 @@
 	</div>
 </template>
 <script>
-import { Toast, Dialog } from 'vant'
-import { getWxUserInfo } from '../api/login'
+import { Toast } from 'vant'
+import { getRole } from '../api/index'
 import { getWxOpenId } from '../script/wxGetOpenId'
+
+const authMap = {
+	'211': 'express', // web外部寄件
+	'210': 'inexpress', // web内部寄件
+	'212': 'trans' // web门店调货
+}
+
 export default {
 	data() {
 		return {
-
-
+			role: {
+				express: false,
+				inexpress: false,
+				trans: false,
+			}
 		};
 	},
 	created: async function () {
@@ -65,18 +75,38 @@ export default {
 		console.log('开始走了')
 		// getWxOpenId()
 
+		getRole({}).then(res => {
+			if (res.code.toString() === '200') {
+				this.setRole(res.roleInfo.rights)
+			} else {
+				Toast(res.msg)
+			}
+		})
 	},
 	methods: {
+		setRole(authStr) {
+			try {
+				let authArr = authStr.split(',')
+				authArr.forEach(item => {
+					 if(authMap[item]){
+						this.role[authMap[item]] = true
+					 }
+				})
+			} catch (e) {
+				console.log(e)
+			}
+
+		},
 		link() {
 			Toast("正在开发中,敬请期待!")
 		},
-		goPage(type){
-			if(type === 1){
+		goPage(type) {
+			if (type === 1) {
 				window.location.href = window.location.href + "Express"
 				window.location.reload()
 				return
 			}
-			if(type === 'trans'){
+			if (type === 'trans') {
 				// this.$router.push({ path: "/transferGoods" })
 				window.location.href = window.location.href + "transferGoods"
 				window.location.reload()
@@ -234,6 +264,7 @@ export default {
 		}
 	}
 }
+
 .iconStyle {
 	font-size: 1rem;
 	color: #0c2469;