'适配深色模式'
This commit is contained in:
@@ -1,9 +1,8 @@
|
||||
<template>
|
||||
<!-- 状态栏 -->
|
||||
<view class="status_bar"></view>
|
||||
|
||||
<!-- 导航栏 :border="false" :left-text=" isLogin ? '返回': '首页'" :title="navTitle"-->
|
||||
<uni-nav-bar left-icon="left" rightWidth="200rpx" style="padding:10rpx 0" @clickLeft="clickLeft">
|
||||
<!-- 导航栏 style="padding:20rpx 0" -->
|
||||
<uni-nav-bar left-icon="left" :dark="!appTheme" rightWidth="200rpx" @clickLeft="clickLeft" >
|
||||
<view style="flex: 1;flex-direction: row;display:flex;align-items: center;justify-content: center;overflow: hidden;">
|
||||
<text style="font-weight: bold;font-size: 36rpx;">{{ navTitle }}</text>
|
||||
</view>
|
||||
@@ -15,7 +14,7 @@
|
||||
</template>
|
||||
</uni-nav-bar>
|
||||
|
||||
<view class="logo">
|
||||
<view class="logo" >
|
||||
<image @tap="switchTerrace" :src="log" mode="scaleToFill" />
|
||||
</view>
|
||||
|
||||
@@ -43,6 +42,7 @@
|
||||
</view>
|
||||
|
||||
<view class="info">欢迎进入京西到家商家版</view>
|
||||
|
||||
|
||||
<uni-popup ref="wxPopup" type="bottom">
|
||||
<view class="wxPopup-root">
|
||||
@@ -65,14 +65,219 @@
|
||||
</uni-popup>
|
||||
</template>
|
||||
|
||||
<script lang="ts" src="./wxLogin.ts">
|
||||
<script lang="ts" setup>
|
||||
import toast from "@/utils/toast";
|
||||
import { computed, ref } from "vue";
|
||||
import useGlobalFunc from "@/composables/useGlobalFunc";
|
||||
import { getStorage, setStorage } from "@/utils/storage";
|
||||
import { store } from "@/store";
|
||||
import { onReady, onShow } from "@dcloudio/uni-app";
|
||||
import login from "@/api/https/login"
|
||||
const { setUserInfo, appWxLogin } = useGlobalFunc()
|
||||
// export default {
|
||||
// setup() {
|
||||
const appTheme = computed(() => { return store.getters['serveInfo/appTheme'] === 'light'})
|
||||
const isLogin = computed(() => { return getStorage('token') ? true : false })
|
||||
|
||||
// 跳转手机号登录
|
||||
function phoneLogin() {
|
||||
// console.log('当前是属于哪个平台',getStorage('terrace'))
|
||||
uni.navigateTo({
|
||||
url: '/subPages/login/index',
|
||||
})
|
||||
}
|
||||
|
||||
// const log = ref<string>('https://image.jxc4.com/image/9b9436561e7ff7d8d764787b1aa5182e.jpg')
|
||||
const log = ref<string>('https://image.jxc4.com/image/987f5c2f23452cdcbddde16f055437f5.png')
|
||||
const navTitle = ref<string>('京西到家商家')
|
||||
onReady(() => {
|
||||
uni.setNavigationBarColor({
|
||||
frontColor: appTheme.value ? '#000000': '#ffffff', // 前景文字颜色,必选
|
||||
backgroundColor: appTheme.value ? '#ffffff' : '#000000', // 背景颜色,必选
|
||||
});
|
||||
})
|
||||
onShow(() => {
|
||||
isDownWx()
|
||||
if (getStorage('terrace') == 'jxcs') {
|
||||
// log.value = 'https://image.jxc4.com/image/9b9436561e7ff7d8d764787b1aa5182e.jpg'
|
||||
log.value = 'https://image.jxc4.com/image/987f5c2f23452cdcbddde16f055437f5.png'
|
||||
navTitle.value = '京西到家商家'
|
||||
} else if(getStorage('terrace') == 'jxgy'){
|
||||
// log.value = 'https://image.jxc4.com/image/9e26e6d4e8646d340c21dfe595ac4d08.jpg'
|
||||
log.value = 'https://image.jxc4.com/image/5b24d0fae35b45d99a911bb09ecfa927.png'
|
||||
navTitle.value = '京西果园商家'
|
||||
}else{
|
||||
// log.value = 'https://image.jxc4.com/image/5cd356df441a32295798f78a39491464.png'
|
||||
log.value = 'https://image.jxc4.com/image/a2164dbb2289734a7d96e778040c5776.png'
|
||||
navTitle.value = '京西超市商家'
|
||||
}
|
||||
// 获取cid
|
||||
plus.push.getClientInfoAsync((info) => {
|
||||
let cid = info["clientid"];
|
||||
setStorage('cid', cid)
|
||||
}, () => { });
|
||||
})
|
||||
|
||||
// ******************** 是否下载微信 *****************************
|
||||
const isWx = ref<boolean>(false)
|
||||
function isDownWx() {
|
||||
// if (plus.runtime.isApplicationExist({ pname: 'com.tencent.mm', action: 'weixin://' })) {
|
||||
// isWx.value = true
|
||||
// } else {
|
||||
// isWx.value = false
|
||||
// }
|
||||
|
||||
isWx.value = false
|
||||
// // return
|
||||
// uni.getProvider({
|
||||
// service: 'share',
|
||||
// success: function (res) {
|
||||
// // res.provider[0] === 'weixin' ? 微信已经安装 : 微信尚未安装
|
||||
// isWx.value = res.provider[0] == 'weixin' ? true : false
|
||||
// }})
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户协议
|
||||
*/
|
||||
function user() {
|
||||
let url = 'https://www.jxc4.com/managerApp/jxdjService.html'
|
||||
uni.navigateTo({ url: `/subPages/agreement/jxcs?url=${url}` })
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 隐私协议
|
||||
*/
|
||||
function privacy() {
|
||||
let url = 'https://www.jxc4.com/managerApp/jxdjPrivacy.html'
|
||||
uni.navigateTo({ url: `/subPages/agreement/jxcs?url=${url}` })
|
||||
}
|
||||
|
||||
// 微信登录弹窗实例
|
||||
const wxPopup = ref<any>(null)
|
||||
|
||||
// ******************** wx登录类 *****************************
|
||||
//#region
|
||||
// 微信登录
|
||||
function appWxLoginFn() {
|
||||
appWxLogin({
|
||||
bangding: (authToken: string) => {
|
||||
// 显示自定义加载图(vuex)
|
||||
store.commit('storeInfo/jxLoadingFn', true)
|
||||
uni.navigateTo({ url: `/subPages/login/addAuth/addAuth?authToken=${authToken}` })
|
||||
},
|
||||
success: (data: AnyObject) => {
|
||||
setUserInfo(data)
|
||||
saveUserType()
|
||||
}
|
||||
})
|
||||
wxPopup.value.close()
|
||||
}
|
||||
|
||||
/*************************************************
|
||||
* 存储用户信息
|
||||
*/
|
||||
async function saveUserType() {
|
||||
let res = await login.get_self_info()
|
||||
setStorage('userType', res.code == 0 ? res.data.type : 0)
|
||||
}
|
||||
//#endregion
|
||||
|
||||
|
||||
// ******************** 切换平台 *****************************
|
||||
//#region
|
||||
let timer: any = null
|
||||
function switchTerrace() {
|
||||
uni.showActionSheet({
|
||||
title: '请选择使用平台',
|
||||
itemColor: '#5ab83e',
|
||||
itemList: ['京西到家商家', '京西果园商家','京西超市商家'],
|
||||
popover: {
|
||||
width: 5000,
|
||||
},
|
||||
success: function (res) {
|
||||
uni.showLoading({
|
||||
title: '正在切换系统',
|
||||
})
|
||||
timer = setTimeout(() => {
|
||||
// 京西菜市商家
|
||||
if (res.tapIndex == 0) {
|
||||
setStorage('terrace', 'jxcs')
|
||||
log.value = 'https://image.jxc4.com/image/987f5c2f23452cdcbddde16f055437f5.png'
|
||||
navTitle.value = '京西到家商家'
|
||||
}
|
||||
// 京西果园商家
|
||||
if (res.tapIndex == 1) {
|
||||
setStorage('terrace', 'jxgy')
|
||||
log.value = 'https://image.jxc4.com/image/5b24d0fae35b45d99a911bb09ecfa927.png'
|
||||
navTitle.value = '京西果园商家'
|
||||
}
|
||||
// 京西到家商家
|
||||
if (res.tapIndex == 2) {
|
||||
setStorage('terrace', 'gblm')
|
||||
log.value = 'https://image.jxc4.com/image/a2164dbb2289734a7d96e778040c5776.png'
|
||||
navTitle.value = '京西超市商家'
|
||||
}
|
||||
|
||||
uni.hideLoading()
|
||||
toast('切换成功', 1)
|
||||
clearTimeout(timer)
|
||||
}, 500)
|
||||
},
|
||||
fail: () => {
|
||||
console.log('ZSW-取消')
|
||||
},
|
||||
})
|
||||
}
|
||||
//#endregion
|
||||
|
||||
/**
|
||||
* 返回
|
||||
*/
|
||||
const clickLeft = (() => {
|
||||
console.log('点击返回,当前的登录状态,11111111',isLogin.value)
|
||||
if(isLogin.value){
|
||||
|
||||
uni.navigateBack({
|
||||
delta: 1
|
||||
});
|
||||
}else{
|
||||
uni.switchTab({ url: '/pages/merchant/index' })
|
||||
}
|
||||
// uni.navigateBack({
|
||||
// uni.navigateBack({
|
||||
// delta: 1
|
||||
// });
|
||||
// })
|
||||
})
|
||||
|
||||
// return {
|
||||
// appTheme,
|
||||
// phoneLogin,
|
||||
// user,
|
||||
// privacy,
|
||||
// wxPopup,
|
||||
// appWxLoginFn,
|
||||
// switchTerrace,
|
||||
// log,
|
||||
// navTitle,
|
||||
// isWx,
|
||||
// getStorage,
|
||||
// clickLeft,
|
||||
// isLogin
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@import './wxLogin.scss';
|
||||
</style>
|
||||
<style>
|
||||
page {
|
||||
background-color: #fff;
|
||||
@media (prefers-color-scheme: light) {
|
||||
page {
|
||||
background-color: #fff;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user