feat: 选品广场详情添加购买按钮
This commit is contained in:
@@ -16,7 +16,7 @@
|
|||||||
</view>
|
</view>
|
||||||
<view class="ai-button1 h_80 line80 w_200" @click="go"> 去结算 </view>
|
<view class="ai-button1 h_80 line80 w_200" @click="go"> 去结算 </view>
|
||||||
</view>
|
</view>
|
||||||
<uni-popup ref="popupRef" type="bottom" border-radius="10px 10px 0 0">
|
<uni-popup ref="popupRef" type="bottom" border-radius="10px 10px 0 0" @change="onPopupChange">
|
||||||
<view class="p-x-32 p-y-40 bg17">
|
<view class="p-x-32 p-y-40 bg17">
|
||||||
<view class="flex-center ju-between p-b-44">
|
<view class="flex-center ju-between p-b-44">
|
||||||
<view>已加购商品</view>
|
<view>已加购商品</view>
|
||||||
@@ -117,10 +117,10 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const popupSpacerHeight = computed(() => {
|
const safeAreaBottom = Number(uni.getSystemInfoSync()?.safeAreaInsets?.bottom || 0);
|
||||||
const deltaPx = uni.upx2px(30);
|
const popupOpened = ref(false);
|
||||||
return Math.max(0, (Number(props.bottomOffset) || 0) - deltaPx);
|
const popupBottomInsetPx = ref(0);
|
||||||
});
|
const popupSpacerHeight = computed(() => Math.max(0, Number(popupBottomInsetPx.value) || 0));
|
||||||
const cartList = ref([]);
|
const cartList = ref([]);
|
||||||
let price = ref(0);
|
let price = ref(0);
|
||||||
let num = ref(0);
|
let num = ref(0);
|
||||||
@@ -155,15 +155,38 @@
|
|||||||
getCartList();
|
getCartList();
|
||||||
});
|
});
|
||||||
let popupRef = ref(null);
|
let popupRef = ref(null);
|
||||||
|
const resolvePopupBottomInsetPx = () => {
|
||||||
|
return Math.max(0, (Number(props.bottomOffset) || 0) - safeAreaBottom);
|
||||||
|
};
|
||||||
|
const onPopupChange = (e: any) => {
|
||||||
|
popupOpened.value = !!e?.show;
|
||||||
|
if (popupOpened.value) {
|
||||||
|
popupBottomInsetPx.value = resolvePopupBottomInsetPx();
|
||||||
|
} else {
|
||||||
|
popupBottomInsetPx.value = 0;
|
||||||
|
}
|
||||||
|
};
|
||||||
const showPopup = () => {
|
const showPopup = () => {
|
||||||
if (!popupRef.value) return;
|
if (!popupRef.value) return;
|
||||||
|
|
||||||
|
popupOpened.value = true;
|
||||||
|
popupBottomInsetPx.value = resolvePopupBottomInsetPx();
|
||||||
popupRef.value.open('bottom');
|
popupRef.value.open('bottom');
|
||||||
};
|
};
|
||||||
const hidePopup = () => {
|
const hidePopup = () => {
|
||||||
|
popupOpened.value = false;
|
||||||
|
popupBottomInsetPx.value = 0;
|
||||||
popupRef.value.close();
|
popupRef.value.close();
|
||||||
};
|
};
|
||||||
onMounted(() => { });
|
onMounted(() => { });
|
||||||
|
watch(
|
||||||
|
() => cartList.value?.length,
|
||||||
|
(len) => {
|
||||||
|
if (popupOpened.value && (!len || len <= 0)) {
|
||||||
|
hidePopup();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
//#region 选择规格弹窗
|
//#region 选择规格弹窗
|
||||||
let showSelectSku = ref(false);
|
let showSelectSku = ref(false);
|
||||||
let goodsInfo = ref({});
|
let goodsInfo = ref({});
|
||||||
|
|||||||
+2
-2
@@ -2,8 +2,8 @@
|
|||||||
"name" : "优购商城",
|
"name" : "优购商城",
|
||||||
"appid" : "__UNI__8B19741",
|
"appid" : "__UNI__8B19741",
|
||||||
"description" : "",
|
"description" : "",
|
||||||
"versionName" : "1.4.6",
|
"versionName" : "1.4.7",
|
||||||
"versionCode" : 146,
|
"versionCode" : 147,
|
||||||
"transformPx" : false,
|
"transformPx" : false,
|
||||||
"app-plus" : {
|
"app-plus" : {
|
||||||
"privacy" : {
|
"privacy" : {
|
||||||
|
|||||||
+30
-3
@@ -68,14 +68,21 @@
|
|||||||
<detail-content-card class="detail-content-selector" :content="state.goodsInfo.description" />
|
<detail-content-card class="detail-content-selector" :content="state.goodsInfo.description" />
|
||||||
</view>
|
</view>
|
||||||
</block>
|
</block>
|
||||||
<view class="theme-ai">
|
<view class="theme-ai" v-if="state.goodsInfo && state.goodsInfo.id">
|
||||||
<card_payment ref="paymentRef" source="orderInfo" :actionStatus="timeText" @addCar="addCar" />
|
<card_payment ref="paymentRef" source="orderInfo" :actionStatus="timeText" :bottomOffset="paymentBottomOffset"
|
||||||
|
@addCar="addCar" @updatePrice="updatePrice" />
|
||||||
</view>
|
</view>
|
||||||
|
<su-fixed bottom placeholder bg="bg24" :zIndex="1"
|
||||||
|
v-if="state.goodsInfo && state.goodsInfo.id && !hasCartItems">
|
||||||
|
<view class="buy-now-bar bg24">
|
||||||
|
<view class="ai-button1 buy-now-btn" @tap="addCar">立即购买</view>
|
||||||
|
</view>
|
||||||
|
</su-fixed>
|
||||||
</view>
|
</view>
|
||||||
</s-layout>
|
</s-layout>
|
||||||
</template>
|
</template>
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, reactive, onMounted, onUnmounted, getCurrentInstance, watch, nextTick } from 'vue';
|
import { computed, ref, reactive, onMounted, onUnmounted, getCurrentInstance, watch, nextTick } from 'vue';
|
||||||
import { onLoad, onPageScroll } from '@dcloudio/uni-app';
|
import { onLoad, onPageScroll } from '@dcloudio/uni-app';
|
||||||
import sheep from '@/sheep';
|
import sheep from '@/sheep';
|
||||||
// import { onPageScroll} from '@dcloudio/uni-app';
|
// import { onPageScroll} from '@dcloudio/uni-app';
|
||||||
@@ -114,6 +121,7 @@ const getInfo = async () => {
|
|||||||
};
|
};
|
||||||
let id = ref();
|
let id = ref();
|
||||||
let shoppingPlazaId = ref();
|
let shoppingPlazaId = ref();
|
||||||
|
const hasCartItems = ref(false);
|
||||||
onLoad(async (options) => {
|
onLoad(async (options) => {
|
||||||
// 滚到顶部
|
// 滚到顶部
|
||||||
uni.pageScrollTo({
|
uni.pageScrollTo({
|
||||||
@@ -130,6 +138,9 @@ function onSkuChange(e) {
|
|||||||
const onAddCart = () => { };
|
const onAddCart = () => { };
|
||||||
const onBuy = () => { };
|
const onBuy = () => { };
|
||||||
let paymentRef = ref(null);
|
let paymentRef = ref(null);
|
||||||
|
const updatePrice = (val) => {
|
||||||
|
hasCartItems.value = !!val;
|
||||||
|
};
|
||||||
const addCar = () => {
|
const addCar = () => {
|
||||||
paymentRef.value.addCar({ ...state.goodsInfo, shoppingPlazaId: shoppingPlazaId.value });
|
paymentRef.value.addCar({ ...state.goodsInfo, shoppingPlazaId: shoppingPlazaId.value });
|
||||||
};
|
};
|
||||||
@@ -187,6 +198,9 @@ let sysInfo = uni.getSystemInfoSync();
|
|||||||
const windowHeight = sysInfo.windowHeight;
|
const windowHeight = sysInfo.windowHeight;
|
||||||
let height = ref(0);
|
let height = ref(0);
|
||||||
height.value = sysInfo.statusBarHeight + uni.upx2px(88);
|
height.value = sysInfo.statusBarHeight + uni.upx2px(88);
|
||||||
|
const buyBarOffset =
|
||||||
|
uni.upx2px(120) + Number(sheep?.$platform?.device?.safeAreaInsets?.bottom || 0);
|
||||||
|
const paymentBottomOffset = computed(() => (hasCartItems.value ? 0 : buyBarOffset));
|
||||||
</script>
|
</script>
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.detail-card {
|
.detail-card {
|
||||||
@@ -457,6 +471,19 @@ height.value = sysInfo.statusBarHeight + uni.upx2px(88);
|
|||||||
left: 0;
|
left: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.buy-now-bar {
|
||||||
|
height: 120rpx;
|
||||||
|
padding: 20rpx 32rpx;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
.buy-now-btn {
|
||||||
|
width: 100%;
|
||||||
|
height: 80rpx;
|
||||||
|
line-height: 80rpx;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
:deep(.uni-countdown__number) {
|
:deep(.uni-countdown__number) {
|
||||||
font-size: 24rpx !important;
|
font-size: 24rpx !important;
|
||||||
width: 40rpx !important;
|
width: 40rpx !important;
|
||||||
|
|||||||
@@ -330,7 +330,7 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
const system = uni.getSystemInfoSync();
|
const system = uni.getSystemInfoSync();
|
||||||
const tabbarBottomOffset = uni.upx2px(100);
|
const tabbarBottomOffset = uni.upx2px(100) + Number(system.safeAreaInsets?.bottom || 0);
|
||||||
const paymentBarReserve = uni.upx2px(148);
|
const paymentBarReserve = uni.upx2px(148);
|
||||||
const baseHeight =
|
const baseHeight =
|
||||||
system.windowHeight -
|
system.windowHeight -
|
||||||
|
|||||||
Reference in New Issue
Block a user