feat: 门店详情商户电话多号码用,分隔展示并自动拆分连写号码,icon颜色与相邻模块一致
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5
parent
4143667d1c
commit
bc2fb1715b
+34
-8
@@ -20,14 +20,17 @@
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 商户电话(取商铺客服电话字段,点击拨号) -->
|
||||
<view class="discount-section" v-if="store.servicePhone">
|
||||
<!-- 商户电话(取商铺客服电话字段,多个用,分隔,点击拨号) -->
|
||||
<view class="discount-section" v-if="servicePhoneList.length">
|
||||
<view class="section-title">
|
||||
<u-icon name="phone-fill" color="#0088ff" size="34"></u-icon>
|
||||
<u-icon name="phone-fill" color="#1296DB" size="34"></u-icon>
|
||||
<text class="discount-title">商户电话</text>
|
||||
</view>
|
||||
<view class="discount-list">
|
||||
<text class="discount-item phone-link" @click="callPhone">{{ store.servicePhone }}</text>
|
||||
<text class="discount-item">
|
||||
<text v-for="(p, i) in servicePhoneList" :key="i" class="phone-link"
|
||||
@click="callPhone(p)">{{ i > 0 ? ',' : '' }}{{ p }}</text>
|
||||
</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@@ -76,6 +79,29 @@ export default {
|
||||
discountList() {
|
||||
if (!this.store || !this.store.merchantDiscount) return []
|
||||
return this.store.merchantDiscount.split('\n')
|
||||
},
|
||||
// xuchao: 客服电话列表:按常见分隔符切分;无分隔符连写的多个11位手机号也自动拆开
|
||||
servicePhoneList() {
|
||||
if (!this.store || !this.store.servicePhone) return []
|
||||
const parts = String(this.store.servicePhone).split(/[,,;;、\s\n]+/).filter(Boolean)
|
||||
const out = []
|
||||
parts.forEach(p => {
|
||||
if (p.length > 11 && /^1[3-9]\d{9}$/.test(p.slice(0, 11))) {
|
||||
let rest = p
|
||||
const segs = []
|
||||
while (rest.length >= 11 && /^1[3-9]\d{9}$/.test(rest.slice(0, 11))) {
|
||||
segs.push(rest.slice(0, 11))
|
||||
rest = rest.slice(11)
|
||||
}
|
||||
if (rest) segs[segs.length - 1] += rest
|
||||
if (segs.length > 1) {
|
||||
out.push(...segs)
|
||||
return
|
||||
}
|
||||
}
|
||||
out.push(p)
|
||||
})
|
||||
return out
|
||||
}
|
||||
},
|
||||
onLoad(options) {
|
||||
@@ -84,10 +110,10 @@ export default {
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
// xuchao: 点击商户电话唤起拨号
|
||||
callPhone() {
|
||||
if (!this.store || !this.store.servicePhone) return
|
||||
uni.makePhoneCall({ phoneNumber: String(this.store.servicePhone) })
|
||||
// xuchao: 点击某个商户电话唤起拨号(多个号码时逐个可点)
|
||||
callPhone(phone) {
|
||||
if (!phone) return
|
||||
uni.makePhoneCall({ phoneNumber: String(phone) })
|
||||
},
|
||||
loadDetail(shopId) {
|
||||
const loc = uni.getStorageSync('lng') && uni.getStorageSync('lat')
|
||||
|
||||
Reference in New Issue
Block a user