Merge branch 'dev' into 'master'

uniapp【优化】: 服务商品类型问题,封装授权功能

See merge request jianweie/coreshoppro!55
This commit is contained in:
花城
2024-10-25 01:53:10 +00:00
18 changed files with 214 additions and 119 deletions

View File

@@ -61,7 +61,7 @@ export const queryPromotionList = (data : any) : Promise<Response<Array<any>>> =
}
/** 获取服务商品列表 */
export const queryServicelist = (data : any) : Promise<Response<Array<ServiceGoodsType>>> => {
export const queryServicelist = (data : any) : Promise<Response<{count:number,list:Array<ServiceGoodsType>}>> => {
return post('Api/Service/GetPageList', {
data,
});

View File

@@ -0,0 +1,36 @@
import { authorize, showModal, openSetting } from './uni-promise';
interface AuthorizationParams {
scope : string;
modalTitle ?: string;
modalContent ?: string;
modalConfirmText ?: string;
}
export const handleAuthorize = async ({ scope, modalTitle = "温馨提示", modalContent = "如果您拒绝授权,将无法正常使用此功能", modalConfirmText = "去授权" } : AuthorizationParams) : Promise<boolean> => {
try {
/** 唤起授权 */
const authorizeRes = await authorize({
scope: `scope.${scope}`,
})
/** 接受授权 */
if (authorizeRes.errMsg === 'authorize:ok') {
return true;
}
} catch (res : any) {
/** 没有授权弹框提示-因为后续操作需要点击才能调用 */
const modalRes = await showModal({
title: modalTitle,
content: modalContent,
confirmText: modalConfirmText,
})
if (!modalRes.confirm) {
return false;
}
/** 打开授权设置面板 */
const openSetRes = await openSetting();
return openSetRes.authSetting[`scope.${scope}`]
}
}

View File

@@ -28,3 +28,6 @@ export * from './time-format';
/** 处理分享 */
export * from './handle-share';
/** 处理授权 */
export * from './handle-authorize';

View File

@@ -178,6 +178,15 @@ export const showToast = (options : UniNamespace.ShowToastOptions) : Promise<any
})
}
export const showModal = (options : UniNamespace.ShowModalOptions) : Promise<any> => {
return new Promise((success, fail) => {
uni.showModal({
...options,
success,
fail
});
})
}
export default {
@@ -197,5 +206,6 @@ export default {
getSetting,
openSetting,
authorize,
showToast
showToast,
showModal
}

View File

@@ -67,7 +67,7 @@
"path": "pages/order/submit/submit",
"style": {
"navigationBarTitleText": "订单提交",
"enablePullDownRefresh": false,
"enablePullDownRefresh": true,
"navigationStyle": "custom"
}
},

View File

@@ -5,7 +5,7 @@
"path": "pinTuan/list/list",
"style": {
"navigationBarTitleText": "拼团列表",
"enablePullDownRefresh": false,
"enablePullDownRefresh": true,
"navigationStyle": "custom"
}
},
@@ -21,7 +21,7 @@
"path": "seckill/list/list",
"style": {
"navigationBarTitleText": "秒杀列表",
"enablePullDownRefresh": false,
"enablePullDownRefresh": true,
"navigationStyle": "custom"
}
},
@@ -36,15 +36,15 @@
{
"path": "groupBuying/list/list",
"style": {
"navigationBarTitleText": "团列表",
"enablePullDownRefresh": false,
"navigationBarTitleText": "团列表",
"enablePullDownRefresh": true,
"navigationStyle": "custom"
}
},
{
"path": "groupBuying/detail/detail",
"style": {
"navigationBarTitleText": "团详情",
"navigationBarTitleText": "团详情",
"enablePullDownRefresh": true,
"navigationStyle": "custom"
}
@@ -53,7 +53,7 @@
"path": "solitaire/list/list",
"style": {
"navigationBarTitleText": "接龙列表",
"enablePullDownRefresh": false,
"enablePullDownRefresh": true,
"navigationStyle": "custom"
}
},

View File

