wip: 4.0
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2024-05-16 14:27:57 +08:00
parent b09c1d9537
commit 8f3b158032
72 changed files with 3931 additions and 2161 deletions

View File

@@ -1,11 +1,11 @@
<script setup lang="ts">
import { ref } from "vue";
import Taro from "@tarojs/taro";
import { addCart, getCart, clearCart } from "@/api/cart";
import { Del2 } from "@nutui/icons-vue-taro";
import { createActiveOrder } from "@/api/goods";
import { createAfterOrder, getUserPoint } from "@/api/admin";
import Pay from "@/components/Pay.vue";
import {ref} from 'vue';
import Taro from '@tarojs/taro';
import {addCart, getCart, clearCart} from '@/api/cart';
import {Plus, Minus} from '@nutui/icons-vue-taro';
import {createActiveOrder} from '@/api/goods';
import {createAfterOrder, getUserPoint} from '@/api/admin';
import Pay from '@/components/Pay.vue';
interface CardList {
name: string;
@@ -30,7 +30,7 @@ const props = defineProps({
},
});
const emit = defineEmits(["updateCart"]);
const emit = defineEmits(['updateCart']);
const openModal = async () => {
await get_cart_list();
@@ -47,13 +47,13 @@ const add_cart = async (item: CardList, num: number = 1) => {
});
Taro.showToast({
title: res.msg,
icon: "none",
icon: 'none',
});
await get_cart_list();
} catch (e) {
Taro.showToast({
title: e.msg,
icon: "none",
icon: 'none',
});
}
};
@@ -92,11 +92,11 @@ const get_cart_list = async () => {
cartInfo.value.price += Number(item.price);
cartInfo.value.exchange += Number(item.exchange);
});
emit("updateCart", res.data.data || []);
emit('updateCart', res.data.data || []);
} catch (e) {
Taro.showToast({
title: e.msg,
icon: "none",
icon: 'none',
});
}
};
@@ -110,7 +110,7 @@ const clear_cart = async () => {
} catch (e) {
Taro.showToast({
title: e.msg,
icon: "none",
icon: 'none',
});
}
show.value = false;
@@ -124,7 +124,7 @@ const closePay = (val: boolean) => {
isShowPay.value = val;
orderData.value = [];
Taro.redirectTo({
url: "/pages/users/order_list/index?type=0",
url: '/pages/users/order_list/index?type=0',
});
};
@@ -142,8 +142,8 @@ const create_order = async () => {
url: `/pages/admin/add_order/pending_order/pending_order_detail/index?oid=${res.data.oid}&bid=${props.merInfo.bid}`,
});
} else {
const mer_info = Taro.getStorageSync("mer_info");
const user_info = Taro.getStorageSync("userInfo");
const mer_info = Taro.getStorageSync('mer_info');
const user_info = Taro.getStorageSync('userInfo');
const data = await getUserPoint({
phone: user_info.data.phone,
bid: mer_info.bid,
@@ -157,17 +157,20 @@ const create_order = async () => {
jh_info: data.data,
oid: res.data.oid,
};
isShowPay.value = true;
// isShowPay.value = true;
Taro.navigateTo({
url: `/pages/goods/pay/index?oid=${res.data.oid}&bid=${mer_info.bid}`,
});
}
}
Taro.showToast({
title: res.msg,
icon: "none",
icon: 'none',
});
} catch (e) {
Taro.showToast({
title: e.msg,
icon: "none",
icon: 'none',
});
}
};
@@ -181,9 +184,17 @@ defineExpose({
<template>
<view>
<view class="cart" @click.stop="openModal">
<view class="container">
<view>购物车数量: {{ cartInfo.count }}</view>
<view v-if="cartInfo.count > 0">
<view class="container flex items-center">
<!-- <view>购物车数量: {{ cartInfo.count }}</view> -->
<view class="cardImg">
<image
src="http://p1.meituan.net/csc/929f447a96a44b09a09b2e0055433222717.png">
</image>
<view class="count-text" v-if="cartInfo.count > 0">
<text>{{ cartInfo.count }}</text>
</view>
</view>
<view class="ml-1">
<text>总金额: {{ cartInfo.price.toFixed(2) }}</text>
<text v-if="!IsPendingOrder"
>总积分: {{ cartInfo.exchange.toFixed(2) }}</text
@@ -191,23 +202,25 @@ defineExpose({
</view>
</view>
<view v-if="cartInfo.count > 0" class="payBtn" @click.stop="create_order"
>立即下单</view
>去结算</view
>
</view>
<!-- 购物车弹窗 -->
<nut-popup
:style="{ padding: '20rpx' }"
:style="{padding: '15px'}"
round
position="bottom"
z-index="1"
:catch-move="true"
:safe-area-inset-bottom="true"
v-model:visible="show"
>
v-model:visible="show">
<view class="list-header">
<view class="left" @click.stop="clear_cart">
<Del2 color="#666666" />
<text style="color: #666666">清空购物车</text>
<!-- <Del2 color="#666666" /> -->
<image
class="w-[20px] h-[20px]"
src="http://p0.meituan.net/csc/db4d11fd744b69435c6ffdc6bfc868c5684.png" />
<text class="text-[20px]" style="color: #666666">清空购物车</text>
</view>
</view>
<scroll-view :scroll-y="true" class="cart-list">
@@ -216,9 +229,10 @@ defineExpose({
<image :src="item.cover" />
<view class="center">
<view class="name">{{ item.name }}</view>
<view class="price">
<view class="price flex">
<view>现金:{{ item.price }}</view>
<view>积分:{{ item.exchange }}</view>
<view class="ml-2">积分:{{ item.exchange }}</view>
</view>
</view>
</view>
@@ -227,57 +241,90 @@ defineExpose({
readonly
:min="-1"
@add="() => onAdd(item)"
@reduce="() => onReduce(item)"
/>
@reduce="() => onReduce(item)">
<template #left-icon>
<view class="btn" @click.stop="onReduce(item)">
<Minus />
</view>
</template>
<template #right-icon>
<view class="btn" @click.stop="onAdd(item)">
<Plus />
</view>
</template>
</nut-input-number>
</view>
</scroll-view>
<view style="height: 140rpx"></view>
<view style="height: 140px"></view>
</nut-popup>
<!-- 支付 -->
<Pay
:is-show-pay="isShowPay"
v-model:jfInfo="orderData"
@closePay="closePay"
@successPay="closePay"
/>
@successPay="closePay" />
</view>
</template>
<style lang="scss">
$h-border-radius: 50rpx;
$h-border-radius: 50px;
.cart {
position: fixed;
bottom: 50rpx;
bottom: 50px;
left: 50%;
transform: translateX(-50%);
z-index: 9999;
width: 95%;
background-color: red;
background-color: #262323;
border-radius: $h-border-radius;
color: #fff;
height: 100rpx;
height: 100px;
display: flex;
justify-content: space-between;
align-items: center;
.container {
margin-left: 30rpx;
margin-left: 30px;
.cardImg {
position: relative;
image {
width: 60px;
height: 60px;
}
.count-text {
position: absolute;
top: -10px;
right: -10px;
background-image: url('http://p0.meituan.net/csc/80b0e11d4270d09324df0b802d4c479b986.png');
background-size: 100% 100%;
// padding: 0 8px;
width: 35px;
height: 35px;
text-align: center;
line-height: 35px;
text {
margin: auto;
font-size: 25px;
}
}
}
}
.payBtn {
width: 180rpx;
height: 100rpx;
line-height: 100rpx;
width: 200px;
height: 100px;
line-height: 100px;
text-align: center;
background-color: #000;
background-color: #f83d3d;
border-radius: 0 $h-border-radius $h-border-radius 0;
}
}
.list-header {
margin: 15rpx 0;
margin: 15px 0;
.left {
display: flex;
@@ -286,37 +333,47 @@ $h-border-radius: 50rpx;
}
.cart-list {
height: 290rpx;
height: 290px;
.item {
display: flex;
align-items: flex-end;
margin-bottom: 10rpx;
margin-bottom: 10px;
justify-content: space-between;
.left {
display: flex;
justify-content: space-between;
image {
width: 130rpx;
height: 130rpx;
border-radius: 10rpx;
margin-right: 10rpx;
width: 130px;
height: 130px;
border-radius: 15px;
margin-right: 10px;
}
.center {
height: 100%;
height: 130px;
display: flex;
flex-direction: column;
justify-content: space-between;
.price {
color: red;
margin-top: 20rpx;
// margin-bottom: 0px;
}
}
}
}
}
.btn {
background-color: #ff0000;
color: #fff;
border-radius: 50%;
text-align: center;
line-height: 65px;
width: 45px;
height: 45px;
}
</style>

View File

@@ -1,35 +1,92 @@
<template>
<view class="goodBox">
<view
class="good"
v-for="item in merdata"
:key="item.ID"
@click.stop="toMerDetails(item)"
>
<image :src="item.head_photo" />
<view class="good-text-box">
<text class="good-text">{{ item.name }}</text>
<text style="color: #999"
>距离我{{
calculateDistance(
userLocalNum.t,
userLocalNum.l,
Number(item.lat),
Number(item.lon)
)
}}
</text>
<view class="list-box">
<view class="list">
<swiper
class="item"
:style="{
height: '250px',
}"
indicator-color="#EDEDED"
indicator-active-color="#F83D3D"
:circular="true"
:indicator-dots="true"
:autoplay="true">
<swiper-item v-for="(item, index) in bannerList" :key="index">
<image
:style="{
width: '100%',
height: '100%',
}"
:src="item.url"
@tap="toPage(item.jump)" />
</swiper-item>
</swiper>
<view
class="item"
v-for="(item, index) in list1"
:key="index"
@click="toMerDetails(item)">
<image
:style="{
height: '200px',
}"
:src="item.head_photo" />
<view class="text">
<view class="title">{{ item.name }}</view>
<view class="list_local">
<view class="icon iconfont icon-dizhi"></view>
<view class="desc"
>距离我{{
calculateDistance(
userLocalNum.t,
userLocalNum.l,
Number(item.lat),
Number(item.lon),
)
}}
</view>
</view>
</view>
</view>
</view>
<view class="list">
<view
class="item"
v-for="(item, index) in list2"
:key="index"
@click.stop="toMerDetails(item)">
<image
:style="{
height: '200px',
}"
:src="item.head_photo" />
<view class="text">
<view class="title">{{ item.name }}</view>
<view class="list_local">
<view class="icon iconfont icon-dizhi"></view>
<view class="desc"
>距离我{{
calculateDistance(
userLocalNum.t,
userLocalNum.l,
Number(item.lat),
Number(item.lon),
)
}}
</view>
</view>
</view>
</view>
</view>
</view>
</template>
<script setup lang="ts">
import { ref } from "vue";
import Taro from "@tarojs/taro";
import { calculateDistance } from "@/utils";
import { bindParent } from "@/api/user";
import { getMerList } from "@/api/goods";
import {ref} from 'vue';
import Taro from '@tarojs/taro';
import {calculateDistance, parseQueryString} from '@/utils';
import {bindParent, getBanner} from '@/api/user';
import {getMerList} from '@/api/goods';
const props = defineProps({
classId: {
@@ -38,22 +95,30 @@ const props = defineProps({
},
});
Taro.useDidShow(async () => {
const list1 = ref<Array<MerData>>([]);
const list2 = ref<Array<MerData>>([]);
Taro.useLoad(async () => {
Taro.showLoading({
title: '加载中',
});
await get_mer_list();
if (Taro.getStorageSync("token") && Taro.getStorageSync("bind_id")) {
await get_banner_list();
if (Taro.getStorageSync('token') && Taro.getStorageSync('bind_id')) {
try {
const res = await bindParent({
uid: Taro.getStorageSync("bind_id"),
uid: Taro.getStorageSync('bind_id'),
});
Taro.showToast({
title: res.msg,
});
Taro.removeStorageSync("bind_id");
Taro.removeStorageSync('bind_id');
} catch (error) {
Taro.removeStorageSync("bind_id");
Taro.removeStorageSync('bind_id');
throw error;
}
}
Taro.hideLoading();
});
interface MerData {
@@ -71,79 +136,124 @@ const userLocalNum = ref({
t: 0,
});
const pageVal = ref({
page: 1,
total: 0,
});
const get_mer_list = async () => {
Taro.getLocation({
type: "wgs84",
success: (res) => {
type: 'wgs84',
success: res => {
userLocalNum.value.l = res.longitude;
userLocalNum.value.t = res.latitude;
},
});
const res = await getMerList({
PageNum: 1,
PageNum: pageVal.value.page,
PageSize: 10,
class_id: props.classId,
});
pageVal.value.total = res.data.total;
merdata.value = res.data.data;
const middleIndex = Math.floor(merdata.value.length / 2);
const arr1 = merdata.value.slice(0, middleIndex);
const arr2 = merdata.value.slice(middleIndex);
list1.value.push(...arr1);
list2.value.push(...arr2);
merdata.value = [];
};
const bannerList = ref<any[]>([]);
const get_banner_list = async () => {
const {data}: any = await getBanner();
bannerList.value = data.data;
};
const toMerDetails = (item: any) => {
Taro.setStorageSync("mer_info", item);
const toPage = async (url: string) => {
console.log(url);
// url转对象
const obj = parseQueryString(url);
if (obj.type === '1') {
const {data: res} = await getMerList({});
const mer = res.data.filter(item => item.bid === obj.bid)[0];
Taro.setStorageSync('mer_info', mer);
}
Taro.navigateTo({
url,
});
};
const toMerDetails = item => {
Taro.setStorageSync('mer_info', item);
Taro.navigateTo({
url: `/pages/mer/mer_detail/index`,
});
};
Taro.useReachBottom(() => {
const currTotal = list1.value.length + list2.value.length;
if (currTotal === pageVal.value.total) {
Taro.showToast({
title: '没有更多了',
icon: 'none',
});
} else {
pageVal.value.page += 1;
get_mer_list();
}
});
</script>
<style lang="scss">
.goodBox {
.list-box {
padding: 10px;
display: flex;
padding: 20px;
flex-wrap: wrap;
justify-content: space-between;
.good {
width: 340px;
background-color: #fff;
margin-bottom: 20px;
border-radius: 10px;
.list {
overflow: scroll;
image {
width: 100%;
height: 250px;
border-top-right-radius: 10px;
border-top-left-radius: 10px;
}
.item {
width: 350px;
margin-bottom: 10px;
border-radius: 20px;
background-color: #fff;
.good-text-box {
padding: 10px;
.good-text {
flex-shrink: 0;
font-size: 28px;
color: #333;
font-weight: 400;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 1;
overflow: hidden;
word-break: break-word;
image {
width: 100%;
border-radius: 15px;
}
.good-price-box {
display: flex;
justify-content: space-between;
align-items: center;
margin-top: 10px;
.text {
padding: 15px;
.good-text-price {
.title {
color: #333333;
font-size: 28px;
font-weight: bold;
color: #ff0000;
-webkit-box-orient: vertical;
-webkit-line-clamp: 1;
overflow: hidden;
text-overflow: ellipsis;
// white-space: nowrap;
}
.list_local {
display: flex;
align-items: center;
justify-content: flex-start;
color: #808080;
margin-top: 8px;
.icon {
display: inline-block;
font-size: 30px;
}
.desc {
font-size: 25px;
}
}
}
}