From 03bcdfbc9dd10e473686bbe27a8e615f5a22a283 Mon Sep 17 00:00:00 2001 From: web <candymxq888@outlook.com> Date: 星期三, 02 七月 2025 16:11:04 +0800 Subject: [PATCH] fix:小程序界面 --- pages/login/index.vue | 24 ++++++++++++------------ 1 files changed, 12 insertions(+), 12 deletions(-) diff --git a/pages/login/index.vue b/pages/login/index.vue index f612943..2e29d3e 100644 --- a/pages/login/index.vue +++ b/pages/login/index.vue @@ -2,7 +2,7 @@ <view class="container"> <view class="content"> <view class="top"> - <image class="top-bg" :src="BASE_URL + '/upload' + '/qingYuan/images/20241126/2f56a2a7ecfd2544dec5978d2687383e.png'" mode="widthFix"></image> + <image class="top-bg" src="../../static/images/login/top_bg.png" mode="widthFix"></image> <view class="top--title"> <image class="logo" src="../../static/images/login/logo.png "></image> <view class="text">慧物通直饮水</view> @@ -38,11 +38,11 @@ </view> </view> </view> - <view class="switch-btn" @click="changeLoginType"> +<!-- <view class="switch-btn" @click="changeLoginType"> <text v-if="loginType == 0">切换微信登录</text> <text v-if="loginType == 1">切换管理员登录</text> <image class="switch-to" src="../../static/images/login/switchto.svg"></image> - </view> + </view> --> </view> </view> </template> @@ -50,6 +50,7 @@ <script setup> import {ref, onMounted} from 'vue' import { BASE_URL } from '../../config/index.js'; + import { wxLoginApi } from '../../api/index.js' const loginType = ref(1) const form = ref({userName:'',password:''}) @@ -69,7 +70,7 @@ if(res.code == 200){ uni.setStorageSync('maintainId',JSON.stringify(res.data.id)) uni.setStorageSync('token',res.data.token) - uni.redirectTo({ + uni.switchTab({ url:'/pages/index/index' }) } @@ -77,23 +78,22 @@ } //用户点击微信登录默认授权 - function wxLogin(){ + const wxLogin = () => { wx.login({ - success:async (res1)=>{ + success:(res1)=>{ //存储微信登录的code,调用后端接口传递code参数,返回openid(也就是userId)存储到本地,通过判断本地是否存在openId,存在表示已登录 uni.setStorageSync('code',res1.code) - await wxLoginApi({code:res1.code}).then((res2) =>{ + wxLoginApi({code:res1.code}).then((res2) =>{ if(res2.code == 200){ - uni.redirectTo({ - url:'/pages/index/index' - }) uni.setStorageSync('openId',res2.data.userId) uni.setStorageSync('token',res2.data.token) + uni.switchTab({ + url:'/pages/index/index' + }) }else{ uni.showToast({ title:'登录失败', icon:'none', - }) } }) @@ -110,7 +110,7 @@ onMounted(() => { if(uni.getStorageSync('openId') && uni.getStorageSync('token')){ - uni.redirectTo({ + uni.switchTab({ url:'/pages/index/index' }) } -- Gitblit v1.9.3