Commit db6ece49 by 谢中龙

C端订单拆单实现

parent 2d129b1f
......@@ -790,7 +790,6 @@ wxService.page({
},
//下单
order(isSelect, params) {
if (this.data.orderStoreInfo) {
if (this.data.orderStoreInfo.storeId) {
params.storeId = this.data.orderStoreInfo.storeId;
......@@ -810,74 +809,88 @@ wxService.page({
wx.removeStorageSync('orderRemark');
if (result == 0) {
delete data.appId
let amount = data.amount || 0
wx.requestPayment(Object.assign({
success(res) {
wx.hideLoading()
//消息订阅
let baseUserInfo = wx.getStorageSync('_baseUserInfo');
wxService.post(`${'/merchant/message/wxSubMsgMapping/getListByParams'}`, {
scenarioIds: ['ordersend', 'orderconfirm'],
sourceFrom: 2,
switchType: 3
}).then(res => {
let tempArr = res.data.data ? res.data.data : [];
let currentType = _this.data.currentType;
if (tempArr.length == 0){
wx.redirectTo({
url: `/subPackage/page/pages/paymentStatus/paymentStatus?status=S&amount=${amount}&type=${currentType}`,
});
return ;
}
let tempids = [];
tempArr.map(item => {
tempids.push(item.templateId);
});
wx.requestSubscribeMessage({
tmplIds: tempids,
success: (res)=>{
for(let i = 0; i < tempArr.length; i++){
wxService.post(`${'/merchant/message/wxSubMsgSubscride/member/subscribe'}`, {
businessId: tradeId,
memberId: baseUserInfo.memberId,
scenarioId:tempArr[i].scenarioId,
templateId: tempArr[i].templateId
}).then(resp => {});
}
},
complete: (res)=>{
let amount = data.amount || 0;
if(amount > 0){
wx.requestPayment(Object.assign({
success(res) {
wx.hideLoading()
//消息订阅
let baseUserInfo = wx.getStorageSync('_baseUserInfo');
wxService.post(`${'/merchant/message/wxSubMsgMapping/getListByParams'}`, {
scenarioIds: ['ordersend', 'orderconfirm'],
sourceFrom: 2,
switchType: 3
}).then(res => {
let tempArr = res.data.data ? res.data.data : [];
let currentType = _this.data.currentType;
if (tempArr.length == 0){
wx.redirectTo({
url: `/subPackage/page/pages/paymentStatus/paymentStatus?status=S&amount=${amount}&type=${currentType}`,
});
return ;
}
let tempids = [];
tempArr.map(item => {
tempids.push(item.templateId);
});
wx.requestSubscribeMessage({
tmplIds: tempids,
success: (res)=>{
for(let i = 0; i < tempArr.length; i++){
wxService.post(`${'/merchant/message/wxSubMsgSubscride/member/subscribe'}`, {
businessId: tradeId,
memberId: baseUserInfo.memberId,
scenarioId:tempArr[i].scenarioId,
templateId: tempArr[i].templateId
}).then(resp => {});
}
},
complete: (res)=>{
wx.redirectTo({
url: `/subPackage/page/pages/paymentStatus/paymentStatus?status=S&amount=${amount}&type=${currentType}`,
});
}
})
}).catch(err => {
let currentType = _this.data.currentType;
wx.redirectTo({
url: `/subPackage/page/pages/paymentStatus/paymentStatus?status=S&amount=${amount}&type=${currentType}`,
});
})
}).catch(err => {
let currentType = _this.data.currentType;
wx.redirectTo({
url: `/subPackage/page/pages/paymentStatus/paymentStatus?status=S&amount=${amount}&type=${currentType}`,
});
})
},
fail(res) {
wx.hideLoading();
wx.showToast({
title: '支付已取消',
icon: 'none'
});
if (_this.data.currentType == 'delivery') {
wx.redirectTo({
url: '/pages/order/order',
});
}
else {
wx.redirectTo({
url: '/subPackage/page/pages/selfPickUpOrderList/selfPickUpOrderList',
},
fail(res) {
wx.hideLoading();
wx.showToast({
title: '支付已取消',
icon: 'none'
});
if (_this.data.currentType == 'delivery') {
wx.redirectTo({
url: '/pages/order/order',
});
}
else {
wx.redirectTo({
url: '/subPackage/page/pages/selfPickUpOrderList/selfPickUpOrderList',
});
}
}
}, data.wxParams));
}
else{
if (_this.data.currentType == 'delivery') {
wx.redirectTo({
url: '/pages/order/order',
});
}
}, data.wxParams));
else {
wx.redirectTo({
url: '/subPackage/page/pages/selfPickUpOrderList/selfPickUpOrderList',
});
}
}
}
}
});
......
......@@ -25,22 +25,12 @@ wxService.page({
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
wx.hideShareMenu()
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
const { params } = this.options
let detail = JSON.parse(params)
// supplierCode code
if(detail.id){
let detail = options.params ? JSON.parse(options.params) : null;
if(detail){
this.data.logisticCompanyName = detail.logistic.supplierName ? detail.logistic.supplierName : '暂无';
this.data.logisticNo = detail.logistic.code ? detail.logistic.code : '暂无';
this.setData({
params,
detail,
orderId: detail.id,
status: detail.status,
orderCode: detail.logistic.supplierCode,
......@@ -51,39 +41,17 @@ wxService.page({
const {orderCode, orderLogisticsNo} = this.data
this.getLogisticsInfo(orderCode, orderLogisticsNo)
})
}
},
//申请退货
handelReturnGood() {
const {params} = this.data
// 退款申请
wxService.router(`/pages/refund/refund`).search({params})
};
wx.hideShareMenu()
},
// 确认收货
handelConfirmReceipt() {
const { orderId } = this.data
wx.showLoading({
title: '加载中',
mask: true
})
wxService.post(`/sale/trade/buyer/confirm/${orderId}`).then(res => {
if (res) {
const { result, data } = res.data
if (result == 0) {
wx.hideLoading()
wx.showToast({
title: `您已确认收货!`,
icon: 'none'
})
} else {
wx.showToast({
title: `确认收货失败!`,
icon: 'none'
})
}
}
})
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
// 获取物流信息
getLogisticsInfo(code,num){
wxService.get(`/sale/logistics/getLogisticsDetail?companyCode=${code}&logisticsNo=${num}`).then(res => {
......@@ -126,12 +94,6 @@ wxService.page({
});
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
......@@ -140,24 +102,5 @@ wxService.page({
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})
\ No newline at end of file
......@@ -6,7 +6,7 @@
<view class="logistics-status">
<view class="status">物流公司:{{logisticCompanyName}}</view>
<view class="desc">物流单号:{{logisticNo}}</view>
<view class="copy" bindtap="copy" data-content="89687687687687786">复制</view>
<view class="copy" bindtap="copy" data-content="{{logisticNo}}">复制</view>
</view>
</view>
......@@ -38,13 +38,8 @@
</view>
</view>
<!-- <view class="button-wrap" wx:if="{{status == 'D'}}">
<button class="btn btn-primary btn-lg" bindtap="handelConfirmReceipt">确认收货</button>
</view> -->
</view>
<!-- <view wx:if="{{!orderId || !hasLogisticInfo}}" class="df no-logis">
</view> -->
<!-- 空 -->
<empty text="当前暂无快递物流信息,请耐心等待~" wx:if="{{!orderId || !hasLogisticInfo}}"/>
......
......@@ -3,6 +3,25 @@ const app = getApp()
const wxService = require('../../utils/wxService')
const utils = require('../../utils/util')
const envInfo = require('../../config/index').envInfo
const ORDER_STATUS_TEXT = {
N: "待付款",
P: "已支付待发货",
D: "已发货",
R: "已完成",
C: "已关闭",
PR : "退货中",
RE : "退货完成",
};
const STATUS_CLASS = {
N: "package-status-color-N",
P: "package-status-color-P",
D: "package-status-color-D",
R: "package-status-color-R",
C: "package-status-color-C",
PR : "package-status-color-C",
RE : "package-status-color-C",
}
wxService.page({
/**
......@@ -112,12 +131,16 @@ wxService.page({
},
// 确认收货
handelConfirmReceipt(e) {
const { id } = e.currentTarget.dataset
wx.showLoading({
title: '加载中',
mask: true
})
wxService.post(`/sale/trade/buyer/confirm/${id}`).then(res => {
let id = e.currentTarget.dataset.id;
let packageInfo = e.currentTarget.dataset.package;
let parcelId = packageInfo.id;
wxService.post(`/sale/trade/buyer/parcelConfirm?findId=${id}&parcelId=${parcelId}`).then(res => {
if (res) {
const { result, data } = res.data
if (result == 0) {
......@@ -141,6 +164,72 @@ wxService.page({
}
})
},
// 取消订单
handelCancelOrder(e) {
let _this = this;
wx.showModal({
title: '订单取消提示',
content: '确认取消此订单?',
showCancel: true,
cancelText: '再想想',
confirmText: '取消订单',
confirmColor: '#cb3c3c',
success: function (modalRes) {
if (modalRes.confirm) {
//跳去开卡
const { id } = e.currentTarget.dataset
wx.showLoading({
title: '订单取消中..',
mask: true
});
wxService.post(`/sale/trade/buyer/cancel/${id}`).then(res => {
if (res) {
const { result } = res.data
if (result == 0) {
wx.hideLoading()
wx.showToast({
title: `取消成功!`,
icon: 'none'
})
setTimeout(() => {
_this.initOrderList(_this.data.pageNo, _this.data.pageSize, _this.data.status)
}, 200)
} else {
wx.showToast({
title: `取消失败!`,
icon: 'none'
})
}
}
})
}
}
});
},
// 申请退款
handelRequestRefund(e) {
let orderId = e.currentTarget.dataset.id;
let packageInfo = e.currentTarget.dataset.package;
let detail = {
id : orderId,
skuVOList :packageInfo.sendOutList,
}
let copyOrderInfo = JSON.parse(JSON.stringify(detail));
//过滤掉已经退货完的商品
copyOrderInfo.skuVOList = copyOrderInfo.skuVOList.filter(item => item.canRefundNum > 0);
//更新可退货数量
copyOrderInfo.skuVOList.forEach(item => {
item.totalCount = item.count;
item.count = item.canRefundNum;
});
let params = JSON.stringify(copyOrderInfo);
// 退款申请
wxService.router(`/pages/refund/refund`).search({params})
},
// 删除订单
handelDelOrder(e) {
let _this = this;
......@@ -184,6 +273,7 @@ wxService.page({
},
// 立即支付
handelToPay(e) {
let _this= this;
const { id, merged } = e.currentTarget.dataset
let url = merged ? `/sale/payment/merged/buyer/wxprepay/${id}` : `/sale/trade/buyer/wxprepay/${id}`
wx.showLoading({
......@@ -201,11 +291,17 @@ wxService.page({
success(res) {
wx.hideLoading()
// 支付成功页面
wxService.router(`/subPackage/page/pages/paymentStatus/paymentStatus?status=S&amount=${amount}`)
wx.showToast({
title: '支付成功',
});
_this.initOrderList(_this.data.pageNo, _this.data.pageSize, _this.data.status)
},
fail(res) {
wx.hideLoading()
wxService.router('/subPackage/page/pages/paymentStatus/paymentStatus?status=F')
wx.showToast({
title: '支付失败',
});
}
}, data))
......@@ -215,26 +311,20 @@ wxService.page({
},
// 查看物流
checkLogistics(e) {
let { detail } = e.currentTarget.dataset
let copyOrderInfo = JSON.parse(JSON.stringify(detail));
//过滤掉已经退货完的商品
copyOrderInfo.skuVOList = copyOrderInfo.skuVOList.filter(item => item.canRefundNum > 0);
//更新可退货数量
copyOrderInfo.skuVOList.forEach(item => {
item.totalCount = item.count;
item.count = item.canRefundNum;
});
let { detail } = e.currentTarget.dataset;
let obj = {
id: copyOrderInfo.id,
logistic: copyOrderInfo.logistic,
status: copyOrderInfo.status,
id: this.data.id,
logistic: {
supplierName : detail.supplierName,
code : detail.code,
supplierCode : detail.supplierCode,
},
status: detail.status,
}
let params = JSON.stringify(obj);
// 退款申请
wxService.router(`/pages/logistics/logistics`).search({ params })
// // 退款申请
wxService.router(`/pages/logistics/logistics`).search({params});
},
// 查看详情
handelCheckRfDetail(e) {
......@@ -257,6 +347,7 @@ wxService.page({
const { id } = e.currentTarget.dataset
this.handelRevokeRefund(id)
},
handelRevokeRefund(id) {
wx.showLoading({
title: '加载中',
......@@ -314,16 +405,94 @@ wxService.page({
if (res) {
const { result, data } = res.data
if (result == 0) {
wx.hideLoading()
wx.hideLoading();
let orderList = data ? data : [];
// 处理包裹数据信息
orderList.forEach(item => {
item.statusText = ORDER_STATUS_TEXT[item.status];
let parcelList = item.parcelList ? item.parcelList : [];
if(parcelList.length == 0){
let skuVOList = item.skuVOList ? item.skuVOList : [];
skuVOList.forEach(sku => {
sku.refundCount = sku.refundCount ? sku.refundCount : 0;
sku.canRefundNum = (sku.count - sku.refundCount) >= 0 ? (sku.count - sku.refundCount) : 0;
});
if(item.status == 'N' || item.status == 'C'){
parcelList = [{
code : '',
supplierCode : '',
supplierName : '',
status : item.status,
statusText : item.statusText,
statusClass : STATUS_CLASS[item.status],
orderCanRefund : false,
sendOutList : item.skuVOList
}];
}
else{
parcelList = [{
code : '',
supplierCode : '',
supplierName : '',
status : item.status,
statusText : item.statusText,
statusClass : STATUS_CLASS[item.status],
orderCanRefund : true,
sendOutList : item.skuVOList
}];
}
}
else{
parcelList.forEach(p => {
p.deliverTime = p.deliverTime ? p.deliverTime : '';
//计算一下包裹能不能退货
let deliverTime = p.deliverTime ? p.deliverTime : null;
p.statusText = ORDER_STATUS_TEXT[p.status];
p.statusClass = STATUS_CLASS[p.status];
if(deliverTime){
let diffObj = utils.getDateDiff(deliverTime);
if (diffObj.days <= this.data.canRefundDaysAfterDelivery){
p.orderCanRefund = true;
}
else{
p.orderCanRefund = false;
}
}
else{
p.orderCanRefund = true;
}
//找商品填充
let sendOutList = [];
p.sendOutList.forEach(s => {
let filter = item.skuVOList.filter(f => f.skuId == s.skuId);
if(filter.length > 0){
sendOutList.push(filter[0]);
}
});
p.sendOutList = sendOutList;
});
}
item.parcelList = parcelList;
})
console.log(orderList)
if(this.data.pageNo == 1){
this.data.orderList = orderList;
}
else{
this.data.orderList = [...this.data.orderList,...orderList];
}
this.setData({
orderList: this.data.pageNo == 1 ? [...data] : [...this.data.orderList, ...data],
noMoreFlag: data.length < pageSize ? true : false,
}, () => {
this.setData({
no_data: this.data.orderList.length ? true : false
})
// wx.setStorageSync('orderList', this.data.orderList)
})
no_data: this.data.orderList.length ? true : false
});
}
}
})
......
......@@ -16,55 +16,85 @@
<!-- 订单布局 -->
<view class="order-content order-list-new clear-box" wx:if="{{currentIndex != 5}}">
<!-- 这里订单布局 -->
<view class="order-item-new">
<view class="order-new-no">
<view class="order-item-new"
wx:for="{{orderList}}"
wx:for-item="item"
wx:for-index="idx"
wx:key="*this">
<view class="order-new-no" bindtap="handelDetail" data-id="{{item.id}}">
<view class="order-new-no-lf">
订单编号:102024525214152524
<view class="copy" data-no="{{87878978}}" bindtap="onTapCopy">复制</view>
订单编号:{{item.id}}
<view class="copy" data-no="{{item.id}}" catchtap="onTapCopy">复制</view>
</view>
<image src="/assets/imgs/arrow-right.png" mode="aspectFit"></image>
</view>
<!-- 包裹 -->
<view class="order-package clear-box">
<view class="order-package clear-box"
wx:for="{{item.parcelList}}"
wx:for-item="packageInfo"
wx:for-index="cIndex"
wx:key="*this">
<view class="package-titile">
<view class="package-name">包裹1</view>
<view class="package-status-color-P">待发货</view>
<view class="package-name">包裹{{cIndex+1}}</view>
<view class="{{packageInfo.statusClass}}">{{packageInfo.statusText}}</view>
</view>
<!-- 商品数据 -->
<view class="package-products clear-box">
<view class="product-item">
<image src="https://img3.bigaka.com/test/1002/202003/20200302/1002c503d764-c600-4efb-a02b-339ed03b7e9b.jpg" class="lf-product-img" mode="aspectFit"></image>
<view class="package-products clear-box" data-id="{{item.id}}" bindtap="handelDetail">
<view class="product-item"
wx:for="{{packageInfo.sendOutList}}"
wx:for-item="sku"
wx:for-index="sIndex"
wx:key="*this">
<image src="{{sku.skuImgUrl ? sku.skuImgUrl : sku.mainImgUrl}}" class="lf-product-img" mode="aspectFit"></image>
<view class="rg-product-info">
<view class="pro-name">这个是商品的名称</view>
<view class="pro-spec">这个是商品规格</view>
<view class="pro-name">{{sku.productName}}</view>
<view class="pro-spec">{{sku.skuSpec}}</view>
<view class="pro-count">
<text>数量</text>
<label>x2</label>
<label>x{{sku.count}}</label>
</view>
<view class="refund-count">
<view class="refund-count" wx:if="{{sku.refundCount > 0}}">
<text>退单</text>
<label>x1</label>
</view>
</view>
</view>
<view class="product-item">
<image src="https://img3.bigaka.com/test/1002/202003/20200302/1002c503d764-c600-4efb-a02b-339ed03b7e9b.jpg" class="lf-product-img" mode="aspectFit"></image>
<view class="rg-product-info">
<view class="pro-name">这个是商品的名称</view>
<view class="pro-spec">这个是商品规格</view>
<view class="pro-count">
<text>数量</text>
<label>x2</label>
<label>x{{sku.refundCount}}</label>
</view>
</view>
</view>
</view>
<!-- 按钮 -->
<view class="package-btns">
<view class="btns normal-btn">取消订单</view>
<view class="btns pay-now">立即支付</view>
<view class="btns sure-get-goods">确认收货</view>
<view class="btns normal-btn">申请退款</view>
<view class="btns normal-btn"
wx:if="{{packageInfo.status == 'N'}}"
data-id="{{item.id}}" bindtap="handelCancelOrder">取消订单</view>
<view class="btns pay-now"
wx:if="{{packageInfo.status == 'N'}}"
data-merged="{{item.mergedAmount}}"
data-id="{{item.id}}"
bindtap="handelToPay">立即支付</view>
<view class="btns normal-btn"
wx:if="{{packageInfo.status == 'C' || packageInfo.status == 'RE'}}"
data-id="{{item.id}}" bindtap="handelDelOrder">删除订单</view>
<view class="btns normal-btn"
wx:if="{{packageInfo.status == 'D' || packageInfo.status == 'R'}}"
data-id="{{item.id}}"
data-detail="{{packageInfo}}"
data-code="{{packageInfo.supplierCode}}"
data-logisticsNo="{{packageInfo.code}}"
bindtap="checkLogistics">查看物流</view>
<view class="btns sure-get-goods"
wx:if="{{packageInfo.status == 'D'}}"
data-id="{{item.id}}"
data-package="{{packageInfo}}"
bindtap="handelConfirmReceipt">确认收货</view>
<view class="btns normal-btn"
wx:if="{{packageInfo.orderCanRefund}}"
data-id="{{item.id}}"
data-package="{{packageInfo}}"
bindtap="handelRequestRefund">申请退款</view>
</view>
</view>
</view>
......
......@@ -20,6 +20,7 @@ scroll-view{
padding: 24rpx 40rpx 0;
box-sizing: border-box;
-webkit-box-sizing: border-box;
border-bottom: solid 1rpx #dddddd;
}
.swiper-tab-item{
padding: 14rpx 10rpx;
......@@ -237,12 +238,17 @@ scroll-view{
align-items: center;
justify-content: space-between;
font-size: 24rpx;
color: #666666;
color: #333333;
padding-bottom: 20rpx;
font-weight: bold;
}
.package-status-color-N{
color: red;
}
.package-status-color-P{
color: #409EFF;
color: #67C23A;
}
.package-status-color-D{
......
......@@ -399,6 +399,8 @@ page{
opacity: 0.7;
}
/* .order-status- */
.header-wrap{
position: relative;
height: 160rpx;
......
......@@ -205,7 +205,7 @@
"id": 24,
"name": "订单详情",
"pathName": "pages/orderDetail/orderDetail",
"query": "id=695665398192017408",
"query": "id=695598415471579136",
"scene": null
},
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment