123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- 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) {
-
- let actTime = (new Date()).getTime();
-
- let stopTime = time - actTime;
- let daytime = Math.floor(stopTime / 24 / 3600 / 1000)
-
- if (stopTime < 0) {
- stopTime = stopTime * -1
- }
- let day = daytime;
- 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 {
- day,
- hours,
- minutes,
- seconds
- }
- }
- export function deconstructArticle(data) {
- if (data) {
- data = data.replace(/<img/g, '<img style="width: 100% !important;height:auto"').replace(
- /<p>\S*<img/g, '<p style="line-height: 0;"><img');
- }
- return data;
- }
- export function openMap(e) {
- var that = this
- return new Promise((resolve, reject) => {
- uni.getSetting({
- success(res) {
- console.log(res);
-
- if (!res.authSetting['scope.userLocation']) {
- uni.showModal({
- title: '提示',
- content: '请求获取位置权限',
- success: function(res) {
- if (res.confirm == false) {
-
- reject()
- return false;
- }
- uni.openSetting({
- success(res) {
- console.log(res);
-
- if (!res.authSetting['scope.userLocation']) {
- uni.showToast({
- title: '此功能需获取位置信息,请重新设置',
- duration: 3000,
- icon: 'none'
- })
- } else {
-
- resolve()
- }
- },
- fail(e) {
- console.log(e);
- }
- })
- }
- })
- } else {
-
- resolve()
- }
- }
- })
-
- })
- }
|