123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120 |
- export function isCardNo(card) {
-
- var reg =
- /(^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$)|(^[1-9]\d{5}\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{2}$)/;
- if (reg.test(card) === false) {
- console.log(card);
- return false;
- }
- return true
- }
- export function getMoneyStyle(value = 0) {
- if (typeof value == 'string') {
- value = (+value).toFixed(2)
- }
- if (typeof value == 'number') {
- value = value.toFixed(2)
- }
-
- let n = value.split("");
-
- let arr = n.reverse().map(function(e, ind, ar) {
-
- if (ind % 3 == 0 && ind / 3 > 1 && ind != ar.length) {
- return e + ','
- } else {
- return e
- }
- })
-
- arr = arr.reverse().join('')
- return arr;
- }
- export function timeComputed(time) {
-
- const actTime = (new Date()).getTime();
-
- let stopTime = time - actTime;
-
- if (stopTime < 0) {
- stopTime = stopTime * -1
- }
- let day = Math.floor(stopTime / 1000 / 60 / 60 / 24)
- let hours = Math.floor((stopTime / 1000 / 60 / 60) % 24);
- let minutes = Math.floor((stopTime / 1000 / 60) % 60);
- let seconds = Math.floor((stopTime / 1000) % 60);
- return {
- hours,
- minutes,
- seconds,
- day
- }
- }
- export function openMap(e) {
- const that = this
- return new Promise((resolve, reject) => {
- wx.getSetting({
- success(res) {
-
- if (!res.authSetting['scope.userLocation']) {
- wx.showModal({
- title: '提示',
- content: '请求获取位置权限',
- success: function(res) {
- if (res.confirm == false) {
-
- reject()
- return false;
- }
- wx.openSetting({
- success(res) {
-
- if (!res.authSetting['scope.userLocation']) {
- wx.showToast({
- title: '此功能需获取位置信息,请重新设置',
- duration: 3000,
- icon: 'none'
- })
- } else {
-
- resolve()
- }
- }
- })
- }
- })
- } else {
-
- resolve()
- }
- }
- })
- })
- }
- export function getTime(time) {
- const num =13 - (time+'').length;
- let l = 1;
- for (let i = 0; i < num; i++) {
- l+='0';
- }
-
- l = parseInt(l)
- const date = new Date(parseInt(time) * l);
- const year = date.getFullYear();
- const mon = date.getMonth() + 1;
- const day = date.getDate();
- const hours = date.getHours();
- const minu = date.getMinutes();
- const sec = date.getSeconds();
- return year + '-' + mon + '-' + day + ' ' + hours + ':' + minu + ':' + sec;
- }
|