【代码优化】代码格式化

pull/91/head
卢越 2024-09-05 12:40:53 +08:00
parent b6dd2ae1eb
commit 75e7e58b8d
5 changed files with 42 additions and 32 deletions

View File

@ -1,7 +1,12 @@
<template> <template>
<s-layout title="选择自提门店" :bgStyle="{ color: '#FFF' }"> <s-layout title="选择自提门店" :bgStyle="{ color: '#FFF' }">
<view class="storeBox" ref="container"> <view class="storeBox" ref="container">
<view class="storeBox-box" v-for="(item, index) in state.storeList" :key="index" @tap="checked(item)"> <view
class="storeBox-box"
v-for="(item, index) in state.storeList"
:key="index"
@tap="checked(item)"
>
<view class="store-img"> <view class="store-img">
<image :src="item.logo" class="img" /> <image :src="item.logo" class="img" />
</view> </view>
@ -33,7 +38,9 @@
<!-- #endif --> <!-- #endif -->
</view> </view>
<view class="store-distance ss-flex ss-row-center" @tap.stop="showMaoLocation(item)"> <view class="store-distance ss-flex ss-row-center" @tap.stop="showMaoLocation(item)">
<text class="addressTxt" v-if="item.distance">{{ item.distance.toFixed(2) }}</text> <text class="addressTxt" v-if="item.distance"
>距离{{ item.distance.toFixed(2) }}千米</text
>
<text class="addressTxt" v-else></text> <text class="addressTxt" v-else></text>
<view class="iconfont"> <view class="iconfont">
<view class="ss-rest-button"> <view class="ss-rest-button">
@ -112,7 +119,7 @@
latitude: Number(e.latitude), latitude: Number(e.latitude),
longitude: Number(e.longitude), longitude: Number(e.longitude),
name: e.name, name: e.name,
address: `${e.areaName}-${e.detailAddress}` address: `${e.areaName}-${e.detailAddress}`,
}); });
} else { } else {
// #endif // #endif
@ -172,7 +179,7 @@
state.user_latitude = uni.getStorageSync(LATITUDE); state.user_latitude = uni.getStorageSync(LATITUDE);
state.user_longitude = uni.getStorageSync(LONGITUDE); state.user_longitude = uni.getStorageSync(LONGITUDE);
} catch (e) { } catch (e) {
console.error(e) console.error(e);
} }
}); });
</script> </script>
@ -180,7 +187,7 @@
.line1 { .line1 {
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
white-space: nowrap white-space: nowrap;
} }
.geoPage { .geoPage {

View File

@ -37,7 +37,7 @@ const CombinationApi = {
url: '/promotion/combination-activity/detail-list', url: '/promotion/combination-activity/detail-list',
method: 'GET', method: 'GET',
params: { params: {
ids ids,
}, },
}); });
}, },
@ -58,9 +58,9 @@ const CombinationApi = {
// 获得我的拼团记录分页 // 获得我的拼团记录分页
getCombinationRecordPage: (params) => { getCombinationRecordPage: (params) => {
return request({ return request({
url: "/promotion/combination-record/page", url: '/promotion/combination-record/page',
method: 'GET', method: 'GET',
params params,
}); });
}, },

View File

@ -3,7 +3,10 @@
<!-- 商品卡片 --> <!-- 商品卡片 -->
<view> <view>
<!-- 布局1. 单列大图上图下内容--> <!-- 布局1. 单列大图上图下内容-->
<view v-if="layoutType === LayoutTypeEnum.ONE_COL_BIG_IMG && state.goodsList.length" class="goods-sl-box"> <view
v-if="layoutType === LayoutTypeEnum.ONE_COL_BIG_IMG && state.goodsList.length"
class="goods-sl-box"
>
<view <view
class="goods-box" class="goods-box"
v-for="item in state.goodsList" v-for="item in state.goodsList"
@ -100,7 +103,10 @@
</view> </view>
<!-- 布局3. 单列小图左图右内容 --> <!-- 布局3. 单列小图左图右内容 -->
<view v-if="layoutType === LayoutTypeEnum.ONE_COL_SMALL_IMG && state.goodsList.length" class="goods-lg-box"> <view
v-if="layoutType === LayoutTypeEnum.ONE_COL_SMALL_IMG && state.goodsList.length"
class="goods-lg-box"
>
<view <view
class="goods-box" class="goods-box"
:style="[{ marginBottom: data.space + 'px' }]" :style="[{ marginBottom: data.space + 'px' }]"
@ -157,11 +163,11 @@
const props = defineProps({ const props = defineProps({
data: { data: {
type: Object, type: Object,
default: () => ({}) default: () => ({}),
}, },
styles: { styles: {
type: Object, type: Object,
default: () => ({}) default: () => ({}),
}, },
}); });

View File

@ -3,7 +3,10 @@
<!-- 商品卡片 --> <!-- 商品卡片 -->
<view> <view>
<!-- 布局1. 单列大图上图下内容--> <!-- 布局1. 单列大图上图下内容-->
<view v-if="layoutType === LayoutTypeEnum.ONE_COL_BIG_IMG && state.spuList.length" class="goods-sl-box"> <view
v-if="layoutType === LayoutTypeEnum.ONE_COL_BIG_IMG && state.spuList.length"
class="goods-sl-box"
>
<view <view
class="goods-box" class="goods-box"
v-for="item in state.spuList" v-for="item in state.spuList"
@ -100,7 +103,10 @@
</view> </view>
<!-- 布局3. 单列小图左图右内容 --> <!-- 布局3. 单列小图左图右内容 -->
<view v-if="layoutType === LayoutTypeEnum.ONE_COL_SMALL_IMG && state.spuList.length" class="goods-lg-box"> <view
v-if="layoutType === LayoutTypeEnum.ONE_COL_SMALL_IMG && state.spuList.length"
class="goods-lg-box"
>
<view <view
class="goods-box" class="goods-box"
:style="[{ marginBottom: data.space + 'px' }]" :style="[{ marginBottom: data.space + 'px' }]"
@ -135,12 +141,7 @@
/** /**
* 商品卡片 * 商品卡片
*/ */
import { import { computed, onMounted, reactive, ref } from 'vue';
computed,
onMounted,
reactive,
ref,
} from 'vue';
import sheep from '@/sheep'; import sheep from '@/sheep';
import CombinationApi from '@/sheep/api/promotion/combination'; import CombinationApi from '@/sheep/api/promotion/combination';
import SpuApi from '@/sheep/api/product/spu'; import SpuApi from '@/sheep/api/product/spu';
@ -164,13 +165,11 @@
const props = defineProps({ const props = defineProps({
data: { data: {
type: Object, type: Object,
default() { default() {},
},
}, },
styles: { styles: {
type: Object, type: Object,
default() { default() {},
},
}, },
}); });
@ -247,7 +246,6 @@
return spu; return spu;
} }
// //
onMounted(async () => { onMounted(async () => {
// //
@ -257,15 +255,14 @@
state.spuList.push(await getSpuDetail(activity.spuId)); state.spuList.push(await getSpuDetail(activity.spuId));
} }
// //
activityList.forEach(activity => { activityList.forEach((activity) => {
// //
activity.products.forEach(product => { activity.products.forEach((product) => {
const combinationPrice = product.combinationPrice || Infinity; const combinationPrice = product.combinationPrice || Infinity;
// spu // spu
const spu = state.spuList.find(spu => activity.spuId === spu.id); const spu = state.spuList.find((spu) => activity.spuId === spu.id);
if (spu) { if (spu) {
spu.price = Math.min(combinationPrice, spu.price || Infinity); spu.price = Math.min(combinationPrice, spu.price || Infinity);
} }