From 2dce1fe5a79e6f96f031b65fff77ef66a973d6f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=85=A8=E6=A0=88=E5=B0=8F=E5=AD=A6=E7=94=9F?= <1518079521@qq.com> Date: Sat, 16 Nov 2024 14:36:04 +0800 Subject: [PATCH] up --- uni-app/src/App.vue | 28 ++- uni-app/src/app/api/auth.ts | 6 + uni-app/src/app/api/member.ts | 3 + uni-app/src/app/api/system.ts | 7 - .../components/diy/carousel-search/index.vue | 134 +++++++--- .../app/components/diy/graphic-nav/index.vue | 181 +++++++++----- .../src/app/components/diy/notice/index.vue | 6 +- uni-app/src/app/pages/auth/login.vue | 2 +- uni-app/src/app/pages/member/address_edit.vue | 1 - .../src/components/top-tabbar/top-tabbar.vue | 146 +++-------- uni-app/src/hooks/useGoods.ts | 50 ---- uni-app/src/hooks/useLocation.ts | 229 ++++++++++++++++++ uni-app/src/hooks/useLogin.ts | 6 +- uni-app/src/locale/zh-Hans.json | 1 + uni-app/src/stores/config.ts | 3 + uni-app/src/stores/system.ts | 20 +- uni-app/src/styles/common.scss | 60 ----- uni-app/src/styles/iconfont.css | 10 +- uni-app/src/styles/official-iconfont.css | 14 +- uni-app/src/utils/common.ts | 36 --- uni-app/src/utils/request.ts | 2 +- uni-app/src/utils/wechat.ts | 20 +- 22 files changed, 580 insertions(+), 385 deletions(-) delete mode 100644 uni-app/src/hooks/useGoods.ts create mode 100644 uni-app/src/hooks/useLocation.ts diff --git a/uni-app/src/App.vue b/uni-app/src/App.vue index 56362fb9b..1967d155b 100644 --- a/uni-app/src/App.vue +++ b/uni-app/src/App.vue @@ -121,7 +121,20 @@ if (memberInfo && memberInfo.wx_openid) { uni.setStorageSync('openid', memberInfo.wx_openid) } else { - data.query.code ? login.updateOpenid(data.query.code) : login.getAuthCode({ scopes: 'snsapi_base' }) + if (data.query.code) { + // 检测身份是否合法(当前登录的账号是不是我的),openid有效后才能更新登录 + login.updateOpenid(data.query.code, () => { + login.authLogin({ code: data.query.code }) + }) + } else { + if (loginConfig.is_force_access_user_info) { + // 强制获取用户信息 + login.getAuthCode({ scopes: 'snsapi_userinfo' }) + } else { + // 静默获取 + login.getAuthCode({ scopes: 'snsapi_base' }) + } + } } } // #endif @@ -163,7 +176,17 @@ if (uni.getStorageSync('autoLoginLock') && !uni.getStorageSync('wechat_login_back')) return; if (loginConfig.is_auth_register || uni.getStorageSync('wechat_login_back')) { uni.removeStorageSync('wechat_login_back') // 删除微信公众号手动授权登录回调标识 - data.query.code ? login.authLogin({ code: data.query.code }) : login.getAuthCode({ scopes: 'snsapi_base' }) + if (data.query.code) { + login.authLogin({ code: data.query.code }) + } else { + if (loginConfig.is_force_access_user_info) { + // 强制获取用户信息 + login.getAuthCode({ scopes: 'snsapi_userinfo' }) + } else { + // 静默获取 + login.getAuthCode({ scopes: 'snsapi_base' }) + } + } } } // #endif @@ -173,6 +196,7 @@ }) onShow(() => { + }) onHide(() => { diff --git a/uni-app/src/app/api/auth.ts b/uni-app/src/app/api/auth.ts index ded313f28..c599f089c 100644 --- a/uni-app/src/app/api/auth.ts +++ b/uni-app/src/app/api/auth.ts @@ -4,6 +4,9 @@ import request from '@/utils/request' * 用户名登录 */ export function usernameLogin(data : AnyObject) { + if(uni.getStorageSync('pid')){ + data.pid = uni.getStorageSync('pid'); + } return request.get('login', data, { showErrorMessage: true }) } @@ -11,6 +14,9 @@ export function usernameLogin(data : AnyObject) { * 手机验证码登录 */ export function mobileLogin(data : AnyObject) { + if(uni.getStorageSync('pid')){ + data.pid = uni.getStorageSync('pid'); + } return request.post('login/mobile', data, { showErrorMessage: true }) } diff --git a/uni-app/src/app/api/member.ts b/uni-app/src/app/api/member.ts index d34b3fb12..26e6169fa 100644 --- a/uni-app/src/app/api/member.ts +++ b/uni-app/src/app/api/member.ts @@ -47,6 +47,9 @@ export function modifyMember(data : AnyObject) { * 登录会员绑定手机号 */ export function bindMobile(data : AnyObject) { + if(uni.getStorageSync('pid')){ + data.pid = uni.getStorageSync('pid'); + } return request.put('member/mobile', data, { showErrorMessage: true }) } diff --git a/uni-app/src/app/api/system.ts b/uni-app/src/app/api/system.ts index 3e1f3b899..4f76dc6aa 100644 --- a/uni-app/src/app/api/system.ts +++ b/uni-app/src/app/api/system.ts @@ -116,13 +116,6 @@ export function getAddressByLatlng(params: Record) { return request.get(`area/address_by_latlng`, params, { showErrorMessage: true }) } -/** - * 获取手机端首页列表 - */ -export function getWapIndexList(data: AnyObject) { - return request.get('wap_index', data) -} - /** * 获取海报 * @returns diff --git a/uni-app/src/app/components/diy/carousel-search/index.vue b/uni-app/src/app/components/diy/carousel-search/index.vue index 0320e10c0..c69e9fd03 100644 --- a/uni-app/src/app/components/diy/carousel-search/index.vue +++ b/uni-app/src/app/components/diy/carousel-search/index.vue @@ -7,7 +7,7 @@ - + @@ -21,7 +21,35 @@ - + + + + + + {{diyComponent.search.subTitle.text}} + + + + + {{systemStore.currShippingAddress.city}} + + + {{systemStore.currShippingAddress.community}} + + {{ systemStore.defaultPositionAddress }} + + + {{isShowSearchPlaceholder ? diyComponent.search.text : ''}} + + + + {{ item.text }} + + + + + + @@ -35,18 +63,18 @@ - + - + - + - + 全部分类 @@ -113,8 +141,11 @@ import { ref, reactive, computed, watch, onMounted, nextTick, getCurrentInstance } from 'vue'; import { img } from '@/utils/common'; import useDiyStore from '@/app/stores/diy'; - import diyGroup from '@/addon/components/diy/group/index.vue' + import diyGroup from '@/addon/components/diy/group/index.vue'; import { getDiyInfo } from '@/app/api/diy'; + import {useLocation} from '@/hooks/useLocation' + import useSystemStore from '@/stores/system'; + const systemStore = useSystemStore(); const instance = getCurrentInstance(); const props = defineProps(['component', 'index', 'pullDownRefreshCount', 'global', 'scrollBool']); @@ -126,7 +157,18 @@ return props.component; } }) - + + /************** 定位-start ****************/ + let isOpenLocation = false; + if(diyComponent.value && diyComponent.value.search.style == 'style-2' && diyStore.mode != 'decorate') { + isOpenLocation = true; + } + + const locationVal = useLocation(isOpenLocation); + locationVal.onLoad(); + locationVal.initFn(); + /************** 定位-end ****************/ + const warpCss = computed(() => { var style = ''; if(diyComponent.value.componentStartBgColor) { @@ -140,6 +182,7 @@ return style; }) + watch( () => props.pullDownRefreshCount, (newValue, oldValue) => { @@ -160,7 +203,7 @@ moduleHeight.value = ''; } }) - }) + }) } const fixedStyleBg = ref(false); @@ -170,25 +213,25 @@ style += 'position: absolute;z-index: 10;left: 0;right: 0;'; } if (diyStore.mode == 'decorate') return style; - + // #ifdef H5 if(props.global.topStatusBar.isShow && props.global.topStatusBar.style == 'style-4') { style += 'top:' + diyStore.topTabarHeight + 'px;'; } // #endif - + if(diyComponent.value.positionWay == 'fixed') { if (props.scrollBool != undefined && props.scrollBool != -1) { style += 'position: fixed;z-index: 10;left: 0;right: 0;'; } - + // #ifdef MP-WEIXIN || MP-BAIDU || MP-TOUTIAO || MP-QQ menuButtonInfo = uni.getMenuButtonBoundingClientRect(); if(props.global.topStatusBar.isShow) { style += 'top:' + diyStore.topTabarHeight + 'px;'; } // #endif - + fixedStyleBg.value = false; if (props.scrollBool == 1) { let str = diyComponent.value.fixedBgColor || ""; @@ -204,7 +247,7 @@ } return style; }) - + // 轮播样式 const carouselSwiperStyle = ()=> { let style = ""; @@ -285,6 +328,14 @@ return style; }) + const searchSubTitleCss = computed(() => { + var style = ''; + if (diyComponent.value.search.subTitle.textColor) style += 'color:' + diyComponent.value.search.subTitle.textColor + ';'; + if (diyComponent.value.search.subTitle.startColor && diyComponent.value.search.subTitle.endColor) style += `background:linear-gradient(${diyComponent.value.search.subTitle.startColor}, ${diyComponent.value.search.subTitle.endColor});`; + else style += 'background-color:' + (diyComponent.value.search.subTitle.startColor || diyComponent.value.search.subTitle.endColor) + ';'; + return style; + }) + const currTabIndex = ref(-1) const currentSource = ref('') @@ -347,15 +398,16 @@ }else if(props.global.topStatusBar){ navbarInnerStyle.value = '' } - + } // #endif - }); - + const refresh = ()=> { setModuleLocation(); - + // 刷新定位 + locationVal.refreshLocationFn(); + changeData({ source : 'home' },-1) diyComponent.value.swiper.list.forEach((item : any) => { if (item.imageUrl == '') { @@ -368,9 +420,9 @@ const diyPageData = reactive({ pageMode: 'diy', title: '', - global: {}, + global: {}, value: [] - }) + }); const getDiyInfoFn = (id:any) => { if(!id){ @@ -416,17 +468,17 @@ } }); } - + // 轮播指示器 let isShowDots = ref(true) // #ifdef H5 isShowDots.value = true; // #endif - + // #ifdef MP-WEIXIN isShowDots.value = false; // #endif - + /******************************* 存储滚动值-start ***********************/ // 键名和组件名一致即可 let componentsScrollVal = uni.getStorageSync('componentsScrollValGroup') @@ -439,8 +491,7 @@ } uni.setStorageSync('componentsScrollValGroup', obj); } - /******************************* 存储滚动值-end ***********************/ - + /******************************* 存储滚动值-end ***********************/ \ No newline at end of file + diff --git a/uni-app/src/app/components/diy/graphic-nav/index.vue b/uni-app/src/app/components/diy/graphic-nav/index.vue index f159f3055..7a4769dc3 100644 --- a/uni-app/src/app/components/diy/graphic-nav/index.vue +++ b/uni-app/src/app/components/diy/graphic-nav/index.vue @@ -33,55 +33,63 @@ - - - - - - - + - - -