mirror of
http://git.coreshop.cn/jianweie/coreshoppro.git
synced 2025-12-06 17:33:27 +08:00
Merge branch 'dev' into 'master'
【新增】(地址模块):根据后台开关按钮,是否需要定位功能 See merge request jianweie/coreshoppro!38
This commit is contained in:
@@ -25,9 +25,9 @@
|
||||
justify-content: space-between;
|
||||
padding-bottom: calc(env(safe-area-inset-bottom) / 2);
|
||||
|
||||
.btn {
|
||||
width: 100%;
|
||||
padding: 20rpx;
|
||||
.btn {
|
||||
width: calc(100% - 40rpx);
|
||||
margin: 20rpx;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -69,6 +69,12 @@ export enum ShowVasEnum {
|
||||
no = 2,
|
||||
}
|
||||
|
||||
/** 是否使用地图定位功能 */
|
||||
export enum ShowAllowAddressToUseMap {
|
||||
yes = 1,
|
||||
no = 2,
|
||||
}
|
||||
|
||||
/** 是否显示门店列表*/
|
||||
export enum ShowStoresSwitchEnum {
|
||||
yes = 1,
|
||||
|
||||
@@ -66,4 +66,5 @@ export interface ShopConfigType {
|
||||
toCashMoneyLow ?: string;
|
||||
toCashMoneyRate ?: string;
|
||||
userAgreementId ?: number;
|
||||
allowAddressToUseMap ?: number;
|
||||
}
|
||||
@@ -8,40 +8,50 @@ type TReqOptions = Pick<UniApp.RequestOptions, 'method' | 'data' | 'header'>;
|
||||
type TReqMethodOptions = Omit<TReqOptions, 'method'>;
|
||||
type TResData = UniApp.RequestSuccessCallbackResult['data'];
|
||||
|
||||
// 存储未完成的请求
|
||||
const pendingRequests : any[] = [];
|
||||
let isRefreshing = true;
|
||||
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) {
|
||||
if (uni.getStorageSync(UserToken)) {
|
||||
requestHeader['Authorization'] = `Bearer ${uni.getStorageSync(UserToken)}`;
|
||||
} else {
|
||||
/** 储存当前请求 */
|
||||
pendingRequests.push({
|
||||
url,
|
||||
data: { method, data, header, },
|
||||
auth,
|
||||
});
|
||||
/** 重新请求拿到token */
|
||||
await handleLoginGetToken().then(() => {
|
||||
pendingRequests.forEach((requestConfig) => {
|
||||
return request(requestConfig.url, requestConfig.data, requestConfig.auth);
|
||||
});
|
||||
pendingRequests.length = 0;
|
||||
});
|
||||
return;
|
||||
const request = async <T = TResData>(url : string, { method, data, header = {} } : TReqOptions, auth : boolean = true, callBack ?: Function) : Promise<Response<T>> => {
|
||||
return new Promise(async (resolve, _) => {
|
||||
const res = await UniP.request<T>({
|
||||
url: url.indexOf('http') >= 0 ? url : `${getRequestHost()}/${url}`,
|
||||
method,
|
||||
data,
|
||||
header: {
|
||||
...header,
|
||||
'Authorization': `Bearer ${uni.getStorageSync(UserToken)}`
|
||||
}
|
||||
});
|
||||
|
||||
if (callBack) {
|
||||
return callBack(res);
|
||||
}
|
||||
}
|
||||
|
||||
return UniP.request<T>({
|
||||
url: url.indexOf('http') >= 0 ? url : `${getRequestHost()}/${url}`,
|
||||
method,
|
||||
data,
|
||||
header: {
|
||||
...requestHeader
|
||||
// 授权过期
|
||||
if (res.code === 14007) {
|
||||
addSubscriber(() => {
|
||||
request<T>(url, { method, data, header }, auth, resolve)
|
||||
});
|
||||
if (isRefreshing) {
|
||||
await handleLoginGetToken();
|
||||
onAccessTokenFetched();
|
||||
isRefreshing = true;
|
||||
}
|
||||
isRefreshing = false;
|
||||
} else {
|
||||
isRefreshing = true;
|
||||
return resolve(res);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<coreshop-page :title="state.isScrollToTop ? '' : userInfoStore.userInfo?.nickName || ''" titleColor="#fff"
|
||||
mode="left" :bgColor=" state.isScrollToTop ? 'rgba(0,0,0,0)':'#d33123'" :isShowStatusBarHeight="false"
|
||||
:isBack="false" showLoginModalDom>
|
||||
<view class="layout-member-page">
|
||||
<view class="layout-member-page">
|
||||
<view class="member-head">
|
||||
<image class="memeber-bg" src="/static/images/member/bg.png"></image>
|
||||
<view class="head-box m-b-10">
|
||||
@@ -48,7 +48,7 @@
|
||||
<view class="tit">售后</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="member-box">
|
||||
<view class="member-box">
|
||||
<view class="member-content">
|
||||
<view class="content">
|
||||
<view class="grade">{{ userInfoStore.userInfo?.gradeName || '普通会员' }}</view>
|
||||
@@ -64,7 +64,7 @@
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="p-20">
|
||||
<!-- 我的订单 -->
|
||||
<view class="view-box">
|
||||
@@ -112,7 +112,7 @@
|
||||
<view class="tit">商家管理</view>
|
||||
</view>
|
||||
<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>
|
||||
<view class="tit">{{ item.title }}</view>
|
||||
</view>
|
||||
@@ -152,10 +152,10 @@
|
||||
import { reactive } from 'vue';
|
||||
import { onPageScroll, onShow } from '@dcloudio/uni-app';
|
||||
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 { 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 { 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) => {
|
||||
/** 判断签到,系统设置 */
|
||||
|
||||
@@ -138,7 +138,8 @@
|
||||
v-if="state.userCouponsList.length > 0 && state.orderType === PaymentTypeEnum.common && shopConfigStore.config.showCoupon === ShowCouponEnum.yes">
|
||||
<view class="title-box">
|
||||
<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 class="list-box">
|
||||
<scroll-view class="coupon-scroll" scroll-x>
|
||||
@@ -390,8 +391,13 @@
|
||||
await getUserDefaultShip();
|
||||
});
|
||||
|
||||
interface CartListCallBack {
|
||||
success : Function,
|
||||
file : Function,
|
||||
}
|
||||
|
||||
/** 获取商品详情 */
|
||||
const getCartList = async (callBack ?: (data : any) => void) => {
|
||||
const getCartList = async (data ?: CartListCallBack) => {
|
||||
uni.showLoading({
|
||||
title: '加载中'
|
||||
});
|
||||
@@ -421,9 +427,10 @@
|
||||
if (shopConfigStore.config.pointSwitch === OpenPointEnum.yes && !state.isUsePoint) {
|
||||
getUserPoint(cartList?.data?.amount)
|
||||
}
|
||||
data?.success(cartList);
|
||||
} else {
|
||||
uni.hideLoading();
|
||||
callBack(cartList);
|
||||
data?.file(cartList);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -495,22 +502,27 @@
|
||||
|
||||
/** 选择使用优惠券 */
|
||||
const handleSelectCoupop = (item : any) => {
|
||||
if(!item.disabled){
|
||||
if (!item.disabled) {
|
||||
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);
|
||||
}else{
|
||||
item.checked = true;
|
||||
} else {
|
||||
state.couponCodeList.push(item.couponCode);
|
||||
}
|
||||
getCartList((data : any) => {
|
||||
handleShowToast(data.msg);
|
||||
state.couponCodeList.splice(state.couponCodeList.findIndex((cell) => cell == item.couponCode), 1);
|
||||
item.checked = false;
|
||||
});
|
||||
}
|
||||
|
||||
getCartList({
|
||||
success() {
|
||||
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="val" @click="handleShowCityPicker">
|
||||
<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 class="item">
|
||||
<view class="lab">街道社区</view>
|
||||
<view class="val" @click="handleGoToMap">
|
||||
<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 class="item">
|
||||
@@ -56,7 +56,7 @@
|
||||
<script setup lang="ts">
|
||||
import { reactive } from 'vue';
|
||||
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 type { Response, ShopConfigStoreType, AddressType } from '@/core/models';
|
||||
import { useShopConfigStore } from '@/core/store';
|
||||
@@ -141,7 +141,10 @@
|
||||
state.shipId = query.id;
|
||||
getShipInfo();
|
||||
}
|
||||
getMyLocation();
|
||||
/** 开启定位 */
|
||||
if(shopConfigStore.config?.allowAddressToUseMap == ShowAllowAddressToUseMap.yes){
|
||||
getMyLocation();
|
||||
}
|
||||
});
|
||||
|
||||
onUnload(() => {
|
||||
@@ -233,7 +236,9 @@
|
||||
|
||||
/** 去定位 */
|
||||
const handleGoToMap = () => {
|
||||
|
||||
if(shopConfigStore.config?.allowAddressToUseMap != ShowAllowAddressToUseMap.yes){
|
||||
return;
|
||||
}
|
||||
// #ifdef MP-WEIXIN
|
||||
const txMapkey = shopConfigStore?.config?.qqMapKey; //使用在腾讯位置服务申请的key
|
||||
const referer = shopConfigStore?.config?.shopName; //调用插件的app的名称
|
||||
|
||||
Reference in New Issue
Block a user