소스 검색

Merge branch 'master' of git.oschina.net:yiguanjia/php

north 7 년 전
부모
커밋
f2d3e93d7b
1개의 변경된 파일73개의 추가작업 그리고 75개의 파일을 삭제
  1. 73 75
      www/webapp/housekeeping/src/config/method.js

+ 73 - 75
www/webapp/housekeeping/src/config/method.js

@@ -1,29 +1,27 @@
-import axios from "axios";
-import qs from "qs";
-import globalVariables from "./globalVariables";
+import axios from 'axios';
+import qs from 'qs';
+import globalVariables from './globalVariables';
 
 let locationHref = location.href;
-let apiPath = "";
+let apiPath = '';
 
 // 时间戳 => 正常日期
 let timetrans = function(d) {
   var date = new Date(d * 1000); //如果date为13位不需要乘1000
-  var Y = date.getFullYear() + "年";
+  var Y = date.getFullYear() + '年';
   var M =
     (date.getMonth() + 1 < 10
-      ? "0" + (date.getMonth() + 1)
-      : date.getMonth() + 1) + "月";
+      ? '0' + (date.getMonth() + 1)
+      : date.getMonth() + 1) + '月';
   var D =
-    (date.getDate() < 10 ? "0" + date.getDate() : date.getDate()) + "日" + " ";
+    (date.getDate() < 10 ? '0' + date.getDate() : date.getDate()) + '日' + ' ';
   var h =
-    (date.getHours() < 10 ? "0" + date.getHours() : date.getHours()) + ":";
+    (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':';
   var m =
-    (date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes()) +
-    ":";
-  var s = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
-  console.log(`${Y}${M}${D}${h}${m}${s}`);
+    (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()) +
+    ':';
+  var s = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds();
   return `${Y}${M}${D}${h}${m}${s}`;
-  // return Y + M + D + h + m + s;
 };
 
 // 系统检测
@@ -33,18 +31,18 @@ function systemDetection(factor) {
     app = navigator.appVersion;
   //android终端或者uc浏览器
   let isAndroid =
-    (u.indexOf("Android") > -1 || u.indexOf("Linux") > -1) &&
-    (app.indexOf("Android") > -1 || app.indexOf("Linux") > -1);
+    (u.indexOf('Android') > -1 || u.indexOf('Linux') > -1) &&
+    (app.indexOf('Android') > -1 || app.indexOf('Linux') > -1);
   //ios终端
   let isiOS =
     !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/) &&
     !!app.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);
   if (isAndroid) {
-    return "Android";
+    return 'Android';
   } else if (isiOS) {
-    return "iOS";
+    return 'iOS';
   } else {
-    return "other";
+    return 'other';
   }
 }
 
