Commit 22882961 by zhangxw

Merge branch 'SAAS+V4.56.0-0908' of http://192.168.3.233:8090/saas/mini-program/…

…points-mall into SAAS+V4.56.0-0908
2 parents 1dec3748 6d8198f7
...@@ -5,17 +5,59 @@ Component({ ...@@ -5,17 +5,59 @@ Component({
nodes: { nodes: {
type: Array, type: Array,
value: [], value: [],
} observer(newVal) {
this.formatContent(newVal);
},
},
},
data: {
timeLineNodes: [],
}, },
methods: { methods: {
formatContent(nodes) {
nodes.forEach((item) => {
if (item.type == "special") {
item.content = [{ type: "text", txt: item.content }];
} else {
item.content = this.parsePhone(item.content);
}
});
this.setData({
timeLineNodes: nodes,
});
},
// 把原始文本切成 text | phone 两种节点
parsePhone(str) {
if(!str){
return [];
}
const phoneReg = /(1[3-9]\d{9}|0\d{2,3}[-]?\d{7,8})/g; // 简易手机号正则
let lastIndex = 0;
const res = [];
let match;
while ((match = phoneReg.exec(str)) !== null) {
// 1. match 之前的纯文本
if (match.index > lastIndex) {
res.push({ type: "text", txt: str.slice(lastIndex, match.index) });
}
// 2. 手机号本身
res.push({ type: "phone", txt: match[0] });
lastIndex = match.index + match[0].length;
}
// 3. 尾部剩余文本
if (lastIndex < str.length) {
res.push({ type: "text", txt: str.slice(lastIndex) });
}
return res;
},
// 拨打电话 // 拨打电话
makePhoneCall(e) { makePhoneCall(e) {
const phone = e.currentTarget.dataset.phone; const phone = e.currentTarget.dataset.phone;
if (phone) { if (phone) {
wx.makePhoneCall({ wx.makePhoneCall({
phoneNumber: phone phoneNumber: phone,
}); });
} }
} },
} },
}); });
...@@ -97,7 +97,6 @@ ...@@ -97,7 +97,6 @@
.timeline-node__content--special-active, .timeline-node__content--special-active,
.timeline-node__content--special-small-active, .timeline-node__content--special-small-active,
.timeline-node__content--special-active-small { .timeline-node__content--special-active-small {
.timeline-node__title, .timeline-node__title,
.timeline-node__tip { .timeline-node__tip {
font-weight: 400; font-weight: 400;
...@@ -141,6 +140,12 @@ ...@@ -141,6 +140,12 @@
font-weight: 400; font-weight: 400;
font-size: 24rpx; font-size: 24rpx;
line-height: 1.5; line-height: 1.5;
.content {
white-space: pre-wrap;
.phone {
color: #fb8a32;
}
}
} }
.timeline-node__content--active, .timeline-node__content--active,
......
<!-- 时间轴组件 --> <!-- 时间轴组件 -->
<view class="timeline-container"> <view class="timeline-container">
<view wx:for="{{nodes}}" wx:key="index" class="timeline-node"> <view wx:for="{{timeLineNodes}}" wx:key="index" class="timeline-node">
<!-- 时间轴节点 --> <!-- 时间轴节点 -->
<view class="timeline-node__dot-wrapper"> <view class="timeline-node__dot-wrapper">
<!-- 使用预处理的样式类 --> <!-- 使用预处理的样式类 -->
...@@ -15,16 +15,14 @@ ...@@ -15,16 +15,14 @@
<view wx:if="{{item.operateTime}}" class="timeline-node__time">{{item.operateTime}}</view> <view wx:if="{{item.operateTime}}" class="timeline-node__time">{{item.operateTime}}</view>
</view> </view>
<view class="timeline-node__tip"> <view class="timeline-node__tip">
<view class="timeline-node__tip"> <view class="content">
<rich-text nodes="{{item.content}}"></rich-text> <block wx:for="{{item.content}}" wx:key="index" wx:for-item="content">
<!-- 手机号码点击区域 --> <block wx:if="{{content.type==='text'}}">{{content.txt}}</block>
<view wx:if="{{item.phones && item.phones.length > 0}}" class="phone-numbers"> <label wx:elif="{{content.type==='phone'}}"
<view wx:for="{{item.phones}}" wx:for-item="phone" wx:key="*this" catchtap="makePhoneCall"
class="phone-number" catchtap="makePhoneCall" data-phone="{{phone}}"> data-phone="{{content.txt}}"
<!-- <mp-icon icon="cellphone" color="var(--btnColor)" size="{{14}}"></mp-icon> --> class="phone">{{content.txt}}</label>
<text class="phone-call-text">拨打电话: {{phone}}</text> </block>
</view>
</view>
</view> </view>
</view> </view>
</view> </view>
......
...@@ -136,22 +136,22 @@ Component({ ...@@ -136,22 +136,22 @@ Component({
} }
} }
// 提取手机号码 // 提取手机号码
const phoneRegex = /(1[3-9]\d{9}|0\d{2,3}[-]?\d{7,8})/g; // const phoneRegex = /(1[3-9]\d{9}|0\d{2,3}[-]?\d{7,8})/g;
const phones = []; // const phones = [];
let match; // let match;
while ((match = phoneRegex.exec(content)) !== null) { // while ((match = phoneRegex.exec(content)) !== null) {
phones.push(match[1]); // phones.push(match[1]);
} // }
// 高亮手机号码和座机号码 // // 高亮手机号码和座机号码
const highlightedContent = content.replace( // const highlightedContent = content.replace(
phoneRegex, // phoneRegex,
'<span style="color: #fb8a32;">$1</span>' // '<span style="color: #fb8a32;" bindtap="makePhoneCall" data-phone="$1">$1</span>'
); // );
return { return {
...track, ...track,
content: highlightedContent, content,
phones: phones, // 添加提取的手机号码数组 // phones: phones, // 添加提取的手机号码数组
operateTime, operateTime,
type, type,
status, status,
...@@ -194,7 +194,6 @@ Component({ ...@@ -194,7 +194,6 @@ Component({
console.warn("Express组件: expressInfo参数无效"); console.warn("Express组件: expressInfo参数无效");
return; return;
} }
const { const {
logisticsStatus, logisticsStatus,
shipmentTrack, shipmentTrack,
......
...@@ -71,7 +71,7 @@ Page({ ...@@ -71,7 +71,7 @@ Page({
receiveMobile, receiveMobile,
} = data.receiveAddress; } = data.receiveAddress;
const receiveAddress = provinceName + cityName + countyName + address; const receiveAddress = provinceName + cityName + countyName + address;
const receiveInfo = receiveName + receiveMobile; const receiveInfo = `${receiveName} ${receiveMobile}`;
this.setData({ this.setData({
orderInfo: { orderInfo: {
...data, ...data,
...@@ -79,7 +79,7 @@ Page({ ...@@ -79,7 +79,7 @@ Page({
receiveAddress, receiveAddress,
receiveInfo, receiveInfo,
}, },
receiver: `${receiveAddress}<br/>${receiveInfo}`, receiver: `${receiveAddress}\n${receiveInfo}`,
// 如果有expressInfo也一并设置 // 如果有expressInfo也一并设置
...(data.expressName && this.data.orderInfo.goodsSource == GoodsSource.SELF ? { ...(data.expressName && this.data.orderInfo.goodsSource == GoodsSource.SELF ? {
expressInfo: { expressInfo: {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!