提交 f4d45d02 authored 作者: 刘旭's avatar 刘旭

查漏补缺

上级 58c63e7e
......@@ -155,6 +155,12 @@
"navigationBarTitleText": "重新报价",
"navigationBarBackgroundColor": "#fff"
}
}, {
"path": "pages/productLine/productLineDetails",
"style": {
"navigationBarTitleText": "产品线详情",
"navigationBarBackgroundColor": "#fff"
}
}
],
"tabBar": {
......
......@@ -103,7 +103,7 @@
<script lang="ts" setup>
import { ref, reactive } from 'vue';
import { getCartIndex, cartChecked, cartDelete, cartUpdate } from '@/api/cart';
import { onShow, onLoad } from '@dcloudio/uni-app';
import { onShow } from '@dcloudio/uni-app';
import _ from 'lodash';
import config from '@/utils/config';
......@@ -206,7 +206,7 @@ const tapOptions = () => {
key: prop,
data: el,
success(res: any) {
if (prop == 'cartId' && el == 0) {
if (prop == 'couponId' && el == 0) {
if (type.value === 0)
uni.navigateTo({ url: `../order/checkout?type=` + 'cart' });
else uni.navigateTo({ url: `../order/checkout?type=` + 'productLineCart' });
......
......@@ -138,7 +138,9 @@ let custom = (selectShop: any) => {
goodsInfo.value.spec_list.map((item: any, i: number) => {
if(item.custom) {
selectShop.sku_name_arr[i] = item.custom
customArr.push(item.custom)
let obj: any = {}
obj[item.name] = item.custom
customArr.push(obj)
flag = true
}
})
......
......@@ -167,6 +167,7 @@ onLoad((options: any) => {
let selectedGoodsItem = ref()
let selectedGoodsSum = ref()
// 选择规格展示
let selectedGoods = computed(() => {
if(selectedGoodsItem.value.length > 0) {
let str = ''
......
......@@ -64,7 +64,9 @@ let clickNextStep = () => {
let initLogin = async (mobile: number, password: string) => {
uni.clearStorage();
let res: any = await login({ mobile, password });
if (res.data.code == 200) {
console.log(res, 'res');
if (res.data.code === 200) {
console.log('2000');
uni.setStorage({
key: 'token',
data: res.data.data.token,
......@@ -94,13 +96,14 @@ let initLogin = async (mobile: number, password: string) => {
},
});
} else {
console.log('5000');
uni.showToast({
title: '手机号或密码错误',
icon: 'none',
duration: 2000,
});
}
};
}
</script>
<style lang="scss" scoped>
......
......@@ -81,10 +81,11 @@ let baseUrl = config.baseUrl;
const buyNowId = ref(uni.getStorageSync('buyNowId') || 0);
const buyNowData = ref();
const remarks = ref(); // 订单备注
const type = ref(''); // 何种方式下单
const type = ref('' as any); // 何种方式下单
onLoad((options: any) => {
type.value = options.type;
console.log(type.value, '.type');
});
// 设置地址
......@@ -97,7 +98,8 @@ const tapAddresss = () => {
// 结算
const onsubmit = () => {
let types = 0;
if (type.value === 'productline') types = 2;
console.log(type.value, 'type.value');
if (type.value === 'productline' || type.value === 'productLineCart') types = 2;
else types = 0;
let data: object = {
addressId: uni.getStorageSync('addressId'),
......@@ -109,16 +111,22 @@ const onsubmit = () => {
// 提交订单
orderSubmit(data).then((res: any) => {
if (res.data.code === 200) {
uni.navigateTo({
url: `/pages/order/downPdf?orderId=${res.data.data.orderId}&type=${
type.value
}`,
});
if (type.value == 'productline' || type.value == 'productLineCart') {
uni.navigateTo({
url: `../productLine/productLineDetails?orderId=${res.data.data.orderId}&type=${
type.value
}`,
});
} else {
uni.navigateTo({
url: `/pages/order/downPdf?orderId=${res.data.data.orderId}&type=${type.value}`,
});
}
// orderDetail({
// orderId: res.data.data.orderId,
// }).then((res1: any) => {
// console.log(res1, '订单详情信息');
// });
}
});
......@@ -158,12 +166,10 @@ onShow(() => {
case 'cart':
buyNowId.value = 0;
initCheckoutCart(buyNowId.value, 0);
type.value = '';
break;
case 'productLineCart':
buyNowId.value = 0;
initCheckoutCart(buyNowId.value, 2);
type.value = '';
break;
case 'goods':
buyNowId.value = uni.getStorageSync('buyNowId');
......
......@@ -91,6 +91,7 @@
</view>
</view>
</view>
<view style="height: 100rpx;"></view>
<view class="footer">
<text>商品总价:¥{{ totlePirce }}</text>
<text>含税商品总价:¥{{ taxTotlePirce }}</text>
......@@ -104,7 +105,6 @@ import config from '@/utils/config';
import { useStore, useCurrentStore } from '@/store/useStore';
// import { getOrderPdf } from '@/api/cart';
import { orderDetail, getTax } from '@/api/index';
import { getProductLineIndex } from '@/api/productLine';
let baseUrl = config.baseUrl;
let store = useStore();
......@@ -124,7 +124,6 @@ onLoad((options: any) => {
enclosure.value = res.data.data.orderInfo.enclosure;
detailData.value = res.data.data.orderGoods;
orderId.value = res.data.data.orderInfo.id;
initProductLineIndex();
}
console.log(res, '订单详情信息');
});
......@@ -225,15 +224,6 @@ let initTax = () => {
});
};
let initProductLineIndex = () => {
console.log(type.value, '产品线type');
detailData.value.map((item: any) => {
getProductLineIndex({ lineId: item.goodsId }).then((res: any) => {
console.log(res, '产品线');
});
});
};
onBackPress(() => {
if (type.value === 'productline') {
store.$reset();
......@@ -300,6 +290,7 @@ onBackPress(() => {
.footer {
position: fixed;
bottom: 0;
z-index: 99;
width: 100%;
height: 100rpx;
background-color: #fff;
......
......@@ -99,28 +99,7 @@ onLoad((options: any) => {
tax.value = Number(res.data.data.mall_tax_rate) * 0.01;
}
});
quotationInitAgain({ orderId: orderId.value }).then((res: any) => {
if (res.data.code === 200) {
quotationData.value = res.data.data;
let data = quotationData.value.quotation;
quotationList.value = [
{ title: '发货人', value: data.attend },
{ title: '发货联系电话', value: data.tel },
{ title: '发货email', value: data.email },
{ title: '发货地址', value: data.addr },
{ title: '收货公司名称', value: data.toCust },
{ title: '收货人', value: data.quotationAttend },
{ title: '收货email', value: data.quotationEmail },
{ title: '收货联系电话', value: data.quotationTel },
{ title: '交货日期', value: data.deliveryDate },
{ title: '收货地址', value: data.deliveryAddr },
{ title: '订单号', value: data.noOrder },
{ title: '付款方式', value: data.pay },
{ title: '保修', value: data.guarantee },
{ title: '备注', value: data.remarks },
];
}
});
init()
});
// 总价格
......@@ -155,6 +134,7 @@ let modelConfirm = () => {
if (content.value === '确认重新报价?') {
fillQuotation(quotationData.value).then((res: any) => {
if (res.data.code === 200) {
init()
showModel.value = false;
}
});
......@@ -205,6 +185,31 @@ let priceInput = (val: any, index: number) => {
quotationData.value.items[index].totalPrice * tax.value +
quotationData.value.items[index].totalPrice;
};
let init = () => {
quotationInitAgain({ orderId: orderId.value }).then((res: any) => {
if (res.data.code === 200) {
quotationData.value = res.data.data;
let data = quotationData.value.quotation;
quotationList.value = [
{ title: '发货人', value: data.attend },
{ title: '发货联系电话', value: data.tel },
{ title: '发货email', value: data.email },
{ title: '发货地址', value: data.addr },
{ title: '收货公司名称', value: data.toCust },
{ title: '收货人', value: data.quotationAttend },
{ title: '收货email', value: data.quotationEmail },
{ title: '收货联系电话', value: data.quotationTel },
{ title: '交货日期', value: data.deliveryDate },
{ title: '收货地址', value: data.deliveryAddr },
{ title: '订单号', value: data.noOrder },
{ title: '付款方式', value: data.pay },
{ title: '保修', value: data.guarantee },
{ title: '备注', value: data.remarks },
];
}
});
};
</script>
<style lang="scss" scoped>
......
......@@ -97,7 +97,7 @@
<view
v-if="res.orderStatusText === '待推送'"
class="evaluate btn"
@tap="orderQuotation(res.id)"
@tap="orderQuotation(res.id, res.type)"
>
生成报价
</view>
......@@ -190,18 +190,6 @@ onLoad((options?: any) => {
getOrderList()
})
// 跳转到订单详情
let toDownPdf = (orderId: number) => {
uni.navigateTo({
url: `/pages/order/downPdf?orderId=${orderId}&type=profile`,
success() {
currentStore.$patch({
current: current.value
})
}
});
}
// 价格小数
let priceDecimal = computed(() => {
return (val: any) => {
......@@ -270,19 +258,37 @@ let orderDel = (orderId: number) => {
orderIds.value = orderId
}
// 生成报价
let orderQuotation = (orderId: number) => {
// 生成报价 type为0是普通订单, 2是生产线订单
let orderQuotation = (orderId: number, type: number) => {
orderIds.value = orderId
quotationExist({ orderId }).then((res: any) => {
if(res.data.code === 200) {
if(res.data.data) {
uni.navigateTo({
url: '../order/editQuotation?orderId=' + orderId
})
} else toDownPdf(orderId)
}
if(type == 0) {
quotationExist({ orderId }).then((res: any) => {
if(res.data.code === 200) {
if(res.data.data) {
uni.navigateTo({
url: '../order/editQuotation?orderId=' + orderId
})
} else toDownPdf(orderId)
}
})
} else {
uni.navigateTo({
url: '../productLine/productLineDetails?orderId=' + orderId
})
}
}
})
// 跳转到订单详情
let toDownPdf = (orderId: number) => {
uni.navigateTo({
url: `/pages/order/downPdf?orderId=${orderId}&type=profile`,
success() {
currentStore.$patch({
current: current.value
})
}
});
}
// 推送订单
......
......@@ -183,15 +183,19 @@ onReady(() => {
let submit = () => {
uFormRef.value?.validate((valid: any, err: any) => {
if(valid) {
quotationData.value.items.forEach((item: any, i: number) => {
if(item.goodsName == unitPrice.value[i].goodsName) {
item.price = unitPrice.value[i].unitPrice
}
quotationData.value.items.forEach((item: any) => {
console.log(item, unitPrice.value);
unitPrice.value.map((res: any) => {
if(item.goodsName == res.goodsName) {
item.price = res.unitPrice
}
})
})
let data = {
items: quotationData.value.items,
quotation: formData.value,
};
console.log(data, 'submit');
fillQuotation(data).then((res: any) => {
if (res.data.code === 200) showModel.value = true
});
......
<template>
<view class="container">
<block v-for="(item, index) in detailData">
<view>
<view class="details">
<u-image
width="140rpx"
height="200rpx"
: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"
>
<u-tag
:text="item.specifications[index1]"
type="info"
size="mini"
style="margin: 8rpx 8rpx 8rpx 0;"
/>
</block>
</view>
<view class="sum-price">
<view style="display: flex; flex-direction: column;">
<view
style="display: flex; flex-direction: row; align-items: center; margin-bottom: 10rpx;"
>
<text>设置单价:</text>
<u-input
v-model="item.unitPrice"
type="number"
height="50"
placeholder="请输入单价"
style="width: 200rpx;"
/>
</view>
<view style="margin-bottom: 10rpx;">
金额:¥{{
item.unitPrice
? (Number(item.unitPrice) * item.number).toFixed(2)
: 0
}}
</view>
<view style="margin-bottom: 10rpx;">
含税金额:¥{{
item.unitPrice
? (
Number(item.unitPrice) * item.number +
Number(item.unitPrice) *
item.number *
tax *
0.01
).toFixed(2)
: 0
}}
</view>
</view>
<text style="color: #969799; font-size: 12px;">x{{ item.number }}</text>
</view>
</view>
</view>
<u-line v-if="detailData.length > 1" color="#e8e8e8" />
</view>
</block>
<view class="content-footer">
<u-button
shape="circle"
type="error"
size="mini"
style="margin-right: 30;"
@tap="toIndex"
>
返回首页
</u-button>
<view class="">
<u-button shape="circle" size="mini" @tap="generateQuote">生成报价</u-button>
<u-button shape="circle" size="mini" style="margin-left: 20rpx;" @tap="download">
下载pdf
</u-button>
</view>
</view>
</view>
<view style="height: 100rpx;"></view>
<view class="footer">
<text>商品总价:¥{{ totlePirce }}</text>
<text>含税商品总价:¥{{ taxTotlePirce }}</text>
</view>
</template>
<script setup lang="ts">
import { ref, computed } from 'vue';
import { onLoad } from '@dcloudio/uni-app';
import config from '@/utils/config';
import { getTax, orderDetail } from '@/api/index';
import { quotationInit } from '@/api/cart';
import { getProductLineIndex } from '@/api/productLine';
let baseUrl = config.baseUrl;
let enclosure = ref(''); // pdf key值
let detailData = ref([] as any);
let type = ref();
let orderId = ref();
let tax = ref(0); // 税率
onLoad((options: any) => {
type.value = options.type;
orderId.value = options.orderId
initOrderData(options.orderId);
// initQuotationInit(options.orderId);
// initPdf(options.orderId); // 查询pdf详细资料
initTax(); // 查询税率
});
// 返回首页
let toIndex = () => {
uni.reLaunch({
url: '../index/index',
});
};
// 生成报价
let generateQuote = () => {
let data = [] as any;
let flag = true;
detailData.value.map((item: any) => {
if (typeof item.unitPrice === 'undefined') {
flag = false;
return uni.showToast({
title: `请填写 ${item.goodsName} 单价`,
icon: 'none',
});
} else
data.push({
goodsName: item.goodsName,
unitPrice: item.unitPrice,
});
});
if (flag)
uni.navigateTo({
url: `../order/quotation?orderId=${orderId.value}&data=${JSON.stringify(data)}`,
});
};
// 总价格
let totlePirce: any = computed(() => {
let totlePic = 0;
if (detailData.value) {
detailData.value.map((item: any) => {
if (typeof item.unitPrice !== 'undefined') {
totlePic += Number(item.unitPrice);
}
});
}
return totlePic.toFixed(2);
});
// 含税总价格
let taxTotlePirce = computed(() => {
let taxTotlePic = Number(totlePirce.value) + Number(totlePirce.value) * tax.value * 0.01;
return Number(taxTotlePic).toFixed(2);
});
// 下载pdf
let download = () => {
uni.showLoading({
title: '正在请求数据',
});
uni.request({
url: baseUrl + '/wx/storage/download/' + enclosure.value,
responseType: 'arraybuffer',
success: (res: any) => {
uni.hideLoading();
if (res.data) {
let blob = new Blob([res.data]);
let downloadElement = document.createElement('a');
let href = window.URL.createObjectURL(blob); //创建下载的链接
downloadElement.href = href;
downloadElement.download = enclosure.value + '.pdf'; //下载后文件名
document.body.appendChild(downloadElement);
downloadElement.click(); //点击下载
document.body.removeChild(downloadElement); //下载完成移除元素
window.URL.revokeObjectURL(href); //释放掉blob对象
}
},
fail(err: any) {
console.log(err);
},
});
};
// 获取下载pdf信息
// let initPdf = (orderId: number) => {
// getOrderPdf({ orderId }).then((res: any) => {
// if (res.data.code === 200) {
// console.log(res, 'pdf');
// }
// });
// };
// 获取税率
let initTax = () => {
getTax().then((res: any) => {
if (res.data.code === 200) tax.value = Number(res.data.data.mall_tax_rate);
});
};
let initQuotationInit = (orderId: number) => {
quotationInit({ orderId }).then((res: any) => {
console.log(res, '产品线');
});
};
// 获取goodsId
let initOrderData = (orderId: number) => {
orderDetail({ orderId }).then((res: any) => {
if (res.data.code === 200) {
res.data.data.orderGoods.map((item: any) => {
initProductLineIndex(item.goodsId);
});
}
});
};
// 通过goodsId查询产品线数据
let initProductLineIndex = (lineId: number) => {
getProductLineIndex({ lineId }).then((res: any) => {
if (res.data.code === 200) {
detailData.value = [...res.data.data.cartList, ...detailData.value];
console.log(res, 'lineId');
}
});
};
</script>
<style lang="scss" scoped>
.container {
box-sizing: border-box;
margin: 16rpx 32rpx;
background-color: #fff;
.details {
width: 100%;
padding: 16rpx 32rpx;
display: flex;
flex-direction: row;
justify-content: flex-start;
align-items: center;
.img {
margin-right: 20rpx;
}
.tag {
margin-top: 1%;
display: flex;
flex-direction: row;
flex-wrap: wrap;
margin-bottom: 5%;
}
.right {
width: 80%;
.sum-price {
display: flex;
justify-content: space-between;
}
}
}
.content-footer {
margin-top: 50rpx;
padding: 50rpx;
width: 100%;
display: flex;
justify-content: space-between;
align-items: center;
}
}
.footer {
position: fixed;
bottom: 0;
z-index: 99;
width: 100%;
height: 100rpx;
background-color: #fff;
padding: 0 32rpx;
line-height: 100rpx;
font-size: 30rpx;
font-weight: 600;
display: flex;
justify-content: space-between;
}
</style>
......@@ -7,8 +7,8 @@ function request(url: string, method: 'GET' | 'POST' | 'PUT' | 'DELETE', data?:
return new Promise(function(resolve, reject) {
let header: any;
uni.showLoading({
title: '加载中...'
})
title: '加载中...',
});
if (uni.getStorageSync('token') !== undefined && uni.getStorageSync('token') !== '') {
header = {
'content-type': 'application/json',
......@@ -38,22 +38,12 @@ function request(url: string, method: 'GET' | 'POST' | 'PUT' | 'DELETE', data?:
uni.hideLoading();
if (res.data.code == 200) {
resolve(res);
} else if (res.data.code == 501) {
nextTick(() => {
uni.reLaunch({
url: '/pages/login/login',
success() {
uni.showToast({
title: res.data.msg,
icon: 'none',
});
},
fail(err) {
console.log(err);
},
});
} else if (res.data.code == 500) {
uni.showToast({
title: res.data.msg,
icon: 'none',
});
} else if (res.error === 'invalid_token') {
} else if (res.error == 'invalid_token') {
console.log('token', res);
uni.clearStorage();
} else {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论