This commit is contained in:
2024-04-16 11:41:18 +08:00
parent 178e8ff5cb
commit 32aa0eb971
8 changed files with 105 additions and 29 deletions

View File

@@ -49,7 +49,7 @@ export const getAddressDetail = (id: string) => get<any>({ url: URL.addressDetai
export const addressCreate = (data: any) => post<any>({ url: URL.addressCreate, data });
export const addressUpdate = (data: any) => post<any>({ url: URL.addressUpdate, data });
export const addressDelete = (id: string) => post<any>({ url: URL.addressDelete + `?id=${id}` });
export const addressDelete = (id: string) => post<any>({ url: URL.addressDelete + `?addrid=${id}` });
export const getDynamicCode = () => post<any>({ url: URL.dynamicCode });

View File

@@ -22,7 +22,8 @@
@click.stop='goPath(`/pages/mall/subs/goods/detail?goodsId=${item.goodsId}`)'>
<image class='goods-image' :src='item.images||defaultImage' />
<text class='goods-name'>{{ item.goodsName || '未知' }}</text>
<text class='goods-price'>¥{{ item.price }}</text>
<text class='goods-price'>¥{{ (item.price * ((userInfo.levelEntity?.discount || 100)/100)).toFixed(2) }}
<text v-if='userInfo.levelEntity?.discount>0' style='text-decoration: line-through;color: #999999;font-size: 25rpx'>¥{{ item.price }}</text></text>
<image class='add-image' :src='assetsUrl("ic_add_goods.png")' @click.stop='addShoppingCart(item)' />
</view>
</grid-view>
@@ -50,7 +51,7 @@ import useShoppingCartStore from '@/store/modules/shoppingcart';
import { useUserStore } from '@/store';
const userStore = useUserStore();
const { companyConfigInfo } = storeToRefs(userStore);
const {userInfo, companyConfigInfo } = storeToRefs(userStore);
const shoppingCartStore = useShoppingCartStore();
const { totalCount } = storeToRefs(shoppingCartStore);

View File

@@ -14,7 +14,13 @@
<view class='goods-info-view c-flex-column' style='margin-right: 10rpx'>
<view class='c-flex-row'>
<text class='goods-price accent-text-color'>{{ goodsBean?.price || 0 }}</text>
<text class='goods-price accent-text-color'>
¥{{ ((goodsBean?.price || 0) * ((userInfo.levelEntity?.discount || 100) / 100)).toFixed(2) }}
<text v-if='userInfo.levelEntity?.discount>0'
style='display:unset;text-decoration: line-through;font-size: 30rpx;color: #999999'>
¥{{ goodsBean?.price || 0 }}
</text>
</text>
<text>销量{{ goodsBean?.send_num || 0 }}</text>
</view>
@@ -49,8 +55,12 @@
:key='index'>
<view class='recommend-item c-flex-column'>
<image :src='item.images||defaultImage' />
<text>{{ item.goodsName||'未知' }}</text>
<text class='goods-price'>{{ item.price }}</text>
<text>{{ item.goodsName || '未知' }}</text>
<text class='goods-price'>{{ (item.price * ((userInfo.levelEntity.discount || 100) / 100)).toFixed(2) }}
<text v-if='userInfo.levelEntity.discount>0'
style='text-decoration: line-through;font-size: 25rpx;color: #999999'>{{ item.price }}
</text>
</text>
</view>
</view>
</scroll-view>
@@ -100,10 +110,14 @@ import { goPath, showToast } from '@/utils';
import { getGoodsDetail, getGoodsList } from '@/api/goods';
import { GoodsBean } from '@/api/goods/types';
import useShoppingCartStore from '@/store/modules/shoppingcart';
import { useUserStore } from '@/store';
const shoppingCartStore = useShoppingCartStore();
const { totalCount } = storeToRefs(shoppingCartStore);
const userStore = useUserStore();
const { userInfo } = storeToRefs(userStore);
const goodsBean = ref<GoodsBean>();
const recommendList = ref<GoodsBean[]>();
@@ -216,6 +230,9 @@ const placeOrder = () => {
padding: 20rpx 30rpx;
view:nth-of-type(1) {
display: flex;
flex-direction: row;
text:nth-of-type(1) {
display: flex;
font-size: 40rpx;
@@ -225,10 +242,10 @@ const placeOrder = () => {
}
.goods-price:before {
content: "¥";
font-size: 30rpx;
margin-bottom: 5rpx;
margin-right: 5rpx;
//content: "¥";
//font-size: 30rpx;
//margin-bottom: 5rpx;
//margin-right: 5rpx;
}
text:nth-of-type(2) {

View File

@@ -12,8 +12,12 @@
<view v-for='(item, index) in goodsList' :key='index' class='goods-item'
@click.stop='goPath(`/pages/mall/subs/goods/detail?goodsId=${item.goodsId}`)'>
<image class='goods-image' :src='item.images||defaultImage' />
<text class='goods-name'>{{ item.goodsName||'未知' }}</text>
<text class='goods-price'>¥{{ item.price }}</text>
<text class='goods-name'>{{ item.goodsName || '未知' }}</text>
<text class='goods-price'>¥{{ (item.price * ((userInfo.levelEntity?.discount || 100)/100)).toFixed(2) }}
<text v-if='userInfo.levelEntity?.discount>0'
style='text-decoration: line-through;color: #999999;font-size: 25rpx'>¥{{ item.price }}
</text>
</text>
<image class='add-image' :src='assetsUrl("ic_add_goods.png")' @click.stop='addShoppingCart(item)' />
</view>
</grid-view>
@@ -29,10 +33,14 @@ import { goPath } from '@/utils';
import { getGoodsList } from '@/api/goods';
import useShoppingCartStore from '@/store/modules/shoppingcart';
import { GoodsBean } from '@/api/goods/types';
import { useUserStore } from '@/store';
const skuDialogRef = ref();
const shoppingCartStore = useShoppingCartStore();
const userStore = useUserStore();
const { userInfo } = storeToRefs(userStore);
const goodsList = ref<GoodsBean[]>([]);
onLoad((e) => {

View File

@@ -12,7 +12,7 @@
<view class='c-flex-row'>
<image class='checkbox'
:src='assetsUrl(item.checked?"ic_checkbox_active_red.png":"ic_checkbox_normal.png")'
@click.stop='item.checked=!item.checked' />
@click.stop='handleCheck(item)' />
<image class='goods-image' :src='item.images||defaultImage' />
<view class='c-flex-column'>
<text>{{ item.name }}</text>
@@ -24,7 +24,12 @@
<image :src='assetsUrl("ic_arrow_down_gray.png")' />
</view>
</view>
<text style='margin-top: 50rpx'>¥{{ item.price }}</text>
<text style='margin-top: 50rpx'>
¥{{ (item?.price * ((userInfo.levelEntity?.discount || 100) / 100)).toFixed(2) }}
<text v-if='userInfo.levelEntity?.discount>0'
style='text-decoration: line-through;color: #999999;font-size: 25rpx'>¥{{ item?.price }}
</text>
</text>
<view class='count-change-view c-flex-row'>
<view class='count-image' @click.stop='countChange(index,false)'>
<image :src='assetsUrl("ic_reduce.png")' />
@@ -41,7 +46,7 @@
</view>
<view class='bottom-view c-flex-row'>
<view class='c-flex-row' @click.stop='checkedAll = !checkedAll'>
<view class='c-flex-row' @click.stop='handleAllCheck'>
<image :src='assetsUrl(checkedAll?"ic_checkbox_active.png":"ic_checkbox_normal.png")' />
<text>全选</text>
</view>
@@ -50,7 +55,7 @@
<text v-if='isEditMode' class='settlement' @click.stop='deleteShoppingCart'>删除</text>
<view v-else class='c-flex-row'>
<text>合计:
<text>¥{{ totalPayPrice }}</text>
<text>¥{{ totalPayPrice.toFixed(2) }}</text>
</text>
<text class='settlement' @click.stop='settlement'>结算</text>
</view>
@@ -67,6 +72,7 @@ import { goPath, showToast } from '@/utils';
import { GoodsBean, StockBean } from '@/api/goods/types';
import SkuDialog from '@/components/sku-dialog.vue';
import { ref } from 'vue';
import { useUserStore } from '@/store';
const isEditMode = ref(false);
const checkedAll = ref(false);
@@ -74,22 +80,37 @@ const checkedAll = ref(false);
const shoppingCartStore = useShoppingCartStore();
const { shoppingCartList, totalCount } = storeToRefs(shoppingCartStore);
const userStore = useUserStore();
const { userInfo } = storeToRefs(userStore);
const skuDialogRef = ref();
const temporaryGoodsBean = ref<GoodsBean>();
const temporaryStockBean = ref<StockBean>();
watch(checkedAll, (newValue) => {
shoppingCartList.value.forEach(res => {
res.checked = newValue;
});
const totalPayPrice = computed(() => {
return shoppingCartList.value.filter(res => res.checked).reduce((a, b) => a + b.consumePrice * b.checkedStock.count, 0) || 0;
});
const totalPayPrice = computed(() => {
return shoppingCartList.value.filter(res => res.checked).reduce((a, b) => a + b.consumePrice * b.checkedStock.count, 0);
});
const handleCheck = (item: any) => {
item.checked = !item.checked;
if(!item.checked) {
checkedAll.value = false;
} else {
checkedAll.value = shoppingCartList.value.every(res => res.checked);
}
};
const handleAllCheck = () => {
checkedAll.value = !checkedAll.value;
shoppingCartList.value.forEach(res => {
res.checked = checkedAll.value;
});
};
const deleteShoppingCart = () => {
shoppingCartStore.deleteIfChecked();
checkedAll.value = false;
isEditMode.value = false;
};
const showSkuDialog = (index: number) => {

View File

@@ -4,7 +4,7 @@
<item v-for='(item,index) in addressList' :key='index' :item='item'
@on-checked='onChecked(item)'
@on-edit='args => goPath(`create?bean=${encodeURIComponent(JSON.stringify(args))}`)'
@on-delete='args => {addressDelete(args?.addrid);fetchAddressList}' />
@on-delete='args => {handleDelete(args)}' />
</scroll-view>
<view class='bottom-button-view'>
@@ -42,6 +42,23 @@ const fetchAddressList = async () => {
addressList.value = await getAddressList();
};
const handleDelete = async (item: any) => {
uni.showModal(
{
title: '提示',
content: '确定删除该地址吗',
success: async (res) => {
if(res.confirm) {
const result = await addressDelete(item?.addrid);
if(result) {
await fetchAddressList();
}
}
}
}
);
};
const onChecked = (e: any) => {
const pages = getCurrentPages();
if(pages.length >= 2 && pages[pages.length - 2].route?.includes('pages/mall/subs/order/order-confirm')) {

View File

@@ -18,11 +18,14 @@
<view class='address-view c-flex-column'
v-if='orderBean?.order?.address'>
<view class='user-info c-flex-row'>
<text v-if='orderBean.order.address.defaultstatus==1'>默认</text>
<text class='status' v-if='orderBean.order.address.defaultstatus==1'>默认</text>
<text>{{ orderBean?.order?.address.name }}</text>
<text>{{ orderBean?.order?.address.mobile }}</text>
<view style='flex: 1' />
<text style='color: #5B96FB'>复制</text>
<text style='color: #5B96FB'
@click.stop='copy(orderBean?.order?.address.name+","+orderBean?.order?.address.mobile+","+orderBean?.order?.address.addr)'>
复制
</text>
</view>
<view class='addr c-flex-row'>
@@ -89,7 +92,7 @@
<view class='order-no c-flex-column'>
<text>订单编号{{ orderBean?.order?.id }}
<text style='color: #5B96FB;margin-left: 10rpx'>复制</text>
<text style='color: #5B96FB;margin-left: 10rpx' @click.stop='copy(orderBean?.order?.id||"")'>复制</text>
</text>
<text>下单时间{{ orderBean?.order?.createTime }}</text>
<text>
@@ -122,7 +125,7 @@
import { assetsUrl, defaultImage } from '@/utils/assets';
import { getOrderDetail } from '@/api/order';
import { OrderBean } from '@/api/order/types';
import { parseParameter, sortASCII } from '@/utils';
import { copy, parseParameter, sortASCII } from '@/utils';
import { hexMD5 } from '@/utils/common/md5';
import { useUserStore } from '@/store';
import { getOrderDeadline, handlePayResult, isPending } from '@/utils/order';
@@ -255,7 +258,7 @@ const payment = () => {
margin-left: 20rpx;
margin-right: 20rpx;
text:nth-of-type(1) {
.status {
padding: 2rpx 10rpx;
font-size: 24rpx;
color: #F32B2B;

View File

@@ -108,3 +108,12 @@ export function parseParameter(obj: any) {
}
return arr.join('&');
}
export function copy(content: string) {
uni.setClipboardData({
data: content,
success: function(res) {
showToast('复制成功');
}
});
}