mirror of
http://git.coreshop.cn/jianweie/coreshoppro.git
synced 2026-03-23 00:17:21 +08:00
Merge branch 'dev' into 'master'
【新增】(地址模块):根据后台开关按钮,是否需要定位功能 See merge request jianweie/coreshoppro!38
This commit is contained in:
@@ -26,8 +26,8 @@
|
|||||||
padding-bottom: calc(env(safe-area-inset-bottom) / 2);
|
padding-bottom: calc(env(safe-area-inset-bottom) / 2);
|
||||||
|
|
||||||
.btn {
|
.btn {
|
||||||
width: 100%;
|
width: calc(100% - 40rpx);
|
||||||
padding: 20rpx;
|
margin: 20rpx;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
@@ -69,6 +69,12 @@ export enum ShowVasEnum {
|
|||||||
no = 2,
|
no = 2,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 是否使用地图定位功能 */
|
||||||
|
export enum ShowAllowAddressToUseMap {
|
||||||
|
yes = 1,
|
||||||
|
no = 2,
|
||||||
|
}
|
||||||
|
|
||||||
/** 是否显示门店列表*/
|
/** 是否显示门店列表*/
|
||||||
export enum ShowStoresSwitchEnum {
|
export enum ShowStoresSwitchEnum {
|
||||||
yes = 1,
|
yes = 1,
|
||||||
|
|||||||
@@ -66,4 +66,5 @@ export interface ShopConfigType {
|
|||||||
toCashMoneyLow ?: string;
|
toCashMoneyLow ?: string;
|
||||||
toCashMoneyRate ?: string;
|
toCashMoneyRate ?: string;
|
||||||
userAgreementId ?: number;
|
userAgreementId ?: number;
|
||||||
|
allowAddressToUseMap ?: number;
|
||||||
}
|
}
|
||||||
@@ -8,40 +8,50 @@ type TReqOptions = Pick<UniApp.RequestOptions, 'method' | 'data' | 'header'>;
|
|||||||
type TReqMethodOptions = Omit<TReqOptions, 'method'>;
|
type TReqMethodOptions = Omit<TReqOptions, 'method'>;
|
||||||
type TResData = UniApp.RequestSuccessCallbackResult['data'];
|
type TResData = UniApp.RequestSuccessCallbackResult['data'];
|
||||||
|
|
||||||
// 存储未完成的请求
|
let isRefreshing = true;
|
||||||
const pendingRequests : any[] = [];
|
let subscribers = [];
|
||||||
|
|
||||||
const request = async <T = TResData>(url : string, { method, data, header = {} } : TReqOptions, auth : boolean = true) : Promise<Response<T>> => {
|
function onAccessTokenFetched() {
|
||||||
|
subscribers.forEach((callback) => {
|
||||||
|
callback();
|
||||||
|
})
|
||||||
|
subscribers = [];
|
||||||
|
isRefreshing = true;
|
||||||
|
}
|
||||||
|
|
||||||
let requestHeader : any = header;
|
function addSubscriber(callback:Function) {
|
||||||
|
subscribers.push(callback)
|
||||||
|
}
|
||||||
|
|
||||||
if (auth) {
|
const request = async <T = TResData>(url : string, { method, data, header = {} } : TReqOptions, auth : boolean = true, callBack ?: Function) : Promise<Response<T>> => {
|
||||||
if (uni.getStorageSync(UserToken)) {
|
return new Promise(async (resolve, _) => {
|
||||||
requestHeader['Authorization'] = `Bearer ${uni.getStorageSync(UserToken)}`;
|
const res = await UniP.request<T>({
|
||||||
} else {
|
url: url.indexOf('http') >= 0 ? url : `${getRequestHost()}/${url}`,
|
||||||
/** 储存当前请求 */
|
method,
|
||||||
pendingRequests.push({
|
data,
|
||||||
url,
|
header: {
|
||||||
data: { method, data, header, },
|
...header,
|
||||||
auth,
|
'Authorization': `Bearer ${uni.getStorageSync(UserToken)}`
|
||||||
});
|
}
|
||||||
/** 重新请求拿到token */
|
});
|
||||||
await handleLoginGetToken().then(() => {
|
|
||||||
pendingRequests.forEach((requestConfig) => {
|
if (callBack) {
|
||||||
return request(requestConfig.url, requestConfig.data, requestConfig.auth);
|
return callBack(res);
|
||||||
});
|
|
||||||
pendingRequests.length = 0;
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
// 授权过期
|
||||||
|
if (res.code === 14007) {
|
||||||
return UniP.request<T>({
|
addSubscriber(() => {
|
||||||
url: url.indexOf('http') >= 0 ? url : `${getRequestHost()}/${url}`,
|
request<T>(url, { method, data, header }, auth, resolve)
|
||||||
method,
|
});
|
||||||
data,
|
if (isRefreshing) {
|
||||||
header: {
|
await handleLoginGetToken();
|
||||||
...requestHeader
|
onAccessTokenFetched();
|
||||||
|
isRefreshing = true;
|
||||||
|
}
|
||||||
|
isRefreshing = false;
|
||||||
|
} else {
|
||||||
|
isRefreshing = true;
|
||||||
|
return resolve(res);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -112,7 +112,7 @@
|
|||||||
<view class="tit">商家管理</view>
|
<view class="tit">商家管理</view>
|
||||||
</view>
|
</view>
|
||||||
<template v-for="item in navState.myServiceList" :key="item.name">
|
<template v-for="item in navState.myServiceList" :key="item.name">
|
||||||
<view class="item" v-if="item.isShow" @click="handleJumpPage(item.url)">
|
<view class="item" v-if="item.isShow" @click="handleMyServiceJumpPage(item)">
|
||||||
<image class="img" :src="handleStaticResources(item.img)"></image>
|
<image class="img" :src="handleStaticResources(item.img)"></image>
|
||||||
<view class="tit">{{ item.title }}</view>
|
<view class="tit">{{ item.title }}</view>
|
||||||
</view>
|
</view>
|
||||||
@@ -152,10 +152,10 @@
|
|||||||
import { reactive } from 'vue';
|
import { reactive } from 'vue';
|
||||||
import { onPageScroll, onShow } from '@dcloudio/uni-app';
|
import { onPageScroll, onShow } from '@dcloudio/uni-app';
|
||||||
import { handleStaticResources, handleRouteNavigateTo, handleShowToast } from '@/core/utils';
|
import { handleStaticResources, handleRouteNavigateTo, handleShowToast } from '@/core/utils';
|
||||||
import { queryUserInfo, queryOrderStatusNum, queryUserIsClerk } from '@/core/api';
|
import { queryUserInfo, queryOrderStatusNum, queryUserIsClerk, queryDistributionInfo, queryAgentInfo } from '@/core/api';
|
||||||
import type { Response, MemberOrderType, UserInfoType, UserIsClerkType, MemberServiceType } from '@/core/models';
|
import type { Response, MemberOrderType, UserInfoType, UserIsClerkType, MemberServiceType } from '@/core/models';
|
||||||
import { useShopConfigStore, useUserInfoStore, useLoginStore } from '@/core/store';
|
import { useShopConfigStore, useUserInfoStore, useLoginStore } from '@/core/store';
|
||||||
import { ShowVasEnum, ShowInviterEnum, OrderTabStatusEnum, MemberPageNameEnum } from '@/core/enum';
|
import { ShowVasEnum, ShowInviterEnum, OrderTabStatusEnum, MemberPageNameEnum, DistributionApplyStatus, AgentApplyStatus } from '@/core/enum';
|
||||||
import { useNavHook } from './use-nav-hook';
|
import { useNavHook } from './use-nav-hook';
|
||||||
import { UserToken } from '@/core/consts'
|
import { UserToken } from '@/core/consts'
|
||||||
|
|
||||||
@@ -247,6 +247,45 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 我的服务跳转页面 */
|
||||||
|
const handleMyServiceJumpPage = (item : MemberServiceType) => {
|
||||||
|
_useLoginStore.checkLogin(async () => {
|
||||||
|
/** 判断分销 获取分销商进度状态 */
|
||||||
|
if (item.name == MemberPageNameEnum.distribution) {
|
||||||
|
const info : Response<any> = await queryDistributionInfo();
|
||||||
|
if (info.status) {
|
||||||
|
if (info.data?.verifyStatus == DistributionApplyStatus.success || (!info.data?.needApply && info.data?.conditionStatus)) {
|
||||||
|
handleRouteNavigateTo('/pages/subpackage/distribution/index/index');
|
||||||
|
} else if (info.data?.verifyStatus > DistributionApplyStatus.success) {
|
||||||
|
handleRouteNavigateTo(`/pages/subpackage/distribution/apply/state`);
|
||||||
|
} else {
|
||||||
|
handleRouteNavigateTo(`/pages/subpackage/distribution/apply/index`);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
handleShowToast(info.msg)
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
/** 判断代理 获取代理商进度状态 */
|
||||||
|
if (item.name == MemberPageNameEnum.agent) {
|
||||||
|
const info : Response<any> = await queryAgentInfo({ check_condition: true });
|
||||||
|
if (info.status) {
|
||||||
|
if (info.data?.verifyStatus == AgentApplyStatus.success || (!info.data?.needApply && info.data?.conditionStatus)) {
|
||||||
|
handleRouteNavigateTo('/pages/subpackage/agency/index/index');
|
||||||
|
} else if (info.data?.verifyStatus > AgentApplyStatus.success) {
|
||||||
|
handleRouteNavigateTo(`/pages/subpackage/agency/apply/state`);
|
||||||
|
} else {
|
||||||
|
handleRouteNavigateTo(`/pages/subpackage/agency/apply/index`);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
handleShowToast(info.msg)
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
handleRouteNavigateTo(item.url);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/** 分类服务跳转页面 */
|
/** 分类服务跳转页面 */
|
||||||
const handleClassifyServiceJumpPage = (item : MemberServiceType) => {
|
const handleClassifyServiceJumpPage = (item : MemberServiceType) => {
|
||||||
/** 判断签到,系统设置 */
|
/** 判断签到,系统设置 */
|
||||||
|
|||||||
@@ -138,7 +138,8 @@
|
|||||||
v-if="state.userCouponsList.length > 0 && state.orderType === PaymentTypeEnum.common && shopConfigStore.config.showCoupon === ShowCouponEnum.yes">
|
v-if="state.userCouponsList.length > 0 && state.orderType === PaymentTypeEnum.common && shopConfigStore.config.showCoupon === ShowCouponEnum.yes">
|
||||||
<view class="title-box">
|
<view class="title-box">
|
||||||
<view class="title">优惠券</view>
|
<view class="title">优惠券</view>
|
||||||
<view class="desc" v-if="state.couponCodeList.length > 0" @click="handleCancelSelectCoupop">取消选择</view>
|
<view class="desc" v-if="state.couponCodeList.length > 0" @click="handleCancelSelectCoupop">取消选择
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="list-box">
|
<view class="list-box">
|
||||||
<scroll-view class="coupon-scroll" scroll-x>
|
<scroll-view class="coupon-scroll" scroll-x>
|
||||||
@@ -390,8 +391,13 @@
|
|||||||
await getUserDefaultShip();
|
await getUserDefaultShip();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
interface CartListCallBack {
|
||||||
|
success : Function,
|
||||||
|
file : Function,
|
||||||
|
}
|
||||||
|
|
||||||
/** 获取商品详情 */
|
/** 获取商品详情 */
|
||||||
const getCartList = async (callBack ?: (data : any) => void) => {
|
const getCartList = async (data ?: CartListCallBack) => {
|
||||||
uni.showLoading({
|
uni.showLoading({
|
||||||
title: '加载中'
|
title: '加载中'
|
||||||
});
|
});
|
||||||
@@ -421,9 +427,10 @@
|
|||||||
if (shopConfigStore.config.pointSwitch === OpenPointEnum.yes && !state.isUsePoint) {
|
if (shopConfigStore.config.pointSwitch === OpenPointEnum.yes && !state.isUsePoint) {
|
||||||
getUserPoint(cartList?.data?.amount)
|
getUserPoint(cartList?.data?.amount)
|
||||||
}
|
}
|
||||||
|
data?.success(cartList);
|
||||||
} else {
|
} else {
|
||||||
uni.hideLoading();
|
uni.hideLoading();
|
||||||
callBack(cartList);
|
data?.file(cartList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -495,22 +502,27 @@
|
|||||||
|
|
||||||
/** 选择使用优惠券 */
|
/** 选择使用优惠券 */
|
||||||
const handleSelectCoupop = (item : any) => {
|
const handleSelectCoupop = (item : any) => {
|
||||||
if(!item.disabled){
|
if (!item.disabled) {
|
||||||
handleShowToast('请在有效时间内使用');
|
handleShowToast('请在有效时间内使用');
|
||||||
return ;
|
return;
|
||||||
}
|
}
|
||||||
if(state.couponCodeList.includes(item.couponCode)){
|
|
||||||
item.checked = false;
|
if (state.couponCodeList.includes(item.couponCode)) {
|
||||||
state.couponCodeList.splice(state.couponCodeList.findIndex((cell) => cell == item.couponCode), 1);
|
state.couponCodeList.splice(state.couponCodeList.findIndex((cell) => cell == item.couponCode), 1);
|
||||||
}else{
|
} else {
|
||||||
item.checked = true;
|
|
||||||
state.couponCodeList.push(item.couponCode);
|
state.couponCodeList.push(item.couponCode);
|
||||||
}
|
}
|
||||||
getCartList((data : any) => {
|
|
||||||
handleShowToast(data.msg);
|
getCartList({
|
||||||
state.couponCodeList.splice(state.couponCodeList.findIndex((cell) => cell == item.couponCode), 1);
|
success() {
|
||||||
item.checked = false;
|
item.checked = !item.checked;
|
||||||
});
|
},
|
||||||
|
file(data : any) {
|
||||||
|
handleShowToast(data.msg);
|
||||||
|
state.couponCodeList.splice(state.couponCodeList.findIndex((cell) => cell == item.couponCode), 1);
|
||||||
|
item.checked = false;
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 获取默认店铺 */
|
/** 获取默认店铺 */
|
||||||
|
|||||||
@@ -20,14 +20,14 @@
|
|||||||
<view class="lab">省市县</view>
|
<view class="lab">省市县</view>
|
||||||
<view class="val" @click="handleShowCityPicker">
|
<view class="val" @click="handleShowCityPicker">
|
||||||
<uv-input placeholder="请选择省市县" border="surround" v-model="state.city"
|
<uv-input placeholder="请选择省市县" border="surround" v-model="state.city"
|
||||||
:readonly="true"></uv-input>
|
:readonly="true" suffixIcon="arrow-down" suffixIconStyle="color: #909399"></uv-input>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="item">
|
<view class="item">
|
||||||
<view class="lab">街道社区</view>
|
<view class="lab">街道社区</view>
|
||||||
<view class="val" @click="handleGoToMap">
|
<view class="val" @click="handleGoToMap">
|
||||||
<uv-input placeholder="请选择街道社区" border="surround" v-model="state.form.street"
|
<uv-input placeholder="请选择街道社区" border="surround" v-model="state.form.street"
|
||||||
:readonly="true"></uv-input>
|
:readonly="shopConfigStore.config?.allowAddressToUseMap == ShowAllowAddressToUseMap.yes" suffixIcon="map-fill" suffixIconStyle="color: #5ac725"></uv-input>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="item">
|
<view class="item">
|
||||||
@@ -56,7 +56,7 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { reactive } from 'vue';
|
import { reactive } from 'vue';
|
||||||
import { onLoad, onShow, onUnload } from '@dcloudio/uni-app';
|
import { onLoad, onShow, onUnload } from '@dcloudio/uni-app';
|
||||||
import { AddressPageTitltEnum } from '@/core/enum';
|
import { AddressPageTitltEnum ,ShowAllowAddressToUseMap} from '@/core/enum';
|
||||||
import { queryAreaId, querySaveUserShip, queryShipDetail } from '@/core/api';
|
import { queryAreaId, querySaveUserShip, queryShipDetail } from '@/core/api';
|
||||||
import type { Response, ShopConfigStoreType, AddressType } from '@/core/models';
|
import type { Response, ShopConfigStoreType, AddressType } from '@/core/models';
|
||||||
import { useShopConfigStore } from '@/core/store';
|
import { useShopConfigStore } from '@/core/store';
|
||||||
@@ -141,7 +141,10 @@
|
|||||||
state.shipId = query.id;
|
state.shipId = query.id;
|
||||||
getShipInfo();
|
getShipInfo();
|
||||||
}
|
}
|
||||||
getMyLocation();
|
/** 开启定位 */
|
||||||
|
if(shopConfigStore.config?.allowAddressToUseMap == ShowAllowAddressToUseMap.yes){
|
||||||
|
getMyLocation();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
onUnload(() => {
|
onUnload(() => {
|
||||||
@@ -233,7 +236,9 @@
|
|||||||
|
|
||||||
/** 去定位 */
|
/** 去定位 */
|
||||||
const handleGoToMap = () => {
|
const handleGoToMap = () => {
|
||||||
|
if(shopConfigStore.config?.allowAddressToUseMap != ShowAllowAddressToUseMap.yes){
|
||||||
|
return;
|
||||||
|
}
|
||||||
// #ifdef MP-WEIXIN
|
// #ifdef MP-WEIXIN
|
||||||
const txMapkey = shopConfigStore?.config?.qqMapKey; //使用在腾讯位置服务申请的key
|
const txMapkey = shopConfigStore?.config?.qqMapKey; //使用在腾讯位置服务申请的key
|
||||||
const referer = shopConfigStore?.config?.shopName; //调用插件的app的名称
|
const referer = shopConfigStore?.config?.shopName; //调用插件的app的名称
|
||||||
|
|||||||
Reference in New Issue
Block a user