소스 검색

新增登录权限

ltx529596 4 년 전
부모
커밋
1be3e8c7de

+ 130 - 0
src/components/tabbar/tabbar.vue

@@ -0,0 +1,130 @@
+<!-- tabbar -->
+<template name="tabBar">
+  <view class="tabbar">
+    <view class="content">
+      <view class="tabbar-warp"  v-for="(item, index) in roleList" :key="index" @tap="switchTab(index, item.code)">
+        <view class="navigator" :class="currentIndex === index ? 'active' : ''">
+          <view class="icon">
+            <view :class="item.code" class="iconbgc"></view>
+          </view>
+          <view class="text">{{ item.name }}</view>
+        </view>
+      </view>
+    </view>
+  </view>
+</template>
+
+<script>
+
+export default {
+  name: 'tabbar',
+  components: {},
+  props:{
+    currentIndex:{
+      type:Number,
+      default: 0
+    },
+    role:{
+      type:Array,
+      role:[]
+    }
+  },
+  data () {
+    //这里存放数据
+    return {
+      roleList:[]
+      // role: [
+      //   { name: '首页管理', code: 'index' },
+      //   { name: '订单管理', code: 'order' },
+      //   { name: '商品管理', code: 'shop' }
+      // ]
+    };
+  },
+  onReady () {
+    // this.roleList = this.$mStore.getters.hasrole.reverse()
+    let role = uni.getStorageSync('role')
+    this.roleList = role.reverse()
+  },
+  onLoad () {},
+  //方法集合
+  methods: {
+    switchTab (index, url) {
+      this.$emit('iscurrentIndex',index)
+      this.$mRouter.switchTab({ route: `/pages/${url}/${url}` })
+    }
+  }
+}
+</script>
+<style lang='scss' scoped>
+.tabbar {
+  position: fixed;
+  bottom: 0;
+  left: 0;
+  width: 100vw;
+  height: 110upx;
+  align-items: center;
+  background-color: #fff;
+  border-top: 1upx solid rgba(0, 0, 0, 0.33);
+  z-index: 99;
+  .content {
+    display: flex;
+    align-items: center;
+    height: 100%;
+    .tabbar-warp {
+      width: 33%;
+      .navigator {
+        display: flex;
+        flex-direction: column;
+        justify-content: center;
+        align-items: center;
+        .icon {
+          .iconbgc {
+            width: 48upx;
+            height: 48upx;
+          }
+          .index {
+            background: url('../../static/images/index.png') no-repeat center
+              center;
+            background-size: contain;
+          }
+          .order {
+            background: url('../../static/images/order.png') no-repeat center
+              center;
+            background-size: contain;
+          }
+          .goods {
+            background: url('../../static/images/shop.png') no-repeat center
+              center;
+            background-size: contain;
+          }
+        }
+        .text {
+          margin-top: 3upx;
+          font-size: 20upx;
+          color: rgb(183, 183, 183);
+        }
+      }
+     
+      .active {
+        .icon {
+          .index {
+            background: url('../../static/images/index_active.png') no-repeat center center;
+            background-size: contain;
+          }
+          .order {
+            background: url('../../static/images/order_active.png') no-repeat center center;
+            background-size: contain;
+          }
+          .goods {
+            background: url('../../static/images/shop_active.png') no-repeat center center;
+            background-size: contain;
+          }
+        }
+        .text {
+          color: #7d66f3;
+        }
+      }
+    }
+  }
+}
+</style>

+ 2 - 2
src/config/index.config.js

