Kaynağa Gözat

自定义导航栏

zxl 1 yıl önce
ebeveyn
işleme
761071aa9d

Dosya farkı çok büyük olduğundan ihmal edildi
+ 2 - 19486
package-lock.json


+ 39 - 21
src/App.vue

@@ -1,27 +1,45 @@
 <script>
-import { updateVersion } from './utils/system';
-export default {
-  async onLaunch() {
-    //#ifdef MP-WEIXIN
-    updateVersion();
-    //#endif
-  },
-};
+  import { updateVersion } from './utils/system';
+  import { setCache, getCache } from '@/utils/cache';
+  export default {
+    async onLaunch() {
+      //#ifdef MP-WEIXIN
+      // updateVersion();
+      //#endif
+      console.log('@@@@getCache',getCache('SET_ACCESS_TOKEN'));
+      return 
+      uni.hideTabBar()
+      let tabbar_type = uni.getStorageSync('tabbar_type')
+      console.log('@@@tabbar_type',tabbar_type);
+      // if(tabbar_type == false)
+      // let token = getCache('access_token')
+      // console.log('@@@token',token);
+      // if(!token){
+      //   uni.navigateTo({
+      //     url:'/pages/login/index'
+      //   })
+      //   return
+      // }
+    },
+    onShow() {
+      uni.hideTabBar()
+    }
+  };
 </script>
 
 <style lang="scss">
-@import 'uview-ui/index.scss';
-@import url('design/background.css');
-@import url('design/flex.css');
-@import url('design/margin.css');
-@import url('design/padding.css');
-@import url('design/shadow.css');
-@import url('design/text.css');
-@import url('design/common.css');
+  @import 'uview-ui/index.scss';
+  @import url('design/background.css');
+  @import url('design/flex.css');
+  @import url('design/margin.css');
+  @import url('design/padding.css');
+  @import url('design/shadow.css');
+  @import url('design/text.css');
+  @import url('design/common.css');
 
-page {
-  background-color: #f5f5f5;
-  color: $uni-text-color;
-  font-size: $uni-font-size-base;
-}
+  page {
+    background-color: #f5f5f5;
+    color: $uni-text-color;
+    font-size: $uni-font-size-base;
+  }
 </style>

+ 21 - 6
src/components/tabbar/index.vue

@@ -49,21 +49,21 @@ export default {
         {
           text: '首页',
           name: 'clientHome',
-          pagePath: 'pages/client/tabBar/home/index',
+          pagePath: '/pages/client/tabBar/home/index',
           iconPath: '/static/images/home.png',
           selectedIconPath: '/static/images/home-select.png',
         },
         {
           text: '社区',
           name: 'clientCommunity',
-          pagePath: 'pages/client/tabBar/community/index',
+          pagePath: '/pages/client/tabBar/community/index',
           iconPath: '/static/images/community.png',
           selectedIconPath: '/static/images/community-select.png',
         },
         {
           text: '消息',
           name: 'clientMessage',
-          pagePath: 'pages/client/tabBar/message/index',
+          pagePath: '/pages/client/tabBar/message/index',
           iconPath: '/static/images/message.png',
           selectedIconPath: '/static/images/message-select.png',
         },
@@ -114,11 +114,26 @@ export default {
       ],
     };
   },
+  mounted() {
+    this.isShow = uni.getStorageSync('tabbar_type')
+  },
+  watch:{
+    isShow(newValue){
+      console.log('@@@newValue',newValue);
+    }
+  },
   methods: {
     handTab(row) {
-      uni.switchTab({
-        url: row.pagePath,
-      });
+      if(this.isShow){
+        uni.switchTab({
+          url: row.pagePath,
+        });
+      }else{
+        uni.navigateTo({
+          url: row.pagePath,
+        });
+      }
+
     },
   },
 };

+ 10 - 22
src/pages.json

@@ -2,18 +2,17 @@
   "easycom": {
     "^u-(.*)": "uview-ui/components/u-$1/u-$1.vue"
   },
