提交 250028a1 authored 作者: 刘旭's avatar 刘旭

补全

上级 a93896ee
import { request } from '@/utils/request';
// 购物车初始数据
export const getCartIndex = () => request('/wx/cart/index', 'GET');
export const getCartIndex = (data: any) => request('/wx/cart/index', 'GET', data);
// 选择或取消商品
export const cartChecked = (data: any) => request('/wx/cart/checked', 'POST', data);
......@@ -14,3 +14,24 @@ export const cartUpdate = (data: any) => request('/wx/cart/update', 'POST', data
// 更新商品
export const downloadPdf = (data: string) => request('/wx/storage/download/' + data, 'GET');
// 查询pdf详细数据
export const getOrderPdf = (data: any) => request('/wx/order/orderPdfSource', 'GET', data);
// 报价-准备报价
export const quotationInit = (data: any) => request('/wx/quotation/init', 'GET', data);
// 报价单-订单查询
export const quotationOrder = (data: any) => request('/wx/quotation/order', 'GET', data);
// 报价单-用户列表查询
export const quotationList = (data: any) => request('/wx/quotation/list', 'GET', data);
// 报价-填报报价
export const fillQuotation = (data: any) => request('/wx/quotation/filling', 'POST', data);
// 报价单-逻辑删除
export const deleteQuotation = (data: any) => request('/wx/quotation/delete', 'DELETE', data);
// 报价单-详细
export const quotationDetail = (data: any) => request('/wx/quotation/detail', 'POST', data);
......@@ -9,3 +9,8 @@ export const productLineCollect = (data: any) => request('/wx/productLine/collec
// 产品线取消收藏或重新收藏
export const delProductLineCollect = (data: any) => request('/wx/collect/addordelete', 'POST', data)
// 产品线点击购买
export const productLineByuNow = (data: any) => request('/wx/cart/fastadd', 'POST', data)
// 产品线点击购买后获取数据
export const getProductLineByuNowData = (data: any) => request('/wx/cart/checkout', 'GET', data)
\ No newline at end of file
......@@ -3,7 +3,7 @@
<u-image
width="176rpx"
height="176rpx"
:src="src.split('http').length > 1 ? src : baseUrl + src"
:src="src?.split('http').length > 1 ? src : baseUrl + src"
></u-image>
<view class="content">
<view class="title">
......@@ -11,9 +11,9 @@
<text style="color: #646566;">{{ brief }}</text>
</view>
<view class="price">
<text class="new-price">{{ retailPrice.toFixed(2) }}</text>
<text class="new-price">{{ retailPrice?.toFixed(2) }}</text>
<text v-if="counterPrice != 0" class="old-price">
{{ counterPrice.toFixed(2) }}
{{ counterPrice?.toFixed(2) }}
</text>
</view>
</view>
......
......@@ -55,25 +55,52 @@
:key="index1"
>
<view class="item-title">{{ item.name }}</view>
<view class="item-wrapper">
<view
class="item-content"
v-for="(item_value, index2) in item.list"
:key="index2"
:class="[
item_value.ishow ? '' : 'noactived',
subIndex[index1] == index2 ? 'actived' : '',
]"
:style="[
item_value.ishow ? '' : themeColorFn('disableStyle'),
item_value.ishow ? themeColorFn('btnStyle') : '',
subIndex[index1] == index2
? themeColorFn('activedStyle')
: '',
]"
@click="skuClick(item_value, index1, index2)"
>
{{ item_value.name }}
<view
style="display: flex; justify-content: space-between; align-items: center;"
>
<view class="item-wrapper">
<view
class="item-content"
v-for="(item_value, index2) in item.list"
:key="index2"
:class="[
item_value.ishow ? '' : 'noactived',
subIndex[index1] == index2 ? 'actived' : '',
]"
:style="[
item_value.ishow ? '' : themeColorFn('disableStyle'),
item_value.ishow ? themeColorFn('btnStyle') : '',
subIndex[index1] == index2
? themeColorFn('activedStyle')
: '',
]"
@click="skuClick(item_value, index1, index2)"
>
{{ item_value.name }}
</view>
</view>
<view v-if="item.isPlus">
<u-icon
name="plus-circle"
color="#999"
size="36"
@click="onPlus(index1)"
></u-icon>
</view>
<view v-else style="margin-bottom: 12rpx; width: 200rpx;">
<u-input
v-model="item.custom"
placeholder="自定义规格"
type="text"
border-color="#2979ff"
height="50"
clearable
border
focus
@blur="onBlur($event, index1)"
@confirm="onConfirm($event, index1)"
/>
</view>
</view>
</view>
......@@ -189,6 +216,9 @@ export default {
'num-change',
'change',
'clear',
'plus',
'confirm',
'blur',
],
props: {
// true 组件显示 false 组件隐藏
......@@ -1074,9 +1104,24 @@ export default {
this.$emit('num-change', e.value);
},
handClose() {
let that = this
let that = this;
that.selectShop = {};
that.goodsInfo = {}
that.goodsInfo = {};
},
// 添加子字段
onPlus(index) {
let that = this;
that.$emit('plus', index);
},
// 失去焦点后还原
onBlur(val, index) {
let that = this;
that.$emit('blur', val, index);
},
// 失去焦点后还原
onConfirm(val, index) {
let that = this;
that.$emit('confirm', val, index);
},
},
// 计算属性
......
......@@ -31,7 +31,8 @@
}, {
"path": "pages/productLine/productLine",
"style": {
"navigationBarTitleText": "产品线"
"navigationBarTitleText": "产品线",
"navigationStyle": "custom"
}
}, {
"path": "pages/cart/index",
......
<template>
<u-navbar :is-back="false" title="">
<template #right>
<text style="margin-right: 30rpx;" @tap="tapSwitch">
{{ type === 0 ? '切换产品线' : '返回商品' }}
</text>
<text style="margin-right: 30rpx;" @tap="tapDel">{{ administration }}</text>
</template>
</u-navbar>
......@@ -18,7 +21,7 @@
width="140rpx"
height="200rpx"
:src="
item.picUrl.split('http').length > 1
item.picUrl?.split('http').length > 1
? item.picUrl
: baseUrl + item.picUrl
"
......@@ -28,7 +31,7 @@
<view>{{ item.goodsName }}</view>
<view class="b-tag">
<block
v-for="(item1, index1) in item.specifications.length"
v-for="(item1, index1) in item.specifications?.length"
:key="index1"
>
<u-tag
......@@ -58,6 +61,7 @@
</u-checkbox-group>
</view>
<view v-else style="margin-top: 200rpx;"><u-empty text="购物车为空" mode="car" /></view>
<view style="width: 100%; height: 100rpx;" />
<view class="footer">
<view class="left">
<u-checkbox-group>
......@@ -111,7 +115,8 @@ const checkedGoods = ref(); // 购物车列表check为true id
const totalPrice = ref(); // 总价
const delCircle = ref(false); // 控制删除与管理
const administration = ref('管理');
const delProductIds = ref([] as any); // 删除id
const delIds = ref([] as any); // 删除id
const type = ref(0); // 产品线跟普通商品查询的区别
const showModel = reactive({
title: '',
show: false,
......@@ -122,7 +127,7 @@ const showModel = reactive({
// 管理
const tapDel = () => {
if (delCircle.value) {
initCartIndex();
initCartIndex(type.value);
delCircle.value = false;
administration.value = '管理';
} else {
......@@ -131,29 +136,40 @@ const tapDel = () => {
}
};
const tapSwitch = () => {
if (type.value === 0) {
type.value = 2;
initCartIndex(type.value);
} else {
type.value = 0;
initCartIndex(type.value);
}
};
// 点击购物车列表checkbox
const checkboxGroupChange = (e: any) => {
let addProductIds: any = [];
let addIds: any = [];
_.each(e, (v: any) => {
let productId = _.find(cartList.value, (result: any) => {
let ids = _.find(cartList.value, (result: any) => {
return result.id === v;
}).productId;
if (productId == undefined) initCartIndex();
addProductIds.push(productId);
});
if (ids == undefined) initCartIndex(type.value);
else addIds.push(ids.id);
});
// 取消checkedbox
let delProductIds: any = [];
let delIds: any = [];
_.each(_.difference(allGoods.value, e), (v: any) => {
let productId = _.find(cartList.value, (result: any) => {
let ids = _.find(cartList.value, (result: any) => {
return result.id === v;
}).productId;
delProductIds.push(productId);
}).id;
delIds.push(ids);
});
if (addProductIds.length > 0) initCartChecked(1, addProductIds);
if (addIds.length > 0) initCartChecked(1, addIds, type.value);
if (delProductIds.length > 0) initCartChecked(0, delProductIds);
if (delIds.length > 0) initCartChecked(0, delIds, type.value);
if (e.length === allGoods.value.length) checkedAll.value = true;
else checkedAll.value = false;
......@@ -161,19 +177,19 @@ const checkboxGroupChange = (e: any) => {
// 单个删除
const deleteCart = (index: number) => {
delProductIds.value.push(cartList.value[index].productId);
delIds.value.push(cartList.value[index].id);
showModel.show = true;
};
// 批量删除
const tapOptions = () => {
if (delCircle.value) {
delProductIds.value = [];
delIds.value = [];
_.each(checkedGoods.value, (id: any) => {
delProductIds.value.push(
delIds.value.push(
_.find(cartList.value, (vv: any) => {
return id === vv.id;
}).productId
}).id
);
});
showModel.show = true;
......@@ -182,8 +198,6 @@ const tapOptions = () => {
cartId: 0,
addressId: 0,
couponId: 0,
userCouponId: 0,
grouponRulesId: 0,
};
Object.keys(storage).forEach((prop: any) => {
const el: any = storage[prop];
......@@ -191,7 +205,7 @@ const tapOptions = () => {
key: prop,
data: el,
success(res: any) {
if (prop == 'grouponRulesId' && el == 0) {
if (prop == 'cartId' && el == 0) {
uni.navigateTo({ url: `../order/checkout?type=` + 'cart' });
}
},
......@@ -202,11 +216,11 @@ const tapOptions = () => {
// 确认删除
const onConfirm = () => {
if (delProductIds.value) {
if (delProductIds.value.length === 1) {
cartDelete({ productIds: delProductIds.value }).then((res: any) => {
if (delIds.value) {
if (delIds.value.length === 1) {
cartDelete({ ids: delIds.value, type: type.value }).then((res: any) => {
if (res.data.code === 200) {
delProductIds.value = [];
delIds.value = [];
cartList.value = res.data.data.cartList;
allGoods.value = getAllList();
checkedGoods.value = getCheckedList(cartList.value);
......@@ -215,16 +229,22 @@ const onConfirm = () => {
}
});
} else {
cartDelete({ productIds: delProductIds.value }).then((res: any) => {
cartDelete({ ids: delIds.value, type: type.value }).then((res: any) => {
if (res.data.code === 200) {
delProductIds.value = [];
delIds.value = [];
cartList.value = res.data.data.cartList;
allGoods.value = getAllList();
checkedGoods.value = getCheckedList(cartList.value);
totalPrice.value = res.data.data.cartTotal.checkedGoodsAmount.toFixed(2);
// 批量删除后,check的name属性没有更新,需要刷新当前页面
uni.reLaunch({ url: '../cart/index' });
showModel.show = false;
// 批量删除后,check的name属性没有更新,需要刷新当前页面
// uni.reLaunch({
// url: '../cart/index',
// success() {
// type.value = 2;
// initCartIndex(type.value);
// },
// });
}
});
}
......@@ -233,15 +253,15 @@ const onConfirm = () => {
// 是否全选
const checkboxChange = () => {
let productIds: any = [];
let ids: any = [];
_.each(cartList.value, (v: any) => {
productIds.push(v.productId);
ids.push(v.id);
});
if (checkedAll.value) {
initCartChecked(1, productIds);
initCartChecked(1, ids, type.value);
checkedAll.value = true;
} else {
initCartChecked(0, productIds);
initCartChecked(0, ids, type.value);
checkedAll.value = false;
}
};
......@@ -252,32 +272,34 @@ const valChange = (e: any, item: any) => {
number: e.value,
goodsId: item.goodsId,
id: item.id,
productId: item.productId,
ids: item.ids,
}).then((res: any) => {
if (res.data.code === 200) initCartIndex();
if (res.data.code === 200) initCartIndex(type.value);
});
};
// 初始化数据
const initCartIndex = () => {
getCartIndex().then((res: any) => {
cartList.value = res.data.data.cartList;
totalPrice.value = res.data.data.cartTotal.checkedGoodsAmount.toFixed(2);
allGoods.value = getAllList();
checkedGoods.value = getCheckedList(cartList.value);
let sort = 0;
cartList.value.map((item: any) => {
if (!item.checked) sort += 1;
});
if (sort === 0) checkedAll.value = true;
else checkedAll.value = false;
sort = 0;
const initCartIndex = (type: number) => {
getCartIndex({ type }).then((res: any) => {
if (res.data.code === 200) {
cartList.value = res.data.data.cartList;
totalPrice.value = res.data.data.cartTotal.checkedGoodsAmount.toFixed(2);
allGoods.value = getAllList();
checkedGoods.value = getCheckedList(cartList.value);
let sort = 0;
cartList.value.map((item: any) => {
if (!item.checked) sort += 1;
});
if (sort === 0) checkedAll.value = true;
else checkedAll.value = false;
sort = 0;
}
});
};
// 点击复选框操作
const initCartChecked = (isChecked: number, productIds: any) => {
cartChecked({ isChecked, productIds }).then((res: any) => {
const initCartChecked = (isChecked: number, ids: any, type: number) => {
cartChecked({ isChecked, ids, type }).then((res: any) => {
totalPrice.value = res.data.data.cartTotal.checkedGoodsAmount.toFixed(2);
cartList.value = res.data.data.cartList;
allGoods.value = getAllList();
......@@ -305,7 +327,7 @@ const getCheckedList = (goods: any) => {
return result;
};
onShow(() => initCartIndex());
onShow(() => initCartIndex(type.value));
</script>
<style lang="scss" scoped>
......
......@@ -14,6 +14,9 @@
@change="onChange"
@num-change="numChange"
@add-product="addProduct"
@plus="onPlus"
@confirm="onConfirm"
@blur="onBlur"
></vk-data-goods-sku-popup>
</view>
</template>
......@@ -27,7 +30,7 @@ let skuMode = ref(1);
// 是否打开SKU弹窗
let skuKey = ref(false);
// 后端返回的商品信息
let goodsInfo = ref({});
let goodsInfo = ref({} as any);
let skuPopupRef = ref();
let detailData = ref()
......@@ -36,6 +39,11 @@ let selectedGoodsItem = ref('')
let selectedGoodsSum = ref(1)
let emits = defineEmits(['selected', 'addProduct'])
watch([selectedGoodsItem, selectedGoodsSum],(newVal)=> {
// console.log(newVal);
emits('selected', newVal)
},{immediate:true})
let onChange = (e: any) => {
selectedGoodsItem.value = e.sku_name_arr
}
......@@ -44,10 +52,22 @@ let numChange = (e: any) => {
selectedGoodsSum.value = e
}
watch([selectedGoodsItem, selectedGoodsSum],(newVal)=> {
// console.log(newVal);
emits('selected', newVal)
},{immediate:true})
// 添加自定义规格字段
let onPlus = (index: number) => {
goodsInfo.value.spec_list[index].isPlus = false
}
let onBlur = (val: string, index: number) => {
goodsInfo.value.spec_list[index].isPlus = true
if(!val) return
goodsInfo.value.spec_list[index].custom = val
}
let onConfirm = (val: string, index: number) => {
goodsInfo.value.spec_list[index].isPlus = true
if(!val) return
goodsInfo.value.spec_list[index].custom = val
}
// 初始化 把请求数据变成组件需要的格式
let init = (data: any, id: number) => {
......@@ -71,6 +91,8 @@ let init = (data: any, id: number) => {
specificationList = data.specificationList.map((item: any) => {
return {
name: item.name,
isPlus: true, // 控制自定义规格输入框显示
custom: '', // 自定义规格
list: item.valueList.map((res: any) => {
return {
name: res.value,
......@@ -94,15 +116,36 @@ let onOpenSkuPopup = () => {};
// 关闭弹窗
let SkuPopup = (e: any) => {};
// 选择自定义规格后的逻辑
let custom = (selectShop: any) => {
let flag = false
goodsInfo.value.spec_list.map((item: any, i: number) => {
if(item.custom) {
selectShop.sku_name_arr[i] = item.custom
flag = true
}
})
return {selectShop, flag }
}
// 加入购物车前的判断
let addCartFn = (obj: any) => {
let { selectShop } = obj;
let productId: any = getProductId(selectShop.sku_name_arr)
let shop = custom(selectShop)
let specifications: any = []
if(shop.flag) {
productId = 0
selectShop = shop.selectShop
specifications = shop.selectShop.sku_name_arr
}
addCart({
goodsId: detailId.value,
number: selectShop.buy_num,
productId: productId,
type: 0
type: 0,
specifications
}).then((res: any) => {
if(res.data.code === 200) {
uni.showToast({
......@@ -149,21 +192,16 @@ let buyNow = (selectShop: any) => {
uni.navigateTo({
url: `../order/checkout?type=` + 'goods',
success() {
uni.setStorage({
data: res.data.data,
key: 'buyNowId'
})
if(!uni.getStorageSync('addressId')) {
uni.setStorage({
key: 'addressId',
data: 0
data: 0,
})
}
let storage: any = {
buyNowId: res.data.data,
cartId: 0,
couponId: 0,
userCouponId: 0,
grouponRulesId: 0
}
Object.keys(storage).forEach((prop: any) => {
const el: any = storage[prop];
......@@ -192,7 +230,6 @@ const addProduct = (selectShop: any) => {
goodsInfo.value = {}
detailData.value = undefined
detailId.value = undefined
console.log(goodsInfo.value, 'goodsInfo.value');
}
......
......@@ -217,9 +217,8 @@ const onClick = (e: any) => {
}
};
// 打开sku
const buttonClick = () => {
console.log(detailData.value, detailId.value, '加入');
goodsSkuRef.value.init(detailData.value, detailId.value)
goodsSkuRef.value.skuKey = true
};
......
......@@ -19,15 +19,15 @@
<u-image
width="140rpx"
height="200rpx"
:src="item.picUrl.split('http').length > 1 ? item.picUrl : baseUrl + item.picUrl"
:src="item.picUrl?.split('http').length > 1 ? item.picUrl : baseUrl + item.picUrl"
class="img"
></u-image>
<view class="right">
<view class="name">{{ item.goodsName }}</view>
<view class="tag">
<block v-for="(item1, index1) in item.specifications.length" :key="index1">
<block v-for="(item1, index1) in item.specifications?.length" :key="index1">
<u-tag
:text="item.specifications[index1]"
:text="item?.specifications[index1]"
type="info"
size="mini"
style="margin: 8rpx 8rpx 8rpx 0pt;"
......@@ -70,7 +70,7 @@
</template>
<script setup lang="ts">
import { onShow, onHide, onLoad } from '@dcloudio/uni-app';
import { onShow, onLoad } from '@dcloudio/uni-app';
import { ref } from 'vue';
import { checkoutCart, orderDetail, orderSubmit } from '@/api/index';
import config from '@/utils/config';
......@@ -95,14 +95,15 @@ const tapAddresss = () => {
// 结算
const onsubmit = () => {
let types = 0;
if (type.value === 'productline') types = 2;
else types = 0;
let data: object = {
addressId: uni.getStorageSync('addressId'),
cartId: uni.getStorageSync('cartId'),
couponId: uni.getStorageSync('couponId'),
grouponLinkId: 0,
grouponRulesId: uni.getStorageSync('grouponRulesId'),
message: remarks.value,
userCouponId: 0,
type: types,
};
// 提交订单
orderSubmit(data).then((res: any) => {
......@@ -112,7 +113,7 @@ const onsubmit = () => {
}).then((res1: any) => {
console.log(res1, '订单详情信息');
uni.navigateTo({
url: `/pages/order/downPdf?data=${JSON.stringify(res1.data.data)}`,
url: `/pages/order/downPdf?data=${JSON.stringify(res1.data.data)}&type=${type.value}`,
});
});
}
......@@ -120,22 +121,14 @@ const onsubmit = () => {
};
// 初始化数据
const initCheckoutCart = (cartId: number) => {
const initCheckoutCart = (cartId: number, types: number) => {
let couponId = uni.getStorageSync('couponId');
let userCouponId = uni.getStorageSync('userCouponId');
let grouponRulesId = uni.getStorageSync('grouponRulesId');
let addressId = uni.getStorageSync('addressId');
if (type.value === 'cart') cartId = 0;
if (type.value === 'goods' && cartId === 0) {
buyNowId.value = uni.getStorageSync('buyNowId');
initCheckoutCart(buyNowId.value);
}
checkoutCart({
cartId,
couponId,
userCouponId,
grouponRulesId,
addressId,
type: types,
}).then((res: any) => {
if (res.data.code === 200) {
buyNowData.value = res.data.data;
......@@ -143,8 +136,6 @@ const initCheckoutCart = (cartId: number) => {
addressId: res.data.data.addressId,
cartId: res.data.data.cartId,
couponId: res.data.data.couponId,
userCouponId: res.data.data.userCouponId,
grouponRulesId: res.data.data.grouponRulesId,
};
Object.keys(storage).forEach((prop: any) => {
const el: any = storage[prop];
......@@ -159,7 +150,19 @@ const initCheckoutCart = (cartId: number) => {
};
onShow(() => {
initCheckoutCart(buyNowId.value);
if (type.value === 'cart') {
buyNowId.value = 0;
initCheckoutCart(buyNowId.value, 2);
type.value = '';
}
if (type.value === 'goods') {
buyNowId.value = uni.getStorageSync('buyNowId');
initCheckoutCart(buyNowId.value, 0);
}
if (type.value == 'productline') {
buyNowId.value = uni.getStorageSync('buyNowId');
initCheckoutCart(buyNowId.value, 2);
}
});
</script>
......
<template>
<!-- <u-navbar back-text="" title="订单详情" title-color="#000"></u-navbar> -->
<view class="container">
<view v-for="(item, index) in detailData" class="details">
<u-image
......@@ -30,32 +31,37 @@
<u-button shape="circle" type="error" size="mini" @tap="toIndex">返回首页</u-button>
<u-button shape="circle" size="mini" @tap="download">下载pdf</u-button>
</view>
</view>
</template>
<script setup lang="ts">
import { ref } from 'vue';
import { onLoad, onHide } from '@dcloudio/uni-app';
import { onLoad, onHide, onBackPress } from '@dcloudio/uni-app';
import config from '@/utils/config';
import { useStore } from '@/store/useStore';
import { getOrderPdf, quotationInit } from '@/api/cart';
const baseUrl = config.baseUrl;
let enclosure = ref('');
let baseUrl = config.baseUrl;
let store = useStore();
let enclosure = ref(''); // pdf key值
let detailData = ref();
let type = ref();
onLoad((options: any) => {
type.value = options.type;
let data = JSON.parse(options.data);
enclosure.value = data.orderInfo.enclosure;
detailData.value = data.orderGoods;
initPdf(data.orderInfo.id);
initQuotation(data.orderInfo.id);
console.log(enclosure.value, data);
});
let toIndex = () => {
uni.reLaunch({
url: '../index/index'
})
}
url: '../index/index',
});
};
// 下载pdf
let download = () => {
......@@ -85,12 +91,35 @@ let download = () => {
});
};
// onHide(() => {
// uni.setStorage({
// key: 'buyNowId',
// data: 0,
// });
// });
let initPdf = (orderId: number) => {
getOrderPdf({ orderId }).then((res: any) => {
if (res.data.code === 200) {
console.log(res, 'pdf');
}
});
};
let initQuotation = (orderId: number) => {
quotationInit({ orderId }).then((res: any) => {
if (res.data.code === 200) {
console.log(res, 'baojia');
}
});
};
onBackPress(() => {
if (type.value === 'productline') {
store.$reset();
uni.reLaunch({
url: '../productLine/productLine',
});
} else {
uni.reLaunch({
url: '../index/index',
});
}
return true;
});
</script>
<style lang="scss" scoped>
......@@ -126,7 +155,7 @@ let download = () => {
}
}
}
.footer {
margin-top: 50rpx;
padding: 50rpx 25%;
......
export const imgList = [
{
id: 1,
url: '../../static/cpx/line2.png',
show: false,
},
{
id: 2,
url: '../../static/cpx/line3.png',
show: false
},
// {
// id: 3,
// url: '../../static/cpx/line4.png',
// show: false
// },
// {
// id: 4,
// url: '../../static/cpx/line5.png',
// show: false
// },
// {
// id: 5,
// url: '../../static/cpx/line6.png',
// show: false
// },
// {
// id: 6,
// url: '../../static/cpx/line7.png',
// show: false
// },
// {
// id: 7,
// url: '../../static/cpx/line8.png',
// show: false
// },
// {
// id: 8,
// url: '../../static/cpx/line9.png',
// show: false
// },
// {
// id: 9,
// url: '../../static/cpx/line1.png',
// show: false
// }
{},
];
<template>
<u-navbar
:is-back="false"
title="产品线"
:background="{ background: '#f8f8f8' }"
title-bold
title-color="#000"
>
<template #right>
<view style="margin-right: 30rpx" @tap="reset">重置</view>
</template>
</u-navbar>
<view class="u-wrap">
<view class="u-menu-wrap">
<view style="position: fixed; left: 8rpx; top: 5%;">
......@@ -59,13 +70,27 @@
<!-- 设置标题 -->
<set-title ref="setTitleRef" />
<!-- model提示框 -->
<u-modal
v-model="model.show"
:content="model.content"
show-cancel-button
@confirm="onConfirm"
></u-modal>
</template>
<script lang="ts" setup>
import { ref } from 'vue';
import { indexDetails } from '@/api/index';
import { useStore } from '@/store/useStore';
import { addProductLineCart, productLineCollect, delProductLineCollect } from '@/api/productLine';
import {
addProductLineCart,
productLineCollect,
delProductLineCollect,
productLineByuNow,
getProductLineByuNowData,
} from '@/api/productLine';
import config from '@/utils/config';
import dragAndDropSort from './components/drag-and-drop-sort.vue';
import categoryPopup from './components/categoryPopup.vue';
......@@ -83,7 +108,10 @@ let setTitleRef = ref();
let dragRef = ref();
let detailData = ref();
let star = ref(store.star);
let collectData = ref();
let model = ref({
show: false,
content: '确定重置所选产品?',
});
let options = ref([
{
......@@ -121,6 +149,7 @@ let onClick = (e: any) => {
// 收藏
if (!star.value) {
if (JSON.stringify(store.collectData) === '{}') {
// 初次收藏
complete().then((data: any) => {
productLineCollect(data).then((res: any) => {
if (res.data.code === 200) {
......@@ -133,11 +162,15 @@ let onClick = (e: any) => {
});
star.value = true;
options.value[0].icon = 'star-filled';
uni.showToast({
title: '收藏成功',
icon: 'none',
});
}
});
});
} else {
console.log(star.value);
// 收藏取消后收藏
delProductLineCollect(store.collectData).then((res: any) => {
if (res.data.code === 200) {
store.$patch({
......@@ -145,10 +178,15 @@ let onClick = (e: any) => {
});
star.value = true;
options.value[0].icon = 'star-filled';
uni.showToast({
title: '收藏成功',
icon: 'none',
});
}
});
}
} else {
// 取消收藏
delProductLineCollect(store.collectData).then((res: any) => {
if (res.data.code === 200) {
store.$patch({
......@@ -156,6 +194,10 @@ let onClick = (e: any) => {
});
star.value = false;
options.value[0].icon = 'star';
uni.showToast({
title: '取消收藏',
icon: 'none',
});
}
});
}
......@@ -169,7 +211,7 @@ let buttonClick = (e: any) => {
addCart();
break;
case 1:
console.log('下单', JSON.stringify(store.lineData));
buyNow();
break;
default:
break;
......@@ -192,7 +234,36 @@ let addCart = () => {
};
// 立即购买
let buyNow = () => {};
let buyNow = () => {
complete().then((data: any) => {
addProductLineCart(data).then((res: any) => {
if (res.data.code === 200) {
console.log('okla');
if (!uni.getStorageSync('addressId')) {
uni.setStorage({
key: 'addressId',
data: 0,
});
}
let storage: any = {
buyNowId: res.data.data,
cartId: 0,
couponId: 0,
};
Object.keys(storage).forEach((prop: any) => {
const el: any = storage[prop];
uni.setStorage({
key: prop,
data: el,
});
});
uni.navigateTo({
url: `../order/checkout?type=` + 'productline',
});
}
});
});
};
// 点击 收藏,加入购物车,立即购买 前逻辑
let complete = () => {
......@@ -262,11 +333,20 @@ let initDetails = (id: number) => {
});
};
// 重置产品线
let reset = () => (model.value.show = true);
//确认重置
let onConfirm = () => {
reload();
model.value.show = false;
};
// 重置页面数据
let reload = () => {
store.$reset(); // 重置pinia数据
let pages = getCurrentPages(); //获取所有页面的数组对象
let currPage: any = pages[pages.length - 1]; //当前页面
store.$reset();
uni.reLaunch({
url: '/' + currPage.route,
});
......
<template>
<view>
<drag-and-drop-sort
style="display: flex; justify-content: center;"
:controlsList="controlsList"
:containerSize="{ width: '200px', height: '100vh' }"
:controlsSize="{ width: 200, height: 40 }"
/>
</view>
</template>
<script setup>
import dragAndDropSort from './drag-and-drop-sort.vue';
let controlsList = [
'#fc5531',
'#1481f9',
'#1ab519',
'#32c0eb',
'#e73e60',
'#a663c2',
'#b26801',
'#1c2e6c',
'#cdccc8',
];
</script>
<style scoped lang="scss"></style>
......@@ -3,7 +3,7 @@
<view v-if="collectList.length !== 0">
<goodsItem
v-for="item in collectList"
:src="item.picUrl"
:src="item?.picUrl"
:name="item.name"
:brief="item.brief"
:retailPrice="item.retailPrice"
......@@ -37,8 +37,11 @@ let list = ref([
{
name: '商品收藏',
},
// {
// name: '专题收藏',
// },
{
name: '专题收藏',
name: '产品线',
},
]);
......@@ -59,6 +62,7 @@ let change = (index: number) => {
collectList.value = [];
collectQuery.value.page = 1;
collectQuery.value.type = index;
if (index === 1) collectQuery.value.type = 2;
init();
};
......
<template>
<view class="profile-container">
<view class="profile-info" @tap="toLogin">
<view class="profile-info">
<view class="profile-avatar">
<image style="width: 220rpx;" src="../../static/logo.png" mode="scaleToFill"/>
<image style="width: 220rpx;" src="../../static/logo.png" mode="scaleToFill" />
</view>
<view class="profile-nickname">
<text>{{ nickName }}</text>
</view>
<view class="profile-nickname"><text>{{ nickName }}</text></view>
</view>
<view class="order-center">
......@@ -67,7 +69,7 @@ const toLogin = () => {
});
};
let nickName = uni.getStorageSync('nickName')
let nickName = uni.getStorageSync('nickName');
const orderBtnList = ref([
{
......
......@@ -2,7 +2,7 @@ const CONFIG: any = {
// 开发环境配置
development: {
assetsPath: 'http://192.168.0.23', // 静态资源路径
baseUrl: 'http://192.168.0.23', // 后台接口请求地址
baseUrl: 'http://192.168.0.9:8089', // 后台接口请求地址
hostUrl: 'http://192.168.0.23', // H5地址(前端运行地址)
websocketUrl: '', // websocket服务端地址
},
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论