init
This commit is contained in:
BIN
miniprogram/pages/order/.DS_Store
vendored
Normal file
BIN
miniprogram/pages/order/.DS_Store
vendored
Normal file
Binary file not shown.
34
miniprogram/pages/order/after-service-detail/api.js
Normal file
34
miniprogram/pages/order/after-service-detail/api.js
Normal file
@@ -0,0 +1,34 @@
|
||||
import { resp } from '../after-service-list/api';
|
||||
import dayjs from 'dayjs';
|
||||
import { mockIp, mockReqId } from '../../../utils/mock';
|
||||
|
||||
export const formatTime = (date, template) => dayjs(date).format(template);
|
||||
|
||||
export function getRightsDetail({ rightsNo }) {
|
||||
const _resq = {
|
||||
data: {},
|
||||
code: 'Success',
|
||||
msg: null,
|
||||
requestId: mockReqId(),
|
||||
clientIp: mockIp(),
|
||||
rt: 79,
|
||||
success: true,
|
||||
};
|
||||
_resq.data =
|
||||
resp.data.dataList.filter((item) => item.rights.rightsNo === rightsNo) ||
|
||||
{};
|
||||
return Promise.resolve(_resq);
|
||||
}
|
||||
|
||||
export function cancelRights() {
|
||||
const _resq = {
|
||||
data: {},
|
||||
code: 'Success',
|
||||
msg: null,
|
||||
requestId: mockReqId(),
|
||||
clientIp: mockIp(),
|
||||
rt: 79,
|
||||
success: true,
|
||||
};
|
||||
return Promise.resolve(_resq);
|
||||
}
|
||||
228
miniprogram/pages/order/after-service-detail/index.js
Normal file
228
miniprogram/pages/order/after-service-detail/index.js
Normal file
@@ -0,0 +1,228 @@
|
||||
import Toast from 'tdesign-miniprogram/toast/index';
|
||||
import { ServiceType, ServiceTypeDesc, ServiceStatus } from '../config';
|
||||
import { formatTime, getRightsDetail } from './api';
|
||||
|
||||
const TitleConfig = {
|
||||
[ServiceType.ORDER_CANCEL]: '退款详情',
|
||||
[ServiceType.ONLY_REFUND]: '退款详情',
|
||||
[ServiceType.RETURN_GOODS]: '退货退款详情',
|
||||
};
|
||||
|
||||
Page({
|
||||
data: {
|
||||
pageLoading: true,
|
||||
serviceRaw: {},
|
||||
service: {},
|
||||
deliveryButton: {},
|
||||
gallery: {
|
||||
current: 0,
|
||||
show: false,
|
||||
proofs: [],
|
||||
},
|
||||
showProofs: false,
|
||||
backRefresh: false,
|
||||
},
|
||||
|
||||
onLoad(query) {
|
||||
this.rightsNo = query.rightsNo;
|
||||
this.inputDialog = this.selectComponent('#input-dialog');
|
||||
this.init();
|
||||
},
|
||||
|
||||
onShow() {
|
||||
// 当从其他页面返回,并且 backRefresh 被置为 true 时,刷新数据
|
||||
if (!this.data.backRefresh) return;
|
||||
this.init();
|
||||
this.setData({ backRefresh: false });
|
||||
},
|
||||
|
||||
// 页面刷新,展示下拉刷新
|
||||
onPullDownRefresh_(e) {
|
||||
// 安全检查 e.detail 是否存在
|
||||
const callback = e && e.detail && e.detail.callback;
|
||||
this.setData({
|
||||
pullDownRefreshing: true,
|
||||
});
|
||||
this.init()
|
||||
.then(() => {
|
||||
this.setData({
|
||||
pullDownRefreshing: false,
|
||||
});
|
||||
// 确保 callback 存在且是函数
|
||||
if (callback && typeof callback === 'function') {
|
||||
callback();
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
this.setData({
|
||||
pullDownRefreshing: false,
|
||||
});
|
||||
// 即使出错也要调用 callback 来结束刷新状态
|
||||
if (callback && typeof callback === 'function') {
|
||||
callback();
|
||||
}
|
||||
Promise.reject(err);
|
||||
});
|
||||
},
|
||||
|
||||
init() {
|
||||
this.setData({ pageLoading: true });
|
||||
this.getService().then(() => {
|
||||
this.setData({ pageLoading: false });
|
||||
});
|
||||
},
|
||||
|
||||
getService() {
|
||||
const params = { rightsNo: this.rightsNo };
|
||||
return getRightsDetail(params).then((res) => {
|
||||
const serviceRaw = res.data && res.data.length > 0 ? res.data[0] : {};
|
||||
// 滤掉填写运单号、修改运单号按钮,这两个按钮特殊处理,不在底部按钮栏展示
|
||||
if (!serviceRaw.buttonVOs) serviceRaw.buttonVOs = [];
|
||||
const deliveryButton = {};
|
||||
const service = {
|
||||
id: serviceRaw.rights.rightsNo,
|
||||
serviceNo: serviceRaw.rights.rightsNo,
|
||||
storeName: serviceRaw.rights.storeName,
|
||||
type: serviceRaw.rights.rightsType,
|
||||
typeDesc: ServiceTypeDesc[serviceRaw.rights.rightsType],
|
||||
status: serviceRaw.rights.rightsStatus,
|
||||
statusIcon: this.genStatusIcon(serviceRaw.rights),
|
||||
statusName: serviceRaw.rights.userRightsStatusName,
|
||||
statusDesc: serviceRaw.rights.userRightsStatusDesc,
|
||||
amount: serviceRaw.rights.refundRequestAmount,
|
||||
goodsList: (serviceRaw.rightsItem || []).map((item, i) => ({
|
||||
id: i,
|
||||
thumb: item.goodsPictureUrl,
|
||||
title: item.goodsName,
|
||||
specs: (item.specInfo || []).map((s) => s.specValues || ''),
|
||||
itemRefundAmount: item.itemRefundAmount,
|
||||
rightsQuantity: item.rightsQuantity,
|
||||
})),
|
||||
orderNo: serviceRaw.rights.orderNo, // 订单编号
|
||||
rightsNo: serviceRaw.rights.rightsNo, // 售后服务单号
|
||||
rightsReasonDesc: serviceRaw.rights.rightsReasonDesc, // 申请售后原因
|
||||
isRefunded: serviceRaw.rights.userRightsStatus === ServiceStatus.REFUNDED, // 是否已退款
|
||||
refundMethodList: (serviceRaw.refundMethodList || []).map((m) => ({
|
||||
name: m.refundMethodName,
|
||||
amount: m.refundMethodAmount,
|
||||
})), // 退款明细
|
||||
refundRequestAmount: serviceRaw.rights.refundRequestAmount, // 申请退款金额
|
||||
payTraceNo: serviceRaw.rightsRefund.traceNo, // 交易流水号
|
||||
createTime: formatTime(parseFloat(`${serviceRaw.rights.createTime}`), 'YYYY-MM-DD HH:mm'), // 申请时间
|
||||
logisticsNo: serviceRaw.logisticsVO.logisticsNo, // 退货物流单号
|
||||
logisticsCompanyName: serviceRaw.logisticsVO.logisticsCompanyName, // 退货物流公司
|
||||
logisticsCompanyCode: serviceRaw.logisticsVO.logisticsCompanyCode, // 退货物流公司
|
||||
remark: serviceRaw.logisticsVO.remark, // 退货备注
|
||||
receiverName: serviceRaw.logisticsVO.receiverName, // 收货人
|
||||
receiverPhone: serviceRaw.logisticsVO.receiverPhone, // 收货人电话
|
||||
receiverAddress: this.composeAddress(serviceRaw), // 收货人地址
|
||||
applyRemark: serviceRaw.rightsRefund.refundDesc, // 申请退款时的填写的说明
|
||||
buttons: serviceRaw.buttonVOs || [],
|
||||
logistics: serviceRaw.logisticsVO,
|
||||
};
|
||||
const proofs = serviceRaw.rights.rightsImageUrls || [];
|
||||
this.setData({
|
||||
serviceRaw,
|
||||
service,
|
||||
deliveryButton,
|
||||
'gallery.proofs': proofs,
|
||||
showProofs:
|
||||
serviceRaw.rights.userRightsStatus === ServiceStatus.PENDING_VERIFY &&
|
||||
(service.applyRemark || proofs.length > 0),
|
||||
});
|
||||
wx.setNavigationBarTitle({
|
||||
title: TitleConfig[service.type],
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
composeAddress(service) {
|
||||
return [
|
||||
service.logisticsVO.receiverProvince,
|
||||
service.logisticsVO.receiverCity,
|
||||
service.logisticsVO.receiverCountry,
|
||||
service.logisticsVO.receiverArea,
|
||||
service.logisticsVO.receiverAddress,
|
||||
]
|
||||
.filter((item) => !!item)
|
||||
.join(' ');
|
||||
},
|
||||
|
||||
onRefresh() {
|
||||
this.init();
|
||||
},
|
||||
|
||||
editLogistices() {
|
||||
this.setData({
|
||||
inputDialogVisible: true,
|
||||
});
|
||||
this.inputDialog.setData({
|
||||
cancelBtn: '取消',
|
||||
confirmBtn: '确定',
|
||||
});
|
||||
this.inputDialog._onConfirm = () => {
|
||||
Toast({
|
||||
message: '确定填写物流单号',
|
||||
});
|
||||
};
|
||||
},
|
||||
|
||||
onProofTap(e) {
|
||||
if (this.data.gallery.show) {
|
||||
this.setData({
|
||||
'gallery.show': false,
|
||||
});
|
||||
return;
|
||||
}
|
||||
const { index } = e.currentTarget.dataset;
|
||||
this.setData({
|
||||
'gallery.show': true,
|
||||
'gallery.current': index,
|
||||
});
|
||||
},
|
||||
|
||||
onGoodsCardTap(e) {
|
||||
const { index } = e.currentTarget.dataset;
|
||||
const goods = this.data.serviceRaw.rightsItem[index];
|
||||
wx.navigateTo({ url: `/pages/goods/details/index?skuId=${goods.skuId}` });
|
||||
},
|
||||
|
||||
onServiceNoCopy() {
|
||||
wx.setClipboardData({
|
||||
data: this.data.service.serviceNo,
|
||||
});
|
||||
},
|
||||
|
||||
onAddressCopy() {
|
||||
wx.setClipboardData({
|
||||
data: `${this.data.service.receiverName} ${this.data.service.receiverPhone}\n${this.data.service.receiverAddress}`,
|
||||
});
|
||||
},
|
||||
|
||||
/** 获取状态ICON */
|
||||
genStatusIcon(item) {
|
||||
const { userRightsStatus, afterSaleRequireType } = item;
|
||||
switch (userRightsStatus) {
|
||||
// 退款成功
|
||||
case ServiceStatus.REFUNDED: {
|
||||
return 'succeed';
|
||||
}
|
||||
// 已取消、已关闭
|
||||
case ServiceStatus.CLOSED: {
|
||||
return 'indent_close';
|
||||
}
|
||||
default: {
|
||||
switch (afterSaleRequireType) {
|
||||
case 'REFUND_MONEY': {
|
||||
return 'goods_refund';
|
||||
}
|
||||
case 'REFUND_GOODS_MONEY':
|
||||
return 'goods_return';
|
||||
default: {
|
||||
return 'goods_return';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
21
miniprogram/pages/order/after-service-detail/index.json
Normal file
21
miniprogram/pages/order/after-service-detail/index.json
Normal file
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"navigationBarTitleText": "",
|
||||
"usingComponents": {
|
||||
"wr-loading-content": "/components/loading-content/index",
|
||||
"wr-price": "/components/price/index",
|
||||
"wr-service-goods-card": "../components/order-goods-card/index",
|
||||
"t-cell": "tdesign-miniprogram/cell/cell",
|
||||
"t-icon": "tdesign-miniprogram/icon/icon",
|
||||
"t-cell-group": "tdesign-miniprogram/cell-group/cell-group",
|
||||
"t-pull-down-refresh": "tdesign-miniprogram/pull-down-refresh/pull-down-refresh",
|
||||
"t-grid": "tdesign-miniprogram/grid/grid",
|
||||
"t-grid-item": "tdesign-miniprogram/grid-item/grid-item",
|
||||
"t-toast": "tdesign-miniprogram/toast/toast",
|
||||
"t-dialog": "tdesign-miniprogram/dialog/dialog",
|
||||
"t-input": "tdesign-miniprogram/input/input",
|
||||
"t-swiper": "tdesign-miniprogram/swiper/swiper",
|
||||
"t-swiper-nav": "tdesign-miniprogram/swiper-nav/swiper-nav",
|
||||
"wr-after-service-button-bar": "../components/after-service-button-bar/index",
|
||||
"t-image": "/components/webp-image/index"
|
||||
}
|
||||
}
|
||||
197
miniprogram/pages/order/after-service-detail/index.wxml
Normal file
197
miniprogram/pages/order/after-service-detail/index.wxml
Normal file
@@ -0,0 +1,197 @@
|
||||
<wr-loading-content position="fixed" type="spinner" wx:if="{{pageLoading}}" />
|
||||
<view class="page-container">
|
||||
<t-pull-down-refresh id="t-pull-down-refresh" bind:refresh="onPullDownRefresh_" t-class-indicator="t-class-indicator">
|
||||
<!-- 页面内容 -->
|
||||
<view class="service-detail safe-bottom">
|
||||
<!-- 状态及描述 -->
|
||||
<view class="service-detail__header">
|
||||
<view class="title">
|
||||
<t-icon prefix="wr" name="{{service.statusIcon}}" size="30px" />
|
||||
{{service.statusName}}
|
||||
</view>
|
||||
<view class="desc"> {{service.statusDesc}} </view>
|
||||
</view>
|
||||
<!-- 退款金额 -->
|
||||
<view class="service-section__pay pay-result" wx:if="{{service.isRefunded}}">
|
||||
<t-cell
|
||||
t-class-title="title"
|
||||
t-class-note="right"
|
||||
t-class="t-class-wrapper-first-child"
|
||||
title="{{service.isRefunded ? '退款金额' : '预计退款金额'}}"
|
||||
bordered="{{false}}"
|
||||
>
|
||||
<wr-price slot="note" price="{{service.refundRequestAmount}}" fill />
|
||||
</t-cell>
|
||||
<t-cell
|
||||
wx:for="{{service.refundMethodList}}"
|
||||
wx:key="name"
|
||||
wx:for-index="index"
|
||||
wx:for-item="item"
|
||||
t-class-title="t-cell-title"
|
||||
t-class-note="t-cell-title"
|
||||
t-class="t-class-wrapper"
|
||||
title="{{item.name}}"
|
||||
bordered="{{service.refundMethodList.length - 1 === index ? true : false}}"
|
||||
>
|
||||
<wr-price slot="note" price="{{item.amount}}" fill />
|
||||
</t-cell>
|
||||
<block wx:if="{{service.isRefunded}}">
|
||||
<t-cell
|
||||
title=""
|
||||
t-class="t-class-wrapper-first-child"
|
||||
t-class-description="label"
|
||||
description="说明:微信退款后,可以在微信支付账单查询,实际退款到时间可能受到银行处理时间的影响有一定延时,可以稍后查看"
|
||||
/>
|
||||
</block>
|
||||
</view>
|
||||
<!-- 物流 -->
|
||||
<view class="service-section logistics" wx:if="{{service.logisticsNo}}">
|
||||
<view class="service-section__title">
|
||||
<t-cell
|
||||
align="top"
|
||||
title="{{service.logisticsCompanyName + ' ' + service.logisticsNo}}"
|
||||
bordered="{{false}}"
|
||||
description="买家已寄出"
|
||||
arrow
|
||||
>
|
||||
<t-icon prefix="wr" color="#333333" name="deliver" size="40rpx" slot="left-icon" />
|
||||
</t-cell>
|
||||
<view style="padding: 0 32rpx">
|
||||
<wr-after-service-button-bar service="{{service}}" />
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 收货地址 -->
|
||||
<view class="service-section goods-refund-address" wx:if="{{service.receiverName}}">
|
||||
<t-cell-group>
|
||||
<t-cell align="top" title="退货地址" bordered="{{false}}">
|
||||
<t-icon prefix="wr" color="#333333" name="location" size="40rpx" slot="left-icon" />
|
||||
<view
|
||||
slot="note"
|
||||
class="right text-btn goods-refund-address-copy-btn"
|
||||
hover-class="text-btn--active"
|
||||
bindtap="onAddressCopy"
|
||||
>复制
|
||||
</view>
|
||||
<view slot="description">
|
||||
<view> {{service.receiverAddress}} </view>
|
||||
<view>收货人:{{service.receiverName}}</view>
|
||||
<view>收货人手机:{{service.receiverName}}</view>
|
||||
</view>
|
||||
</t-cell>
|
||||
</t-cell-group>
|
||||
</view>
|
||||
<!-- 商品卡片 -->
|
||||
<view
|
||||
class="service-section service-goods-card-wrap"
|
||||
wx:if="{{service.goodsList && service.goodsList.length > 0}}"
|
||||
>
|
||||
<wr-service-goods-card
|
||||
wx:for="{{service.goodsList}}"
|
||||
wx:key="id"
|
||||
wx:for-item="goods"
|
||||
goods="{{goods}}"
|
||||
no-top-line
|
||||
bindtap="onGoodsCardTap"
|
||||
data-index="{{index}}"
|
||||
>
|
||||
<view slot="footer" class="order-goods-card-footer">
|
||||
<wr-price
|
||||
price="{{goods.itemRefundAmount}}"
|
||||
fill
|
||||
wr-class="order-goods-card-footer-price-class"
|
||||
symbol-class="order-goods-card-footer-price-symbol"
|
||||
decimal-class="order-goods-card-footer-price-decimal"
|
||||
/>
|
||||
<view class="order-goods-card-footer-num">x {{goods.rightsQuantity}}</view>
|
||||
</view>
|
||||
</wr-service-goods-card>
|
||||
</view>
|
||||
<!-- 退款信息 -->
|
||||
<view class="service-section__pay">
|
||||
<t-cell bordered="{{false}}" title="退款信息" t-class="t-refund-wrapper" t-class-title="t-refund-title" />
|
||||
<t-cell
|
||||
bordered="{{false}}"
|
||||
t-class="t-refund-wrapper"
|
||||
t-class-title="t-refund-info"
|
||||
t-class-note="t-refund-note"
|
||||
title="订单编号"
|
||||
note="{{service.orderNo}}"
|
||||
/>
|
||||
<t-cell
|
||||
bordered="{{false}}"
|
||||
t-class="t-refund-wrapper"
|
||||
t-class-title="t-refund-info"
|
||||
t-class-note="t-refund-note"
|
||||
title="服务单号"
|
||||
note="{{service.rightsNo}}"
|
||||
>
|
||||
<view slot="right-icon" class="text-btn" hover-class="text-btn--active" bindtap="onServiceNoCopy">复制 </view>
|
||||
</t-cell>
|
||||
<t-cell
|
||||
bordered="{{false}}"
|
||||
t-class="t-refund-wrapper"
|
||||
t-class-title="t-refund-info"
|
||||
t-class-note="t-refund-note"
|
||||
title="退款原因"
|
||||
note="{{service.rightsReasonDesc}}"
|
||||
/>
|
||||
<t-cell
|
||||
bordered="{{false}}"
|
||||
t-class="t-refund-wrapper"
|
||||
t-class-title="t-refund-info"
|
||||
t-class-note="t-refund-note"
|
||||
title="退款金额"
|
||||
>
|
||||
<wr-price slot="note" price="{{service.refundRequestAmount}}" fill />
|
||||
</t-cell>
|
||||
<t-cell
|
||||
bordered="{{false}}"
|
||||
t-class="t-refund-wrapper"
|
||||
t-class-title="t-refund-info"
|
||||
t-class-note="t-refund-note"
|
||||
title="申请时间"
|
||||
note="{{service.createTime}}"
|
||||
/>
|
||||
</view>
|
||||
<!-- 凭证/说明 -->
|
||||
<view class="service-section__pay credential_desc" wx:if="{{showProofs}}">
|
||||
<t-cell
|
||||
bordered="{{false}}"
|
||||
title="凭证/说明"
|
||||
t-class="t-refund-wrapper"
|
||||
t-class-title="t-refund-info"
|
||||
description="{{service.applyRemark}}"
|
||||
/>
|
||||
<t-grid border="{{false}}" column="{{3}}">
|
||||
<t-grid-item
|
||||
t-class-image="t-refund-grid-image"
|
||||
wx:for="{{gallery.proofs}}"
|
||||
wx:key="index"
|
||||
image="{{item}}"
|
||||
bindclick="onProofTap"
|
||||
data-index="{{index}}"
|
||||
/>
|
||||
</t-grid>
|
||||
</view>
|
||||
<t-swiper
|
||||
wx:if="{{gallery.show}}"
|
||||
current="{{gallery.current}}"
|
||||
img-srcs="{{gallery.proofs}}"
|
||||
full-screen
|
||||
circular="{{false}}"
|
||||
bindtap="onProofTap"
|
||||
/>
|
||||
</view>
|
||||
</t-pull-down-refresh>
|
||||
</view>
|
||||
<t-toast id="t-toast" />
|
||||
<!-- 退款说明填写 -->
|
||||
<t-dialog id="input-dialog" visible="{{inputDialogVisible}}">
|
||||
<view class="input-dialog__content" slot="content">
|
||||
<view style="color: #333333; padding-left: 32rpx">物流单号</view>
|
||||
<t-input class="input" placeholder="请输入物流单号" />
|
||||
<view class="tips">{{amountTip}}</view>
|
||||
</view>
|
||||
</t-dialog>
|
||||
<t-dialog id="t-dialog" />
|
||||
441
miniprogram/pages/order/after-service-detail/index.wxss
Normal file
441
miniprogram/pages/order/after-service-detail/index.wxss
Normal file
@@ -0,0 +1,441 @@
|
||||
:host {
|
||||
background-color: #f5f5f5;
|
||||
}
|
||||
|
||||
.service-detail {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.service-detail wr-service-goods-card .wr-goods-card__body {
|
||||
margin-left: 50rpx;
|
||||
}
|
||||
|
||||
.order-goods-card-footer {
|
||||
display: flex;
|
||||
width: calc(100% - 190rpx);
|
||||
justify-content: space-between;
|
||||
position: absolute;
|
||||
bottom: 20rpx;
|
||||
left: 190rpx;
|
||||
}
|
||||
|
||||
.order-goods-card-footer-num {
|
||||
color: #999;
|
||||
line-height: 40rpx;
|
||||
}
|
||||
|
||||
.service-detail .order-goods-card-footer .order-goods-card-footer-price-class {
|
||||
font-size: 36rpx;
|
||||
color: #333;
|
||||
font-family: DIN Alternate;
|
||||
}
|
||||
|
||||
.service-detail .order-goods-card-footer .order-goods-card-footer-price-decimal {
|
||||
font-size: 28rpx;
|
||||
color: #333;
|
||||
font-family: DIN Alternate;
|
||||
}
|
||||
|
||||
.service-detail .order-goods-card-footer .order-goods-card-footer-price-symbol {
|
||||
color: #333;
|
||||
font-size: 24rpx;
|
||||
font-family: DIN Alternate;
|
||||
}
|
||||
|
||||
.service-detail .service-detail__header {
|
||||
padding: 60rpx 0 48rpx 40rpx;
|
||||
box-sizing: border-box;
|
||||
height: 220rpx;
|
||||
background-color: #fff;
|
||||
}
|
||||
.service-detail .service-detail__header .title,
|
||||
.service-detail .service-detail__header .desc {
|
||||
overflow: hidden;
|
||||
display: -webkit-box;
|
||||
-webkit-box-orient: vertical;
|
||||
}
|
||||
|
||||
.service-detail .service-detail__header .title {
|
||||
-webkit-line-clamp: 1;
|
||||
font-size: 48rpx;
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.service-detail .service-detail__header .desc {
|
||||
-webkit-line-clamp: 2;
|
||||
margin-top: 10rpx;
|
||||
font-size: 28rpx;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.service-detail .service-detail__header .desc .count-down {
|
||||
color: #fff185;
|
||||
display: inline;
|
||||
}
|
||||
|
||||
.service-detail .service-section {
|
||||
margin: 20rpx 0 20rpx 0;
|
||||
/* padding: 30rpx 32rpx; */
|
||||
width: auto;
|
||||
border-radius: 8rpx;
|
||||
background-color: white;
|
||||
overflow: hidden;
|
||||
}
|
||||
.service-section__pay {
|
||||
margin: 0 0 20rpx 0;
|
||||
width: auto;
|
||||
border-radius: 8rpx;
|
||||
background-color: white;
|
||||
overflow: hidden;
|
||||
}
|
||||
.service-section__pay.credential_desc {
|
||||
padding: 0 24rpx;
|
||||
}
|
||||
.service-section__pay .t-grid-item__content {
|
||||
padding: 0 0 24rpx;
|
||||
}
|
||||
.service-detail .service-section__title {
|
||||
color: #333333;
|
||||
margin-bottom: 10rpx;
|
||||
padding-bottom: 18rpx;
|
||||
height: 224rpx;
|
||||
position: relative;
|
||||
}
|
||||
.service-detail .service-section__title .icon {
|
||||
margin-right: 16rpx;
|
||||
font-size: 40rpx !important;
|
||||
}
|
||||
.service-detail .service-section__title .right {
|
||||
flex: none;
|
||||
font-weight: normal;
|
||||
font-size: 26rpx;
|
||||
}
|
||||
.service-detail .section-content {
|
||||
margin: 16rpx 0 0 52rpx;
|
||||
}
|
||||
|
||||
.service-detail .main {
|
||||
font-size: 28rpx;
|
||||
color: #222427;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.service-detail .main .phone-num {
|
||||
margin-left: 16rpx;
|
||||
display: inline;
|
||||
}
|
||||
.service-detail .label {
|
||||
color: #999999;
|
||||
font-size: 26rpx;
|
||||
}
|
||||
|
||||
.service-detail .custom-remark {
|
||||
font-size: 26rpx;
|
||||
line-height: 36rpx;
|
||||
color: #333333;
|
||||
word-wrap: break-word;
|
||||
}
|
||||
.service-detail .proofs {
|
||||
margin-top: 20rpx;
|
||||
}
|
||||
|
||||
.service-detail .proofs .proof {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-color: #f9f9f9;
|
||||
}
|
||||
|
||||
.service-detail .pay-result .t-cell-title,
|
||||
.service-detail .pay-result .t-cell-value {
|
||||
color: #666666;
|
||||
font-size: 28rpx;
|
||||
}
|
||||
|
||||
.t-class-wrapper {
|
||||
padding: 10rpx 24rpx !important;
|
||||
}
|
||||
|
||||
.t-class-wrapper-first-child {
|
||||
padding: 24rpx !important;
|
||||
}
|
||||
|
||||
.service-detail .pay-result .wr-cell__value {
|
||||
font-weight: bold;
|
||||
}
|
||||
.service-detail .right {
|
||||
font-size: 36rpx;
|
||||
color: #fa550f;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.service-detail .title {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.service-detail .pay-result .service-section__title .right.integer {
|
||||
font-size: 48rpx;
|
||||
}
|
||||
.service-detail .pay-result .split-line {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.service-detail .pay-result .split-line::after {
|
||||
position: absolute;
|
||||
display: block;
|
||||
content: ' ';
|
||||
height: 1px;
|
||||
left: -50%;
|
||||
right: -50%;
|
||||
transform: scale(0.5);
|
||||
background-color: #e6e6e6;
|
||||
}
|
||||
|
||||
.service-detail .pay-result .section-content {
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
.service-detail .pay-result .section-content .label {
|
||||
color: #999999;
|
||||
font-size: 24rpx;
|
||||
}
|
||||
|
||||
.service-detail .pay-result .wr-cell::after {
|
||||
left: 0;
|
||||
}
|
||||
|
||||
.service-detail .footer-bar-wrapper {
|
||||
height: 100rpx;
|
||||
}
|
||||
|
||||
.service-detail .footer-bar-wrapper .footer-bar {
|
||||
position: fixed;
|
||||
left: 0;
|
||||
bottom: 0;
|
||||
height: 100rpx;
|
||||
width: 100vw;
|
||||
box-sizing: border-box;
|
||||
padding: 0 20rpx;
|
||||
background-color: white;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.service-detail .text-btn {
|
||||
display: inline;
|
||||
box-sizing: border-box;
|
||||
color: #333;
|
||||
border: 2rpx solid #ddd;
|
||||
border-radius: 32rpx;
|
||||
margin-left: 10rpx;
|
||||
padding: 0 16rpx;
|
||||
font-weight: normal;
|
||||
font-size: 24rpx;
|
||||
line-height: 32rpx;
|
||||
}
|
||||
.service-detail .text-btn--active {
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
.service-detail .specs-popup .bottom-btn {
|
||||
color: #fa550f;
|
||||
}
|
||||
.service-detail .specs-popup .bottom-btn::after {
|
||||
color: #fa550f;
|
||||
}
|
||||
|
||||
.dialog .dialog__button-confirm {
|
||||
color: #fa550f;
|
||||
}
|
||||
|
||||
.page-container .order-goods-card > wr-goods-card .wr-goods-card__bottom .price {
|
||||
top: 100rpx;
|
||||
left: 10rpx;
|
||||
position: absolute;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.page-container .order-goods-card > wr-goods-card .wr-goods-card__num {
|
||||
top: 100rpx;
|
||||
right: 0;
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
.page-container .order-goods-card > wr-goods-card .wr-goods-card__bottom .price::before {
|
||||
display: inline;
|
||||
content: '退款金额:';
|
||||
margin-right: 1em;
|
||||
font-size: 24rpx;
|
||||
color: #333333;
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
.page-container .wr-goods-card__specs {
|
||||
margin: 14rpx 20rpx 0 0;
|
||||
}
|
||||
|
||||
.page-container .order-goods-card > wr-goods-card .wr-goods-card__title {
|
||||
margin-right: 0;
|
||||
-webkit-line-clamp: 1;
|
||||
display: -webkit-box;
|
||||
-webkit-box-orient: vertical;
|
||||
overflow: hidden;
|
||||
width: 80%;
|
||||
}
|
||||
|
||||
.page-container .order-card .header .store-name {
|
||||
-webkit-line-clamp: 1;
|
||||
display: -webkit-box;
|
||||
-webkit-box-orient: vertical;
|
||||
overflow: hidden;
|
||||
width: 80%;
|
||||
}
|
||||
|
||||
.page-container .status-desc {
|
||||
box-sizing: border-box;
|
||||
padding: 22rpx 20rpx;
|
||||
font-size: 26rpx;
|
||||
line-height: 1.3;
|
||||
text-align: left;
|
||||
color: #333333;
|
||||
background-color: #f5f5f5;
|
||||
border-radius: 8rpx;
|
||||
word-wrap: break-word;
|
||||
margin-top: 40rpx;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.page-container .header__right {
|
||||
font-size: 24rpx;
|
||||
color: #333333;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.page-container .header__right__icon {
|
||||
color: #d05b27;
|
||||
font-size: 16px !important;
|
||||
margin-right: 10rpx;
|
||||
}
|
||||
|
||||
.page-container .wr-goods-card__thumb {
|
||||
width: 140rpx;
|
||||
}
|
||||
.page-container .page-background {
|
||||
position: absolute;
|
||||
z-index: -1;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100vw;
|
||||
color: #fff;
|
||||
overflow: hidden;
|
||||
}
|
||||
.page-container .page-background-img {
|
||||
width: 100%;
|
||||
height: 320rpx !important;
|
||||
}
|
||||
.page-container .navbar-bg .nav-back,
|
||||
.page-container .navbar-bg .page-background {
|
||||
background: linear-gradient(to right, rgba(250, 85, 15, 1) 0%, rgba(250, 85, 15, 0.6) 100%) !important;
|
||||
}
|
||||
|
||||
.page-container .navigation-bar__btn {
|
||||
font-size: 40rpx !important;
|
||||
font-weight: bold !important;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.t-class-title {
|
||||
color: #000;
|
||||
}
|
||||
|
||||
.refresh-bar {
|
||||
background: linear-gradient(90deg, #ff6b44 0%, #ed3427 100%) !important;
|
||||
}
|
||||
|
||||
.page-container .navigation-bar__inner .navigation-bar__left {
|
||||
padding-left: 16rpx;
|
||||
}
|
||||
|
||||
.t-refund-info {
|
||||
font-size: 26rpx;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.t-refund-grid-image {
|
||||
width: 212rpx !important;
|
||||
height: 212rpx !important;
|
||||
}
|
||||
|
||||
.t-refund-info-img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.t-refund-wrapper {
|
||||
padding-top: 18rpx !important;
|
||||
padding-bottom: 18rpx !important;
|
||||
}
|
||||
|
||||
.t-refund-title {
|
||||
font-size: 28rpx;
|
||||
color: #333;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.t-refund-note {
|
||||
font-size: 26rpx;
|
||||
color: #333 !important;
|
||||
}
|
||||
|
||||
.service-detail .logistics {
|
||||
padding-top: 0;
|
||||
padding-bottom: 0;
|
||||
padding-right: 0;
|
||||
}
|
||||
|
||||
.service-section__title__header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
color: #333;
|
||||
font-weight: normal;
|
||||
font-size: 32rpx;
|
||||
}
|
||||
|
||||
.safe-bottom {
|
||||
padding-bottom: env(safe-area-inset-bottom);
|
||||
}
|
||||
|
||||
.service-section-logistics {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
color: #fa4126;
|
||||
align-items: center;
|
||||
margin-top: 24rpx;
|
||||
}
|
||||
|
||||
.t-class-indicator {
|
||||
color: #b9b9b9 !important;
|
||||
}
|
||||
|
||||
.service-detail .goods-refund-address {
|
||||
padding-top: 0;
|
||||
padding-bottom: 0;
|
||||
}
|
||||
|
||||
.service-detail .goods-refund-address .goods-refund-address-copy-btn {
|
||||
position: absolute;
|
||||
top: 22rpx;
|
||||
right: 32rpx;
|
||||
}
|
||||
|
||||
.service-detail .service-goods-card-wrap {
|
||||
padding: 0 32rpx;
|
||||
}
|
||||
|
||||
.t-button {
|
||||
--td-button-default-color: #000;
|
||||
--td-button-primary-text-color: #fa4126;
|
||||
}
|
||||
1409
miniprogram/pages/order/after-service-list/api.js
Normal file
1409
miniprogram/pages/order/after-service-list/api.js
Normal file
File diff suppressed because it is too large
Load Diff
224
miniprogram/pages/order/after-service-list/index.js
Normal file
224
miniprogram/pages/order/after-service-list/index.js
Normal file
@@ -0,0 +1,224 @@
|
||||
import { getRightsList } from './api';
|
||||
import { AfterServiceStatus, ServiceType, ServiceTypeDesc } from '../config';
|
||||
|
||||
Page({
|
||||
page: {
|
||||
size: 10,
|
||||
num: 1,
|
||||
},
|
||||
|
||||
data: {
|
||||
tabs: [
|
||||
{
|
||||
key: -1,
|
||||
text: '全部',
|
||||
},
|
||||
{
|
||||
key: AfterServiceStatus.TO_AUDIT,
|
||||
text: '待审核',
|
||||
},
|
||||
{
|
||||
key: AfterServiceStatus.THE_APPROVED,
|
||||
text: '已审核',
|
||||
},
|
||||
{
|
||||
key: AfterServiceStatus.COMPLETE,
|
||||
text: '已完成',
|
||||
},
|
||||
{
|
||||
key: AfterServiceStatus.CLOSED,
|
||||
text: '已关闭',
|
||||
},
|
||||
],
|
||||
curTab: -1,
|
||||
dataList: [],
|
||||
listLoading: 0, // 0-未加载,1-加载中,2-已全部加载
|
||||
pullDownRefreshing: false, // 下拉刷新时不显示load-more
|
||||
emptyImg: 'https://tdesign.gtimg.com/miniprogram/template/retail/order/empty-order-list.png',
|
||||
backRefresh: false,
|
||||
},
|
||||
|
||||
onLoad(query) {
|
||||
let status = parseInt(query.status);
|
||||
status = this.data.tabs.map((t) => t.key).includes(status) ? status : -1;
|
||||
this.init(status);
|
||||
this.pullDownRefresh = this.selectComponent('#wr-pull-down-refresh');
|
||||
},
|
||||
|
||||
onShow() {
|
||||
// 当从其他页面返回,并且 backRefresh 被置为 true 时,刷新数据
|
||||
if (!this.data.backRefresh) return;
|
||||
this.onRefresh();
|
||||
this.setData({
|
||||
backRefresh: false,
|
||||
});
|
||||
},
|
||||
|
||||
onReachBottom() {
|
||||
if (this.data.listLoading === 0) {
|
||||
this.getAfterServiceList(this.data.curTab);
|
||||
}
|
||||
},
|
||||
|
||||
onPageScroll(e) {
|
||||
this.pullDownRefresh && this.pullDownRefresh.onPageScroll(e);
|
||||
},
|
||||
|
||||
onPullDownRefresh_(e) {
|
||||
// 安全检查 e.detail 是否存在
|
||||
const callback = e && e.detail && e.detail.callback;
|
||||
this.setData({
|
||||
pullDownRefreshing: true,
|
||||
}); // 下拉刷新时不显示load-more
|
||||
this.refreshList(this.data.curTab)
|
||||
.then(() => {
|
||||
this.setData({
|
||||
pullDownRefreshing: false,
|
||||
});
|
||||
// 确保 callback 存在且是函数
|
||||
if (callback && typeof callback === 'function') {
|
||||
callback();
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
this.setData({
|
||||
pullDownRefreshing: false,
|
||||
});
|
||||
// 即使出错也要调用 callback 来结束刷新状态
|
||||
if (callback && typeof callback === 'function') {
|
||||
callback();
|
||||
}
|
||||
Promise.reject(err);
|
||||
});
|
||||
},
|
||||
|
||||
init(status) {
|
||||
status = status !== undefined ? status : this.data.curTab;
|
||||
this.refreshList(status);
|
||||
},
|
||||
|
||||
getAfterServiceList(statusCode = -1, reset = false) {
|
||||
const params = {
|
||||
parameter: {
|
||||
pageSize: this.page.size,
|
||||
pageNum: this.page.num,
|
||||
},
|
||||
};
|
||||
if (statusCode !== -1) params.parameter.afterServiceStatus = statusCode;
|
||||
this.setData({
|
||||
listLoading: 1,
|
||||
});
|
||||
return getRightsList(params)
|
||||
.then((res) => {
|
||||
this.page.num++;
|
||||
let dataList = [];
|
||||
let { tabs } = this.data;
|
||||
if (res && res.data && res.data.states) {
|
||||
tabs = this.data.tabs.map((item) => {
|
||||
switch (item.key) {
|
||||
case AfterServiceStatus.TO_AUDIT:
|
||||
item.info = res.data.states.audit;
|
||||
break;
|
||||
case AfterServiceStatus.THE_APPROVED:
|
||||
item.info = res.data.states.approved;
|
||||
break;
|
||||
case AfterServiceStatus.COMPLETE:
|
||||
item.info = res.data.states.complete;
|
||||
break;
|
||||
case AfterServiceStatus.CLOSED:
|
||||
item.info = res.data.states.closed;
|
||||
break;
|
||||
}
|
||||
return item;
|
||||
});
|
||||
}
|
||||
if (res && res.data && res.data.dataList) {
|
||||
dataList = (res.data.dataList || []).map((_data) => {
|
||||
return {
|
||||
id: _data.rights.rightsNo,
|
||||
serviceNo: _data.rights.rightsNo,
|
||||
storeName: _data.rights.storeName,
|
||||
type: _data.rights.rightsType,
|
||||
typeDesc: ServiceTypeDesc[_data.rights.rightsType],
|
||||
typeDescIcon: _data.rightsType === ServiceType.ONLY_REFUND ? 'money-circle' : 'return-goods-1',
|
||||
status: _data.rights.rightsStatus,
|
||||
statusName: _data.rights.userRightsStatusName,
|
||||
statusDesc: _data.rights.userRightsStatusDesc,
|
||||
amount: _data.rights.refundAmount,
|
||||
goodsList: _data.rightsItem.map((item, i) => ({
|
||||
id: i,
|
||||
thumb: item.goodsPictureUrl,
|
||||
title: item.goodsName,
|
||||
specs: (item.specInfo || []).map((s) => s.specValues || ''),
|
||||
itemRefundAmount: item.itemRefundAmount,
|
||||
rightsQuantity: item.itemRefundAmount,
|
||||
})),
|
||||
storeId: _data.storeId,
|
||||
buttons: _data.buttonVOs || [],
|
||||
logisticsNo: _data.logisticsVO.logisticsNo, // 退货物流单号
|
||||
logisticsCompanyName: _data.logisticsVO.logisticsCompanyName, // 退货物流公司
|
||||
logisticsCompanyCode: _data.logisticsVO.logisticsCompanyCode, // 退货物流公司
|
||||
remark: _data.logisticsVO.remark, // 退货备注
|
||||
logisticsVO: _data.logisticsVO,
|
||||
};
|
||||
});
|
||||
}
|
||||
return new Promise((resolve) => {
|
||||
if (reset) {
|
||||
this.setData(
|
||||
{
|
||||
dataList: [],
|
||||
},
|
||||
() => resolve(),
|
||||
);
|
||||
} else resolve();
|
||||
}).then(() => {
|
||||
this.setData({
|
||||
tabs,
|
||||
dataList: this.data.dataList.concat(dataList),
|
||||
listLoading: dataList.length > 0 ? 0 : 2,
|
||||
});
|
||||
});
|
||||
})
|
||||
.catch((err) => {
|
||||
this.setData({
|
||||
listLoading: 3,
|
||||
});
|
||||
return Promise.reject(err);
|
||||
});
|
||||
},
|
||||
|
||||
onReTryLoad() {
|
||||
this.getAfterServiceList(this.data.curTab);
|
||||
},
|
||||
|
||||
onTabChange(e) {
|
||||
const { value } = e.detail;
|
||||
const tab = this.data.tabs.find((v) => v.key === value);
|
||||
if (!tab) return;
|
||||
this.refreshList(value);
|
||||
},
|
||||
|
||||
refreshList(status = -1) {
|
||||
this.page = {
|
||||
size: 10,
|
||||
num: 1,
|
||||
};
|
||||
this.setData({
|
||||
curTab: status,
|
||||
dataList: [],
|
||||
});
|
||||
return this.getAfterServiceList(status, true);
|
||||
},
|
||||
|
||||
onRefresh() {
|
||||
this.refreshList(this.data.curTab);
|
||||
},
|
||||
|
||||
// 点击订单卡片
|
||||
onAfterServiceCardTap(e) {
|
||||
wx.navigateTo({
|
||||
url: `/pages/order/after-service-detail/index?rightsNo=${e.currentTarget.dataset.order.id}`,
|
||||
});
|
||||
},
|
||||
});
|
||||
17
miniprogram/pages/order/after-service-list/index.json
Normal file
17
miniprogram/pages/order/after-service-list/index.json
Normal file
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"navigationBarTitleText": "退款/售后",
|
||||
"usingComponents": {
|
||||
"wr-load-more": "/components/load-more/index",
|
||||
"wr-after-service-button-bar": "../components/after-service-button-bar/index",
|
||||
"wr-price": "/components/price/index",
|
||||
"wr-order-card": "../components/order-card/index",
|
||||
"wr-goods-card": "../components/goods-card/index",
|
||||
"t-tabs": "tdesign-miniprogram/tabs/tabs",
|
||||
"t-tab-panel": "tdesign-miniprogram/tab-panel/tab-panel",
|
||||
"t-icon": "tdesign-miniprogram/icon/icon",
|
||||
"t-toast": "tdesign-miniprogram/toast/toast",
|
||||
"t-dialog": "tdesign-miniprogram/dialog/dialog",
|
||||
"t-empty": "tdesign-miniprogram/empty/empty",
|
||||
"t-pull-down-refresh": "tdesign-miniprogram/pull-down-refresh/pull-down-refresh"
|
||||
}
|
||||
}
|
||||
81
miniprogram/pages/order/after-service-list/index.wxml
Normal file
81
miniprogram/pages/order/after-service-list/index.wxml
Normal file
@@ -0,0 +1,81 @@
|
||||
<view class="page-container">
|
||||
<view class="tab-bar">
|
||||
<view class="tab-bar__placeholder" />
|
||||
<t-tabs
|
||||
t-class="tab-bar__inner"
|
||||
t-class-active="tab-bar__active"
|
||||
t-class-track="t-tabs-track"
|
||||
bind:change="onTabChange"
|
||||
value="{{curTab}}"
|
||||
style="position: fixed; top: 0; left: 0; z-index: 100"
|
||||
>
|
||||
<t-tab-panel
|
||||
wx:for="{{tabs}}"
|
||||
wx:for-index="index"
|
||||
wx:for-item="item"
|
||||
wx:key="index"
|
||||
label="{{item.text}}"
|
||||
value="{{item.key}}"
|
||||
/>
|
||||
</t-tabs>
|
||||
</view>
|
||||
<t-pull-down-refresh id="t-pull-down-refresh" bindrefresh="onPullDownRefresh_" t-class-indicator="t-class-indicator">
|
||||
<wr-order-card
|
||||
wx:for="{{dataList}}"
|
||||
wx:key="id"
|
||||
wx:for-item="order"
|
||||
wx:for-index="oIndex"
|
||||
order="{{order}}"
|
||||
data-order="{{order}}"
|
||||
bindcardtap="onAfterServiceCardTap"
|
||||
useTopRightSlot
|
||||
header-class="header-class"
|
||||
>
|
||||
<view class="text-btn" slot="top-right">
|
||||
<view class="header__right">
|
||||
<t-icon prefix="wr" color="#FA4126" name="goods_refund" size="20px" slot="left-icon" />
|
||||
{{order.typeDesc}}
|
||||
</view>
|
||||
</view>
|
||||
<wr-goods-card
|
||||
wx:for="{{order.goodsList}}"
|
||||
wx:key="id"
|
||||
wx:for-item="goods"
|
||||
wx:for-index="gIndex"
|
||||
data="{{goods}}"
|
||||
no-top-line="{{gIndex === 0}}"
|
||||
>
|
||||
<view slot="footer" class="order-goods-card-footer">
|
||||
<wr-price
|
||||
price="{{goods.itemRefundAmount}}"
|
||||
fill
|
||||
wr-class="order-goods-card-footer-price-class"
|
||||
symbol-class="order-goods-card-footer-price-symbol"
|
||||
decimal-class="order-goods-card-footer-price-decimal"
|
||||
/>
|
||||
<view class="order-goods-card-footer-num">x {{goods.rightsQuantity}}</view>
|
||||
</view>
|
||||
</wr-goods-card>
|
||||
<view slot="more">
|
||||
<view class="status-desc">{{order.statusDesc}}</view>
|
||||
<wr-after-service-button-bar service="{{order}}" bindrefresh="onRefresh" />
|
||||
</view>
|
||||
</wr-order-card>
|
||||
<!-- 列表加载中/已全部加载 -->
|
||||
<wr-load-more
|
||||
wx:if="{{!pullDownRefreshing}}"
|
||||
list-is-empty="{{!dataList.length}}"
|
||||
status="{{listLoading}}"
|
||||
bindretry="onReTryLoad"
|
||||
>
|
||||
<!-- 空态 -->
|
||||
<view slot="empty" class="empty-wrapper">
|
||||
<t-empty size="240rpx" textColor="#999999" textSize="28rpx" src="{{emptyImg}}">
|
||||
暂无退款或售后申请记录
|
||||
</t-empty>
|
||||
</view>
|
||||
</wr-load-more>
|
||||
</t-pull-down-refresh>
|
||||
</view>
|
||||
<t-toast id="t-toast" />
|
||||
<t-dialog id="t-dialog" />
|
||||
134
miniprogram/pages/order/after-service-list/index.wxss
Normal file
134
miniprogram/pages/order/after-service-list/index.wxss
Normal file
@@ -0,0 +1,134 @@
|
||||
:host {
|
||||
background-color: #f5f5f5;
|
||||
}
|
||||
|
||||
/* Tab相关样式 */
|
||||
.tab-bar {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.tab-bar__placeholder {
|
||||
height: 88rpx;
|
||||
}
|
||||
|
||||
.tab-bar__inner {
|
||||
background: #fff;
|
||||
border-bottom: 1rpx solid #f0f0f0;
|
||||
}
|
||||
|
||||
.tab-bar__active {
|
||||
color: #333333 !important;
|
||||
}
|
||||
|
||||
.t-tabs-track {
|
||||
background: #333333 !important;
|
||||
}
|
||||
|
||||
.t-tabs.t-tabs--top .t-tabs-scroll {
|
||||
border: none !important;
|
||||
}
|
||||
|
||||
.t-class-indicator {
|
||||
color: #b9b9b9 !important;
|
||||
}
|
||||
|
||||
.list-loading {
|
||||
height: 100rpx;
|
||||
}
|
||||
|
||||
.empty-wrapper {
|
||||
height: calc(100vh - 88rpx);
|
||||
}
|
||||
|
||||
.page-container .order-goods-card-footer {
|
||||
display: flex;
|
||||
width: calc(100% - 190rpx);
|
||||
justify-content: space-between;
|
||||
position: absolute;
|
||||
bottom: 20rpx;
|
||||
left: 190rpx;
|
||||
}
|
||||
|
||||
.page-container .order-goods-card-footer .order-goods-card-footer-num {
|
||||
color: #999;
|
||||
line-height: 40rpx;
|
||||
}
|
||||
|
||||
.page-container .order-goods-card-footer .order-goods-card-footer-price-class {
|
||||
font-size: 36rpx;
|
||||
color: #333;
|
||||
font-family: DIN Alternate;
|
||||
}
|
||||
|
||||
.page-container .order-goods-card-footer .order-goods-card-footer-price-decimal {
|
||||
font-size: 28rpx;
|
||||
color: #333;
|
||||
font-family: DIN Alternate;
|
||||
}
|
||||
|
||||
.page-container .order-goods-card-footer .order-goods-card-footer-price-symbol {
|
||||
color: #333;
|
||||
font-size: 24rpx;
|
||||
font-family: DIN Alternate;
|
||||
}
|
||||
|
||||
.page-container .wr-goods-card__specs {
|
||||
margin: 14rpx 20rpx 0 0;
|
||||
}
|
||||
|
||||
.page-container .order-goods-card > wr-goods-card .wr-goods-card__title {
|
||||
margin-right: 0;
|
||||
-webkit-line-clamp: 1;
|
||||
}
|
||||
|
||||
.page-container .order-card .header .store-name {
|
||||
width: 80%;
|
||||
-webkit-line-clamp: 1;
|
||||
}
|
||||
|
||||
.page-container .order-card .header .store-name > view {
|
||||
overflow: hidden;
|
||||
width: 100%;
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.page-container .status-desc {
|
||||
box-sizing: border-box;
|
||||
padding: 22rpx 20rpx;
|
||||
font-size: 26rpx;
|
||||
line-height: 1.3;
|
||||
text-align: left;
|
||||
color: #333333;
|
||||
background-color: #f5f5f5;
|
||||
border-radius: 8rpx;
|
||||
word-wrap: break-word;
|
||||
margin-top: 24rpx;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.page-container .header__right {
|
||||
font-size: 24rpx;
|
||||
color: #fa4126;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.page-container .header__right__icon {
|
||||
color: #d05b27;
|
||||
font-size: 16px !important;
|
||||
margin-right: 10rpx;
|
||||
}
|
||||
|
||||
.t-class-indicator {
|
||||
color: #b9b9b9 !important;
|
||||
}
|
||||
|
||||
.page-container .header-class {
|
||||
margin-bottom: 5rpx !important;
|
||||
}
|
||||
|
||||
.t-button {
|
||||
--td-button-default-color: #000;
|
||||
--td-button-primary-text-color: #fa4126;
|
||||
}
|
||||
445
miniprogram/pages/order/apply-service/index.js
Normal file
445
miniprogram/pages/order/apply-service/index.js
Normal file
@@ -0,0 +1,445 @@
|
||||
import Dialog from 'tdesign-miniprogram/dialog/index';
|
||||
import Toast from 'tdesign-miniprogram/toast/index';
|
||||
import { priceFormat } from '../../../utils/util';
|
||||
import { OrderStatus, ServiceType, ServiceReceiptStatus } from '../config';
|
||||
import reasonSheet from '../components/reason-sheet/reasonSheet';
|
||||
import {
|
||||
fetchRightsPreview,
|
||||
dispatchConfirmReceived,
|
||||
fetchApplyReasonList,
|
||||
dispatchApplyService,
|
||||
} from '../../../services/order/applyService';
|
||||
|
||||
Page({
|
||||
query: {},
|
||||
data: {
|
||||
uploading: false, // 凭证上传状态
|
||||
canApplyReturn: true, // 是否可退货
|
||||
goodsInfo: {},
|
||||
receiptStatusList: [
|
||||
{ desc: '未收到货', status: ServiceReceiptStatus.NOT_RECEIPTED },
|
||||
{ desc: '已收到货', status: ServiceReceiptStatus.RECEIPTED },
|
||||
],
|
||||
applyReasons: [],
|
||||
serviceType: null, // 20-仅退款,10-退货退款
|
||||
serviceFrom: {
|
||||
returnNum: 1,
|
||||
receiptStatus: { desc: '请选择', status: null },
|
||||
applyReason: { desc: '请选择', type: null },
|
||||
// max-填写上限(单位分),current-当前值(单位分),temp输入框中的值(单位元)
|
||||
amount: { max: 0, current: 0, temp: 0, focus: false },
|
||||
remark: '',
|
||||
rightsImageUrls: [],
|
||||
},
|
||||
maxApplyNum: 2, // 最大可申请售后的商品数
|
||||
amountTip: '',
|
||||
showReceiptStatusDialog: false,
|
||||
validateRes: {
|
||||
valid: false,
|
||||
msg: '',
|
||||
},
|
||||
submitting: false,
|
||||
inputDialogVisible: false,
|
||||
uploadGridConfig: {
|
||||
column: 3,
|
||||
width: 212,
|
||||
height: 212,
|
||||
},
|
||||
serviceRequireType: '',
|
||||
},
|
||||
|
||||
setWatcher(key, callback) {
|
||||
let lastData = this.data;
|
||||
const keys = key.split('.');
|
||||
keys.slice(0, -1).forEach((k) => {
|
||||
lastData = lastData[k];
|
||||
});
|
||||
const lastKey = keys[keys.length - 1];
|
||||
this.observe(lastData, lastKey, callback);
|
||||
},
|
||||
|
||||
observe(data, k, callback) {
|
||||
let val = data[k];
|
||||
Object.defineProperty(data, k, {
|
||||
configurable: true,
|
||||
enumerable: true,
|
||||
set: (value) => {
|
||||
val = value;
|
||||
callback();
|
||||
},
|
||||
get: () => {
|
||||
return val;
|
||||
},
|
||||
});
|
||||
},
|
||||
|
||||
validate() {
|
||||
let valid = true;
|
||||
let msg = '';
|
||||
// 检查必填项
|
||||
if (!this.data.serviceFrom.applyReason.type) {
|
||||
valid = false;
|
||||
msg = '请填写退款原因';
|
||||
} else if (!this.data.serviceFrom.amount.current) {
|
||||
valid = false;
|
||||
msg = '请填写退款金额';
|
||||
}
|
||||
if (this.data.serviceFrom.amount.current <= 0) {
|
||||
valid = false;
|
||||
msg = '退款金额必须大于0';
|
||||
}
|
||||
this.setData({ validateRes: { valid, msg } });
|
||||
},
|
||||
|
||||
onLoad(query) {
|
||||
this.query = query;
|
||||
if (!this.checkQuery()) return;
|
||||
this.setData({
|
||||
canApplyReturn: query.canApplyReturn === 'true',
|
||||
});
|
||||
this.init();
|
||||
this.inputDialog = this.selectComponent('#input-dialog');
|
||||
this.setWatcher('serviceFrom.returnNum', this.validate.bind(this));
|
||||
this.setWatcher('serviceFrom.applyReason', this.validate.bind(this));
|
||||
this.setWatcher('serviceFrom.amount', this.validate.bind(this));
|
||||
this.setWatcher('serviceFrom.rightsImageUrls', this.validate.bind(this));
|
||||
},
|
||||
|
||||
async init() {
|
||||
try {
|
||||
await this.refresh();
|
||||
} catch (e) {}
|
||||
},
|
||||
|
||||
checkQuery() {
|
||||
const { orderNo, skuId } = this.query;
|
||||
if (!orderNo) {
|
||||
Dialog.alert({
|
||||
content: '请先选择订单',
|
||||
}).then(() => {
|
||||
wx.redirectTo({ url: 'pages/order/order-list/index' });
|
||||
});
|
||||
return false;
|
||||
}
|
||||
if (!skuId) {
|
||||
Dialog.alert({
|
||||
content: '请先选择商品',
|
||||
}).then(() => {
|
||||
wx.redirectTo(`pages/order/order-detail/index?orderNo=${orderNo}`);
|
||||
});
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
|
||||
async refresh() {
|
||||
wx.showLoading({ title: 'loading' });
|
||||
try {
|
||||
const res = await this.getRightsPreview();
|
||||
wx.hideLoading();
|
||||
const goodsInfo = {
|
||||
id: res.data.skuId,
|
||||
thumb: res.data.goodsInfo && res.data.goodsInfo.skuImage,
|
||||
title: res.data.goodsInfo && res.data.goodsInfo.goodsName,
|
||||
spuId: res.data.spuId,
|
||||
skuId: res.data.skuId,
|
||||
specs: ((res.data.goodsInfo && res.data.goodsInfo.specInfo) || []).map((s) => s.specValue),
|
||||
paidAmountEach: res.data.paidAmountEach,
|
||||
boughtQuantity: res.data.boughtQuantity,
|
||||
};
|
||||
this.setData({
|
||||
goodsInfo,
|
||||
'serviceFrom.amount': {
|
||||
max: res.data.refundableAmount,
|
||||
current: res.data.refundableAmount,
|
||||
},
|
||||
'serviceFrom.returnNum': res.data.numOfSku,
|
||||
amountTip: `最多可申请退款¥ ${priceFormat(res.data.refundableAmount, 2)},含发货运费¥ ${priceFormat(
|
||||
res.data.shippingFeeIncluded,
|
||||
2,
|
||||
)}`,
|
||||
maxApplyNum: res.data.numOfSkuAvailable,
|
||||
});
|
||||
} catch (err) {
|
||||
wx.hideLoading();
|
||||
throw err;
|
||||
}
|
||||
},
|
||||
|
||||
async getRightsPreview() {
|
||||
const { orderNo, skuId, spuId } = this.query;
|
||||
const params = {
|
||||
orderNo,
|
||||
skuId,
|
||||
spuId,
|
||||
numOfSku: this.data.serviceFrom.returnNum,
|
||||
};
|
||||
const res = await fetchRightsPreview(params);
|
||||
return res;
|
||||
},
|
||||
|
||||
onApplyOnlyRefund() {
|
||||
wx.setNavigationBarTitle({ title: '申请退款' });
|
||||
this.setData({ serviceRequireType: 'REFUND_MONEY' });
|
||||
this.switchReceiptStatus(0);
|
||||
},
|
||||
|
||||
onApplyReturnGoods() {
|
||||
wx.setNavigationBarTitle({ title: '申请退货退款' });
|
||||
this.setData({ serviceRequireType: 'REFUND_GOODS' });
|
||||
const orderStatus = parseInt(this.query.orderStatus);
|
||||
Promise.resolve()
|
||||
.then(() => {
|
||||
if (orderStatus === OrderStatus.PENDING_RECEIPT) {
|
||||
return Dialog.confirm({
|
||||
title: '订单商品是否已经收到货',
|
||||
content: '',
|
||||
confirmBtn: '确认收货,并申请退货',
|
||||
cancelBtn: '未收到货',
|
||||
}).then(() => {
|
||||
return dispatchConfirmReceived({
|
||||
parameter: {
|
||||
logisticsNo: this.query.logisticsNo,
|
||||
orderNo: this.query.orderNo,
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
return;
|
||||
})
|
||||
.then(() => {
|
||||
this.setData({ serviceType: ServiceType.RETURN_GOODS });
|
||||
this.switchReceiptStatus(1);
|
||||
});
|
||||
},
|
||||
|
||||
onApplyReturnGoodsStatus() {
|
||||
reasonSheet({
|
||||
show: true,
|
||||
title: '选择退款原因',
|
||||
options: this.data.applyReasons.map((r) => ({
|
||||
title: r.desc,
|
||||
})),
|
||||
showConfirmButton: true,
|
||||
showCancelButton: true,
|
||||
emptyTip: '请选择退款原因',
|
||||
}).then((indexes) => {
|
||||
if (indexes && indexes.length > 0) {
|
||||
this.setData({
|
||||
'serviceFrom.applyReason': this.data.applyReasons[indexes[0]],
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
onChangeReturnNum(e) {
|
||||
const { value } = e.detail;
|
||||
this.setData({
|
||||
'serviceFrom.returnNum': value,
|
||||
});
|
||||
},
|
||||
|
||||
onApplyGoodsStatus() {
|
||||
reasonSheet({
|
||||
show: true,
|
||||
title: '请选择收货状态',
|
||||
options: this.data.receiptStatusList.map((r) => ({
|
||||
title: r.desc,
|
||||
})),
|
||||
showConfirmButton: true,
|
||||
emptyTip: '请选择收货状态',
|
||||
}).then((indexes) => {
|
||||
if (indexes && indexes.length > 0) {
|
||||
this.setData({
|
||||
'serviceFrom.receiptStatus': this.data.receiptStatusList[indexes[0]],
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
switchReceiptStatus(index) {
|
||||
const statusItem = this.data.receiptStatusList[index];
|
||||
// 没有找到对应的状态,则清空/初始化
|
||||
if (!statusItem) {
|
||||
this.setData({
|
||||
showReceiptStatusDialog: false,
|
||||
'serviceFrom.receiptStatus': { desc: '请选择', status: null },
|
||||
'serviceFrom.applyReason': { desc: '请选择', type: null }, // 收货状态改变时,初始化申请原因
|
||||
applyReasons: [],
|
||||
});
|
||||
return;
|
||||
}
|
||||
// 仅选中项与当前项不一致时,才切换申请原因列表applyReasons
|
||||
if (!statusItem || statusItem.status === this.data.serviceFrom.receiptStatus.status) {
|
||||
this.setData({ showReceiptStatusDialog: false });
|
||||
return;
|
||||
}
|
||||
this.getApplyReasons(statusItem.status).then((reasons) => {
|
||||
this.setData({
|
||||
showReceiptStatusDialog: false,
|
||||
'serviceFrom.receiptStatus': statusItem,
|
||||
'serviceFrom.applyReason': { desc: '请选择', type: null }, // 收货状态改变时,重置申请原因
|
||||
applyReasons: reasons,
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
getApplyReasons(receiptStatus) {
|
||||
const params = { rightsReasonType: receiptStatus };
|
||||
return fetchApplyReasonList(params)
|
||||
.then((res) => {
|
||||
return res.data.rightsReasonList.map((reason) => ({
|
||||
type: reason.id,
|
||||
desc: reason.desc,
|
||||
}));
|
||||
})
|
||||
.catch(() => {
|
||||
return [];
|
||||
});
|
||||
},
|
||||
|
||||
onReceiptStatusDialogConfirm(e) {
|
||||
const { index } = e.currentTarget.dataset;
|
||||
this.switchReceiptStatus(index);
|
||||
},
|
||||
|
||||
onAmountTap() {
|
||||
this.setData({
|
||||
'serviceFrom.amount.temp': priceFormat(this.data.serviceFrom.amount.current),
|
||||
'serviceFrom.amount.focus': true,
|
||||
inputDialogVisible: true,
|
||||
});
|
||||
this.inputDialog.setData({
|
||||
cancelBtn: '取消',
|
||||
confirmBtn: '确定',
|
||||
});
|
||||
this.inputDialog._onConfirm = () => {
|
||||
this.setData({
|
||||
'serviceFrom.amount.current': this.data.serviceFrom.amount.temp * 100,
|
||||
});
|
||||
};
|
||||
this.inputDialog._onCancel = () => {};
|
||||
},
|
||||
|
||||
// 对输入的值进行过滤
|
||||
onAmountInput(e) {
|
||||
let { value } = e.detail;
|
||||
const regRes = value.match(/\d+(\.?\d*)?/); // 输入中,允许末尾为小数点
|
||||
value = regRes ? regRes[0] : '';
|
||||
this.setData({ 'serviceFrom.amount.temp': value });
|
||||
},
|
||||
|
||||
// 失去焦点时,更严格的过滤并转化为float
|
||||
onAmountBlur(e) {
|
||||
let { value } = e.detail;
|
||||
const regRes = value.match(/\d+(\.?\d+)?/); // 失去焦点时,不允许末尾为小数点
|
||||
value = regRes ? regRes[0] : '0';
|
||||
value = parseFloat(value) * 100;
|
||||
if (value > this.data.serviceFrom.amount.max) {
|
||||
value = this.data.serviceFrom.amount.max;
|
||||
}
|
||||
this.setData({
|
||||
'serviceFrom.amount.temp': priceFormat(value),
|
||||
'serviceFrom.amount.focus': false,
|
||||
});
|
||||
},
|
||||
|
||||
onAmountFocus() {
|
||||
this.setData({ 'serviceFrom.amount.focus': true });
|
||||
},
|
||||
|
||||
onRemarkChange(e) {
|
||||
const { value } = e.detail;
|
||||
this.setData({
|
||||
'serviceFrom.remark': value,
|
||||
});
|
||||
},
|
||||
|
||||
// 发起申请售后请求
|
||||
onSubmit() {
|
||||
this.submitCheck().then(() => {
|
||||
const params = {
|
||||
rights: {
|
||||
orderNo: this.query.orderNo,
|
||||
refundRequestAmount: this.data.serviceFrom.amount.current,
|
||||
rightsImageUrls: this.data.serviceFrom.rightsImageUrls,
|
||||
rightsReasonDesc: this.data.serviceFrom.applyReason.desc,
|
||||
rightsReasonType: this.data.serviceFrom.receiptStatus.status,
|
||||
rightsType: this.data.serviceType,
|
||||
},
|
||||
rightsItem: [
|
||||
{
|
||||
itemTotalAmount: this.data.goodsInfo.price * this.data.serviceFrom.returnNum,
|
||||
rightsQuantity: this.data.serviceFrom.returnNum,
|
||||
skuId: this.query.skuId,
|
||||
spuId: this.query.spuId,
|
||||
},
|
||||
],
|
||||
refundMemo: this.data.serviceFrom.remark.current,
|
||||
};
|
||||
this.setData({ submitting: true });
|
||||
// 发起申请售后请求
|
||||
dispatchApplyService(params)
|
||||
.then((res) => {
|
||||
Toast({
|
||||
context: this,
|
||||
selector: '#t-toast',
|
||||
message: '申请成功',
|
||||
icon: '',
|
||||
});
|
||||
|
||||
wx.redirectTo({
|
||||
url: `/pages/order/after-service-detail/index?rightsNo=${res.data.rightsNo}`,
|
||||
});
|
||||
})
|
||||
.then(() => this.setData({ submitting: false }))
|
||||
.catch(() => this.setData({ submitting: false }));
|
||||
});
|
||||
},
|
||||
|
||||
submitCheck() {
|
||||
return new Promise((resolve) => {
|
||||
const { msg, valid } = this.data.validateRes;
|
||||
if (!valid) {
|
||||
Toast({
|
||||
context: this,
|
||||
selector: '#t-toast',
|
||||
message: msg,
|
||||
icon: '',
|
||||
});
|
||||
return;
|
||||
}
|
||||
resolve();
|
||||
});
|
||||
},
|
||||
|
||||
handleSuccess(e) {
|
||||
const { files } = e.detail;
|
||||
this.setData({
|
||||
'sessionFrom.rightsImageUrls': files,
|
||||
});
|
||||
},
|
||||
|
||||
handleRemove(e) {
|
||||
const { index } = e.detail;
|
||||
const {
|
||||
sessionFrom: { rightsImageUrls },
|
||||
} = this.data;
|
||||
rightsImageUrls.splice(index, 1);
|
||||
this.setData({
|
||||
'sessionFrom.rightsImageUrls': rightsImageUrls,
|
||||
});
|
||||
},
|
||||
|
||||
handleComplete() {
|
||||
this.setData({
|
||||
uploading: false,
|
||||
});
|
||||
},
|
||||
|
||||
handleSelectChange() {
|
||||
this.setData({
|
||||
uploading: true,
|
||||
});
|
||||
},
|
||||
});
|
||||
19
miniprogram/pages/order/apply-service/index.json
Normal file
19
miniprogram/pages/order/apply-service/index.json
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"navigationBarTitleText": "选择售后类型",
|
||||
"usingComponents": {
|
||||
"wr-price": "/components/price/index",
|
||||
"wr-order-goods-card": "../components/order-goods-card/index",
|
||||
"wr-reason-sheet": "../components/reason-sheet/index",
|
||||
"t-cell": "tdesign-miniprogram/cell/cell",
|
||||
"t-icon": "tdesign-miniprogram/icon/icon",
|
||||
"t-toast": "tdesign-miniprogram/toast/toast",
|
||||
"t-dialog": "tdesign-miniprogram/dialog/dialog",
|
||||
"t-button": "tdesign-miniprogram/button/button",
|
||||
"t-cell-group": "tdesign-miniprogram/cell-group/cell-group",
|
||||
"t-stepper": "tdesign-miniprogram/stepper/stepper",
|
||||
"t-popup": "tdesign-miniprogram/popup/popup",
|
||||
"t-textarea": "tdesign-miniprogram/textarea/textarea",
|
||||
"t-input": "tdesign-miniprogram/input/input",
|
||||
"t-upload": "tdesign-miniprogram/upload/upload"
|
||||
}
|
||||
}
|
||||
198
miniprogram/pages/order/apply-service/index.wxml
Normal file
198
miniprogram/pages/order/apply-service/index.wxml
Normal file
@@ -0,0 +1,198 @@
|
||||
<view class="select-service">
|
||||
<view class="order-goods-card">
|
||||
<wr-order-goods-card goods="{{goodsInfo}}" no-top-line thumb-class="order-goods-card-title-class">
|
||||
<view slot="footer" class="order-goods-card-footer">
|
||||
<wr-price
|
||||
price="{{goodsInfo.paidAmountEach}}"
|
||||
fill
|
||||
wr-class="order-goods-card-footer-price-class"
|
||||
symbol-class="order-goods-card-footer-price-symbol"
|
||||
decimal-class="order-goods-card-footer-price-decimal"
|
||||
/>
|
||||
<view class="order-goods-card-footer-num">x {{goodsInfo.boughtQuantity}}</view>
|
||||
</view>
|
||||
</wr-order-goods-card>
|
||||
</view>
|
||||
<view wx:if="{{!serviceRequireType}}" class="service-choice">
|
||||
<t-cell-group>
|
||||
<t-cell
|
||||
title="申请退款(无需退货)"
|
||||
arrow
|
||||
description="没收到货,或与商家协商同意不用退货只退款"
|
||||
bindtap="onApplyOnlyRefund"
|
||||
>
|
||||
<t-icon
|
||||
slot="left-icon"
|
||||
prefix="wr"
|
||||
class="t-cell__left__icon"
|
||||
name="goods_refund"
|
||||
size="48rpx"
|
||||
color="#fa4126"
|
||||
/>
|
||||
</t-cell>
|
||||
<t-cell
|
||||
wx:if="{{canApplyReturn}}"
|
||||
title="退货退款"
|
||||
description="已收到货,需要退还收到的商品"
|
||||
arrow
|
||||
bindtap="onApplyReturnGoods"
|
||||
>
|
||||
<t-icon
|
||||
slot="left-icon"
|
||||
prefix="wr"
|
||||
class="t-cell__left__icon"
|
||||
name="goods_return"
|
||||
size="48rpx"
|
||||
color="#fa4126"
|
||||
/>
|
||||
</t-cell>
|
||||
<t-cell wx:else class="non-returnable" title="退货退款" description="该商品不支持退货">
|
||||
<t-icon
|
||||
slot="left-icon"
|
||||
prefix="wr"
|
||||
class="t-cell__left__icon"
|
||||
name="goods_return"
|
||||
size="48rpx"
|
||||
color="#fa4126"
|
||||
/>
|
||||
</t-cell>
|
||||
</t-cell-group>
|
||||
</view>
|
||||
<!-- 售后表单 -->
|
||||
<view wx:else class="service-form">
|
||||
<view class="service-from-group">
|
||||
<t-cell-group>
|
||||
<t-cell title="商品收货状态" arrow note="{{serviceFrom.receiptStatus.desc}}" bind:tap="onApplyGoodsStatus" />
|
||||
<t-cell
|
||||
bordered="{{false}}"
|
||||
title="退款原因"
|
||||
wx:if="{{canApplyReturn}}"
|
||||
note="{{serviceFrom.applyReason.desc}}"
|
||||
arrow
|
||||
bindtap="onApplyReturnGoodsStatus"
|
||||
/>
|
||||
</t-cell-group>
|
||||
</view>
|
||||
<view class="service-from-group">
|
||||
<t-cell-group>
|
||||
<t-cell title="退款商品数量">
|
||||
<t-stepper
|
||||
slot="note"
|
||||
theme="filled"
|
||||
min="1"
|
||||
max="{{maxApplyNum}}"
|
||||
value="{{serviceFrom.returnNum}}"
|
||||
bindchange="onChangeReturnNum"
|
||||
/>
|
||||
</t-cell>
|
||||
<t-cell
|
||||
title="退款金额"
|
||||
t-class-description="refund-money__description"
|
||||
description="{{amountTip}}"
|
||||
bind:tap="onAmountTap"
|
||||
>
|
||||
<view class="service-from-group__wrapper" slot="note">
|
||||
<wr-price
|
||||
price="{{serviceFrom.amount.current}}"
|
||||
fill
|
||||
wr-class="refund-money-price-class"
|
||||
symbol-class="refund-money-price-symbol"
|
||||
decimal-class="refund-money-price-decimal"
|
||||
/>
|
||||
<view class="service-from-group__price">
|
||||
修改
|
||||
<t-icon color="#bbb" name="chevron-right" size="30rpx" slot="left-icon" />
|
||||
</view>
|
||||
</view>
|
||||
</t-cell>
|
||||
</t-cell-group>
|
||||
</view>
|
||||
<view class="service-from-group__textarea">
|
||||
<text class="textarea--label">退款说明</text>
|
||||
<t-textarea
|
||||
style="height: 220rpx"
|
||||
value="{{serviceFrom.remark}}"
|
||||
t-class="textarea--content"
|
||||
maxlength="200"
|
||||
indicator
|
||||
placeholder="退款说明(选填)"
|
||||
bind:change="onRemarkChange"
|
||||
/>
|
||||
</view>
|
||||
<view class="service-from-group__grid">
|
||||
<t-upload
|
||||
media-type="{{['image','video']}}"
|
||||
files="{{sessionFrom.rightsImageUrls}}"
|
||||
bind:remove="handleRemove"
|
||||
bind:success="handleSuccess"
|
||||
bind:complete="handleComplete"
|
||||
bind:select-change="handleSelectChange"
|
||||
gridConfig="{{uploadGridConfig}}"
|
||||
max="3"
|
||||
>
|
||||
<view slot="add-content" class="upload-addcontent-slot">
|
||||
<t-icon name="add" size="60rpx" />
|
||||
<view class="upload-desc">
|
||||
<text>上传凭证</text>
|
||||
<text>(最多3张)</text>
|
||||
</view>
|
||||
</view>
|
||||
</t-upload>
|
||||
</view>
|
||||
<view class="bottom-bar">
|
||||
<t-button
|
||||
t-class="bottom-bar__btn {{validateRes.valid && !uploading ? '' : 'disabled'}}"
|
||||
bindtap="onSubmit"
|
||||
loading="{{submitting}}"
|
||||
>
|
||||
提交
|
||||
</t-button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 收货状态选择 -->
|
||||
<t-popup visible="{{showReceiptStatusDialog}}" placement="bottom" bindclose="onReceiptStatusDialogConfirm">
|
||||
<view class="dialog--service-status" slot="content">
|
||||
<view class="options">
|
||||
<view
|
||||
wx:for="{{receiptStatusList}}"
|
||||
wx:key="status"
|
||||
class="option"
|
||||
hover-class="option--active"
|
||||
bindtap="onReceiptStatusDialogConfirm"
|
||||
data-index="{{index}}"
|
||||
>
|
||||
{{item.desc}}
|
||||
</view>
|
||||
</view>
|
||||
<view class="cancel" hover-class="cancel--active" bindtap="onReceiptStatusDialogConfirm">取消</view>
|
||||
</view>
|
||||
</t-popup>
|
||||
<!-- 理由选择 -->
|
||||
<wr-reason-sheet id="wr-reason-sheet" />
|
||||
<!-- 金额填写 -->
|
||||
<t-dialog
|
||||
id="input-dialog"
|
||||
visible="{{inputDialogVisible}}"
|
||||
class="{{serviceFrom.amount.focus ? 'amount-dialog--focus' : ''}}"
|
||||
>
|
||||
<view class="input-dialog__title" slot="title">退款金额</view>
|
||||
<view class="input-dialog__content" slot="content">
|
||||
<t-input
|
||||
t-class="input"
|
||||
t-class-input="input-dialog__input"
|
||||
t-class-label="input-dialog__label"
|
||||
placeholder=""
|
||||
value="{{serviceFrom.amount.temp}}"
|
||||
type="digit"
|
||||
focus="{{serviceFrom.amount.focus}}"
|
||||
bindinput="onAmountInput"
|
||||
bindfocus="onAmountFocus"
|
||||
bindblur="onAmountBlur"
|
||||
label="¥"
|
||||
></t-input>
|
||||
<view class="tips">{{amountTip}}</view>
|
||||
</view>
|
||||
</t-dialog>
|
||||
<t-dialog id="t-dialog" />
|
||||
<t-toast id="t-toast" />
|
||||
308
miniprogram/pages/order/apply-service/index.wxss
Normal file
308
miniprogram/pages/order/apply-service/index.wxss
Normal file
@@ -0,0 +1,308 @@
|
||||
:host {
|
||||
background-color: #f5f5f5;
|
||||
}
|
||||
.select-service .service-form .service-from-group {
|
||||
margin-top: 20rpx;
|
||||
}
|
||||
.select-service .service-form {
|
||||
padding-bottom: calc(env(safe-area-inset-bottom) + 80rpx);
|
||||
}
|
||||
|
||||
.order-goods-card-footer {
|
||||
display: flex;
|
||||
width: calc(100% - 190rpx);
|
||||
justify-content: space-between;
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
left: 190rpx;
|
||||
}
|
||||
|
||||
.order-goods-card-footer-num {
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.select-service .order-goods-card-footer .order-goods-card-footer-price-class {
|
||||
font-size: 36rpx;
|
||||
color: #333;
|
||||
font-family: DIN Alternate;
|
||||
}
|
||||
.select-service .order-goods-card-footer .order-goods-card-footer-price-decimal {
|
||||
font-size: 28rpx;
|
||||
color: #333;
|
||||
font-family: DIN Alternate;
|
||||
}
|
||||
.select-service .order-goods-card-footer .order-goods-card-footer-price-symbol {
|
||||
color: #333;
|
||||
font-size: 24rpx;
|
||||
font-family: DIN Alternate;
|
||||
}
|
||||
|
||||
.select-service .remark {
|
||||
min-height: 110rpx;
|
||||
border-radius: 10rpx;
|
||||
margin-top: 20rpx;
|
||||
background-color: #f5f5f5;
|
||||
}
|
||||
.select-service .remark::after {
|
||||
border: none;
|
||||
}
|
||||
|
||||
.select-service .special-cell .special-cell-note {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.select-service .special-cell .wr-cell__title {
|
||||
margin-right: 100rpx;
|
||||
}
|
||||
|
||||
.select-service .special-cell .special-cell-note-price-class {
|
||||
font-size: 36rpx;
|
||||
color: #fa4126;
|
||||
font-family: DIN Alternate;
|
||||
}
|
||||
.select-service .special-cell .special-cell-note-price-decimal {
|
||||
font-size: 28rpx;
|
||||
color: #fa4126;
|
||||
font-family: DIN Alternate;
|
||||
}
|
||||
.select-service .special-cell .special-cell-note-price-symbol {
|
||||
color: #fa4126;
|
||||
font-size: 24rpx;
|
||||
font-family: DIN Alternate;
|
||||
}
|
||||
|
||||
.select-service .bottom-bar__btn {
|
||||
width: 686rpx;
|
||||
background-color: #fa4126;
|
||||
color: white;
|
||||
font-size: 32rpx;
|
||||
border-radius: 48rpx;
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
top: 20rpx;
|
||||
transform: translateX(-50%);
|
||||
}
|
||||
.select-service .bottom-bar__btn::after {
|
||||
border: none;
|
||||
}
|
||||
.select-service .bottom-bar__btn.disabled {
|
||||
background-color: #c6c6c6;
|
||||
--td-button-default-active-bg-color: #c6c6c6;
|
||||
--td-button-default-border-bg-color: #c6c6c6;
|
||||
}
|
||||
.select-service .bottom-bar__btn.disabled::after {
|
||||
border: none;
|
||||
}
|
||||
.select-service .order-goods-card .wr-goods-card {
|
||||
padding: 0 30rpx;
|
||||
}
|
||||
|
||||
.order-goods-card-footer {
|
||||
display: flex;
|
||||
width: calc(100% - 190rpx);
|
||||
justify-content: space-between;
|
||||
position: absolute;
|
||||
bottom: 20rpx;
|
||||
left: 190rpx;
|
||||
}
|
||||
|
||||
.order-goods-card-footer-num {
|
||||
color: #999;
|
||||
line-height: 40rpx;
|
||||
}
|
||||
|
||||
.order-goods-card-title-class {
|
||||
width: 10rpx !important;
|
||||
}
|
||||
|
||||
.input-dialog__content .input-dialog__input {
|
||||
font-size: 72rpx !important;
|
||||
height: 64rpx;
|
||||
}
|
||||
|
||||
.t-input__label {
|
||||
margin-right: 0 !important;
|
||||
}
|
||||
|
||||
.input-dialog__label {
|
||||
font-size: 48rpx;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.input-dialog__content .input-dialog__input,
|
||||
.input-dialog__label {
|
||||
height: 64rpx;
|
||||
line-height: 64rpx !important;
|
||||
}
|
||||
|
||||
.input-dialog__content .input {
|
||||
font-size: 48rpx;
|
||||
padding-left: 0;
|
||||
padding-right: 0;
|
||||
--td-input-border-left-space: 0;
|
||||
}
|
||||
|
||||
.input-dialog__content .tips {
|
||||
margin-top: 24rpx;
|
||||
font-size: 24rpx;
|
||||
color: #999999;
|
||||
}
|
||||
|
||||
.t-input__name {
|
||||
width: 10rpx !important;
|
||||
}
|
||||
|
||||
.input-dialog__title {
|
||||
color: #333;
|
||||
font-size: 32rpx;
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
.dialog--service-status {
|
||||
background-color: #f3f4f5;
|
||||
overflow: hidden;
|
||||
}
|
||||
.dialog--service-status .options .option {
|
||||
color: #333333;
|
||||
font-size: 30rpx;
|
||||
text-align: center;
|
||||
height: 100rpx;
|
||||
line-height: 100rpx;
|
||||
background-color: white;
|
||||
}
|
||||
.dialog--service-status .options .option:not(:last-child) {
|
||||
border-bottom: 1rpx solid #e6e6e6;
|
||||
}
|
||||
.dialog--service-status .options .option--active {
|
||||
opacity: 0.5;
|
||||
}
|
||||
.dialog--service-status .options .option.main {
|
||||
color: #fa4126;
|
||||
}
|
||||
.dialog--service-status .cancel {
|
||||
color: #333333;
|
||||
font-size: 30rpx;
|
||||
text-align: center;
|
||||
height: 100rpx;
|
||||
line-height: 100rpx;
|
||||
background-color: white;
|
||||
margin-top: 20rpx;
|
||||
}
|
||||
.dialog--service-status .cancel--active {
|
||||
opacity: 0.5;
|
||||
}
|
||||
.amount-dialog--focus .popup__content--center,
|
||||
.remark-dialog--focus .popup__content--center {
|
||||
top: 100rpx;
|
||||
transform: translate(-50%, 0);
|
||||
}
|
||||
.dialog .dialog__button-confirm {
|
||||
color: #fa4126;
|
||||
color: var(--color-primary, #fa4126);
|
||||
}
|
||||
.select-service .bottom-bar {
|
||||
background-color: #fff;
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 158rpx;
|
||||
z-index: 3;
|
||||
}
|
||||
.order-goods-card {
|
||||
background: #fff;
|
||||
margin-bottom: 24rpx;
|
||||
}
|
||||
|
||||
.service-from-group__wrapper {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
font-family: DIN Alternate;
|
||||
font-weight: bold;
|
||||
font-size: 36rpx;
|
||||
text-align: right;
|
||||
color: #fa4126;
|
||||
}
|
||||
.service-from-group__price {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
color: #bbb;
|
||||
font-size: 24rpx;
|
||||
position: relative;
|
||||
left: 30rpx;
|
||||
}
|
||||
.textarea--label {
|
||||
}
|
||||
.service-from-group__textarea {
|
||||
margin-top: 20rpx;
|
||||
background-color: #fff;
|
||||
padding: 32rpx 32rpx 24rpx;
|
||||
}
|
||||
|
||||
.textarea--content {
|
||||
margin-top: 32rpx;
|
||||
background: #f5f5f5 !important;
|
||||
border-radius: 16rpx;
|
||||
}
|
||||
.service-from-group__textarea .t-textarea__wrapper .t-textarea__wrapper-textarea {
|
||||
height: 136rpx;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.service-from-group__grid {
|
||||
padding: 0 32rpx 48rpx;
|
||||
background: #fff;
|
||||
margin-bottom: 148rpx;
|
||||
}
|
||||
|
||||
.upload-addcontent-slot {
|
||||
background-color: #f5f5f5;
|
||||
height: inherit;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.refund-money__description {
|
||||
font-size: 24rpx !important;
|
||||
}
|
||||
|
||||
.upload-desc {
|
||||
text-align: center;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
font-size: 24rpx;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.t-cell__left__icon {
|
||||
position: relative;
|
||||
top: -24rpx;
|
||||
margin-right: 18rpx;
|
||||
}
|
||||
|
||||
.service-choice .t-cell__title-text {
|
||||
color: #333;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.service-form .service-from-group .service-from-group__wrapper .refund-money-price-class {
|
||||
font-size: 36rpx;
|
||||
font-family: DIN Alternate;
|
||||
}
|
||||
|
||||
.service-form .service-from-group .service-from-group__wrapper .refund-money-price-decimal {
|
||||
font-size: 28rpx;
|
||||
font-family: DIN Alternate;
|
||||
}
|
||||
|
||||
.service-form .service-from-group .service-from-group__wrapper .refund-money-price-symbol {
|
||||
font-size: 24rpx;
|
||||
font-family: DIN Alternate;
|
||||
}
|
||||
|
||||
.t-button {
|
||||
--td-button-default-color: #000;
|
||||
--td-button-primary-text-color: #fa4126;
|
||||
}
|
||||
125
miniprogram/pages/order/comment-list/index.js
Normal file
125
miniprogram/pages/order/comment-list/index.js
Normal file
@@ -0,0 +1,125 @@
|
||||
import Toast from 'tdesign-miniprogram/toast/index';
|
||||
import config from '../../../config/index';
|
||||
|
||||
Page({
|
||||
data: {
|
||||
orderNo: '',
|
||||
orderItems: [],
|
||||
loading: true,
|
||||
},
|
||||
|
||||
onLoad(options) {
|
||||
const { orderNo } = options;
|
||||
if (orderNo) {
|
||||
this.setData({ orderNo });
|
||||
this.fetchOrderItems();
|
||||
} else {
|
||||
Toast({
|
||||
context: this,
|
||||
selector: '#t-toast',
|
||||
message: '订单号不能为空',
|
||||
icon: 'error',
|
||||
});
|
||||
setTimeout(() => {
|
||||
wx.navigateBack();
|
||||
}, 1500);
|
||||
}
|
||||
},
|
||||
|
||||
// 获取订单商品列表
|
||||
async fetchOrderItems() {
|
||||
try {
|
||||
wx.showLoading({
|
||||
title: '加载中...',
|
||||
mask: true
|
||||
});
|
||||
|
||||
const token = wx.getStorageSync('token');
|
||||
if (!token) {
|
||||
Toast({
|
||||
context: this,
|
||||
selector: '#t-toast',
|
||||
message: '请先登录',
|
||||
icon: 'error',
|
||||
});
|
||||
setTimeout(() => {
|
||||
wx.navigateTo({
|
||||
url: '/pages/login/index'
|
||||
});
|
||||
}, 1500);
|
||||
return;
|
||||
}
|
||||
|
||||
const res = await new Promise((resolve, reject) => {
|
||||
wx.request({
|
||||
url: `${config.apiBase}/api/v1/orders/${this.data.orderNo}`,
|
||||
method: 'GET',
|
||||
header: {
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': `Bearer ${token}`
|
||||
},
|
||||
success: resolve,
|
||||
fail: reject
|
||||
});
|
||||
});
|
||||
|
||||
wx.hideLoading();
|
||||
|
||||
if (res.statusCode === 200 && res.data.code === 200) {
|
||||
const order = res.data.data;
|
||||
const orderItems = order.order_items || [];
|
||||
|
||||
// 过滤出可以评论的商品(已确认收货且未评论)
|
||||
const commentableItems = orderItems.filter(item =>
|
||||
order.status === 'completed' && !item.is_commented
|
||||
);
|
||||
|
||||
this.setData({
|
||||
orderItems: commentableItems,
|
||||
loading: false
|
||||
});
|
||||
|
||||
if (commentableItems.length === 0) {
|
||||
Toast({
|
||||
context: this,
|
||||
selector: '#t-toast',
|
||||
message: '暂无可评论的商品',
|
||||
icon: 'info',
|
||||
});
|
||||
}
|
||||
} else {
|
||||
throw new Error(res.data.message || '获取订单信息失败');
|
||||
}
|
||||
} catch (error) {
|
||||
wx.hideLoading();
|
||||
console.error('获取订单商品失败:', error);
|
||||
Toast({
|
||||
context: this,
|
||||
selector: '#t-toast',
|
||||
message: error.message || '网络错误,请重试',
|
||||
icon: 'error',
|
||||
});
|
||||
this.setData({ loading: false });
|
||||
}
|
||||
},
|
||||
|
||||
// 点击评论商品
|
||||
onCommentItem(e) {
|
||||
const { item } = e.currentTarget.dataset;
|
||||
wx.navigateTo({
|
||||
url: `/pages/order/comment/index?orderNo=${this.data.orderNo}&orderItemId=${item.id}`,
|
||||
});
|
||||
},
|
||||
|
||||
// 返回上一页
|
||||
onBack() {
|
||||
wx.navigateBack();
|
||||
},
|
||||
|
||||
// 下拉刷新
|
||||
onPullDownRefresh() {
|
||||
this.fetchOrderItems().finally(() => {
|
||||
wx.stopPullDownRefresh();
|
||||
});
|
||||
}
|
||||
});
|
||||
11
miniprogram/pages/order/comment-list/index.json
Normal file
11
miniprogram/pages/order/comment-list/index.json
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"usingComponents": {
|
||||
"t-navbar": "tdesign-miniprogram/navbar/navbar",
|
||||
"t-loading": "tdesign-miniprogram/loading/loading",
|
||||
"t-icon": "tdesign-miniprogram/icon/icon",
|
||||
"t-toast": "tdesign-miniprogram/toast/toast",
|
||||
"price": "/components/price/index"
|
||||
},
|
||||
"navigationStyle": "custom",
|
||||
"enablePullDownRefresh": true
|
||||
}
|
||||
66
miniprogram/pages/order/comment-list/index.wxml
Normal file
66
miniprogram/pages/order/comment-list/index.wxml
Normal file
@@ -0,0 +1,66 @@
|
||||
<view class="comment-list-page">
|
||||
<!-- 导航栏 -->
|
||||
<t-navbar title="选择评价商品" left-arrow bind:left-click="onBack" />
|
||||
|
||||
<!-- 加载状态 -->
|
||||
<view class="loading-container" wx:if="{{loading}}">
|
||||
<t-loading theme="circular" size="48rpx" text="加载中..." />
|
||||
</view>
|
||||
|
||||
<!-- 商品列表 -->
|
||||
<view class="order-items" wx:else>
|
||||
<view
|
||||
class="order-item"
|
||||
wx:for="{{orderItems}}"
|
||||
wx:key="id"
|
||||
bind:tap="onCommentItem"
|
||||
data-item="{{item}}"
|
||||
>
|
||||
<view class="item-content">
|
||||
<!-- 商品图片 -->
|
||||
<image
|
||||
class="product-image"
|
||||
src="{{item.product.images[0] || '/assets/placeholder.png'}}"
|
||||
mode="aspectFill"
|
||||
/>
|
||||
|
||||
<!-- 商品信息 -->
|
||||
<view class="product-info">
|
||||
<view class="product-name">{{item.product.name}}</view>
|
||||
<view class="product-spec" wx:if="{{item.product_spec}}">{{item.product_spec}}</view>
|
||||
<view class="product-price">
|
||||
<price price="{{item.price}}" />
|
||||
<text class="quantity">x{{item.quantity}}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 评论状态 -->
|
||||
<view class="comment-status">
|
||||
<view class="status-badge" wx:if="{{item.is_commented}}">
|
||||
<t-icon name="check-circle-filled" size="32rpx" color="#52c41a" />
|
||||
<text class="status-text commented">已评价</text>
|
||||
</view>
|
||||
<view class="status-badge" wx:else>
|
||||
<t-icon name="chat" size="32rpx" color="#ff6b35" />
|
||||
<text class="status-text uncommented">待评价</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 箭头 -->
|
||||
<view class="arrow" wx:if="{{!item.is_commented}}">
|
||||
<t-icon name="chevron-right" size="32rpx" color="#999" />
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 空状态 -->
|
||||
<view class="empty-state" wx:if="{{orderItems.length === 0}}">
|
||||
<t-icon name="chat" size="120rpx" color="#ddd" />
|
||||
<text class="empty-text">暂无可评价的商品</text>
|
||||
<text class="empty-desc">所有商品都已评价完成</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- Toast -->
|
||||
<t-toast id="t-toast" />
|
||||
</view>
|
||||
133
miniprogram/pages/order/comment-list/index.wxss
Normal file
133
miniprogram/pages/order/comment-list/index.wxss
Normal file
@@ -0,0 +1,133 @@
|
||||
.comment-list-page {
|
||||
background-color: #f5f5f5;
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
/* 加载状态 */
|
||||
.loading-container {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
height: 400rpx;
|
||||
}
|
||||
|
||||
/* 商品列表 */
|
||||
.order-items {
|
||||
padding: 20rpx 0;
|
||||
}
|
||||
|
||||
.order-item {
|
||||
background: #fff;
|
||||
margin-bottom: 20rpx;
|
||||
padding: 32rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.order-item:active {
|
||||
background-color: #f8f8f8;
|
||||
}
|
||||
|
||||
.item-content {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
/* 商品图片 */
|
||||
.product-image {
|
||||
width: 120rpx;
|
||||
height: 120rpx;
|
||||
border-radius: 12rpx;
|
||||
margin-right: 24rpx;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
/* 商品信息 */
|
||||
.product-info {
|
||||
flex: 1;
|
||||
margin-right: 24rpx;
|
||||
}
|
||||
|
||||
.product-name {
|
||||
font-size: 32rpx;
|
||||
color: #333;
|
||||
font-weight: 500;
|
||||
margin-bottom: 8rpx;
|
||||
line-height: 1.4;
|
||||
display: -webkit-box;
|
||||
-webkit-box-orient: vertical;
|
||||
-webkit-line-clamp: 2;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.product-spec {
|
||||
font-size: 24rpx;
|
||||
color: #999;
|
||||
margin-bottom: 8rpx;
|
||||
}
|
||||
|
||||
.product-price {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.quantity {
|
||||
font-size: 28rpx;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
/* 评论状态 */
|
||||
.comment-status {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.status-badge {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 8rpx;
|
||||
}
|
||||
|
||||
.status-text {
|
||||
font-size: 24rpx;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.status-text.commented {
|
||||
color: #52c41a;
|
||||
}
|
||||
|
||||
.status-text.uncommented {
|
||||
color: #ff6b35;
|
||||
}
|
||||
|
||||
/* 箭头 */
|
||||
.arrow {
|
||||
margin-left: 16rpx;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
/* 空状态 */
|
||||
.empty-state {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 120rpx 32rpx;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.empty-text {
|
||||
font-size: 32rpx;
|
||||
color: #666;
|
||||
margin-top: 24rpx;
|
||||
margin-bottom: 8rpx;
|
||||
}
|
||||
|
||||
.empty-desc {
|
||||
font-size: 28rpx;
|
||||
color: #999;
|
||||
}
|
||||
239
miniprogram/pages/order/comment/index.js
Normal file
239
miniprogram/pages/order/comment/index.js
Normal file
@@ -0,0 +1,239 @@
|
||||
import { createComment } from '../../../services/comments/createComment';
|
||||
import Toast from 'tdesign-miniprogram/toast/index';
|
||||
|
||||
Page({
|
||||
data: {
|
||||
orderItem: null,
|
||||
rating: 5,
|
||||
content: '',
|
||||
images: [],
|
||||
isAnonymous: false,
|
||||
submitting: false,
|
||||
maxImages: 9,
|
||||
maxContentLength: 500
|
||||
},
|
||||
|
||||
onLoad(options) {
|
||||
console.log('评论页面加载', options);
|
||||
|
||||
// 从页面参数获取订单项信息
|
||||
if (options.orderItemData) {
|
||||
try {
|
||||
const orderItem = JSON.parse(decodeURIComponent(options.orderItemData));
|
||||
this.setData({ orderItem });
|
||||
console.log('订单项信息', orderItem);
|
||||
} catch (e) {
|
||||
console.error('解析订单项数据失败', e);
|
||||
Toast({
|
||||
context: this,
|
||||
selector: '#t-toast',
|
||||
message: '参数错误',
|
||||
icon: 'error-circle',
|
||||
});
|
||||
setTimeout(() => {
|
||||
wx.navigateBack();
|
||||
}, 1500);
|
||||
}
|
||||
} else {
|
||||
Toast({
|
||||
context: this,
|
||||
selector: '#t-toast',
|
||||
message: '缺少订单信息',
|
||||
icon: 'error-circle',
|
||||
});
|
||||
setTimeout(() => {
|
||||
wx.navigateBack();
|
||||
}, 1500);
|
||||
}
|
||||
},
|
||||
|
||||
// 评分变化
|
||||
onRatingChange(e) {
|
||||
this.setData({
|
||||
rating: e.detail.value
|
||||
});
|
||||
},
|
||||
|
||||
// 评论内容输入
|
||||
onContentInput(e) {
|
||||
this.setData({
|
||||
content: e.detail.value
|
||||
});
|
||||
},
|
||||
|
||||
// 匿名评论切换
|
||||
onAnonymousChange(e) {
|
||||
this.setData({
|
||||
isAnonymous: e.detail.value
|
||||
});
|
||||
},
|
||||
|
||||
// 选择图片
|
||||
onChooseImage() {
|
||||
const { images, maxImages } = this.data;
|
||||
const remainCount = maxImages - images.length;
|
||||
|
||||
if (remainCount <= 0) {
|
||||
Toast({
|
||||
context: this,
|
||||
selector: '#t-toast',
|
||||
message: `最多只能上传${maxImages}张图片`,
|
||||
icon: 'error-circle',
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
wx.chooseMedia({
|
||||
count: remainCount,
|
||||
mediaType: ['image'],
|
||||
sourceType: ['album', 'camera'],
|
||||
success: (res) => {
|
||||
const newImages = res.tempFiles.map(file => file.tempFilePath);
|
||||
this.setData({
|
||||
images: [...images, ...newImages]
|
||||
});
|
||||
},
|
||||
fail: (err) => {
|
||||
console.error('选择图片失败', err);
|
||||
Toast({
|
||||
context: this,
|
||||
selector: '#t-toast',
|
||||
message: '选择图片失败',
|
||||
icon: 'error-circle',
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// 删除图片
|
||||
onDeleteImage(e) {
|
||||
const { index } = e.currentTarget.dataset;
|
||||
const { images } = this.data;
|
||||
images.splice(index, 1);
|
||||
this.setData({ images });
|
||||
},
|
||||
|
||||
// 预览图片
|
||||
onPreviewImage(e) {
|
||||
const { index } = e.currentTarget.dataset;
|
||||
const { images } = this.data;
|
||||
|
||||
wx.previewImage({
|
||||
current: images[index],
|
||||
urls: images
|
||||
});
|
||||
},
|
||||
|
||||
// 上传图片到服务器
|
||||
async uploadImages(images) {
|
||||
const uploadPromises = images.map(imagePath => {
|
||||
return new Promise((resolve, reject) => {
|
||||
wx.uploadFile({
|
||||
url: `${getApp().globalData.config.apiBaseUrl}/upload/image`,
|
||||
filePath: imagePath,
|
||||
name: 'file',
|
||||
header: {
|
||||
'Authorization': `Bearer ${wx.getStorageSync('token')}`
|
||||
},
|
||||
success: (res) => {
|
||||
try {
|
||||
const data = JSON.parse(res.data);
|
||||
if (data.code === 200) {
|
||||
resolve(data.data.url);
|
||||
} else {
|
||||
reject(new Error(data.message || '上传失败'));
|
||||
}
|
||||
} catch (e) {
|
||||
reject(new Error('解析上传结果失败'));
|
||||
}
|
||||
},
|
||||
fail: reject
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
return Promise.all(uploadPromises);
|
||||
},
|
||||
|
||||
// 提交评论
|
||||
async onSubmit() {
|
||||
const { orderItem, rating, content, images, isAnonymous, submitting } = this.data;
|
||||
|
||||
if (submitting) return;
|
||||
|
||||
if (!content.trim()) {
|
||||
Toast({
|
||||
context: this,
|
||||
selector: '#t-toast',
|
||||
message: '请输入评论内容',
|
||||
icon: 'error-circle',
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
this.setData({ submitting: true });
|
||||
|
||||
try {
|
||||
// 上传图片
|
||||
let uploadedImages = [];
|
||||
if (images.length > 0) {
|
||||
Toast({
|
||||
context: this,
|
||||
selector: '#t-toast',
|
||||
message: '正在上传图片...',
|
||||
icon: 'loading',
|
||||
});
|
||||
uploadedImages = await this.uploadImages(images);
|
||||
}
|
||||
|
||||
// 提交评论
|
||||
const commentData = {
|
||||
orderItemId: orderItem.id,
|
||||
productId: orderItem.product_id,
|
||||
rating,
|
||||
content: content.trim(),
|
||||
images: uploadedImages,
|
||||
isAnonymous
|
||||
};
|
||||
|
||||
await createComment(commentData);
|
||||
|
||||
Toast({
|
||||
context: this,
|
||||
selector: '#t-toast',
|
||||
message: '评论提交成功',
|
||||
icon: 'check-circle',
|
||||
});
|
||||
|
||||
// 设置上一页刷新标志
|
||||
const pages = getCurrentPages();
|
||||
const prevPage = pages[pages.length - 2]; // 上一页(订单详情页)
|
||||
if (prevPage) {
|
||||
prevPage.setData({ backRefresh: true });
|
||||
}
|
||||
|
||||
// 延迟返回上一页
|
||||
setTimeout(() => {
|
||||
wx.navigateBack({
|
||||
delta: 1
|
||||
});
|
||||
}, 1500);
|
||||
|
||||
} catch (error) {
|
||||
console.error('提交评论失败', error);
|
||||
Toast({
|
||||
context: this,
|
||||
selector: '#t-toast',
|
||||
message: error.message || '提交失败,请重试',
|
||||
icon: 'error-circle',
|
||||
});
|
||||
} finally {
|
||||
this.setData({ submitting: false });
|
||||
}
|
||||
},
|
||||
|
||||
// 返回上一页
|
||||
onBack() {
|
||||
wx.navigateBack();
|
||||
}
|
||||
});
|
||||
13
miniprogram/pages/order/comment/index.json
Normal file
13
miniprogram/pages/order/comment/index.json
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"usingComponents": {
|
||||
"t-navbar": "tdesign-miniprogram/navbar/navbar",
|
||||
"t-rate": "tdesign-miniprogram/rate/rate",
|
||||
"t-textarea": "tdesign-miniprogram/textarea/textarea",
|
||||
"t-icon": "tdesign-miniprogram/icon/icon",
|
||||
"t-switch": "tdesign-miniprogram/switch/switch",
|
||||
"t-button": "tdesign-miniprogram/button/button",
|
||||
"t-toast": "tdesign-miniprogram/toast/toast",
|
||||
"price": "/components/price/index"
|
||||
},
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
106
miniprogram/pages/order/comment/index.wxml
Normal file
106
miniprogram/pages/order/comment/index.wxml
Normal file
@@ -0,0 +1,106 @@
|
||||
<view class="comment-page">
|
||||
<!-- 导航栏 -->
|
||||
<t-navbar title="评价商品" left-arrow bind:left-click="onBack" />
|
||||
|
||||
<!-- 商品信息 -->
|
||||
<view class="product-info" wx:if="{{orderItem}}">
|
||||
<image class="product-image" src="{{orderItem.product.images[0] || '/assets/placeholder.png'}}" mode="aspectFill" />
|
||||
<view class="product-details">
|
||||
<view class="product-name">{{orderItem.product.name}}</view>
|
||||
<view class="product-spec" wx:if="{{orderItem.product_spec}}">{{orderItem.product_spec}}</view>
|
||||
<view class="product-price">
|
||||
<price price="{{orderItem.price}}" />
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 评分 -->
|
||||
<view class="rating-section">
|
||||
<view class="section-title">商品评分</view>
|
||||
<t-rate
|
||||
value="{{rating}}"
|
||||
size="60rpx"
|
||||
color="#ff6b35"
|
||||
bind:change="onRatingChange"
|
||||
allow-half="{{false}}"
|
||||
/>
|
||||
</view>
|
||||
|
||||
<!-- 评论内容 -->
|
||||
<view class="content-section">
|
||||
<view class="section-title">评价内容</view>
|
||||
<t-textarea
|
||||
value="{{content}}"
|
||||
placeholder="请输入您的评价内容..."
|
||||
maxlength="{{maxContentLength}}"
|
||||
indicator="{{true}}"
|
||||
autosize="{{true}}"
|
||||
bind:change="onContentInput"
|
||||
t-class="comment-textarea"
|
||||
/>
|
||||
</view>
|
||||
|
||||
<!-- 图片上传 -->
|
||||
<view class="images-section">
|
||||
<view class="section-title">上传图片(可选)</view>
|
||||
<view class="images-grid">
|
||||
<view
|
||||
class="image-item"
|
||||
wx:for="{{images}}"
|
||||
wx:key="index"
|
||||
bind:tap="onPreviewImage"
|
||||
data-index="{{index}}"
|
||||
>
|
||||
<image src="{{item}}" mode="aspectFill" class="uploaded-image" />
|
||||
<view
|
||||
class="delete-btn"
|
||||
bind:tap="onDeleteImage"
|
||||
data-index="{{index}}"
|
||||
catch:tap="true"
|
||||
>
|
||||
<t-icon name="close" size="24rpx" color="#fff" />
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view
|
||||
class="add-image-btn"
|
||||
wx:if="{{images.length < maxImages}}"
|
||||
bind:tap="onChooseImage"
|
||||
>
|
||||
<t-icon name="add" size="48rpx" color="#999" />
|
||||
<text class="add-text">添加图片</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="images-tip">最多可上传{{maxImages}}张图片</view>
|
||||
</view>
|
||||
|
||||
<!-- 匿名评论 -->
|
||||
<view class="anonymous-section">
|
||||
<view class="anonymous-item">
|
||||
<text class="anonymous-label">匿名评论</text>
|
||||
<t-switch
|
||||
value="{{isAnonymous}}"
|
||||
bind:change="onAnonymousChange"
|
||||
size="large"
|
||||
/>
|
||||
</view>
|
||||
<view class="anonymous-tip">开启后,您的用户名将不会显示</view>
|
||||
</view>
|
||||
|
||||
<!-- 提交按钮 -->
|
||||
<view class="submit-section">
|
||||
<t-button
|
||||
theme="primary"
|
||||
size="large"
|
||||
loading="{{submitting}}"
|
||||
disabled="{{submitting}}"
|
||||
bind:tap="onSubmit"
|
||||
t-class="submit-btn"
|
||||
>
|
||||
{{submitting ? '提交中...' : '提交评价'}}
|
||||
</t-button>
|
||||
</view>
|
||||
|
||||
<!-- Toast -->
|
||||
<t-toast id="t-toast" />
|
||||
</view>
|
||||
179
miniprogram/pages/order/comment/index.wxss
Normal file
179
miniprogram/pages/order/comment/index.wxss
Normal file
@@ -0,0 +1,179 @@
|
||||
.comment-page {
|
||||
background-color: #f5f5f5;
|
||||
min-height: 100vh;
|
||||
padding-bottom: 120rpx;
|
||||
}
|
||||
|
||||
/* 商品信息 */
|
||||
.product-info {
|
||||
background: #fff;
|
||||
padding: 32rpx;
|
||||
margin-bottom: 20rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.product-image {
|
||||
width: 120rpx;
|
||||
height: 120rpx;
|
||||
border-radius: 12rpx;
|
||||
margin-right: 24rpx;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.product-details {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.product-name {
|
||||
font-size: 32rpx;
|
||||
color: #333;
|
||||
font-weight: 500;
|
||||
margin-bottom: 8rpx;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.product-spec {
|
||||
font-size: 24rpx;
|
||||
color: #999;
|
||||
margin-bottom: 8rpx;
|
||||
}
|
||||
|
||||
.product-price {
|
||||
font-size: 28rpx;
|
||||
color: #ff6b35;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
/* 评分区域 */
|
||||
.rating-section {
|
||||
background: #fff;
|
||||
padding: 32rpx;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.section-title {
|
||||
font-size: 32rpx;
|
||||
color: #333;
|
||||
font-weight: 500;
|
||||
margin-bottom: 24rpx;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* 评论内容 */
|
||||
.content-section {
|
||||
background: #fff;
|
||||
padding: 32rpx;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.comment-textarea {
|
||||
margin-top: 16rpx;
|
||||
}
|
||||
|
||||
/* 图片上传 */
|
||||
.images-section {
|
||||
background: #fff;
|
||||
padding: 32rpx;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.images-grid {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 16rpx;
|
||||
margin-top: 16rpx;
|
||||
}
|
||||
|
||||
.image-item {
|
||||
position: relative;
|
||||
width: 160rpx;
|
||||
height: 160rpx;
|
||||
}
|
||||
|
||||
.uploaded-image {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
border-radius: 12rpx;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
.delete-btn {
|
||||
position: absolute;
|
||||
top: -8rpx;
|
||||
right: -8rpx;
|
||||
width: 32rpx;
|
||||
height: 32rpx;
|
||||
background: rgba(0, 0, 0, 0.6);
|
||||
border-radius: 50%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.add-image-btn {
|
||||
width: 160rpx;
|
||||
height: 160rpx;
|
||||
border: 2rpx dashed #ddd;
|
||||
border-radius: 12rpx;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: #fafafa;
|
||||
}
|
||||
|
||||
.add-text {
|
||||
font-size: 24rpx;
|
||||
color: #999;
|
||||
margin-top: 8rpx;
|
||||
}
|
||||
|
||||
.images-tip {
|
||||
font-size: 24rpx;
|
||||
color: #999;
|
||||
margin-top: 16rpx;
|
||||
}
|
||||
|
||||
/* 匿名评论 */
|
||||
.anonymous-section {
|
||||
background: #fff;
|
||||
padding: 32rpx;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.anonymous-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.anonymous-label {
|
||||
font-size: 32rpx;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.anonymous-tip {
|
||||
font-size: 24rpx;
|
||||
color: #999;
|
||||
margin-top: 16rpx;
|
||||
}
|
||||
|
||||
/* 提交按钮 */
|
||||
.submit-section {
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
background: #fff;
|
||||
padding: 24rpx 32rpx;
|
||||
border-top: 1rpx solid #eee;
|
||||
z-index: 100;
|
||||
}
|
||||
|
||||
.submit-btn {
|
||||
width: 100%;
|
||||
height: 88rpx;
|
||||
border-radius: 44rpx;
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
import Dialog from 'tdesign-miniprogram/dialog/index';
|
||||
import Toast from 'tdesign-miniprogram/toast/index';
|
||||
|
||||
import { cancelRights } from '../../after-service-detail/api';
|
||||
import { ServiceButtonTypes } from '../../config';
|
||||
|
||||
Component({
|
||||
properties: {
|
||||
service: {
|
||||
type: Object,
|
||||
observer(service) {
|
||||
const buttonsRight = service.buttons || service.buttonVOs || [];
|
||||
this.setData({
|
||||
buttons: {
|
||||
left: [],
|
||||
right: buttonsRight,
|
||||
},
|
||||
});
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
data: {
|
||||
service: {},
|
||||
buttons: {
|
||||
left: [],
|
||||
right: [],
|
||||
},
|
||||
},
|
||||
|
||||
methods: {
|
||||
// 点击【订单操作】按钮,根据按钮类型分发
|
||||
onServiceBtnTap(e) {
|
||||
const { type } = e.currentTarget.dataset;
|
||||
switch (type) {
|
||||
case ServiceButtonTypes.REVOKE:
|
||||
this.onConfirm(this.data.service);
|
||||
break;
|
||||
case ServiceButtonTypes.FILL_TRACKING_NO:
|
||||
this.onFillTrackingNo(this.data.service);
|
||||
break;
|
||||
case ServiceButtonTypes.CHANGE_TRACKING_NO:
|
||||
this.onChangeTrackingNo(this.data.service);
|
||||
break;
|
||||
case ServiceButtonTypes.VIEW_DELIVERY:
|
||||
this.viewDelivery(this.data.service);
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
||||
onFillTrackingNo(service) {
|
||||
wx.navigateTo({
|
||||
url: `/pages/order/fill-tracking-no/index?rightsNo=${service.id}`,
|
||||
});
|
||||
},
|
||||
|
||||
viewDelivery(service) {
|
||||
wx.navigateTo({
|
||||
url: `/pages/order/delivery-detail/index?data=${JSON.stringify(
|
||||
service.logistics || service.logisticsVO,
|
||||
)}&source=2`,
|
||||
});
|
||||
},
|
||||
|
||||
onChangeTrackingNo(service) {
|
||||
wx.navigateTo({
|
||||
url: `/pages/order/fill-tracking-no/index?rightsNo=${
|
||||
service.id
|
||||
}&logisticsNo=${service.logisticsNo}&logisticsCompanyName=${
|
||||
service.logisticsCompanyName
|
||||
}&logisticsCompanyCode=${service.logisticsCompanyCode}&remark=${
|
||||
service.remark || ''
|
||||
}`,
|
||||
});
|
||||
},
|
||||
|
||||
onConfirm() {
|
||||
Dialog.confirm({
|
||||
title: '是否撤销退货申请?',
|
||||
content: '',
|
||||
confirmBtn: '撤销申请',
|
||||
cancelBtn: '不撤销',
|
||||
}).then(() => {
|
||||
const params = { rightsNo: this.data.service.id };
|
||||
return cancelRights(params).then(() => {
|
||||
Toast({
|
||||
context: this,
|
||||
selector: '#t-toast',
|
||||
message: '你确认撤销申请',
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {
|
||||
"t-button": "tdesign-miniprogram/button/button"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<view class="btn-bar">
|
||||
<view class="left">
|
||||
<t-button
|
||||
wx:for="{{buttons.left}}"
|
||||
wx:key="type"
|
||||
wx:for-item="leftBtn"
|
||||
size="extra-small"
|
||||
shape="round"
|
||||
t-class="order-btn delete-btn"
|
||||
catchtap="onServiceBtnTap"
|
||||
data-type="{{leftBtn.type}}"
|
||||
>
|
||||
{{leftBtn.name}}
|
||||
</t-button>
|
||||
</view>
|
||||
<view class="right">
|
||||
<t-button
|
||||
wx:for="{{buttons.right}}"
|
||||
wx:key="type"
|
||||
wx:for-item="rightBtn"
|
||||
size="extra-small"
|
||||
variant="{{ rightBtn.primary ? 'base' : 'outline'}}"
|
||||
shape="round"
|
||||
t-class="order-btn {{rightBtn.primary ? 'primary' : 'normal'}}"
|
||||
catchtap="onServiceBtnTap"
|
||||
data-type="{{rightBtn.type}}"
|
||||
open-type="{{ rightBtn.openType }}"
|
||||
data-share="{{ rightBtn.dataShare }}"
|
||||
>
|
||||
{{rightBtn.name}}
|
||||
</t-button>
|
||||
</view>
|
||||
</view>
|
||||
@@ -0,0 +1,43 @@
|
||||
:host {
|
||||
width: 100%;
|
||||
}
|
||||
.btn-bar {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
line-height: 1;
|
||||
}
|
||||
.btn-bar .order-btn {
|
||||
background-color: inherit;
|
||||
font-size: 26rpx;
|
||||
padding: 16rpx 28rpx;
|
||||
line-height: 1;
|
||||
border-radius: unset;
|
||||
min-width: 160rpx;
|
||||
border-radius: 32rpx;
|
||||
height: 60rpx;
|
||||
margin-right: 10rpx;
|
||||
}
|
||||
|
||||
.btn-bar .left .order-btn:not(:first-child),
|
||||
.btn-bar .right .order-btn:not(:first-child) {
|
||||
margin-left: 20rpx;
|
||||
}
|
||||
.btn-bar .left .delete-btn {
|
||||
font-size: 22rpx;
|
||||
}
|
||||
.btn-bar .left .delete-btn::after {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.btn-bar .right .normal {
|
||||
--td-button-default-color: #333333;
|
||||
--td-button-default-border-color: #dddddd;
|
||||
}
|
||||
|
||||
.btn-bar .right .primary {
|
||||
--td-button-default-color: #fff;
|
||||
--td-button-default-bg-color: #fa4126;
|
||||
--td-button-default-border-color: #fa4126;
|
||||
--td-button-default-active-bg-color: #fa42269c;
|
||||
}
|
||||
38
miniprogram/pages/order/components/customer-service/index.js
Normal file
38
miniprogram/pages/order/components/customer-service/index.js
Normal file
@@ -0,0 +1,38 @@
|
||||
Component({
|
||||
externalClasses: ['wr-class'],
|
||||
|
||||
properties: {
|
||||
phoneNumber: String,
|
||||
desc: String,
|
||||
},
|
||||
|
||||
data: {
|
||||
show: false,
|
||||
},
|
||||
|
||||
methods: {
|
||||
onBtnTap() {
|
||||
this.setData({
|
||||
show: true,
|
||||
});
|
||||
},
|
||||
|
||||
onDialogClose() {
|
||||
this.setData({
|
||||
show: false,
|
||||
});
|
||||
},
|
||||
|
||||
onCall() {
|
||||
const { phoneNumber } = this.properties;
|
||||
wx.makePhoneCall({
|
||||
phoneNumber,
|
||||
});
|
||||
},
|
||||
onCallOnlineService() {
|
||||
wx.showToast({
|
||||
title: '你点击了在线客服',
|
||||
});
|
||||
},
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {
|
||||
"t-popup": "tdesign-miniprogram/popup/popup"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<!-- 联系客服按钮 -->
|
||||
<view class="wr-class customer-service text-btn" hover-class="text-btn--active" bindtap="onBtnTap">联系客服</view>
|
||||
<!-- 联系客服弹框 -->
|
||||
<t-popup visible="{{show}}" placement="bottom" bind:visible-change="onDialogClose">
|
||||
<view class="dialog--customer-service">
|
||||
<view class="content" wx:if="{{desc}}">
|
||||
<view class="title">服务时间:</view>
|
||||
<text class="subtitle">{{desc}}</text>
|
||||
</view>
|
||||
<view class="options">
|
||||
<view
|
||||
class="option main"
|
||||
hover-class="text-btn--active"
|
||||
wx:if="{{phoneNumber}}"
|
||||
bindtap="onCall"
|
||||
>呼叫 {{phoneNumber}}
|
||||
</view>
|
||||
<view class="option main online" hover-class="text-btn--active" bindtap="onCallOnlineService">在线客服</view>
|
||||
<view class="option" hover-class="text-btn--active" bindtap="onDialogClose">取消</view>
|
||||
</view>
|
||||
</view>
|
||||
</t-popup>
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
.text-btn {
|
||||
display: inline;
|
||||
color: #333;
|
||||
font-size: 24rpx;
|
||||
}
|
||||
.text-btn--active {
|
||||
opacity: 0.5;
|
||||
}
|
||||
.dialog--customer-service {
|
||||
background-color: #f3f4f5;
|
||||
overflow: hidden;
|
||||
}
|
||||
.dialog--customer-service .content {
|
||||
font-size: 26rpx;
|
||||
margin: 32rpx 30rpx;
|
||||
text-align: center;
|
||||
}
|
||||
.dialog--customer-service .content .title {
|
||||
display: inline;
|
||||
color: #999999;
|
||||
font-weight: bold;
|
||||
}
|
||||
.dialog--customer-service .content .subtitle {
|
||||
display: inline;
|
||||
color: #999999;
|
||||
}
|
||||
.dialog--customer-service .options .option {
|
||||
color: #333333;
|
||||
font-size: 30rpx;
|
||||
text-align: center;
|
||||
height: 100rpx;
|
||||
line-height: 100rpx;
|
||||
background-color: white;
|
||||
}
|
||||
.dialog--customer-service .options .option:not(:last-child) {
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
.dialog--customer-service .options .option--active {
|
||||
opacity: 0.5;
|
||||
}
|
||||
.dialog--customer-service .options .option.main {
|
||||
color: #333;
|
||||
}
|
||||
.dialog--customer-service .options .option.online {
|
||||
position: relative;
|
||||
top: -17rpx;
|
||||
margin-bottom: 2rpx;
|
||||
}
|
||||
269
miniprogram/pages/order/components/goods-card/index.js
Normal file
269
miniprogram/pages/order/components/goods-card/index.js
Normal file
@@ -0,0 +1,269 @@
|
||||
Component({
|
||||
options: {
|
||||
multipleSlots: true, // 在组件定义时的选项中启用多slot支持
|
||||
addGlobalClass: true,
|
||||
},
|
||||
intersectionObserverContext: null,
|
||||
|
||||
externalClasses: [
|
||||
'card-class',
|
||||
'title-class',
|
||||
'desc-class',
|
||||
'num-class',
|
||||
'thumb-class',
|
||||
'specs-class',
|
||||
'price-class',
|
||||
'origin-price-class',
|
||||
'price-prefix-class',
|
||||
],
|
||||
|
||||
relations: {
|
||||
'../order-card/index': {
|
||||
type: 'ancestor',
|
||||
linked(target) {
|
||||
this.parent = target;
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
properties: {
|
||||
hidden: {
|
||||
// 设置为null代表不做类型转换
|
||||
type: null,
|
||||
value: false,
|
||||
observer(hidden) {
|
||||
// null就是代表没有设置,没有设置的话不setData,防止祖先组件触发的setHidden操作被覆盖
|
||||
if (hidden !== null) {
|
||||
this.setHidden(!!hidden);
|
||||
}
|
||||
},
|
||||
},
|
||||
id: {
|
||||
type: String,
|
||||
// `goods-card-88888888`
|
||||
// 不能在这里写生成逻辑,如果在这里写,那么假设有多个goods-list时,他们将共享这个值
|
||||
value: '',
|
||||
observer: (id) => {
|
||||
this.genIndependentID(id);
|
||||
if (this.properties.thresholds?.length) {
|
||||
this.createIntersectionObserverHandle();
|
||||
}
|
||||
},
|
||||
},
|
||||
data: {
|
||||
type: Object,
|
||||
observer(goods) {
|
||||
// 有ID的商品才渲染
|
||||
if (!goods) {
|
||||
return;
|
||||
}
|
||||
|
||||
/** 划线价是否有效 */
|
||||
let isValidityLinePrice = true;
|
||||
// 判断一次划线价格是否合理
|
||||
if (
|
||||
goods.originPrice &&
|
||||
goods.price &&
|
||||
goods.originPrice < goods.price
|
||||
) {
|
||||
isValidityLinePrice = false;
|
||||
}
|
||||
|
||||
// 敲定换行数量默认值
|
||||
if (goods.lineClamp === undefined || goods.lineClamp <= 0) {
|
||||
// tag数组长度 大于0 且 可见
|
||||
// 指定换行为1行
|
||||
if ((goods.tags?.length || 0) > 0 && !goods.hideKey?.tags) {
|
||||
goods.lineClamp = 1;
|
||||
} else {
|
||||
goods.lineClamp = 2;
|
||||
}
|
||||
}
|
||||
|
||||
this.setData({ goods, isValidityLinePrice });
|
||||
},
|
||||
},
|
||||
layout: {
|
||||
type: String,
|
||||
value: 'horizontal',
|
||||
},
|
||||
thumbMode: {
|
||||
type: String,
|
||||
value: 'aspectFill',
|
||||
},
|
||||
thumbWidth: Number,
|
||||
thumbHeight: Number,
|
||||
priceFill: {
|
||||
type: Boolean,
|
||||
value: true,
|
||||
},
|
||||
currency: {
|
||||
type: String,
|
||||
value: '¥',
|
||||
},
|
||||
lazyLoad: {
|
||||
type: Boolean,
|
||||
value: false,
|
||||
},
|
||||
centered: {
|
||||
type: Boolean,
|
||||
value: false,
|
||||
},
|
||||
showCart: {
|
||||
type: Boolean,
|
||||
value: false,
|
||||
},
|
||||
pricePrefix: {
|
||||
type: String,
|
||||
value: '',
|
||||
},
|
||||
cartSize: {
|
||||
type: Number,
|
||||
value: 48,
|
||||
},
|
||||
cartColor: {
|
||||
type: String,
|
||||
value: '#FA550F',
|
||||
},
|
||||
/** 元素可见监控阈值, 数组长度大于0就创建 */
|
||||
thresholds: {
|
||||
type: Array,
|
||||
value: [],
|
||||
observer(current) {
|
||||
if (current && current.length) {
|
||||
this.createIntersectionObserverHandle();
|
||||
} else {
|
||||
this.clearIntersectionObserverHandle();
|
||||
}
|
||||
},
|
||||
},
|
||||
specsIconClassPrefix: {
|
||||
type: String,
|
||||
value: 'wr',
|
||||
},
|
||||
specsIcon: {
|
||||
type: String,
|
||||
value: 'expand_more',
|
||||
},
|
||||
addCartIconClassPrefix: {
|
||||
type: String,
|
||||
value: 'wr',
|
||||
},
|
||||
addCartIcon: {
|
||||
type: String,
|
||||
value: 'cart',
|
||||
},
|
||||
},
|
||||
|
||||
data: {
|
||||
hiddenInData: false,
|
||||
independentID: '',
|
||||
goods: { id: '' },
|
||||
/** 保证划线价格不小于原价,否则不渲染划线价 */
|
||||
isValidityLinePrice: false,
|
||||
},
|
||||
|
||||
lifetimes: {
|
||||
ready() {
|
||||
this.init();
|
||||
},
|
||||
detached() {
|
||||
this.clear();
|
||||
},
|
||||
},
|
||||
|
||||
methods: {
|
||||
clickHandle() {
|
||||
this.triggerEvent('click', { goods: this.data.goods });
|
||||
},
|
||||
clickThumbHandle() {
|
||||
this.triggerEvent('thumb', { goods: this.data.goods });
|
||||
},
|
||||
clickTagHandle(evt) {
|
||||
const { index } = evt.currentTarget.dataset;
|
||||
this.triggerEvent('tag', { goods: this.data.goods, index });
|
||||
},
|
||||
// 加入购物车
|
||||
addCartHandle(e) {
|
||||
const { id } = e.currentTarget;
|
||||
const { id: cardID } = e.currentTarget.dataset;
|
||||
this.triggerEvent('add-cart', {
|
||||
...e.detail,
|
||||
id,
|
||||
cardID,
|
||||
goods: this.data.goods,
|
||||
});
|
||||
},
|
||||
|
||||
handleImageError(e) {
|
||||
console.warn('订单商品卡片图片加载失败:', e.detail);
|
||||
// 可以在这里设置默认图片或其他错误处理逻辑
|
||||
},
|
||||
genIndependentID(id, cb) {
|
||||
let independentID;
|
||||
if (id) {
|
||||
independentID = id;
|
||||
} else {
|
||||
// `goods-card-88888888`
|
||||
independentID = `goods-card-${~~(Math.random() * 10 ** 8)}`;
|
||||
}
|
||||
this.setData({ independentID }, cb);
|
||||
},
|
||||
|
||||
init() {
|
||||
const { thresholds, id, hidden } = this.properties;
|
||||
if (hidden !== null) {
|
||||
this.setHidden(!!hidden);
|
||||
}
|
||||
|
||||
this.genIndependentID(id || '', () => {
|
||||
if (thresholds && thresholds.length) {
|
||||
this.createIntersectionObserverHandle();
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
clear() {
|
||||
this.clearIntersectionObserverHandle();
|
||||
},
|
||||
|
||||
setHidden(hidden) {
|
||||
this.setData({ hiddenInData: !!hidden });
|
||||
},
|
||||
|
||||
createIntersectionObserverHandle() {
|
||||
if (this.intersectionObserverContext || !this.data.independentID) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.intersectionObserverContext = wx
|
||||
.createIntersectionObserver(this, {
|
||||
thresholds: this.properties.thresholds,
|
||||
})
|
||||
.relativeToViewport();
|
||||
|
||||
this.intersectionObserverContext.observe(
|
||||
`#${this.data.independentID}`,
|
||||
(res) => {
|
||||
this.intersectionObserverCB(res);
|
||||
},
|
||||
);
|
||||
},
|
||||
intersectionObserverCB(ob) {
|
||||
this.triggerEvent('ob', {
|
||||
goods: this.data.goods,
|
||||
context: this.intersectionObserverContext,
|
||||
ob,
|
||||
});
|
||||
},
|
||||
clearIntersectionObserverHandle() {
|
||||
if (this.intersectionObserverContext) {
|
||||
try {
|
||||
this.intersectionObserverContext.disconnect();
|
||||
} catch (e) {}
|
||||
|
||||
this.intersectionObserverContext = null;
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
8
miniprogram/pages/order/components/goods-card/index.json
Normal file
8
miniprogram/pages/order/components/goods-card/index.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {
|
||||
"price": "/components/price/index",
|
||||
"t-image": "/components/webp-image/index",
|
||||
"t-icon": "tdesign-miniprogram/icon/icon"
|
||||
}
|
||||
}
|
||||
80
miniprogram/pages/order/components/goods-card/index.wxml
Normal file
80
miniprogram/pages/order/components/goods-card/index.wxml
Normal file
@@ -0,0 +1,80 @@
|
||||
<view
|
||||
id="{{independentID}}"
|
||||
class="wr-goods-card card-class {{ layout }} {{ centered ? 'center' : ''}}"
|
||||
bind:tap="clickHandle"
|
||||
data-goods="{{ goods }}"
|
||||
hidden="{{hiddenInData}}"
|
||||
>
|
||||
<view class="wr-goods-card__main">
|
||||
<view class="wr-goods-card__thumb thumb-class" bind:tap="clickThumbHandle">
|
||||
<!-- data-src 是方便加购动画读取图片用的 -->
|
||||
<t-image
|
||||
t-class="wr-goods-card__thumb-com"
|
||||
wx:if="{{ !!goods.thumb && !goods.hideKey.thumb }}"
|
||||
src="{{ goods.thumb }}"
|
||||
mode="{{ thumbMode }}"
|
||||
lazy-load="{{ lazyLoad }}"
|
||||
bind:error="handleImageError"
|
||||
/>
|
||||
<slot name="thumb-cover" />
|
||||
</view>
|
||||
|
||||
<view class="wr-goods-card__body">
|
||||
<view class="wr-goods-card__long_content">
|
||||
<view wx:if="{{ goods.title && !goods.hideKey.title }}" class="wr-goods-card__title title-class" style="-webkit-line-clamp: {{ goods.lineClamp }};">
|
||||
<slot name="before-title" />
|
||||
{{ goods.title }}
|
||||
</view>
|
||||
<slot name="after-title" />
|
||||
<view wx:if="{{ goods.desc && !goods.hideKey.desc }}" class="wr-goods-card__desc desc-class">{{ goods.desc }}</view>
|
||||
<slot name="after-desc" />
|
||||
<view wx:if="{{ goods.specs && goods.specs.length > 0 && !goods.hideKey.specs }}" class="wr-goods-card__specs__desc specs-class" bind:tap="clickSpecsHandle">
|
||||
<view class="wr-goods-card__specs__desc-text">{{ goods.specs }}</view>
|
||||
</view>
|
||||
<view class="goods_tips" wx:if="{{goods.stockQuantity !== 0 && goods.quantity >= goods.stockQuantity}}">库存不足</view>
|
||||
</view>
|
||||
|
||||
<view class="wr-goods-card__short_content">
|
||||
<block wx:if="{{goods.stockQuantity !== 0}}">
|
||||
<view wx:if="{{ pricePrefix }}" class="wr-goods-card__price__prefix price-prefix-class">{{ pricePrefix }}</view>
|
||||
<slot name="price-prefix" />
|
||||
<view wx:if="{{ goods.price && !goods.hideKey.price }}" class="wr-goods-card__price">
|
||||
<price
|
||||
wr-class="price-class"
|
||||
symbol="{{currency}}"
|
||||
price="{{goods.price}}"
|
||||
priceUnit="yuan"
|
||||
fill="{{priceFill}}"
|
||||
decimalSmaller
|
||||
/>
|
||||
</view>
|
||||
<view wx:if="{{ goods.originPrice && !goods.hideKey.originPrice && isValidityLinePrice }}" class="wr-goods-card__origin-price">
|
||||
<price
|
||||
wr-class="origin-price-class"
|
||||
symbol="{{currency}}"
|
||||
price="{{goods.originPrice}}"
|
||||
priceUnit="yuan"
|
||||
fill="{{priceFill}}"
|
||||
/>
|
||||
</view>
|
||||
<slot name="origin-price" />
|
||||
<view wx:if="{{goods.num && !goods.hideKey.num}}" class="wr-goods-card__num num-class">
|
||||
<text class="wr-goods-card__num__prefix">x </text>
|
||||
{{ goods.num }}
|
||||
</view>
|
||||
</block>
|
||||
<block wx:else>
|
||||
<view class="no_storage">
|
||||
<view>请重新选择商品规格</view>
|
||||
<view class="no_storage__right">重选</view>
|
||||
</view>
|
||||
</block>
|
||||
|
||||
</view>
|
||||
<slot name="append-body" />
|
||||
</view>
|
||||
<slot name="footer" />
|
||||
</view>
|
||||
<slot name="append-card" />
|
||||
</view>
|
||||
|
||||
254
miniprogram/pages/order/components/goods-card/index.wxss
Normal file
254
miniprogram/pages/order/components/goods-card/index.wxss
Normal file
@@ -0,0 +1,254 @@
|
||||
.wr-goods-card {
|
||||
box-sizing: border-box;
|
||||
font-size: 24rpx;
|
||||
}
|
||||
.wr-goods-card__main {
|
||||
position: relative;
|
||||
display: flex;
|
||||
line-height: 1;
|
||||
flex-direction: row;
|
||||
background: transparent;
|
||||
padding: 16rpx 0rpx;
|
||||
}
|
||||
.wr-goods-card.center .wr-goods-card__main {
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
.wr-goods-card__thumb {
|
||||
flex-shrink: 0;
|
||||
position: relative;
|
||||
width: 176rpx;
|
||||
height: 176rpx;
|
||||
}
|
||||
.wr-goods-card__thumb-com {
|
||||
width: 176rpx;
|
||||
height: 176rpx;
|
||||
border-radius: 8rpx;
|
||||
overflow: hidden;
|
||||
}
|
||||
.wr-goods-card__thumb:empty {
|
||||
display: none;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.wr-goods-card__body {
|
||||
display: flex;
|
||||
margin: 0 0 0 16rpx;
|
||||
flex-direction: row;
|
||||
flex: 1 1 auto;
|
||||
min-height: 176rpx;
|
||||
}
|
||||
.wr-goods-card__long_content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
flex: 1 1 auto;
|
||||
}
|
||||
.wr-goods-card__long_content .goods_tips {
|
||||
width: 100%;
|
||||
margin-top: 16rpx;
|
||||
text-align: right;
|
||||
color: #fa4126;
|
||||
font-size: 24rpx;
|
||||
line-height: 32rpx;
|
||||
font-weight: bold;
|
||||
}
|
||||
.wr-goods-card__title {
|
||||
flex-shrink: 0;
|
||||
font-size: 28rpx;
|
||||
color: #333;
|
||||
line-height: 40rpx;
|
||||
font-weight: 400;
|
||||
display: -webkit-box;
|
||||
-webkit-box-orient: vertical;
|
||||
overflow: hidden;
|
||||
word-break: break-word;
|
||||
}
|
||||
.wr-goods-card__title__prefix-tags {
|
||||
display: inline-flex;
|
||||
}
|
||||
.wr-goods-card__title__prefix-tags .prefix-tag {
|
||||
margin: 0 8rpx 0 0;
|
||||
}
|
||||
.wr-goods-card__desc {
|
||||
font-size: 24rpx;
|
||||
color: #f5f5f5;
|
||||
line-height: 40rpx;
|
||||
display: -webkit-box;
|
||||
-webkit-box-orient: vertical;
|
||||
-webkit-line-clamp: 2;
|
||||
overflow: hidden;
|
||||
}
|
||||
.wr-goods-card__specs__desc,
|
||||
.wr-goods-card__specs__text {
|
||||
font-size: 24rpx;
|
||||
height: 32rpx;
|
||||
line-height: 32rpx;
|
||||
color: #999999;
|
||||
margin: 8rpx 0;
|
||||
}
|
||||
.wr-goods-card__specs__desc {
|
||||
display: flex;
|
||||
align-self: flex-start;
|
||||
flex-direction: row;
|
||||
}
|
||||
.wr-goods-card__specs__desc-text {
|
||||
height: 100%;
|
||||
max-width: 380rpx;
|
||||
word-break: break-all;
|
||||
overflow: hidden;
|
||||
display: -webkit-box;
|
||||
-webkit-box-orient: vertical;
|
||||
-webkit-line-clamp: 1;
|
||||
}
|
||||
.wr-goods-card__specs__desc-icon {
|
||||
line-height: inherit;
|
||||
margin-left: 8rpx;
|
||||
font-size: 24rpx;
|
||||
color: #bbb;
|
||||
}
|
||||
.wr-goods-card__specs__text {
|
||||
display: -webkit-box;
|
||||
-webkit-box-orient: vertical;
|
||||
-webkit-line-clamp: 1;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
word-break: break-all;
|
||||
}
|
||||
.wr-goods-card__tags {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
flex-wrap: wrap;
|
||||
margin: 16rpx 0 0 0;
|
||||
}
|
||||
.wr-goods-card__tag {
|
||||
color: #fa550f;
|
||||
background: transparent;
|
||||
font-size: 20rpx;
|
||||
border: 1rpx solid #fa550f;
|
||||
padding: 0 8rpx;
|
||||
height: 30rpx;
|
||||
line-height: 30rpx;
|
||||
margin: 0 8rpx 8rpx 0;
|
||||
display: block;
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
word-break: keep-all;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
.wr-goods-card__short_content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: flex-start;
|
||||
align-items: flex-end;
|
||||
margin: 0 0 0 46rpx;
|
||||
}
|
||||
.wr-goods-card__price__prefix {
|
||||
order: 0;
|
||||
color: #666;
|
||||
margin: 0;
|
||||
}
|
||||
.wr-goods-card__price {
|
||||
white-space: nowrap;
|
||||
font-weight: bold;
|
||||
order: 1;
|
||||
color: #fa4126;
|
||||
font-size: 36rpx;
|
||||
margin: 0;
|
||||
line-height: 48rpx;
|
||||
}
|
||||
.wr-goods-card__origin-price {
|
||||
white-space: nowrap;
|
||||
font-weight: normal;
|
||||
order: 2;
|
||||
color: #aaaaaa;
|
||||
font-size: 24rpx;
|
||||
margin: 0;
|
||||
}
|
||||
.wr-goods-card__num {
|
||||
white-space: nowrap;
|
||||
order: 4;
|
||||
font-size: 24rpx;
|
||||
color: #999;
|
||||
margin: 20rpx 0 0 auto;
|
||||
}
|
||||
.wr-goods-card__num__prefix {
|
||||
color: inherit;
|
||||
}
|
||||
.wr-goods-card__add-cart {
|
||||
order: 3;
|
||||
margin: auto 0 0 auto;
|
||||
}
|
||||
.wr-goods-card.horizontal-wrap .wr-goods-card__thumb {
|
||||
width: 192rpx;
|
||||
height: 192rpx;
|
||||
border-radius: 8rpx;
|
||||
overflow: hidden;
|
||||
}
|
||||
.wr-goods-card.horizontal-wrap .wr-goods-card__body {
|
||||
flex-direction: column;
|
||||
}
|
||||
.wr-goods-card.horizontal-wrap .wr-goods-card__short_content {
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
margin: 16rpx 0 0 0;
|
||||
}
|
||||
|
||||
.wr-goods-card.horizontal-wrap .wr-goods-card__num {
|
||||
margin: 0 0 0 auto;
|
||||
}
|
||||
.wr-goods-card.vertical .wr-goods-card__main {
|
||||
padding: 0 0 22rpx 0;
|
||||
flex-direction: column;
|
||||
}
|
||||
.wr-goods-card.vertical .wr-goods-card__thumb {
|
||||
width: 340rpx;
|
||||
height: 340rpx;
|
||||
}
|
||||
.wr-goods-card.vertical .wr-goods-card__body {
|
||||
margin: 20rpx 20rpx 0 20rpx;
|
||||
flex-direction: column;
|
||||
}
|
||||
.wr-goods-card.vertical .wr-goods-card__long_content {
|
||||
overflow: hidden;
|
||||
}
|
||||
.wr-goods-card.vertical .wr-goods-card__title {
|
||||
line-height: 36rpx;
|
||||
}
|
||||
.wr-goods-card.vertical .wr-goods-card__short_content {
|
||||
margin: 20rpx 0 0 0;
|
||||
}
|
||||
.wr-goods-card.vertical .wr-goods-card__price {
|
||||
order: 2;
|
||||
color: #fa4126;
|
||||
margin: 20rpx 0 0 0;
|
||||
}
|
||||
.wr-goods-card.vertical .wr-goods-card__origin-price {
|
||||
order: 1;
|
||||
}
|
||||
.wr-goods-card.vertical .wr-goods-card__add-cart {
|
||||
position: absolute;
|
||||
bottom: 20rpx;
|
||||
right: 20rpx;
|
||||
}
|
||||
|
||||
.wr-goods-card__short_content .no_storage {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
height: 40rpx;
|
||||
color: #333;
|
||||
font-size: 24rpx;
|
||||
line-height: 32rpx;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.no_storage .no_storage__right {
|
||||
width: 80rpx;
|
||||
height: 40rpx;
|
||||
border-radius: 20rpx;
|
||||
border: 2rpx solid #fa4126;
|
||||
line-height: 40rpx;
|
||||
text-align: center;
|
||||
color: #fa4126;
|
||||
}
|
||||
17
miniprogram/pages/order/components/noGoods/noGood.wxs
Normal file
17
miniprogram/pages/order/components/noGoods/noGood.wxs
Normal file
@@ -0,0 +1,17 @@
|
||||
var isOnlyBack = function (data) {
|
||||
return data.limitGoodsList || (data.inValidGoodsList && !data.storeGoodsList);
|
||||
};
|
||||
|
||||
var isShowChangeAddress = function (data) {
|
||||
return data.abnormalDeliveryGoodsList;
|
||||
};
|
||||
|
||||
var isShowKeepPay = function (data) {
|
||||
return data.outOfStockGoodsList || (data.storeGoodsList && data.inValidGoodsList);
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
isOnlyBack: isOnlyBack,
|
||||
isShowChangeAddress: isShowChangeAddress,
|
||||
isShowKeepPay: isShowKeepPay,
|
||||
};
|
||||
57
miniprogram/pages/order/components/noGoods/noGoods.js
Normal file
57
miniprogram/pages/order/components/noGoods/noGoods.js
Normal file
@@ -0,0 +1,57 @@
|
||||
Component({
|
||||
properties: {
|
||||
settleDetailData: {
|
||||
type: Object,
|
||||
value: {},
|
||||
observer(settleDetailData) {
|
||||
const {
|
||||
outOfStockGoodsList,
|
||||
abnormalDeliveryGoodsList,
|
||||
inValidGoodsList,
|
||||
limitGoodsList,
|
||||
} = settleDetailData;
|
||||
// 弹窗逻辑 限购 超出配送范围 失效 库存不足;
|
||||
const tempList =
|
||||
limitGoodsList ||
|
||||
abnormalDeliveryGoodsList ||
|
||||
inValidGoodsList ||
|
||||
outOfStockGoodsList ||
|
||||
[];
|
||||
|
||||
tempList.forEach((goods, index) => {
|
||||
goods.id = index;
|
||||
goods.unSettlementGoods &&
|
||||
goods.unSettlementGoods.forEach((ele) => {
|
||||
ele.name = ele.goodsName;
|
||||
ele.price = ele.payPrice;
|
||||
ele.imgUrl = ele.image;
|
||||
});
|
||||
});
|
||||
this.setData({
|
||||
// settleDetailData,
|
||||
goodsList: tempList,
|
||||
});
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
data: {
|
||||
goodList: [],
|
||||
},
|
||||
methods: {
|
||||
onCard(e) {
|
||||
const { item } = e.currentTarget.dataset;
|
||||
if (item === 'cart') {
|
||||
// 购物车
|
||||
Navigator.gotoPage('/cart');
|
||||
} else if (item === 'orderSure') {
|
||||
// 结算页
|
||||
this.triggerEvent('change', undefined);
|
||||
}
|
||||
},
|
||||
onDelive() {
|
||||
// 修改配送地址
|
||||
Navigator.gotoPage('/address', { type: 'orderSure' });
|
||||
},
|
||||
},
|
||||
});
|
||||
8
miniprogram/pages/order/components/noGoods/noGoods.json
Normal file
8
miniprogram/pages/order/components/noGoods/noGoods.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {
|
||||
"wr-order-card": "/pages/order/components/order-card/index",
|
||||
"wr-goods-card": "/components/goods-card/index",
|
||||
"wr-order-goods-card": "/pages/order/components/order-goods-card/index"
|
||||
}
|
||||
}
|
||||
53
miniprogram/pages/order/components/noGoods/noGoods.wxml
Normal file
53
miniprogram/pages/order/components/noGoods/noGoods.wxml
Normal file
@@ -0,0 +1,53 @@
|
||||
<wxs src="./noGood.wxs" module="order" />
|
||||
|
||||
<view class="goods-fail">
|
||||
<block wx:if="{{settleDetailData.limitGoodsList && settleDetailData.limitGoodsList.length >0}}">
|
||||
<view class="title">限购商品信息</view>
|
||||
<view class="info">以下商品限购数量,建议您修改商品数量</view>
|
||||
</block>
|
||||
<block
|
||||
wx:elif="{{settleDetailData.abnormalDeliveryGoodsList && settleDetailData.abnormalDeliveryGoodsList.length >0}}"
|
||||
>
|
||||
<view class="title">不支持配送</view>
|
||||
<view class="info">以下店铺的商品不支持配送,请更改地址或去掉对应店铺商品再进行结算</view>
|
||||
</block>
|
||||
<block wx:elif="{{order.isShowKeepPay(settleDetailData)}}">
|
||||
<view class="title">部分商品库存不足或失效</view>
|
||||
<view class="info">请返回购物车重新选择商品,如果继续结算将自动忽略库存不足或失效的商品。</view>
|
||||
</block>
|
||||
<block wx:elif="{{settleDetailData.inValidGoodsList && settleDetailData.inValidGoodsList.length > 0}}">
|
||||
<view class="title">全部商品库存不足或失效</view>
|
||||
<view class="info">请返回购物车重新选择商品</view>
|
||||
</block>
|
||||
<scroll-view
|
||||
scroll-y="true"
|
||||
style="max-height: 500rpx"
|
||||
bindscrolltoupper="upper"
|
||||
bindscrolltolower="lower"
|
||||
bindscroll="scroll"
|
||||
>
|
||||
<view class="goods-list" wx:for="{{goodsList}}" wx:for-item="goods" wx:key="index">
|
||||
<wr-order-card wx:if="{{goods}}" order="{{goods}}">
|
||||
<wr-order-goods-card
|
||||
wx:for="{{goods.unSettlementGoods}}"
|
||||
wx:key="id"
|
||||
wx:for-item="goods"
|
||||
wx:for-index="gIndex"
|
||||
goods="{{goods}}"
|
||||
no-top-line="{{gIndex === 0}}"
|
||||
/>
|
||||
</wr-order-card>
|
||||
</view>
|
||||
</scroll-view>
|
||||
<view class="goods-fail-btn">
|
||||
<view bindtap="onCard" data-item="cart" class="btn {{order.isOnlyBack(settleDetailData) ? 'limit' : ''}}">
|
||||
返回购物车
|
||||
</view>
|
||||
<view wx:if="{{order.isShowChangeAddress(settleDetailData)}}" bindtap="onDelive" class="btn origin">
|
||||
修改配送地址
|
||||
</view>
|
||||
<view wx:elif="{{order.isShowKeepPay(settleDetailData)}}" bindtap="onCard" data-item="orderSure" class="btn origin">
|
||||
继续结算
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
68
miniprogram/pages/order/components/noGoods/noGoods.wxss
Normal file
68
miniprogram/pages/order/components/noGoods/noGoods.wxss
Normal file
@@ -0,0 +1,68 @@
|
||||
/* 层级定义
|
||||
@z-index-0: 1;
|
||||
@z-index-1: 100;
|
||||
@z-index-2: 200;
|
||||
@z-index-5: 500;
|
||||
@z-index-component: 1000; // 通用组件级别
|
||||
@z-index-dropdown: @z-index-component;
|
||||
@z-index-sticky: @z-index-component + 20;
|
||||
@z-index-fixed: @z-index-component + 30;
|
||||
@z-index-modal-backdrop:@z-index-component + 40;
|
||||
@z-index-modal:@z-index-component + 50;
|
||||
@z-index-popover:@z-index-component + 60;
|
||||
@z-index-tooltip:@z-index-component + 70;
|
||||
*/
|
||||
/* var() css变量适配*/
|
||||
.goods-fail {
|
||||
display: block;
|
||||
background: #fff;
|
||||
font-size: 30rpx;
|
||||
border-radius: 20rpx 20rpx 0 0;
|
||||
}
|
||||
.goods-fail .title {
|
||||
display: inline-block;
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
margin-top: 30rpx;
|
||||
line-height: 42rpx;
|
||||
font-weight: bold;
|
||||
font-size: 32rpx;
|
||||
}
|
||||
.goods-fail .info {
|
||||
display: block;
|
||||
font-size: 26rpx;
|
||||
font-weight: 400;
|
||||
line-height: 36rpx;
|
||||
margin: 20rpx auto 10rpx;
|
||||
text-align: center;
|
||||
width: 560rpx;
|
||||
color: #999;
|
||||
}
|
||||
.goods-fail .goods-fail-btn {
|
||||
display: flex;
|
||||
padding: 30rpx;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
font-size: 30rpx;
|
||||
}
|
||||
.goods-fail .goods-fail-btn .btn {
|
||||
width: 330rpx;
|
||||
height: 80rpx;
|
||||
line-height: 80rpx;
|
||||
border-radius: 8rpx;
|
||||
text-align: center;
|
||||
border: 1rpx solid #999;
|
||||
background: #fff;
|
||||
font-size: 32rpx;
|
||||
color: #666;
|
||||
}
|
||||
.goods-fail .goods-fail-btn .btn.origin,
|
||||
.goods-fail .goods-fail-btn .btn.limit {
|
||||
color: #fa550f;
|
||||
color: var(--color-primary, #fa550f);
|
||||
border: 1rpx solid #fa550f;
|
||||
border: 1rpx solid var(--color-primary, #fa550f);
|
||||
}
|
||||
.goods-fail .goods-fail-btn .btn.limit {
|
||||
flex-grow: 1;
|
||||
}
|
||||
472
miniprogram/pages/order/components/order-button-bar/index.js
Normal file
472
miniprogram/pages/order/components/order-button-bar/index.js
Normal file
@@ -0,0 +1,472 @@
|
||||
import Toast from 'tdesign-miniprogram/toast/index';
|
||||
import Dialog from 'tdesign-miniprogram/dialog/index';
|
||||
import { OrderButtonTypes } from '../../config';
|
||||
import { config } from '../../../../config/index';
|
||||
|
||||
Component({
|
||||
options: {
|
||||
addGlobalClass: true,
|
||||
},
|
||||
properties: {
|
||||
order: {
|
||||
type: Object,
|
||||
observer(order) {
|
||||
// 判定有传goodsIndex ,则认为是商品button bar, 仅显示申请售后按钮
|
||||
if (this.properties?.goodsIndex !== null) {
|
||||
const goods = order.goodsList[Number(this.properties.goodsIndex)];
|
||||
this.setData({
|
||||
buttons: {
|
||||
left: [],
|
||||
right: (goods.buttons || []).filter((b) => b.type == OrderButtonTypes.APPLY_REFUND),
|
||||
},
|
||||
});
|
||||
return;
|
||||
}
|
||||
// 订单的button bar 不显示申请售后按钮
|
||||
const buttonsRight = (order.buttons || [])
|
||||
// .filter((b) => b.type !== OrderButtonTypes.APPLY_REFUND)
|
||||
.map((button) => {
|
||||
//邀请好友拼团按钮
|
||||
if (button.type === OrderButtonTypes.INVITE_GROUPON && order.groupInfoVo) {
|
||||
const {
|
||||
groupInfoVo: { groupId, promotionId, remainMember, groupPrice },
|
||||
goodsList,
|
||||
} = order;
|
||||
const goodsImg = goodsList?.[0]?.imgUrl;
|
||||
const goodsName = goodsList?.[0]?.name;
|
||||
return {
|
||||
...button,
|
||||
openType: 'share',
|
||||
dataShare: {
|
||||
goodsImg,
|
||||
goodsName,
|
||||
groupId,
|
||||
promotionId,
|
||||
remainMember,
|
||||
groupPrice,
|
||||
storeId: order.storeId,
|
||||
},
|
||||
};
|
||||
}
|
||||
return button;
|
||||
});
|
||||
// 删除订单按钮单独挪到左侧
|
||||
const deleteBtnIndex = buttonsRight.findIndex((b) => b.type === OrderButtonTypes.DELETE);
|
||||
let buttonsLeft = [];
|
||||
if (deleteBtnIndex > -1) {
|
||||
buttonsLeft = buttonsRight.splice(deleteBtnIndex, 1);
|
||||
}
|
||||
this.setData({
|
||||
buttons: {
|
||||
left: buttonsLeft,
|
||||
right: buttonsRight,
|
||||
},
|
||||
});
|
||||
},
|
||||
},
|
||||
goodsIndex: {
|
||||
type: Number,
|
||||
value: null,
|
||||
},
|
||||
isBtnMax: {
|
||||
type: Boolean,
|
||||
value: false,
|
||||
},
|
||||
},
|
||||
|
||||
data: {
|
||||
order: {},
|
||||
buttons: {
|
||||
left: [],
|
||||
right: [],
|
||||
},
|
||||
},
|
||||
|
||||
methods: {
|
||||
// 点击【订单操作】按钮,根据按钮类型分发
|
||||
onOrderBtnTap(e) {
|
||||
const { type } = e.currentTarget.dataset;
|
||||
switch (type) {
|
||||
case OrderButtonTypes.DELETE:
|
||||
this.onDelete(this.data.order);
|
||||
break;
|
||||
case OrderButtonTypes.CANCEL:
|
||||
this.onCancel(this.data.order);
|
||||
break;
|
||||
case OrderButtonTypes.CONFIRM:
|
||||
this.onConfirm(this.data.order);
|
||||
break;
|
||||
case OrderButtonTypes.PAY:
|
||||
this.onPay(this.data.order);
|
||||
break;
|
||||
case OrderButtonTypes.REMIND_SHIP:
|
||||
this.onRemindShip(this.data.order);
|
||||
break;
|
||||
case OrderButtonTypes.APPLY_REFUND:
|
||||
this.onApplyRefund(this.data.order);
|
||||
break;
|
||||
case OrderButtonTypes.VIEW_REFUND:
|
||||
this.onViewRefund(this.data.order);
|
||||
break;
|
||||
case OrderButtonTypes.COMMENT:
|
||||
this.onAddComment(this.data.order);
|
||||
break;
|
||||
case OrderButtonTypes.INVITE_GROUPON:
|
||||
//分享邀请好友拼团
|
||||
break;
|
||||
case OrderButtonTypes.REBUY:
|
||||
this.onBuyAgain(this.data.order);
|
||||
}
|
||||
},
|
||||
|
||||
onCancel(order) {
|
||||
Dialog.confirm({
|
||||
title: '确认取消订单',
|
||||
content: '确定要取消这个订单吗?取消后无法恢复。',
|
||||
confirmBtn: '确认取消',
|
||||
cancelBtn: '我再想想',
|
||||
})
|
||||
.then(() => {
|
||||
// 显示加载状态
|
||||
wx.showLoading({
|
||||
title: '取消中...',
|
||||
mask: true
|
||||
});
|
||||
|
||||
// 调用取消订单API
|
||||
wx.request({
|
||||
url: `${config.apiBase}/orders/${order.orderNo}/cancel`,
|
||||
method: 'PUT',
|
||||
header: {
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': `Bearer ${wx.getStorageSync('token')}`
|
||||
},
|
||||
data: {
|
||||
order_no: order.orderNo
|
||||
},
|
||||
success: (res) => {
|
||||
wx.hideLoading();
|
||||
|
||||
if (res.statusCode === 200 && res.data.code === 200) {
|
||||
Toast({
|
||||
context: this,
|
||||
selector: '#t-toast',
|
||||
message: '订单取消成功',
|
||||
icon: 'check-circle',
|
||||
});
|
||||
|
||||
// 触发刷新事件
|
||||
this.triggerEvent('refresh');
|
||||
} else {
|
||||
Toast({
|
||||
context: this,
|
||||
selector: '#t-toast',
|
||||
message: res.data.message || '取消订单失败',
|
||||
icon: 'error',
|
||||
});
|
||||
}
|
||||
},
|
||||
fail: (err) => {
|
||||
wx.hideLoading();
|
||||
console.error('取消订单失败:', err);
|
||||
Toast({
|
||||
context: this,
|
||||
selector: '#t-toast',
|
||||
message: '网络错误,请重试',
|
||||
icon: 'error',
|
||||
});
|
||||
}
|
||||
});
|
||||
})
|
||||
.catch(() => {
|
||||
// 用户取消操作,不做任何处理
|
||||
});
|
||||
},
|
||||
|
||||
onConfirm(order) {
|
||||
Dialog.confirm({
|
||||
title: '确认是否已经收到货?',
|
||||
content: '确认收货后,订单将完成,无法撤销。',
|
||||
confirmBtn: '确认收货',
|
||||
cancelBtn: '取消',
|
||||
})
|
||||
.then(() => {
|
||||
// 显示加载状态
|
||||
wx.showLoading({
|
||||
title: '确认中...',
|
||||
mask: true
|
||||
});
|
||||
|
||||
// 调用确认收货API
|
||||
wx.request({
|
||||
url: `${config.apiBase}/orders/${order.orderNo}/receive`,
|
||||
method: 'PUT',
|
||||
header: {
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': `Bearer ${wx.getStorageSync('token')}`
|
||||
},
|
||||
data: {
|
||||
order_no: order.orderNo
|
||||
},
|
||||
success: (res) => {
|
||||
wx.hideLoading();
|
||||
|
||||
if (res.statusCode === 200 && res.data.code === 200) {
|
||||
Toast({
|
||||
context: this,
|
||||
selector: '#t-toast',
|
||||
message: '确认收货成功',
|
||||
icon: 'check-circle',
|
||||
});
|
||||
|
||||
// 触发刷新事件
|
||||
this.triggerEvent('refresh');
|
||||
} else {
|
||||
Toast({
|
||||
context: this,
|
||||
selector: '#t-toast',
|
||||
message: res.data.message || '确认收货失败',
|
||||
icon: 'error',
|
||||
});
|
||||
}
|
||||
},
|
||||
fail: (err) => {
|
||||
wx.hideLoading();
|
||||
console.error('确认收货失败:', err);
|
||||
Toast({
|
||||
context: this,
|
||||
selector: '#t-toast',
|
||||
message: '网络错误,请重试',
|
||||
icon: 'error',
|
||||
});
|
||||
}
|
||||
});
|
||||
})
|
||||
.catch(() => {
|
||||
// 用户取消操作,不做任何处理
|
||||
});
|
||||
},
|
||||
|
||||
onPay(order) {
|
||||
// 显示加载状态
|
||||
wx.showLoading({
|
||||
title: '创建支付订单...',
|
||||
mask: true
|
||||
});
|
||||
|
||||
// 调用支付API
|
||||
wx.request({
|
||||
url: `${config.apiBase}/payment/create`,
|
||||
method: 'POST',
|
||||
header: {
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': `Bearer ${wx.getStorageSync('token')}`
|
||||
},
|
||||
data: {
|
||||
orderNo: order.orderNo,
|
||||
paymentMethod: 'wechat'
|
||||
},
|
||||
success: (res) => {
|
||||
if (res.statusCode === 200 && res.data.code === 200) {
|
||||
const paymentData = res.data.data;
|
||||
|
||||
// 如果返回了微信支付参数,调用微信支付SDK
|
||||
if (paymentData && paymentData.payInfo) {
|
||||
wx.hideLoading();
|
||||
wx.showLoading({ title: '调起微信支付...' });
|
||||
|
||||
try {
|
||||
const payInfo = typeof paymentData.payInfo === 'string'
|
||||
? JSON.parse(paymentData.payInfo)
|
||||
: paymentData.payInfo;
|
||||
|
||||
console.log('微信支付参数:', payInfo);
|
||||
|
||||
wx.requestPayment({
|
||||
timeStamp: payInfo.timeStamp,
|
||||
nonceStr: payInfo.nonceStr,
|
||||
package: payInfo.package,
|
||||
signType: payInfo.signType || 'RSA',
|
||||
paySign: payInfo.paySign,
|
||||
success: (payRes) => {
|
||||
wx.hideLoading();
|
||||
Toast({
|
||||
context: this,
|
||||
selector: '#t-toast',
|
||||
message: '支付成功',
|
||||
icon: 'check-circle',
|
||||
});
|
||||
|
||||
// 触发刷新事件
|
||||
this.triggerEvent('refresh');
|
||||
},
|
||||
fail: (payErr) => {
|
||||
wx.hideLoading();
|
||||
Toast({
|
||||
context: this,
|
||||
selector: '#t-toast',
|
||||
message: payErr.errMsg || '支付失败',
|
||||
icon: 'error',
|
||||
});
|
||||
}
|
||||
});
|
||||
} catch (parseErr) {
|
||||
wx.hideLoading();
|
||||
Toast({
|
||||
context: this,
|
||||
selector: '#t-toast',
|
||||
message: '支付参数解析失败',
|
||||
icon: 'error',
|
||||
});
|
||||
}
|
||||
} else {
|
||||
// 如果没有返回微信支付参数,可能是模拟支付成功
|
||||
wx.hideLoading();
|
||||
Toast({
|
||||
context: this,
|
||||
selector: '#t-toast',
|
||||
message: '支付成功',
|
||||
icon: 'check-circle',
|
||||
});
|
||||
|
||||
// 触发刷新事件
|
||||
this.triggerEvent('refresh');
|
||||
}
|
||||
} else {
|
||||
wx.hideLoading();
|
||||
Toast({
|
||||
context: this,
|
||||
selector: '#t-toast',
|
||||
message: res.data.message || '创建支付订单失败',
|
||||
icon: 'error',
|
||||
});
|
||||
}
|
||||
},
|
||||
fail: (err) => {
|
||||
wx.hideLoading();
|
||||
console.error('支付失败:', err);
|
||||
Toast({
|
||||
context: this,
|
||||
selector: '#t-toast',
|
||||
message: '网络错误,请重试',
|
||||
icon: 'error',
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
onRemindShip(order) {
|
||||
// 显示加载状态
|
||||
wx.showLoading({
|
||||
title: '发送提醒...',
|
||||
mask: true
|
||||
});
|
||||
|
||||
// 调用提醒发货API
|
||||
wx.request({
|
||||
url: `${config.apiBase}/orders/${order.orderNo}/remind-ship`,
|
||||
method: 'PUT',
|
||||
header: {
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': `Bearer ${wx.getStorageSync('token')}`
|
||||
},
|
||||
success: (res) => {
|
||||
wx.hideLoading();
|
||||
|
||||
if (res.statusCode === 200 && res.data.code === 200) {
|
||||
Toast({
|
||||
context: this,
|
||||
selector: '#t-toast',
|
||||
message: '提醒发货成功,商家将尽快处理',
|
||||
icon: 'check-circle',
|
||||
});
|
||||
} else {
|
||||
Toast({
|
||||
context: this,
|
||||
selector: '#t-toast',
|
||||
message: res.data.message || '提醒发货失败',
|
||||
icon: 'error',
|
||||
});
|
||||
}
|
||||
},
|
||||
fail: (err) => {
|
||||
wx.hideLoading();
|
||||
console.error('提醒发货失败:', err);
|
||||
Toast({
|
||||
context: this,
|
||||
selector: '#t-toast',
|
||||
message: '网络错误,请重试',
|
||||
icon: 'error',
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
onBuyAgain() {
|
||||
Toast({
|
||||
context: this,
|
||||
selector: '#t-toast',
|
||||
message: '你点击了再次购买',
|
||||
icon: 'check-circle',
|
||||
});
|
||||
},
|
||||
|
||||
onApplyRefund(order) {
|
||||
console.log('[订单按钮] 点击申请退款按钮', { orderNo: order?.orderNo, goodsIndex: this.properties.goodsIndex });
|
||||
|
||||
// 如果是商品级别的退款申请(有goodsIndex)
|
||||
if (this.properties.goodsIndex !== null) {
|
||||
const goods = order.goodsList[this.properties.goodsIndex];
|
||||
const params = {
|
||||
orderNo: order.orderNo,
|
||||
skuId: goods?.skuId ?? goods?.id ?? '19384938948343',
|
||||
spuId: goods?.spuId ?? goods?.productId ?? '28373847384343',
|
||||
orderStatus: order.status,
|
||||
logisticsNo: order.logisticsNo,
|
||||
price: goods?.price ?? goods?.actualPrice ?? 89,
|
||||
num: goods?.num ?? goods?.buyQuantity ?? 1,
|
||||
createTime: order.createTime,
|
||||
orderAmt: order.totalAmount,
|
||||
payAmt: order.amount,
|
||||
canApplyReturn: true,
|
||||
};
|
||||
const paramsStr = Object.keys(params)
|
||||
.map((k) => `${k}=${params[k]}`)
|
||||
.join('&');
|
||||
wx.navigateTo({ url: `/pages/order/apply-service/index?${paramsStr}` });
|
||||
} else {
|
||||
// 订单级别的退款申请,跳转到订单详情页
|
||||
if (order?.orderNo) {
|
||||
wx.navigateTo({
|
||||
url: `/pages/order/order-detail/index?orderNo=${order.orderNo}`
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
onViewRefund(order) {
|
||||
console.log('[订单按钮] 点击查看退款按钮', { orderNo: order?.orderNo });
|
||||
|
||||
// 跳转到售后列表页面
|
||||
wx.navigateTo({
|
||||
url: '/pages/order/after-service-list/index'
|
||||
});
|
||||
},
|
||||
|
||||
/** 添加订单评论 */
|
||||
onAddComment(order) {
|
||||
// 如果订单只有一个商品,直接跳转到评论页面
|
||||
if (order?.goodsList?.length === 1) {
|
||||
const orderItem = order.goodsList[0];
|
||||
wx.navigateTo({
|
||||
url: `/pages/order/comment/index?orderNo=${order.orderNo}&orderItemId=${orderItem.id}`,
|
||||
});
|
||||
} else {
|
||||
// 如果有多个商品,跳转到评论列表页面让用户选择
|
||||
wx.navigateTo({
|
||||
url: `/pages/order/comment-list/index?orderNo=${order.orderNo}`,
|
||||
});
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {
|
||||
"t-button": "tdesign-miniprogram/button/button",
|
||||
"t-toast": "tdesign-miniprogram/toast/toast",
|
||||
"t-dialog": "tdesign-miniprogram/dialog/dialog"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
<view class="btn-bar">
|
||||
<view class="left">
|
||||
<t-button
|
||||
wx:for="{{buttons.left}}"
|
||||
wx:key="type"
|
||||
wx:for-item="leftBtn"
|
||||
size="extra-small"
|
||||
shape="round"
|
||||
t-class="{{isBtnMax ? 't-button--max':'t-button'}} order-btn delete-btn"
|
||||
hover-class="order-btn--active"
|
||||
catchtap="onOrderBtnTap"
|
||||
data-type="{{leftBtn.type}}"
|
||||
>
|
||||
{{leftBtn.name}}
|
||||
</t-button>
|
||||
</view>
|
||||
<view class="right">
|
||||
<t-button
|
||||
wx:for="{{buttons.right}}"
|
||||
wx:key="type"
|
||||
wx:for-item="rightBtn"
|
||||
size="extra-small"
|
||||
variant="{{ rightBtn.primary ? 'base' : 'outline'}}"
|
||||
shape="round"
|
||||
t-class="{{isBtnMax ? 't-button--max':'t-button'}} order-btn {{rightBtn.primary ? 'primary' : 'normal'}}"
|
||||
hover-class="order-btn--active"
|
||||
catchtap="onOrderBtnTap"
|
||||
data-type="{{rightBtn.type}}"
|
||||
open-type="{{ rightBtn.openType }}"
|
||||
data-share="{{ rightBtn.dataShare }}"
|
||||
>
|
||||
{{rightBtn.name}}
|
||||
</t-button>
|
||||
</view>
|
||||
</view>
|
||||
<t-toast id="t-toast" />
|
||||
<t-dialog id="t-dialog" />
|
||||
@@ -0,0 +1,54 @@
|
||||
:host {
|
||||
width: 100%;
|
||||
}
|
||||
.btn-bar {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
line-height: 1;
|
||||
}
|
||||
.btn-bar .order-btn {
|
||||
line-height: 1;
|
||||
/* border-radius: unset; */
|
||||
/* min-width: 160rpx; */
|
||||
}
|
||||
|
||||
.btn-bar .right {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
.btn-bar .t-button {
|
||||
width: 160rpx;
|
||||
font-weight: 400;
|
||||
margin-left: 24rpx;
|
||||
}
|
||||
.btn-bar .t-button--max {
|
||||
width: 176rpx;
|
||||
margin-left: 24rpx;
|
||||
|
||||
--td-button-extra-small-height: 72rpx;
|
||||
}
|
||||
|
||||
.btn-bar .left .delete-btn {
|
||||
font-size: 22rpx;
|
||||
}
|
||||
.btn-bar .left .delete-btn::after {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.btn-bar .right .normal {
|
||||
--td-button-default-color: #333333;
|
||||
--td-button-default-border-color: #dddddd;
|
||||
}
|
||||
|
||||
.btn-bar .right .primary {
|
||||
--td-button-default-color: #fff;
|
||||
--td-button-default-bg-color: #fa4126;
|
||||
--td-button-default-border-color: #fa4126;
|
||||
--td-button-default-active-bg-color: #fa42269c;
|
||||
}
|
||||
|
||||
.t-button {
|
||||
--td-button-default-color: #000;
|
||||
--td-button-primary-text-color: #fa4126;
|
||||
}
|
||||
90
miniprogram/pages/order/components/order-card/index.js
Normal file
90
miniprogram/pages/order/components/order-card/index.js
Normal file
@@ -0,0 +1,90 @@
|
||||
Component({
|
||||
externalClasses: ['wr-class', 'header-class', 'title-class'],
|
||||
|
||||
options: {
|
||||
multipleSlots: true,
|
||||
},
|
||||
|
||||
relations: {
|
||||
'../order-goods-card/index': {
|
||||
type: 'descendant',
|
||||
linked(target) {
|
||||
this.children.push(target);
|
||||
this.setHidden();
|
||||
},
|
||||
unlinked(target) {
|
||||
this.children = this.children.filter((item) => item !== target);
|
||||
},
|
||||
},
|
||||
'../goods-card/index': {
|
||||
type: 'descendant',
|
||||
linked(target) {
|
||||
this.children.push(target);
|
||||
this.setHidden();
|
||||
},
|
||||
unlinked(target) {
|
||||
this.children = this.children.filter((item) => item !== target);
|
||||
},
|
||||
},
|
||||
'../specs-goods-card/index': {
|
||||
type: 'descendant',
|
||||
linked(target) {
|
||||
this.children.push(target);
|
||||
this.setHidden();
|
||||
},
|
||||
unlinked(target) {
|
||||
this.children = this.children.filter((item) => item !== target);
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
created() {
|
||||
this.children = [];
|
||||
},
|
||||
|
||||
properties: {
|
||||
order: {
|
||||
type: Object,
|
||||
observer(order) {
|
||||
if (!order?.goodsList) return;
|
||||
const goodsCount = order.goodsList.length;
|
||||
this.setData({
|
||||
goodsCount,
|
||||
});
|
||||
},
|
||||
},
|
||||
useTopRightSlot: Boolean,
|
||||
// 初始显示的商品数量,超出部分会隐藏。
|
||||
defaultShowNum: {
|
||||
type: null,
|
||||
value: 10,
|
||||
},
|
||||
useLogoSlot: {
|
||||
type: Boolean,
|
||||
value: false,
|
||||
},
|
||||
},
|
||||
|
||||
data: {
|
||||
showAll: true, // 是否展示所有商品,设置为false,可以使用展开更多功能
|
||||
goodsCount: 0,
|
||||
},
|
||||
|
||||
methods: {
|
||||
setHidden() {
|
||||
const isHidden = !this.data.showAll;
|
||||
this.children.forEach(
|
||||
(c, i) => i >= this.properties.defaultShowNum && c.setHidden(isHidden),
|
||||
);
|
||||
},
|
||||
|
||||
onOrderCardTap() {
|
||||
this.triggerEvent('cardtap');
|
||||
},
|
||||
|
||||
onShowMoreTap() {
|
||||
this.setData({ showAll: true }, () => this.setHidden());
|
||||
this.triggerEvent('showall');
|
||||
},
|
||||
},
|
||||
});
|
||||
7
miniprogram/pages/order/components/order-card/index.json
Normal file
7
miniprogram/pages/order/components/order-card/index.json
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {
|
||||
"t-image": "/components/webp-image/index",
|
||||
"t-icon": "tdesign-miniprogram/icon/icon"
|
||||
}
|
||||
}
|
||||
22
miniprogram/pages/order/components/order-card/index.wxml
Normal file
22
miniprogram/pages/order/components/order-card/index.wxml
Normal file
@@ -0,0 +1,22 @@
|
||||
<view class="order-card wr-class" bind:tap="onOrderCardTap">
|
||||
<view class="header header-class">
|
||||
<view class="store-name title-class">
|
||||
<block wx:if="{{!useLogoSlot}}">
|
||||
<t-image wx:if="{{order.storeLogo}}" t-class="store-name__logo" src="{{order.storeLogo}}" />
|
||||
<t-icon wx:else prefix="wr" class="store-name__logo" name="store" size="40rpx" color="inherit" />
|
||||
<view class="store-name__label">{{order.storeName}}</view>
|
||||
</block>
|
||||
<slot wx:else name="top-left" />
|
||||
</view>
|
||||
<view wx:if="{{!useTopRightSlot}}" class="order-status">{{order.statusDesc}}</view>
|
||||
<slot wx:else name="top-right" />
|
||||
</view>
|
||||
<view class="slot-wrapper">
|
||||
<slot />
|
||||
</view>
|
||||
<view wx:if="{{goodsCount > defaultShowNum && !showAll}}" class="more-mask" catchtap="onShowMoreTap">
|
||||
展开商品信息(共 {{goodsCount}} 个)
|
||||
<t-icon name="chevron-down" size="32rpx" />
|
||||
</view>
|
||||
<slot name="more" />
|
||||
</view>
|
||||
45
miniprogram/pages/order/components/order-card/index.wxss
Normal file
45
miniprogram/pages/order/components/order-card/index.wxss
Normal file
@@ -0,0 +1,45 @@
|
||||
.order-card {
|
||||
margin: 24rpx 0;
|
||||
padding: 24rpx 32rpx 24rpx;
|
||||
background-color: white;
|
||||
border-radius: 8rpx;
|
||||
}
|
||||
.order-card .header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 24rpx;
|
||||
}
|
||||
.order-card .header .store-name {
|
||||
font-size: 28rpx;
|
||||
font-weight: normal;
|
||||
color: #333333;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
line-height: 40rpx;
|
||||
}
|
||||
.order-card .header .store-name__logo {
|
||||
margin-right: 16rpx;
|
||||
font-size: 40rpx;
|
||||
width: 48rpx;
|
||||
height: 48rpx;
|
||||
}
|
||||
.order-card .header .store-name__label {
|
||||
max-width: 500rpx;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
word-break: break-all;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.order-card .header .order-status {
|
||||
font-size: 26rpx;
|
||||
line-height: 40rpx;
|
||||
color: #fa4126;
|
||||
}
|
||||
.order-card .more-mask {
|
||||
padding: 20rpx 0;
|
||||
text-align: center;
|
||||
background-color: white;
|
||||
color: #fa4126;
|
||||
font-size: 24rpx;
|
||||
}
|
||||
43
miniprogram/pages/order/components/order-goods-card/index.js
Normal file
43
miniprogram/pages/order/components/order-goods-card/index.js
Normal file
@@ -0,0 +1,43 @@
|
||||
Component({
|
||||
options: {
|
||||
addGlobalClass: true,
|
||||
multipleSlots: true, // 在组件定义时的选项中启用多slot支持
|
||||
},
|
||||
|
||||
relations: {
|
||||
'../order-card/index': {
|
||||
type: 'ancestor',
|
||||
linked(target) {
|
||||
this.parent = target;
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
properties: {
|
||||
goods: Object,
|
||||
thumbWidth: Number,
|
||||
thumbHeight: Number,
|
||||
thumbWidthInPopup: Number,
|
||||
thumbHeightInPopup: Number,
|
||||
noTopLine: Boolean,
|
||||
step: Boolean,
|
||||
stepDisabled: Boolean,
|
||||
},
|
||||
|
||||
data: {
|
||||
goods: {},
|
||||
hidden: false,
|
||||
},
|
||||
|
||||
methods: {
|
||||
setHidden(hidden) {
|
||||
if (this.data.hidden === hidden) return;
|
||||
this.setData({ hidden });
|
||||
},
|
||||
|
||||
onNumChange(e) {
|
||||
const { value } = e.detail;
|
||||
this.triggerEvent('num-change', { value });
|
||||
},
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {
|
||||
"t-stepper": "tdesign-miniprogram/stepper/stepper",
|
||||
"goods-card": "../specs-goods-card/index"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<goods-card
|
||||
class="order-goods-card {{ step ? 'order-goods-card--step' : '' }}"
|
||||
wx:if="{{!hidden}}"
|
||||
data="{{goods}}"
|
||||
thumb-width="{{thumbWidth}}"
|
||||
thumb-height="{{thumbHeight}}"
|
||||
thumb-width-in-popup="{{thumbWidthInPopup}}"
|
||||
thumb-height-in-popup="{{thumbHeightInPopup}}"
|
||||
>
|
||||
<t-stepper
|
||||
wx:if="{{ step }}"
|
||||
slot="append-body"
|
||||
disabled="{{ step ? stepDisabled : ''}}"
|
||||
value="{{goods.quantity}}"
|
||||
min="{{ 1 }}"
|
||||
theme="filled"
|
||||
bindminus="onNumChange"
|
||||
bindplus="onNumChange"
|
||||
bindblur="onNumChange"
|
||||
/>
|
||||
<!-- 透传good-card组件的slot -->
|
||||
<slot name="thumb-cover" slot="thumb-cover" />
|
||||
<slot name="after-title" slot="after-title" />
|
||||
<slot name="after-desc" slot="after-desc" />
|
||||
<slot name="price-prefix" slot="price-prefix" />
|
||||
<slot name="append-body" slot="append-body" />
|
||||
<slot name="footer" slot="footer" />
|
||||
<slot name="append-card" slot="append-card" />
|
||||
</goods-card>
|
||||
121
miniprogram/pages/order/components/reason-sheet/index.js
Normal file
121
miniprogram/pages/order/components/reason-sheet/index.js
Normal file
@@ -0,0 +1,121 @@
|
||||
Component({
|
||||
options: {
|
||||
addGlobalClass: true,
|
||||
},
|
||||
properties: {
|
||||
show: Boolean,
|
||||
title: String,
|
||||
options: {
|
||||
type: Object,
|
||||
observer() {
|
||||
this.init();
|
||||
},
|
||||
},
|
||||
multiple: {
|
||||
type: Boolean,
|
||||
observer() {
|
||||
this.init();
|
||||
},
|
||||
},
|
||||
showConfirmButton: Boolean,
|
||||
showCloseButton: Boolean,
|
||||
confirmButtonText: {
|
||||
type: String,
|
||||
value: '确定',
|
||||
},
|
||||
cancelButtonText: {
|
||||
type: String,
|
||||
value: '取消',
|
||||
},
|
||||
emptyTip: {
|
||||
type: String,
|
||||
value: '请选择',
|
||||
},
|
||||
},
|
||||
|
||||
data: {
|
||||
_options: [],
|
||||
checkedIndexes: [],
|
||||
},
|
||||
|
||||
methods: {
|
||||
attached() {
|
||||
this.toast = this.selectComponent('#t-toast');
|
||||
},
|
||||
|
||||
init() {
|
||||
const checkedIndexes = [];
|
||||
const _options = this.properties.options.map((opt, i) => {
|
||||
const checked = !!opt.checked;
|
||||
if (checked) {
|
||||
if (this.properties.multiple) {
|
||||
checkedIndexes.length = 0; // 清空数组
|
||||
checkedIndexes[0] = i;
|
||||
} else {
|
||||
checkedIndexes.push(i);
|
||||
}
|
||||
}
|
||||
return {
|
||||
title: opt.title,
|
||||
checked,
|
||||
};
|
||||
});
|
||||
this.setData({ checkedIndexes, _options });
|
||||
},
|
||||
|
||||
onOptionTap(e) {
|
||||
const { index } = e.currentTarget.dataset;
|
||||
const { checkedIndexes } = this.data;
|
||||
let data = {};
|
||||
if (this.properties.multiple) {
|
||||
if (checkedIndexes.includes(index)) {
|
||||
checkedIndexes.splice(index, 1);
|
||||
data = { checkedIndexes, [`_options[${index}].checked`]: false };
|
||||
} else {
|
||||
checkedIndexes.push(index);
|
||||
data = { checkedIndexes, [`_options[${index}].checked`]: true };
|
||||
}
|
||||
} else {
|
||||
if (checkedIndexes.length > 0 && checkedIndexes[0] === index) {
|
||||
// 单选不可取消选择
|
||||
return;
|
||||
}
|
||||
data = {
|
||||
[`_options[${index}].checked`]: true,
|
||||
checkedIndexes: [index],
|
||||
};
|
||||
if (checkedIndexes.length > 0 && checkedIndexes[0] !== undefined) {
|
||||
data[`_options[${checkedIndexes[0]}].checked`] = false;
|
||||
}
|
||||
}
|
||||
this.setData(data);
|
||||
this.triggerEvent('select', { index });
|
||||
this._onOptionTap && this._onOptionTap(index);
|
||||
if (!this.properties.showConfirmButton && !this.properties.multiple) {
|
||||
// 没有确认按钮且是单选的情况下,选择选项则自动确定
|
||||
this._onConfirm && this._onConfirm([index]);
|
||||
this.setData({ show: false });
|
||||
}
|
||||
},
|
||||
|
||||
onCancel() {
|
||||
this.triggerEvent('cancel');
|
||||
this._onCancel && this._onCancel();
|
||||
this.setData({ show: false });
|
||||
},
|
||||
|
||||
onConfirm() {
|
||||
if (this.data.checkedIndexes.length === 0) {
|
||||
this.toast.show({
|
||||
icon: '',
|
||||
text: this.properties.emptyTip,
|
||||
});
|
||||
return;
|
||||
}
|
||||
const indexed = this.data.checkedIndexes;
|
||||
this.triggerEvent('confirm', { indexed });
|
||||
this._onConfirm && this._onConfirm(indexed);
|
||||
this.setData({ show: false });
|
||||
},
|
||||
},
|
||||
});
|
||||
10
miniprogram/pages/order/components/reason-sheet/index.json
Normal file
10
miniprogram/pages/order/components/reason-sheet/index.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {
|
||||
"t-icon": "tdesign-miniprogram/icon/icon",
|
||||
"t-popup": "tdesign-miniprogram/popup/popup",
|
||||
"t-cell": "tdesign-miniprogram/cell/cell",
|
||||
"t-toast": "tdesign-miniprogram/toast/toast",
|
||||
"t-button": "tdesign-miniprogram/button/button"
|
||||
}
|
||||
}
|
||||
27
miniprogram/pages/order/components/reason-sheet/index.wxml
Normal file
27
miniprogram/pages/order/components/reason-sheet/index.wxml
Normal file
@@ -0,0 +1,27 @@
|
||||
<t-popup visible="{{show}}" placement="bottom" bind:visible-change="onCancel" close-btn="{{showCloseButton}}">
|
||||
<view class="popup-content">
|
||||
<view class="header"> {{title}} </view>
|
||||
<view class="options cell--noborder">
|
||||
<t-cell
|
||||
wx:for="{{_options}}"
|
||||
wx:key="title"
|
||||
t-class="cell"
|
||||
title="{{item.title}}"
|
||||
bindclick="onOptionTap"
|
||||
data-index="{{index}}"
|
||||
border="{{false}}"
|
||||
>
|
||||
<view slot="right-icon">
|
||||
<t-icon name="check-circle-filled" size="36rpx" color="#fa4126" wx:if="{{item.checked}}" />
|
||||
<t-icon name="circle" size="36rpx" color="#C7C7C7" wx:else />
|
||||
</view>
|
||||
</t-cell>
|
||||
</view>
|
||||
<view class="button-bar" wx:if="{{showConfirmButton}}">
|
||||
<t-button class="btnWrapper" wx:if="{{showConfirmButton}}" t-class="btn" bindtap="onConfirm">
|
||||
{{confirmButtonText}}
|
||||
</t-button>
|
||||
</view>
|
||||
</view>
|
||||
</t-popup>
|
||||
<t-toast id="t-toast" />
|
||||
46
miniprogram/pages/order/components/reason-sheet/index.wxss
Normal file
46
miniprogram/pages/order/components/reason-sheet/index.wxss
Normal file
@@ -0,0 +1,46 @@
|
||||
page view {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.popup-content {
|
||||
background-color: white;
|
||||
color: #222427;
|
||||
border-radius: 20rpx 20rpx 0 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
.popup-content .header {
|
||||
height: 100rpx;
|
||||
line-height: 100rpx;
|
||||
text-align: center;
|
||||
vertical-align: middle;
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
position: relative;
|
||||
}
|
||||
.popup-content .options {
|
||||
max-height: 60vh;
|
||||
overflow-y: scroll;
|
||||
-webkit-overflow-scrolling: touch;
|
||||
}
|
||||
.popup-content .options .cell {
|
||||
height: 100rpx;
|
||||
align-items: center;
|
||||
font-size: 30rpx;
|
||||
color: #333333;
|
||||
}
|
||||
.popup-content .button-bar {
|
||||
width: 100%;
|
||||
padding: 20rpx 30rpx;
|
||||
display: flex;
|
||||
flex-wrap: nowrap;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
}
|
||||
.popup-content .button-bar .btn {
|
||||
width: 100%;
|
||||
background: #fa4126;
|
||||
color: #fff;
|
||||
border-radius: 48rpx;
|
||||
}
|
||||
.button-bar .btnWrapper {
|
||||
width: 100%;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
function getInstance(context, selector = '#wr-reason-sheet') {
|
||||
if (!context) {
|
||||
const pages = getCurrentPages();
|
||||
const page = pages[pages.length - 1];
|
||||
context = page;
|
||||
}
|
||||
const instance = context && context.selectComponent(selector);
|
||||
if (!instance) {
|
||||
console.warn(`未找到reason-sheet组件,请检查selector是否正确`);
|
||||
return null;
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
export default function (options) {
|
||||
const { context, selector, ..._options } = options;
|
||||
return new Promise((resolve, reject) => {
|
||||
const instance = getInstance(context, selector);
|
||||
if (instance) {
|
||||
instance.setData(Object.assign({}, _options));
|
||||
instance._onCancel = () => reject();
|
||||
instance._onConfirm = (indexes) => resolve(indexes);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,375 @@
|
||||
import dayjs from 'dayjs';
|
||||
import { couponsData } from './mock';
|
||||
import { request } from '../../../../services/_utils/request';
|
||||
|
||||
const emptyCouponImg = `https://tdesign.gtimg.com/miniprogram/template/retail/coupon/ordersure-coupon-newempty.png`;
|
||||
|
||||
Component({
|
||||
properties: {
|
||||
storeId: String,
|
||||
promotionGoodsList: {
|
||||
type: Array,
|
||||
value: [],
|
||||
},
|
||||
orderSureCouponList: {
|
||||
type: Array,
|
||||
value: [],
|
||||
},
|
||||
couponsShow: {
|
||||
type: Boolean,
|
||||
value: false,
|
||||
observer(couponsShow) {
|
||||
console.log('selectCoupons observer 触发:', { couponsShow });
|
||||
if (couponsShow) {
|
||||
console.log('开始处理优惠券显示逻辑');
|
||||
const { promotionGoodsList, orderSureCouponList, storeId } = this.data;
|
||||
console.log('组件数据:', { promotionGoodsList, orderSureCouponList, storeId });
|
||||
const products =
|
||||
promotionGoodsList &&
|
||||
promotionGoodsList.map((goods) => {
|
||||
this.storeId = goods.storeId;
|
||||
return {
|
||||
skuId: goods.skuId,
|
||||
spuId: goods.spuId,
|
||||
storeId: goods.storeId,
|
||||
selected: true,
|
||||
quantity: goods.num,
|
||||
prices: {
|
||||
sale: goods.settlePrice,
|
||||
},
|
||||
};
|
||||
});
|
||||
const selectedCoupons =
|
||||
orderSureCouponList &&
|
||||
orderSureCouponList.map((ele) => {
|
||||
return {
|
||||
promotionId: ele.promotionId,
|
||||
storeId: ele.storeId,
|
||||
couponId: ele.couponId,
|
||||
};
|
||||
});
|
||||
this.setData({
|
||||
products,
|
||||
});
|
||||
this.coupons({
|
||||
products,
|
||||
selectedCoupons,
|
||||
storeId,
|
||||
}).then((res) => {
|
||||
this.initData(res);
|
||||
});
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
data: {
|
||||
emptyCouponImg,
|
||||
goodsList: [],
|
||||
selectedList: [],
|
||||
couponsList: [],
|
||||
orderSureCouponList: [],
|
||||
promotionGoodsList: [],
|
||||
},
|
||||
lifetimes: {
|
||||
attached() {
|
||||
console.log('selectCoupons组件已挂载');
|
||||
},
|
||||
ready() {
|
||||
console.log('selectCoupons组件已准备就绪');
|
||||
console.log('组件属性值:', {
|
||||
couponsShow: this.properties.couponsShow,
|
||||
storeId: this.properties.storeId,
|
||||
promotionGoodsListLength: this.properties.promotionGoodsList.length,
|
||||
orderSureCouponListLength: this.properties.orderSureCouponList.length
|
||||
});
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
initData(data = {}) {
|
||||
console.log('initData方法被调用:', data);
|
||||
const { couponResultList = [], reduce = 0 } = data;
|
||||
const { orderSureCouponList } = this.data;
|
||||
console.log('initData - orderSureCouponList:', orderSureCouponList);
|
||||
|
||||
const selectedList = [];
|
||||
let selectedNum = 0;
|
||||
const couponsList =
|
||||
couponResultList &&
|
||||
couponResultList.map((coupon) => {
|
||||
const { status, couponVO } = coupon;
|
||||
const { couponId, condition = '', endTime = 0, name = '', startTime = 0, value, type } = couponVO;
|
||||
|
||||
// 检查当前优惠券是否在已选列表中
|
||||
const isSelected = orderSureCouponList && orderSureCouponList.some(selectedCoupon => {
|
||||
return selectedCoupon.key === couponId ||
|
||||
selectedCoupon.couponId === couponId ||
|
||||
selectedCoupon.id === couponId;
|
||||
});
|
||||
|
||||
console.log(`initData - 优惠券 ${name} (ID: ${couponId}) 是否已选: ${isSelected}`);
|
||||
|
||||
if (isSelected) {
|
||||
selectedNum++;
|
||||
selectedList.push({
|
||||
userCouponId: coupon.id, // 用户优惠券ID,用于后端验证所有权
|
||||
id: coupon.id, // 保持兼容性
|
||||
couponId,
|
||||
promotionId: couponId, // 使用couponId作为promotionId
|
||||
storeId: this.storeId,
|
||||
key: couponId,
|
||||
// 添加调试信息
|
||||
_debug: {
|
||||
userCouponId: coupon.id,
|
||||
couponTemplateId: couponId
|
||||
}
|
||||
});
|
||||
}
|
||||
const val = value; // 直接使用原始值,ui-coupon-card组件会自动处理单位转换
|
||||
return {
|
||||
id: coupon.id, // 用户优惠券ID,用于后端验证所有权
|
||||
key: couponId, // 保持原有的key逻辑
|
||||
couponId: couponId, // 优惠券模板ID
|
||||
title: name,
|
||||
isSelected: isSelected,
|
||||
timeLimit: this.formatTimeLimit(startTime, endTime),
|
||||
value: val,
|
||||
status: status === -1 ? 'useless' : 'default',
|
||||
desc: condition,
|
||||
type,
|
||||
tag: '',
|
||||
};
|
||||
});
|
||||
console.log('initData设置数据:', { selectedList, couponsList, reduce, selectedNum });
|
||||
this.setData({
|
||||
selectedList,
|
||||
couponsList,
|
||||
reduce,
|
||||
selectedNum,
|
||||
});
|
||||
},
|
||||
selectCoupon(e) {
|
||||
const { key } = e.currentTarget.dataset;
|
||||
const { couponsList } = this.data;
|
||||
|
||||
// 先清除所有选中状态(假设一次只能选择一张优惠券)
|
||||
couponsList.forEach((coupon) => {
|
||||
coupon.isSelected = false;
|
||||
});
|
||||
|
||||
// 设置当前选中的优惠券
|
||||
const selectedCoupon = couponsList.find((coupon) => coupon.key === key);
|
||||
if (selectedCoupon) {
|
||||
selectedCoupon.isSelected = true;
|
||||
}
|
||||
|
||||
const couponSelected = couponsList.filter((coupon) => coupon.isSelected === true);
|
||||
|
||||
// 转换为后端期望的数据格式
|
||||
const selectedListForBackend = couponSelected.map(coupon => ({
|
||||
userCouponId: coupon.id, // 用户优惠券ID,用于后端验证所有权
|
||||
id: coupon.id, // 保持兼容性
|
||||
couponId: coupon.couponId, // 优惠券模板ID,用于获取优惠券信息
|
||||
key: coupon.key,
|
||||
promotionId: coupon.couponId, // 使用couponId作为promotionId
|
||||
storeId: this.storeId,
|
||||
// 添加调试信息
|
||||
_debug: {
|
||||
originalCoupon: coupon,
|
||||
userCouponId: coupon.id,
|
||||
couponTemplateId: coupon.couponId
|
||||
}
|
||||
}));
|
||||
|
||||
this.setData({
|
||||
selectedList: selectedListForBackend,
|
||||
couponsList: [...couponsList],
|
||||
});
|
||||
|
||||
console.log('优惠券选择:', {
|
||||
selectedKey: key,
|
||||
selectedCoupon,
|
||||
couponSelected,
|
||||
selectedListForBackend
|
||||
});
|
||||
|
||||
this.triggerEvent('sure', {
|
||||
selectedList: selectedListForBackend,
|
||||
});
|
||||
},
|
||||
hide() {
|
||||
this.setData({
|
||||
couponsShow: false,
|
||||
});
|
||||
},
|
||||
onPopupVisibleChange(e) {
|
||||
const { visible } = e.detail;
|
||||
console.log('弹窗状态变化:', visible);
|
||||
|
||||
// 只有当弹窗被关闭时才触发父组件的状态更新
|
||||
if (!visible && this.data.couponsShow) {
|
||||
// 通知父组件关闭弹窗
|
||||
this.triggerEvent('close');
|
||||
}
|
||||
},
|
||||
async coupons(params = {}) {
|
||||
console.log('coupons方法被调用:', params);
|
||||
try {
|
||||
// 计算订单总金额
|
||||
const calculatedAmount = this.calculateOrderAmount();
|
||||
// 确保订单金额至少为1,避免后端验证错误
|
||||
const orderAmount = calculatedAmount > 0 ? calculatedAmount : 100;
|
||||
console.log('计算的订单金额:', calculatedAmount, '使用的订单金额:', orderAmount);
|
||||
|
||||
// 调用API获取可用优惠券
|
||||
const response = await request({
|
||||
url: `/coupons/order/available?order_amount=${orderAmount}`,
|
||||
method: 'GET'
|
||||
});
|
||||
|
||||
console.log('优惠券API响应:', response);
|
||||
|
||||
if (response.code === 200 && response.data) {
|
||||
const formattedData = this.formatCouponsData(response.data);
|
||||
console.log('格式化后的优惠券数据:', formattedData);
|
||||
|
||||
// 返回符合initData期望的格式
|
||||
return {
|
||||
couponResultList: formattedData.map(coupon => ({
|
||||
status: coupon.status === 'default' ? 1 : 0,
|
||||
id: coupon.id, // 用户优惠券ID
|
||||
couponVO: {
|
||||
couponId: coupon.couponId,
|
||||
name: coupon.name,
|
||||
type: coupon.type,
|
||||
value: coupon.value,
|
||||
condition: coupon.desc,
|
||||
startTime: coupon.startTime,
|
||||
endTime: coupon.endTime
|
||||
}
|
||||
})),
|
||||
reduce: 0
|
||||
};
|
||||
} else {
|
||||
console.error('获取优惠券失败:', response.message);
|
||||
return { couponResultList: [], reduce: 0 };
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取优惠券异常:', error);
|
||||
// 如果API调用失败,返回mock数据作为备选
|
||||
console.log('使用mock数据:', couponsData);
|
||||
return {
|
||||
couponResultList: couponsData.couponResultList || [],
|
||||
reduce: couponsData.reduce || 0
|
||||
};
|
||||
}
|
||||
},
|
||||
|
||||
// 计算订单总金额
|
||||
calculateOrderAmount() {
|
||||
const { promotionGoodsList } = this.data;
|
||||
let totalAmount = 0;
|
||||
|
||||
if (promotionGoodsList && promotionGoodsList.length > 0) {
|
||||
promotionGoodsList.forEach(store => {
|
||||
if (store.goodsList && store.goodsList.length > 0) {
|
||||
store.goodsList.forEach(item => {
|
||||
totalAmount += (item.price || 0) * (item.quantity || 1);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return totalAmount;
|
||||
},
|
||||
|
||||
// 格式化优惠券数据
|
||||
formatCouponsData(coupons) {
|
||||
const { orderSureCouponList } = this.data;
|
||||
console.log('formatCouponsData - orderSureCouponList:', orderSureCouponList);
|
||||
|
||||
return coupons.map(userCoupon => {
|
||||
const coupon = userCoupon.coupon;
|
||||
|
||||
// 检查当前优惠券是否在已选列表中
|
||||
const isSelected = orderSureCouponList && orderSureCouponList.some(selectedCoupon => {
|
||||
return selectedCoupon.key === userCoupon.id ||
|
||||
selectedCoupon.couponId === coupon.id ||
|
||||
selectedCoupon.id === userCoupon.id;
|
||||
});
|
||||
|
||||
console.log(`优惠券 ${coupon.name} (ID: ${coupon.id}) 是否已选: ${isSelected}`);
|
||||
|
||||
return {
|
||||
id: userCoupon.id,
|
||||
key: userCoupon.id, // 添加key字段用于选择
|
||||
couponId: coupon.id,
|
||||
name: coupon.name,
|
||||
title: coupon.name, // 添加title字段映射到name
|
||||
type: coupon.type,
|
||||
value: coupon.value, // 保持原始值,ui-coupon-card组件会自动除以100
|
||||
minAmount: coupon.min_amount,
|
||||
desc: this.getCouponDesc(coupon),
|
||||
timeLimit: this.formatTimeLimit(coupon.start_time, coupon.end_time),
|
||||
startTime: coupon.start_time,
|
||||
endTime: coupon.end_time,
|
||||
status: userCoupon.status === 0 ? 'default' : 'disabled',
|
||||
tag: '', // 添加tag字段
|
||||
isSelected: isSelected // 根据orderSureCouponList设置选中状态
|
||||
};
|
||||
});
|
||||
},
|
||||
|
||||
// 获取优惠券描述
|
||||
getCouponDesc(coupon) {
|
||||
if (coupon.type === 1) { // 满减券
|
||||
if (coupon.min_amount > 0) {
|
||||
return `满${coupon.min_amount/100}元减${coupon.value/100}元`;
|
||||
}
|
||||
return `立减${coupon.value/100}元`;
|
||||
} else if (coupon.type === 2) { // 折扣券
|
||||
return `${coupon.value/10}折`;
|
||||
} else if (coupon.type === 3) { // 免邮券
|
||||
return '免运费';
|
||||
}
|
||||
return coupon.description || '优惠券';
|
||||
},
|
||||
|
||||
// 格式化时间限制
|
||||
formatTimeLimit(startTime, endTime) {
|
||||
// 检查时间数据是否有效
|
||||
if (!startTime || !endTime) {
|
||||
console.warn('formatTimeLimit: 时间数据无效', { startTime, endTime });
|
||||
return '有效期待确认';
|
||||
}
|
||||
|
||||
try {
|
||||
// 处理不同格式的时间数据
|
||||
let start, end;
|
||||
|
||||
// 如果是时间戳(数字或数字字符串)
|
||||
if (typeof startTime === 'number' || (typeof startTime === 'string' && /^\d+$/.test(startTime))) {
|
||||
start = dayjs(Number(startTime));
|
||||
} else {
|
||||
start = dayjs(startTime);
|
||||
}
|
||||
|
||||
if (typeof endTime === 'number' || (typeof endTime === 'string' && /^\d+$/.test(endTime))) {
|
||||
end = dayjs(Number(endTime));
|
||||
} else {
|
||||
end = dayjs(endTime);
|
||||
}
|
||||
|
||||
// 验证日期是否有效
|
||||
if (!start.isValid() || !end.isValid()) {
|
||||
console.warn('formatTimeLimit: 日期解析失败', { startTime, endTime });
|
||||
return '有效期待确认';
|
||||
}
|
||||
|
||||
return `${start.format('YYYY.MM.DD')} - ${end.format('YYYY.MM.DD')}`;
|
||||
} catch (error) {
|
||||
console.error('formatTimeLimit: 格式化时间出错', error, { startTime, endTime });
|
||||
return '有效期待确认';
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {
|
||||
"t-popup": "tdesign-miniprogram/popup/popup",
|
||||
"t-icon": "tdesign-miniprogram/icon/icon",
|
||||
"t-image": "/components/webp-image/index",
|
||||
"wr-price": "/components/price/index",
|
||||
"coupon-card": "/components/promotion/ui-coupon-card/index"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
<wxs src="../selectCoupon.wxs" module="m1" />
|
||||
|
||||
|
||||
<t-popup visible="{{couponsShow}}" placement="bottom" bind:visible-change="onPopupVisibleChange">
|
||||
<view class="select-coupons">
|
||||
<view class="title">选择优惠券</view>
|
||||
<block wx:if="{{couponsList && couponsList.length > 0}}">
|
||||
<view class="info">
|
||||
<block wx:if="{{!selectedNum}}">你有{{couponsList.length}}张可用优惠券</block>
|
||||
<block wx:else>
|
||||
已选中{{selectedNum}}张推荐优惠券, 共抵扣
|
||||
<wr-price fill="{{false}}" price="{{reduce || 0}}" />
|
||||
</block>
|
||||
</view>
|
||||
<scroll-view class="coupons-list" scroll-y="true">
|
||||
<view class="coupons-wrap">
|
||||
<block wx:for="{{couponsList}}" wx:key="index" wx:for-item="coupon">
|
||||
<coupon-card
|
||||
title="{{coupon.title}}"
|
||||
type="{{coupon.type}}"
|
||||
status="{{coupon.status}}"
|
||||
desc="{{coupon.desc}}"
|
||||
value="{{coupon.value}}"
|
||||
tag="{{coupon.tag}}"
|
||||
timeLimit="{{coupon.timeLimit}}"
|
||||
>
|
||||
<view class="slot-radio" slot="operator">
|
||||
<t-icon bindtap="selectCoupon" data-key="{{coupon.key}}" name="{{coupon.isSelected ? 'check-circle-filled' : 'circle'}}" color="#fa4126" size="40rpx"/>
|
||||
</view>
|
||||
</coupon-card>
|
||||
<view class="disable" wx:if="{{coupon.status == 'useless'}}">此优惠券不能和已勾选的优惠券叠加使用</view>
|
||||
</block>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</block>
|
||||
<view wx:else class="couponp-empty-wrap">
|
||||
<t-image t-class="couponp-empty-img" src="{{emptyCouponImg}}" />
|
||||
<view class="couponp-empty-title">暂无优惠券</view>
|
||||
</view>
|
||||
<view class="coupons-cover" />
|
||||
</view>
|
||||
</t-popup>
|
||||
|
||||
@@ -0,0 +1,104 @@
|
||||
.select-coupons {
|
||||
background: #fff;
|
||||
width: 100%;
|
||||
position: relative;
|
||||
border-radius: 20rpx 20rpx 0 0;
|
||||
padding-top: 28rpx;
|
||||
padding-bottom: env(safe-area-inset-bottom);
|
||||
}
|
||||
.select-coupons .title {
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
font-size: 32rpx;
|
||||
color: #333;
|
||||
font-weight: 600;
|
||||
line-height: 44rpx;
|
||||
}
|
||||
.select-coupons .info {
|
||||
width: 100%;
|
||||
height: 34rpx;
|
||||
font-size: 24rpx;
|
||||
color: #999;
|
||||
line-height: 34rpx;
|
||||
margin: 20rpx 0;
|
||||
padding: 0 20rpx;
|
||||
}
|
||||
.select-coupons .info .price {
|
||||
color: #fa4126;
|
||||
}
|
||||
.select-coupons .coupons-list {
|
||||
max-height: 500rpx;
|
||||
}
|
||||
.select-coupons .coupons-list .coupons-wrap {
|
||||
padding: 0rpx 20rpx;
|
||||
}
|
||||
.select-coupons .coupons-list .disable {
|
||||
font-size: 24rpx;
|
||||
color: #ff2525;
|
||||
padding-top: 20rpx;
|
||||
}
|
||||
.select-coupons .coupons-list .slot-radio {
|
||||
position: absolute;
|
||||
right: 22rpx;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
display: inline-block;
|
||||
}
|
||||
.select-coupons .coupons-list .slot-radio .wr-check-filled {
|
||||
font-size: 36rpx;
|
||||
}
|
||||
.select-coupons .coupons-list .slot-radio .check {
|
||||
width: 36rpx;
|
||||
}
|
||||
.select-coupons .coupons-list .slot-radio .text-primary {
|
||||
color: #fa4126;
|
||||
}
|
||||
.select-coupons .coupons-list .slot-radio .wr-check {
|
||||
font-size: 36rpx;
|
||||
}
|
||||
.select-coupons .coupons-list .slot-radio .wr-uncheck {
|
||||
font-size: 36rpx;
|
||||
color: #999;
|
||||
}
|
||||
.select-coupons .couponp-empty-wrap {
|
||||
padding: 40rpx;
|
||||
}
|
||||
.select-coupons .couponp-empty-wrap .couponp-empty-img {
|
||||
display: block;
|
||||
width: 240rpx;
|
||||
height: 240rpx;
|
||||
margin: 0 auto;
|
||||
}
|
||||
.select-coupons .couponp-empty-wrap .couponp-empty-title {
|
||||
font-size: 28rpx;
|
||||
color: #999;
|
||||
text-align: center;
|
||||
line-height: 40rpx;
|
||||
margin-top: 40rpx;
|
||||
}
|
||||
.select-coupons .coupons-cover {
|
||||
height: 112rpx;
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
margin-top: 30rpx;
|
||||
padding: 12rpx 32rpx;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
.select-coupons .coupons-cover .btn {
|
||||
width: 332rpx;
|
||||
height: 88rpx;
|
||||
text-align: center;
|
||||
line-height: 88rpx;
|
||||
font-size: 32rpx;
|
||||
border-radius: 44rpx;
|
||||
box-sizing: border-box;
|
||||
border: 2rpx solid #dddddd;
|
||||
color: #333333;
|
||||
}
|
||||
.select-coupons .coupons-cover .red {
|
||||
border-color: #fa4126;
|
||||
background-color: #fa4126;
|
||||
color: #ffffff;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
export const couponsData = {
|
||||
couponResultList: [
|
||||
{
|
||||
couponVO: {
|
||||
condition: '满200元可用',
|
||||
couponId: 11,
|
||||
endTime: 1584530282686,
|
||||
name: '折扣券',
|
||||
profit: '5.5折',
|
||||
promotionCode: 90,
|
||||
promotionSubCode: 1,
|
||||
scopeText: '部分商品可用',
|
||||
startTime: 1584530282686,
|
||||
storeId: 90,
|
||||
value: 550,
|
||||
type: 2,
|
||||
},
|
||||
status: 0, // 0:未勾选。1:勾选。-1:置灰
|
||||
},
|
||||
],
|
||||
reduce: 1000,
|
||||
};
|
||||
@@ -0,0 +1,16 @@
|
||||
function formatDays(value) {
|
||||
if (value < 10) {
|
||||
return '0' + value;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
var dateFormat = function (d) {
|
||||
var date = getDate(+d);
|
||||
return (
|
||||
date.getFullYear() +
|
||||
'-' +
|
||||
formatDays(date.getMonth() + 1) +
|
||||
formatDays(date.getDate())
|
||||
);
|
||||
};
|
||||
module.exports.dateFormat = dateFormat;
|
||||
@@ -0,0 +1,362 @@
|
||||
import dayjs from 'dayjs';
|
||||
import { couponsData } from './mock';
|
||||
import { request } from '../../../../services/_utils/request';
|
||||
|
||||
const emptyCouponImg = `https://tdesign.gtimg.com/miniprogram/template/retail/coupon/ordersure-coupon-newempty.png`;
|
||||
|
||||
Component({
|
||||
properties: {
|
||||
storeId: String,
|
||||
promotionGoodsList: {
|
||||
type: Array,
|
||||
value: [],
|
||||
},
|
||||
orderSureCouponList: {
|
||||
type: Array,
|
||||
value: [],
|
||||
},
|
||||
couponsShow: {
|
||||
type: Boolean,
|
||||
value: false,
|
||||
observer(couponsShow) {
|
||||
console.log('selectCoupons observer 触发:', { couponsShow });
|
||||
if (couponsShow) {
|
||||
console.log('开始处理优惠券显示逻辑');
|
||||
const { promotionGoodsList, orderSureCouponList, storeId } = this.data;
|
||||
console.log('组件数据:', { promotionGoodsList, orderSureCouponList, storeId });
|
||||
const products =
|
||||
promotionGoodsList &&
|
||||
promotionGoodsList.map((goods) => {
|
||||
this.storeId = goods.storeId;
|
||||
return {
|
||||
skuId: goods.skuId,
|
||||
spuId: goods.spuId,
|
||||
storeId: goods.storeId,
|
||||
selected: true,
|
||||
quantity: goods.num,
|
||||
prices: {
|
||||
sale: goods.settlePrice,
|
||||
},
|
||||
};
|
||||
});
|
||||
const selectedCoupons =
|
||||
orderSureCouponList &&
|
||||
orderSureCouponList.map((ele) => {
|
||||
return {
|
||||
promotionId: ele.promotionId,
|
||||
storeId: ele.storeId,
|
||||
couponId: ele.couponId,
|
||||
};
|
||||
});
|
||||
this.setData({
|
||||
products,
|
||||
});
|
||||
this.coupons({
|
||||
products,
|
||||
selectedCoupons,
|
||||
storeId,
|
||||
}).then((res) => {
|
||||
this.initData(res);
|
||||
});
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
data: {
|
||||
emptyCouponImg,
|
||||
goodsList: [],
|
||||
selectedList: [],
|
||||
couponsList: [],
|
||||
orderSureCouponList: [],
|
||||
promotionGoodsList: [],
|
||||
// 新增:临时选择状态,用于确认前的预览
|
||||
tempSelectedList: [],
|
||||
},
|
||||
lifetimes: {
|
||||
attached() {
|
||||
console.log('selectCoupons组件已挂载');
|
||||
},
|
||||
ready() {
|
||||
console.log('selectCoupons组件已准备就绪');
|
||||
console.log('组件属性值:', {
|
||||
couponsShow: this.properties.couponsShow,
|
||||
storeId: this.properties.storeId,
|
||||
promotionGoodsListLength: this.properties.promotionGoodsList.length,
|
||||
orderSureCouponListLength: this.properties.orderSureCouponList.length
|
||||
});
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
initData(data = {}) {
|
||||
console.log('initData方法被调用:', data);
|
||||
const { couponResultList = [], reduce = 0 } = data;
|
||||
const { orderSureCouponList } = this.data;
|
||||
console.log('initData - orderSureCouponList:', orderSureCouponList);
|
||||
|
||||
const selectedList = [];
|
||||
let selectedNum = 0;
|
||||
const couponsList =
|
||||
couponResultList &&
|
||||
couponResultList.map((coupon) => {
|
||||
const { status, couponVO } = coupon;
|
||||
const { couponId, condition = '', endTime = 0, name = '', startTime = 0, value, type } = couponVO;
|
||||
|
||||
// 检查当前优惠券是否在已选列表中
|
||||
const isSelected = orderSureCouponList && orderSureCouponList.some(selectedCoupon => {
|
||||
return selectedCoupon.key === coupon.id ||
|
||||
selectedCoupon.couponId === couponId ||
|
||||
selectedCoupon.id === coupon.id;
|
||||
});
|
||||
|
||||
if (isSelected) {
|
||||
selectedNum += 1;
|
||||
selectedList.push({
|
||||
userCouponId: coupon.id,
|
||||
id: coupon.id,
|
||||
couponId: couponId,
|
||||
key: coupon.id,
|
||||
promotionId: couponId,
|
||||
storeId: this.storeId,
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
id: coupon.id, // 用户优惠券ID
|
||||
couponId: couponId, // 优惠券模板ID
|
||||
key: coupon.id,
|
||||
title: name,
|
||||
type: type === 1 ? 'price' : 'discount',
|
||||
status: status === 1 ? 'default' : 'useless',
|
||||
desc: this.getCouponDesc({ condition, type, value }),
|
||||
value: type === 1 ? value / 100 : value / 10,
|
||||
tag: '',
|
||||
timeLimit: this.formatTimeLimit(startTime, endTime),
|
||||
isSelected: isSelected,
|
||||
};
|
||||
});
|
||||
|
||||
this.setData({
|
||||
couponsList,
|
||||
selectedList,
|
||||
tempSelectedList: [...selectedList], // 初始化临时选择状态
|
||||
selectedNum,
|
||||
reduce,
|
||||
});
|
||||
|
||||
console.log('initData完成:', {
|
||||
couponsList: couponsList.length,
|
||||
selectedList: selectedList.length,
|
||||
selectedNum,
|
||||
reduce
|
||||
});
|
||||
},
|
||||
|
||||
// 修改:只更新选择状态,不立即触发确认
|
||||
selectCoupon(e) {
|
||||
const { key } = e.currentTarget.dataset;
|
||||
const { couponsList } = this.data;
|
||||
|
||||
console.log('用户点击优惠券:', { key });
|
||||
|
||||
// 先清除所有选中状态(假设一次只能选择一张优惠券)
|
||||
couponsList.forEach((coupon) => {
|
||||
coupon.isSelected = false;
|
||||
});
|
||||
|
||||
// 设置当前选中的优惠券
|
||||
const selectedCoupon = couponsList.find((coupon) => coupon.key === key);
|
||||
if (selectedCoupon) {
|
||||
selectedCoupon.isSelected = true;
|
||||
}
|
||||
|
||||
const couponSelected = couponsList.filter((coupon) => coupon.isSelected === true);
|
||||
|
||||
// 转换为后端期望的数据格式,但暂存到临时状态
|
||||
const tempSelectedList = couponSelected.map(coupon => ({
|
||||
userCouponId: coupon.id,
|
||||
id: coupon.id,
|
||||
couponId: coupon.couponId,
|
||||
key: coupon.key,
|
||||
promotionId: coupon.couponId,
|
||||
storeId: this.storeId,
|
||||
_debug: {
|
||||
originalCoupon: coupon,
|
||||
userCouponId: coupon.id,
|
||||
couponTemplateId: coupon.couponId
|
||||
}
|
||||
}));
|
||||
|
||||
this.setData({
|
||||
tempSelectedList,
|
||||
couponsList: [...couponsList],
|
||||
selectedNum: couponSelected.length,
|
||||
});
|
||||
|
||||
console.log('优惠券选择状态更新:', {
|
||||
selectedKey: key,
|
||||
selectedCoupon,
|
||||
tempSelectedList
|
||||
});
|
||||
},
|
||||
|
||||
// 新增:确认选择
|
||||
onConfirm() {
|
||||
const { tempSelectedList } = this.data;
|
||||
|
||||
console.log('用户确认选择优惠券:', tempSelectedList);
|
||||
|
||||
this.setData({
|
||||
selectedList: [...tempSelectedList],
|
||||
});
|
||||
|
||||
// 触发确认事件
|
||||
this.triggerEvent('sure', {
|
||||
selectedList: tempSelectedList,
|
||||
});
|
||||
|
||||
// 关闭弹窗
|
||||
this.hide();
|
||||
},
|
||||
|
||||
// 新增:取消选择
|
||||
onCancel() {
|
||||
console.log('用户取消选择优惠券');
|
||||
|
||||
// 恢复到之前的选择状态
|
||||
const { selectedList } = this.data;
|
||||
this.restoreSelectionState(selectedList);
|
||||
|
||||
// 关闭弹窗
|
||||
this.hide();
|
||||
},
|
||||
|
||||
// 新增:恢复选择状态
|
||||
restoreSelectionState(selectedList) {
|
||||
const { couponsList } = this.data;
|
||||
|
||||
// 重置所有优惠券的选中状态
|
||||
couponsList.forEach((coupon) => {
|
||||
coupon.isSelected = selectedList.some(selected => selected.key === coupon.key);
|
||||
});
|
||||
|
||||
this.setData({
|
||||
couponsList: [...couponsList],
|
||||
tempSelectedList: [...selectedList],
|
||||
selectedNum: selectedList.length,
|
||||
});
|
||||
},
|
||||
|
||||
hide() {
|
||||
this.setData({
|
||||
couponsShow: false,
|
||||
});
|
||||
this.triggerEvent('close');
|
||||
},
|
||||
|
||||
onPopupVisibleChange(e) {
|
||||
const { visible } = e.detail;
|
||||
console.log('弹窗可见性变化:', visible);
|
||||
if (!visible) {
|
||||
this.hide();
|
||||
}
|
||||
},
|
||||
|
||||
async coupons(params = {}) {
|
||||
console.log('coupons方法被调用:', params);
|
||||
const { products = [], selectedCoupons = [], storeId } = params;
|
||||
|
||||
try {
|
||||
const requestData = {
|
||||
products,
|
||||
selectedCoupons,
|
||||
storeId,
|
||||
};
|
||||
console.log('发送优惠券请求:', requestData);
|
||||
|
||||
const result = await request({
|
||||
url: '/promotion/coupons',
|
||||
method: 'POST',
|
||||
data: requestData,
|
||||
});
|
||||
|
||||
console.log('优惠券API响应:', result);
|
||||
|
||||
if (result && result.data) {
|
||||
const formattedData = this.formatCouponsData(result.data);
|
||||
console.log('格式化后的优惠券数据:', formattedData);
|
||||
return formattedData;
|
||||
} else {
|
||||
console.warn('优惠券API返回数据格式异常:', result);
|
||||
return { couponResultList: [], reduce: 0 };
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取优惠券失败:', error);
|
||||
return { couponResultList: [], reduce: 0 };
|
||||
}
|
||||
},
|
||||
|
||||
calculateOrderAmount() {
|
||||
const { products } = this.data;
|
||||
if (!products || products.length === 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return products.reduce((total, product) => {
|
||||
return total + (product.prices.sale * product.quantity);
|
||||
}, 0);
|
||||
},
|
||||
|
||||
formatCouponsData(data) {
|
||||
if (!data || !Array.isArray(data.couponResultList)) {
|
||||
console.warn('优惠券数据格式错误:', data);
|
||||
return { couponResultList: [], reduce: 0 };
|
||||
}
|
||||
|
||||
const { couponResultList, reduce = 0 } = data;
|
||||
|
||||
console.log('格式化优惠券数据:', {
|
||||
原始数据: couponResultList,
|
||||
优惠金额: reduce
|
||||
});
|
||||
|
||||
return {
|
||||
couponResultList: couponResultList.map(coupon => {
|
||||
const formatted = {
|
||||
...coupon,
|
||||
id: coupon.id || coupon.userCouponId,
|
||||
status: coupon.status || 1,
|
||||
couponVO: {
|
||||
...coupon.couponVO,
|
||||
value: coupon.couponVO.value || 0,
|
||||
type: coupon.couponVO.type || 1,
|
||||
}
|
||||
};
|
||||
console.log('格式化单个优惠券:', { 原始: coupon, 格式化: formatted });
|
||||
return formatted;
|
||||
}),
|
||||
reduce
|
||||
};
|
||||
},
|
||||
|
||||
getCouponDesc(coupon) {
|
||||
const { condition, type, value } = coupon;
|
||||
if (type === 1) {
|
||||
// 满减券
|
||||
return condition ? `满${condition / 100}元可用` : '无门槛使用';
|
||||
} else {
|
||||
// 折扣券
|
||||
return condition ? `满${condition / 100}元可用` : '无门槛使用';
|
||||
}
|
||||
},
|
||||
|
||||
formatTimeLimit(startTime, endTime) {
|
||||
if (!startTime || !endTime) {
|
||||
return '永久有效';
|
||||
}
|
||||
|
||||
const start = dayjs(startTime).format('YYYY.MM.DD');
|
||||
const end = dayjs(endTime).format('YYYY.MM.DD');
|
||||
return `${start}-${end}`;
|
||||
},
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,50 @@
|
||||
<wxs src="./selectCoupon.wxs" module="m1" />
|
||||
|
||||
<t-popup visible="{{couponsShow}}" placement="bottom" bind:visible-change="onPopupVisibleChange">
|
||||
<view class="select-coupons">
|
||||
<view class="title">选择优惠券</view>
|
||||
<block wx:if="{{couponsList && couponsList.length > 0}}">
|
||||
<view class="info">
|
||||
<block wx:if="{{!selectedNum}}">你有{{couponsList.length}}张可用优惠券</block>
|
||||
<block wx:else>
|
||||
已选中{{selectedNum}}张推荐优惠券, 共抵扣
|
||||
<wr-price fill="{{false}}" price="{{reduce || 0}}" />
|
||||
</block>
|
||||
</view>
|
||||
<scroll-view class="coupons-list" scroll-y="true">
|
||||
<view class="coupons-wrap">
|
||||
<block wx:for="{{couponsList}}" wx:key="index" wx:for-item="coupon">
|
||||
<coupon-card
|
||||
title="{{coupon.title}}"
|
||||
type="{{coupon.type}}"
|
||||
status="{{coupon.status}}"
|
||||
desc="{{coupon.desc}}"
|
||||
value="{{coupon.value}}"
|
||||
tag="{{coupon.tag}}"
|
||||
timeLimit="{{coupon.timeLimit}}"
|
||||
>
|
||||
<view class="slot-radio" slot="operator">
|
||||
<t-icon bindtap="selectCoupon" data-key="{{coupon.key}}" name="{{coupon.isSelected ? 'check-circle-filled' : 'circle'}}" color="#fa4126" size="40rpx"/>
|
||||
</view>
|
||||
</coupon-card>
|
||||
<view class="disable" wx:if="{{coupon.status == 'useless'}}">此优惠券不能和已勾选的优惠券叠加使用</view>
|
||||
</block>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</block>
|
||||
<view wx:else class="couponp-empty-wrap">
|
||||
<t-image t-class="couponp-empty-img" src="{{emptyCouponImg}}" />
|
||||
<view class="couponp-empty-title">暂无优惠券</view>
|
||||
</view>
|
||||
|
||||
<!-- 添加确认按钮区域 -->
|
||||
<view class="coupons-actions">
|
||||
<view class="action-buttons">
|
||||
<view class="cancel-btn" bindtap="onCancel">取消</view>
|
||||
<view class="confirm-btn" bindtap="onConfirm">确定</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="coupons-cover" />
|
||||
</view>
|
||||
</t-popup>
|
||||
@@ -0,0 +1,142 @@
|
||||
.select-coupons {
|
||||
background: #fff;
|
||||
width: 100%;
|
||||
position: relative;
|
||||
border-radius: 20rpx 20rpx 0 0;
|
||||
padding-top: 28rpx;
|
||||
padding-bottom: env(safe-area-inset-bottom);
|
||||
}
|
||||
.select-coupons .title {
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
font-size: 32rpx;
|
||||
color: #333;
|
||||
font-weight: 600;
|
||||
line-height: 44rpx;
|
||||
}
|
||||
.select-coupons .info {
|
||||
width: 100%;
|
||||
height: 34rpx;
|
||||
font-size: 24rpx;
|
||||
color: #999;
|
||||
line-height: 34rpx;
|
||||
margin: 20rpx 0;
|
||||
padding: 0 20rpx;
|
||||
}
|
||||
.select-coupons .info .price {
|
||||
color: #fa4126;
|
||||
}
|
||||
.select-coupons .coupons-list {
|
||||
max-height: 500rpx;
|
||||
}
|
||||
.select-coupons .coupons-list .coupons-wrap {
|
||||
padding: 0rpx 20rpx;
|
||||
}
|
||||
.select-coupons .coupons-list .disable {
|
||||
font-size: 24rpx;
|
||||
color: #ff2525;
|
||||
padding-top: 20rpx;
|
||||
}
|
||||
.select-coupons .coupons-list .slot-radio {
|
||||
position: absolute;
|
||||
right: 22rpx;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
display: inline-block;
|
||||
}
|
||||
.select-coupons .coupons-list .slot-radio .wr-check-filled {
|
||||
font-size: 36rpx;
|
||||
}
|
||||
.select-coupons .coupons-list .slot-radio .check {
|
||||
width: 36rpx;
|
||||
}
|
||||
.select-coupons .coupons-list .slot-radio .text-primary {
|
||||
color: #fa4126;
|
||||
}
|
||||
.select-coupons .coupons-list .slot-radio .wr-check {
|
||||
font-size: 36rpx;
|
||||
}
|
||||
.select-coupons .coupons-list .slot-radio .wr-uncheck {
|
||||
font-size: 36rpx;
|
||||
color: #999;
|
||||
}
|
||||
.select-coupons .couponp-empty-wrap {
|
||||
padding: 40rpx;
|
||||
}
|
||||
.select-coupons .couponp-empty-wrap .couponp-empty-img {
|
||||
display: block;
|
||||
width: 240rpx;
|
||||
height: 240rpx;
|
||||
margin: 0 auto;
|
||||
}
|
||||
.select-coupons .couponp-empty-wrap .couponp-empty-title {
|
||||
font-size: 28rpx;
|
||||
color: #999;
|
||||
text-align: center;
|
||||
line-height: 40rpx;
|
||||
margin-top: 40rpx;
|
||||
}
|
||||
|
||||
/* 新增:确认按钮区域样式 */
|
||||
.select-coupons .coupons-actions {
|
||||
width: 100%;
|
||||
padding: 20rpx 32rpx 32rpx;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.select-coupons .action-buttons {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
gap: 20rpx;
|
||||
}
|
||||
|
||||
.select-coupons .cancel-btn,
|
||||
.select-coupons .confirm-btn {
|
||||
flex: 1;
|
||||
height: 88rpx;
|
||||
text-align: center;
|
||||
line-height: 88rpx;
|
||||
font-size: 32rpx;
|
||||
border-radius: 44rpx;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.select-coupons .cancel-btn {
|
||||
border: 2rpx solid #dddddd;
|
||||
color: #333333;
|
||||
background-color: #ffffff;
|
||||
}
|
||||
|
||||
.select-coupons .confirm-btn {
|
||||
border: 2rpx solid #fa4126;
|
||||
background-color: #fa4126;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.select-coupons .coupons-cover {
|
||||
height: 112rpx;
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
margin-top: 30rpx;
|
||||
padding: 12rpx 32rpx;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
.select-coupons .coupons-cover .btn {
|
||||
width: 332rpx;
|
||||
height: 88rpx;
|
||||
text-align: center;
|
||||
line-height: 88rpx;
|
||||
font-size: 32rpx;
|
||||
border-radius: 44rpx;
|
||||
box-sizing: border-box;
|
||||
border: 2rpx solid #dddddd;
|
||||
color: #333333;
|
||||
}
|
||||
.select-coupons .coupons-cover .red {
|
||||
border-color: #fa4126;
|
||||
background-color: #fa4126;
|
||||
color: #ffffff;
|
||||
}
|
||||
@@ -0,0 +1,451 @@
|
||||
import dayjs from 'dayjs';
|
||||
import { request } from '../../../../services/_utils/request';
|
||||
|
||||
const emptyCouponImg = `https://tdesign.gtimg.com/miniprogram/template/retail/coupon/ordersure-coupon-newempty.png`;
|
||||
|
||||
Component({
|
||||
properties: {
|
||||
storeId: String,
|
||||
promotionGoodsList: {
|
||||
type: Array,
|
||||
value: [],
|
||||
},
|
||||
orderSureCouponList: {
|
||||
type: Array,
|
||||
value: [],
|
||||
},
|
||||
couponsShow: {
|
||||
type: Boolean,
|
||||
value: false,
|
||||
observer(couponsShow) {
|
||||
console.log('selectCoupons observer 触发:', { couponsShow });
|
||||
if (couponsShow) {
|
||||
console.log('开始处理优惠券显示逻辑');
|
||||
const { promotionGoodsList, orderSureCouponList, storeId } = this.data;
|
||||
console.log('组件数据:', { promotionGoodsList, orderSureCouponList, storeId });
|
||||
const products =
|
||||
promotionGoodsList &&
|
||||
promotionGoodsList.map((goods) => {
|
||||
this.storeId = goods.storeId;
|
||||
return {
|
||||
skuId: goods.skuId,
|
||||
spuId: goods.spuId,
|
||||
storeId: goods.storeId,
|
||||
selected: true,
|
||||
quantity: goods.num,
|
||||
prices: {
|
||||
sale: goods.settlePrice,
|
||||
},
|
||||
};
|
||||
});
|
||||
const selectedCoupons =
|
||||
orderSureCouponList &&
|
||||
orderSureCouponList.map((ele) => {
|
||||
return {
|
||||
promotionId: ele.promotionId,
|
||||
storeId: ele.storeId,
|
||||
couponId: ele.couponId,
|
||||
};
|
||||
});
|
||||
this.setData({
|
||||
products,
|
||||
});
|
||||
this.coupons({
|
||||
products,
|
||||
selectedCoupons,
|
||||
storeId,
|
||||
}).then((res) => {
|
||||
this.initData(res);
|
||||
});
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
data: {
|
||||
emptyCouponImg,
|
||||
goodsList: [],
|
||||
selectedList: [],
|
||||
tempSelectedList: [], // 临时选择状态,用于确认前的预览
|
||||
couponsList: [],
|
||||
orderSureCouponList: [],
|
||||
promotionGoodsList: [],
|
||||
},
|
||||
lifetimes: {
|
||||
attached() {
|
||||
console.log('selectCoupons组件已挂载');
|
||||
},
|
||||
ready() {
|
||||
console.log('selectCoupons组件已准备就绪');
|
||||
console.log('组件属性值:', {
|
||||
couponsShow: this.properties.couponsShow,
|
||||
storeId: this.properties.storeId,
|
||||
promotionGoodsListLength: this.properties.promotionGoodsList.length,
|
||||
orderSureCouponListLength: this.properties.orderSureCouponList.length
|
||||
});
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
initData(data = {}) {
|
||||
console.log('initData方法被调用:', data);
|
||||
const { couponResultList = [], reduce = 0 } = data;
|
||||
const { orderSureCouponList } = this.data;
|
||||
console.log('initData - orderSureCouponList:', orderSureCouponList);
|
||||
|
||||
const selectedList = [];
|
||||
let selectedNum = 0;
|
||||
const couponsList =
|
||||
couponResultList &&
|
||||
couponResultList.map((coupon) => {
|
||||
const { status, couponVO } = coupon;
|
||||
const { couponId, condition = '', endTime = 0, name = '', startTime = 0, value, type } = couponVO;
|
||||
|
||||
// 检查当前优惠券是否在已选列表中
|
||||
const isSelected = orderSureCouponList && orderSureCouponList.some(selectedCoupon => {
|
||||
return selectedCoupon.key === couponId ||
|
||||
selectedCoupon.couponId === couponId ||
|
||||
selectedCoupon.id === couponId;
|
||||
});
|
||||
|
||||
console.log(`initData - 优惠券 ${name} (ID: ${couponId}) 是否已选: ${isSelected}`);
|
||||
|
||||
if (isSelected) {
|
||||
selectedNum++;
|
||||
selectedList.push({
|
||||
userCouponId: coupon.id, // 用户优惠券ID,用于后端验证所有权
|
||||
id: coupon.id, // 保持兼容性
|
||||
couponId,
|
||||
promotionId: couponId, // 使用couponId作为promotionId
|
||||
storeId: this.storeId,
|
||||
key: couponId,
|
||||
// 添加调试信息
|
||||
_debug: {
|
||||
userCouponId: coupon.id,
|
||||
couponTemplateId: couponId
|
||||
}
|
||||
});
|
||||
}
|
||||
const val = value; // 直接使用原始值,ui-coupon-card组件会自动处理单位转换
|
||||
return {
|
||||
id: coupon.id, // 用户优惠券ID,用于后端验证所有权
|
||||
key: couponId, // 保持原有的key逻辑
|
||||
couponId: couponId, // 优惠券模板ID
|
||||
title: name,
|
||||
isSelected: isSelected,
|
||||
timeLimit: this.formatTimeLimit(startTime, endTime),
|
||||
value: val,
|
||||
status: status === -1 ? 'useless' : 'default',
|
||||
desc: condition,
|
||||
type,
|
||||
tag: '',
|
||||
};
|
||||
});
|
||||
console.log('initData设置数据:', { selectedList, couponsList, reduce, selectedNum });
|
||||
this.setData({
|
||||
selectedList,
|
||||
couponsList,
|
||||
reduce,
|
||||
selectedNum,
|
||||
});
|
||||
},
|
||||
selectCoupon(e) {
|
||||
const { key } = e.currentTarget.dataset;
|
||||
const { couponsList } = this.data;
|
||||
|
||||
// 先清除所有选中状态(假设一次只能选择一张优惠券)
|
||||
couponsList.forEach((coupon) => {
|
||||
coupon.isSelected = false;
|
||||
});
|
||||
|
||||
// 设置当前选中的优惠券
|
||||
const selectedCoupon = couponsList.find((coupon) => coupon.key === key);
|
||||
if (selectedCoupon) {
|
||||
selectedCoupon.isSelected = true;
|
||||
}
|
||||
|
||||
const couponSelected = couponsList.filter((coupon) => coupon.isSelected === true);
|
||||
|
||||
// 转换为后端期望的数据格式,但只存储到临时状态
|
||||
const tempSelectedListForBackend = couponSelected.map(coupon => ({
|
||||
userCouponId: coupon.userCouponId || coupon.id, // 用户优惠券ID,用于后端验证所有权
|
||||
id: coupon.id, // 保持兼容性
|
||||
couponId: coupon.couponId, // 优惠券模板ID,用于获取优惠券信息
|
||||
key: coupon.key,
|
||||
promotionId: coupon.couponId, // 使用couponId作为promotionId
|
||||
storeId: this.storeId,
|
||||
// 添加调试信息
|
||||
_debug: {
|
||||
originalCoupon: coupon,
|
||||
userCouponId: coupon.userCouponId || coupon.id,
|
||||
couponTemplateId: coupon.couponId
|
||||
}
|
||||
}));
|
||||
|
||||
// 只更新临时选择状态和UI显示,不触发sure事件
|
||||
this.setData({
|
||||
tempSelectedList: tempSelectedListForBackend,
|
||||
couponsList: [...couponsList],
|
||||
});
|
||||
|
||||
console.log('优惠券临时选择:', {
|
||||
selectedKey: key,
|
||||
selectedCoupon,
|
||||
couponSelected,
|
||||
tempSelectedListForBackend
|
||||
});
|
||||
},
|
||||
hide() {
|
||||
this.setData({
|
||||
couponsShow: false,
|
||||
});
|
||||
},
|
||||
onPopupVisibleChange(e) {
|
||||
const { visible } = e.detail;
|
||||
console.log('弹窗状态变化:', visible);
|
||||
|
||||
// 只有当弹窗被关闭时才触发父组件的状态更新
|
||||
if (!visible && this.data.couponsShow) {
|
||||
// 通知父组件关闭弹窗
|
||||
this.triggerEvent('close');
|
||||
}
|
||||
},
|
||||
async coupons(params = {}) {
|
||||
console.log('coupons方法被调用:', params);
|
||||
try {
|
||||
// 计算订单总金额
|
||||
const calculatedAmount = this.calculateOrderAmount();
|
||||
// 确保订单金额至少为1,避免后端验证错误
|
||||
const orderAmount = calculatedAmount > 0 ? calculatedAmount : 100;
|
||||
console.log('计算的订单金额:', calculatedAmount, '使用的订单金额:', orderAmount);
|
||||
|
||||
// 调用API获取可用优惠券
|
||||
const response = await request({
|
||||
url: `/coupons/order/available?order_amount=${orderAmount}`,
|
||||
method: 'GET'
|
||||
});
|
||||
|
||||
console.log('优惠券API响应:', response);
|
||||
|
||||
if (response.code === 200 && response.data) {
|
||||
const formattedData = this.formatCouponsData(response.data);
|
||||
console.log('格式化后的优惠券数据:', formattedData);
|
||||
|
||||
// 返回符合initData期望的格式
|
||||
return {
|
||||
couponResultList: formattedData.map(coupon => ({
|
||||
status: coupon.status === 'default' ? 1 : 0,
|
||||
id: coupon.id, // 用户优惠券ID
|
||||
couponVO: {
|
||||
couponId: coupon.couponId,
|
||||
name: coupon.name,
|
||||
type: coupon.type,
|
||||
value: coupon.value,
|
||||
condition: coupon.desc,
|
||||
startTime: coupon.startTime,
|
||||
endTime: coupon.endTime
|
||||
}
|
||||
})),
|
||||
reduce: 0
|
||||
};
|
||||
} else {
|
||||
console.error('获取优惠券失败:', response.message);
|
||||
return { couponResultList: [], reduce: 0 };
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取优惠券异常:', error);
|
||||
// 如果API调用失败,返回空数据而不是mock数据
|
||||
// 避免使用硬编码的优惠券ID导致权限错误
|
||||
console.log('API调用失败,返回空优惠券列表');
|
||||
return {
|
||||
couponResultList: [],
|
||||
reduce: 0
|
||||
};
|
||||
}
|
||||
},
|
||||
|
||||
// 计算订单总金额
|
||||
calculateOrderAmount() {
|
||||
const { promotionGoodsList } = this.data;
|
||||
let totalAmount = 0;
|
||||
|
||||
if (promotionGoodsList && promotionGoodsList.length > 0) {
|
||||
promotionGoodsList.forEach(store => {
|
||||
if (store.goodsList && store.goodsList.length > 0) {
|
||||
store.goodsList.forEach(item => {
|
||||
totalAmount += (item.price || 0) * (item.quantity || 1);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return totalAmount;
|
||||
},
|
||||
|
||||
// 格式化优惠券数据
|
||||
formatCouponsData(coupons) {
|
||||
const { orderSureCouponList } = this.data;
|
||||
console.log('formatCouponsData - orderSureCouponList:', orderSureCouponList);
|
||||
|
||||
return coupons.map(userCoupon => {
|
||||
const coupon = userCoupon.coupon;
|
||||
|
||||
// 检查当前优惠券是否在已选列表中
|
||||
const isSelected = orderSureCouponList && orderSureCouponList.some(selectedCoupon => {
|
||||
return selectedCoupon.key === userCoupon.id ||
|
||||
selectedCoupon.couponId === coupon.id ||
|
||||
selectedCoupon.id === userCoupon.id;
|
||||
});
|
||||
|
||||
console.log(`优惠券 ${coupon.name} (ID: ${coupon.id}) 是否已选: ${isSelected}`);
|
||||
|
||||
return {
|
||||
id: userCoupon.id,
|
||||
key: userCoupon.id, // 添加key字段用于选择
|
||||
userCouponId: userCoupon.id, // 确保userCouponId字段存在,这是用户优惠券表的主键
|
||||
couponId: coupon.id, // 优惠券模板ID
|
||||
name: coupon.name,
|
||||
title: coupon.name, // 添加title字段映射到name
|
||||
type: coupon.type,
|
||||
value: coupon.value, // 保持原始值,ui-coupon-card组件会自动除以100
|
||||
minAmount: coupon.min_amount,
|
||||
desc: this.getCouponDesc(coupon),
|
||||
timeLimit: this.formatTimeLimit(coupon.start_time, coupon.end_time),
|
||||
startTime: coupon.start_time,
|
||||
endTime: coupon.end_time,
|
||||
status: userCoupon.status === 0 ? 'default' : 'disabled',
|
||||
tag: '', // 添加tag字段
|
||||
isSelected: isSelected // 根据orderSureCouponList设置选中状态
|
||||
};
|
||||
});
|
||||
},
|
||||
|
||||
// 获取优惠券描述
|
||||
getCouponDesc(coupon) {
|
||||
if (coupon.type === 1) { // 满减券
|
||||
if (coupon.min_amount > 0) {
|
||||
return `满${coupon.min_amount/100}元减${coupon.value/100}元`;
|
||||
}
|
||||
return `立减${coupon.value/100}元`;
|
||||
} else if (coupon.type === 2) { // 折扣券
|
||||
return `${coupon.value/10}折`;
|
||||
} else if (coupon.type === 3) { // 免邮券
|
||||
return '免运费';
|
||||
}
|
||||
return coupon.description || '优惠券';
|
||||
},
|
||||
|
||||
// 格式化时间限制
|
||||
formatTimeLimit(startTime, endTime) {
|
||||
// 检查时间数据是否有效
|
||||
if (!startTime || !endTime) {
|
||||
console.warn('formatTimeLimit: 时间数据无效', { startTime, endTime });
|
||||
return '有效期待确认';
|
||||
}
|
||||
|
||||
try {
|
||||
// 处理不同格式的时间数据
|
||||
let start, end;
|
||||
|
||||
// 如果是时间戳(数字或数字字符串)
|
||||
if (typeof startTime === 'number' || (typeof startTime === 'string' && /^\d+$/.test(startTime))) {
|
||||
start = dayjs(Number(startTime));
|
||||
} else {
|
||||
start = dayjs(startTime);
|
||||
}
|
||||
|
||||
if (typeof endTime === 'number' || (typeof endTime === 'string' && /^\d+$/.test(endTime))) {
|
||||
end = dayjs(Number(endTime));
|
||||
} else {
|
||||
end = dayjs(endTime);
|
||||
}
|
||||
|
||||
// 验证日期是否有效
|
||||
if (!start.isValid() || !end.isValid()) {
|
||||
console.warn('formatTimeLimit: 日期解析失败', { startTime, endTime });
|
||||
return '有效期待确认';
|
||||
}
|
||||
|
||||
return `${start.format('YYYY.MM.DD')} - ${end.format('YYYY.MM.DD')}`;
|
||||
} catch (error) {
|
||||
console.error('formatTimeLimit: 格式化时间出错', error, { startTime, endTime });
|
||||
return '有效期待确认';
|
||||
}
|
||||
},
|
||||
|
||||
// 确认选择优惠券
|
||||
onConfirm() {
|
||||
const { tempSelectedList, couponsList } = this.data;
|
||||
|
||||
console.log('确认选择优惠券:', { tempSelectedList });
|
||||
|
||||
// 为传递给后端的优惠券数据添加完整字段
|
||||
const completeSelectedList = tempSelectedList.map(selectedCoupon => {
|
||||
// 从couponsList中找到对应的完整优惠券信息
|
||||
const fullCouponInfo = couponsList.find(coupon => coupon.key === selectedCoupon.key);
|
||||
|
||||
return {
|
||||
...selectedCoupon,
|
||||
// 确保userCouponId字段正确传递(这是用户优惠券表的ID,用于后端验证权限)
|
||||
userCouponId: selectedCoupon.userCouponId || selectedCoupon.id,
|
||||
// 添加后端计算折扣所需的关键字段
|
||||
status: 'default', // 确保状态为default,这样后端才会计算折扣
|
||||
type: fullCouponInfo ? fullCouponInfo.type : 1, // 优惠券类型
|
||||
value: fullCouponInfo ? fullCouponInfo.value : 0, // 优惠券面值
|
||||
name: fullCouponInfo ? fullCouponInfo.title : '', // 优惠券名称
|
||||
desc: fullCouponInfo ? fullCouponInfo.desc : '', // 优惠券描述
|
||||
};
|
||||
});
|
||||
|
||||
console.log('完整的优惠券数据:', { completeSelectedList });
|
||||
console.log('优惠券ID字段检查:', completeSelectedList.map(coupon => ({
|
||||
userCouponId: coupon.userCouponId,
|
||||
id: coupon.id,
|
||||
couponId: coupon.couponId
|
||||
})));
|
||||
|
||||
// 将临时选择状态应用到正式状态
|
||||
this.setData({
|
||||
selectedList: completeSelectedList,
|
||||
});
|
||||
|
||||
// 触发sure事件,通知父组件
|
||||
this.triggerEvent('sure', {
|
||||
selectedList: completeSelectedList,
|
||||
});
|
||||
|
||||
console.log('优惠券选择已确认并通知父组件');
|
||||
},
|
||||
|
||||
// 取消选择,恢复到原始状态
|
||||
onCancel() {
|
||||
const { selectedList, couponsList } = this.data;
|
||||
|
||||
console.log('取消优惠券选择,恢复原始状态');
|
||||
|
||||
// 恢复优惠券列表的选中状态到确认前的状态
|
||||
couponsList.forEach((coupon) => {
|
||||
coupon.isSelected = false;
|
||||
});
|
||||
|
||||
// 如果有之前确认的选择,恢复其选中状态
|
||||
if (selectedList && selectedList.length > 0) {
|
||||
selectedList.forEach(selected => {
|
||||
const coupon = couponsList.find(c => c.key === selected.key);
|
||||
if (coupon) {
|
||||
coupon.isSelected = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 清空临时选择状态,恢复UI
|
||||
this.setData({
|
||||
tempSelectedList: [],
|
||||
couponsList: [...couponsList],
|
||||
});
|
||||
|
||||
// 触发close事件,关闭弹窗
|
||||
this.triggerEvent('close');
|
||||
|
||||
console.log('优惠券选择已取消');
|
||||
},
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {
|
||||
"t-popup": "tdesign-miniprogram/popup/popup",
|
||||
"t-icon": "tdesign-miniprogram/icon/icon",
|
||||
"t-image": "/components/webp-image/index",
|
||||
"wr-price": "/components/price/index",
|
||||
"coupon-card": "/components/promotion/ui-coupon-card/index"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
<wxs src="./selectCoupon.wxs" module="m1" />
|
||||
|
||||
|
||||
<t-popup visible="{{couponsShow}}" placement="bottom" bind:visible-change="onPopupVisibleChange">
|
||||
<view class="select-coupons">
|
||||
<view class="title">选择优惠券</view>
|
||||
<block wx:if="{{couponsList && couponsList.length > 0}}">
|
||||
<view class="info">
|
||||
<block wx:if="{{!selectedNum}}">你有{{couponsList.length}}张可用优惠券</block>
|
||||
<block wx:else>
|
||||
已选中{{selectedNum}}张推荐优惠券, 共抵扣
|
||||
<wr-price fill="{{false}}" price="{{reduce || 0}}" />
|
||||
</block>
|
||||
</view>
|
||||
<scroll-view class="coupons-list" scroll-y="true">
|
||||
<view class="coupons-wrap">
|
||||
<block wx:for="{{couponsList}}" wx:key="index" wx:for-item="coupon">
|
||||
<coupon-card
|
||||
title="{{coupon.title}}"
|
||||
type="{{coupon.type}}"
|
||||
status="{{coupon.status}}"
|
||||
desc="{{coupon.desc}}"
|
||||
value="{{coupon.value}}"
|
||||
tag="{{coupon.tag}}"
|
||||
timeLimit="{{coupon.timeLimit}}"
|
||||
userCouponId="{{coupon.id}}"
|
||||
couponTemplateId="{{coupon.couponId}}"
|
||||
>
|
||||
<view class="slot-radio" slot="operator">
|
||||
<t-icon bindtap="selectCoupon" data-key="{{coupon.key}}" name="{{coupon.isSelected ? 'check-circle-filled' : 'circle'}}" color="#fa4126" size="40rpx"/>
|
||||
</view>
|
||||
</coupon-card>
|
||||
<view class="disable" wx:if="{{coupon.status == 'useless'}}">此优惠券不能和已勾选的优惠券叠加使用</view>
|
||||
</block>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</block>
|
||||
<view wx:else class="couponp-empty-wrap">
|
||||
<t-image t-class="couponp-empty-img" src="{{emptyCouponImg}}" />
|
||||
<view class="couponp-empty-title">暂无优惠券</view>
|
||||
</view>
|
||||
<view class="coupons-cover" />
|
||||
|
||||
<!-- 确认按钮区域 -->
|
||||
<view class="confirm-buttons">
|
||||
<view class="cancel-btn" bindtap="onCancel">取消</view>
|
||||
<view class="confirm-btn" bindtap="onConfirm">确定</view>
|
||||
</view>
|
||||
</view>
|
||||
</t-popup>
|
||||
|
||||
@@ -0,0 +1,144 @@
|
||||
.select-coupons {
|
||||
background: #fff;
|
||||
width: 100%;
|
||||
position: relative;
|
||||
border-radius: 20rpx 20rpx 0 0;
|
||||
padding-top: 28rpx;
|
||||
padding-bottom: env(safe-area-inset-bottom);
|
||||
}
|
||||
.select-coupons .title {
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
font-size: 32rpx;
|
||||
color: #333;
|
||||
font-weight: 600;
|
||||
line-height: 44rpx;
|
||||
}
|
||||
.select-coupons .info {
|
||||
width: 100%;
|
||||
height: 34rpx;
|
||||
font-size: 24rpx;
|
||||
color: #999;
|
||||
line-height: 34rpx;
|
||||
margin: 20rpx 0;
|
||||
padding: 0 20rpx;
|
||||
}
|
||||
.select-coupons .info .price {
|
||||
color: #fa4126;
|
||||
}
|
||||
.select-coupons .coupons-list {
|
||||
max-height: 500rpx;
|
||||
}
|
||||
.select-coupons .coupons-list .coupons-wrap {
|
||||
padding: 0rpx 20rpx;
|
||||
}
|
||||
.select-coupons .coupons-list .disable {
|
||||
font-size: 24rpx;
|
||||
color: #ff2525;
|
||||
padding-top: 20rpx;
|
||||
}
|
||||
.select-coupons .coupons-list .slot-radio {
|
||||
position: absolute;
|
||||
right: 22rpx;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
display: inline-block;
|
||||
}
|
||||
.select-coupons .coupons-list .slot-radio .wr-check-filled {
|
||||
font-size: 36rpx;
|
||||
}
|
||||
.select-coupons .coupons-list .slot-radio .check {
|
||||
width: 36rpx;
|
||||
}
|
||||
.select-coupons .coupons-list .slot-radio .text-primary {
|
||||
color: #fa4126;
|
||||
}
|
||||
.select-coupons .coupons-list .slot-radio .wr-check {
|
||||
font-size: 36rpx;
|
||||
}
|
||||
.select-coupons .coupons-list .slot-radio .wr-uncheck {
|
||||
font-size: 36rpx;
|
||||
color: #999;
|
||||
}
|
||||
.select-coupons .couponp-empty-wrap {
|
||||
padding: 40rpx;
|
||||
}
|
||||
.select-coupons .couponp-empty-wrap .couponp-empty-img {
|
||||
display: block;
|
||||
width: 240rpx;
|
||||
height: 240rpx;
|
||||
margin: 0 auto;
|
||||
}
|
||||
.select-coupons .couponp-empty-wrap .couponp-empty-title {
|
||||
font-size: 28rpx;
|
||||
color: #999;
|
||||
text-align: center;
|
||||
line-height: 40rpx;
|
||||
margin-top: 40rpx;
|
||||
}
|
||||
.select-coupons .coupons-cover {
|
||||
height: 112rpx;
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
margin-top: 30rpx;
|
||||
padding: 12rpx 32rpx;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
.select-coupons .coupons-cover .btn {
|
||||
width: 332rpx;
|
||||
height: 88rpx;
|
||||
text-align: center;
|
||||
line-height: 88rpx;
|
||||
font-size: 32rpx;
|
||||
border-radius: 44rpx;
|
||||
box-sizing: border-box;
|
||||
border: 2rpx solid #dddddd;
|
||||
color: #333333;
|
||||
}
|
||||
.select-coupons .coupons-cover .red {
|
||||
border-color: #fa4126;
|
||||
background-color: #fa4126;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
/* 确认按钮区域样式 */
|
||||
.select-coupons .confirm-buttons {
|
||||
display: flex;
|
||||
padding: 32rpx;
|
||||
background-color: #ffffff;
|
||||
border-top: 1rpx solid #f0f0f0;
|
||||
gap: 24rpx;
|
||||
}
|
||||
|
||||
.select-coupons .cancel-btn,
|
||||
.select-coupons .confirm-btn {
|
||||
flex: 1;
|
||||
height: 88rpx;
|
||||
line-height: 88rpx;
|
||||
text-align: center;
|
||||
font-size: 32rpx;
|
||||
border-radius: 44rpx;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.select-coupons .cancel-btn {
|
||||
background-color: #f8f8f8;
|
||||
color: #666666;
|
||||
border: 1rpx solid #e0e0e0;
|
||||
}
|
||||
|
||||
.select-coupons .confirm-btn {
|
||||
background-color: #fa4126;
|
||||
color: #ffffff;
|
||||
border: 1rpx solid #fa4126;
|
||||
}
|
||||
|
||||
.select-coupons .cancel-btn:active {
|
||||
background-color: #e8e8e8;
|
||||
}
|
||||
|
||||
.select-coupons .confirm-btn:active {
|
||||
background-color: #e03618;
|
||||
}
|
||||
132
miniprogram/pages/order/components/specs-goods-card/index.js
Normal file
132
miniprogram/pages/order/components/specs-goods-card/index.js
Normal file
@@ -0,0 +1,132 @@
|
||||
Component({
|
||||
options: {
|
||||
addGlobalClass: true,
|
||||
multipleSlots: true, // 在组件定义时的选项中启用多slot支持
|
||||
},
|
||||
|
||||
externalClasses: [
|
||||
'title-class',
|
||||
'desc-class',
|
||||
'num-class',
|
||||
'thumb-class',
|
||||
'specs-class',
|
||||
'price-class',
|
||||
'origin-price-class',
|
||||
'price-prefix-class',
|
||||
],
|
||||
|
||||
relations: {
|
||||
'../order-card/index': {
|
||||
type: 'ancestor',
|
||||
linked(target) {
|
||||
this.parent = target;
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
properties: {
|
||||
id: String,
|
||||
hidden: {
|
||||
// 设置为null代表不做类型转换
|
||||
type: null,
|
||||
observer(hidden) {
|
||||
// null就是代表没有设置,没有设置的话不setData,防止祖先组件触发的setHidden操作被覆盖
|
||||
if (hidden !== null) {
|
||||
this.setHidden(!!hidden);
|
||||
}
|
||||
},
|
||||
},
|
||||
data: Object,
|
||||
layout: {
|
||||
type: String,
|
||||
value: 'horizontal',
|
||||
},
|
||||
thumbMode: {
|
||||
type: String,
|
||||
value: 'aspectFill',
|
||||
},
|
||||
thumbWidth: Number,
|
||||
thumbHeight: Number,
|
||||
thumbWidthInPopup: Number,
|
||||
thumbHeightInPopup: Number,
|
||||
priceFill: {
|
||||
type: Boolean,
|
||||
value: true,
|
||||
},
|
||||
currency: {
|
||||
type: String,
|
||||
value: '¥',
|
||||
},
|
||||
lazyLoad: Boolean,
|
||||
centered: Boolean,
|
||||
showCart: Boolean,
|
||||
pricePrefix: String,
|
||||
cartSize: {
|
||||
type: Number,
|
||||
value: 48,
|
||||
},
|
||||
cartColor: {
|
||||
type: String,
|
||||
value: '#FA550F',
|
||||
},
|
||||
disablePopup: Boolean,
|
||||
},
|
||||
|
||||
data: {
|
||||
hiddenInData: false,
|
||||
specsPopup: {
|
||||
insert: false,
|
||||
show: false,
|
||||
},
|
||||
},
|
||||
|
||||
currentInTapSpecs: false,
|
||||
|
||||
lifetimes: {
|
||||
ready() {
|
||||
const { hidden } = this.properties;
|
||||
if (hidden !== null) {
|
||||
this.setHidden(!!hidden);
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
methods: {
|
||||
closeSpecsPopup() {
|
||||
this.setData({
|
||||
'specsPopup.show': false,
|
||||
});
|
||||
this.triggerEvent('specsclose', { good: this.properties.data });
|
||||
},
|
||||
|
||||
removeSpecsPopup() {
|
||||
this.setData({
|
||||
'specsPopup.insert': false,
|
||||
});
|
||||
},
|
||||
|
||||
onClick(e) {
|
||||
if (this.currentInTapSpecs) {
|
||||
this.currentInTapSpecs = false;
|
||||
return;
|
||||
}
|
||||
this.triggerEvent('click', e.detail);
|
||||
},
|
||||
|
||||
onClickThumb(e) {
|
||||
this.triggerEvent('thumb', e.detail);
|
||||
},
|
||||
|
||||
onClickTag(e) {
|
||||
this.triggerEvent('tag', e.detail);
|
||||
},
|
||||
|
||||
onClickCart(e) {
|
||||
this.triggerEvent('add-cart', e.detail);
|
||||
},
|
||||
|
||||
setHidden(hidden) {
|
||||
this.setData({ hiddenInData: !!hidden });
|
||||
},
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {
|
||||
"goods-card": "../goods-card/index"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<goods-card
|
||||
class="wr-specs-goods-card"
|
||||
id="{{id}}"
|
||||
layout="{{layout}}"
|
||||
data="{{data}}"
|
||||
currency="{{currency}}"
|
||||
price-fill="{{priceFill}}"
|
||||
lazy-load="{{lazyLoad}}"
|
||||
centered="{{centered}}"
|
||||
thumb-mode="{{thumbMode}}"
|
||||
thumb-width="{{thumbWidth}}"
|
||||
thumb-height="{{thumbHeight}}"
|
||||
show-cart="{{showCart}}"
|
||||
cart-size="{{cartSize}}"
|
||||
cart-color="{{cartColor}}"
|
||||
card-class="{{index === goodsList.length - 1 ? 'wr-goods-card__no-border' : 'wr-goods-card'}}"
|
||||
title-class="title-class"
|
||||
desc-class="desc-class"
|
||||
num-class="num-class"
|
||||
thumb-class="thumb-class"
|
||||
specs-class="specs-class"
|
||||
price-class="price-class"
|
||||
origin-price-class="origin-price-class"
|
||||
price-prefix-class="price-prefix-class"
|
||||
bind:thumb="onClickThumb"
|
||||
bind:tag="onClickTag"
|
||||
bind:add-cart="onClickCart"
|
||||
bind:click="onClick"
|
||||
hidden="{{hiddenInData}}"
|
||||
>
|
||||
<!-- 透传good-card组件的slot -->
|
||||
<slot name="thumb-cover" slot="thumb-cover" />
|
||||
<slot name="after-title" slot="after-title" />
|
||||
<slot name="after-desc" slot="after-desc" />
|
||||
<slot name="price-prefix" slot="price-prefix" />
|
||||
<slot name="append-body" slot="append-body" />
|
||||
<slot name="footer" slot="footer" />
|
||||
<slot name="append-card" slot="append-card" />
|
||||
</goods-card>
|
||||
|
||||
95
miniprogram/pages/order/config.js
Normal file
95
miniprogram/pages/order/config.js
Normal file
@@ -0,0 +1,95 @@
|
||||
export const OrderStatus = {
|
||||
PENDING_PAYMENT: 5, // 待支付
|
||||
PENDING_DELIVERY: 10, // 待发货
|
||||
PENDING_RECEIPT: 40, // 待收货
|
||||
COMPLETE: 50, // 已完成/待评价
|
||||
PAYMENT_TIMEOUT: 80, // 已取消,支付超时
|
||||
CANCELED_NOT_PAYMENT: 80, // 已取消,未支付主动取消
|
||||
CANCELED_PAYMENT: 80, // 已取消,已支付主动取消
|
||||
CANCELED_REJECTION: 80, // 已取消,拒收
|
||||
};
|
||||
|
||||
// 售后状态 10:待审核,20:已审核,30:已收货,40:收货异常,50:已完成,60:已关闭;
|
||||
export const AfterServiceStatus = {
|
||||
TO_AUDIT: 10, // 待审核
|
||||
THE_APPROVED: 20, // 已审核
|
||||
HAVE_THE_GOODS: 30, // 已收货
|
||||
ABNORMAL_RECEIVING: 40, // 收货异常
|
||||
COMPLETE: 50, // 已完成
|
||||
CLOSED: 60, // 已关闭
|
||||
};
|
||||
|
||||
// 售后类型
|
||||
export const ServiceType = {
|
||||
RETURN_GOODS: 10, // 退货退款
|
||||
ONLY_REFUND: 20, // 仅退款
|
||||
ORDER_CANCEL: 30, // 支付后取消
|
||||
};
|
||||
|
||||
export const ServiceTypeDesc = {
|
||||
[ServiceType.RETURN_GOODS]: '退货',
|
||||
[ServiceType.ONLY_REFUND]: '退款',
|
||||
[ServiceType.ORDER_CANCEL]: '支付后取消',
|
||||
};
|
||||
|
||||
// 订单按钮类型
|
||||
export const OrderButtonTypes = {
|
||||
CANCEL: 1, // 取消订单
|
||||
PAY: 2, // 立即付款
|
||||
REMIND_SHIP: 3, // 提醒发货
|
||||
CONFIRM: 4, // 确认收货
|
||||
APPLY_REFUND: 5, // 申请售后
|
||||
COMMENT: 6, // 评价
|
||||
DELETE: 7, // 删除订单
|
||||
DELIVERY: 8, // 查看物流
|
||||
REBUY: 9, // 再次购买
|
||||
VIEW_REFUND: 10, // 查看退款
|
||||
INVITE_GROUPON: 11, //邀请好友拼团
|
||||
};
|
||||
|
||||
// 售后服务按钮类型
|
||||
export const ServiceButtonTypes = {
|
||||
REVOKE: 2, // 撤销
|
||||
FILL_TRACKING_NO: 3, // 填写运单号
|
||||
CHANGE_TRACKING_NO: 4, // 修改运单号
|
||||
VIEW_DELIVERY: 5, // 查看物流
|
||||
};
|
||||
|
||||
// 售后状态
|
||||
export const ServiceStatus = {
|
||||
PENDING_VERIFY: 100, //待审核
|
||||
VERIFIED: 110, // 已审核待寄回商品
|
||||
PENDING_DELIVERY: 120, // 等待买家寄回商品
|
||||
PENDING_RECEIPT: 130, // 已寄回商品,待收货
|
||||
RECEIVED: 140, // 已收货
|
||||
EXCEPTION: 150, // 收货异常
|
||||
REFUNDED: 160, // 已退款
|
||||
CLOSED: 170, // 已关闭
|
||||
};
|
||||
|
||||
// 售后收货状态
|
||||
export const ServiceReceiptStatus = {
|
||||
RECEIPTED: 1, // 已收到货
|
||||
NOT_RECEIPTED: 2, // 未收到货
|
||||
};
|
||||
|
||||
// 物流节点
|
||||
export const LogisticsNodeTypes = {
|
||||
SUBMITTED: 200001, // 已提交订单
|
||||
PAYMENTED: 200002, // 已付款/已下单
|
||||
SHIPPED: 200003, // 已发货
|
||||
CANCELED: 200004, // 已取消
|
||||
RECEIVED: 200005, // 已签收
|
||||
ADDRESS_CHANGED: 200006, // 已修改地址
|
||||
IN_TRANSIT: 200007, // 运输中
|
||||
};
|
||||
|
||||
export const LogisticsIconMap = {
|
||||
[LogisticsNodeTypes.SUBMITTED]: '',
|
||||
[LogisticsNodeTypes.PAYMENTED]: 'credit_card',
|
||||
[LogisticsNodeTypes.SHIPPED]: 'deliver',
|
||||
[LogisticsNodeTypes.CANCELED]: '',
|
||||
[LogisticsNodeTypes.RECEIVED]: 'check',
|
||||
[LogisticsNodeTypes.ADDRESS_CHANGED]: '',
|
||||
[LogisticsNodeTypes.IN_TRANSIT]: 'yunshuzhong',
|
||||
};
|
||||
161
miniprogram/pages/order/delivery-detail/api.js
Normal file
161
miniprogram/pages/order/delivery-detail/api.js
Normal file
@@ -0,0 +1,161 @@
|
||||
import { config } from '../../../config/index';
|
||||
import { mockIp, mockReqId } from '../../../utils/mock';
|
||||
|
||||
/**
|
||||
* Mock获取物流信息
|
||||
*/
|
||||
function mockGetLogisticsInfo(params) {
|
||||
console.log('[物流API] 使用Mock数据获取物流信息', { params });
|
||||
|
||||
const mockData = {
|
||||
data: {
|
||||
logisticsNo: params.logisticsNo || '1234567890123',
|
||||
company: '顺丰快递',
|
||||
phoneNumber: '95338',
|
||||
nodes: [
|
||||
{
|
||||
title: '已签收',
|
||||
desc: '您的快件已签收,感谢使用顺丰,期待再次为您服务',
|
||||
date: '2024-01-15 14:30:25',
|
||||
icon: 'check-circle'
|
||||
},
|
||||
{
|
||||
title: '派送中',
|
||||
desc: '快件正在派送途中,请您准备签收',
|
||||
date: '2024-01-15 09:15:10',
|
||||
icon: 'location'
|
||||
},
|
||||
{
|
||||
title: '到达目的地',
|
||||
desc: '快件已到达【北京朝阳区】',
|
||||
date: '2024-01-15 06:20:45',
|
||||
icon: 'location'
|
||||
},
|
||||
{
|
||||
title: '运输中',
|
||||
desc: '快件在【北京转运中心】,正发往下一站',
|
||||
date: '2024-01-14 22:10:30',
|
||||
icon: 'swap'
|
||||
},
|
||||
{
|
||||
title: '已发货',
|
||||
desc: '商家已发货,快件已交给顺丰快递',
|
||||
date: '2024-01-14 16:45:20',
|
||||
icon: 'check-circle'
|
||||
}
|
||||
]
|
||||
},
|
||||
code: 200,
|
||||
message: 'success',
|
||||
requestId: mockReqId(),
|
||||
clientIp: mockIp(),
|
||||
success: true
|
||||
};
|
||||
|
||||
return new Promise((resolve) => {
|
||||
setTimeout(() => {
|
||||
console.log('[物流API] Mock物流信息获取完成', mockData.data);
|
||||
resolve(mockData);
|
||||
}, 500);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取物流信息
|
||||
* @param {Object} params - 参数对象
|
||||
* @param {string} params.logisticsNo - 物流单号
|
||||
* @param {string} params.logisticsCompanyCode - 物流公司代码
|
||||
* @param {string} params.orderNo - 订单号(可选)
|
||||
* @param {string} params.rightsNo - 售后单号(可选)
|
||||
*/
|
||||
export function getLogisticsInfo(params) {
|
||||
console.log('[物流API] 开始获取物流信息', {
|
||||
params,
|
||||
useMock: config.useMock,
|
||||
timestamp: new Date().toISOString()
|
||||
});
|
||||
|
||||
if (config.useMock) {
|
||||
return mockGetLogisticsInfo(params);
|
||||
}
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
const token = wx.getStorageSync('token');
|
||||
if (!token) {
|
||||
console.error('[物流API] 用户未登录');
|
||||
reject(new Error('未登录'));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!params.logisticsNo) {
|
||||
console.error('[物流API] 缺少物流单号');
|
||||
reject(new Error('缺少物流单号'));
|
||||
return;
|
||||
}
|
||||
|
||||
const requestUrl = `${config.apiBase}/logistics/track`;
|
||||
console.log('[物流API] 发送物流查询API请求', {
|
||||
url: requestUrl,
|
||||
logisticsNo: params.logisticsNo,
|
||||
companyCode: params.logisticsCompanyCode
|
||||
});
|
||||
|
||||
wx.request({
|
||||
url: requestUrl,
|
||||
method: 'GET',
|
||||
data: {
|
||||
logisticsNo: params.logisticsNo,
|
||||
logisticsCompanyCode: params.logisticsCompanyCode,
|
||||
orderNo: params.orderNo,
|
||||
rightsNo: params.rightsNo
|
||||
},
|
||||
header: {
|
||||
'Authorization': `Bearer ${token}`,
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
success: (res) => {
|
||||
console.log('[物流API] 物流查询API响应', {
|
||||
statusCode: res.statusCode,
|
||||
dataCode: res.data?.code,
|
||||
message: res.data?.message,
|
||||
logisticsNo: params.logisticsNo
|
||||
});
|
||||
|
||||
if (res.statusCode === 200 && res.data.code === 200) {
|
||||
console.log('[物流API] 物流信息获取成功', {
|
||||
logisticsNo: params.logisticsNo,
|
||||
nodesCount: res.data.data?.nodes?.length || 0
|
||||
});
|
||||
resolve(res.data);
|
||||
} else {
|
||||
const errorMsg = res.data?.message || '获取物流信息失败';
|
||||
console.error('[物流API] 物流信息获取失败', {
|
||||
statusCode: res.statusCode,
|
||||
dataCode: res.data?.code,
|
||||
message: errorMsg,
|
||||
logisticsNo: params.logisticsNo
|
||||
});
|
||||
reject(new Error(errorMsg));
|
||||
}
|
||||
},
|
||||
fail: (err) => {
|
||||
console.error('[物流API] 物流查询请求失败', {
|
||||
error: err,
|
||||
logisticsNo: params.logisticsNo,
|
||||
url: requestUrl,
|
||||
timestamp: new Date().toISOString()
|
||||
});
|
||||
reject(new Error('网络请求失败'));
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 刷新物流信息
|
||||
* @param {Object} params - 参数对象
|
||||
*/
|
||||
export function refreshLogisticsInfo(params) {
|
||||
console.log('[物流API] 刷新物流信息', { params });
|
||||
return getLogisticsInfo(params);
|
||||
}
|
||||
178
miniprogram/pages/order/delivery-detail/index.js
Normal file
178
miniprogram/pages/order/delivery-detail/index.js
Normal file
@@ -0,0 +1,178 @@
|
||||
import { getLogisticsInfo, refreshLogisticsInfo } from './api';
|
||||
import Toast from 'tdesign-miniprogram/toast/index';
|
||||
|
||||
Page({
|
||||
data: {
|
||||
logisticsData: {
|
||||
logisticsNo: '',
|
||||
nodes: [],
|
||||
company: '',
|
||||
phoneNumber: '',
|
||||
},
|
||||
active: 0,
|
||||
loading: false,
|
||||
refreshing: false,
|
||||
// 存储查询参数,用于刷新
|
||||
queryParams: null,
|
||||
},
|
||||
|
||||
onLoad(query) {
|
||||
console.log('[物流详情] 页面加载', { query });
|
||||
|
||||
let data;
|
||||
try {
|
||||
data = JSON.parse(decodeURIComponent(query.data || '{}'));
|
||||
} catch (e) {
|
||||
console.warn('物流节点数据解析失败', e);
|
||||
}
|
||||
|
||||
// 如果是从售后页面跳转过来的(source=2)
|
||||
if (Number(query.source) === 2) {
|
||||
const service = {
|
||||
company: data.logisticsCompanyName,
|
||||
logisticsNo: data.logisticsNo,
|
||||
nodes: data.nodes,
|
||||
phoneNumber: data.phoneNumber,
|
||||
};
|
||||
this.setData({
|
||||
logisticsData: service,
|
||||
queryParams: {
|
||||
logisticsNo: data.logisticsNo,
|
||||
logisticsCompanyCode: data.logisticsCompanyCode,
|
||||
rightsNo: query.rightsNo,
|
||||
orderNo: query.orderNo
|
||||
}
|
||||
});
|
||||
|
||||
// 如果有物流单号,尝试获取最新的物流信息
|
||||
if (data.logisticsNo) {
|
||||
this.fetchLogisticsInfo();
|
||||
}
|
||||
} else if (data) {
|
||||
// 直接传入的物流数据
|
||||
this.setData({
|
||||
logisticsData: data,
|
||||
queryParams: {
|
||||
logisticsNo: data.logisticsNo,
|
||||
logisticsCompanyCode: data.logisticsCompanyCode,
|
||||
orderNo: query.orderNo
|
||||
}
|
||||
});
|
||||
|
||||
// 如果有物流单号,尝试获取最新的物流信息
|
||||
if (data.logisticsNo) {
|
||||
this.fetchLogisticsInfo();
|
||||
}
|
||||
} else if (query.logisticsNo) {
|
||||
// 直接传入物流单号
|
||||
this.setData({
|
||||
queryParams: {
|
||||
logisticsNo: query.logisticsNo,
|
||||
logisticsCompanyCode: query.logisticsCompanyCode,
|
||||
orderNo: query.orderNo,
|
||||
rightsNo: query.rightsNo
|
||||
}
|
||||
});
|
||||
this.fetchLogisticsInfo();
|
||||
}
|
||||
},
|
||||
|
||||
// 获取物流信息
|
||||
async fetchLogisticsInfo() {
|
||||
if (!this.data.queryParams?.logisticsNo) {
|
||||
console.warn('[物流详情] 缺少物流单号,无法获取物流信息');
|
||||
return;
|
||||
}
|
||||
|
||||
this.setData({ loading: true });
|
||||
|
||||
try {
|
||||
console.log('[物流详情] 开始获取物流信息', this.data.queryParams);
|
||||
const res = await getLogisticsInfo(this.data.queryParams);
|
||||
|
||||
if (res.success && res.data) {
|
||||
console.log('[物流详情] 物流信息获取成功', res.data);
|
||||
this.setData({
|
||||
logisticsData: {
|
||||
logisticsNo: res.data.logisticsNo,
|
||||
company: res.data.company,
|
||||
phoneNumber: res.data.phoneNumber,
|
||||
nodes: res.data.nodes || []
|
||||
},
|
||||
active: 0 // 默认激活第一个节点
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('[物流详情] 获取物流信息失败', error);
|
||||
Toast({
|
||||
context: this,
|
||||
selector: '#t-toast',
|
||||
message: error.message || '获取物流信息失败',
|
||||
icon: 'error-circle',
|
||||
});
|
||||
} finally {
|
||||
this.setData({ loading: false });
|
||||
}
|
||||
},
|
||||
|
||||
// 刷新物流信息
|
||||
async onRefresh() {
|
||||
if (!this.data.queryParams?.logisticsNo) {
|
||||
Toast({
|
||||
context: this,
|
||||
selector: '#t-toast',
|
||||
message: '无法刷新,缺少物流单号',
|
||||
icon: 'error-circle',
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
this.setData({ refreshing: true });
|
||||
|
||||
try {
|
||||
console.log('[物流详情] 开始刷新物流信息', this.data.queryParams);
|
||||
const res = await refreshLogisticsInfo(this.data.queryParams);
|
||||
|
||||
if (res.success && res.data) {
|
||||
console.log('[物流详情] 物流信息刷新成功', res.data);
|
||||
this.setData({
|
||||
logisticsData: {
|
||||
logisticsNo: res.data.logisticsNo,
|
||||
company: res.data.company,
|
||||
phoneNumber: res.data.phoneNumber,
|
||||
nodes: res.data.nodes || []
|
||||
},
|
||||
active: 0
|
||||
});
|
||||
|
||||
Toast({
|
||||
context: this,
|
||||
selector: '#t-toast',
|
||||
message: '刷新成功',
|
||||
icon: 'check-circle',
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('[物流详情] 刷新物流信息失败', error);
|
||||
Toast({
|
||||
context: this,
|
||||
selector: '#t-toast',
|
||||
message: error.message || '刷新失败',
|
||||
icon: 'error-circle',
|
||||
});
|
||||
} finally {
|
||||
this.setData({ refreshing: false });
|
||||
}
|
||||
},
|
||||
|
||||
onLogisticsNoCopy() {
|
||||
wx.setClipboardData({ data: this.data.logisticsData.logisticsNo });
|
||||
},
|
||||
|
||||
onCall() {
|
||||
const { phoneNumber } = this.data.logisticsData;
|
||||
wx.makePhoneCall({
|
||||
phoneNumber,
|
||||
});
|
||||
},
|
||||
});
|
||||
13
miniprogram/pages/order/delivery-detail/index.json
Normal file
13
miniprogram/pages/order/delivery-detail/index.json
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"navigationBarTitleText": "物流信息",
|
||||
"usingComponents": {
|
||||
"t-cell": "tdesign-miniprogram/cell/cell",
|
||||
"t-cell-group": "tdesign-miniprogram/cell-group/cell-group",
|
||||
"t-image": "/components/webp-image/index",
|
||||
"t-icon": "tdesign-miniprogram/icon/icon",
|
||||
"t-steps": "tdesign-miniprogram/steps/steps",
|
||||
"t-step": "tdesign-miniprogram/step-item/step-item",
|
||||
"t-button": "tdesign-miniprogram/button/button",
|
||||
"t-toast": "tdesign-miniprogram/toast/toast"
|
||||
}
|
||||
}
|
||||
107
miniprogram/pages/order/delivery-detail/index.wxml
Normal file
107
miniprogram/pages/order/delivery-detail/index.wxml
Normal file
@@ -0,0 +1,107 @@
|
||||
<wxs module="isUrl">
|
||||
var isUrl = function(item) {
|
||||
return item.indexOf('http') > -1;
|
||||
}
|
||||
module.exports = {
|
||||
isUrl: isUrl,
|
||||
}
|
||||
</wxs>
|
||||
|
||||
<!-- 刷新按钮 -->
|
||||
<view class="refresh-section" wx:if="{{queryParams.logisticsNo}}">
|
||||
<t-button
|
||||
theme="light"
|
||||
size="small"
|
||||
loading="{{refreshing}}"
|
||||
bind:tap="onRefresh"
|
||||
t-class="refresh-btn"
|
||||
>
|
||||
{{refreshing ? '刷新中...' : '刷新物流'}}
|
||||
</t-button>
|
||||
</view>
|
||||
|
||||
<view class="page-section cells" wx:if="{{logisticsData.logisticsNo || logisticsData.company}}">
|
||||
<t-cell-group>
|
||||
<t-cell
|
||||
title="快递单号"
|
||||
t-class-title="wr-cell__title"
|
||||
t-class-note="wr-cell__value"
|
||||
t-class-left="order-group__left"
|
||||
wx:if="{{logisticsData.logisticsNo}}"
|
||||
bordered="{{false}}"
|
||||
>
|
||||
<text slot="note" class="logistics-no">{{logisticsData.logisticsNo}}</text>
|
||||
<view
|
||||
slot="right-icon"
|
||||
class="text-btn"
|
||||
hover-class="text-btn--active"
|
||||
bindtap="onLogisticsNoCopy"
|
||||
>复制
|
||||
</view>
|
||||
</t-cell>
|
||||
<t-cell
|
||||
title="物流公司"
|
||||
t-class-title="wr-cell__title"
|
||||
t-class-note="wr-cell__value"
|
||||
t-class-left="order-group__left"
|
||||
bordered="{{false}}"
|
||||
wx:if="{{logisticsData.company}}"
|
||||
note="{{logisticsData.company + (logisticsData.phoneNumber ? '-' + logisticsData.phoneNumber : '')}}"
|
||||
>
|
||||
<view
|
||||
slot="right-icon"
|
||||
class="text-btn"
|
||||
hover-class="text-btn--active"
|
||||
bindtap="onCall"
|
||||
wx:if="{{logisticsData.phoneNumber}}"
|
||||
>
|
||||
拨打
|
||||
</view>
|
||||
</t-cell>
|
||||
</t-cell-group>
|
||||
</view>
|
||||
<view class="page-section cell-steps">
|
||||
<t-steps
|
||||
class="page-section__steps"
|
||||
t-class="steps"
|
||||
layout="vertical"
|
||||
current="{{active}}"
|
||||
>
|
||||
<t-step
|
||||
class="steps"
|
||||
t-class-title="step-title"
|
||||
wx:for="{{logisticsData.nodes}}"
|
||||
wx:for-item="item"
|
||||
wx:for-index="index"
|
||||
wx:key="index"
|
||||
title="{{item.title}}"
|
||||
icon="slot"
|
||||
>
|
||||
<block wx:if="{{isUrl.isUrl(item.icon)}}">
|
||||
<t-image
|
||||
class="cell-steps__imgWrapper"
|
||||
slot="icon"
|
||||
t-class="cell-steps__img"
|
||||
src="{{item.icon}}"
|
||||
/>
|
||||
</block>
|
||||
<block wx:else>
|
||||
<t-icon
|
||||
slot="icon"
|
||||
size="32rpx"
|
||||
prefix="wr"
|
||||
color="{{index === 0 ? '#ef5433' : '#bbb'}}"
|
||||
name="{{item.icon}}"
|
||||
/>
|
||||
</block>
|
||||
<view slot="content">
|
||||
<view class="step-desc">{{item.desc}}</view>
|
||||
<view class="step-date">{{item.date}}</view>
|
||||
</view>
|
||||
</t-step>
|
||||
</t-steps>
|
||||
</view>
|
||||
|
||||
<!-- Toast 组件 -->
|
||||
<t-toast id="t-toast" />
|
||||
|
||||
110
miniprogram/pages/order/delivery-detail/index.wxss
Normal file
110
miniprogram/pages/order/delivery-detail/index.wxss
Normal file
@@ -0,0 +1,110 @@
|
||||
page {
|
||||
background-color: #f5f5f5;
|
||||
}
|
||||
|
||||
.refresh-section {
|
||||
padding: 24rpx;
|
||||
text-align: center;
|
||||
background-color: white;
|
||||
margin-top: 24rpx;
|
||||
}
|
||||
|
||||
.refresh-btn {
|
||||
width: 200rpx !important;
|
||||
}
|
||||
.page-section {
|
||||
margin-top: 24rpx;
|
||||
background-color: white;
|
||||
}
|
||||
.page-section .order-group__left {
|
||||
margin-right: 0 !important;
|
||||
}
|
||||
.cell-steps {
|
||||
padding: 8rpx;
|
||||
}
|
||||
.wr-cell__title {
|
||||
flex: none;
|
||||
font-size: 28rpx;
|
||||
color: #666;
|
||||
}
|
||||
.wr-cell__value {
|
||||
flex: auto;
|
||||
margin-left: 30rpx;
|
||||
font-size: 28rpx;
|
||||
color: #333 !important;
|
||||
}
|
||||
.logistics-no {
|
||||
display: inline-block;
|
||||
text-align: left;
|
||||
word-break: break-all;
|
||||
color: #333;
|
||||
}
|
||||
.text-btn {
|
||||
margin-left: 20rpx;
|
||||
display: inline;
|
||||
font-size: 24rpx;
|
||||
padding: 0 15rpx;
|
||||
border: 1rpx solid #ddd;
|
||||
border-radius: 28rpx;
|
||||
color: #333;
|
||||
}
|
||||
.text-btn--active {
|
||||
opacity: 0.5;
|
||||
}
|
||||
.steps .step-title {
|
||||
font-weight: bold;
|
||||
color: #333 !important;
|
||||
font-size: 30rpx;
|
||||
}
|
||||
.steps .step-desc {
|
||||
color: #333333;
|
||||
font-size: 28rpx;
|
||||
}
|
||||
.steps .step-date {
|
||||
color: #999999;
|
||||
font-size: 24rpx;
|
||||
}
|
||||
|
||||
.cell-steps__img,
|
||||
.cell-steps__imgWrapper {
|
||||
width: 48rpx;
|
||||
height: 48rpx;
|
||||
}
|
||||
|
||||
.steps
|
||||
.t-step--vertical.t-step--default-anchor
|
||||
.t-steps-item--process
|
||||
.t-steps-item__icon-number {
|
||||
background: #ffece9 !important;
|
||||
color: white !important;
|
||||
border: none;
|
||||
}
|
||||
|
||||
.steps
|
||||
.t-step--vertical.t-step--default-anchor
|
||||
.t-steps-item--default
|
||||
.t-steps-item__icon-number {
|
||||
color: white !important;
|
||||
background: #f5f5f5 !important;
|
||||
border: none;
|
||||
}
|
||||
|
||||
.steps
|
||||
.t-step--vertical.t-step--default-anchor.t-step--not-last-child
|
||||
.t-steps-item__inner::after {
|
||||
top: 48rpx;
|
||||
height: calc(100% - 44rpx - 4rpx);
|
||||
}
|
||||
|
||||
.steps
|
||||
.t-step--vertical.t-step--default-anchor.t-step--not-last-child
|
||||
.t-steps-item__inner::after,
|
||||
.steps
|
||||
.t-step--vertical.t-step--default-anchor.t-step--not-last-child
|
||||
.t-steps-item--default
|
||||
.t-steps-item__inner:after {
|
||||
background: #f5f5f5 !important;
|
||||
}
|
||||
.page-section__steps {
|
||||
padding: 24rpx;
|
||||
}
|
||||
146
miniprogram/pages/order/fill-tracking-no/api.js
Normal file
146
miniprogram/pages/order/fill-tracking-no/api.js
Normal file
@@ -0,0 +1,146 @@
|
||||
import { mockIp, mockReqId } from '../../../utils/mock';
|
||||
import { config } from '../../../config/index';
|
||||
|
||||
export function create(params) {
|
||||
console.log('[运单号API] 创建运单号', { params, useMock: config.useMock });
|
||||
|
||||
if (config.useMock) {
|
||||
const _resq = {
|
||||
data: null,
|
||||
code: 'Success',
|
||||
msg: null,
|
||||
requestId: mockReqId(),
|
||||
clientIp: mockIp(),
|
||||
rt: 79,
|
||||
success: true,
|
||||
};
|
||||
return Promise.resolve(_resq);
|
||||
}
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
const token = wx.getStorageSync('token');
|
||||
if (!token) {
|
||||
reject(new Error('未登录'));
|
||||
return;
|
||||
}
|
||||
|
||||
wx.request({
|
||||
url: `${config.apiBase}/after-service/${params.rightsNo}/tracking`,
|
||||
method: 'POST',
|
||||
data: {
|
||||
logisticsCompanyCode: params.logisticsCompanyCode,
|
||||
logisticsCompanyName: params.logisticsCompanyName,
|
||||
logisticsNo: params.logisticsNo,
|
||||
remark: params.remark
|
||||
},
|
||||
header: {
|
||||
'Authorization': `Bearer ${token}`,
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
success: (res) => {
|
||||
if (res.statusCode === 200 && res.data.code === 200) {
|
||||
resolve(res.data);
|
||||
} else {
|
||||
reject(new Error(res.data?.message || '创建运单号失败'));
|
||||
}
|
||||
},
|
||||
fail: (err) => {
|
||||
reject(new Error('网络请求失败'));
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export function update(params) {
|
||||
console.log('[运单号API] 更新运单号', { params, useMock: config.useMock });
|
||||
|
||||
if (config.useMock) {
|
||||
const _resq = {
|
||||
data: null,
|
||||
code: 'Success',
|
||||
msg: null,
|
||||
requestId: mockReqId(),
|
||||
clientIp: mockIp(),
|
||||
rt: 79,
|
||||
success: true,
|
||||
};
|
||||
return Promise.resolve(_resq);
|
||||
}
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
const token = wx.getStorageSync('token');
|
||||
if (!token) {
|
||||
reject(new Error('未登录'));
|
||||
return;
|
||||
}
|
||||
|
||||
wx.request({
|
||||
url: `${config.apiBase}/after-service/${params.rightsNo}/tracking`,
|
||||
method: 'PUT',
|
||||
data: {
|
||||
logisticsCompanyCode: params.logisticsCompanyCode,
|
||||
logisticsCompanyName: params.logisticsCompanyName,
|
||||
logisticsNo: params.logisticsNo,
|
||||
remark: params.remark
|
||||
},
|
||||
header: {
|
||||
'Authorization': `Bearer ${token}`,
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
success: (res) => {
|
||||
if (res.statusCode === 200 && res.data.code === 200) {
|
||||
resolve(res.data);
|
||||
} else {
|
||||
reject(new Error(res.data?.message || '更新运单号失败'));
|
||||
}
|
||||
},
|
||||
fail: (err) => {
|
||||
reject(new Error('网络请求失败'));
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export function getDeliverCompanyList() {
|
||||
const _resq = {
|
||||
data: [
|
||||
{
|
||||
name: '中通快递',
|
||||
code: '0001',
|
||||
},
|
||||
{
|
||||
name: '申通快递',
|
||||
code: '0002',
|
||||
},
|
||||
{
|
||||
name: '圆通快递',
|
||||
code: '0003',
|
||||
},
|
||||
{
|
||||
name: '顺丰快递',
|
||||
code: '0004',
|
||||
},
|
||||
{
|
||||
name: '百世快递',
|
||||
code: '0005',
|
||||
},
|
||||
{
|
||||
name: '韵达快递',
|
||||
code: '0006',
|
||||
},
|
||||
{
|
||||
name: '邮政快递',
|
||||
code: '0007',
|
||||
},
|
||||
{
|
||||
name: '丰网快递',
|
||||
code: '0008',
|
||||
},
|
||||
{
|
||||
name: '顺丰直邮',
|
||||
code: '0009',
|
||||
},
|
||||
],
|
||||
};
|
||||
return Promise.resolve(_resq);
|
||||
}
|
||||
192
miniprogram/pages/order/fill-tracking-no/index.js
Normal file
192
miniprogram/pages/order/fill-tracking-no/index.js
Normal file
@@ -0,0 +1,192 @@
|
||||
import Dialog from 'tdesign-miniprogram/dialog/index';
|
||||
import Toast from 'tdesign-miniprogram/toast/index';
|
||||
import reasonSheet from '../components/reason-sheet/reasonSheet';
|
||||
import { getDeliverCompanyList, create, update } from './api';
|
||||
|
||||
Page({
|
||||
deliveryCompanyList: [],
|
||||
|
||||
data: {
|
||||
trackingNo: '',
|
||||
remark: '',
|
||||
deliveryCompany: null,
|
||||
submitActived: false,
|
||||
submitting: false,
|
||||
},
|
||||
onLoad(query) {
|
||||
const {
|
||||
rightsNo = '',
|
||||
logisticsNo = '',
|
||||
logisticsCompanyName = '',
|
||||
logisticsCompanyCode = '',
|
||||
remark = '',
|
||||
} = query;
|
||||
|
||||
if (!rightsNo) {
|
||||
Dialog.confirm({
|
||||
title: '请选择售后单?',
|
||||
content: '',
|
||||
confirmBtn: '确认',
|
||||
}).then(() => {
|
||||
wx.navigateBack({ backRefresh: true });
|
||||
});
|
||||
}
|
||||
this.rightsNo = rightsNo;
|
||||
if (logisticsNo) {
|
||||
wx.setNavigationBarTitle({
|
||||
title: '修改运单号',
|
||||
fail() {},
|
||||
});
|
||||
this.isChange = true;
|
||||
this.setData({
|
||||
deliveryCompany: {
|
||||
name: logisticsCompanyName,
|
||||
code: logisticsCompanyCode,
|
||||
},
|
||||
trackingNo: logisticsNo,
|
||||
remark,
|
||||
submitActived: true,
|
||||
});
|
||||
}
|
||||
this.setWatcher('trackingNo', this.checkParams.bind(this));
|
||||
this.setWatcher('deliveryCompany', this.checkParams.bind(this));
|
||||
},
|
||||
|
||||
setWatcher(key, callback) {
|
||||
let lastData = this.data;
|
||||
const keys = key.split('.');
|
||||
keys.slice(0, -1).forEach((k) => {
|
||||
lastData = lastData[k];
|
||||
});
|
||||
const lastKey = keys[keys.length - 1];
|
||||
this.observe(lastData, lastKey, callback);
|
||||
},
|
||||
|
||||
observe(data, k, callback) {
|
||||
let val = data[k];
|
||||
Object.defineProperty(data, k, {
|
||||
configurable: true,
|
||||
enumerable: true,
|
||||
set: (value) => {
|
||||
val = value;
|
||||
callback();
|
||||
},
|
||||
get: () => {
|
||||
return val;
|
||||
},
|
||||
});
|
||||
},
|
||||
|
||||
getDeliveryCompanyList() {
|
||||
if (this.deliveryCompanyList.length > 0) {
|
||||
return Promise.resolve(this.deliveryCompanyList);
|
||||
}
|
||||
return getDeliverCompanyList().then((res) => {
|
||||
this.deliveryCompanyList = res.data || [];
|
||||
return this.deliveryCompanyList;
|
||||
});
|
||||
},
|
||||
|
||||
onInput(e) {
|
||||
const { key } = e.currentTarget.dataset;
|
||||
const { value } = e.detail;
|
||||
this.setData({ [key]: value });
|
||||
},
|
||||
|
||||
onCompanyTap() {
|
||||
this.getDeliveryCompanyList().then((deliveryCompanyList) => {
|
||||
reasonSheet({
|
||||
show: true,
|
||||
title: '选择物流公司',
|
||||
options: deliveryCompanyList.map((company) => ({
|
||||
title: company.name,
|
||||
checked: this.data.deliveryCompany
|
||||
? company.code === this.data.deliveryCompany.code
|
||||
: false,
|
||||
})),
|
||||
showConfirmButton: true,
|
||||
showCancelButton: true,
|
||||
emptyTip: '请选择物流公司',
|
||||
}).then((indexes) => {
|
||||
if (indexes && indexes.length > 0) {
|
||||
this.setData({
|
||||
deliveryCompany: deliveryCompanyList[indexes[0]],
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
checkParams() {
|
||||
const res = { errMsg: '', require: false };
|
||||
|
||||
if (!this.data.trackingNo) {
|
||||
res.errMsg = '请填写运单号';
|
||||
res.require = true;
|
||||
} else if (!this.data.deliveryCompany) {
|
||||
res.errMsg = '请选择物流公司';
|
||||
res.require = true;
|
||||
}
|
||||
this.setData({ submitActived: !res.require });
|
||||
return res;
|
||||
},
|
||||
|
||||
onSubmit() {
|
||||
const checkRes = this.checkParams();
|
||||
if (checkRes.errMsg) {
|
||||
Toast({
|
||||
context: this,
|
||||
selector: '#t-toast',
|
||||
message: checkRes.errMsg,
|
||||
icon: '',
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
const {
|
||||
trackingNo,
|
||||
remark,
|
||||
deliveryCompany: { code, name },
|
||||
} = this.data;
|
||||
|
||||
const params = {
|
||||
rightsNo: this.rightsNo,
|
||||
logisticsCompanyCode: code,
|
||||
logisticsCompanyName: name,
|
||||
logisticsNo: trackingNo,
|
||||
remark,
|
||||
};
|
||||
const api = this.isChange ? create : update;
|
||||
this.setData({ submitting: true });
|
||||
api(params)
|
||||
.then(() => {
|
||||
this.setData({ submitting: false });
|
||||
Toast({
|
||||
context: this,
|
||||
selector: '#t-toast',
|
||||
message: '保存成功',
|
||||
icon: '',
|
||||
});
|
||||
setTimeout(() => wx.navigateBack({ backRefresh: true }), 1000);
|
||||
})
|
||||
.catch(() => {
|
||||
this.setData({ submitting: false });
|
||||
});
|
||||
},
|
||||
|
||||
onScanTap() {
|
||||
wx.scanCode({
|
||||
scanType: ['barCode'],
|
||||
success: (res) => {
|
||||
Toast({
|
||||
context: this,
|
||||
selector: '#t-toast',
|
||||
message: '扫码成功',
|
||||
icon: '',
|
||||
});
|
||||
this.setData({ trackingNo: res.result });
|
||||
},
|
||||
fail: () => {},
|
||||
});
|
||||
},
|
||||
});
|
||||
14
miniprogram/pages/order/fill-tracking-no/index.json
Normal file
14
miniprogram/pages/order/fill-tracking-no/index.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"navigationBarTitleText": "填写运单号",
|
||||
"usingComponents": {
|
||||
"t-icon": "tdesign-miniprogram/icon/icon",
|
||||
"t-cell": "tdesign-miniprogram/cell/cell",
|
||||
"t-cell-group": "tdesign-miniprogram/cell-group/cell-group",
|
||||
"t-textarea": "tdesign-miniprogram/textarea/textarea",
|
||||
"t-input": "tdesign-miniprogram/input/input",
|
||||
"t-toast": "tdesign-miniprogram/toast/toast",
|
||||
"t-dialog": "tdesign-miniprogram/dialog/dialog",
|
||||
"t-button": "tdesign-miniprogram/button/button",
|
||||
"ui-reason-sheet": "../components/reason-sheet/index"
|
||||
}
|
||||
}
|
||||
56
miniprogram/pages/order/fill-tracking-no/index.wxml
Normal file
56
miniprogram/pages/order/fill-tracking-no/index.wxml
Normal file
@@ -0,0 +1,56 @@
|
||||
<view class="fill-tracking-no">
|
||||
<view class="notice-bar">请填写正确的退货包裹运单信息,以免影响退款进度</view>
|
||||
<view class="fill-tracking-no__form">
|
||||
<t-cell-group>
|
||||
<t-cell title="运单号" t-class-title="t-cell-title-width">
|
||||
<t-input
|
||||
slot="note"
|
||||
borderless
|
||||
t-class="t-cell__value"
|
||||
type="text"
|
||||
value="{{trackingNo}}"
|
||||
maxlength="30"
|
||||
placeholder="请输入物流单号"
|
||||
bind:change="onInput"
|
||||
data-key="trackingNo"
|
||||
/>
|
||||
|
||||
<t-icon slot="right-icon" name="scan" t-class="icon-scan" bindtap="onScanTap" />
|
||||
</t-cell>
|
||||
<t-cell
|
||||
t-class-title="t-cell-title-width"
|
||||
t-class-note="{{deliveryCompany && deliveryCompany.name ? 't-cell__value' : 't-cell__placeholder'}}"
|
||||
title="物流公司"
|
||||
note="{{deliveryCompany && deliveryCompany.name || '请选择物流公司'}}"
|
||||
arrow
|
||||
bindtap="onCompanyTap"
|
||||
/>
|
||||
</t-cell-group>
|
||||
<view class="textarea-wrapper">
|
||||
<text>备注信息</text>
|
||||
</view>
|
||||
<t-textarea
|
||||
t-class="t-textarea-wrapper"
|
||||
type="text"
|
||||
value="{{remark}}"
|
||||
maxlength="140"
|
||||
autosize
|
||||
placeholder="选填项,如有多个包裹寄回,请注明其运单信息"
|
||||
bind:change="onInput"
|
||||
data-key="remark"
|
||||
/>
|
||||
</view>
|
||||
<view class="fill-tracking-no__button-bar">
|
||||
<t-button
|
||||
t-class="btn {{ submitActived ? 'confirmBtn' : '' }}"
|
||||
disabled="{{!submitActived}}"
|
||||
loading="{{submitting}}"
|
||||
bindtap="onSubmit"
|
||||
>
|
||||
保存
|
||||
</t-button>
|
||||
</view>
|
||||
</view>
|
||||
<ui-reason-sheet id="wr-reason-sheet" />
|
||||
<t-toast id="t-toast" />
|
||||
<t-dialog id="t-dialog" />
|
||||
107
miniprogram/pages/order/fill-tracking-no/index.wxss
Normal file
107
miniprogram/pages/order/fill-tracking-no/index.wxss
Normal file
@@ -0,0 +1,107 @@
|
||||
@import '../../../style/theme.wxss';
|
||||
|
||||
:host {
|
||||
background-color: #f5f5f5;
|
||||
}
|
||||
|
||||
.notice-bar {
|
||||
padding: 24rpx 30rpx;
|
||||
text-align: center;
|
||||
font-size: 26rpx;
|
||||
color: #e17349;
|
||||
background: #fefcef;
|
||||
}
|
||||
|
||||
.fill-tracking-no__form {
|
||||
margin-top: 20rpx;
|
||||
}
|
||||
|
||||
.fill-tracking-no__form .t-cell__note {
|
||||
justify-content: flex-start;
|
||||
width: 340rpx;
|
||||
}
|
||||
.fill-tracking-no__form .t-cell__note text {
|
||||
margin-left: 10rpx;
|
||||
}
|
||||
|
||||
.fill-tracking-no__form .t-cell__value {
|
||||
color: #333 !important;
|
||||
font-size: 30rpx;
|
||||
text-align: left;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.fill-tracking-no__form .t-cell__value::after {
|
||||
border: none !important;
|
||||
}
|
||||
|
||||
.fill-tracking-no__form .t-cell__value .t-textarea__wrapper {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.fill-tracking-no__form .t-input__control,
|
||||
.fill-tracking-no__form .t-textarea__placeholder,
|
||||
.fill-tracking-no__form .t-cell__placeholder {
|
||||
font-size: 30rpx !important;
|
||||
}
|
||||
|
||||
.fill-tracking-no__form .t-textarea__placeholder,
|
||||
.fill-tracking-no__form .t-cell__placeholder {
|
||||
color: #bbbbbb !important;
|
||||
}
|
||||
|
||||
.t-textarea__note {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.fill-tracking-no__button-bar {
|
||||
margin: 38rpx 30rpx 0;
|
||||
}
|
||||
|
||||
.fill-tracking-no__button-bar .btn {
|
||||
background-color: transparent;
|
||||
font-size: 32rpx;
|
||||
width: 100%;
|
||||
border-radius: 48rpx;
|
||||
}
|
||||
|
||||
.fill-tracking-no__button-bar .btn:first-child {
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.fill-tracking-no__button-bar .btn.confirmBtn {
|
||||
background: #fa4126;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.fill-tracking-no__button-bar .btn.disabled {
|
||||
background-color: #c6c6c6;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.t-cell-title-width {
|
||||
width: 160rpx;
|
||||
flex: none !important;
|
||||
}
|
||||
.textarea-wrapper {
|
||||
background: #fff;
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
padding: 24rpx 32rpx 0 32rpx;
|
||||
}
|
||||
.t-textarea-wrapper {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.fill-tracking-no__form .t-input__wrapper {
|
||||
margin: 0 !important;
|
||||
}
|
||||
|
||||
.fill-tracking-no__form {
|
||||
--td-input-vertical-padding: 0;
|
||||
}
|
||||
|
||||
.t-button {
|
||||
--td-button-default-color: #aeb3b7;
|
||||
--td-button-primary-text-color: #fa4126;
|
||||
}
|
||||
38
miniprogram/pages/order/invoice/index.js
Normal file
38
miniprogram/pages/order/invoice/index.js
Normal file
@@ -0,0 +1,38 @@
|
||||
import { fetchOrderDetail } from '../../../services/order/orderDetail';
|
||||
|
||||
Page({
|
||||
data: {
|
||||
invoice: {},
|
||||
},
|
||||
onLoad({ orderNo }) {
|
||||
this.orderNo = orderNo;
|
||||
this.init();
|
||||
},
|
||||
init() {
|
||||
this.getDetail();
|
||||
},
|
||||
getDetail() {
|
||||
const params = {
|
||||
parameter: this.orderNo,
|
||||
};
|
||||
return fetchOrderDetail(params).then((res) => {
|
||||
const order = res.data;
|
||||
|
||||
const invoice = {
|
||||
buyerName: order?.invoiceVO?.buyerName, //个人或公司名称
|
||||
buyerTaxNo: order?.invoiceVO?.buyerTaxNo, //税号
|
||||
buyerPhone: order?.invoiceVO?.buyerPhone, //手机
|
||||
email: order?.invoiceVO?.email, //邮箱
|
||||
titleType: order?.invoiceVO?.titleType === 1 ? '个人' : '公司', //发票抬头 1-个人 2-公司
|
||||
ontentType: order?.invoiceVO?.ontentType === 1 ? '商品明细' : '2类别', //发票内容 1-明细 2类别
|
||||
invoiceType:
|
||||
order?.invoiceVO?.invoiceType === 5 ? '电子普通发票' : '不开发票', //是否开票 0-不开 5-电子发票
|
||||
isInvoice: order?.invoiceVO?.buyerName ? '已开票' : '未开票',
|
||||
money: order?.invoiceVO?.money,
|
||||
};
|
||||
this.setData({
|
||||
invoice,
|
||||
});
|
||||
});
|
||||
},
|
||||
});
|
||||
8
miniprogram/pages/order/invoice/index.json
Normal file
8
miniprogram/pages/order/invoice/index.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"navigationBarTitleText": "发票详情",
|
||||
"usingComponents": {
|
||||
"t-cell": "tdesign-miniprogram/cell/cell",
|
||||
"t-button": "tdesign-miniprogram/button/button",
|
||||
"t-cell-group": "tdesign-miniprogram/cell-group/cell-group"
|
||||
}
|
||||
}
|
||||
40
miniprogram/pages/order/invoice/index.wxml
Normal file
40
miniprogram/pages/order/invoice/index.wxml
Normal file
@@ -0,0 +1,40 @@
|
||||
<view class="invoice-detail">
|
||||
<view class="invoice-detail-box">
|
||||
<view class="invoice-detail-title">发票详情</view>
|
||||
<view class="invoice-detail-box-row">
|
||||
<view class="invoice-detail-box-title">发票类型</view>
|
||||
<view class="invoice-detail-box-value">{{invoice.invoiceType}}</view>
|
||||
</view>
|
||||
<view class="invoice-detail-box-row">
|
||||
<view class="invoice-detail-box-title">发票抬头</view>
|
||||
<view class="invoice-detail-box-value">{{invoice.buyerName}}</view>
|
||||
</view>
|
||||
<view class="invoice-detail-box-row">
|
||||
<view class="invoice-detail-box-title">纳税人识别号</view>
|
||||
<view class="invoice-detail-box-value">{{invoice.buyerTaxNo}}</view>
|
||||
</view>
|
||||
<view class="invoice-detail-box-row">
|
||||
<view class="invoice-detail-box-title">发票内容</view>
|
||||
<view class="invoice-detail-box-value">{{invoice.ontentType}}</view>
|
||||
</view>
|
||||
<view class="invoice-detail-box-row">
|
||||
<view class="invoice-detail-box-title">发票金额</view>
|
||||
<view class="invoice-detail-box-value">{{invoice.money}}</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="invoice-detail-box">
|
||||
<view class="invoice-detail-title">收票人信息</view>
|
||||
<view class="invoice-detail-box-row">
|
||||
<view class="invoice-detail-box-title">邮箱</view>
|
||||
<view class="invoice-detail-box-value">{{invoice.email}}</view>
|
||||
</view>
|
||||
<view class="invoice-detail-box-row">
|
||||
<view class="invoice-detail-box-title">手机号</view>
|
||||
<view class="invoice-detail-box-value">{{invoice.buyerPhone}}</view>
|
||||
</view>
|
||||
<view class="invoice-detail-box-row">
|
||||
<view class="invoice-detail-box-title">开票状态</view>
|
||||
<view class="invoice-detail-box-value">{{invoice.isInvoice}}</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
31
miniprogram/pages/order/invoice/index.wxss
Normal file
31
miniprogram/pages/order/invoice/index.wxss
Normal file
@@ -0,0 +1,31 @@
|
||||
:host {
|
||||
background-color: #f5f5f5;
|
||||
}
|
||||
|
||||
.invoice-detail .invoice-detail-box {
|
||||
background-color: #fff;
|
||||
padding: 24rpx 32rpx;
|
||||
margin-top: 24rpx;
|
||||
}
|
||||
|
||||
.invoice-detail-title {
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.invoice-detail-box-row {
|
||||
display: flex;
|
||||
margin-top: 44rpx;
|
||||
}
|
||||
|
||||
.invoice-detail-box-title {
|
||||
font-size: 13px;
|
||||
color: #666666;
|
||||
width: 156rpx;
|
||||
margin-right: 32rpx;
|
||||
}
|
||||
|
||||
.invoice-detail-box-value {
|
||||
font-size: 13px;
|
||||
color: #333333;
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
Component({
|
||||
externalClasses: ['wr-class'],
|
||||
properties: {
|
||||
addressData: {
|
||||
type: Object,
|
||||
value: {},
|
||||
observer: function(newVal, oldVal) {
|
||||
// 确保数据正确传递到模板
|
||||
if (newVal && Object.keys(newVal).length > 0) {
|
||||
const processedAddress = {
|
||||
...newVal,
|
||||
// 确保区域信息字段存在
|
||||
provinceName: newVal.provinceName || '',
|
||||
cityName: newVal.cityName || '',
|
||||
districtName: newVal.districtName || '',
|
||||
detailAddress: newVal.detailAddress || '',
|
||||
name: newVal.name || '',
|
||||
phone: newVal.phone || '',
|
||||
addressTag: newVal.addressTag || ''
|
||||
};
|
||||
|
||||
// 直接设置到组件的data中,确保模板能访问
|
||||
this.setData({
|
||||
currentAddress: processedAddress
|
||||
});
|
||||
} else {
|
||||
// 如果没有地址数据,设置为空对象而不是null,这样模板的条件判断能正确工作
|
||||
this.setData({
|
||||
currentAddress: {}
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
data: {
|
||||
currentAddress: {}
|
||||
},
|
||||
methods: {
|
||||
onAddressTap() {
|
||||
this.triggerEvent('addressclick');
|
||||
},
|
||||
onAddTap() {
|
||||
this.triggerEvent('addclick');
|
||||
},
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {
|
||||
"t-cell": "tdesign-miniprogram/cell/cell",
|
||||
"t-icon": "tdesign-miniprogram/icon/icon"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
<wxs module="utils">
|
||||
var hidePhoneNum = function(array) {
|
||||
if (!array) return;
|
||||
var mphone = array.substring(0, 3) + '****' + array.substring(7);
|
||||
return mphone;
|
||||
}
|
||||
module.exports = {
|
||||
hidePhoneNum:hidePhoneNum
|
||||
}
|
||||
</wxs>
|
||||
|
||||
<view class="address-card wr-class">
|
||||
<t-cell wx:if="{{currentAddress && (currentAddress.detailAddress || currentAddress.name)}}" bindtap="onAddressTap" hover>
|
||||
<view class="order-address" slot="title">
|
||||
<t-icon name="location" color="#333333" size="40rpx" />
|
||||
<view class="address-content">
|
||||
<view class="title">
|
||||
<view class="address-tag" wx:if="{{currentAddress.addressTag}}">
|
||||
{{currentAddress.addressTag}}
|
||||
</view>
|
||||
<view style="margin-top: 10rpx;">
|
||||
<text wx:if="{{currentAddress.provinceName}}">{{currentAddress.provinceName}}</text>
|
||||
<text wx:if="{{currentAddress.cityName}}"> {{currentAddress.cityName}}</text>
|
||||
<text wx:if="{{currentAddress.districtName}}"> {{currentAddress.districtName}}</text>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
<view class="detail">{{currentAddress.detailAddress}}</view>
|
||||
<view class="info">
|
||||
{{currentAddress.name}} {{utils.hidePhoneNum(currentAddress.phone)}}
|
||||
</view>
|
||||
</view>
|
||||
<t-icon
|
||||
class="address__right"
|
||||
name="chevron-right"
|
||||
color="#BBBBBB"
|
||||
size="40rpx"
|
||||
/>
|
||||
</view>
|
||||
</t-cell>
|
||||
<t-cell
|
||||
wx:else
|
||||
bindtap="onAddTap"
|
||||
title="添加收货地址"
|
||||
hover
|
||||
>
|
||||
<t-icon name="add-circle" slot="left-icon" size="40rpx" />
|
||||
</t-cell>
|
||||
<view class="top-line" />
|
||||
</view>
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
.address-card {
|
||||
background: #fff;
|
||||
margin: 0rpx 0rpx 24rpx;
|
||||
}
|
||||
.address-card .wr-cell__title {
|
||||
color: #999;
|
||||
margin-left: 6rpx;
|
||||
}
|
||||
.address-card .order-address {
|
||||
display: flex;
|
||||
width: 100%;
|
||||
}
|
||||
.address-card .order-address .address-content {
|
||||
flex: 1;
|
||||
}
|
||||
.order-address .address__right {
|
||||
align-self: center;
|
||||
}
|
||||
.address-card .order-address .title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
height: 40rpx;
|
||||
font-size: 28rpx;
|
||||
font-weight: normal;
|
||||
color: #999999;
|
||||
line-height: 40rpx;
|
||||
}
|
||||
.address-card .order-address .title .address-tag {
|
||||
width: 52rpx;
|
||||
height: 29rpx;
|
||||
border: 1rpx solid #0091ff;
|
||||
background-color: rgba(122, 167, 251, 0.1);
|
||||
text-align: center;
|
||||
line-height: 29rpx;
|
||||
border-radius: 8rpx;
|
||||
color: #0091ff;
|
||||
font-size: 20rpx;
|
||||
margin-right: 12rpx;
|
||||
}
|
||||
.address-card .order-address .detail {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
display: -webkit-box;
|
||||
-webkit-box-orient: vertical;
|
||||
-webkit-line-clamp: 2;
|
||||
font-size: 36rpx;
|
||||
font-weight: bold;
|
||||
color: #333333;
|
||||
line-height: 48rpx;
|
||||
margin: 8rpx 0;
|
||||
}
|
||||
.address-card .order-address .info {
|
||||
height: 40rpx;
|
||||
font-size: 28rpx;
|
||||
font-weight: normal;
|
||||
color: #333333;
|
||||
line-height: 40rpx;
|
||||
}
|
||||
.address-card .top-line {
|
||||
width: 100%;
|
||||
height: 6rpx;
|
||||
background-color: #fff;
|
||||
background-image: url(https://tdesign.gtimg.com/miniprogram/template/retail/order/stripe.png);
|
||||
background-repeat: repeat-x;
|
||||
display: block;
|
||||
}
|
||||
11
miniprogram/pages/order/order-confirm/getNotes.wxs
Normal file
11
miniprogram/pages/order/order-confirm/getNotes.wxs
Normal file
@@ -0,0 +1,11 @@
|
||||
var getNotes = function (storeInfoList, storeIndex) {
|
||||
if (!storeInfoList || typeof storeInfoList !== 'object' || typeof storeInfoList.length !== 'number' || storeIndex < 0 || storeIndex >= storeInfoList.length) {
|
||||
return '';
|
||||
}
|
||||
var storeInfo = storeInfoList[storeIndex];
|
||||
if (!storeInfo) {
|
||||
return '';
|
||||
}
|
||||
return storeInfo.remark || '';
|
||||
};
|
||||
module.exports = getNotes;
|
||||
11
miniprogram/pages/order/order-confirm/handleInvoice.wxs
Normal file
11
miniprogram/pages/order/order-confirm/handleInvoice.wxs
Normal file
@@ -0,0 +1,11 @@
|
||||
var handleInvoice = function (invoiceData) {
|
||||
if (!invoiceData || invoiceData.invoiceType == 0) {
|
||||
return '暂不开发票';
|
||||
}
|
||||
var title = invoiceData.titleType == 2 ? '公司' : '个人';
|
||||
var content = invoiceData.contentType == 2 ? '商品类别' : '商品明细';
|
||||
return invoiceData.email
|
||||
? '电子普通发票 (' + content + ' - ' + title + ')'
|
||||
: '暂不开发票';
|
||||
};
|
||||
module.exports = handleInvoice;
|
||||
1154
miniprogram/pages/order/order-confirm/index.js
Normal file
1154
miniprogram/pages/order/order-confirm/index.js
Normal file
File diff suppressed because it is too large
Load Diff
16
miniprogram/pages/order/order-confirm/index.json
Normal file
16
miniprogram/pages/order/order-confirm/index.json
Normal file
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"navigationBarTitleText": "订单确认",
|
||||
"usingComponents": {
|
||||
"t-popup": "tdesign-miniprogram/popup/popup",
|
||||
"t-toast": "tdesign-miniprogram/toast/toast",
|
||||
"t-icon": "tdesign-miniprogram/icon/icon",
|
||||
"t-cell": "tdesign-miniprogram/cell/cell",
|
||||
"t-dialog": "tdesign-miniprogram/dialog/dialog",
|
||||
"t-textarea": "tdesign-miniprogram/textarea/textarea",
|
||||
"price": "/components/price/index",
|
||||
"select-coupons": "../components/selectCoupons/selectCoupons",
|
||||
"no-goods": "../components/noGoods/noGoods",
|
||||
"t-image": "/components/webp-image/index",
|
||||
"address-card": "./components/address-card/index"
|
||||
}
|
||||
}
|
||||
150
miniprogram/pages/order/order-confirm/index.wxml
Normal file
150
miniprogram/pages/order/order-confirm/index.wxml
Normal file
@@ -0,0 +1,150 @@
|
||||
<wxs module="order" src="./order.wxs" />
|
||||
|
||||
<wxs module="handleInvoice" src="./handleInvoice.wxs" />
|
||||
<wxs module="getNotes" src="./getNotes.wxs" />
|
||||
<view class="order-sure" wx:if="{{!loading}}">
|
||||
<address-card addressData="{{userAddress}}" bind:addclick="onGotoAddress" bind:addressclick="onGotoAddress" />
|
||||
<view
|
||||
class="order-wrapper"
|
||||
wx:for="{{settleDetailData.storeGoodsList}}"
|
||||
wx:for-item="stores"
|
||||
wx:for-index="storeIndex"
|
||||
wx:key="storeIndex"
|
||||
>
|
||||
<view class="store-wrapper">
|
||||
<t-icon prefix="wr" size="40rpx" color="#333333" name="store" class="store-logo" />
|
||||
{{stores.storeName}}
|
||||
</view>
|
||||
<view
|
||||
wx:if="{{orderCardList[storeIndex] && orderCardList[storeIndex].goodsList && orderCardList[storeIndex].goodsList.length > 0}}"
|
||||
wx:for="{{orderCardList[storeIndex] && orderCardList[storeIndex].goodsList || []}}"
|
||||
wx:for-item="goods"
|
||||
wx:for-index="gIndex"
|
||||
wx:key="id"
|
||||
class="goods-wrapper"
|
||||
>
|
||||
<t-image src="{{goods.thumb}}" t-class="goods-image" mode="aspectFill" bind:error="handleImageError" />
|
||||
<view class="goods-content">
|
||||
<view class="goods-title">{{goods.title}}</view>
|
||||
<view>{{goods.specs}}</view>
|
||||
</view>
|
||||
<view class="goods-right">
|
||||
<price wr-class="goods-price" priceUnit="fen" price="{{goods.price}}" fill="{{true}}" decimalSmaller />
|
||||
<view class="goods-num">x{{goods.num}}</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="pay-detail">
|
||||
<view class="pay-item">
|
||||
<text>商品总额</text>
|
||||
<price
|
||||
fill
|
||||
decimalSmaller
|
||||
priceUnit="fen"
|
||||
wr-class="pay-item__right font-bold"
|
||||
price="{{settleDetailData.totalSalePrice || '0'}}"
|
||||
/>
|
||||
</view>
|
||||
<view class="pay-item">
|
||||
<text>运费</text>
|
||||
<view class="pay-item__right font-bold">
|
||||
<block wx:if="{{settleDetailData.totalDeliveryFee && settleDetailData.totalDeliveryFee != 0}}">
|
||||
+
|
||||
<price fill decimalSmaller priceUnit="fen" price="{{settleDetailData.totalDeliveryFee}}" />
|
||||
</block>
|
||||
<text wx:else>免运费</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="pay-item">
|
||||
<text>活动优惠</text>
|
||||
<view class="pay-item__right primary font-bold">
|
||||
-
|
||||
<price fill priceUnit="fen" price="{{settleDetailData.totalPromotionAmount || 0}}" />
|
||||
</view>
|
||||
</view>
|
||||
<view class="pay-item">
|
||||
<text>优惠券</text>
|
||||
<view
|
||||
class="pay-item__right"
|
||||
data-storeid="{{settleDetailData.storeGoodsList && settleDetailData.storeGoodsList[0] && settleDetailData.storeGoodsList[0].storeId || ''}}"
|
||||
catchtap="onOpenCoupons"
|
||||
>
|
||||
<block wx:if="{{settleDetailData.totalCouponAmount && settleDetailData.totalCouponAmount !== '0'}}">
|
||||
-<price fill decimalSmaller priceUnit="fen" price="{{settleDetailData.totalCouponAmount}}" />
|
||||
</block>
|
||||
<text wx:else>选择优惠券</text>
|
||||
<t-icon name="chevron-right" size="32rpx" color="#BBBBBB" />
|
||||
</view>
|
||||
</view>
|
||||
<view class="pay-item" wx:if="{{settleDetailData.invoiceSupport}}">
|
||||
<text>发票</text>
|
||||
<view class="pay-item__right" catchtap="onReceipt">
|
||||
<text>{{handleInvoice(invoiceData)}}</text>
|
||||
<t-icon name="chevron-right" size="32rpx" color="#BBBBBB" />
|
||||
</view>
|
||||
</view>
|
||||
<view class="pay-item">
|
||||
<text>订单备注</text>
|
||||
<view class="pay-item__right" data-storenoteindex="{{0}}" catchtap="onNotes">
|
||||
<text class="pay-remark"
|
||||
>{{getNotes(storeInfoList, 0) ? getNotes(storeInfoList, 0) :'选填,建议先和商家沟通确认'}}</text
|
||||
>
|
||||
<t-icon name="chevron-right" size="32rpx" color="#BBBBBB" />
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="amount-wrapper">
|
||||
<view class="pay-amount">
|
||||
<text class="order-num">共{{settleDetailData.totalGoodsCount}}件</text>
|
||||
<text>小计</text>
|
||||
<price class="total-price" priceUnit="fen" price="{{settleDetailData.totalPayAmount}}" fill="{{false}}" decimalSmaller />
|
||||
</view>
|
||||
</view>
|
||||
<view class="wx-pay-cover">
|
||||
<view class="wx-pay">
|
||||
<price decimalSmaller fill priceUnit="fen" class="price" price="{{settleDetailData.totalPayAmount || '0'}}" />
|
||||
<view class="submit-btn {{ !payLock && settleDetailData.totalAmount > 0 ? '':'btn-gray'}}" bindtap="submitOrder">
|
||||
{{payLock ? '提交中...' : '提交订单'}}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<t-dialog
|
||||
t-class="add-notes"
|
||||
title="填写备注信息"
|
||||
visible="{{dialogShow}}"
|
||||
confirm-btn="确认"
|
||||
cancel-btn="取消"
|
||||
t-class-content="add-notes__content"
|
||||
t-class-confirm="dialog__button-confirm"
|
||||
t-class-cancel="dialog__button-cancel"
|
||||
bindconfirm="onNoteConfirm"
|
||||
bindcancel="onNoteCancel"
|
||||
>
|
||||
<t-textarea
|
||||
slot="content"
|
||||
focus="{{dialogShow}}"
|
||||
class="notes"
|
||||
t-class="add-notes__textarea"
|
||||
value="{{storeInfoList[storeNoteIndex] && storeInfoList[storeNoteIndex].remark}}"
|
||||
placeholder="备注信息"
|
||||
t-class-textarea="add-notes__textarea__font"
|
||||
bindfocus="onFocus"
|
||||
bindblur="onBlur"
|
||||
bindchange="onInput"
|
||||
maxlength="{{50}}"
|
||||
/>
|
||||
</t-dialog>
|
||||
<t-popup visible="{{popupShow}}" placement="bottom" bind:visible-change="onPopupChange">
|
||||
<no-goods slot="content" bind:change="onSureCommit" settleDetailData="{{settleDetailData}}" />
|
||||
</t-popup>
|
||||
<select-coupons
|
||||
bind:sure="onCoupons"
|
||||
bind:close="onCouponsClose"
|
||||
storeId="{{currentStoreId}}"
|
||||
orderSureCouponList="{{couponList}}"
|
||||
promotionGoodsList="{{promotionGoodsList}}"
|
||||
couponsShow="{{couponsShow}}"
|
||||
/>
|
||||
</view>
|
||||
<t-toast id="t-toast" />
|
||||
<t-dialog id="t-dialog" />
|
||||
221
miniprogram/pages/order/order-confirm/index.wxss
Normal file
221
miniprogram/pages/order/order-confirm/index.wxss
Normal file
@@ -0,0 +1,221 @@
|
||||
.order-sure {
|
||||
box-sizing: border-box;
|
||||
background: #f6f6f6;
|
||||
padding: 24rpx 0 calc(env(safe-area-inset-bottom) + 136rpx);
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
.order-sure .wx-pay-cover {
|
||||
position: fixed;
|
||||
left: 0;
|
||||
bottom: 0;
|
||||
right: 0;
|
||||
z-index: 10;
|
||||
background: #fff;
|
||||
height: 112rpx;
|
||||
padding-bottom: env(safe-area-inset-bottom);
|
||||
}
|
||||
.order-sure .wx-pay-cover .wx-pay {
|
||||
width: 100%;
|
||||
height: 100rpx;
|
||||
box-sizing: border-box;
|
||||
padding: 0rpx 32rpx;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
.order-sure .wx-pay-cover .wx-pay .price {
|
||||
color: #fa4126;
|
||||
font-weight: bold;
|
||||
font-size: 63rpx;
|
||||
line-height: 88rpx;
|
||||
}
|
||||
|
||||
.order-sure .wx-pay-cover .wx-pay .submit-btn {
|
||||
height: 80rpx;
|
||||
width: 240rpx;
|
||||
border-radius: 40rpx;
|
||||
background-color: #fa4126;
|
||||
color: #ffffff;
|
||||
line-height: 80rpx;
|
||||
font-weight: bold;
|
||||
font-size: 28rpx;
|
||||
text-align: center;
|
||||
}
|
||||
.order-sure .wx-pay-cover .wx-pay .btn-gray {
|
||||
background: #cccccc;
|
||||
}
|
||||
|
||||
.order-wrapper .store-wrapper {
|
||||
width: 100%;
|
||||
height: 96rpx;
|
||||
box-sizing: border-box;
|
||||
padding: 0 32rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
font-size: 28rpx;
|
||||
line-height: 40rpx;
|
||||
color: #333333;
|
||||
background-color: #ffffff;
|
||||
}
|
||||
.order-wrapper .store-wrapper .store-logo {
|
||||
margin-right: 16rpx;
|
||||
}
|
||||
.order-wrapper .goods-wrapper {
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
padding: 16rpx 32rpx;
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
font-size: 24rpx;
|
||||
line-height: 32rpx;
|
||||
color: #999999;
|
||||
background-color: #ffffff;
|
||||
}
|
||||
.goods-wrapper .goods-image {
|
||||
width: 176rpx;
|
||||
height: 176rpx;
|
||||
border-radius: 8rpx;
|
||||
overflow: hidden;
|
||||
margin-right: 16rpx;
|
||||
}
|
||||
.goods-wrapper .goods-content {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.goods-wrapper .goods-content .goods-title {
|
||||
display: -webkit-box;
|
||||
-webkit-box-orient: vertical;
|
||||
-webkit-line-clamp: 2;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
font-size: 28rpx;
|
||||
line-height: 40rpx;
|
||||
margin-bottom: 12rpx;
|
||||
color: #333333;
|
||||
margin-right: 16rpx;
|
||||
}
|
||||
|
||||
.goods-wrapper .goods-right {
|
||||
min-width: 128rpx;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-end;
|
||||
}
|
||||
|
||||
.goods-right .goods-price {
|
||||
color: #333333;
|
||||
font-size: 32rpx;
|
||||
line-height: 48rpx;
|
||||
font-weight: bold;
|
||||
margin-bottom: 16rpx;
|
||||
}
|
||||
|
||||
.goods-right .goods-num {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.order-sure .pay-detail {
|
||||
background-color: #ffffff;
|
||||
padding: 16rpx 32rpx;
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.order-sure .pay-detail .pay-item {
|
||||
width: 100%;
|
||||
height: 72rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
font-size: 26rpx;
|
||||
line-height: 36rpx;
|
||||
color: #666666;
|
||||
}
|
||||
.order-sure .pay-detail .pay-item .pay-item__right {
|
||||
color: #333333;
|
||||
font-size: 24rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
max-width: 400rpx;
|
||||
}
|
||||
.order-sure .pay-detail .pay-item .pay-item__right .pay-remark {
|
||||
display: -webkit-box;
|
||||
-webkit-box-orient: vertical;
|
||||
-webkit-line-clamp: 2;
|
||||
max-width: 400rpx;
|
||||
text-overflow: ellipsis;
|
||||
overflow: hidden;
|
||||
}
|
||||
.order-sure .pay-detail .pay-item .font-bold {
|
||||
font-weight: bold;
|
||||
}
|
||||
.order-sure .pay-detail .pay-item .primary {
|
||||
color: #fa4126;
|
||||
}
|
||||
|
||||
.add-notes .add-notes__content {
|
||||
--td-textarea-background-color: #f5f5f5;
|
||||
}
|
||||
|
||||
.add-notes .t-textarea__placeholder {
|
||||
color: #aeb3b7;
|
||||
}
|
||||
|
||||
.add-notes .add-notes__textarea__font {
|
||||
font-size: 26rpx;
|
||||
}
|
||||
.add-notes .add-notes__textarea {
|
||||
margin-top: 32rpx;
|
||||
}
|
||||
|
||||
.order-sure .add-notes .dialog__message {
|
||||
border-radius: 8rpx;
|
||||
}
|
||||
|
||||
.order-sure .add-notes .dialog__button-cancel::after {
|
||||
border-right: 0;
|
||||
}
|
||||
|
||||
.order-sure .amount-wrapper {
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
background-color: #ffffff;
|
||||
padding: 0rpx 32rpx;
|
||||
height: 96rpx;
|
||||
}
|
||||
|
||||
.order-sure .pay-amount {
|
||||
width: 100%;
|
||||
height: 96rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
font-size: 28rpx;
|
||||
color: #333333;
|
||||
position: relative;
|
||||
}
|
||||
.order-sure .pay-amount::after {
|
||||
position: absolute;
|
||||
content: ' ';
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 200%;
|
||||
height: 200%;
|
||||
transform: scale(0.5);
|
||||
transform-origin: 0 0;
|
||||
border-top: 2rpx solid #f5f5f5;
|
||||
}
|
||||
.order-sure .pay-amount .order-num {
|
||||
color: #999999;
|
||||
padding-right: 8rpx;
|
||||
}
|
||||
|
||||
.order-sure .pay-amount .total-price {
|
||||
font-size: 36rpx;
|
||||
color: #fa4126;
|
||||
font-weight: bold;
|
||||
padding-left: 8rpx;
|
||||
}
|
||||
8
miniprogram/pages/order/order-confirm/order.wxs
Normal file
8
miniprogram/pages/order/order-confirm/order.wxs
Normal file
@@ -0,0 +1,8 @@
|
||||
var toHide = function (array) {
|
||||
if (!array) return;
|
||||
var mphone = array.substring(0, 3) + '****' + array.substring(7);
|
||||
return mphone;
|
||||
};
|
||||
module.exports = {
|
||||
toHide: toHide,
|
||||
};
|
||||
253
miniprogram/pages/order/order-confirm/pay.js
Normal file
253
miniprogram/pages/order/order-confirm/pay.js
Normal file
@@ -0,0 +1,253 @@
|
||||
import Dialog from 'tdesign-miniprogram/dialog/index';
|
||||
import Toast from 'tdesign-miniprogram/toast/index';
|
||||
|
||||
import { dispatchCommitPay } from '../../../services/order/orderConfirm';
|
||||
import { config } from '../../../config/index';
|
||||
|
||||
// 真实的提交支付
|
||||
export const commitPay = (params) => {
|
||||
console.log('=== pay.js commitPay 调试 ===');
|
||||
console.log('接收到的params:', params);
|
||||
console.log('params.couponList:', params.couponList);
|
||||
if (params.couponList && params.couponList.length > 0) {
|
||||
console.log('第一张优惠券详情:', params.couponList[0]);
|
||||
console.log('优惠券ID字段检查:', {
|
||||
id: params.couponList[0].id,
|
||||
couponId: params.couponList[0].couponId,
|
||||
userCouponId: params.couponList[0].userCouponId,
|
||||
allFields: Object.keys(params.couponList[0])
|
||||
});
|
||||
}
|
||||
|
||||
return dispatchCommitPay({
|
||||
goodsRequestList: params.goodsRequestList, // 待结算的商品集合
|
||||
invoiceRequest: params.invoiceRequest, // 发票信息
|
||||
// isIgnore: params.isIgnore || false, // 删掉 是否忽视库存不足和商品失效,继续结算,true=继续结算 购物车请赋值false
|
||||
userAddressReq: params.userAddressReq, // 地址信息(用户在购物选择更换地址)
|
||||
currency: params.currency || 'CNY', // 支付货币: 人民币=CNY,美元=USD
|
||||
logisticsType: params.logisticsType || 1, // 配送方式 0=无需配送 1=快递 2=商家 3=同城 4=自提
|
||||
// orderMark: params.orderMark, // 下单备注
|
||||
orderType: params.orderType || 0, // 订单类型 0=普通订单 1=虚拟订单
|
||||
payType: params.payType || 1, // 支付类型(0=线上、1=线下)
|
||||
totalAmount: params.totalAmount, // 新增字段"totalAmount"总的支付金额
|
||||
userName: params.userName, // 用户名
|
||||
payWay: 1,
|
||||
authorizationCode: '', //loginCode, // 登录凭证
|
||||
storeInfoList: params.storeInfoList, //备注信息列表
|
||||
couponList: params.couponList,
|
||||
groupInfo: params.groupInfo,
|
||||
});
|
||||
};
|
||||
|
||||
export const paySuccess = (payOrderInfo, pageContext = null) => {
|
||||
const { payAmt, tradeNo, groupId, promotionId } = payOrderInfo;
|
||||
// 支付成功
|
||||
console.log('支付成功,准备跳转到支付结果页面', payOrderInfo);
|
||||
|
||||
// 显示成功提示,如果有页面上下文则使用,否则使用全局提示
|
||||
if (pageContext) {
|
||||
Toast({
|
||||
context: pageContext,
|
||||
selector: '#t-toast',
|
||||
message: '支付成功',
|
||||
duration: 1500,
|
||||
icon: 'check-circle',
|
||||
});
|
||||
} else {
|
||||
wx.showToast({
|
||||
title: '支付成功',
|
||||
icon: 'success',
|
||||
duration: 1500
|
||||
});
|
||||
}
|
||||
|
||||
const params = {
|
||||
totalPaid: payAmt,
|
||||
orderNo: tradeNo,
|
||||
};
|
||||
if (groupId) {
|
||||
params.groupId = groupId;
|
||||
}
|
||||
if (promotionId) {
|
||||
params.promotionId = promotionId;
|
||||
}
|
||||
const paramsStr = Object.keys(params)
|
||||
.map((k) => `${k}=${params[k]}`)
|
||||
.join('&');
|
||||
|
||||
// 确保提示显示完成后再跳转
|
||||
setTimeout(() => {
|
||||
console.log('准备跳转到支付结果页面', `/pages/order/pay-result/index?${paramsStr}`);
|
||||
|
||||
// 直接使用redirectTo进行页面跳转
|
||||
wx.redirectTo({
|
||||
url: `/pages/order/pay-result/index?${paramsStr}`,
|
||||
success: () => {
|
||||
console.log('跳转到支付结果页面成功');
|
||||
},
|
||||
fail: (err) => {
|
||||
console.error('跳转到支付结果页面失败', err);
|
||||
// 如果redirectTo失败,尝试使用navigateTo
|
||||
wx.navigateTo({
|
||||
url: `/pages/order/pay-result/index?${paramsStr}`,
|
||||
fail: (navErr) => {
|
||||
console.error('navigateTo也失败了', navErr);
|
||||
// 最后尝试使用reLaunch
|
||||
wx.reLaunch({
|
||||
url: `/pages/order/pay-result/index?${paramsStr}`,
|
||||
fail: (relaunchErr) => {
|
||||
console.error('所有跳转方式都失败了', relaunchErr);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}, 1600); // 延迟1.6秒后跳转,确保Toast显示完成
|
||||
};
|
||||
|
||||
export const payFail = (payOrderInfo, resultMsg) => {
|
||||
if (resultMsg === 'requestPayment:fail cancel') {
|
||||
if (payOrderInfo.dialogOnCancel) {
|
||||
//结算页,取消付款,dialog提示
|
||||
Dialog.confirm({
|
||||
title: '是否放弃付款',
|
||||
content: '商品可能很快就会被抢空哦,是否放弃付款?',
|
||||
confirmBtn: '放弃',
|
||||
cancelBtn: '继续付款',
|
||||
}).then(() => {
|
||||
wx.redirectTo({ url: '/pages/order/order-list/index' });
|
||||
});
|
||||
} else {
|
||||
//订单列表页,订单详情页,取消付款,toast提示
|
||||
Toast({
|
||||
context: this,
|
||||
selector: '#t-toast',
|
||||
message: '支付取消',
|
||||
duration: 2000,
|
||||
icon: 'close-circle',
|
||||
});
|
||||
}
|
||||
} else {
|
||||
Toast({
|
||||
context: this,
|
||||
selector: '#t-toast',
|
||||
message: `支付失败:${resultMsg}`,
|
||||
duration: 2000,
|
||||
icon: 'close-circle',
|
||||
});
|
||||
setTimeout(() => {
|
||||
wx.redirectTo({ url: '/pages/order/order-list/index' });
|
||||
}, 2000);
|
||||
}
|
||||
};
|
||||
|
||||
// 微信支付方式
|
||||
export const wechatPayOrder = (payOrderInfo, pageContext = null) => {
|
||||
console.log('开始微信支付流程', payOrderInfo);
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
// 获取token
|
||||
const token = wx.getStorageSync('token');
|
||||
if (!token) {
|
||||
wx.showModal({
|
||||
title: '提示',
|
||||
content: '请先登录后再进行支付',
|
||||
showCancel: true,
|
||||
cancelText: '取消',
|
||||
confirmText: '去登录',
|
||||
success: (res) => {
|
||||
if (res.confirm) {
|
||||
wx.navigateTo({
|
||||
url: '/pages/login/index'
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
reject(new Error('未登录'));
|
||||
return;
|
||||
}
|
||||
|
||||
// 显示支付中提示
|
||||
wx.showLoading({ title: '创建支付订单...' });
|
||||
|
||||
// 调用后端创建支付订单API
|
||||
wx.request({
|
||||
url: `${config.apiBase}/payment/create`,
|
||||
method: 'POST',
|
||||
header: {
|
||||
'Authorization': `Bearer ${token}`,
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
data: {
|
||||
orderNo: payOrderInfo.tradeNo,
|
||||
paymentMethod: 'wechat'
|
||||
},
|
||||
success: (res) => {
|
||||
console.log('创建支付订单API响应:', res);
|
||||
|
||||
if (res.statusCode === 200 && res.data.code === 200) {
|
||||
const paymentData = res.data.data;
|
||||
|
||||
// 如果返回了微信支付参数,调用微信支付SDK
|
||||
if (paymentData && paymentData.payInfo) {
|
||||
wx.hideLoading();
|
||||
wx.showLoading({ title: '调起微信支付...' });
|
||||
|
||||
try {
|
||||
const payInfo = typeof paymentData.payInfo === 'string'
|
||||
? JSON.parse(paymentData.payInfo)
|
||||
: paymentData.payInfo;
|
||||
|
||||
console.log('微信支付参数:', payInfo);
|
||||
|
||||
wx.requestPayment({
|
||||
timeStamp: payInfo.timeStamp,
|
||||
nonceStr: payInfo.nonceStr,
|
||||
package: payInfo.package,
|
||||
signType: payInfo.signType || 'RSA',
|
||||
paySign: payInfo.paySign,
|
||||
success: function (payRes) {
|
||||
wx.hideLoading();
|
||||
console.log('微信支付成功:', payRes);
|
||||
paySuccess(payOrderInfo, pageContext);
|
||||
resolve();
|
||||
},
|
||||
fail: function (payErr) {
|
||||
wx.hideLoading();
|
||||
console.error('微信支付失败:', payErr);
|
||||
payFail(payOrderInfo, payErr.errMsg);
|
||||
reject(payErr);
|
||||
}
|
||||
});
|
||||
} catch (parseErr) {
|
||||
wx.hideLoading();
|
||||
console.error('解析支付参数失败:', parseErr);
|
||||
payFail(payOrderInfo, '支付参数解析失败');
|
||||
reject(parseErr);
|
||||
}
|
||||
} else {
|
||||
// 如果没有返回微信支付参数,可能是模拟支付成功
|
||||
wx.hideLoading();
|
||||
console.log('支付处理完成,调用支付成功回调');
|
||||
paySuccess(payOrderInfo, pageContext);
|
||||
resolve();
|
||||
}
|
||||
} else {
|
||||
wx.hideLoading();
|
||||
console.error('创建支付订单失败:', res.data.message);
|
||||
const errorMsg = res.data.message || '创建支付订单失败';
|
||||
payFail(payOrderInfo, errorMsg);
|
||||
reject(new Error(errorMsg));
|
||||
}
|
||||
},
|
||||
fail: (err) => {
|
||||
wx.hideLoading();
|
||||
console.error('创建支付订单请求失败:', err);
|
||||
const errorMsg = '网络错误,支付失败';
|
||||
payFail(payOrderInfo, errorMsg);
|
||||
reject(err);
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user