@@ -5,15 +5,15 @@
"path": "list/list",
"style": {
"navigationBarTitleText": "服务商品",
"enablePullDownRefresh": false,
"enablePullDownRefresh": true,
"navigationStyle": "custom"
}
},
{
"path": "detail/detail",
"style": {
"navigationBarTitleText": "服务商品",
"enablePullDownRefresh": false,
"navigationBarTitleText": "服务商品详情",
"enablePullDownRefresh": true,
"navigationStyle": "custom"
}
}

View File

@@ -109,7 +109,7 @@
"path": "pages/order/submit/submit",
"style": {
"navigationBarTitleText": "订单提交",
"enablePullDownRefresh": false,
"enablePullDownRefresh": true,
"navigationStyle": "custom"
}
},
@@ -474,15 +474,15 @@
"path": "list/list",
"style": {
"navigationBarTitleText": "服务商品",
"enablePullDownRefresh": false,
"enablePullDownRefresh": true,
"navigationStyle": "custom"
}
},
{
"path": "detail/detail",
"style": {
"navigationBarTitleText": "服务商品",
"enablePullDownRefresh": false,
"navigationBarTitleText": "服务商品详情",
"enablePullDownRefresh": true,
"navigationStyle": "custom"
}
}
@@ -493,7 +493,7 @@
"path": "pinTuan/list/list",
"style": {
"navigationBarTitleText": "拼团列表",
"enablePullDownRefresh": false,
"enablePullDownRefresh": true,
"navigationStyle": "custom"
}
},
@@ -509,7 +509,7 @@
"path": "seckill/list/list",
"style": {
"navigationBarTitleText": "秒杀列表",
"enablePullDownRefresh": false,
"enablePullDownRefresh": true,
"navigationStyle": "custom"
}
},
@@ -524,15 +524,15 @@
{
"path": "groupBuying/list/list",
"style": {
"navigationBarTitleText": "团列表",
"enablePullDownRefresh": false,
"navigationBarTitleText": "团列表",
"enablePullDownRefresh": true,
"navigationStyle": "custom"
}
},
{
"path": "groupBuying/detail/detail",
"style": {
"navigationBarTitleText": "团详情",
"navigationBarTitleText": "团详情",
"enablePullDownRefresh": true,
"navigationStyle": "custom"
}
@@ -541,7 +541,7 @@
"path": "solitaire/list/list",
"style": {
"navigationBarTitleText": "接龙列表",
"enablePullDownRefresh": false,
"enablePullDownRefresh": true,
"navigationStyle": "custom"
}
},

View File

@@ -125,7 +125,7 @@
}
const hanldeClickViewMore = () => {
console.log('点击更多')
handleRouteNavigateTo('/pages/category/category')
}
const hanldeClickGoods = (data : any) => {

View File

@@ -211,6 +211,7 @@
getOrderStatusNum();
getUserInfo();
}
shopConfigStore.querySystemConfig();
});
/** 获取用户信息 */

View File

