This commit is contained in:
2024-03-31 18:19:26 +08:00
parent b502385272
commit 60cb832b02
10 changed files with 107 additions and 109 deletions

View File

@@ -66,23 +66,13 @@ export interface OrderBean {
ogList: any[]; ogList: any[];
orderGoods: GoodsBean[]; orderGoods: GoodsBean[];
changeStockNum: number; changeStockNum: number;
companyId: string;
consumePrice: number; consumePrice: number;
consumerId: string;
consumerName: string;
createTime: string;
creatorId: number;
creatorName: string;
discount: number;
discountOriginPrice: number; discountOriginPrice: number;
discountPrice: number;
goodsCode: string; goodsCode: string;
goodsId: string; goodsId: string;
goodsName: string; goodsName: string;
goodsNum: number;
goodsPriceModify: string; goodsPriceModify: string;
goodsTypeName: string; goodsTypeName: string;
id: string;
images: string; images: string;
offset: string; offset: string;
orderId: string; orderId: string;
@@ -91,14 +81,9 @@ export interface OrderBean {
originStockNum: number; originStockNum: number;
priceModify: []; priceModify: [];
produceIntegral: number; produceIntegral: number;
remark: string;
salePrice: number; salePrice: number;
stockId: string; stockId: string;
stockStock: StockBean[]; stockStock: StockBean[];
storeId: string;
type: number;
typeName: string;
updateTime: string;
payStatus: number; payStatus: number;
payTypeIds: string; payTypeIds: string;
printed: string; printed: string;

View File

@@ -3,7 +3,7 @@
*/ */
import type { CouponBean, LoginParams, LoginResult, RegisterParams, TerminalBean } from './types'; import type { CouponBean, LoginParams, LoginResult, RegisterParams, TerminalBean } from './types';
import { get, post } from '@/utils/request'; import { get, post } from '@/utils/request';
import type { UserState } from '@/store/modules/user/types'; import { UserBean } from '@/store/modules/user/types';
enum URL { enum URL {
// login = '/member/login', // login = '/member/login',
@@ -29,7 +29,7 @@ enum URL {
terminal = 'wechat/coupons/terminal?companyId=' terminal = 'wechat/coupons/terminal?companyId='
} }
export const getUserProfile = () => get<UserState>({ url: URL.profile }); export const getUserProfile = () => get<UserBean>({ url: URL.profile });
export const login = (data: LoginParams) => post<LoginResult>({ url: URL.login, data }); export const login = (data: LoginParams) => post<LoginResult>({ url: URL.login, data });
export const loginByCode = (code: string, companyId: string) => post<any>({ url: URL.loginByCode + `?code=${code}` }); export const loginByCode = (code: string, companyId: string) => post<any>({ url: URL.loginByCode + `?code=${code}` });

View File

@@ -65,9 +65,11 @@ export interface CouponBean {
status: number; status: number;
strategyType: string; strategyType: string;
telephone: string; telephone: string;
threshold: string; threshold: number;
type: number; type: number;
userTime: string; userTime: string;
checked: boolean;
} }
export interface TerminalBean { export interface TerminalBean {

View File

@@ -3,11 +3,11 @@
<view class='popup-content c-flex-column'> <view class='popup-content c-flex-column'>
<view class='c-flex-row'> <view class='c-flex-row'>
<text>优惠券</text> <text>优惠券</text>
<text @click.stop='close'>确定</text> <text @click.stop='confirm'>确定</text>
</view> </view>
<scroll-view scroll-y> <scroll-view scroll-y>
<coupon-item v-for='(item,index) in coupons' :item='item' :key='index' /> <coupon-item v-for='(item,index) in coupons' :item='item' :key='index' @confirm='confirmItem(index)' />
</scroll-view> </scroll-view>
</view> </view>
</uni-popup> </uni-popup>
@@ -15,62 +15,53 @@
<script lang='ts' setup> <script lang='ts' setup>
import CouponItem from '../components/coupon-item.vue'; import CouponItem from '../components/coupon-item.vue';
import { getCompanyId } from '@/utils';
import { getCouponList } from '@/api/user';
import { CouponBean } from '@/api/user/types';
import { useUserStore } from '@/store';
const popupRef = ref(); const popupRef = ref();
const coupons = ref([{
id: 1, const userStore = useUserStore();
title: '优惠券', const { userInfo } = storeToRefs(userStore);
desc: '满100减10',
price: 100, const props = defineProps({
threshold: 10, orderPrice: {
priceDesc: '满100减10', type: Number,
useTime: '2021-12-31', default: 0
status: 1, }
useStatus: '未使用' });
}, { const emits = defineEmits(['confirm']);
id: 1, const coupons = ref<CouponBean[]>([]);
title: '优惠券',
desc: '满100减10', const fetchData = async (status: number) => {
price: 200, const { list } = await getCouponList({
threshold: 80, companyId: getCompanyId(),
priceDesc: '满100减10', memberId: userInfo.value?.id,
useTime: '2021-01-01', status: status,
status: 1, pageNum: 1,
useStatus: '未使用' pageSize: 100
}, { });
id: 1, list.filter((item: CouponBean) => item.status = (props.orderPrice >= item.threshold) ? 0 : 1);
title: '优惠券', coupons.value = list;
desc: '满100减10', };
price: 300,
threshold: 60,
priceDesc: '满100减10',
useTime: '2023-12-31',
status: '0',
useStatus: '未使用'
}, {
id: 1,
title: '优惠券',
desc: '满100减10',
price: 50,
threshold: 50,
priceDesc: '满100减10',
useTime: '2021-10-31',
status: 0,
useStatus: '未使用'
}, {
id: 1,
title: '优惠券',
desc: '满1000减30',
price: 200,
threshold: 30,
priceDesc: '满100减10',
useTime: '2024-12-31',
status: 0,
useStatus: '未使用'
}]);
const show = () => { const show = () => {
popupRef.value.open(); popupRef.value.open();
fetchData(0);
};
const confirmItem = (index: number) => {
coupons.value.forEach(item => {
item.checked = false;
});
coupons.value[index].checked = !coupons.value[index].checked;
};
const confirm = () => {
close();
emits('confirm', coupons.value.filter(item => item.checked)[0]);
}; };
const close = () => { const close = () => {

View File

@@ -1,28 +1,35 @@
<template> <template>
<view class='coupon-content'> <view class='coupon-content' @click.stop='()=>{emits("confirm")}'>
<image v-if='item.status==0' :src='assetsUrl("bg_coupon.png")' /> <image v-if='item?.status==0' :src='assetsUrl("bg_coupon.png")' />
<image v-else-if='item.status==1' :src='assetsUrl("bg_coupon_expired.png")' /> <image v-else-if='item?.status==1' :src='assetsUrl("bg_coupon_expired.png")' />
<view class='left-content accent-text-color' :class='{"left-content-disabled": item.status==1}'> <view class='left-content accent-text-color' :class='{"left-content-disabled": item?.status==1}'>
<text>{{ item.price }}</text> <text>{{ item?.reduce }}</text>
<text>{{ item.threshold }}元可用</text> <text>满{{ item?.threshold }}元可用</text>
</view> </view>
<view class='right-content accent-text-color' :class='{"right-content-disabled": item.status==1}'> <view class='right-content accent-text-color' :class='{"right-content-disabled": item?.status==1}'>
<text>{{ item?.title }}</text> <text>{{ item?.name }}</text>
<text>有效期至{{ item.useTime }}</text> <text>有效期至{{ dayjs(item?.startTime).format('YYYY-MM-DD') }}</text>
<image class='checkbox' :src='assetsUrl("ic_checkbox_active.png")' /> <image v-if='item?.status==0' class='checkbox'
:src='assetsUrl(item.checked?"ic_checkbox_active.png":"ic_checkbox_normal.png")'
/>
</view> </view>
</view> </view>
</template> </template>
<script lang='ts' setup> <script lang='ts' setup>
import { PropType } from 'vue';
import { assetsUrl } from '@/utils/assets'; import { assetsUrl } from '@/utils/assets';
import { CouponBean } from '@/api/user/types';
import dayjs from 'dayjs';
defineProps({ defineProps({
item: Object item: Object as PropType<CouponBean>
}); });
const emits = defineEmits(['confirm']);
</script> </script>
<style lang='scss' scoped> <style lang='scss' scoped>
@@ -74,7 +81,7 @@ defineProps({
position: relative; position: relative;
flex: 1; flex: 1;
justify-content: center; justify-content: center;
margin-left: 100rpx; margin-left: 60rpx;
text:nth-of-type(1) { text:nth-of-type(1) {
font-size: 30rpx; font-size: 30rpx;

View File

@@ -67,7 +67,7 @@
<text class='card-view-title'>优惠券 <text class='card-view-title'>优惠券
<text style='font-size: 22rpx;color: #F32B2B;'>已选最大优惠</text> <text style='font-size: 22rpx;color: #F32B2B;'>已选最大优惠</text>
</text> </text>
<view class='card-view-value' style='color: #F32B2B;margin: 0'>-20 <view class='card-view-value' style='color: #F32B2B;margin: 0'>-{{ checkedCoupon?.reduce || 0 }}
<image :src='assetsUrl("ic_arrow_right_gray.png")' /> <image :src='assetsUrl("ic_arrow_right_gray.png")' />
</view> </view>
</view> </view>
@@ -96,7 +96,7 @@
</view> </view>
</view> </view>
<payment-dialog ref='paymentDialogRef' @change='args => paymentType=args' /> <payment-dialog ref='paymentDialogRef' @change='args => paymentType=args' />
<coupon-dialog ref='couponDialogRef' /> <coupon-dialog ref='couponDialogRef' @confirm='confirmCoupon' :order-price='500' />
</template> </template>
<script lang='ts' setup> <script lang='ts' setup>
@@ -105,14 +105,16 @@ import PaymentDialog from '@/components/payment-dialog.vue';
import CouponDialog from '@/pages/mall/subs/components/coupon-dialog.vue'; import CouponDialog from '@/pages/mall/subs/components/coupon-dialog.vue';
import { goPath } from '@/utils'; import { goPath } from '@/utils';
import { orderCreate } from '@/api/goods'; import { orderCreate } from '@/api/goods';
import { CouponBean } from '@/api/user/types';
const couponDialogRef = ref(); const couponDialogRef = ref();
const paymentDialogRef = ref(); const paymentDialogRef = ref();
const paymentType = ref(0); const paymentType = ref(0);
const tabIndex = ref(0); const tabIndex = ref(0);
const checkedCoupon = ref<CouponBean>();
const changePayment = () => { const changePayment = () => {
console.log(paymentDialogRef);
paymentDialogRef.value.show(); paymentDialogRef.value.show();
}; };
@@ -120,6 +122,10 @@ const showCouponDialog = () => {
couponDialogRef.value.show(); couponDialogRef.value.show();
}; };
const confirmCoupon = (item: CouponBean) => {
checkedCoupon.value = item;
};
const payment = async () => { const payment = async () => {
const params = { const params = {
'discount': 0, 'discount': 0,

View File

@@ -63,7 +63,7 @@
import { assetsUrl } from '@/utils/assets'; import { assetsUrl } from '@/utils/assets';
import useShoppingCartStore from '@/store/modules/shoppingcart'; import useShoppingCartStore from '@/store/modules/shoppingcart';
import { goPath } from '@/utils'; import { goPath, showToast } from '@/utils';
import { GoodsBean, StockBean } from '@/api/goods/types'; import { GoodsBean, StockBean } from '@/api/goods/types';
import SkuDialog from '@/components/sku-dialog.vue'; import SkuDialog from '@/components/sku-dialog.vue';
import { ref } from 'vue'; import { ref } from 'vue';
@@ -127,6 +127,10 @@ const countChange = (index: number, isPlus: Boolean) => {
}; };
const settlement = () => { const settlement = () => {
if(shoppingCartList.value.filter(res => res.checked).length == 0) {
showToast('请选择商品');
return;
}
goPath('/pages/mall/subs/order/order-confirm'); goPath('/pages/mall/subs/order/order-confirm');
}; };
</script> </script>

View File

@@ -1,16 +1,16 @@
<template> <template>
<view class='coupon-content'> <view class='coupon-content'>
<image v-if='item.status==0' :src='assetsUrl("bg_coupon.png")' /> <image v-if='item?.status==0' :src='assetsUrl("bg_coupon.png")' />
<image v-else-if='item.status==1' :src='assetsUrl("bg_coupon_expired.png")' /> <image v-else-if='item?.status==1' :src='assetsUrl("bg_coupon_expired.png")' />
<view class='left-content accent-text-color' :class='{"left-content-disabled": item.status==1}'> <view class='left-content accent-text-color' :class='{"left-content-disabled": item?.status==1}'>
<text>{{ item.reduce }}</text> <text>{{ item?.reduce }}</text>
<text>{{ item.threshold }}元可用</text> <text>{{ item?.threshold }}元可用</text>
</view> </view>
<view class='right-content accent-text-color' :class='{"right-content-disabled": item.status==1}'> <view class='right-content accent-text-color' :class='{"right-content-disabled": item?.status==1}'>
<text>{{ item?.name }}</text> <text>{{ item?.name }}</text>
<text>有效期至{{ dayjs(item.startTime).format("YYYY-MM-DD") }}</text> <text>有效期至{{ dayjs(item?.startTime).format('YYYY-MM-DD') }}</text>
<text class='btn-text' :class='{"btn-text-disabled": item.status==1}'> <text class='btn-text' :class='{"btn-text-disabled": item?.status==1}'>
立即使用 立即使用
</text> </text>
</view> </view>
@@ -22,9 +22,11 @@
import { assetsUrl } from '@/utils/assets'; import { assetsUrl } from '@/utils/assets';
import dayjs from 'dayjs'; import dayjs from 'dayjs';
import { PropType } from 'vue';
import { CouponBean } from '@/api/user/types';
defineProps({ defineProps({
item: Object item: Object as PropType<CouponBean>
}); });
</script> </script>
@@ -114,6 +116,7 @@ defineProps({
.right-content-disabled { .right-content-disabled {
@extend .right-content; @extend .right-content;
color: #C2C2C2; color: #C2C2C2;
text:nth-of-type(2) { text:nth-of-type(2) {
color: #C2C2C2; color: #C2C2C2;
} }

View File

@@ -11,15 +11,15 @@ import CouponItem from './components/coupon-item.vue';
import { getCouponList } from '@/api/user'; import { getCouponList } from '@/api/user';
import { useUserStore } from '@/store'; import { useUserStore } from '@/store';
import { getCompanyId } from '@/utils'; import { getCompanyId } from '@/utils';
import { GroupBuyBean } from '@/api/groupbuy/types'; import { CouponBean } from '@/api/user/types';
const store = useUserStore(); const store = useUserStore();
const { userInfo } = storeToRefs(store); const { userInfo } = storeToRefs(store);
const coupons = ref<GroupBuyBean[]>([]); const coupons = ref<CouponBean[]>([]);
onLoad(async () => { onLoad(async () => {
fetchData(0); await fetchData(0);
}); });
const tabChange = (index: number) => { const tabChange = (index: number) => {

View File

@@ -57,20 +57,20 @@ export function sortASCII(obj: any, isSort = true) {
return sortObj; return sortObj;
} }
Array.prototype.contains = function(obj: any) { // Array.prototype.contains = function(obj: any) {
let i = this.length; // let i = this.length;
while (i--) { // while (i--) {
if(this[i] === obj) { // if(this[i] === obj) {
return true; // return true;
} // }
} // }
return false; // return false;
}; // };
export function parseParameter(obj: any) { export function parseParameter(obj: any) {
if(obj === null || obj === undefined) return ''; if(obj === null || obj === undefined) return '';
const arr = []; const arr = [];
const keys: string[] = Object.keys(obj); const keys: any = Object.keys(obj);
const entries: any[] = Object.entries(obj); const entries: any[] = Object.entries(obj);
for (const [key, value] of entries) { for (const [key, value] of entries) {
if(keys.contains(key) && !key.startsWith('function')) { if(keys.contains(key) && !key.startsWith('function')) {