1. 手机号格式校验
This commit is contained in:
李琦
2026-08-11 18:39:38 +08:00
parent 206f0aaa50
commit c681cb916b
8 changed files with 148 additions and 5 deletions

View File

@@ -57,6 +57,7 @@
getCodes,
getsLogin
} from '../../request/api/api';
import { isPhone } from '@/utils/phone.js';
export default {
data() {
return {
@@ -93,7 +94,8 @@
})
return
}
if (!/^1[345678]\d{9}$/.test(this.form['mobile'])) {
// 与后端 checkPhone 统一:含 19 号段
if (!isPhone(this.form['mobile'])) {
// uni.showToast({
// title: '请输入正确的手机号',
// duration: 2000,
@@ -137,6 +139,14 @@
})
},
register() {
if (!isPhone(this.form['mobile'])) {
this.$refs.uToast.show({
title: '请输入正确的手机号',
type: 'default',
icon: false
})
return
}
if (this.form['pwd'] == []) {
uni.showToast({
title: '请输入验证码',

View File

@@ -78,6 +78,14 @@
</view>
</view>
<!-- 医生代支付标识与列表一致详情页顶部可见 -->
<view
class="proxy-pay-banner"
v-if="orderInfo.product_order && (orderInfo.product_order.is_proxy_pay == 1 || orderInfo.product_order.is_proxy_pay === true || orderInfo.product_order.pay_user_type == 2)"
>
<text class="proxy-pay-banner-text">本单为医生代支付</text>
</view>
<!-- 商品列表 -->
<view class="card">
<!-- 门店 -->
@@ -156,6 +164,15 @@
<text class="price">{{orderInfo.product_order.total_pay_price}}</text>
</view>
</view>
<view
class="good_"
v-if="orderInfo.product_order && (orderInfo.product_order.is_proxy_pay == 1 || orderInfo.product_order.is_proxy_pay === true || orderInfo.product_order.pay_user_type == 2)"
>
<text>付款方式</text>
<view class="price">
<text class="proxy-pay-inline">医生代支付</text>
</view>
</view>
<view class="good_" v-if="orderInfo.product_order&&orderInfo.product_order.pay_time!='0'">
<text>支付时间</text>
<view class="price">
@@ -805,6 +822,21 @@ export default {
font-weight: 500;
color: #222;
}
.proxy-pay-banner {
margin: 20rpx 24rpx 0;
padding: 16rpx 24rpx;
background: #F5E8FF;
border-radius: 12rpx;
}
.proxy-pay-banner-text {
font-size: 26rpx;
color: #722ED1;
font-weight: 600;
}
.proxy-pay-inline {
color: #722ED1;
font-weight: 600;
}
.agreen {
padding: 60rpx 50rpx 20rpx;

View File

@@ -49,7 +49,14 @@
v-if="item.prescription_type"
/>
</view>
<text class="status_txt">{{item.status_string}}</text>
<view class="status_wrap">
<!-- 医生代支付后端 is_proxy_pay / pay_user_type=2 -->
<text
v-if="item.is_proxy_pay == 1 || item.is_proxy_pay === true || item.pay_user_type == 2"
class="proxy_pay_tag"
>代支付</text>
<text class="status_txt">{{item.status_string}}</text>
</view>
</view>
<!-- 订单编号降级 -->
@@ -713,6 +720,21 @@ export default {
}
}
.status_wrap {
display: flex;
flex-direction: column;
align-items: flex-end;
flex-shrink: 0;
gap: 8rpx;
}
.proxy_pay_tag {
font-size: 22rpx;
color: #722ED1;
background: #F5E8FF;
padding: 4rpx 12rpx;
border-radius: 8rpx;
font-weight: 600;
}
.status_txt {
font-size: 28rpx;
font-weight: 500;

View File

@@ -374,6 +374,7 @@
userRelation
} from '../../request/api/api';
import { checkProfileTexts, handleSecurityError, SCENE_PROFILE } from '@/utils/content-security.js';
import { assertPhone, isPhone } from '@/utils/phone.js';
export default {
data() {
return {
@@ -831,6 +832,10 @@
});
return false;
}
// 就诊人手机号与后端 PatientService 一致
if (!assertPhone(this.phone)) {
return false;
}
return true;
},
validatePatientAge() {
@@ -874,7 +879,7 @@
});
return false;
}
if (!/^\d{11}$/.test(this.guardianForm.mobile)) {
if (!isPhone(this.guardianForm.mobile)) {
uni.showToast({
title: '监护人手机号格式不正确',
icon: 'none',

View File

@@ -355,6 +355,7 @@
userRelation
} from '../../request/api/api';
import { checkProfileTexts, handleSecurityError, SCENE_PROFILE } from '@/utils/content-security.js';
import { assertPhone, isPhone } from '@/utils/phone.js';
export default {
data() {
return {
@@ -1015,6 +1016,10 @@
});
return false;
}
// 就诊人手机号与后端 PatientService 一致
if (!assertPhone(this.phone)) {
return false;
}
return true;
},
calcAgeFromIdCard(idCard) {
@@ -1071,7 +1076,7 @@
});
return false;
}
if (!/^\d{11}$/.test(this.guardianForm.mobile)) {
if (!isPhone(this.guardianForm.mobile)) {
uni.showToast({
title: '监护人手机号格式不正确',
icon: 'none',

View File

@@ -83,6 +83,7 @@ height:' 68rpx',borderRadio:'8rpx'}">
getaddressEdit,
getaddressList
} from '../../request/api/api'
import { assertPhone } from '@/utils/phone.js'
export default {
data() {
return {
@@ -144,6 +145,10 @@ height:' 68rpx',borderRadio:'8rpx'}">
},
// 新增地址
getAdd() {
// 收货手机号与后端一致:大陆 11 位号段
if (!assertPhone(this.mobile, '请填写收货人手机号', '收货人手机号格式不正确')) {
return
}
let list = {
name: this.name,
mobile: this.mobile,
@@ -211,6 +216,10 @@ height:' 68rpx',borderRadio:'8rpx'}">
// 修改地址
getEdit() {
const editMobile = this.from[0] && this.from[0].mobile
if (!assertPhone(editMobile, '请填写收货人手机号', '收货人手机号格式不正确')) {
return
}
let list = {
id: this.id,
name: this.from[0].name,

View File

@@ -24,7 +24,13 @@
<view class="list">
<view class="store"><text class="iconfont icon-mendian"></text>{{item.store.name}} <text class="state">西药(中成)</text>
</view>
<text class="active">{{item.status_string}}</text>
<view class="status_wrap">
<text
v-if="item.is_proxy_pay == 1 || item.is_proxy_pay === true || item.pay_user_type == 2"
class="proxy_pay_tag"
>代支付</text>
<text class="active">{{item.status_string}}</text>
</view>
</view>
<!-- 商品 -->
<view class="item" v-for="(item1,index) in item.items">
@@ -397,6 +403,22 @@
color: #FC3636;
}
.status_wrap {
display: flex;
flex-direction: column;
align-items: flex-end;
gap: 8rpx;
flex-shrink: 0;
}
.proxy_pay_tag {
font-size: 22rpx;
color: #722ED1;
background: #F5E8FF;
padding: 4rpx 12rpx;
border-radius: 8rpx;
font-weight: 600;
}
}
.item {

38
utils/phone.js Normal file
View File

@@ -0,0 +1,38 @@
/**
* 大陆手机号校验(与后端 UtilsService::checkPhone 一致)
* 规则11 位,号段 13-19^1[3456789]\d{9}$
*/
const MOBILE_REG = /^1[3456789]\d{9}$/;
/**
* 判断是否为合法大陆手机号(不弹 toast
* @param {string|number|null|undefined} phone
* @returns {boolean}
*/
export function isPhone(phone) {
if (phone === null || phone === undefined) {
return false;
}
return MOBILE_REG.test(String(phone).trim());
}
/**
* 校验手机号;不合法时 toast 并返回 false
* @param {string|number|null|undefined} phone
* @param {string} [emptyMsg='请输入手机号']
* @param {string} [invalidMsg='手机号格式不正确']
* @returns {boolean}
*/
export function assertPhone(phone, emptyMsg = '请输入手机号', invalidMsg = '手机号格式不正确') {
const value = phone === null || phone === undefined ? '' : String(phone).trim();
if (!value) {
uni.showToast({ title: emptyMsg, icon: 'none' });
return false;
}
if (!MOBILE_REG.test(value)) {
uni.showToast({ title: invalidMsg, icon: 'none' });
return false;
}
return true;
}