@@ -54,8 +52,8 @@ axios.defaults.headers.common['Authorization'] = AUTH_TOKEN;
 axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';*/
 function $http(url, params, callback) {
   if (
-    locationHref.indexOf("commontest.yiguanjia.me") > -1 ||
-    locationHref.indexOf("common.yiguanjia.me") > -1
+    locationHref.indexOf('commontest.yiguanjia.me') > -1 ||
+    locationHref.indexOf('common.yiguanjia.me') > -1
   ) {
   } else {
     // apiPath = 'http://common.yiguanjia.me/index.php?r=';
@@ -63,12 +61,12 @@ function $http(url, params, callback) {
   }
   axios
     .post(globalVariables.apiPath + url, qs.stringify(params))
-    .then(response => {
+    .then((response) => {
       if (response.status === 200) {
         callback(response);
       }
     })
-    .catch(err => {
+    .catch((err) => {
       callback(err);
     });
 }
@@ -85,19 +83,19 @@ function SMS(params, callback) {
   */
   // 检验手机号码
   if (!/^1[34578]\d{9}$/.test(params.mobile) || params.mobile === 0) {
-    weui.alert("输入的手机号码有误,请重新输入");
+    weui.alert('输入的手机号码有误,请重新输入');
     return;
   }
   if (params.iCreateCode === params.createCode) {
     $http(
-      "/moonclub/reserve/code",
+      '/moonclub/reserve/code',
       {
         type: 2,
         mobile: params.mobile,
       },
-      res => {
+      (res) => {
         if (res.data.success) {
-          weui.alert("短信已发送,请留意查收!");
+          weui.alert('短信已发送,请留意查收!');
           // 绑定短信验证码
           callback(res.data.data.code);
           // this.code = res.data.data.code;
@@ -105,86 +103,86 @@ function SMS(params, callback) {
           // this.iCreateCode = '';// 清空已输入验证码
           // this.createCode = createCode(); // 重置验证码
         } else {
-          weui.alert("短信发送发送失败,请稍后再试!");
+          weui.alert('短信发送发送失败,请稍后再试!');
         }
       },
     );
   } else {
-    weui.alert("您输入验证码有误,请重新输入");
+    weui.alert('您输入验证码有误,请重新输入');
   }
 }
 
 // 身份证检验
 let checkID = function(ID) {
-  if (typeof ID !== "string") return "您输入的身份证包含其他文字";
-  if (ID === "") return "身份证号不为空";
+  if (typeof ID !== 'string') return '您输入的身份证包含其他文字';
+  if (ID === '') return '身份证号不为空';
   let city = {
-    11: "北京",
-    12: "天津",
-    13: "河北",
-    14: "山西",
-    15: "内蒙古",
-    21: "辽宁",
-    22: "吉林",
-    23: "黑龙江 ",
-    31: "上海",
-    32: "江苏",
-    33: "浙江",
-    34: "安徽",
-    35: "福建",
-    36: "江西",
-    37: "山东",
-    41: "河南",
-    42: "湖北 ",
-    43: "湖南",
-    44: "广东",
-    45: "广西",
-    46: "海南",
-    50: "重庆",
-    51: "四川",
-    52: "贵州",
-    53: "云南",
-    54: "西藏 ",
-    61: "陕西",
-    62: "甘肃",
-    63: "青海",
-    64: "宁夏",
-    65: "新疆",
-    71: "台湾",
-    81: "香港",
-    82: "澳门",
-    91: "国外",
+    11: '北京',
+    12: '天津',
+    13: '河北',
+    14: '山西',
+    15: '内蒙古',
+    21: '辽宁',
+    22: '吉林',
+    23: '黑龙江 ',
+    31: '上海',
+    32: '江苏',
+    33: '浙江',
+    34: '安徽',
+    35: '福建',
+    36: '江西',
+    37: '山东',
+    41: '河南',
+    42: '湖北 ',
+    43: '湖南',
+    44: '广东',
+    45: '广西',
+    46: '海南',
+    50: '重庆',
+    51: '四川',
+    52: '贵州',
+    53: '云南',
+    54: '西藏 ',
+    61: '陕西',
+    62: '甘肃',
+    63: '青海',
+    64: '宁夏',
+    65: '新疆',
+    71: '台湾',
+    81: '香港',
+    82: '澳门',
+    91: '国外',
   };
   let birthday =
     ID.substr(6, 4) +
-    "/" +
+    '/' +
     Number(ID.substr(10, 2)) +
-    "/" +
+    '/' +
     Number(ID.substr(12, 2));
   let d = new Date(birthday);
   let newBirthday =
     d.getFullYear() +
-    "/" +
+    '/' +
     Number(d.getMonth() + 1) +
-    "/" +
+    '/' +
     Number(d.getDate());
   let currentTime = new Date().getTime();
   let time = d.getTime();
   let arrInt = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2];
-  let arrCh = ["1", "0", "X", "9", "8", "7", "6", "5", "4", "3", "2"];
+  let arrCh = ['1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2'];
   let sum = 0,
     i,
     residue;
 
-  if (!/^\d{17}(\d|x)$/i.test(ID)) return "身份证格式有误";
-  if (city[ID.substr(0, 2)] === undefined) return "身份证所在地区不属于中国!";
+  if (!/^\d{17}(\d|x)$/i.test(ID)) return '身份证格式有误';
+  if (city[ID.substr(0, 2)] === undefined) return '身份证所在地区不属于中国!';
   if (time >= currentTime || birthday !== newBirthday)
-    return "身份证中的出生日期,不属于当代!";
+    return '身份证中的出生日期,不属于当代!';
   for (i = 0; i < 17; i++) {
     sum += ID.substr(i, 1) * arrInt[i];
   }
   residue = arrCh[sum % 11];
-  if (residue !== ID.substr(17, 1)) return "身份证格式有误";
+  if (residue !== ID.substr(17, 1)) return '身份证格式有误';
 
   // return city[ID.substr(0, 2)] + "," + birthday + "," + (ID.substr(16, 1) % 2 ? " 男" : "女") //浙江,1994/7/26, 男
   return true;