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', { return post('Api/Service/GetPageList', {
data, 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-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 { export default {
@@ -197,5 +206,6 @@ export default {
getSetting, getSetting,
openSetting, openSetting,
authorize, authorize,
showToast showToast,
showModal
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -70,7 +70,7 @@
import type { Response, UserInfoType } from '@/core/models'; import type { Response, UserInfoType } from '@/core/models';
import { onLoad } from '@dcloudio/uni-app'; import { onLoad } from '@dcloudio/uni-app';
import { UserToken } from '@/core/consts'; import { UserToken } from '@/core/consts';
import { handleShowToast, handleStaticResources } from '@/core/utils'; import { handleShowToast, handleStaticResources, handleAuthorize } from '@/core/utils';
import { ShareEnum } from '@/core/enum'; import { ShareEnum } from '@/core/enum';
import { queryUserInfo, queryActivityDetial, queryDistributionStoreInfo, queryAgentInfo, queryGoodsDetail, queryPinTuanGoodsDetail, queryServiceDetail } from '@/core/api'; import { queryUserInfo, queryActivityDetial, queryDistributionStoreInfo, queryAgentInfo, queryGoodsDetail, queryPinTuanGoodsDetail, queryServiceDetail } from '@/core/api';
import LPainter from '@/uni_modules/lime-painter/components/l-painter/l-painter.vue'; 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 // #ifdef APP-PLUS || APP-PLUS-NVUE
uni.downloadFile({ uni.downloadFile({
url: state.imgSrc, url: state.imgSrc,
@@ -348,20 +348,18 @@
// #endif // #endif
// #ifdef MP // #ifdef MP
uni.authorize({ let authorizeRes : boolean = await handleAuthorize({ scope: 'writePhotosAlbum' });
scope: 'scope.writePhotosAlbum', if (authorizeRes) {
success() { uni.saveImageToPhotosAlbum({
uni.saveImageToPhotosAlbum({ filePath: state.imgSrc,
filePath: state.imgSrc, success() {
success() { handleShowToast('保存成功', 'success');
handleShowToast('保存成功', 'success'); },
}, fail() {
fail() { handleShowToast('图片保存失败', 'error');
handleShowToast('图片保存失败', 'error'); }
} });
}); }
}
})
// #endif // #endif
} }
</script> </script>

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,5 +1,6 @@
<template> <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"> <view class="layout-goods-detail">
<GoodsDetail :goodsId="state.goodsDetailData?.id" :goodsDetailData="state.goodsDetailData" <GoodsDetail :goodsId="state.goodsDetailData?.id" :goodsDetailData="state.goodsDetailData"
:swiperBanner="state.swiperBanner" :goodsDetailContent="state.goodsDetailContent" :swiperBanner="state.swiperBanner" :goodsDetailContent="state.goodsDetailContent"
@@ -81,17 +82,18 @@
</coreshop-page> </coreshop-page>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { reactive } from 'vue'; import { reactive, ref } from 'vue';
import { onLoad ,onShareAppMessage,onShareTimeline} from '@dcloudio/uni-app'; import { onLoad, onShareAppMessage, onShareTimeline,onPullDownRefresh } from '@dcloudio/uni-app';
import type { Response, ServiceGoodsType } from '@/core/models'; import type { Response, ServiceGoodsType } from '@/core/models';
import { queryServiceDetail, queryAddServiceOrder } from '@/core/api'; import { queryServiceDetail, queryAddServiceOrder } from '@/core/api';
import { ServiceGoodsOpenEnum, ShareEnum, PaymentTypeEnum, ShareClientEnum, ShareModelEnum, } from '@/core/enum'; 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 { useLoginStore } from '@/core/store';
import { shareUrl } from '@/core/consts'; import { shareUrl } from '@/core/consts';
import GoodsDetail from '@/pages/components/goods-detail/index.vue'; 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 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 GoodsDetailBottomTabbar from '@/pages/components/goods-detail/components/goods-detail-bottom-tabbar/goods-detail-bottom-tabbar.vue';
import { useLoadingFn } from '@/core/hooks';
interface QueryParams { interface QueryParams {
id : number; id : number;
@@ -105,22 +107,31 @@
goodsDetailData : ServiceGoodsType, goodsDetailData : ServiceGoodsType,
swiperBanner : Array<string>; swiperBanner : Array<string>;
goodsDetailContent : string; goodsDetailContent : string;
shareUrl:string; shareUrl : string;
}>({ }>({
id: 0, id: 0,
goodsDetailData: {}, goodsDetailData: {},
swiperBanner: [], swiperBanner: [],
goodsDetailContent: "", goodsDetailContent: "",
shareUrl:"", shareUrl: "",
}); });
const loadingPage = ref(true);
const handleGetGoodsDetail = useLoadingFn(getGoodsDetail, loadingPage);
onLoad((query : QueryParams) => { onLoad((query : QueryParams) => {
state.id = query?.id; 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 }); const goodsDetail : Response<ServiceGoodsType> = await queryServiceDetail({ id: state.id });
if (goodsDetail.status) { if (goodsDetail.status) {
state.goodsDetailData = { state.goodsDetailData = {

View File

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