mirror of
https://gitee.com/niucloud-team/niucloud.git
synced 2025-12-12 18:02:47 +00:00
up
This commit is contained in:
parent
7088f5add1
commit
2dce1fe5a7
@ -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(() => {
|
||||
|
||||
@ -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 })
|
||||
}
|
||||
|
||||
|
||||
@ -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 })
|
||||
}
|
||||
|
||||
|
||||
@ -116,13 +116,6 @@ export function getAddressByLatlng(params: Record<string, any>) {
|
||||
return request.get(`area/address_by_latlng`, params, { showErrorMessage: true })
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取手机端首页列表
|
||||
*/
|
||||
export function getWapIndexList(data: AnyObject) {
|
||||
return request.get('wap_index', data)
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取海报
|
||||
* @returns
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
<view class="bg-img-box" :style="bgImgBoxStyle"></view>
|
||||
</view>
|
||||
<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">
|
||||
<image :src="img(diyComponent.search.logo)" mode="aspectFit"/>
|
||||
</view>
|
||||
@ -21,7 +21,35 @@
|
||||
</swiper>
|
||||
</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">
|
||||
<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 }]">
|
||||
@ -35,18 +63,18 @@
|
||||
</scroll-view>
|
||||
<view v-if="diyComponent.tab.list.length" class="absolute tab-btn iconfont icona-yingyongliebiaoV6xx-32" @click="tabAllPopup = true"></view>
|
||||
</view>
|
||||
|
||||
|
||||
<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"/>
|
||||
<view v-else class="w-full h-full bg-[#fff]"></view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
|
||||
<!-- 解决fixed定位后导航栏塌陷的问题 -->
|
||||
<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>
|
||||
</template>
|
||||
|
||||
|
||||
<!-- 轮播图 -->
|
||||
<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"
|
||||
@ -80,7 +108,7 @@
|
||||
</view>
|
||||
<!-- #endif -->
|
||||
</view>
|
||||
|
||||
|
||||
<!-- 分类展开 -->
|
||||
<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>
|
||||
@ -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: <any>{},
|
||||
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 ***********************/
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@ -469,7 +520,7 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
.fixed-wrap {
|
||||
&.fixed {
|
||||
position: fixed;
|
||||
@ -533,6 +584,13 @@
|
||||
}
|
||||
}
|
||||
|
||||
&.style-2{
|
||||
flex-direction: column;
|
||||
align-items: baseline;
|
||||
.img-wrap{
|
||||
margin-right: 10rpx;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.tab-list-wrap {
|
||||
@ -558,7 +616,7 @@
|
||||
color: #333;
|
||||
line-height: 32rpx;
|
||||
}
|
||||
|
||||
|
||||
&.active {
|
||||
position: relative;
|
||||
.name {
|
||||
@ -569,7 +627,7 @@
|
||||
}
|
||||
.tab-btn{
|
||||
font-size: 34rpx;
|
||||
/* #ifdef H5 */
|
||||
/* #ifdef H5 */
|
||||
top: 22rpx;
|
||||
right: 20rpx;
|
||||
line-height: 1;
|
||||
@ -626,7 +684,7 @@
|
||||
width: 12rpx;
|
||||
height: 12rpx;
|
||||
}
|
||||
|
||||
|
||||
// 指示器样式二
|
||||
.swiper.ns-indicator-dots :deep(.uni-swiper-dot) {
|
||||
width: 18rpx;
|
||||
@ -636,7 +694,7 @@
|
||||
.swiper.ns-indicator-dots :deep(.uni-swiper-dot-active) {
|
||||
width: 36rpx;
|
||||
}
|
||||
|
||||
|
||||
// 指示器样式三
|
||||
.swiper.ns-indicator-dots-three :deep(.uni-swiper-dot) {
|
||||
width: 8rpx;
|
||||
@ -650,7 +708,7 @@
|
||||
.swiper.ns-indicator-dots-three :deep(.uni-swiper-dot-active) {
|
||||
width: 30rpx;
|
||||
}
|
||||
|
||||
|
||||
.swiper-dot-box {
|
||||
position: absolute;
|
||||
bottom: 20rpx;
|
||||
@ -660,15 +718,15 @@
|
||||
justify-content: center;
|
||||
padding: 0 80rpx 8rpx;
|
||||
box-sizing: border-box;
|
||||
|
||||
|
||||
&.swiper-left {
|
||||
justify-content: flex-start;
|
||||
}
|
||||
|
||||
|
||||
&.swiper-right {
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
|
||||
.swiper-dot {
|
||||
background-color: #b2b2b2;
|
||||
width: 12rpx;
|
||||
@ -676,13 +734,13 @@
|
||||
height: 12rpx;
|
||||
margin: 8rpx;
|
||||
}
|
||||
|
||||
|
||||
&.straightLine {
|
||||
.swiper-dot {
|
||||
width: 18rpx;
|
||||
height: 6rpx;
|
||||
border-radius: 6rpx;
|
||||
|
||||
|
||||
&.active {
|
||||
width: 36rpx;
|
||||
}
|
||||
@ -704,7 +762,7 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
.swiper-style-3{
|
||||
:deep(.uni-swiper-dots-horizontal){
|
||||
bottom: 46rpx !important;
|
||||
@ -713,4 +771,4 @@
|
||||
bottom: 38rpx !important;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
|
||||
@ -33,55 +33,63 @@
|
||||
</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"
|
||||
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' }"/>
|
||||
<view @click="diyStore.toRedirect(item.link)" class="graphic-nav-item flex flex-col items-center py-2">
|
||||
|
||||
<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 }}
|
||||
<view class="graphic-img relative flex items-center justify-center w-10 h-10"
|
||||
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
|
||||
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>
|
||||
</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>
|
||||
</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>
|
||||
</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]">
|
||||
<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]">
|
||||
<!-- #ifdef MP -->
|
||||
<view class="uni-scroll-view-content">
|
||||
<!-- #endif -->
|
||||
<view :style="horizontalSingleSlideStyle" class="flex">
|
||||
<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))">
|
||||
<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 :style="horizontalSingleSlideStyle" >
|
||||
<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" >
|
||||
|
||||
<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"
|
||||
v-if="diyComponent.mode != 'text'"
|
||||
:style="{ width: diyComponent.imageSize * 2 + 'rpx', height: diyComponent.imageSize * 2 + 'rpx' }">
|
||||
@ -104,13 +112,13 @@
|
||||
</text>
|
||||
</view>
|
||||
</template>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</view>
|
||||
<!-- #ifdef MP -->
|
||||
</view>
|
||||
<!-- #endif -->
|
||||
|
||||
</scroll-view>
|
||||
|
||||
</view>
|
||||
|
||||
<scroll-view v-else :scroll-x="diyComponent.showStyle == 'singleSlide'" :class="['graphic-nav','graphic-nav-' + diyComponent.showStyle]" class=" py-[10rpx]">
|
||||
<!-- #ifdef MP -->
|
||||
@ -172,7 +180,11 @@
|
||||
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(() => {
|
||||
var style = '';
|
||||
style += 'position:relative;';
|
||||
@ -209,7 +221,7 @@
|
||||
|
||||
return style;
|
||||
});
|
||||
|
||||
|
||||
// 多行,单行滑动样式
|
||||
const horizontalSingleSlideStyle = computed(()=>{
|
||||
let style = {width: ""};
|
||||
@ -219,7 +231,7 @@
|
||||
style.width = `calc(${widthStr * itemLen}vw - ${marginLen}rpx)`;
|
||||
return style;
|
||||
})
|
||||
|
||||
|
||||
const horizontalSingleSlideBoxStyle = (index: any)=>{
|
||||
let style = {width: ""};
|
||||
let widthStr = 100 / diyComponent.value.rowCount; // 表示每项宽度
|
||||
@ -268,27 +280,29 @@
|
||||
const swiperCondition = (index, numItem) => {
|
||||
let count = diyComponent.value.pageCount * diyComponent.value.rowCount;
|
||||
let result = true;
|
||||
|
||||
|
||||
result = index >= [(numItem - 1) * (count)] && index < [numItem * (count)];
|
||||
|
||||
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 = () => {
|
||||
if(diyComponent.value.layout == 'horizontal' && diyComponent.value.showStyle == 'pageSlide') {
|
||||
var height = 0;
|
||||
const query = uni.createSelectorQuery().in(instance);
|
||||
query.select('.graphic-nav-item').boundingClientRect((data: any) => {
|
||||
if (diyComponent.value.layout == 'horizontal' && diyComponent.value.showStyle == 'pageSlide') {
|
||||
var height = 0;
|
||||
const query = uni.createSelectorQuery().in(instance);
|
||||
query.select('.graphic-nav-item').boundingClientRect((data: any) => {
|
||||
let len = 1;
|
||||
if(diyComponent.value.pageCount == 2){
|
||||
len = (diyComponent.value.list.length / diyComponent.value.rowCount) > 1 ? 2 : 1 ;
|
||||
if (diyComponent.value.pageCount == 2) {
|
||||
len = (diyComponent.value.list.length / diyComponent.value.rowCount) > 1 ? 2 : 1;
|
||||
}
|
||||
height = data.height * len;
|
||||
swiperHeight.value = (height * 2) + 'rpx';
|
||||
}).exec();
|
||||
}
|
||||
height = data.height * len;
|
||||
swiperHeight.value = height + 'px';
|
||||
uni.setStorageSync(storageKey, swiperHeight.value);
|
||||
}).exec();
|
||||
}
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
@ -333,4 +347,63 @@
|
||||
}
|
||||
</style>
|
||||
<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>
|
||||
|
||||
@ -3,13 +3,13 @@
|
||||
<view :style="maskLayer"></view>
|
||||
<view class="diy-notice relative overflow-hidden">
|
||||
<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'">
|
||||
<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" />
|
||||
</template>
|
||||
<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 class="flex-1 flex overflow-hidden horizontal-body" :id="'horizontal-body-'+diyComponent.id" :class="{'items-center':diyComponent.scrollWay == 'upDown'}">
|
||||
<!-- 横向滚动 -->
|
||||
|
||||
@ -114,8 +114,8 @@
|
||||
if (option.type == 'mobile') {
|
||||
if (configStore.login.is_mobile) {
|
||||
type.value = option.type
|
||||
uni.getStorageSync('pid') && (Object.assign(formData, { pid: uni.getStorageSync('pid') }))
|
||||
}
|
||||
|
||||
} else if (option.type == 'username' && configStore.login.is_username) {
|
||||
type.value = option.type
|
||||
}
|
||||
|
||||
@ -324,7 +324,6 @@
|
||||
}
|
||||
.address-edit :deep(.u-form-item__body__right){
|
||||
display:flex;
|
||||
align-items: center;
|
||||
}
|
||||
.footer{
|
||||
height: calc(100rpx + var(--top-m) + var(--top-m) + constant(safe-area-inset-bottom)) !important;
|
||||
|
||||
@ -17,7 +17,7 @@
|
||||
<view :style="{ color: topStatusBarData.textColor }">{{ data.title }}</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
|
||||
<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 class="title-wrap" @click="diyStore.toRedirect(topStatusBarData.link)">
|
||||
@ -29,29 +29,28 @@
|
||||
</view>
|
||||
<view :style="{ 'width': capsuleWidth }"></view>
|
||||
</view>
|
||||
|
||||
|
||||
<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>
|
||||
<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>
|
||||
<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-if="systemStore.currShippingAddress">{{ systemStore.currShippingAddress.community }}</view>
|
||||
<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>
|
||||
|
||||
|
||||
<!-- 解决fixed定位后导航栏塌陷的问题 -->
|
||||
<view v-if="props.isFill" class="u-navbar-placeholder" :style="{ width: '100%', paddingTop: placeholderHeight + 'px' }"></view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, computed, watch, onMounted, getCurrentInstance, nextTick } from 'vue';
|
||||
import { img, getLocation, locationStorage } from '@/utils/common';
|
||||
import { getAddressByLatlng } from '@/app/api/system';
|
||||
import { ref, computed, onMounted, getCurrentInstance, nextTick } from 'vue';
|
||||
import { img } from '@/utils/common';
|
||||
import useSystemStore from '@/stores/system';
|
||||
import useDiyStore from '@/app/stores/diy';
|
||||
import manifestJson from '@/manifest.json'
|
||||
import { cloneDeep } from 'lodash-es'
|
||||
import {useLocation} from '@/hooks/useLocation'
|
||||
|
||||
// 获取系统状态栏的高度
|
||||
let systemInfo = uni.getSystemInfoSync();
|
||||
@ -100,7 +99,7 @@ const topStatusBarData = computed(() => {
|
||||
// 导航栏内部盒子的样式
|
||||
const navbarInnerStyle = computed(() => {
|
||||
let style = '';
|
||||
|
||||
|
||||
if(props.isBack && isBackShow.value){
|
||||
style += 'padding-left: 30rpx;';//30=>右边留边 44=>箭头宽度 10=>箭头的右maring
|
||||
if(topStatusBarData.value.style == 'style-1') //样式一需要居中需要有右边padding辅助
|
||||
@ -122,7 +121,7 @@ const navbarInnerStyle = computed(() => {
|
||||
// 样式一的字体大小
|
||||
const styleOneFontSize = computed(() => {
|
||||
let style = '';
|
||||
|
||||
|
||||
// #ifdef H5
|
||||
style += 'font-size: 28rpx;';
|
||||
// #endif
|
||||
@ -164,7 +163,7 @@ const bgColor = computed(() => {
|
||||
return color;
|
||||
})
|
||||
|
||||
/******************************* 存储滚动值-start ***********************/
|
||||
/******************************* 存储滚动值-start ***********************/
|
||||
// 键名和组件名一致即可
|
||||
let componentsScrollVal = uni.getStorageSync('componentsScrollValGroup')
|
||||
if(componentsScrollVal){
|
||||
@ -176,7 +175,7 @@ if(componentsScrollVal){
|
||||
}
|
||||
uni.setStorageSync('componentsScrollValGroup', obj);
|
||||
}
|
||||
/******************************* 存储滚动值-end ***********************/
|
||||
/******************************* 存储滚动值-end ***********************/
|
||||
|
||||
/******************************* 返回按钮-start ***********************/
|
||||
const isBackShow = ref(false);
|
||||
@ -191,7 +190,7 @@ const goBack = () => {
|
||||
uni.navigateBack();
|
||||
}
|
||||
}
|
||||
/******************************* 返回按钮-end ***********************/
|
||||
/******************************* 返回按钮-end ***********************/
|
||||
|
||||
// 微信胶囊宽度+right
|
||||
const capsuleWidth = computed(() => {
|
||||
@ -216,120 +215,29 @@ const navbarPlaceholderHeight = () => {
|
||||
})
|
||||
}
|
||||
|
||||
/******************************* 定位-start ***********************/
|
||||
// 获取地图配置
|
||||
const currentPosition = ref('定位中...')
|
||||
let mapConfig = uni.getStorageSync('mapConfig');
|
||||
|
||||
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);
|
||||
/************** 定位-start ****************/
|
||||
let isOpenLocation = false;
|
||||
if(topStatusBarData.value && topStatusBarData.value.style == 'style-4') {
|
||||
isOpenLocation = true;
|
||||
}
|
||||
// #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)=> {
|
||||
if (nval.latitude && nval.longitude) {
|
||||
getAddressByLatlngFn()
|
||||
}else{
|
||||
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 ***********************/
|
||||
const locationVal = useLocation(isOpenLocation);
|
||||
locationVal.onLoad();
|
||||
locationVal.initFn();
|
||||
/************** 定位-end ****************/
|
||||
onMounted(() => {
|
||||
navbarPlaceholderHeight();
|
||||
if (pages.length > 1) {
|
||||
isBackShow.value = true;
|
||||
}
|
||||
if(topStatusBarData.value && topStatusBarData.value.style == 'style-4') {
|
||||
initPosition();
|
||||
}
|
||||
// 刷新定位
|
||||
locationVal.refreshLocationFn();
|
||||
});
|
||||
|
||||
// 页面onShow调用时,也会触发改方法
|
||||
const refresh = ()=>{
|
||||
if(topStatusBarData.value && topStatusBarData.value.style == 'style-4') {
|
||||
initPosition();
|
||||
}
|
||||
// 刷新定位
|
||||
locationVal.refreshLocationFn();
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
@ -506,4 +414,4 @@ defineExpose({
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
|
||||
@ -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
|
||||
}
|
||||
}
|
||||
229
uni-app/src/hooks/useLocation.ts
Normal file
229
uni-app/src/hooks/useLocation.ts
Normal 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
|
||||
}
|
||||
}
|
||||
@ -2,7 +2,6 @@ import { redirect, isWeixinBrowser, urlDeconstruction } from '@/utils/common'
|
||||
import {
|
||||
weappLogin,
|
||||
updateWeappOpenid,
|
||||
wechatLogin,
|
||||
updateWechatOpenid,
|
||||
wechatUser,
|
||||
wechatUserLogin
|
||||
@ -173,8 +172,10 @@ export function useLogin() {
|
||||
}
|
||||
/**
|
||||
* 登录普通账号后修改openid
|
||||
* @param code
|
||||
* @param callback
|
||||
*/
|
||||
const updateOpenid = (code: string | null) => {
|
||||
const updateOpenid = (code: string | null, callback: any = null) => {
|
||||
let obj: any = {
|
||||
code
|
||||
};
|
||||
@ -193,6 +194,7 @@ export function useLogin() {
|
||||
useMemberStore().getMemberInfo(() => {
|
||||
const memberInfo = useMemberStore().info
|
||||
memberInfo && memberInfo.wx_openid && uni.setStorageSync('openid', memberInfo.wx_openid)
|
||||
if (callback) callback();
|
||||
})
|
||||
})
|
||||
// #endif
|
||||
|
||||
@ -71,6 +71,7 @@
|
||||
"shop.pages.goods.category": "商品分类",
|
||||
"shop.pages.goods.detail": "商品详情",
|
||||
"shop.pages.goods.list": "商品列表",
|
||||
"shop.pages.goods.rank": "排行榜",
|
||||
"shop.pages.member.index": "个人中心",
|
||||
"shop.pages.member.my_coupon": "我的优惠券",
|
||||
"shop.pages.order.list": "订单列表",
|
||||
|
||||
@ -6,6 +6,7 @@ interface loginConfig {
|
||||
is_username: number | boolean,
|
||||
is_mobile: number | boolean,
|
||||
is_auth_register: number | boolean,
|
||||
is_force_access_user_info: number | boolean,
|
||||
is_bind_mobile: number | boolean,
|
||||
agreement_show: number | boolean,
|
||||
bg_url: string,
|
||||
@ -35,6 +36,7 @@ const useConfigStore = defineStore('config', {
|
||||
is_username: 0,
|
||||
is_mobile: 0,
|
||||
is_auth_register: 0,
|
||||
is_force_access_user_info: 0,
|
||||
is_bind_mobile: 0,
|
||||
agreement_show: 0,
|
||||
bg_url: '',
|
||||
@ -60,6 +62,7 @@ const useConfigStore = defineStore('config', {
|
||||
this.login.is_username = res.data.is_username
|
||||
this.login.is_mobile = res.data.is_mobile
|
||||
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.agreement_show = parseInt(res.data.agreement_show)
|
||||
this.login.bg_url = res.data.bg_url // 背景图
|
||||
|
||||
@ -13,7 +13,9 @@ interface System {
|
||||
mapConfig: any,
|
||||
initStatus: any, // 初始化状态
|
||||
menuButtonInfo: any, // 如果是小程序,获取右上角胶囊的尺寸信息
|
||||
shareCallback: any // 分享回调
|
||||
shareCallback: any, // 分享回调
|
||||
currShippingAddress: any,
|
||||
defaultPositionAddress:any
|
||||
}
|
||||
|
||||
const useSystemStore = defineStore('system', {
|
||||
@ -35,7 +37,9 @@ const useSystemStore = defineStore('system', {
|
||||
right: '',
|
||||
width: ''
|
||||
},
|
||||
shareCallback: null
|
||||
shareCallback: null,
|
||||
currShippingAddress: null,
|
||||
defaultPositionAddress:'定位中'
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
@ -79,6 +83,7 @@ const useSystemStore = defineStore('system', {
|
||||
configStore.login.is_username = data.login_config.is_username
|
||||
configStore.login.is_mobile = data.login_config.is_mobile
|
||||
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.agreement_show = parseInt(data.login_config.agreement_show)
|
||||
configStore.login.bg_url = data.login_config.bg_url // 背景图
|
||||
@ -115,7 +120,16 @@ const useSystemStore = defineStore('system', {
|
||||
value.valid_time = date.getTime() / 1000; // 定位信息 5分钟内有效,过期后将重新获取定位信息
|
||||
this.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');
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
@ -475,63 +475,3 @@ button[type='primary'],uni-button[type='primary']{
|
||||
opacity: 0;
|
||||
}
|
||||
/******************** 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 **********************/
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
@font-face {
|
||||
font-family: "iconfont"; /* Project id 3952239 */
|
||||
src: url('//at.alicdn.com/t/c/font_3952239_cci6ogjyld.woff2?t=1729334583603') format('woff2'),
|
||||
url('//at.alicdn.com/t/c/font_3952239_cci6ogjyld.woff?t=1729334583603') format('woff'),
|
||||
url('//at.alicdn.com/t/c/font_3952239_cci6ogjyld.ttf?t=1729334583603') format('truetype');
|
||||
src: url('//at.alicdn.com/t/c/font_3952239_w9mu2hnz4eg.woff2?t=1731396621845') format('woff2'),
|
||||
url('//at.alicdn.com/t/c/font_3952239_w9mu2hnz4eg.woff?t=1731396621845') format('woff'),
|
||||
url('//at.alicdn.com/t/c/font_3952239_w9mu2hnz4eg.ttf?t=1731396621845') format('truetype');
|
||||
}
|
||||
|
||||
.iconfont {
|
||||
@ -13,6 +13,10 @@
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
}
|
||||
|
||||
.icona-paihangbangpc30:before {
|
||||
content: "\e83a";
|
||||
}
|
||||
|
||||
.iconbiaoqianV6xx2:before {
|
||||
content: "\e824";
|
||||
}
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
@font-face {
|
||||
font-family: "nc-iconfont"; /* Project id 4567203 */
|
||||
src: url('//at.alicdn.com/t/c/font_4567203_p1l3213jbpf.woff2?t=1725850647351') format('woff2'),
|
||||
url('//at.alicdn.com/t/c/font_4567203_p1l3213jbpf.woff?t=1725850647351') format('woff'),
|
||||
url('//at.alicdn.com/t/c/font_4567203_p1l3213jbpf.ttf?t=1725850647351') format('truetype');
|
||||
src: url('//at.alicdn.com/t/c/font_4567203_upzww1i5qjn.woff2?t=1731549702579') format('woff2'),
|
||||
url('//at.alicdn.com/t/c/font_4567203_upzww1i5qjn.woff?t=1731549702579') format('woff'),
|
||||
url('//at.alicdn.com/t/c/font_4567203_upzww1i5qjn.ttf?t=1731549702579') format('truetype');
|
||||
}
|
||||
|
||||
.nc-iconfont {
|
||||
@ -13,6 +13,14 @@
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
}
|
||||
|
||||
.nc-icon-gouwuche1:before {
|
||||
content: "\e76e";
|
||||
}
|
||||
|
||||
.nc-icon-gouwuche:before {
|
||||
content: "\e6ea";
|
||||
}
|
||||
|
||||
.nc-icon-kabao:before {
|
||||
content: "\e7ec";
|
||||
}
|
||||
|
||||
@ -476,42 +476,6 @@ export function handleOnloadParams(option: any) {
|
||||
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 深度克隆
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import useMemberStore from '@/stores/member'
|
||||
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'
|
||||
|
||||
interface RequestConfig {
|
||||
|
||||
@ -11,7 +11,7 @@ class Wechat {
|
||||
// #endif
|
||||
}
|
||||
|
||||
public init() {
|
||||
public init(callback:any = null) {
|
||||
getWechatSdkConfig({
|
||||
url: uni.getSystemInfoSync().platform == 'ios' ? uni.getStorageSync('initUrl') : location.href
|
||||
}).then((res: any) => {
|
||||
@ -22,8 +22,9 @@ class Wechat {
|
||||
timestamp: data.timestamp, // 必填,生成签名的时间戳
|
||||
nonceStr: data.nonceStr, // 必填,生成签名的随机串
|
||||
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()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user