From e1a4f57610a9c71814f522ae517f2cbe49d13697 Mon Sep 17 00:00:00 2001 From: wangxiaowei <1121133807@qq.com> Date: Thu, 28 Aug 2025 18:20:17 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 27 +- src/bundle/coupon/coupon.vue | 12 +- src/bundle/reserve-room/detail.vue | 8 +- src/bundle/reserve-room/result.vue | 49 --- src/bundle/reserve-room/room.vue | 11 +- src/bundle/store-recharge/store-recharge.vue | 3 +- .../{price-format.vue => PriceFormat.vue} | 2 +- .../{recharge-btn.vue => RechargeBtn.vue} | 2 +- .../{group-coupon.vue => GroupCoupon.vue} | 2 +- src/components/coupon/coupon.vue | 2 +- src/components/navbar.vue | 4 +- src/components/notice/Bill.vue | 91 ++++++ src/components/notice/Pay.vue | 40 +++ src/components/notice/Reserve.vue | 40 +++ .../reserve/{room-list.vue => RoomList.vue} | 8 +- src/main.ts | 4 +- src/pages.json | 78 +++-- src/pages/index/index.vue | 2 +- src/pages/login/login.vue | 83 +++++ src/pages/login/mobile.vue | 189 ++++++++++++ src/pages/notice/bill.vue | 26 ++ src/pages/notice/pay.vue | 51 ++++ src/pages/notice/reserve.vue | 51 ++++ src/pages/result/bill.vue | 19 -- src/pages/result/pay.vue | 20 -- src/pages/result/reserve.vue | 20 -- src/utils/test.ts | 287 ++++++++++++++++++ 27 files changed, 953 insertions(+), 178 deletions(-) delete mode 100644 src/bundle/reserve-room/result.vue rename src/components/{price-format.vue => PriceFormat.vue} (97%) rename src/components/{recharge-btn.vue => RechargeBtn.vue} (92%) rename src/components/coupon/{group-coupon.vue => GroupCoupon.vue} (97%) create mode 100644 src/components/notice/Bill.vue create mode 100644 src/components/notice/Pay.vue create mode 100644 src/components/notice/Reserve.vue rename src/components/reserve/{room-list.vue => RoomList.vue} (96%) create mode 100644 src/pages/login/login.vue create mode 100644 src/pages/login/mobile.vue create mode 100644 src/pages/notice/bill.vue create mode 100644 src/pages/notice/pay.vue create mode 100644 src/pages/notice/reserve.vue delete mode 100644 src/pages/result/bill.vue delete mode 100644 src/pages/result/pay.vue delete mode 100644 src/pages/result/reserve.vue create mode 100644 src/utils/test.ts diff --git a/README.md b/README.md index 652f0c5..9658ee9 100644 --- a/README.md +++ b/README.md @@ -7,8 +7,9 @@ 使用Unibest开发,版本号3.8.2 -
开发规范
-1. 页面或组件添加方法的时候前面加上handle关键字,除了插件相关内容如mescroll +### 开发规范 +#### 1. 页面或组件添加方法的时候前面加上handle关键字,除了插件相关内容如mescroll +``` handleConfirmHour: () => { if (totalHour.value <= 0) { toast.info('至少起订N小时') @@ -16,7 +17,9 @@ } showReservePopup.value = false }, -2. 页面或组件传创建的方法需要以当前文件名称作为对象按照驼峰命名 +``` +#### 2. 页面或组件传创建的方法需要以当前文件名称作为对象按照驼峰命名 +``` const detail = { handleConfirmHour: () => { if (totalHour.value <= 0) { @@ -26,7 +29,10 @@ showReservePopup.value = false } } -3. 页面或组件传创建的内部方法需要放在函数最下面,这种方法前面不需要加上handle +``` + +#### 3. 页面或组件传创建的内部方法需要放在函数最下面,这种方法前面不需要加上handle +``` const detail = { handleConfirmHour: () => { if (totalHour.value <= 0) { @@ -48,7 +54,10 @@ return `${year}-${month}-${day} ${hour}:${minute}` } } -4. 如果组件名称与定义的对象函数名冲突,则对象函数名后面加上s +``` + +#### 4. 如果组件名称与定义的对象函数名冲突,则对象函数名后面加上s +``` import coupon from '@/components/coupon/coupon.vue' const coupons = { handleConfirmHour: () => { @@ -70,4 +79,10 @@ return `${year}-${month}-${day} ${hour}:${minute}` } - } \ No newline at end of file + } +``` +#### 5. 组件名称需按照PascalCase来写 +``` + import UserProfile from './components/UserProfile.vue'; + 在页面模板中按照 来使用 +``` \ No newline at end of file diff --git a/src/bundle/coupon/coupon.vue b/src/bundle/coupon/coupon.vue index c8dbc8a..884385e 100644 --- a/src/bundle/coupon/coupon.vue +++ b/src/bundle/coupon/coupon.vue @@ -32,7 +32,7 @@ :checked="item.id === checkedId" :onCheck="coupons.handleCheck" :class="index !== couponList.length - 1 ? 'mb-20rpx' : ''" - /> + > @@ -51,7 +51,7 @@ :checked="item.id === checkedId" :onCheck="coupons.handleCheck" :class="index !== couponList.length - 1 ? 'mb-20rpx' : ''" - /> + > @@ -74,7 +74,7 @@ :checked="item.id === checkedId" :onCheck="coupons.handleCheck" :class="index !== couponList.length - 1 ? 'mb-20rpx' : ''" - /> + > @@ -93,7 +93,7 @@ :checked="item.id === checkedId" :onCheck="coupons.handleCheck" :class="index !== couponList.length - 1 ? 'mb-20rpx' : ''" - /> + > @@ -112,8 +112,8 @@ - - diff --git a/src/bundle/reserve-room/room.vue b/src/bundle/reserve-room/room.vue index 9e1d777..c60a335 100644 --- a/src/bundle/reserve-room/room.vue +++ b/src/bundle/reserve-room/room.vue @@ -43,7 +43,7 @@ - + 1分钟前有人充值 @@ -81,14 +81,14 @@ - + - + @@ -109,11 +109,10 @@ + + + + diff --git a/src/components/notice/Pay.vue b/src/components/notice/Pay.vue new file mode 100644 index 0000000..ad007ab --- /dev/null +++ b/src/components/notice/Pay.vue @@ -0,0 +1,40 @@ + + + + + + + + diff --git a/src/components/notice/Reserve.vue b/src/components/notice/Reserve.vue new file mode 100644 index 0000000..eedcdd3 --- /dev/null +++ b/src/components/notice/Reserve.vue @@ -0,0 +1,40 @@ + + + + + + + + diff --git a/src/components/reserve/room-list.vue b/src/components/reserve/RoomList.vue similarity index 96% rename from src/components/reserve/room-list.vue rename to src/components/reserve/RoomList.vue index 22b952b..cf34532 100644 --- a/src/components/reserve/room-list.vue +++ b/src/components/reserve/RoomList.vue @@ -65,12 +65,10 @@ - + + diff --git a/src/pages/login/mobile.vue b/src/pages/login/mobile.vue new file mode 100644 index 0000000..e58c6a4 --- /dev/null +++ b/src/pages/login/mobile.vue @@ -0,0 +1,189 @@ +{ + "layout": "default", + "style": { + "navigationBarTitleText": "", + "navigationBarBackgroundColor": "#fff" + } +} + + + + + + + diff --git a/src/pages/notice/bill.vue b/src/pages/notice/bill.vue new file mode 100644 index 0000000..fe9ccab --- /dev/null +++ b/src/pages/notice/bill.vue @@ -0,0 +1,26 @@ +{ + "layout": "default", + "style": { + "navigationBarTitleText": "", + "navigationBarBackgroundColor": "#fff" + } +} + + + + + + + diff --git a/src/pages/notice/pay.vue b/src/pages/notice/pay.vue new file mode 100644 index 0000000..06e974e --- /dev/null +++ b/src/pages/notice/pay.vue @@ -0,0 +1,51 @@ +{ + "layout": "default", + "style": { + "navigationBarTitleText": "", + "navigationBarBackgroundColor": "#fff" + } +} + + + + + + + diff --git a/src/pages/notice/reserve.vue b/src/pages/notice/reserve.vue new file mode 100644 index 0000000..e6a78e0 --- /dev/null +++ b/src/pages/notice/reserve.vue @@ -0,0 +1,51 @@ +{ + "layout": "default", + "style": { + "navigationBarTitleText": "", + "navigationBarBackgroundColor": "#fff" + } +} + + + + + + + diff --git a/src/pages/result/bill.vue b/src/pages/result/bill.vue deleted file mode 100644 index 90f9ad7..0000000 --- a/src/pages/result/bill.vue +++ /dev/null @@ -1,19 +0,0 @@ -{ - "layout": "default", - "style": { - "navigationBarTitleText": "" - } -} - - - - - - diff --git a/src/pages/result/pay.vue b/src/pages/result/pay.vue deleted file mode 100644 index 59b1365..0000000 --- a/src/pages/result/pay.vue +++ /dev/null @@ -1,20 +0,0 @@ -{ - "layout": "default", - "style": { - "navigationBarTitleText": "" - } -} - - - - - - - diff --git a/src/pages/result/reserve.vue b/src/pages/result/reserve.vue deleted file mode 100644 index bfe457e..0000000 --- a/src/pages/result/reserve.vue +++ /dev/null @@ -1,20 +0,0 @@ -{ - "layout": "default", - "style": { - "navigationBarTitleText": "" - } -} - - - - - - - diff --git a/src/utils/test.ts b/src/utils/test.ts new file mode 100644 index 0000000..fb9894d --- /dev/null +++ b/src/utils/test.ts @@ -0,0 +1,287 @@ +/** + * 验证电子邮箱格式 + */ +function email(value) { + return /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/.test(value) +} + +/** + * 验证手机格式 + */ +function mobile(value) { + return /^1([3589]\d|4[5-9]|6[1-2,4-7]|7[0-8])\d{8}$/.test(value) +} + +/** + * 验证URL格式 + */ +function url(value) { + return /^((https|http|ftp|rtsp|mms):\/\/)(([0-9a-zA-Z_!~*'().&=+$%-]+: )?[0-9a-zA-Z_!~*'().&=+$%-]+@)?(([0-9]{1,3}.){3}[0-9]{1,3}|([0-9a-zA-Z_!~*'()-]+.)*([0-9a-zA-Z][0-9a-zA-Z-]{0,61})?[0-9a-zA-Z].[a-zA-Z]{2,6})(:[0-9]{1,4})?((\/?)|(\/[0-9a-zA-Z_!~*'().;?:@&=+$,%#-]+)+\/?)$/ + .test(value) +} + +/** + * 验证日期格式 + */ +function date(value) { + if (!value) return false + // 判断是否数值或者字符串数值(意味着为时间戳),转为数值,否则new Date无法识别字符串时间戳 + if (number(value)) value = +value + return !/Invalid|NaN/.test(new Date(value).toString()) +} + +/** + * 验证ISO类型的日期格式 + */ +function dateISO(value) { + return /^\d{4}[\/\-](0?[1-9]|1[012])[\/\-](0?[1-9]|[12][0-9]|3[01])$/.test(value) +} + +/** + * 验证十进制数字 + */ +function number(value) { + return /^[\+-]?(\d+\.?\d*|\.\d+|\d\.\d+e\+\d+)$/.test(value) +} + +/** + * 验证字符串 + */ +function string(value) { + return typeof value === 'string' +} + +/** + * 验证整数 + */ +function digits(value) { + return /^\d+$/.test(value) +} + +/** + * 验证身份证号码 + */ +function idCard(value) { + return /^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X)$/.test( + value + ) +} + +/** + * 是否车牌号 + */ +function carNo(value) { + // 新能源车牌 + const xreg = /^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}(([0-9]{5}[DF]$)|([DF][A-HJ-NP-Z0-9][0-9]{4}$))/ + // 旧车牌 + const creg = /^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}[A-HJ-NP-Z0-9]{4}[A-HJ-NP-Z0-9挂学警港澳]{1}$/ + if (value.length === 7) { + return creg.test(value) + } if (value.length === 8) { + return xreg.test(value) + } + return false +} + +/** + * 金额,只允许2位小数 + */ +function amount(value) { + // 金额,只允许保留两位小数 + return /^[1-9]\d*(,\d{3})*(\.\d{1,2})?$|^0\.\d{1,2}$/.test(value) +} + +/** + * 中文 + */ +function chinese(value) { + const reg = /^[\u4e00-\u9fa5]+$/gi + return reg.test(value) +} + +/** + * 只能输入字母 + */ +function letter(value) { + return /^[a-zA-Z]*$/.test(value) +} + +/** + * 只能是字母或者数字 + */ +function enOrNum(value) { + // 英文或者数字 + const reg = /^[0-9a-zA-Z]*$/g + return reg.test(value) +} + +/** + * 验证是否包含某个值 + */ +function contains(value, param) { + return value.indexOf(param) >= 0 +} + +/** + * 验证一个值范围[min, max] + */ +function range(value, param) { + return value >= param[0] && value <= param[1] +} + +/** + * 验证一个长度范围[min, max] + */ +function rangeLength(value, param) { + return value.length >= param[0] && value.length <= param[1] +} + +/** + * 是否固定电话 + */ +function landline(value) { + const reg = /^\d{3,4}-\d{7,8}(-\d{3,4})?$/ + return reg.test(value) +} + +/** + * 判断是否为空 + */ +function empty(value) { + switch (typeof value) { + case 'undefined': + return true + case 'string': + if (value.replace(/(^[ \t\n\r]*)|([ \t\n\r]*$)/g, '').length == 0) return true + break + case 'boolean': + if (!value) return true + break + case 'number': + if (value === 0 || isNaN(value)) return true + break + case 'object': + if (value === null || value.length === 0) return true + for (const i in value) { + return false + } + return true + } + return false +} + +/** + * 是否json字符串 + */ +function jsonString(value) { + if (typeof value === 'string') { + try { + const obj = JSON.parse(value) + if (typeof obj === 'object' && obj) { + return true + } + return false + } catch (e) { + return false + } + } + return false +} + +/** + * 是否数组 + */ +function array(value) { + if (typeof Array.isArray === 'function') { + return Array.isArray(value) + } + return Object.prototype.toString.call(value) === '[object Array]' +} + +/** + * 是否对象 + */ +function object(value) { + return Object.prototype.toString.call(value) === '[object Object]' +} + +/** + * 是否短信验证码 + */ +function code(value, len = 6) { + return new RegExp(`^\\d{${len}}$`).test(value) +} + +/** + * 是否函数方法 + * @param {Object} value + */ +function func(value) { + return typeof value === 'function' +} + +/** + * 是否promise对象 + * @param {Object} value + */ +function promise(value) { + return object(value) && func(value.then) && func(value.catch) +} + +/** 是否图片格式 + * @param {Object} value + */ +function image(value) { + const newValue = value.split('?')[0] + const IMAGE_REGEXP = /\.(jpeg|jpg|gif|png|svg|webp|jfif|bmp|dpg)/i + return IMAGE_REGEXP.test(newValue) +} + +/** + * 是否视频格式 + * @param {Object} value + */ +function video(value) { + const VIDEO_REGEXP = /\.(mp4|mpg|mpeg|dat|asf|avi|rm|rmvb|mov|wmv|flv|mkv|m3u8)/i + return VIDEO_REGEXP.test(value) +} + +/** + * 是否为正则对象 + * @param {Object} + * @return {Boolean} + */ +function regExp(o) { + return o && Object.prototype.toString.call(o) === '[object RegExp]' +} + +export { + email, + mobile, + url, + date, + dateISO, + number, + digits, + idCard, + carNo, + amount, + chinese, + letter, + enOrNum, + contains, + range, + rangeLength, + empty, + jsonString, + landline, + object, + array, + code, + func, + promise, + video, + image, + regExp, + string +}