158 lines
4.9 KiB
Vue
158 lines
4.9 KiB
Vue
<template>
|
|
<s-pages title="确认订单" :pink_bg="true">
|
|
<view class="p-b-132">
|
|
<AddressSelection v-model="addressState" theme="2" @getSettlementInfo="getSettlementInfo" />
|
|
<view class="p-x-32 m-t-24">
|
|
<view class="bg24 p-x-20 p-t-20 radius16">
|
|
<view v-if="settlementInfo.items && settlementInfo.items.length">
|
|
<view class="m-b-24" v-for="(v, i) in settlementInfo.items" :key="i">
|
|
<aiOrder :data="v" :source="3" idName="spuId"/>
|
|
</view>
|
|
</view>
|
|
<view class="flex-row ju-between m-b-36">
|
|
<view class="c25 size28">商品金额</view>
|
|
<view>¥{{ $fen2yuan(settlementInfo?.price?.payPrice || 0) }}</view>
|
|
</view>
|
|
<view class="flex-row ju-between m-b-36">
|
|
<view class="c25 size28">运费</view>
|
|
<view>¥{{ $fen2yuan(settlementInfo?.price?.deliveryPrice || 0) }}</view>
|
|
</view>
|
|
<view class="flex-center ju-flex-end borderTop">
|
|
<span class="size26 line96">合计: </span>
|
|
<span class="c13 size28 m-l-12 line96 weight900"
|
|
>¥{{ $fen2yuan(settlementInfo?.price?.payPrice || 0) }}</span
|
|
>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
<view class="p-x-32 btn">
|
|
<view class="ai-button2" @click="sub">确认订单</view>
|
|
</view>
|
|
</s-pages>
|
|
</template>
|
|
<script setup lang="ts">
|
|
import { ref, reactive, onMounted, onUnmounted, getCurrentInstance, watch, nextTick } from 'vue';
|
|
import AddressSelection from '@/pages/order/addressSelection.vue';
|
|
import { onLoad } from '@dcloudio/uni-app';
|
|
import aiOrder from '@/components/ai_order/ai_order';
|
|
import api from '@/sheep/api/member/address';
|
|
let { proxy } = getCurrentInstance();
|
|
import * as SpuApi from '@/sheep/api/ai/index';
|
|
|
|
const addressState = ref({
|
|
addressInfo: {}, // 选择的收货地址
|
|
deliveryType: 1, // 收货方式:1-快递配送,2-门店自提
|
|
isPickUp: false, // 门店自提是否开启
|
|
pickUpInfo: {}, // 选择的自提门店信息
|
|
receiverName: '', // 收件人名称
|
|
receiverMobile: '', // 收件人手机
|
|
});
|
|
|
|
const cartList = ref([]);
|
|
const getCartList = () => {
|
|
SpuApi.getShopCartList({}).then((res) => {
|
|
let list = res.data || [];
|
|
if (list.length) {
|
|
list.forEach((e) => {
|
|
e.skuArr = JSON.parse(e.specification);
|
|
});
|
|
}
|
|
cartList.value = list;
|
|
});
|
|
};
|
|
// 获取订单结算信息
|
|
const settlementInfo = ref({});
|
|
let addressId = ref('');
|
|
const getSettlementInfo = (id = '') => {
|
|
addressId.value = id;
|
|
SpuApi.getSettlementInfo({
|
|
id: id,
|
|
}).then((res) => {
|
|
settlementInfo.value = res.data || {};
|
|
|
|
// if (proxy.$fen2yuan(settlementInfo?.price?.payPrice || 0) >= 5000) {
|
|
// proxy.utils.toast('订单金额不能超过5000元');
|
|
// }
|
|
if (settlementInfo.value?.items?.length) {
|
|
settlementInfo.value.items.forEach((e) => {
|
|
e.skuArr = e.items;
|
|
e.skuArr.forEach((item) => {
|
|
item.propertyText = '';
|
|
item.properties.forEach((e1) => {
|
|
item.propertyText += e1.valueName + ' ';
|
|
});
|
|
});
|
|
});
|
|
}
|
|
});
|
|
};
|
|
const sub = async () => {
|
|
// if (proxy.$fen2yuan(settlementInfo?.price?.payPrice || 0) >= 5000) {
|
|
// proxy.utils.toast('订单金额不能超过5000元, 请重新选择商品');
|
|
// return;
|
|
// }
|
|
if (!addressId.value) return proxy.utils.toast('请选择地址');
|
|
let res: any = await SpuApi.createOrder({ id: addressId.value });
|
|
if (res.code === 0) {
|
|
proxy.utils.toast('下单成功');
|
|
setTimeout(() => {
|
|
// proxy.utils.go('/pages/AI/cashierDesk', {
|
|
// id: res.data.id,
|
|
// payOrderId: res.data.payOrderId,
|
|
// });
|
|
uni.redirectTo({
|
|
url:
|
|
'/pages/AI/cashierDesk?id=' +
|
|
res.data.id +
|
|
'&payOrderId=' +
|
|
res.data.payOrderId +
|
|
'&from=aiStore',
|
|
});
|
|
}, 1000);
|
|
} else {
|
|
}
|
|
};
|
|
const getAddress = () => {
|
|
api.getAddressList().then((res) => {
|
|
if (res.code === 0 && res.data?.length) {
|
|
// addressState.value.addressInfo = res.data[0];
|
|
// getSettlementInfo(res.data[0].id);
|
|
let index = res.data.findIndex((e) => e.defaultStatus);
|
|
if (index !== -1) {
|
|
addressState.value.addressInfo = res.data[index];
|
|
getSettlementInfo(res.data[index].id);
|
|
} else {
|
|
getSettlementInfo();
|
|
}
|
|
} else {
|
|
getSettlementInfo();
|
|
}
|
|
});
|
|
};
|
|
onLoad(() => {
|
|
// getCartList();
|
|
getAddress();
|
|
});
|
|
</script>
|
|
<style lang="scss" scoped>
|
|
.pages {
|
|
}
|
|
|
|
.bottom {
|
|
}
|
|
|
|
.borderTop {
|
|
border-top: 1px solid #d4d4d4;
|
|
}
|
|
|
|
.btn {
|
|
width: 100%;
|
|
position: fixed;
|
|
bottom: 0rpx;
|
|
padding-top: 10rpx;
|
|
padding-bottom: 20rpx;
|
|
// background: #03011d;
|
|
}
|
|
</style>
|