-  "pages": [
-    {
-      "path": "pages/login/index",
+  "pages": [{
+      "path": "pages/client/tabBar/home/index",
       "style": {
-        "navigationBarTitleText": "登录"
+        "navigationBarTitleText": "首页",
+        "navigationStyle": "custom"
       }
     },
     {
-      "path": "pages/client/tabBar/home/index",
+      "path": "pages/login/index",
       "style": {
-        "navigationBarTitleText": "首页",
-        "navigationStyle": "custom"
+        "navigationBarTitleText": "登录"
       }
     },
     {
@@ -74,13 +73,6 @@
         "navigationStyle": "custom"
       }
     },
-	{
-	  "path": "pages/merchant/testPage",
-	  "style": {
-	    "navigationBarTitleText": "店铺",
-	    "navigationStyle": "custom"
-	  }
-	},
     {
       "path": "pages/login/register",
       "style": {
@@ -101,11 +93,9 @@
       }
     }
   ],
-  "subPackages": [
-    {
+  "subPackages": [{
       "root": "pages/client/clientPackage",
-      "pages": [
-        {
+      "pages": [{
           "path": "search",
           "style": {
             "navigationBarTitleText": "搜索"
@@ -169,8 +159,7 @@
     },
     {
       "root": "pages/client/clientUser",
-      "pages": [
-        {
+      "pages": [{
           "path": "collectList",
           "style": {
             "navigationBarTitleText": "我的收藏"
@@ -280,8 +269,7 @@
     "selectedColor": "#42b2fa",
     "borderStyle": "black",
     "backgroundColor": "#ffffff",
-    "list": [
-      {
+    "list": [{
         "pagePath": "pages/client/tabBar/home/index"
       },
       {

+ 4 - 1
src/pages/client/clientUser/mine/setting.vue

@@ -125,7 +125,10 @@ export default {
     confirmSwitch() {
       // 点击确认切换身份
       // 处理身份切换逻辑
-      this.showSwitchDialog = false;
+      uni.setStorageSync('tabbar_type', false);
+      uni.navigateTo({
+        url:'/pages/merchant/tabBar/extend/index'
+      })
       // ... 其他操作
     },
     cancelSwitch() {

+ 1 - 4
src/pages/client/tabBar/home/index.vue

@@ -177,15 +177,12 @@ export default {
     },
   },
   onShow() {
-    /* 隐藏原生的tabbar */
-    uni.hideTabBar({
-      animation: false,
-    });
     this.getSwiperList();
   },
 
   //页面加载
   async onLoad() {
+    uni.hideTabBar()
     setTimeout(() => {
       this.list = new Array(10000).fill(1);
     }, 5000);

+ 3 - 10
src/pages/login/index.vue

@@ -126,21 +126,14 @@ export default {
         uni.$u.toast('请阅读并同意《用户协议》和 《隐私政策》');
         return;
       }
-      this.$Router.pushTab('/pages/client/tabBar/home/index');
-
       if (this.checked.length !== 0) {
         this.loading = true;
         this.form.token = await getWxLoginCode();
-        this.$store
-          .dispatch('LoginByWxCode', this.form)
-          .then(() => {
+        this.$store.dispatch('LoginByWxCode', this.form).then(() => {
+            uni.setStorageSync('tabbar_type', true);
+            this.$Router.pushTab('/pages/client/tabBar/home/index');
             this.loading = false;
             uni.$u.toast('登录成功');
-
-            // this.$store.dispatch('GetUserInfo').then(() => {
-            //   })
-            //   .catch(err => {
-            //   });
           })
           .catch(() => {
             this.loading = false;

+ 0 - 11
src/pages/merchant/testPage.vue

@@ -1,11 +0,0 @@
-<template>
-	<view class="">
-		13123
-	</view>
-</template>
-
-<script>
-</script>
-
-<style>
-</style>

+ 1 - 1
src/store/modules/user.js

@@ -16,7 +16,7 @@ export default {
     },
     SET_MERCGANT_ID(state, data) {
       state.merchantId = data;
-    },
+    }
   },
   actions: {
     GetUserInfo({ commit }) {

+ 32 - 15
src/utils/request.js

@@ -1,4 +1,6 @@
-import { getSystemInfoAsync } from '@/utils/system';
+import {
+  getSystemInfoAsync
+} from '@/utils/system';
 import store from '@/store';
 
 const BASE_URL = 'https://test.api.chelvc.com';
@@ -22,16 +24,18 @@ export function request(options) {
     title: options.loadingText || '加载中...',
   });
   return new Promise(async (resolve, reject) => {
-    const { deviceId, osName, osVersion } = await getSystemInfoAsync();
+    const {
+      deviceId,
+      osName,
+      osVersion
+    } = await getSystemInfoAsync();
     const access_token = store.getters.access_token;
     return uni.request({
       timeout: TIME_OUT,
       url: BASE_URL + options.url,
       method: options.method.toUpperCase() || 'GET',
       data: options.data,
-      header: Object.assign(
-        {},
-        {
+      header: Object.assign({}, {
           Authorization: `Bearer ${access_token}`,
           'Content-Type': 'application/json; charset=utf-8',
           client_id: 'chelvc_client',
@@ -47,15 +51,24 @@ export function request(options) {
         options.header,
       ),
       success: res => {
-        if (res.statusCode !== 200) {
-          uni.showToast({
-            icon: 'none',
-            title: res.data.message || errStatus[res.statusCode],
-            duration: 2000,
-          });
-          reject(res);
-        } else {
-          resolve(res.data);
+        switch (res.statusCode) {
+          case 401:
+            uni.reLaunch({
+              url: '/pages/login/index'
+            })
+            reject(res);
+            break;
+            // 无权限
+          case 403:
+            uni.showToast({
+              title: msg,
+              icon: 'none',
+              duration: 2000
+            });
+            reject(res);
+            break
+          default:
+           resolve(res.data);
         }
       },
       fail: err => {
@@ -81,7 +94,11 @@ export function request(options) {
  * @returns
  */
 export async function uploadFile(filePath) {
-  const { deviceId, osName, osVersion } = await getSystemInfoAsync();
+  const {
+    deviceId,
+    osName,
+    osVersion
+  } = await getSystemInfoAsync();
   const access_token = store.getters.access_token;
   uni.showLoading({
     title: '正在上传...',

Bu fark içinde çok fazla dosya değişikliği olduğu için bazı dosyalar gösterilmiyor