xiaohaizhao преди 8 месеца
родител
ревизия
3859df1414
променени са 6 файла, в които са добавени 110 реда и са изтрити 8 реда
  1. 23 2
      App.vue
  2. 72 0
      components/My-shade/My-shade.vue
  3. 1 0
      pages/index/home.vue
  4. 4 1
      pages/index/index.vue
  5. 9 4
      pages/login/login.vue
  6. 1 1
      utils/Http.js

+ 23 - 2
App.vue

@@ -1,10 +1,31 @@
 <script>
+import { ref, getCurrentInstance } from 'vue'
 export default {
 	onLaunch: function () {
-	
+		const { $Http } = getCurrentInstance().proxy;
+		if (uni.getStorageSync('userMsg').token) {
+			{
+				$Http.basic({
+					"classname": "webmanage.site.site",
+					"method": "querySite_Parameter", //查询站点数据
+					content: {
+						nocache: true
+					}
+				}).then(res => {
+					if (res.code == 1) {
+						uni.removeStorageSync('siteP');
+						uni.setStorageSync("siteP", res.data)
+						$Http.isLoad = true;
+					} else {
+						$Http.isLoad = false;
+					}
+				})
+			}
+		} else {
+			$Http.isLoad = false
+		}
 	},
 	onShow: function () {
-	
 	},
 	onHide: function () {
 	}

+ 72 - 0
components/My-shade/My-shade.vue

@@ -0,0 +1,72 @@
+<template>
+    <view v-if="show" class="main" @click="handleClick">
+        <view class="head" @click.stop>
+            <view class="text" @click.stop>
+                当前页面需要登录才能继续使用
+            </view>
+            <My-button @onClick="toLogin" :customStyle="{
+                width: '200rpx',
+                height: '60rpx',
+                backgroundColor: '#007AFF',
+                color: '#fff',
+                borderRadius: '30rpx',
+                fontSize: '24rpx'
+            }" text="立即登录" />
+        </view>
+    </view>
+</template>
+
+<script setup>
+import { onShow } from '@dcloudio/uni-app';
+import { ref, getCurrentInstance } from 'vue'
+const { $Http } = getCurrentInstance().proxy;
+
+let show = ref(false);
+onShow(() => {
+    show.value = !$Http.isLoad;
+});
+
+function handleClick() {
+    uni.showModal({
+        title: '提示',
+        content: '当前页面需要登录才能继续使用',
+        confirmText: '立即登录',
+        success: ({ confirm }) => {
+            if (confirm) toLogin()
+        },
+
+    })
+}
+
+function toLogin() {
+    uni.navigateTo({
+        url: '/pages/login/login'
+    });
+}
+</script>
+
+<style lang="scss" scoped>
+.main {
+    position: fixed;
+    width: 100vw;
+    height: 100vh;
+    left: 0;
+    z-index: 2;
+
+    .head {
+        display: flex;
+        align-items: center;
+        justify-content: space-between;
+        width: 100vw;
+        background: rgba($color: #000000, $alpha: .5);
+        padding: 20rpx;
+        box-sizing: border-box;
+        margin-top: env(safe-area-inset-top)px;
+
+        .text {
+            color: #fff;
+            font-size: 24rpx;
+        }
+    }
+}
+</style>

+ 1 - 0
pages/index/home.vue

@@ -1,4 +1,5 @@
 <template>
+	<My-shade />
 	<view style="min-height: 100vh;width: 100vw;background-color: #fff;">
 		<view class="image-box">
 			<image style="width: 100vw;" src="/static/image/banner.png" mode="widthFix" />

+ 4 - 1
pages/index/index.vue

@@ -1,5 +1,7 @@
 <template>
-	<home v-show="showPage != 'my'" />
+	<view v-show="showPage != 'my'">
+		<home />
+	</view>
 	<view v-show="showPage != 'home'">
 		12
 	</view>
@@ -31,6 +33,7 @@ const { $Http } = getCurrentInstance().proxy;
 const showPage = ref('home');
 function change1(value) {
 	showPage.value = value;
+	console.log('change1', value);
 }
 
 </script>

+ 9 - 4
pages/login/login.vue

@@ -25,7 +25,7 @@
         </view>
         <My-button :customStyle="customStyle" class="my-but" :loading="loading" :disabled="disabled" text="登录"
             @onClick="logIn" />
-   <!--      <view class="agreement-box">
+        <!--      <view class="agreement-box">
             <up-checkbox label="已阅读并同意" name="agree" usedAlone v-model:checked="isAgreement" />
             <view @click="checkTheAgreement" style="color: #3874F6;">
                 《隐私协议》
@@ -179,9 +179,14 @@ function handleLogin(data) {
             uni.setStorageSync('userMsg', data);
             uni.removeStorageSync('phonenumber');
             uni.setStorageSync('phonenumber', phonenumber.value);
-            uni.redirectTo({
-                url: '/pages/index/index',
-            });
+            $Http.isLoad = true;
+            if (getCurrentPages().length > 1) {
+                uni.navigateBack();
+            } else {
+                uni.reLaunch({
+                    url: '/pages/index/index',
+                });
+            }
 
             $Http.basic({
                 "classname": "webmanage.site.site",

+ 1 - 1
utils/Http.js

@@ -3,7 +3,7 @@ import axios from "axios";
 class HTTP {
   constructor() {
     this.jsessionid = uni.getStorageSync("JSESSIONID") || "";
-
+    this.isLoad = false; // 用于是否显示登录提示
     // 创建 axios 实例
     this.instance = axios.create({
       baseURL: "/yos/rest",