@@ -2,8 +2,8 @@ const CONFIG = {
     //开发环境配置
     development: {
         assetsPath: '/static', // 静态资源路径
-        baseUrl: 'http://tyou.xiudo.cn/merch',  // 后台接口请求地址
-        // baseUrl: 'http://192.168.100.135:83/merch',  // 后台接口请求地址
+        // baseUrl: 'http://tyou.xiudo.cn/merch',  // 后台接口请求地址
+        baseUrl: 'http://192.168.100.135:83/merch',  // 后台接口请求地址
         hostUrl: 'http://localhost:8080',        // H5地址(前端运行地址)
         websocketUrl: '',        // websocket服务端地址
         weixinAppId: '', // 微信公众号appid

+ 3 - 2
src/main.js

@@ -25,6 +25,8 @@ import rfImage from '@/components/rf-image/rf-image';
 import rfEmpty from '@/components/rf-empty';
 import rfLoading from '@/components/rf-loading/rf-loading';
 import rfLoadProgress from '@/components/rf-load-progress/rf-load-progress';
+// import tabBar from '@/components/tabbar.vue';
+import tabBar from '@/components/tabbar/tabbar.vue';
 
 // 网络状态监听
 uni.getNetworkType({
@@ -58,14 +60,13 @@ Vue.component('rfImage', rfImage);
 Vue.component('rfEmpty', rfEmpty);
 Vue.component('rfLoading', rfLoading);
 Vue.component('rfLoadProgress', rfLoadProgress);
+Vue.component('tabBar', tabBar);
 
 if (process.env.NODE_ENV === 'production') {
 	Vue.config.productionTip = false;
 }
 
 
-
-
 // 路由导航
 $mRouter.beforeEach((navType, to) => {
 	if (to.route === undefined)

+ 7 - 6
src/pages.json

@@ -59,7 +59,7 @@
     {
       "path":"pages/index/setting/editnotice",
       "style":{
-        "navigationBarTitleText": "公告管理",
+        "navigationBarTitleText": "公告编辑",
         "navigationBarBackgroundColor":"#ffffff",
         "navigationBarTextStyle": "black"
       }
@@ -98,7 +98,7 @@
       }
     },
     {
-      "path": "pages/shop/shop",
+      "path": "pages/goods/goods",
       "style": {
         "navigationBarTitleText": "商品管理",
         "navigationBarTextStyle": "black",
@@ -107,7 +107,7 @@
       }
     },
 		{
-			"path":"pages/shop/shopdetail",
+			"path":"pages/goods/shopdetail",
 			"style":{
         "navigationBarTitleText": "商品详情",
         "navigationBarTextStyle": "black",
@@ -115,7 +115,7 @@
 			}
 		},
 		{
-			"path":"pages/shop/editclassify",
+			"path":"pages/goods/editclassify",
 			"style":{
         "navigationBarTitleText": "新增自定义分类",
         "navigationBarBackgroundColor":"#ffffff",
@@ -123,7 +123,7 @@
 			}
 		},
 		{
-			"path":"pages/shop/classify",
+			"path":"pages/goods/classify",
 			"style":{
         "navigationBarTitleText": "管理自定义分类",
         "navigationBarBackgroundColor":"#ffffff",
@@ -136,6 +136,7 @@
 		"selectedColor": "#7d66f3",
 		"borderStyle": "black",
     "backgroundColor": "#ffffff",
+    "custom": true,
     "list": [{
 			"pagePath": "pages/index/index",
 			"text": "店铺首页",
@@ -149,7 +150,7 @@
       "selectedIconPath": "static/images/order_active.png"
     },
     {
-			"pagePath": "pages/shop/shop",
+			"pagePath": "pages/goods/goods",
 			"text": "商品管理",
 			"iconPath": "static/images/shop.png",
 			"selectedIconPath": "static/images/shop_active.png"

+ 0 - 2
src/pages/components/mask.vue

@@ -1,7 +1,6 @@
 <!-- 遮罩层 -->
 <template name="mask">
   <view class="mask" @touchmove.stop.prevent="moveHandle">
-    fuck
     <view class="maskbgc"></view>
     <view class="content">
       <view class="header">
@@ -14,7 +13,6 @@
           <icon v-if="!iconShow" class="iocn" type="warn" size="40"/>
           <view class="txt">{{ txt }}</view>
         </view>
-        
         <view class="sure">
           <view class="btn" @tap="sureconver">确认</view>
         </view>

+ 81 - 0
src/pages/components/tabbar.vue

@@ -0,0 +1,81 @@
+<!-- tabbar -->
+<template name="tab-bar">
+  <views class="tabbar">
+
+    <view class="tabbar-warp" v-for="(item,index) in tabList" :key="index">
+      <view class="navigator" :class="currentIndex === index ? 'active' : ''"  @tap='switchTab(index)'>
+        <view class="icon">
+          <image :src="item.icon"></image>
+        </view>
+        <view class="test">{{item.text}}</view>
+      </view>
+    </view>
+
+  </views>
+</template>
+
+<script>
+
+export default {
+  name: 'tabbar',
+  components: {},
+  data () {
+    //这里存放数据
+    return {
+      tabList: [
+        {
+          icon: 'icon-emotion',
+          text: 'tab01',
+          badge: 1
+        },
+        {
+          icon: 'icon-qianbao',
+          text: 'tab02',
+        },
+        {
+          icon: 'icon-choose01',
+          text: 'tab03',
+          badgeDot: true
+        }
+      ],
+      currentIndex: 0,
+
+    };
+  },
+  //方法集合
+  methods: {
+
+  }
+}
+</script>
+<style lang='less' scoped>
+.tabbar {
+  position: fixed;
+  bottom: 0;
+  left: 0;
+  height: 50upx;
+  align-items: center;
+  border-top:1upx solid rgba(0, 0, 0, 0.33);
+  z-index: 99;
+  .tabbar-warp {
+    .navigator {
+      display: flex;
+      flex-direction: column;
+      justify-content: center;
+      align-items: center;
+      .icon {
+        image {
+          width: 24upx;
+          height: 24upx;
+        }
+      }
+      .text {
+        color: rgb(183, 183, 183);
+      }
+    }
+    .active {
+      transform: scale(1.1);
+    }
+  }
+}
+</style>

+ 1 - 3
src/pages/shop/classify.vue → src/pages/goods/classify.vue

@@ -35,10 +35,8 @@
 </template>
 
 <script>
-import Header from '../components/header';
 export default {
   name: 'classify',
-  components: { Header },
   data() {
     //这里存放数据
     return {
@@ -57,7 +55,7 @@ export default {
   methods: {
     compile(data) {
       uni.setStorageSync('classData', data);
-      this.$mRouter.push({ route: '/pages/shop/editclassify' });
+      this.$mRouter.push({ route: '/pages/goods/editclassify' });
     },
     // 自定义分类列表
     async getCustomList() {

+ 0 - 0
src/pages/shop/editclassify.vue → src/pages/goods/editclassify.vue


+ 10 - 2
src/pages/shop/shop.vue → src/pages/goods/goods.vue

@@ -183,6 +183,7 @@
       </view>
     </view>
 
+    <tabBar :currentIndex="typeNum" :role="roleList"></tabBar>
     <uni-load-more :status="more"> </uni-load-more>
     <rf-loading v-if="loading"></rf-loading>
   </view>
@@ -196,8 +197,10 @@ export default {
   data() {
     //这里存放数据
     return {
-      deleteId: '',
+      typeNum: 2,
+      roleList:[],
 
+      deleteId: '',
       scenicID: 0, // 景区id 唯一(一个账号代表一个景区)
       loading: false,
       more: 'loading', // more  loading noMore
@@ -251,6 +254,11 @@ export default {
       }
     },
   },
+  onReady () {
+    // this.roleList = this.$mStore.getters.hasrole.reverse()
+    let role = uni.getStorageSync('role')
+    this.roleList = role.reverse()
+  },
   // 下拉刷新
   onPullDownRefresh() {
     this.more = 'loading';
@@ -287,7 +295,7 @@ export default {
       // if (id) {
       //   uni.setStorageSync('Id', id);
       // }
-      this.$mRouter.push({ route: '/pages/shop/shopdetail', query:{id: id}});
+      this.$mRouter.push({ route: '/pages/goods/shopdetail', query:{id: id}});
     },
     // 删除商品
     async deleteshop(id) {

+ 1 - 1
src/pages/shop/shopdetail.vue → src/pages/goods/shopdetail.vue

@@ -707,7 +707,7 @@ export default {
     toClassify () {
       if (this.storeId) {
         uni.setStorageSync('shopid', this.storeId);
-        this.$mRouter.push({ route: '/pages/shop/classify' });
+        this.$mRouter.push({ route: '/pages/goods/classify' });
       } else {
         this.$mHelper.toast('请选择所属店铺后再进行自定义分类管理');
       }

+ 14 - 4
src/pages/index/index.vue

@@ -281,6 +281,8 @@
 
         <view id="testecharts"></view>
 			</view>
+
+      <tabBar :currentIndex="typeNum" :role="roleList"></tabBar>
 		</view>
     <mask :txt="masktxt" :iconShow="iconShow" v-if="isShowMask" @isSureConver="isSureConver"></mask>
 		<rf-loading v-if="loading"></rf-loading>
@@ -304,6 +306,10 @@ export default {
   },
   data() {
     return {
+      // tabbar
+      typeNum: 0,
+      roleList:[],
+
       loadingMore1: true,
       loadingMore2: true,
       loadingMore3: true,
@@ -397,6 +403,13 @@ export default {
       value: null,
     },
   },
+  onReady () {
+    // this.roleList = this.$mStore.getters.hasrole.reverse()
+    let role = uni.getStorageSync('role')
+    this.roleList = role.reverse()
+  },
+  onLoad () {
+  },
   onShow() {
     this.todayforday = moment().format('YYYY-MM-DD HH:mm:ss')
     _self = this;
@@ -415,9 +428,6 @@ export default {
       this.$mHelper.toast(`自动更新数据${moment().format('h:mm:ss')}`);
     }, 1000 * 60 * 5);
   },
-  onLoad() {
-   
-  },
   onHide() {
     clearInterval(getDataBuyTime);
   },
@@ -514,7 +524,6 @@ export default {
           shopId: this.shopID,
         })
         .then(async (res) => {
-          console.log(res);
           if (res.code === 200 && res.data) {
             // 销售总额
             this.dataDo(res.data.xsze, this.sellSun);
@@ -1198,6 +1207,7 @@ canvas {
 }
 .index {
   background-color: #fafafa;
+  padding-bottom: 50upx;
 
   .index-content {
     padding: 85upx 33rpx 41upx;

+ 8 - 1
src/pages/order/order.vue

@@ -201,6 +201,8 @@
       </view>
     </view>
 
+    
+    <tabBar :currentIndex="typeNum" ></tabBar>
     <uni-load-more :status="more"> </uni-load-more>
     <rf-loading v-if="loading"></rf-loading>
     <view style="height: 100upx;"></view>
@@ -217,6 +219,7 @@ export default {
   data() {
     //这里存放数据
     return {
+      typeNum: 1,
       // loading: false,
       shopArray: [{ name: '全部', id: '' }],
       index: 0,
@@ -260,7 +263,11 @@ export default {
       startY: 0,
     };
   },
-
+  onReady () {
+    // this.roleList = this.$mStore.getters.hasrole.reverse()
+    let role = uni.getStorageSync('role')
+    this.roleList = role.reverse()
+  },
   // 下拉刷新page.json中要配置
   onPullDownRefresh() {
     this.startdate = '';

+ 5 - 1
src/pages/public/login.vue

@@ -140,9 +140,13 @@ export default {
       await this.$http
         .post(loginApi, params)
         .then((r) => {
+          // console.log(r);
+          // let role = JSON.stringify(r.data.page)
+          // console.log(role);
+          // uni.setStorageSync('role',r.data.page)
           this.$mHelper.toast('恭喜您,登录成功!');
           this.$mStore.commit('login', r.data);            
-            this.$mRouter.reLaunch({ route: '/pages/index/index' });
+          this.$mRouter.reLaunch({ route: '/pages/index/index' });
         })
         .catch(() => {
           this.btnLoading = false;

+ 22 - 1
src/store/index.js

@@ -1,5 +1,8 @@
 import Vue from 'vue'
 import Vuex from 'vuex'
+import mHelper from '@/utils/helper';
+import mRouter from '@/utils/router';
+
 
 Vue.use(Vuex);
 
@@ -7,11 +10,14 @@ const ACCESSTOKEN = uni.getStorageSync('accessToken') || '';
 const REFERRER = uni.getStorageSync('referrer') || '';
 const USER = uni.getStorageSync('user') || {};
 const REFRESHTOKEN = uni.getStorageSync('refreshToken') || '';
+const ROLE = uni.getStorageSync('role')
 
 const store = new Vuex.Store({
     state: {
         //用户token
         accessToken: ACCESSTOKEN,
+        // 用户权限
+        role: ROLE,
         //用户信息
         userInfo: USER.member,
         //推荐人
@@ -34,15 +40,30 @@ const store = new Vuex.Store({
             } else {
                 return false
             }
+        },
+        hasrole: state=> {
+            if (state.role) {
+                return state.role
+            } else {
+                mHelper.toast('该账号无权访问,默认重新登录!')
+                uni.hideLoading()
+                setTimeout(() => {
+                    mRouter.reLaunch({route: '/pages/public/login'})
+                }, 1000);
+                return
+            }
         }
     },
     mutations: {
         login(state, provider) {
+            console.log('provider');
+            console.log(provider);
 			state.accessToken=provider.access_token;
 			state.refreshToken=provider.refresh_token;
 			state.userInfo = provider.member;
 			state.user = provider;
-            uni.setStorageSync('user', provider);
+            uni.setStorageSync('user', provider.token);
+            uni.setStorageSync('role',provider.pages)
 			// uni.setStorageSync('accessToken', provider.access_token);
 			// uni.setStorageSync('refreshToken', provider.refresh_token);
 			// uni.setStorageSync('userInfo', provider.member);