@@ -1,5 +1,5 @@
<template>
<coreshop-page title="订单提交" mode="left">
<coreshop-page title="订单提交" mode="left" needLoadingPage :loadingPage="loadingPage">
<view class="layout-order-box p-25 m-b-25">
<!-- 下单提醒 -->
<view class="remind-box">
@@ -236,7 +236,7 @@
</template>
<script setup lang="ts">
import { reactive, computed, ref } from 'vue';
import { onLoad, onShow } from '@dcloudio/uni-app';
import { onLoad, onShow, onPullDownRefresh } from '@dcloudio/uni-app';
import {
PaymentTypeEnum, OrderDistributionEnum, ShowStoresSwitchEnum,
OpenPointEnum, PointExchangeModelEnum, ShowPointExchangePriceEnum,
@@ -257,6 +257,11 @@
teamId ?: number;
}
interface CartListCallBack {
success : Function,
file : Function,
}
/** 获取项目配置 */
const shopConfigStore : ShopConfigStoreType = useShopConfigStore();
const state = reactive<{
@@ -310,8 +315,9 @@
});
const loading = ref(false);
const loadingPage = ref(true);
const handleSubmit = useLoadingFn(onSubmit, loading);
const handleGetOrderDetail = useLoadingFn(getOrderDetail, loadingPage);
/** 是否显示积分兑换价合计 */
const isShowPointRedemptionPrice = computed(() => {
return shopConfigStore.config.pointSwitch == OpenPointEnum.yes &&
@@ -381,6 +387,15 @@
if (query.teamId) {
state.teamId = query.teamId;
}
handleGetOrderDetail();
});
onPullDownRefresh(async () => {
await handleGetOrderDetail();
uni.stopPullDownRefresh();
});
async function getOrderDetail() {
/** 获取不同类型,营销下单支持的配送方式 */
await getOrderDistributionModel();
@@ -392,18 +407,11 @@
}
/** 获取用户默认地址 */
await getUserDefaultShip();
});
interface CartListCallBack {
success : Function,
file : Function,
}
/** 获取商品详情 */
const getCartList = async (data ?: CartListCallBack) => {
uni.showLoading({
title: '加载中'
});
state.params.receiptType = state.tabSelectType;
const cartList : Response<any> = await queryCartList({
@@ -414,7 +422,6 @@
couponCode: state.couponCodeList.length > 0 ? state.couponCodeList.join(',') : '',
});
if (cartList.status) {
uni.hideLoading();
state.cartData = cartList?.data;
/** 判断是否有库存 */
@@ -432,7 +439,6 @@
}
data?.success(cartList);
} else {
uni.hideLoading();
data?.file(cartList);
}
}

View File

