This commit is contained in:
全栈小学生 2024-11-16 14:36:04 +08:00
parent 7088f5add1
commit 2dce1fe5a7
22 changed files with 580 additions and 385 deletions

View File

@ -121,7 +121,20 @@
if (memberInfo && memberInfo.wx_openid) { if (memberInfo && memberInfo.wx_openid) {
uni.setStorageSync('openid', memberInfo.wx_openid) uni.setStorageSync('openid', memberInfo.wx_openid)
} else { } 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 // #endif
@ -163,7 +176,17 @@
if (uni.getStorageSync('autoLoginLock') && !uni.getStorageSync('wechat_login_back')) return; if (uni.getStorageSync('autoLoginLock') && !uni.getStorageSync('wechat_login_back')) return;
if (loginConfig.is_auth_register || uni.getStorageSync('wechat_login_back')) { if (loginConfig.is_auth_register || uni.getStorageSync('wechat_login_back')) {
uni.removeStorageSync('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 // #endif
@ -173,6 +196,7 @@
}) })
onShow(() => { onShow(() => {
}) })
onHide(() => { onHide(() => {

View File

@ -4,6 +4,9 @@ import request from '@/utils/request'
* *
*/ */
export function usernameLogin(data : AnyObject) { export function usernameLogin(data : AnyObject) {
if(uni.getStorageSync('pid')){
data.pid = uni.getStorageSync('pid');
}
return request.get('login', data, { showErrorMessage: true }) return request.get('login', data, { showErrorMessage: true })
} }
@ -11,6 +14,9 @@ export function usernameLogin(data : AnyObject) {
* *
*/ */
export function mobileLogin(data : AnyObject) { export function mobileLogin(data : AnyObject) {
if(uni.getStorageSync('pid')){
data.pid = uni.getStorageSync('pid');
}
return request.post('login/mobile', data, { showErrorMessage: true }) return request.post('login/mobile', data, { showErrorMessage: true })
} }

View File

@ -47,6 +47,9 @@ export function modifyMember(data : AnyObject) {
* *
*/ */
export function bindMobile(data : AnyObject) { export function bindMobile(data : AnyObject) {
if(uni.getStorageSync('pid')){
data.pid = uni.getStorageSync('pid');
}
return request.put('member/mobile', data, { showErrorMessage: true }) return request.put('member/mobile', data, { showErrorMessage: true })
} }

View File

@ -116,13 +116,6 @@ export function getAddressByLatlng(params: Record<string, any>) {
return request.get(`area/address_by_latlng`, params, { showErrorMessage: true }) return request.get(`area/address_by_latlng`, params, { showErrorMessage: true })
} }
/**
*
*/
export function getWapIndexList(data: AnyObject) {
return request.get('wap_index', data)
}
/** /**
* *
* @returns * @returns

View File

@ -7,7 +7,7 @@
<view class="bg-img-box" :style="bgImgBoxStyle"></view> <view class="bg-img-box" :style="bgImgBoxStyle"></view>
</view> </view>
<view class="fixed-wrap" :style="fixedStyle"> <view class="fixed-wrap" :style="fixedStyle">
<view class="diy-search-wrap relative z-10" @click="diyStore.toRedirect(diyComponent.search.link)" :style="navbarInnerStyle"> <view v-if="diyComponent.search.style == 'style-1'" class="diy-search-wrap relative z-10" @click="diyStore.toRedirect(diyComponent.search.link)" :style="navbarInnerStyle">
<view class="img-wrap" v-if="diyComponent.search.logo"> <view class="img-wrap" v-if="diyComponent.search.logo">
<image :src="img(diyComponent.search.logo)" mode="aspectFit"/> <image :src="img(diyComponent.search.logo)" mode="aspectFit"/>
</view> </view>
@ -21,7 +21,35 @@
</swiper> </swiper>
</view> </view>
</view> </view>
<view v-if="diyComponent.search.style == 'style-2'" class="diy-search-wrap style-2 relative z-10" @click="diyStore.toRedirect(diyComponent.search.link)" >
<view class="flex items-center" :style="navbarInnerStyle">
<view class="img-wrap" v-if="diyComponent.search.logo">
<image :src="img(diyComponent.search.logo)" mode="aspectFit"/>
</view>
<view :style="searchSubTitleCss" class="text-[24rpx] h-[38rpx] flex items-center px-[12rpx] rounded-r-[20rpx] rounded-t-[20rpx] rounded-bl-[2rpx]">{{diyComponent.search.subTitle.text}}</view>
</view>
<view class="flex items-center w-full mt-[16rpx]">
<view @click.stop="locationVal.repositionFn()" v-if="systemStore.currShippingAddress" :style="{color: diyComponent.search.positionColor}" class="mr-[30rpx]">
<view class="flex items-baseline font-500">
<text class="text-[24rpx] mr-[2rpx]">{{systemStore.currShippingAddress.city}}</text>
<text class="iconfont iconxiaV6xx !text-[24rpx]"></text>
</view>
<view class="text-[18rpx] mt-[10rpx] truncate max-w-[160rpx]" v-if="systemStore.currShippingAddress.community">{{systemStore.currShippingAddress.community}}</view>
</view>
<view @click.stop="locationVal.repositionFn()" class="text-[24rpx] mr-[30rpx] truncate max-w-[160rpx]" :style="{color: diyComponent.search.positionColor}" v-else>{{ systemStore.defaultPositionAddress }}</view>
<view class="search-content" :style="{backgroundColor: diyComponent.search.bgColor }" @click.stop="diyStore.toRedirect(diyComponent.search.link)">
<text class="input-content text-[#fff] text-[24rpx] leading-[68rpx]" :style="{color: diyComponent.search.color }">{{isShowSearchPlaceholder ? diyComponent.search.text : ''}}</text>
<text class="nc-iconfont nc-icon-sousuo-duanV6xx1 w-[80rpx] h-[52rpx] flex items-center justify-center rounded-[50rpx] text-[28rpx] text-[#fff]" :style="{backgroundColor: diyComponent.search.btnBgColor, color: diyComponent.search.btnColor }"></text>
<swiper class="swiper-wrap" :interval="diyComponent.search.hotWord.interval * 1000" autoplay="true" vertical="true" circular="true" v-if="!isShowSearchPlaceholder">
<swiper-item class="swiper-item" v-for="(item) in diyComponent.search.hotWord.list" :key="item.id">
<view class="leading-[64rpx] text-[24rpx]" :style="{color: diyComponent.search.color }">{{ item.text }}</view>
</swiper-item>
</swiper>
</view>
</view>
</view>
<view class="tab-list-wrap relative z-10" v-if="diyComponent.tab.control"> <view class="tab-list-wrap relative z-10" v-if="diyComponent.tab.control">
<scroll-view scroll-x="true" class="scroll-wrap" :scroll-into-view="'a' + currTabIndex"> <scroll-view scroll-x="true" class="scroll-wrap" :scroll-into-view="'a' + currTabIndex">
<view @click="changeData({ source : 'home' },-1)" class="scroll-item" :class="[{ active: currTabIndex == -1 }]"> <view @click="changeData({ source : 'home' },-1)" class="scroll-item" :class="[{ active: currTabIndex == -1 }]">
@ -35,18 +63,18 @@
</scroll-view> </scroll-view>
<view v-if="diyComponent.tab.list.length" class="absolute tab-btn iconfont icona-yingyongliebiaoV6xx-32" @click="tabAllPopup = true"></view> <view v-if="diyComponent.tab.list.length" class="absolute tab-btn iconfont icona-yingyongliebiaoV6xx-32" @click="tabAllPopup = true"></view>
</view> </view>
<view class="bg-img" v-if="fixedStyleBg"> <view class="bg-img" v-if="fixedStyleBg">
<image v-if="diyComponent.swiper.control && diyComponent.swiper.list && diyComponent.swiper.list[swiperIndex].imageUrl" :src="img(diyComponent.swiper.list[swiperIndex].imageUrl)" mode="widthFix" class="w-full h-full" :show-menu-by-longpress="true"/> <image v-if="diyComponent.swiper.control && diyComponent.swiper.list && diyComponent.swiper.list[swiperIndex].imageUrl" :src="img(diyComponent.swiper.list[swiperIndex].imageUrl)" mode="widthFix" class="w-full h-full" :show-menu-by-longpress="true"/>
<view v-else class="w-full h-full bg-[#fff]"></view> <view v-else class="w-full h-full bg-[#fff]"></view>
</view> </view>
</view> </view>
<!-- 解决fixed定位后导航栏塌陷的问题 --> <!-- 解决fixed定位后导航栏塌陷的问题 -->
<template v-if="diyStore.mode != 'decorate'"> <template v-if="diyStore.mode != 'decorate'">
<view v-if="diyComponent.positionWay == 'fixed' && props.scrollBool != undefined && props.scrollBool != -1" class="u-navbar-placeholder" :style="{ width: '100%', paddingTop: moduleHeight }"></view> <view v-if="diyComponent.positionWay == 'fixed' && props.scrollBool != undefined && props.scrollBool != -1" class="u-navbar-placeholder" :style="{ width: '100%', paddingTop: moduleHeight }"></view>
</template> </template>
<!-- 轮播图 --> <!-- 轮播图 -->
<view class="relative" :class="{'mx-[20rpx]': swiperStyleBool && diyComponent.swiper.swiperStyle != 'style-3', 'swiper-style-3': diyComponent.swiper.swiperStyle == 'style-3'}" :style="carouselSwiperStyle()"> <view class="relative" :class="{'mx-[20rpx]': swiperStyleBool && diyComponent.swiper.swiperStyle != 'style-3', 'swiper-style-3': diyComponent.swiper.swiperStyle == 'style-3'}" :style="carouselSwiperStyle()">
<swiper v-if="diyComponent.swiper.control" class="swiper" :style="{ height: imgHeight }" autoplay="true" circular="true" @change="swiperChange" <swiper v-if="diyComponent.swiper.control" class="swiper" :style="{ height: imgHeight }" autoplay="true" circular="true" @change="swiperChange"
@ -80,7 +108,7 @@
</view> </view>
<!-- #endif --> <!-- #endif -->
</view> </view>
<!-- 分类展开 --> <!-- 分类展开 -->
<u-popup :safeAreaInsetTop="true" :show="tabAllPopup" mode="top" @close="tabAllPopup = false"> <u-popup :safeAreaInsetTop="true" :show="tabAllPopup" mode="top" @close="tabAllPopup = false">
<view class="text-sm px-[30rpx] pt-3" :style="{'padding-top':(menuButtonInfo.top+'px')}">全部分类</view> <view class="text-sm px-[30rpx] pt-3" :style="{'padding-top':(menuButtonInfo.top+'px')}">全部分类</view>
@ -113,8 +141,11 @@
import { ref, reactive, computed, watch, onMounted, nextTick, getCurrentInstance } from 'vue'; import { ref, reactive, computed, watch, onMounted, nextTick, getCurrentInstance } from 'vue';
import { img } from '@/utils/common'; import { img } from '@/utils/common';
import useDiyStore from '@/app/stores/diy'; 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 { getDiyInfo } from '@/app/api/diy';
import {useLocation} from '@/hooks/useLocation'
import useSystemStore from '@/stores/system';
const systemStore = useSystemStore();
const instance = getCurrentInstance(); const instance = getCurrentInstance();
const props = defineProps(['component', 'index', 'pullDownRefreshCount', 'global', 'scrollBool']); const props = defineProps(['component', 'index', 'pullDownRefreshCount', 'global', 'scrollBool']);
@ -126,7 +157,18 @@
return props.component; 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(() => { const warpCss = computed(() => {
var style = ''; var style = '';
if(diyComponent.value.componentStartBgColor) { if(diyComponent.value.componentStartBgColor) {
@ -140,6 +182,7 @@
return style; return style;
}) })
watch( watch(
() => props.pullDownRefreshCount, () => props.pullDownRefreshCount,
(newValue, oldValue) => { (newValue, oldValue) => {
@ -160,7 +203,7 @@
moduleHeight.value = ''; moduleHeight.value = '';
} }
}) })
}) })
} }
const fixedStyleBg = ref(false); const fixedStyleBg = ref(false);
@ -170,25 +213,25 @@
style += 'position: absolute;z-index: 10;left: 0;right: 0;'; style += 'position: absolute;z-index: 10;left: 0;right: 0;';
} }
if (diyStore.mode == 'decorate') return style; if (diyStore.mode == 'decorate') return style;
// #ifdef H5 // #ifdef H5
if(props.global.topStatusBar.isShow && props.global.topStatusBar.style == 'style-4') { if(props.global.topStatusBar.isShow && props.global.topStatusBar.style == 'style-4') {
style += 'top:' + diyStore.topTabarHeight + 'px;'; style += 'top:' + diyStore.topTabarHeight + 'px;';
} }
// #endif // #endif
if(diyComponent.value.positionWay == 'fixed') { if(diyComponent.value.positionWay == 'fixed') {
if (props.scrollBool != undefined && props.scrollBool != -1) { if (props.scrollBool != undefined && props.scrollBool != -1) {
style += 'position: fixed;z-index: 10;left: 0;right: 0;'; style += 'position: fixed;z-index: 10;left: 0;right: 0;';
} }
// #ifdef MP-WEIXIN || MP-BAIDU || MP-TOUTIAO || MP-QQ // #ifdef MP-WEIXIN || MP-BAIDU || MP-TOUTIAO || MP-QQ
menuButtonInfo = uni.getMenuButtonBoundingClientRect(); menuButtonInfo = uni.getMenuButtonBoundingClientRect();
if(props.global.topStatusBar.isShow) { if(props.global.topStatusBar.isShow) {
style += 'top:' + diyStore.topTabarHeight + 'px;'; style += 'top:' + diyStore.topTabarHeight + 'px;';
} }
// #endif // #endif
fixedStyleBg.value = false; fixedStyleBg.value = false;
if (props.scrollBool == 1) { if (props.scrollBool == 1) {
let str = diyComponent.value.fixedBgColor || ""; let str = diyComponent.value.fixedBgColor || "";
@ -204,7 +247,7 @@
} }
return style; return style;
}) })
// //
const carouselSwiperStyle = ()=> { const carouselSwiperStyle = ()=> {
let style = ""; let style = "";
@ -285,6 +328,14 @@
return style; 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 currTabIndex = ref(-1)
const currentSource = ref('') const currentSource = ref('')
@ -347,15 +398,16 @@
}else if(props.global.topStatusBar){ }else if(props.global.topStatusBar){
navbarInnerStyle.value = '' navbarInnerStyle.value = ''
} }
} }
// #endif // #endif
}); });
const refresh = ()=> { const refresh = ()=> {
setModuleLocation(); setModuleLocation();
//
locationVal.refreshLocationFn();
changeData({ source : 'home' },-1) changeData({ source : 'home' },-1)
diyComponent.value.swiper.list.forEach((item : any) => { diyComponent.value.swiper.list.forEach((item : any) => {
if (item.imageUrl == '') { if (item.imageUrl == '') {
@ -368,9 +420,9 @@
const diyPageData = reactive({ const diyPageData = reactive({
pageMode: 'diy', pageMode: 'diy',
title: '', title: '',
global: <any>{}, global: {},
value: [] value: []
}) });
const getDiyInfoFn = (id:any) => { const getDiyInfoFn = (id:any) => {
if(!id){ if(!id){
@ -416,17 +468,17 @@
} }
}); });
} }
// //
let isShowDots = ref(true) let isShowDots = ref(true)
// #ifdef H5 // #ifdef H5
isShowDots.value = true; isShowDots.value = true;
// #endif // #endif
// #ifdef MP-WEIXIN // #ifdef MP-WEIXIN
isShowDots.value = false; isShowDots.value = false;
// #endif // #endif
/******************************* 存储滚动值-start ***********************/ /******************************* 存储滚动值-start ***********************/
// //
let componentsScrollVal = uni.getStorageSync('componentsScrollValGroup') let componentsScrollVal = uni.getStorageSync('componentsScrollValGroup')
@ -439,8 +491,7 @@
} }
uni.setStorageSync('componentsScrollValGroup', obj); uni.setStorageSync('componentsScrollValGroup', obj);
} }
/******************************* 存储滚动值-end ***********************/ /******************************* 存储滚动值-end ***********************/
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
@ -469,7 +520,7 @@
} }
} }
} }
.fixed-wrap { .fixed-wrap {
&.fixed { &.fixed {
position: fixed; position: fixed;
@ -533,6 +584,13 @@
} }
} }
&.style-2{
flex-direction: column;
align-items: baseline;
.img-wrap{
margin-right: 10rpx;
}
}
} }
.tab-list-wrap { .tab-list-wrap {
@ -558,7 +616,7 @@
color: #333; color: #333;
line-height: 32rpx; line-height: 32rpx;
} }
&.active { &.active {
position: relative; position: relative;
.name { .name {
@ -569,7 +627,7 @@
} }
.tab-btn{ .tab-btn{
font-size: 34rpx; font-size: 34rpx;
/* #ifdef H5 */ /* #ifdef H5 */
top: 22rpx; top: 22rpx;
right: 20rpx; right: 20rpx;
line-height: 1; line-height: 1;
@ -626,7 +684,7 @@
width: 12rpx; width: 12rpx;
height: 12rpx; height: 12rpx;
} }
// //
.swiper.ns-indicator-dots :deep(.uni-swiper-dot) { .swiper.ns-indicator-dots :deep(.uni-swiper-dot) {
width: 18rpx; width: 18rpx;
@ -636,7 +694,7 @@
.swiper.ns-indicator-dots :deep(.uni-swiper-dot-active) { .swiper.ns-indicator-dots :deep(.uni-swiper-dot-active) {
width: 36rpx; width: 36rpx;
} }
// //
.swiper.ns-indicator-dots-three :deep(.uni-swiper-dot) { .swiper.ns-indicator-dots-three :deep(.uni-swiper-dot) {
width: 8rpx; width: 8rpx;
@ -650,7 +708,7 @@
.swiper.ns-indicator-dots-three :deep(.uni-swiper-dot-active) { .swiper.ns-indicator-dots-three :deep(.uni-swiper-dot-active) {
width: 30rpx; width: 30rpx;
} }
.swiper-dot-box { .swiper-dot-box {
position: absolute; position: absolute;
bottom: 20rpx; bottom: 20rpx;
@ -660,15 +718,15 @@
justify-content: center; justify-content: center;
padding: 0 80rpx 8rpx; padding: 0 80rpx 8rpx;
box-sizing: border-box; box-sizing: border-box;
&.swiper-left { &.swiper-left {
justify-content: flex-start; justify-content: flex-start;
} }
&.swiper-right { &.swiper-right {
justify-content: flex-end; justify-content: flex-end;
} }
.swiper-dot { .swiper-dot {
background-color: #b2b2b2; background-color: #b2b2b2;
width: 12rpx; width: 12rpx;
@ -676,13 +734,13 @@
height: 12rpx; height: 12rpx;
margin: 8rpx; margin: 8rpx;
} }
&.straightLine { &.straightLine {
.swiper-dot { .swiper-dot {
width: 18rpx; width: 18rpx;
height: 6rpx; height: 6rpx;
border-radius: 6rpx; border-radius: 6rpx;
&.active { &.active {
width: 36rpx; width: 36rpx;
} }
@ -704,7 +762,7 @@
} }
} }
} }
.swiper-style-3{ .swiper-style-3{
:deep(.uni-swiper-dots-horizontal){ :deep(.uni-swiper-dots-horizontal){
bottom: 46rpx !important; bottom: 46rpx !important;
@ -713,4 +771,4 @@
bottom: 38rpx !important; bottom: 38rpx !important;
} }
} }
</style> </style>

View File

@ -33,55 +33,63 @@
</view> </view>
</view> </view>
<swiper v-else-if="diyComponent.layout == 'horizontal' && diyComponent.showStyle == 'pageSlide'"
class="graphic-nav box-border relative" circular :indicator-dots="false"
:style="{ height: swiperHeight }" @change="swiperChange">
<swiper-item class="graphic-nav-wrap flex flex-wrap" v-for="(numItem, numIndex) in Math.ceil(diyComponent.list.length / (diyComponent.pageCount * diyComponent.rowCount))">
<template v-for="(item, index) in diyComponent.list"> <view class="pt-[10rpx]" v-else-if="diyComponent.layout == 'horizontal' && diyComponent.showStyle == 'pageSlide'">
<swiper class="graphic-nav swiper relative" :style="{ height: swiperHeight, width: '95%', margin: '0 auto',opacity : swiperHeight ? 1 : 0 }" circular @change="swiperChange">
<swiper-item class="graphic-nav-wrap flex flex-wrap" v-for="(numItem, numIndex) in Math.ceil(diyComponent.list.length / (diyComponent.pageCount * diyComponent.rowCount))">
<view :class="[diyComponent.mode]" :key="item.id" v-if="swiperCondition(index,numItem)" :style="{ width: 100 / diyComponent.rowCount + '%' }"> <template v-for="(item, index) in diyComponent.list">
<view @click="diyStore.toRedirect(item.link)" class="graphic-nav-item flex flex-col items-center box-border py-2"> <view :class="[diyComponent.mode]" :key="item.id" v-if="swiperCondition(index,numItem)" :style="{ width: 100 / diyComponent.rowCount + '%' }">
<view class="graphic-img relative flex items-center justify-center w-10 h-10" <view @click="diyStore.toRedirect(item.link)" class="graphic-nav-item flex flex-col items-center py-2">
v-if="diyComponent.mode != 'text'"
:style="{ width: diyComponent.imageSize * 2 + 'rpx', height: diyComponent.imageSize * 2 + 'rpx' }">
<image v-if="item.imageUrl" :src="img(item.imageUrl)" mode="aspectFill"
:style="{ maxWidth: diyComponent.imageSize * 2 + 'rpx', maxHeight: diyComponent.imageSize * 2 + 'rpx', borderRadius: diyComponent.aroundRadius * 2 + 'rpx' }"/>
<image v-else :src="img('static/resource/images/diy/figure.png')" mode="aspectFill"
:style="{ maxWidth: diyComponent.imageSize * 2 + 'rpx', maxHeight: diyComponent.imageSize * 2 + 'rpx', borderRadius: diyComponent.aroundRadius * 2 + 'rpx' }"/>
<text <view class="graphic-img relative flex items-center justify-center w-10 h-10"
class="tag absolute -top-[10rpx] -right-[24rpx] text-white rounded-[24rpx] rounded-bl-none transform scale-80 py-1 px-2 text-xs" v-if="diyComponent.mode != 'text'"
v-if="item.label.control" :style="{ width: diyComponent.imageSize * 2 + 'rpx', height: diyComponent.imageSize * 2 + 'rpx' }">
:style="{ color: item.label.textColor, backgroundImage: 'linear-gradient(' + item.label.bgColorStart + ',' + item.label.bgColorEnd + ')' }"> <image v-if="item.imageUrl" :src="img(item.imageUrl)" mode="aspectFill"
{{ item.label.text }} :style="{ maxWidth: diyComponent.imageSize * 2 + 'rpx', maxHeight: diyComponent.imageSize * 2 + 'rpx', borderRadius: diyComponent.aroundRadius * 2 + 'rpx' }"/>
<image v-else :src="img('static/resource/images/diy/figure.png')" mode="aspectFill"
:style="{ maxWidth: diyComponent.imageSize * 2 + 'rpx', maxHeight: diyComponent.imageSize * 2 + 'rpx', borderRadius: diyComponent.aroundRadius * 2 + 'rpx' }"/>
<text
class="tag absolute -top-[10rpx] -right-[24rpx] text-white rounded-[24rpx] rounded-bl-none transform scale-80 py-1 px-2 text-xs"
v-if="item.label.control"
:style="{ color: item.label.textColor, backgroundImage: 'linear-gradient(' + item.label.bgColorStart + ',' + item.label.bgColorEnd + ')' }">
{{ item.label.text }}
</text>
</view>
<text v-if="diyComponent.mode != 'img'"
class="graphic-text w-full text-center truncate leading-normal"
:class="{ 'pt-[16rpx]' : diyComponent.mode != 'text' }"
:style="{ fontSize: diyComponent.font.size * 2 + 'rpx', fontWeight: diyComponent.font.weight, color: diyComponent.font.color }">
{{ item.title }}
</text> </text>
</view> </view>
<text v-if="diyComponent.mode != 'img'"
class="graphic-text w-full text-center truncate leading-normal"
:class="{ 'pt-[16rpx]' : diyComponent.mode != 'text' }"
:style="{ fontSize: diyComponent.font.size * 2 + 'rpx', fontWeight: diyComponent.font.weight, color: diyComponent.font.color }">
{{ item.title }}
</text>
</view> </view>
</template>
</swiper-item>
</swiper>
<view class="graphic-nav-indicator-dot" v-if="shouldShowIndicator && swiperHeight">
<div class="dots-wrap" :class="[diyComponent.swiper.indicatorAlign]">
<div v-for="(item,index) in Math.ceil(diyComponent.list.length / (diyComponent.pageCount * diyComponent.rowCount))"
:class="['dot',index == swiperIndex ? 'dot-active' : '',diyComponent.swiper.indicatorStyle]"
:style="{ background : index == swiperIndex ? diyComponent.swiper.indicatorActiveColor : diyComponent.swiper.indicatorColor}"></div>
</div>
</view>
</view>
</view> <view :style="{width: '98%', margin: '0 auto' }" v-else-if="diyComponent.layout == 'horizontal' && diyComponent.pageCount == 2 && diyComponent.showStyle == 'singleSlide'" :class="['graphic-nav','graphic-nav-' + diyComponent.showStyle]" class="py-[10rpx]">
</template>
</swiper-item>
</swiper>
<scroll-view v-else-if="diyComponent.layout == 'horizontal' && diyComponent.pageCount == 2 && diyComponent.showStyle == 'singleSlide'" :scroll-x="diyComponent.showStyle == 'singleSlide'" :class="['graphic-nav','graphic-nav-' + diyComponent.showStyle]" class="py-[10rpx]">
<!-- #ifdef MP --> <!-- #ifdef MP -->
<view class="uni-scroll-view-content"> <view class="uni-scroll-view-content">
<!-- #endif --> <!-- #endif -->
<view :style="horizontalSingleSlideStyle" class="flex"> <view :style="horizontalSingleSlideStyle" >
<view class="graphic-nav-wrap flex flex-wrap" :style="horizontalSingleSlideBoxStyle(numIndex)" v-for="(numItem, numIndex) in Math.ceil(diyComponent.list.length / (diyComponent.pageCount * diyComponent.rowCount))"> <scroll-view class="graphic-nav-wrap flex " :scroll-x="diyComponent.showStyle == 'singleSlide'" :style="horizontalSingleSlideBoxStyle(numIndex)" v-for="(numItem, numIndex) in Math.ceil(diyComponent.list.length / (diyComponent.pageCount * diyComponent.rowCount))">
<template v-for="(item, index) in diyComponent.list"> <template v-for="(item, index) in diyComponent.list" >
<view v-if="swiperCondition(index,numItem)" @click="diyStore.toRedirect(item.link)" :style="horizontalSingleSlideItemStyle(numIndex)" class="graphic-nav-item flex flex-col items-center box-border py-2"> <view v-if="swiperCondition(index,numItem)" @click="diyStore.toRedirect(item.link)" :style="horizontalSingleSlideItemStyle(numIndex)" class="graphic-nav-item flex flex-col items-center box-border py-2 px-[25rpx]">
<view class="graphic-img relative flex items-center justify-center w-10 h-10" <view class="graphic-img relative flex items-center justify-center w-10 h-10"
v-if="diyComponent.mode != 'text'" v-if="diyComponent.mode != 'text'"
:style="{ width: diyComponent.imageSize * 2 + 'rpx', height: diyComponent.imageSize * 2 + 'rpx' }"> :style="{ width: diyComponent.imageSize * 2 + 'rpx', height: diyComponent.imageSize * 2 + 'rpx' }">
@ -104,13 +112,13 @@
</text> </text>
</view> </view>
</template> </template>
</view> </scroll-view>
</view> </view>
<!-- #ifdef MP --> <!-- #ifdef MP -->
</view> </view>
<!-- #endif --> <!-- #endif -->
</scroll-view> </view>
<scroll-view v-else :scroll-x="diyComponent.showStyle == 'singleSlide'" :class="['graphic-nav','graphic-nav-' + diyComponent.showStyle]" class=" py-[10rpx]"> <scroll-view v-else :scroll-x="diyComponent.showStyle == 'singleSlide'" :class="['graphic-nav','graphic-nav-' + diyComponent.showStyle]" class=" py-[10rpx]">
<!-- #ifdef MP --> <!-- #ifdef MP -->
@ -172,7 +180,11 @@
return props.component; return props.component;
} }
}) })
const shouldShowIndicator = computed(() => {
const totalItems = diyComponent.value.list.length //
const itemsPerPage = diyComponent.value.pageCount * diyComponent.value.rowCount //
return totalItems > itemsPerPage //
})
const warpCss = computed(() => { const warpCss = computed(() => {
var style = ''; var style = '';
style += 'position:relative;'; style += 'position:relative;';
@ -209,7 +221,7 @@
return style; return style;
}); });
// //
const horizontalSingleSlideStyle = computed(()=>{ const horizontalSingleSlideStyle = computed(()=>{
let style = {width: ""}; let style = {width: ""};
@ -219,7 +231,7 @@
style.width = `calc(${widthStr * itemLen}vw - ${marginLen}rpx)`; style.width = `calc(${widthStr * itemLen}vw - ${marginLen}rpx)`;
return style; return style;
}) })
const horizontalSingleSlideBoxStyle = (index: any)=>{ const horizontalSingleSlideBoxStyle = (index: any)=>{
let style = {width: ""}; let style = {width: ""};
let widthStr = 100 / diyComponent.value.rowCount; // let widthStr = 100 / diyComponent.value.rowCount; //
@ -268,27 +280,29 @@
const swiperCondition = (index, numItem) => { const swiperCondition = (index, numItem) => {
let count = diyComponent.value.pageCount * diyComponent.value.rowCount; let count = diyComponent.value.pageCount * diyComponent.value.rowCount;
let result = true; let result = true;
result = index >= [(numItem - 1) * (count)] && index < [numItem * (count)]; result = index >= [(numItem - 1) * (count)] && index < [numItem * (count)];
return result; return result;
} }
const swiperHeight = ref(''); const storageKey = 'graphic_nav_horizontal_page_slide_swiperheight_' + props.index + '_' + diyComponent.value.list.length;
const swiperHeight = ref(uni.getStorageSync(storageKey) || '');
const handleData = () => { const handleData = () => {
if(diyComponent.value.layout == 'horizontal' && diyComponent.value.showStyle == 'pageSlide') { if (diyComponent.value.layout == 'horizontal' && diyComponent.value.showStyle == 'pageSlide') {
var height = 0; var height = 0;
const query = uni.createSelectorQuery().in(instance); const query = uni.createSelectorQuery().in(instance);
query.select('.graphic-nav-item').boundingClientRect((data: any) => { query.select('.graphic-nav-item').boundingClientRect((data: any) => {
let len = 1; let len = 1;
if(diyComponent.value.pageCount == 2){ if (diyComponent.value.pageCount == 2) {
len = (diyComponent.value.list.length / diyComponent.value.rowCount) > 1 ? 2 : 1 ; len = (diyComponent.value.list.length / diyComponent.value.rowCount) > 1 ? 2 : 1;
} }
height = data.height * len; height = data.height * len;
swiperHeight.value = (height * 2) + 'rpx'; swiperHeight.value = height + 'px';
}).exec(); uni.setStorageSync(storageKey, swiperHeight.value);
} }).exec();
}
}; };
onMounted(() => { onMounted(() => {
@ -333,4 +347,63 @@
} }
</style> </style>
<style lang="scss" scoped> <style lang="scss" scoped>
.graphic-nav-indicator-dot{
width: 95%;
margin: auto;
.dots-wrap{
white-space: nowrap;
display: flex;
align-items: center;
justify-content: center;
&.left{
justify-content: left;
padding-left: 30rpx;
}
&.right {
justify-content: right;
padding-right: 30rpx;
}
.dot{
display: inline-block;
width: 12rpx;
height: 12rpx;
cursor: pointer;
transition-property: background-color;
transition-timing-function: ease;
background: rgba(0, 0, 0, 0.3);
border-radius: 50%;
margin-right: 16rpx;
&:last-child {
margin-right: 0;
}
//
&.style-2 {
width: 18rpx;
height: 6rpx;
border-radius: 4rpx;
}
&dot-active.style-2 {
width: 36rpx;
}
//
&.style-3{
width: 10rpx;
height: 10rpx !important;
border-radius: 12rpx;
margin-right: 14rpx;
&:last-of-type{
margin-right: 0;
}
}
&.dot-active.style-3{
width: 32rpx;
}
}
}
}
</style> </style>

View File

@ -3,13 +3,13 @@
<view :style="maskLayer"></view> <view :style="maskLayer"></view>
<view class="diy-notice relative overflow-hidden"> <view class="diy-notice relative overflow-hidden">
<view class="flex items-center pl-[28rpx] p-[22rpx]"> <view class="flex items-center pl-[28rpx] p-[22rpx]">
<template v-if="diyComponent.noticeType == 'img'"> <view v-if="diyComponent.noticeType == 'img'" class="min-w-[60rpx] flex items-center">
<template v-if="diyComponent.imgType == 'system'"> <template v-if="diyComponent.imgType == 'system'">
<image v-if="diyComponent.systemUrl == 'style_1'" :src="img(`static/resource/images/diy/notice/${diyComponent.systemUrl}.png`)" class="h-[40rpx] max-w-[130rpx] mr-[20rpx] flex-shrink-0" mode="heightFix"/> <image v-if="diyComponent.systemUrl == 'style_1'" :src="img(`static/resource/images/diy/notice/${diyComponent.systemUrl}.png`)" class="h-[40rpx] w-[auto] mr-[20rpx] flex-shrink-0" mode="heightFix"/>
<image v-else-if="diyComponent.systemUrl == 'style_2'" :src="img(`static/resource/images/diy/notice/${diyComponent.systemUrl}.png`)" class="w-[200rpx] mr-[20rpx] h-[30rpx] flex-shrink-0" mode="heightFix" /> <image v-else-if="diyComponent.systemUrl == 'style_2'" :src="img(`static/resource/images/diy/notice/${diyComponent.systemUrl}.png`)" class="w-[200rpx] mr-[20rpx] h-[30rpx] flex-shrink-0" mode="heightFix" />
</template> </template>
<image v-else-if="diyComponent.imgType == 'diy'" :src="img(diyComponent.imageUrl || '')" class="w-[200rpx] h-[30rpx] mr-[20rpx] flex-shrink-0" mode="heightFix"/> <image v-else-if="diyComponent.imgType == 'diy'" :src="img(diyComponent.imageUrl || '')" class="w-[200rpx] h-[30rpx] mr-[20rpx] flex-shrink-0" mode="heightFix"/>
</template> </view>
<view v-if="diyComponent.noticeType == 'text' && diyComponent.noticeTitle" class="max-w-[128rpx] px-[12rpx] text-[26rpx] h-[40rpx] leading-[40rpx] text-[var(--primary-color)] bg-[var(--primary-color-light)] truncate rounded-[8rpx] mr-[20rpx] flex-shrink-0">{{ diyComponent.noticeTitle }}</view> <view v-if="diyComponent.noticeType == 'text' && diyComponent.noticeTitle" class="max-w-[128rpx] px-[12rpx] text-[26rpx] h-[40rpx] leading-[40rpx] text-[var(--primary-color)] bg-[var(--primary-color-light)] truncate rounded-[8rpx] mr-[20rpx] flex-shrink-0">{{ diyComponent.noticeTitle }}</view>
<view class="flex-1 flex overflow-hidden horizontal-body" :id="'horizontal-body-'+diyComponent.id" :class="{'items-center':diyComponent.scrollWay == 'upDown'}"> <view class="flex-1 flex overflow-hidden horizontal-body" :id="'horizontal-body-'+diyComponent.id" :class="{'items-center':diyComponent.scrollWay == 'upDown'}">
<!-- 横向滚动 --> <!-- 横向滚动 -->

View File

@ -114,8 +114,8 @@
if (option.type == 'mobile') { if (option.type == 'mobile') {
if (configStore.login.is_mobile) { if (configStore.login.is_mobile) {
type.value = option.type type.value = option.type
uni.getStorageSync('pid') && (Object.assign(formData, { pid: uni.getStorageSync('pid') }))
} }
} else if (option.type == 'username' && configStore.login.is_username) { } else if (option.type == 'username' && configStore.login.is_username) {
type.value = option.type type.value = option.type
} }

View File

@ -324,7 +324,6 @@
} }
.address-edit :deep(.u-form-item__body__right){ .address-edit :deep(.u-form-item__body__right){
display:flex; display:flex;
align-items: center;
} }
.footer{ .footer{
height: calc(100rpx + var(--top-m) + var(--top-m) + constant(safe-area-inset-bottom)) !important; height: calc(100rpx + var(--top-m) + var(--top-m) + constant(safe-area-inset-bottom)) !important;

View File

@ -17,7 +17,7 @@
<view :style="{ color: topStatusBarData.textColor }">{{ data.title }}</view> <view :style="{ color: topStatusBarData.textColor }">{{ data.title }}</view>
</view> </view>
</view> </view>
<view v-if="topStatusBarData.style == 'style-3'" :style="navbarInnerStyle" class="content-wrap"> <view v-if="topStatusBarData.style == 'style-3'" :style="navbarInnerStyle" class="content-wrap">
<view v-if="isBack && isBackShow" class="back-wrap -ml-[16rpx] text-[27px] nc-iconfont nc-icon-zuoV6xx" :style="{ color: titleTextColor }" @tap="goBack"></view> <view v-if="isBack && isBackShow" class="back-wrap -ml-[16rpx] text-[27px] nc-iconfont nc-icon-zuoV6xx" :style="{ color: titleTextColor }" @tap="goBack"></view>
<view class="title-wrap" @click="diyStore.toRedirect(topStatusBarData.link)"> <view class="title-wrap" @click="diyStore.toRedirect(topStatusBarData.link)">
@ -29,29 +29,28 @@
</view> </view>
<view :style="{ 'width': capsuleWidth }"></view> <view :style="{ 'width': capsuleWidth }"></view>
</view> </view>
<view v-if="topStatusBarData.style == 'style-4'" :style="navbarInnerStyle" class="content-wrap"> <view v-if="topStatusBarData.style == 'style-4'" :style="navbarInnerStyle" class="content-wrap">
<view v-if="isBack && isBackShow" class="back-wrap -ml-[16rpx] text-[27px] nc-iconfont nc-icon-zuoV6xx" :style="{ color: titleTextColor }" @tap="goBack"></view> <view v-if="isBack && isBackShow" class="back-wrap -ml-[16rpx] text-[27px] nc-iconfont nc-icon-zuoV6xx" :style="{ color: titleTextColor }" @tap="goBack"></view>
<text class="nc-iconfont nc-icon-dizhiguanliV6xx text-[28rpx]" :style="{ color: topStatusBarData.textColor }"></text> <text class="nc-iconfont nc-icon-dizhiguanliV6xx text-[28rpx]" :style="{ color: topStatusBarData.textColor }"></text>
<view class="title-wrap" @click="reposition()" :style="{ color: topStatusBarData.textColor }">{{ currentPosition }}</view> <view class="title-wrap" @click.stop="locationVal.repositionFn()" :style="{ color: topStatusBarData.textColor }" v-if="systemStore.currShippingAddress">{{ systemStore.currShippingAddress.community }}</view>
<text class="nc-iconfont nc-icon-youV6xx text-[26rpx]" @click="reposition()" :style="{ color: topStatusBarData.textColor }"></text> <view class="title-wrap" @click.stop="locationVal.repositionFn()" :style="{ color: topStatusBarData.textColor }" v-else>{{ systemStore.defaultPositionAddress }}</view>
<text class="nc-iconfont nc-icon-youV6xx text-[26rpx]" @click.stop="locationVal.repositionFn()" :style="{ color: topStatusBarData.textColor }"></text>
</view> </view>
</view> </view>
</view> </view>
<!-- 解决fixed定位后导航栏塌陷的问题 --> <!-- 解决fixed定位后导航栏塌陷的问题 -->
<view v-if="props.isFill" class="u-navbar-placeholder" :style="{ width: '100%', paddingTop: placeholderHeight + 'px' }"></view> <view v-if="props.isFill" class="u-navbar-placeholder" :style="{ width: '100%', paddingTop: placeholderHeight + 'px' }"></view>
</view> </view>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { ref, computed, watch, onMounted, getCurrentInstance, nextTick } from 'vue'; import { ref, computed, onMounted, getCurrentInstance, nextTick } from 'vue';
import { img, getLocation, locationStorage } from '@/utils/common'; import { img } from '@/utils/common';
import { getAddressByLatlng } from '@/app/api/system';
import useSystemStore from '@/stores/system'; import useSystemStore from '@/stores/system';
import useDiyStore from '@/app/stores/diy'; import useDiyStore from '@/app/stores/diy';
import manifestJson from '@/manifest.json' import {useLocation} from '@/hooks/useLocation'
import { cloneDeep } from 'lodash-es'
// //
let systemInfo = uni.getSystemInfoSync(); let systemInfo = uni.getSystemInfoSync();
@ -100,7 +99,7 @@ const topStatusBarData = computed(() => {
// //
const navbarInnerStyle = computed(() => { const navbarInnerStyle = computed(() => {
let style = ''; let style = '';
if(props.isBack && isBackShow.value){ if(props.isBack && isBackShow.value){
style += 'padding-left: 30rpx;';//30=> 44=> 10=>maring style += 'padding-left: 30rpx;';//30=> 44=> 10=>maring
if(topStatusBarData.value.style == 'style-1') //padding if(topStatusBarData.value.style == 'style-1') //padding
@ -122,7 +121,7 @@ const navbarInnerStyle = computed(() => {
// //
const styleOneFontSize = computed(() => { const styleOneFontSize = computed(() => {
let style = ''; let style = '';
// #ifdef H5 // #ifdef H5
style += 'font-size: 28rpx;'; style += 'font-size: 28rpx;';
// #endif // #endif
@ -164,7 +163,7 @@ const bgColor = computed(() => {
return color; return color;
}) })
/******************************* 存储滚动值-start ***********************/ /******************************* 存储滚动值-start ***********************/
// //
let componentsScrollVal = uni.getStorageSync('componentsScrollValGroup') let componentsScrollVal = uni.getStorageSync('componentsScrollValGroup')
if(componentsScrollVal){ if(componentsScrollVal){
@ -176,7 +175,7 @@ if(componentsScrollVal){
} }
uni.setStorageSync('componentsScrollValGroup', obj); uni.setStorageSync('componentsScrollValGroup', obj);
} }
/******************************* 存储滚动值-end ***********************/ /******************************* 存储滚动值-end ***********************/
/******************************* 返回按钮-start ***********************/ /******************************* 返回按钮-start ***********************/
const isBackShow = ref(false); const isBackShow = ref(false);
@ -191,7 +190,7 @@ const goBack = () => {
uni.navigateBack(); uni.navigateBack();
} }
} }
/******************************* 返回按钮-end ***********************/ /******************************* 返回按钮-end ***********************/
// +right // +right
const capsuleWidth = computed(() => { const capsuleWidth = computed(() => {
@ -216,120 +215,29 @@ const navbarPlaceholderHeight = () => {
}) })
} }
/******************************* 定位-start ***********************/ /************** 定位-start ****************/
// let isOpenLocation = false;
const currentPosition = ref('定位中...') if(topStatusBarData.value && topStatusBarData.value.style == 'style-4') {
let mapConfig = uni.getStorageSync('mapConfig'); isOpenLocation = true;
const initPosition = () =>{
// #ifdef H5
if (getQueryVariable('latng')) {
currentPosition.value = "定位中..."
let locationInfo: any = systemStore.location;
var tempArr = getQueryVariable('latng').split(',');
locationInfo.latitude = tempArr[0];
locationInfo.longitude = tempArr[1];
systemStore.setLocation(locationInfo);
} }
// #endif
currentPosition.value = '定位中...';
if(uni.getStorageSync('addressByLatlng')){
currentPosition.value = uni.getStorageSync('addressByLatlng').formatted_addresses.recommend;
}
//
if(mapConfig.is_open == 1 && locationStorage() && locationStorage().is_expired) {
getLocation({
fail: (res: any) => {
//
currentPosition.value = "定位中..."
}
});
}
}
watch(() => systemStore.location, (nval: any, oval)=> { const locationVal = useLocation(isOpenLocation);
if (nval.latitude && nval.longitude) { locationVal.onLoad();
getAddressByLatlngFn() locationVal.initFn();
}else{ /************** 定位-end ****************/
currentPosition.value = "定位中..."
}
},{deep:true})
//
const getAddressByLatlngFn = () => {
let data = {
latlng: ''
};
data.latlng = systemStore.location.latitude + ',' + systemStore.location.longitude ;
getAddressByLatlng(data).then((res: any) => {
if (res.data && Object.keys(res.data).length) {
currentPosition.value = res.data.formatted_addresses.recommend; //
uni.setStorageSync('addressByLatlng', res.data);
} else {
currentPosition.value = '定位中...';
}
})
}
//
const reposition = () => {
// #ifdef MP
uni.chooseLocation({
success: (res) => {
var urlencode = cloneDeep(systemStore.location);
urlencode = Object.assign(urlencode,res)
systemStore.setLocation(urlencode);
},
fail: (res)=>{
// chooseLocation:fail api
if(res.errMsg && res.errno) {
if(res.errno == 104){
let msg = '用户未授权隐私权限,选择位置失败';
uni.showToast({title: msg, icon: 'none'})
}else if(res.errno == 112){
let msg = '隐私协议中未声明,打开地图选择位置失败';
uni.showToast({title: msg, icon: 'none'})
}else {
uni.showToast({title: res.errMsg, icon: 'none'})
}
}
}
});
// #endif
// #ifdef H5
let backurl = location.origin + location.pathname;
window.location.href = 'https://apis.map.qq.com/tools/locpicker?search=1&type=0&backurl=' + encodeURIComponent(backurl) + '&key=' + manifestJson.h5.sdkConfigs.maps.qqmap.key + '&referer=myapp';
// #endif
}
const getQueryVariable = (variable:any)=> {
var query = window.location.search.substring(1);
var vars = query.split('&');
for (var i = 0; i < vars.length; i++) {
var pair = vars[i].split('=');
if (pair[0] == variable) {
return pair[1];
}
}
return false;
}
/******************************* 定位-end ***********************/
onMounted(() => { onMounted(() => {
navbarPlaceholderHeight(); navbarPlaceholderHeight();
if (pages.length > 1) { if (pages.length > 1) {
isBackShow.value = true; isBackShow.value = true;
} }
if(topStatusBarData.value && topStatusBarData.value.style == 'style-4') { //
initPosition(); locationVal.refreshLocationFn();
}
}); });
// onShow // onShow
const refresh = ()=>{ const refresh = ()=>{
if(topStatusBarData.value && topStatusBarData.value.style == 'style-4') { //
initPosition(); locationVal.refreshLocationFn();
}
} }
defineExpose({ defineExpose({
@ -506,4 +414,4 @@ defineExpose({
} }
} }
} }
</style> </style>

View File

@ -1,50 +0,0 @@
import { redirect, img, getToken } from '@/utils/common';
export function useGoods(params: any = {}) {
const baseTagStyle = (data:any)=>{
let style = "";
if(data.color_json.text_color){
style += `color:${data.color_json.text_color};`;
}
if(data.color_json.border_color){
style += `border-color: ${data.color_json.border_color};`;
}
if(data.color_json.bg_color){
style += `background-color: ${data.color_json.bg_color};`;
}
return style;
}
// 价格类型
const priceType = (data:any) =>{
let type = "";
if(data.member_discount && getToken() && data.goodsSku.member_price != data.goodsSku.price) {
type = 'member_price' // 会员价
}
return type;
}
// 商品价格
const goodsPrice = (data:any) => {
let price = "0.00";
if (data.member_discount && getToken() && data.goodsSku.member_price != data.goodsSku.price) {
price = data.goodsSku.member_price ? data.goodsSku.member_price : data.goodsSku.price // 会员价
} else {
price = data.goodsSku ? data.goodsSku.price : data.price; //兼容商品推荐组件
}
return parseFloat(price);
}
// 错误图片展示
const errorImgFn = (data: any, type: any) =>{
data[type] = '';
}
return {
baseTagStyle: baseTagStyle,
goodsPrice: goodsPrice,
priceType: priceType,
error: errorImgFn
}
}

View File

@ -0,0 +1,229 @@
import { onLoad } from '@dcloudio/uni-app';
import { isWeixinBrowser } from '@/utils/common';
import { getAddressByLatlng } from '@/app/api/system';
import manifestJson from '@/manifest.json';
import { cloneDeep } from 'lodash-es';
import wechat from '@/utils/wechat'
import useSystemStore from '@/stores/system';
export function useLocation(isOpenLocation: any) {
const systemStore = useSystemStore();
// 表示,定位是否开启
let isOpen = isOpenLocation;
if (systemStore.mapConfig.is_open != 1) {
isOpen = false;
}
// 监听页面加载
const onLoadLifeCycle = (callback: any = '') => {
onLoad((option: any) => {
if (option && option.latng) {
let obj = { latitude: '', longitude: '' };
obj.latitude = option.latng.split(',')[0]
obj.longitude = option.latng.split(',')[1]
var urlencode = cloneDeep(systemStore.location) || {};
urlencode = Object.assign(urlencode, obj)
systemStore.setLocation(urlencode);
if (urlencode && urlencode.latitude && urlencode.longitude) {
getAddressByLatlngFn('')
} else {
systemStore.setCurrShippingAddress('');
}
}
uni.removeStorageSync('manually_select_location_from_map');
typeof callback == 'function' && callback(option);
});
}
const init = () => {
if (!isOpen) return false;
// 排除手动地图选择位置的情况
if (!uni.getStorageSync('manually_select_location_from_map')) {
// #ifdef H5
if (isWeixinBrowser() && systemStore.mapConfig.is_open&& !uni.getStorageSync('curr_shipping_address')) {
wechat.init(()=>{
wechat.getLocation(res => {
let latlng = res.latitude + ',' + res.longitude; // 纬度浮点数范围为90 ~ -90经度浮点数范围为180 ~ -180
getAddressByLatlngFn(latlng)
})
});
}
// #endif
// #ifdef MP
if (systemStore.mapConfig.is_open && !uni.getStorageSync('curr_shipping_address')) {
uni.getLocation({
type: 'gcj02',
success: res => {
let latlng = res.latitude + ',' + res.longitude; // 纬度浮点数范围为90 ~ -90经度浮点数范围为180 ~ -180
getAddressByLatlngFn(latlng);
},
fail: (res) => {
systemStore.defaultPositionAddress = '定位失败';
if (res.errno) {
if (res.errno == 104) {
let msg = '用户未授权隐私权限,获取位置失败';
uni.showToast({ title: msg, icon: 'none' })
} else if (res.errno == 112) {
let msg = '隐私协议中未声明,获取位置失败';
uni.showToast({ title: msg, icon: 'none' })
}
}
if (res.errMsg) {
if (res.errMsg.indexOf('getLocation:fail') != -1 || res.errMsg.indexOf('deny') != -1 || res.errMsg.indexOf('denied') != -1) {
let msg = '用户未授权获取位置权限,将无法提供服务';
uni.showToast({ title: msg, icon: 'none' })
} else {
uni.showToast({ title: res.errMsg, icon: 'none' })
}
}
}
});
}
// #endif
}
}
// 刷新页面时需要调用的
const refreshLocation = () => {
if (!isOpen) return false;
if (!uni.getStorageSync('manually_select_location_from_map') && uni.getStorageSync('curr_shipping_address')) {
if(locationStorage() && !locationStorage().is_expired){
systemStore.setCurrShippingAddress(uni.getStorageSync('curr_shipping_address'))
}else{
uni.removeStorageSync('curr_shipping_address');
}
}
// 定位信息过期后,重新获取定位
if (!uni.getStorageSync('manually_select_location_from_map') && locationStorage() && locationStorage().is_expired) {
init();
}
}
// 通过经纬度获取地址信息
const getAddressByLatlngFn = (latlng: any = '') => {
if (!isOpen) return false;
let data = { latlng: '' };
if (latlng) {
data.latlng = latlng;
let obj = { latitude: '', longitude: '' };
obj.latitude = data.latlng.split(',')[0]
obj.longitude = data.latlng.split(',')[1]
var urlencode = cloneDeep(systemStore.location) || {};
urlencode = Object.assign(urlencode, obj)
systemStore.setLocation(urlencode);
} else {
data.latlng = systemStore.location.latitude + ',' + systemStore.location.longitude;
}
getAddressByLatlng(data).then((res: any) => {
if (res.data && Object.keys(res.data).length) {
let obj: any = {};
obj.latitude = res.latitude;
obj.longitude = res.longitude;
obj.full_address = res.data.province != undefined ? res.data.province : '';
obj.full_address += res.data.city != undefined ? res.data.city : '';
obj.full_address += res.data.district != undefined ? res.data.district : '';
obj.full_address += res.data.community != undefined ? res.data.community : '';
obj.province_id = res.data.province_id;
obj.province = res.data.province;
obj.city_id = res.data.city_id;
obj.city = res.data.city;
obj.district_id = res.data.district_id;
obj.district = res.data.district;
obj.community = res.data.community;
obj.formatted_addresses = res.data.formatted_addresses;
systemStore.setCurrShippingAddress(obj)
} else {
systemStore.setCurrShippingAddress("")
}
// 手动选择地图位置后,清除标识
setTimeout(() => {
// 由于异步请求速度影响,需要延迟删除
uni.removeStorageSync('manually_select_location_from_map');
}, 500);
})
}
// 打开地图重新选择位置
const reposition = () => {
if (!isOpen) return false;
let latitude = systemStore.location ? systemStore.location.latitude : '';
let longitude = systemStore.location ? systemStore.location.longitude : '';
// #ifdef MP
uni.chooseLocation({
latitude,
longitude,
success: (res) => {
uni.setStorageSync('manually_select_location_from_map', true)
var urlencode = cloneDeep(systemStore.location) || {};
urlencode = Object.assign(urlencode, res)
systemStore.setLocation(urlencode);
if (urlencode && urlencode.latitude && urlencode.longitude) {
getAddressByLatlngFn('')
} else {
systemStore.setCurrShippingAddress('');
}
},
fail: (res) => {
// 在隐私协议中没有声明chooseLocation:fail api作用域
if (res.errMsg && res.errno) {
if (res.errno == 104) {
let msg = '用户未授权隐私权限,选择位置失败';
uni.showToast({ title: msg, icon: 'none' })
} else if (res.errno == 112) {
let msg = '隐私协议中未声明,打开地图选择位置失败';
uni.showToast({ title: msg, icon: 'none' })
} else {
uni.showToast({ title: res.errMsg, icon: 'none' })
}
}
}
});
// #endif
// #ifdef H5
uni.setStorageSync('manually_select_location_from_map', true)
let backurl = location.origin + location.pathname;
window.location.href = 'https://apis.map.qq.com/tools/locpicker?search=1&type=0&backurl=' + encodeURIComponent(backurl) + '&key=' + manifestJson.h5.sdkConfigs.maps.qqmap.key + '&referer=myapp';
// #endif
}
/**
*
*/
const locationStorage = () => {
let data = uni.getStorageSync('location');
if (data) {
var date = new Date();
if (systemStore.mapConfig.valid_time > 0) {
data.is_expired = (date.getTime() / 1000) > data.valid_time; // 是否过期
} else {
data.is_expired = false;
}
}else{
data = {
is_expired : false
};
}
return data;
}
return {
initFn: init,
onLoad: onLoadLifeCycle,
refreshLocationFn: refreshLocation,
repositionFn: reposition
}
}

View File

@ -2,7 +2,6 @@ import { redirect, isWeixinBrowser, urlDeconstruction } from '@/utils/common'
import { import {
weappLogin, weappLogin,
updateWeappOpenid, updateWeappOpenid,
wechatLogin,
updateWechatOpenid, updateWechatOpenid,
wechatUser, wechatUser,
wechatUserLogin wechatUserLogin
@ -173,8 +172,10 @@ export function useLogin() {
} }
/** /**
* openid * openid
* @param code
* @param callback
*/ */
const updateOpenid = (code: string | null) => { const updateOpenid = (code: string | null, callback: any = null) => {
let obj: any = { let obj: any = {
code code
}; };
@ -193,6 +194,7 @@ export function useLogin() {
useMemberStore().getMemberInfo(() => { useMemberStore().getMemberInfo(() => {
const memberInfo = useMemberStore().info const memberInfo = useMemberStore().info
memberInfo && memberInfo.wx_openid && uni.setStorageSync('openid', memberInfo.wx_openid) memberInfo && memberInfo.wx_openid && uni.setStorageSync('openid', memberInfo.wx_openid)
if (callback) callback();
}) })
}) })
// #endif // #endif

View File

@ -71,6 +71,7 @@
"shop.pages.goods.category": "商品分类", "shop.pages.goods.category": "商品分类",
"shop.pages.goods.detail": "商品详情", "shop.pages.goods.detail": "商品详情",
"shop.pages.goods.list": "商品列表", "shop.pages.goods.list": "商品列表",
"shop.pages.goods.rank": "排行榜",
"shop.pages.member.index": "个人中心", "shop.pages.member.index": "个人中心",
"shop.pages.member.my_coupon": "我的优惠券", "shop.pages.member.my_coupon": "我的优惠券",
"shop.pages.order.list": "订单列表", "shop.pages.order.list": "订单列表",

View File

@ -6,6 +6,7 @@ interface loginConfig {
is_username: number | boolean, is_username: number | boolean,
is_mobile: number | boolean, is_mobile: number | boolean,
is_auth_register: number | boolean, is_auth_register: number | boolean,
is_force_access_user_info: number | boolean,
is_bind_mobile: number | boolean, is_bind_mobile: number | boolean,
agreement_show: number | boolean, agreement_show: number | boolean,
bg_url: string, bg_url: string,
@ -35,6 +36,7 @@ const useConfigStore = defineStore('config', {
is_username: 0, is_username: 0,
is_mobile: 0, is_mobile: 0,
is_auth_register: 0, is_auth_register: 0,
is_force_access_user_info: 0,
is_bind_mobile: 0, is_bind_mobile: 0,
agreement_show: 0, agreement_show: 0,
bg_url: '', bg_url: '',
@ -60,6 +62,7 @@ const useConfigStore = defineStore('config', {
this.login.is_username = res.data.is_username this.login.is_username = res.data.is_username
this.login.is_mobile = res.data.is_mobile this.login.is_mobile = res.data.is_mobile
this.login.is_auth_register = parseInt(res.data.is_auth_register) this.login.is_auth_register = parseInt(res.data.is_auth_register)
this.login.is_force_access_user_info = parseInt(res.data.is_force_access_user_info)
this.login.is_bind_mobile = parseInt(res.data.is_bind_mobile) this.login.is_bind_mobile = parseInt(res.data.is_bind_mobile)
this.login.agreement_show = parseInt(res.data.agreement_show) this.login.agreement_show = parseInt(res.data.agreement_show)
this.login.bg_url = res.data.bg_url // 背景图 this.login.bg_url = res.data.bg_url // 背景图

View File

@ -13,7 +13,9 @@ interface System {
mapConfig: any, mapConfig: any,
initStatus: any, // 初始化状态 initStatus: any, // 初始化状态
menuButtonInfo: any, // 如果是小程序,获取右上角胶囊的尺寸信息 menuButtonInfo: any, // 如果是小程序,获取右上角胶囊的尺寸信息
shareCallback: any // 分享回调 shareCallback: any, // 分享回调
currShippingAddress: any,
defaultPositionAddress:any
} }
const useSystemStore = defineStore('system', { const useSystemStore = defineStore('system', {
@ -35,7 +37,9 @@ const useSystemStore = defineStore('system', {
right: '', right: '',
width: '' width: ''
}, },
shareCallback: null shareCallback: null,
currShippingAddress: null,
defaultPositionAddress:'定位中'
} }
}, },
actions: { actions: {
@ -79,6 +83,7 @@ const useSystemStore = defineStore('system', {
configStore.login.is_username = data.login_config.is_username configStore.login.is_username = data.login_config.is_username
configStore.login.is_mobile = data.login_config.is_mobile configStore.login.is_mobile = data.login_config.is_mobile
configStore.login.is_auth_register = parseInt(data.login_config.is_auth_register) configStore.login.is_auth_register = parseInt(data.login_config.is_auth_register)
configStore.login.is_force_access_user_info = parseInt(data.login_config.is_force_access_user_info)
configStore.login.is_bind_mobile = parseInt(data.login_config.is_bind_mobile) configStore.login.is_bind_mobile = parseInt(data.login_config.is_bind_mobile)
configStore.login.agreement_show = parseInt(data.login_config.agreement_show) configStore.login.agreement_show = parseInt(data.login_config.agreement_show)
configStore.login.bg_url = data.login_config.bg_url // 背景图 configStore.login.bg_url = data.login_config.bg_url // 背景图
@ -115,7 +120,16 @@ const useSystemStore = defineStore('system', {
value.valid_time = date.getTime() / 1000; // 定位信息 5分钟内有效过期后将重新获取定位信息 value.valid_time = date.getTime() / 1000; // 定位信息 5分钟内有效过期后将重新获取定位信息
this.location = value; this.location = value;
uni.setStorageSync('location', value); // 初始化数据调用 uni.setStorageSync('location', value); // 初始化数据调用
} },
// 当前选择的收货地址信息
setCurrShippingAddress(value:any) {
this.currShippingAddress = value;
if(value){
uni.setStorageSync('curr_shipping_address', value);
}else{
uni.removeStorageSync('curr_shipping_address');
}
}
} }
}) })

View File

@ -475,63 +475,3 @@ button[type='primary'],uni-button[type='primary']{
opacity: 0; opacity: 0;
} }
/******************** mescroll state **********************/ /******************** mescroll state **********************/
/******************** 商品列表 state **********************/
.brand-tag{
position: relative;
top: -2rpx;
display: inline;
line-height: 38rpx;
padding: 4rpx 8rpx;
border-radius: 4rpx;
margin-right: 8rpx;
background: red;
vertical-align: middle;
font-size: 18rpx;
color: #fff;
&.middle{
padding: 4rpx 8rpx;
border-radius: 8rpx;
font-size: 20rpx;
margin-right: 6rpx;
}
}
.base-tag {
display: flex;
justify-content: center;
align-items: center;
height: 34rpx;
font-size: 18rpx;
padding: 0 8rpx;
color: #333;
border-radius: 4rpx;
background-color: #fff;
margin-right: 8rpx;
box-sizing: border-box;
margin-top: 8rpx;
border: 2rpx solid transparent;
&.middle{
height: 40rpx;
padding: 0 12rpx;
border-radius: 8rpx;
font-size: 20rpx;
margin-right: 16rpx;
}
}
.img-tag {
display: block;
height: 34rpx;
width: auto;
border-radius: 4rpx;
margin-right: 14rpx;
box-sizing: border-box;
margin-top: 8rpx;
&.middle{
height: 38rpx;
border-radius: 8rpx;
margin-right: 16rpx;
}
}
/******************** 商品列表 end **********************/

View File

@ -1,8 +1,8 @@
@font-face { @font-face {
font-family: "iconfont"; /* Project id 3952239 */ font-family: "iconfont"; /* Project id 3952239 */
src: url('//at.alicdn.com/t/c/font_3952239_cci6ogjyld.woff2?t=1729334583603') format('woff2'), src: url('//at.alicdn.com/t/c/font_3952239_w9mu2hnz4eg.woff2?t=1731396621845') format('woff2'),
url('//at.alicdn.com/t/c/font_3952239_cci6ogjyld.woff?t=1729334583603') format('woff'), url('//at.alicdn.com/t/c/font_3952239_w9mu2hnz4eg.woff?t=1731396621845') format('woff'),
url('//at.alicdn.com/t/c/font_3952239_cci6ogjyld.ttf?t=1729334583603') format('truetype'); url('//at.alicdn.com/t/c/font_3952239_w9mu2hnz4eg.ttf?t=1731396621845') format('truetype');
} }
.iconfont { .iconfont {
@ -13,6 +13,10 @@
-moz-osx-font-smoothing: grayscale; -moz-osx-font-smoothing: grayscale;
} }
.icona-paihangbangpc30:before {
content: "\e83a";
}
.iconbiaoqianV6xx2:before { .iconbiaoqianV6xx2:before {
content: "\e824"; content: "\e824";
} }

View File

@ -1,8 +1,8 @@
@font-face { @font-face {
font-family: "nc-iconfont"; /* Project id 4567203 */ font-family: "nc-iconfont"; /* Project id 4567203 */
src: url('//at.alicdn.com/t/c/font_4567203_p1l3213jbpf.woff2?t=1725850647351') format('woff2'), src: url('//at.alicdn.com/t/c/font_4567203_upzww1i5qjn.woff2?t=1731549702579') format('woff2'),
url('//at.alicdn.com/t/c/font_4567203_p1l3213jbpf.woff?t=1725850647351') format('woff'), url('//at.alicdn.com/t/c/font_4567203_upzww1i5qjn.woff?t=1731549702579') format('woff'),
url('//at.alicdn.com/t/c/font_4567203_p1l3213jbpf.ttf?t=1725850647351') format('truetype'); url('//at.alicdn.com/t/c/font_4567203_upzww1i5qjn.ttf?t=1731549702579') format('truetype');
} }
.nc-iconfont { .nc-iconfont {
@ -13,6 +13,14 @@
-moz-osx-font-smoothing: grayscale; -moz-osx-font-smoothing: grayscale;
} }
.nc-icon-gouwuche1:before {
content: "\e76e";
}
.nc-icon-gouwuche:before {
content: "\e6ea";
}
.nc-icon-kabao:before { .nc-icon-kabao:before {
content: "\e7ec"; content: "\e7ec";
} }

View File

@ -476,42 +476,6 @@ export function handleOnloadParams(option: any) {
return params; return params;
} }
/**
*
*/
export function getLocation(param: any = {}) {
uni.getLocation({
type: param.type || 'gcj02',
success: res => {
const systemStore = useSystemStore()
systemStore.setLocation(res);
typeof param.success == 'function' && param.success(res);
},
fail: res => {
typeof param.fail == 'function' && param.fail(res);
},
complete: res => {
typeof param.complete == 'function' && param.complete(res);
}
});
}
/**
*
*/
export function locationStorage() {
let data = uni.getStorageSync('location');
let mapConfig = uni.getStorageSync('mapConfig');
if (data) {
var date = new Date();
if (mapConfig.valid_time > 0) {
data.is_expired = (date.getTime() / 1000) > data.valid_time; // 是否过期
} else {
data.is_expired = false;
}
}
return data;
}
/** /**
* @description * @description

View File

@ -1,6 +1,6 @@
import useMemberStore from '@/stores/member' import useMemberStore from '@/stores/member'
import { t } from '@/locale' import { t } from '@/locale'
import { getToken, getAppChannel, getSiteId, redirect, currRoute } from './common' import { getToken, getAppChannel, getSiteId, redirect, currRoute, isUrl } from './common'
import qs from 'qs' import qs from 'qs'
interface RequestConfig { interface RequestConfig {

View File

@ -11,7 +11,7 @@ class Wechat {
// #endif // #endif
} }
public init() { public init(callback:any = null) {
getWechatSdkConfig({ getWechatSdkConfig({
url: uni.getSystemInfoSync().platform == 'ios' ? uni.getStorageSync('initUrl') : location.href url: uni.getSystemInfoSync().platform == 'ios' ? uni.getStorageSync('initUrl') : location.href
}).then((res: any) => { }).then((res: any) => {
@ -22,8 +22,9 @@ class Wechat {
timestamp: data.timestamp, // 必填,生成签名的时间戳 timestamp: data.timestamp, // 必填,生成签名的时间戳
nonceStr: data.nonceStr, // 必填,生成签名的随机串 nonceStr: data.nonceStr, // 必填,生成签名的随机串
signature: data.signature,// 必填,签名 signature: data.signature,// 必填,签名
jsApiList: ['chooseWXPay', 'updateAppMessageShareData', 'updateTimelineShareData', 'scanQRCode'] // 必填需要使用的JS接口列表 jsApiList: ['chooseWXPay', 'updateAppMessageShareData', 'updateTimelineShareData', 'scanQRCode', 'getLocation'] // 必填需要使用的JS接口列表
}); });
if(callback) callback();
}) })
} }
@ -63,6 +64,21 @@ class Wechat {
}); });
}) })
} }
/**
*
* @param {Object} callback
*/
public getLocation(callback: any) {
wx.ready(function() {
wx.getLocation({
type: 'gcj02',
success: function(res) {
typeof callback == 'function' && callback(res);
}
});
})
}
} }
export default new Wechat() export default new Wechat()