You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
177 lines
3.9 KiB
177 lines
3.9 KiB
<script setup>
|
|
import { onLoad, onShow } from "@dcloudio/uni-app";
|
|
import { ref } from "vue";
|
|
import customTabBar from "@/components/custom-tab-bar/my-tab-bar.vue";
|
|
import navv from "@/components/nav/nav.vue";
|
|
import topTitle from "@/components/topTitle/topTitle.vue";
|
|
import { getMyAreaApi, getUserInfoApi } from "@/libs/api";
|
|
|
|
/**
|
|
* 选择收货地址
|
|
*/
|
|
const selectAddress = ref({});
|
|
/**
|
|
* 购物车是否完成
|
|
*/
|
|
const finished = ref(false);
|
|
/**
|
|
* 购物车列表
|
|
*/
|
|
const cartLists = ref([]);
|
|
|
|
/**
|
|
* 点击选择收货地址
|
|
*/
|
|
function onGoSelectAddress() { }
|
|
|
|
/**
|
|
* 点击管理购物车
|
|
*/
|
|
function onManageCart() { }
|
|
|
|
/**
|
|
* 获取仓库列表数据
|
|
*/
|
|
async function getMyArea() {
|
|
const res = await getMyAreaApi({
|
|
warehouseid: "",
|
|
isEnabled: 1,
|
|
});
|
|
if (res.code !== "0")
|
|
return;
|
|
if (!res.data.login) {
|
|
uni.navigateTo({
|
|
url: "/pages/login/login",
|
|
});
|
|
return;
|
|
}
|
|
if (!res.data.list.length) {
|
|
uni.showModal({
|
|
// title: '提示',
|
|
content: "请先添加收货地址",
|
|
confirmColor: "#3aa24b",
|
|
confirmText: "去添加",
|
|
success(res) {
|
|
if (res.confirm) {
|
|
uni.navigateTo({
|
|
// url: "../../address/pages/addressLists/addressLists",
|
|
});
|
|
}
|
|
},
|
|
});
|
|
return;
|
|
}
|
|
// each 就是找到有 isLastDefaultAddr,没有就那第一个 isDefault 最大值
|
|
res.data.list = res.data.list.sort((a, b) => Number(b.isDefault) - Number(a.isDefault));
|
|
selectAddress.value = res.data.list.find(each => each.isLastDefaultAddr) || res.data.list[0];
|
|
uni.setStorageSync("warehousId", selectAddress.value.warehousId);
|
|
uni.setStorageSync("addressId", selectAddress.value.addrId);
|
|
}
|
|
|
|
/**
|
|
* 获取用户信息
|
|
*/
|
|
async function getUserInfo() {
|
|
const res = await getUserInfoApi();
|
|
if (res.code === "0") {
|
|
if (!res.data.company) {
|
|
uni.showModal({
|
|
title: "提示",
|
|
content: "请先添加企业",
|
|
complete: (res) => {
|
|
if (res.confirm) {
|
|
// uni.navigateTo({
|
|
// url: "../../enterprise/pages/joinEnterprise/joinEnterprise",
|
|
// });
|
|
}
|
|
},
|
|
});
|
|
}
|
|
getMyArea();
|
|
}
|
|
else if (res.code === "4") {
|
|
cartLists.value = [];
|
|
uni.showModal({
|
|
title: "提示",
|
|
content: "请先登录",
|
|
complete: (res) => {
|
|
if (res.confirm) {
|
|
uni.navigateTo({
|
|
url: "/pages/login/login",
|
|
});
|
|
}
|
|
},
|
|
});
|
|
}
|
|
}
|
|
|
|
onShow(() => {
|
|
finished.value = true;
|
|
// isOne.value = true;
|
|
// cartList.value = [];
|
|
// inShow.value = true;
|
|
getUserInfo();
|
|
});
|
|
|
|
onLoad(() => {
|
|
// #ifdef APP
|
|
uni.hideTabBar();
|
|
// #endif
|
|
});
|
|
</script>
|
|
|
|
<template>
|
|
<navv>
|
|
<template #default="{ content, fixStyle }">
|
|
<topTitle
|
|
title="购物车"
|
|
:style="{ ...fixStyle, backgroundColor: '#fff', position: 'static' }"
|
|
/>
|
|
|
|
<!-- 收获地址 -->
|
|
<view class="address">
|
|
<view class="left" @click="onGoSelectAddress">
|
|
<text class="iconfont icon-positioning" />
|
|
<text class="name">
|
|
{{ selectAddress.street }}
|
|
</text>
|
|
<text class="iconfont icon-right" />
|
|
</view>
|
|
<view class="right" @click="onManageCart">
|
|
{{ finished ? '编辑' : '完成' }}
|
|
</view>
|
|
</view>
|
|
|
|
<!-- 列表 -->
|
|
<view :style="{ 'height': `${content}px`, 'overflow-y': 'auto' }" />
|
|
|
|
<customTabBar tab-index="3" />
|
|
</template>
|
|
</navv>
|
|
</template>
|
|
|
|
<style lang="scss" scoped>
|
|
:deep(.left .icon-back) {
|
|
display: none;
|
|
}
|
|
.address {
|
|
padding: 17rpx 0 33rpx 0;
|
|
margin: 0 29rpx 0 33rpx;
|
|
background: #FFFFFF;
|
|
display: flex;
|
|
align-items: center;
|
|
|
|
.left {
|
|
display: flex;
|
|
align-items: center;
|
|
flex: 1;
|
|
margin-right: 15rpx;
|
|
.name {
|
|
margin-left: 15rpx;
|
|
font-weight: bold;
|
|
font-size: $text-lg;
|
|
color: #333333;
|
|
}
|
|
}
|
|
}
|
|
</style>
|