@@ -70,7 +70,7 @@
import type { Response, UserInfoType } from '@/core/models';
import { onLoad } from '@dcloudio/uni-app';
import { UserToken } from '@/core/consts';
import { handleShowToast, handleStaticResources } from '@/core/utils';
import { handleShowToast, handleStaticResources, handleAuthorize } from '@/core/utils';
import { ShareEnum } from '@/core/enum';
import { queryUserInfo, queryActivityDetial, queryDistributionStoreInfo, queryAgentInfo, queryGoodsDetail, queryPinTuanGoodsDetail, queryServiceDetail } from '@/core/api';
import LPainter from '@/uni_modules/lime-painter/components/l-painter/l-painter.vue';
@@ -326,7 +326,7 @@
}
/** 保存到本地 */
const handlesavePoster = () => {
const handlesavePoster = async () => {
// #ifdef APP-PLUS || APP-PLUS-NVUE
uni.downloadFile({
url: state.imgSrc,
@@ -348,9 +348,8 @@
// #endif
// #ifdef MP
uni.authorize({
scope: 'scope.writePhotosAlbum',
success() {
let authorizeRes : boolean = await handleAuthorize({ scope: 'writePhotosAlbum' });
if (authorizeRes) {
uni.saveImageToPhotosAlbum({
filePath: state.imgSrc,
success() {
@@ -361,7 +360,6 @@
}
});
}
})
// #endif
}
</script>

View File

@@ -1,5 +1,5 @@
<template>
<coreshop-page title="团购" mode="left" bgColor="#D33123" titleColor="#fff">
<coreshop-page title="团购" mode="left" bgColor="#D33123" titleColor="#fff" needLoadingPage :loadingPage="loading">
<view class="layout-goods-box">
<view class="goods-box" v-if="state.list.length > 0">
<view class="card-box" v-for="item, index in state.list" :key="index">
@@ -55,11 +55,12 @@
</coreshop-page>
</template>
<script setup lang="ts">
import { reactive } from 'vue';
import { onLoad, onReachBottom } from '@dcloudio/uni-app';
import { reactive, ref } from 'vue';
import { onLoad, onReachBottom, onPullDownRefresh } from '@dcloudio/uni-app';
import { handleRouteNavigateTo } from '@/core/utils';
import { queryActivityList } from '@/core/api';
import { PaymentTypeEnum, IsStartSeckillEnum, EmptyEnum } from '@/core/enum';
import { useLoadingFn } from '@/core/hooks';
interface QueryParams {
id : number;
@@ -78,26 +79,29 @@
list: [],
});
onLoad((query : QueryParams) => {
getActivityList();
const loading = ref(true);
const handleQuerytActivityList = useLoadingFn(getActivityList, loading);
onLoad(() => {
handleQuerytActivityList();
})
onPullDownRefresh(async () => {
state.list = [];
await handleQuerytActivityList();
uni.stopPullDownRefresh();
});
/** 获取团购列表 */
const getActivityList = async () => {
uni.showLoading({
title: "加载中..."
})
async function getActivityList() {
const activityList = await queryActivityList({
page: state.page,
limit: state.limit,
type: PaymentTypeEnum.group,
status: IsStartSeckillEnum.start
});
state.totalPages = activityList.data?.totalPages;
state.list = state.list.concat(activityList.data?.list);
uni.hideLoading();
}
// 组合商品数据传入组件

View File

@@ -1,5 +1,6 @@
<template>
<coreshop-page title="拼团" titleColor="#fff" bgColor="rgba(0,0,0,0)" mode="left" :isShowStatusBarHeight="false">
<coreshop-page title="拼团" titleColor="#fff" bgColor="rgba(0,0,0,0)" mode="left" :isShowStatusBarHeight="false"
needLoadingPage :loadingPage="loading">
<view class="layout-pintuan-box" v-if="state.list.length > 0">
<view class="bg-box"></view>
<view class="content-box">
@@ -45,12 +46,13 @@
</coreshop-page>
</template>
<script setup lang="ts">
import { reactive, onMounted } from 'vue';
import { onReachBottom } from '@dcloudio/uni-app';
import { reactive, onMounted, ref } from 'vue';
import { onReachBottom, onPullDownRefresh } from '@dcloudio/uni-app';
import { queryPinTuanList } from '@/core/api';
import type { Response, PinTuanListType } from '@/core/models';
import { EmptyEnum } from '@/core/enum';
import { handleRouteNavigateTo } from '@/core/utils';
import { useLoadingFn } from '@/core/hooks';
const state = reactive<{
list : Array<PinTuanListType>;
@@ -64,16 +66,22 @@
noData: false,
})
const loading = ref(true);
const handleQuerytPinTuanList = useLoadingFn(getPinTuanList, loading);
onMounted(() => {
/** 获取拼团列表 */
getPinTuanList()
handleQuerytPinTuanList()
});
onPullDownRefresh(async () => {
state.list = [];
await handleQuerytPinTuanList();
uni.stopPullDownRefresh();
});
/** 获取拼团列表 */
const getPinTuanList = async () => {
uni.showLoading({
title: "加载中..."
})
async function getPinTuanList() {
const pinTuanList : Response<Array<PinTuanListType>> = await queryPinTuanList({
page: state.page,
limit: state.limit,
@@ -84,7 +92,6 @@
if (pinTuanList.data?.length > 0) {
state.list = state.list.concat(pinTuanList.data);
}
uni.hideLoading();
}
/** 组合商品数据传入组件 */

View File

@@ -1,5 +1,5 @@
<template>
<coreshop-page title="秒杀" mode="left" bgColor="#D33123" titleColor="#fff">
<coreshop-page title="秒杀" mode="left" bgColor="#D33123" titleColor="#fff" needLoadingPage :loadingPage="loading">
<view class="layout-seckill-box">
<view class="navbar-box" :style="{ 'top': `${statusBarHeight}px` }">
<image class="bg" :style="{ 'left': state.left }"
@@ -64,9 +64,9 @@
</coreshop-page>
</template>
<script setup lang="ts">
import { reactive } from 'vue';
import { onLoad, onReachBottom } from '@dcloudio/uni-app';
import { useSystemInfo } from '@/core/hooks';
import { reactive, ref } from 'vue';
import { onLoad, onReachBottom, onPullDownRefresh } from '@dcloudio/uni-app';
import { useLoadingFn, useSystemInfo } from '@/core/hooks';
import { handleStaticResources, handleRouteNavigateTo } from '@/core/utils';
import { queryActivityList } from '@/core/api';
import { PaymentTypeEnum, IsStartSeckillEnum, EmptyEnum } from '@/core/enum';
@@ -120,9 +120,17 @@
],
});
onLoad((query : QueryParams) => {
getActivityList();
})
const loading = ref(true);
const handleQuerytActivityList = useLoadingFn(getActivityList, loading);
onLoad(() => {
handleQuerytActivityList();
});
onPullDownRefresh(async () => {
state.list = [];
await handleQuerytActivityList();
uni.stopPullDownRefresh();
});
/** 切换tab */
const handleChangeTab = (item : ItabList) => {
@@ -130,15 +138,12 @@
state.tabStatus = item.status;
state.left = item.left;
state.list = [];
getActivityList();
handleQuerytActivityList();
}
}
/** 获取秒杀列表 */
const getActivityList = async () => {
uni.showLoading({
title: "加载中..."
})
async function getActivityList() {
const activityList = await queryActivityList({
page: state.page,
@@ -149,7 +154,6 @@
state.totalPages = activityList.data?.totalPages;
state.list = state.list.concat(activityList.data?.list);
uni.hideLoading();
}
// 组合商品数据传入组件

View File

@@ -1,5 +1,6 @@
<template>
<coreshop-page title="接龙" mode="left" bgColor="#D33123" titleColor="#fff" showLoginModalDom>
<coreshop-page title="接龙" mode="left" bgColor="#D33123" titleColor="#fff" showLoginModalDom needLoadingPage
:loadingPage="loading">
<view class="layout-solitaire-box">
<view class="config-box">
<image class="img" :src="shopConfigStore?.config?.shopLogo"></image>
@@ -44,13 +45,14 @@
</coreshop-page>
</template>
<script setup lang="ts">
import { reactive } from 'vue';
import { onLoad, onReachBottom } from '@dcloudio/uni-app';
import { reactive, ref } from 'vue';
import { onLoad, onReachBottom, onPullDownRefresh } from '@dcloudio/uni-app';
import { handleRouteNavigateTo } from '@/core/utils';
import { querySolitaireList } from '@/core/api';
import { EmptyEnum } from '@/core/enum';
import { useShopConfigStore, useLoginStore } from '@/core/store';
import { timeFormat } from '@/uni_modules/uv-ui-tools/libs/function/index.js';
import { useLoadingFn } from '@/core/hooks';
/** 获取项目配置 */
const shopConfigStore = useShopConfigStore();
@@ -72,15 +74,22 @@
noData: false,
});
const loading = ref(true);
const handleQuerytSolitaireList = useLoadingFn(getSolitaireList, loading);
onLoad(() => {
getSolitaireList();
})
handleQuerytSolitaireList();
});
onPullDownRefresh(async () => {
state.list = [];
await handleQuerytSolitaireList();
uni.stopPullDownRefresh();
});
/** 获取接龙列表 */
const getSolitaireList = async () => {
uni.showLoading({
title: "加载中..."
})
async function getSolitaireList() {
const activityList = await querySolitaireList({
page: state.page,
@@ -93,7 +102,6 @@
if (activityList.data?.length > 0) {
state.list = state.list.concat(activityList.data);
}
uni.hideLoading();
}
// 组合商品数据传入组件

View File

@@ -1,5 +1,6 @@
<template>
<coreshop-page bgColor="rgba(0,0,0,0)" :isShowStatusBarHeight="false" :placeholder="false" showLoginModalDom>
<coreshop-page bgColor="rgba(0,0,0,0)" :isShowStatusBarHeight="false" :placeholder="false" showLoginModalDom
needLoadingPage :loadingPage="loadingPage">
<view class="layout-goods-detail">
<GoodsDetail :goodsId="state.goodsDetailData?.id" :goodsDetailData="state.goodsDetailData"
:swiperBanner="state.swiperBanner" :goodsDetailContent="state.goodsDetailContent"
@@ -81,17 +82,18 @@
</coreshop-page>
</template>
<script setup lang="ts">
import { reactive } from 'vue';
import { onLoad ,onShareAppMessage,onShareTimeline} from '@dcloudio/uni-app';
import { reactive, ref } from 'vue';
import { onLoad, onShareAppMessage, onShareTimeline,onPullDownRefresh } from '@dcloudio/uni-app';
import type { Response, ServiceGoodsType } from '@/core/models';
import { queryServiceDetail, queryAddServiceOrder } from '@/core/api';
import { ServiceGoodsOpenEnum, ShareEnum, PaymentTypeEnum, ShareClientEnum, ShareModelEnum, } from '@/core/enum';
import { handleShowToast, handleRouteNavigateTo,getShareUrl } from '@/core/utils';
import { handleShowToast, handleRouteNavigateTo, getShareUrl } from '@/core/utils';
import { useLoginStore } from '@/core/store';
import { shareUrl } from '@/core/consts';
import GoodsDetail from '@/pages/components/goods-detail/index.vue';
import GoodsDetailRecommend from '@/pages/components/goods-detail/components/goods-detail-recommend/goods-detail-recommend.vue';
import GoodsDetailBottomTabbar from '@/pages/components/goods-detail/components/goods-detail-bottom-tabbar/goods-detail-bottom-tabbar.vue';
import { useLoadingFn } from '@/core/hooks';
interface QueryParams {
id : number;
@@ -105,22 +107,31 @@
goodsDetailData : ServiceGoodsType,
swiperBanner : Array<string>;
goodsDetailContent : string;
shareUrl:string;
shareUrl : string;
}>({
id: 0,
goodsDetailData: {},
swiperBanner: [],
goodsDetailContent: "",
shareUrl:"",
shareUrl: "",
});
const loadingPage = ref(true);
const handleGetGoodsDetail = useLoadingFn(getGoodsDetail, loadingPage);
onLoad((query : QueryParams) => {
state.id = query?.id;
/** 获取商品详情 */
getGoodsDetail();
})
handleGetGoodsDetail();
});
const getGoodsDetail = async () => {
onPullDownRefresh(async () => {
await handleGetGoodsDetail();
uni.stopPullDownRefresh();
});
async function getGoodsDetail() {
const goodsDetail : Response<ServiceGoodsType> = await queryServiceDetail({ id: state.id });
if (goodsDetail.status) {
state.goodsDetailData = {

View File

@@ -1,5 +1,5 @@
<template>
<coreshop-page title="服务商品" mode="left">
<coreshop-page title="服务商品" mode="left" needLoadingPage :loadingPage="loading">
<view class="layout-goods-box">
<view v-if="state.list.length > 0">
<view class="item-box" v-for="item, index in state.list" :key="item.id">
@@ -77,12 +77,13 @@
</coreshop-page>
</template>
<script setup lang="ts">
import { reactive } from 'vue';
import { onLoad, onReachBottom } from '@dcloudio/uni-app';
import { reactive, ref } from 'vue';
import { onLoad, onReachBottom, onPullDownRefresh } from '@dcloudio/uni-app';
import { queryServicelist } from '@/core/api';
import type { Response, ServiceGoodsType } from '@/core/models';
import { EmptyEnum, ServiceGoodsOpenEnum } from '@/core/enum';
import { handleRouteNavigateTo } from '@/core/utils';
import { useLoadingFn } from '@/core/hooks';
const state = reactive<{
list : Array<ServiceGoodsType>;
@@ -98,16 +99,23 @@
})
const loading = ref(true);
const handleQuerytServicelist = useLoadingFn(getServicelist, loading);
onLoad(() => {
getServicelist()
handleQuerytServicelist()
})
onPullDownRefresh(async () => {
state.list = [];
await handleQuerytServicelist();
uni.stopPullDownRefresh();
});
/** 获取服务商品列表 */
const getServicelist = async () => {
uni.showLoading({
title: "加载中..."
})
const servicelist : Response<Array<ServiceGoodsType>> = await queryServicelist({
async function getServicelist() {
const servicelist : Response<{ count : number, list : Array<ServiceGoodsType> }> = await queryServicelist({
page: state.page,
limit: state.limit
})
@@ -121,7 +129,6 @@
}
return item;
}));
uni.hideLoading();
}
onReachBottom(() => {