Files
kangyuan-mobile/pages/order/express/log.vue
T

319 lines
8.6 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!-- 物流追踪 -->
<template>
<s-layout title="物流追踪">
<view class="log-wrap">
<!-- 商品信息 -->
<view class="log-card ss-flex ss-m-20 ss-r-10" v-if="goodsImages.length > 0">
<uni-swiper-dot :info="goodsImages" :current="state.current" mode="round">
<swiper class="swiper-box">
<swiper-item v-for="(item, index) in goodsImages" :key="index">
<image class="log-card-img" :src="sheep.$url.static(item.image)" />
</swiper-item>
</swiper>
</uni-swiper-dot>
<view class="log-card-msg">
<!-- TODO 芋艿:【物流】优化点:展示状态 -->
<!-- <view class="ss-flex ss-m-b-8">-->
<!-- <view>物流状态:</view>-->
<!-- <view class="warning-color">{{ state.info.status_text }}</view>-->
<!-- </view>-->
<view class="ss-m-b-8">快递单号:{{ state.info.logisticsNo }}</view>
<view>快递公司:{{ state.info.logisticsName }}</view>
</view>
</view>
<!-- 物流轨迹 -->
<view class="log-content ss-m-20 ss-r-10">
<view
class="log-content-box ss-flex"
v-for="(item, index) in state.tracks"
:key="item.title"
>
<view class="log-icon ss-flex-col ss-col-center ss-m-r-20">
<text class="cicon-title" />
<view v-if="state.tracks.length - 1 !== index" class="line" />
</view>
<view class="log-content-msg">
<!-- TODO 芋艿:【物流】优化点:展示状态 -->
<!-- <view class="log-msg-title ss-m-b-20">-->
<!-- {{ item.status_text }}-->
<!-- </view>-->
<!-- <view class="log-msg-desc ss-m-b-16">{{ item.content }}</view>-->
<view class="log-msg-desc ss-m-b-16">
<highlight-number :content="item.content" @phone-click="handlePhoneClick" />
<!-- <rich-text :nodes="item.content"></rich-text>-->
</view>
<view class="log-msg-date ss-m-b-40">
{{ sheep.$helper.timeFormat(item.time, 'yyyy-mm-dd hh:MM:ss') }}
</view>
</view>
</view>
</view>
</view>
</s-layout>
</template>
<script setup>
import sheep from '@/sheep';
import { onLoad } from '@dcloudio/uni-app';
import { computed, reactive } from 'vue';
import OrderApi from '@/sheep/api/trade/order';
import { getOrderDetail as getAiOrderDetail, getOpenOrderDetail, getOpenOrderExpressTrackList } from '@/sheep/api/ai';
import { getExpressTrackList } from '@/sheep/api/index/index';
import HighlightNumber from '@/pages/components/HighlightNumberText.vue';
const state = reactive({
info: {},
tracks: [],
});
const goodsImages = computed(() => {
let array = [];
if (state.info && state.info.items) {
state.info.items.forEach((item) => {
array.push({
image: item.picUrl,
});
});
}
if (state.info && state.info.delayRecords && Array.isArray(state.info.delayRecords)) {
state.info.delayRecords.forEach((record) => {
if (record.picUrl || record.orderItemVO?.picUrl) {
array.push({
image: record.picUrl || record.orderItemVO?.picUrl,
});
}
});
}
return array;
});
async function getExpressDetail(options) {
const id = options?.id;
const codeRaw = options?.code;
const code =
codeRaw !== undefined && codeRaw !== null && String(codeRaw).trim() !== ''
? Number(codeRaw)
: 0;
const delayRecordId = options?.delayRecordId;
const hasDelayRecordId =
delayRecordId !== undefined &&
delayRecordId !== null &&
String(delayRecordId).trim() !== '';
if (id) {
state.info.id = id;
}
// 开通店铺订单(type===5):物流接口 /aishop/app/open/order/get-express-track-list
const isOpenOrder = Number(state.info?.type) === 5;
if (isOpenOrder) {
// 优先传 delayRecordId + code=2;没传 delayRecordId 就只传 code(具体 code 值看原 code 参数)
const params = { id };
if (code === 2 && hasDelayRecordId) {
params.code = 2;
params.delayRecordId = delayRecordId;
} else if (code > 0) {
params.code = code;
if (hasDelayRecordId) params.delayRecordId = delayRecordId;
} else {
params.code = 0;
}
try {
const { data } = await getOpenOrderExpressTrackList(params);
state.tracks = Array.isArray(data) ? data : [];
} catch (e) {
state.tracks = [];
}
return;
}
if (code === 2 && hasDelayRecordId) {
const { data } = await getExpressTrackList({
id,
code: 2,
delayRecordId,
});
state.tracks = data;
} else if (code > 0) {
const { data } = await getExpressTrackList({
id,
code,
});
state.tracks = data;
} else {
const { data } = await OrderApi.getOrderExpressTrackList(id);
state.tracks = data;
}
}
async function getOrderDetail(id) {
if (!id) return;
// 开通店铺订单(type===5):详情接口 /aishop/order/get-detail-open,优先尝试
try {
const { code: rc, data } = await getOpenOrderDetail({ id });
if (rc === 0 && data && Number(data?.type) === 5) {
state.info = data;
return;
}
} catch (e) {}
try {
const { data } = await OrderApi.getOrderDetail(id);
if (data) {
state.info = data;
return;
}
} catch (e) {}
try {
const { data } = await getAiOrderDetail({ id });
if (data) {
state.info = data;
}
} catch (e) {}
}
onLoad(async (options) => {
// 先拿订单详情(确定 type===5,以及填充 state.info),再拿物流
await getOrderDetail(options?.id);
await getExpressDetail(options || {});
});
function handlePhoneClick(data) {
handleClick(data);
}
function handleClick(data) {
const phoneNumber = data.phoneNumber;
if (!phoneNumber) return;
// 获取当前平台
const platform = uni.getSystemInfoSync().platform.toLowerCase();
if (platform === 'devtools') {
uni.showToast({ title: '真机才可拨打电话', icon: 'none' });
handleCopy(phoneNumber);
return;
}
if (platform === 'wechat') {
uni.showToast({ title: '请手动拨打', icon: 'none' });
handleCopy(phoneNumber);
return;
}
uni.makePhoneCall({
phoneNumber: phoneNumber,
success: () => {
console.log('拨打电话成功');
},
fail: (err) => {
console.error('拨打电话失败', err);
uni.showToast({ title: '拨号失败,请手动拨打', icon: 'none' });
handleCopy(phoneNumber);
},
});
}
function handleCopy(text) {
uni.setClipboardData({
data: text,
success: () => {
uni.showToast({ title: '已复制到剪贴板', icon: 'success' });
},
fail: () => {
uni.showToast({ title: '复制失败', icon: 'none' });
},
});
}
</script>
<style lang="scss" scoped>
.highlight {
color: red; /* 高亮颜色 */
font-weight: bold;
}
.swiper-box {
width: 200rpx;
height: 200rpx;
}
.log-card {
border-top: 2rpx solid rgba(#dfdfdf, 0.5);
padding: 20rpx;
background: #fff;
margin-bottom: 20rpx;
.log-card-img {
width: 200rpx;
height: 200rpx;
margin-right: 20rpx;
}
.log-card-msg {
font-size: 28rpx;
font-weight: 500;
width: 490rpx;
color: #333333;
.warning-color {
color: #999;
}
}
}
.log-content {
padding: 34rpx 20rpx 0rpx 20rpx;
background: #fff;
.log-content-box {
align-items: stretch;
}
.log-icon {
height: inherit;
.cicon-title {
color: #ccc;
font-size: 40rpx;
}
.activity-color {
color: #f0c785;
font-size: 40rpx;
}
.info-color {
color: #ccc;
font-size: 40rpx;
}
.line {
width: 1px;
height: 100%;
background: #d8d8d8;
}
}
.log-content-msg {
.log-msg-title {
font-size: 28rpx;
font-weight: bold;
color: #333333;
}
.log-msg-desc {
font-size: 24rpx;
font-weight: 400;
color: #333333;
line-height: 36rpx;
}
.log-msg-date {
font-size: 24rpx;
font-weight: 500;
color: #000000;
}
}
}
</style>