我们发布啦
This commit is contained in:
110
app/utils/SubscribeMessage.js
Normal file
110
app/utils/SubscribeMessage.js
Normal file
@@ -0,0 +1,110 @@
|
||||
import {
|
||||
SUBSCRIBE_MESSAGE
|
||||
} from '../config/cache.js';
|
||||
|
||||
export function auth() {
|
||||
let tmplIds = {};
|
||||
let messageTmplIds = uni.getStorageSync(SUBSCRIBE_MESSAGE);
|
||||
tmplIds = messageTmplIds ? JSON.parse(messageTmplIds) : {};
|
||||
return tmplIds;
|
||||
}
|
||||
|
||||
/**
|
||||
* 支付成功后订阅消息id
|
||||
* 订阅 确认收货通知 订单支付成功 新订单管理员提醒
|
||||
*/
|
||||
export function openPaySubscribe() {
|
||||
let tmplIds = auth();
|
||||
return subscribe([
|
||||
tmplIds.oreder_takever,
|
||||
tmplIds.order_pay_success,
|
||||
tmplIds.order_new,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单相关订阅消息
|
||||
* 送货 发货 取消订单
|
||||
*/
|
||||
export function openOrderSubscribe() {
|
||||
let tmplIds = auth();
|
||||
return subscribe([
|
||||
tmplIds.order_deliver_success,
|
||||
tmplIds.order_postage_success,
|
||||
tmplIds.order_clone
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 提现消息订阅
|
||||
* 成功 和 失败 消息
|
||||
*/
|
||||
export function openExtrctSubscribe() {
|
||||
let tmplIds = auth();
|
||||
return subscribe([
|
||||
tmplIds.user_extract
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 拼团成功
|
||||
*/
|
||||
export function openPinkSubscribe() {
|
||||
let tmplIds = auth();
|
||||
return subscribe([
|
||||
tmplIds.pink_true
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 砍价成功
|
||||
*/
|
||||
export function openBargainSubscribe() {
|
||||
let tmplIds = auth();
|
||||
return subscribe([
|
||||
tmplIds.bargain_success
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单退款
|
||||
*/
|
||||
export function openOrderRefundSubscribe() {
|
||||
let tmplIds = auth();
|
||||
return subscribe([tmplIds.order_refund]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 充值成功
|
||||
*/
|
||||
export function openRechargeSubscribe() {
|
||||
let tmplIds = auth();
|
||||
return subscribe([tmplIds.recharge_success]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 提现
|
||||
*/
|
||||
export function openEextractSubscribe() {
|
||||
let tmplIds = auth();
|
||||
return subscribe([tmplIds.user_extract]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 调起订阅界面
|
||||
* array tmplIds 模板id
|
||||
*/
|
||||
export function subscribe(tmplIds) {
|
||||
let wecaht = wx;
|
||||
return new Promise((reslove, reject) => {
|
||||
wecaht.requestSubscribeMessage({
|
||||
tmplIds: tmplIds,
|
||||
success(res) {
|
||||
return reslove(res);
|
||||
},
|
||||
fail(res) {
|
||||
return reslove(res);
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
146
app/utils/cache.js
Normal file
146
app/utils/cache.js
Normal file
@@ -0,0 +1,146 @@
|
||||
import { EXPIRE } from '../config/app';
|
||||
|
||||
class Cache {
|
||||
|
||||
constructor(handler) {
|
||||
this.cacheSetHandler = uni.setStorageSync;
|
||||
this.cacheGetHandler = uni.getStorageSync;
|
||||
this.cacheClearHandler = uni.removeStorageSync;
|
||||
this.cacheExpire = '_expire_2019_12_17_18_44';
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前时间戳
|
||||
*/
|
||||
time()
|
||||
{
|
||||
return Math.round(new Date() / 1000);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置过期时间缓存
|
||||
* @param {Object} key
|
||||
* @param {Object} expire
|
||||
*/
|
||||
setExpireCahe(key,expire)
|
||||
{
|
||||
expire = expire !== undefined ? expire : EXPIRE;
|
||||
if (expire) {
|
||||
this.cacheSetHandler(key + this.cacheExpire,this.time() + expire)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 缓存是否过期,过期自动删除
|
||||
* @param {Object} key
|
||||
* @param {Object} $bool true = 删除,false = 不删除
|
||||
*/
|
||||
getExpireCahe(key,$bool)
|
||||
{
|
||||
try{
|
||||
let time = this.cacheGetHandler(key + this.cacheExpire);
|
||||
if (time) {
|
||||
let newTime = parseInt(time);
|
||||
if (time && time < this.time() && !Number.isNaN(newTime)) {
|
||||
if ($bool === undefined || $bool === true) {
|
||||
this.cacheClearHandler(key);
|
||||
this.cacheClearHandler(key + this.cacheExpire);
|
||||
}
|
||||
return false;
|
||||
} else
|
||||
return true;
|
||||
} else {
|
||||
return !!this.cacheGetHandler(key);
|
||||
}
|
||||
}catch(e){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置缓存
|
||||
* @param {Object} key
|
||||
* @param {Object} data
|
||||
*/
|
||||
set(key,data,expire){
|
||||
if(typeof data === 'object')
|
||||
data = JSON.stringify(data);
|
||||
try{
|
||||
this.setExpireCahe(key,expire);
|
||||
return this.cacheSetHandler(key,data);
|
||||
}catch(e){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 检测缓存是否存在
|
||||
* @param {Object} key
|
||||
*/
|
||||
has(key)
|
||||
{
|
||||
return this.getExpireCahe(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取缓存
|
||||
* @param {Object} key
|
||||
* @param {Object} $default
|
||||
* @param {Object} expire
|
||||
*/
|
||||
get(key,$default,expire){
|
||||
try{
|
||||
let isBe = this.getExpireCahe(key);
|
||||
let data = this.cacheGetHandler(key);
|
||||
if (data && isBe) {
|
||||
if (typeof $default === 'boolean')
|
||||
return JSON.parse(data);
|
||||
else
|
||||
return data;
|
||||
} else {
|
||||
if (typeof $default === 'function') {
|
||||
let value = $default();
|
||||
this.set(key,value,expire);
|
||||
return value;
|
||||
} else {
|
||||
this.set(key,$default,expire);
|
||||
return $default;
|
||||
}
|
||||
}
|
||||
}catch(e){
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除缓存
|
||||
* @param {Object} key
|
||||
*/
|
||||
clear(key)
|
||||
{
|
||||
try{
|
||||
let cahceValue = this.cacheGetHandler(key + this.cacheExpire);
|
||||
if(cahceValue)
|
||||
this.cacheClearHandler(key + this.cacheExpire);
|
||||
return this.cacheClearHandler(key);
|
||||
}catch(e){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 清除过期缓存
|
||||
*/
|
||||
clearOverdue()
|
||||
{
|
||||
// let cacheList = uni.getStorageInfoSync(),that = this;
|
||||
// if (typeof cacheList.keys === 'object'){
|
||||
// cacheList.keys.forEach(item=>{
|
||||
// that.getExpireCahe(item);
|
||||
// })
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export default new Cache;
|
||||
1
app/utils/dialog.js
Normal file
1
app/utils/dialog.js
Normal file
@@ -0,0 +1 @@
|
||||
|
||||
62
app/utils/emoji.js
Normal file
62
app/utils/emoji.js
Normal file
@@ -0,0 +1,62 @@
|
||||
export default [
|
||||
"em-smile",
|
||||
"em-laughing",
|
||||
"em-blush",
|
||||
"em-smiley",
|
||||
"em-relaxed",
|
||||
"em-smirk",
|
||||
"em-heart_eyes",
|
||||
"em-kissing_heart",
|
||||
"em-kissing_closed_eyes",
|
||||
"em-flushed",
|
||||
"em-relieved",
|
||||
"em-satisfied",
|
||||
"em-grin",
|
||||
"em-wink",
|
||||
"em-stuck_out_tongue_winking_eye",
|
||||
"em-stuck_out_tongue_closed_eyes",
|
||||
"em-grinning",
|
||||
"em-kissing",
|
||||
"em-kissing_smiling_eyes",
|
||||
"em-stuck_out_tongue",
|
||||
"em-sleeping",
|
||||
"em-worried",
|
||||
"em-frowning",
|
||||
"em-anguished",
|
||||
"em-open_mouth",
|
||||
"em-grimacing",
|
||||
"em-confused",
|
||||
"em-hushed",
|
||||
"em-expressionless",
|
||||
"em-unamused",
|
||||
"em-sweat_smile",
|
||||
"em-sweat",
|
||||
"em-disappointed_relieved",
|
||||
"em-weary",
|
||||
"em-pensive",
|
||||
"em-disappointed",
|
||||
"em-confounded",
|
||||
"em-fearful",
|
||||
"em-cold_sweat",
|
||||
"em-persevere",
|
||||
"em-cry",
|
||||
"em-sob",
|
||||
"em-joy",
|
||||
"em-astonished",
|
||||
"em-scream",
|
||||
"em-tired_face",
|
||||
"em-angry",
|
||||
"em-rage",
|
||||
"em-triumph",
|
||||
"em-sleepy",
|
||||
"em-yum",
|
||||
"em-mask",
|
||||
"em-sunglasses",
|
||||
"em-dizzy_face",
|
||||
"em-imp",
|
||||
"em-smiling_imp",
|
||||
"em-neutral_face",
|
||||
"em-no_mouth",
|
||||
"em-innocent",
|
||||
"em-alien"
|
||||
];
|
||||
84
app/utils/index.js
Normal file
84
app/utils/index.js
Normal file
@@ -0,0 +1,84 @@
|
||||
import { spread } from "@/api/user";
|
||||
import Cache from "@/utils/cache";
|
||||
|
||||
/**
|
||||
* 绑定用户授权
|
||||
* @param {Object} puid
|
||||
*/
|
||||
export function silenceBindingSpread()
|
||||
{
|
||||
|
||||
|
||||
//#ifdef H5
|
||||
let puid = Cache.get('spread');
|
||||
//#endif
|
||||
|
||||
//#ifdef MP
|
||||
let puid = getApp().globalData.spid;
|
||||
if(!puid){
|
||||
puid = getApp().globalData.code;
|
||||
}
|
||||
//#endif
|
||||
|
||||
puid = parseInt(puid);
|
||||
if(Number.isNaN(puid)){
|
||||
puid = 0;
|
||||
}
|
||||
if(puid){
|
||||
spread(puid).then(res=>{
|
||||
console.log(res);
|
||||
//#ifdef H5
|
||||
Cache.clear('spread');
|
||||
//#endif
|
||||
|
||||
//#ifdef MP
|
||||
getApp().globalData.spid = 0;
|
||||
getApp().globalData.code = 0;
|
||||
//#endif
|
||||
|
||||
}).catch(res=>{
|
||||
console.log(res);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export function isWeixin() {
|
||||
return navigator.userAgent.toLowerCase().indexOf("micromessenger") !== -1;
|
||||
}
|
||||
|
||||
export function parseQuery() {
|
||||
const res = {};
|
||||
|
||||
const query = (location.href.split("?")[1] || "")
|
||||
.trim()
|
||||
.replace(/^(\?|#|&)/, "");
|
||||
|
||||
if (!query) {
|
||||
return res;
|
||||
}
|
||||
|
||||
query.split("&").forEach(param => {
|
||||
const parts = param.replace(/\+/g, " ").split("=");
|
||||
const key = decodeURIComponent(parts.shift());
|
||||
const val = parts.length > 0 ? decodeURIComponent(parts.join("=")) : null;
|
||||
|
||||
if (res[key] === undefined) {
|
||||
res[key] = val;
|
||||
} else if (Array.isArray(res[key])) {
|
||||
res[key].push(val);
|
||||
} else {
|
||||
res[key] = [res[key], val];
|
||||
}
|
||||
});
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
// #ifdef H5
|
||||
const VUE_APP_WS_URL = process.env.VUE_APP_WS_URL || `ws://${location.hostname}:20001`;
|
||||
export {VUE_APP_WS_URL}
|
||||
// #endif
|
||||
|
||||
|
||||
|
||||
export default parseQuery;
|
||||
245
app/utils/permission.js
Normal file
245
app/utils/permission.js
Normal file
@@ -0,0 +1,245 @@
|
||||
/// null = 未请求,1 = 已允许,0 = 拒绝|受限, 2 = 系统未开启
|
||||
|
||||
var isIOS
|
||||
|
||||
function album() {
|
||||
var result = 0;
|
||||
var PHPhotoLibrary = plus.ios.import("PHPhotoLibrary");
|
||||
var authStatus = PHPhotoLibrary.authorizationStatus();
|
||||
if (authStatus === 0) {
|
||||
result = null;
|
||||
} else if (authStatus == 3) {
|
||||
result = 1;
|
||||
} else {
|
||||
result = 0;
|
||||
}
|
||||
plus.ios.deleteObject(PHPhotoLibrary);
|
||||
return result;
|
||||
}
|
||||
|
||||
function camera() {
|
||||
var result = 0;
|
||||
var AVCaptureDevice = plus.ios.import("AVCaptureDevice");
|
||||
var authStatus = AVCaptureDevice.authorizationStatusForMediaType('vide');
|
||||
if (authStatus === 0) {
|
||||
result = null;
|
||||
} else if (authStatus == 3) {
|
||||
result = 1;
|
||||
} else {
|
||||
result = 0;
|
||||
}
|
||||
plus.ios.deleteObject(AVCaptureDevice);
|
||||
return result;
|
||||
}
|
||||
|
||||
function location() {
|
||||
var result = 0;
|
||||
var cllocationManger = plus.ios.import("CLLocationManager");
|
||||
var enable = cllocationManger.locationServicesEnabled();
|
||||
var status = cllocationManger.authorizationStatus();
|
||||
if (!enable) {
|
||||
result = 2;
|
||||
} else if (status === 0) {
|
||||
result = null;
|
||||
} else if (status === 3 || status === 4) {
|
||||
result = 1;
|
||||
} else {
|
||||
result = 0;
|
||||
}
|
||||
plus.ios.deleteObject(cllocationManger);
|
||||
return result;
|
||||
}
|
||||
|
||||
function push() {
|
||||
var result = 0;
|
||||
var UIApplication = plus.ios.import("UIApplication");
|
||||
var app = UIApplication.sharedApplication();
|
||||
var enabledTypes = 0;
|
||||
if (app.currentUserNotificationSettings) {
|
||||
var settings = app.currentUserNotificationSettings();
|
||||
enabledTypes = settings.plusGetAttribute("types");
|
||||
if (enabledTypes == 0) {
|
||||
result = 0;
|
||||
console.log("推送权限没有开启");
|
||||
} else {
|
||||
result = 1;
|
||||
console.log("已经开启推送功能!")
|
||||
}
|
||||
plus.ios.deleteObject(settings);
|
||||
} else {
|
||||
enabledTypes = app.enabledRemoteNotificationTypes();
|
||||
if (enabledTypes == 0) {
|
||||
result = 3;
|
||||
console.log("推送权限没有开启!");
|
||||
} else {
|
||||
result = 4;
|
||||
console.log("已经开启推送功能!")
|
||||
}
|
||||
}
|
||||
plus.ios.deleteObject(app);
|
||||
plus.ios.deleteObject(UIApplication);
|
||||
return result;
|
||||
}
|
||||
|
||||
function contact() {
|
||||
var result = 0;
|
||||
var CNContactStore = plus.ios.import("CNContactStore");
|
||||
var cnAuthStatus = CNContactStore.authorizationStatusForEntityType(0);
|
||||
if (cnAuthStatus === 0) {
|
||||
result = null;
|
||||
} else if (cnAuthStatus == 3) {
|
||||
result = 1;
|
||||
} else {
|
||||
result = 0;
|
||||
}
|
||||
plus.ios.deleteObject(CNContactStore);
|
||||
return result;
|
||||
}
|
||||
|
||||
function record() {
|
||||
var result = null;
|
||||
var avaudiosession = plus.ios.import("AVAudioSession");
|
||||
var avaudio = avaudiosession.sharedInstance();
|
||||
var status = avaudio.recordPermission();
|
||||
console.log("permissionStatus:" + status);
|
||||
if (status === 1970168948) {
|
||||
result = null;
|
||||
} else if (status === 1735552628) {
|
||||
result = 1;
|
||||
} else {
|
||||
result = 0;
|
||||
}
|
||||
plus.ios.deleteObject(avaudiosession);
|
||||
return result;
|
||||
}
|
||||
|
||||
function calendar() {
|
||||
var result = null;
|
||||
var EKEventStore = plus.ios.import("EKEventStore");
|
||||
var ekAuthStatus = EKEventStore.authorizationStatusForEntityType(0);
|
||||
if (ekAuthStatus == 3) {
|
||||
result = 1;
|
||||
console.log("日历权限已经开启");
|
||||
} else {
|
||||
console.log("日历权限没有开启");
|
||||
}
|
||||
plus.ios.deleteObject(EKEventStore);
|
||||
return result;
|
||||
}
|
||||
|
||||
function memo() {
|
||||
var result = null;
|
||||
var EKEventStore = plus.ios.import("EKEventStore");
|
||||
var ekAuthStatus = EKEventStore.authorizationStatusForEntityType(1);
|
||||
if (ekAuthStatus == 3) {
|
||||
result = 1;
|
||||
console.log("备忘录权限已经开启");
|
||||
} else {
|
||||
console.log("备忘录权限没有开启");
|
||||
}
|
||||
plus.ios.deleteObject(EKEventStore);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
function requestIOS(permissionID) {
|
||||
return new Promise((resolve, reject) => {
|
||||
switch (permissionID) {
|
||||
case "push":
|
||||
resolve(push());
|
||||
break;
|
||||
case "location":
|
||||
resolve(location());
|
||||
break;
|
||||
case "record":
|
||||
resolve(record());
|
||||
break;
|
||||
case "camera":
|
||||
resolve(camera());
|
||||
break;
|
||||
case "album":
|
||||
resolve(album());
|
||||
break;
|
||||
case "contact":
|
||||
resolve(contact());
|
||||
break;
|
||||
case "calendar":
|
||||
resolve(calendar());
|
||||
break;
|
||||
case "memo":
|
||||
resolve(memo());
|
||||
break;
|
||||
default:
|
||||
resolve(0);
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function requestAndroid(permissionID) {
|
||||
return new Promise((resolve, reject) => {
|
||||
plus.android.requestPermissions(
|
||||
[permissionID],
|
||||
function(resultObj) {
|
||||
var result = 0;
|
||||
for (var i = 0; i < resultObj.granted.length; i++) {
|
||||
var grantedPermission = resultObj.granted[i];
|
||||
console.log('已获取的权限:' + grantedPermission);
|
||||
result = 1
|
||||
}
|
||||
for (var i = 0; i < resultObj.deniedPresent.length; i++) {
|
||||
var deniedPresentPermission = resultObj.deniedPresent[i];
|
||||
console.log('拒绝本次申请的权限:' + deniedPresentPermission);
|
||||
result = 0
|
||||
}
|
||||
for (var i = 0; i < resultObj.deniedAlways.length; i++) {
|
||||
var deniedAlwaysPermission = resultObj.deniedAlways[i];
|
||||
console.log('永久拒绝申请的权限:' + deniedAlwaysPermission);
|
||||
result = -1
|
||||
}
|
||||
resolve(result);
|
||||
},
|
||||
function(error) {
|
||||
console.log('result error: ' + error.message)
|
||||
resolve({
|
||||
code: error.code,
|
||||
message: error.message
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
function gotoAppPermissionSetting() {
|
||||
if (permission.isIOS) {
|
||||
var UIApplication = plus.ios.import("UIApplication");
|
||||
var application2 = UIApplication.sharedApplication();
|
||||
var NSURL2 = plus.ios.import("NSURL");
|
||||
var setting2 = NSURL2.URLWithString("app-settings:");
|
||||
application2.openURL(setting2);
|
||||
plus.ios.deleteObject(setting2);
|
||||
plus.ios.deleteObject(NSURL2);
|
||||
plus.ios.deleteObject(application2);
|
||||
} else {
|
||||
var Intent = plus.android.importClass("android.content.Intent");
|
||||
var Settings = plus.android.importClass("android.provider.Settings");
|
||||
var Uri = plus.android.importClass("android.net.Uri");
|
||||
var mainActivity = plus.android.runtimeMainActivity();
|
||||
var intent = new Intent();
|
||||
intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
|
||||
var uri = Uri.fromParts("package", mainActivity.getPackageName(), null);
|
||||
intent.setData(uri);
|
||||
mainActivity.startActivity(intent);
|
||||
}
|
||||
}
|
||||
|
||||
const permission = {
|
||||
get isIOS(){
|
||||
return typeof isIOS === 'boolean' ? isIOS : (isIOS = uni.getSystemInfoSync().platform === 'ios')
|
||||
},
|
||||
requestIOS: requestIOS,
|
||||
requestAndroid: requestAndroid,
|
||||
gotoAppSetting: gotoAppPermissionSetting
|
||||
}
|
||||
|
||||
module.exports = permission
|
||||
69
app/utils/request.js
Normal file
69
app/utils/request.js
Normal file
@@ -0,0 +1,69 @@
|
||||
import {
|
||||
HTTP_REQUEST_URL,
|
||||
HEADER,
|
||||
TOKENNAME,
|
||||
HEADERPARAMS
|
||||
} from '@/config/app';
|
||||
import {
|
||||
toLogin,
|
||||
checkLogin
|
||||
} from '../libs/login';
|
||||
import store from '../store';
|
||||
|
||||
|
||||
/**
|
||||
* 发送请求
|
||||
*/
|
||||
function baseRequest(url, method, data, {
|
||||
noAuth = false,
|
||||
noVerify = false
|
||||
}, params) {
|
||||
let Url = HTTP_REQUEST_URL,header = HEADER
|
||||
if (params != undefined) {
|
||||
header = HEADERPARAMS;
|
||||
}
|
||||
if (!noAuth) {
|
||||
//登录过期自动登录
|
||||
if (!store.state.app.token && !checkLogin()) {
|
||||
toLogin();
|
||||
return Promise.reject({
|
||||
msg: '未登陆'
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (store.state.app.token) header[TOKENNAME] = store.state.app.token;
|
||||
|
||||
return new Promise((reslove, reject) => {
|
||||
uni.request({
|
||||
url: Url + '/api/front/' + url,
|
||||
method: method || 'GET',
|
||||
header: header,
|
||||
data: data || {},
|
||||
success: (res) => {
|
||||
if (noVerify)
|
||||
reslove(res.data, res);
|
||||
else if (res.data.code == 200)
|
||||
reslove(res.data, res);
|
||||
else if ([410000, 410001, 410002, 401].indexOf(res.data.code) !== -1) {
|
||||
toLogin();
|
||||
reject(res.data);
|
||||
} else
|
||||
reject(res.data.message || '系统错误');
|
||||
},
|
||||
fail: (msg) => {
|
||||
reject('请求失败');
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
const request = {};
|
||||
|
||||
['options', 'get', 'post', 'put', 'head', 'delete', 'trace', 'connect'].forEach((method) => {
|
||||
request[method] = (api, data, opt, params) => baseRequest(api, method, data, opt || {}, params)
|
||||
});
|
||||
|
||||
|
||||
|
||||
export default request;
|
||||
623
app/utils/util.js
Normal file
623
app/utils/util.js
Normal file
@@ -0,0 +1,623 @@
|
||||
import {
|
||||
TOKENNAME,
|
||||
HTTP_REQUEST_URL
|
||||
} from '../config/app.js';
|
||||
import store from '../store';
|
||||
import {
|
||||
pathToBase64
|
||||
} from '@/plugin/image-tools/index.js';
|
||||
// #ifdef APP-PLUS
|
||||
import permision from "./permission.js"
|
||||
// #endif
|
||||
export default {
|
||||
/**
|
||||
* opt object | string
|
||||
* to_url object | string
|
||||
* 例:
|
||||
* this.Tips('/pages/test/test'); 跳转不提示
|
||||
* this.Tips({title:'提示'},'/pages/test/test'); 提示并跳转
|
||||
* this.Tips({title:'提示'},{tab:1,url:'/pages/index/index'}); 提示并跳转值table上
|
||||
* tab=1 一定时间后跳转至 table上
|
||||
* tab=2 一定时间后跳转至非 table上
|
||||
* tab=3 一定时间后返回上页面
|
||||
* tab=4 关闭所有页面跳转至非table上
|
||||
* tab=5 关闭当前页面跳转至table上
|
||||
*/
|
||||
Tips: function(opt, to_url) {
|
||||
if (typeof opt == 'string') {
|
||||
to_url = opt;
|
||||
opt = {};
|
||||
}
|
||||
let title = opt.title || '',
|
||||
icon = opt.icon || 'none',
|
||||
endtime = opt.endtime || 2000,
|
||||
success = opt.success;
|
||||
if (title) uni.showToast({
|
||||
title: title,
|
||||
icon: icon,
|
||||
duration: endtime,
|
||||
success
|
||||
})
|
||||
if (to_url != undefined) {
|
||||
if (typeof to_url == 'object') {
|
||||
let tab = to_url.tab || 1,
|
||||
url = to_url.url || '';
|
||||
switch (tab) {
|
||||
case 1:
|
||||
//一定时间后跳转至 table
|
||||
setTimeout(function() {
|
||||
uni.switchTab({
|
||||
url: url
|
||||
})
|
||||
}, endtime);
|
||||
break;
|
||||
case 2:
|
||||
//跳转至非table页面
|
||||
setTimeout(function() {
|
||||
uni.navigateTo({
|
||||
url: url,
|
||||
})
|
||||
}, endtime);
|
||||
break;
|
||||
case 3:
|
||||
//返回上页面
|
||||
setTimeout(function() {
|
||||
// #ifndef H5
|
||||
uni.navigateBack({
|
||||
delta: parseInt(url),
|
||||
})
|
||||
// #endif
|
||||
// #ifdef H5
|
||||
history.back();
|
||||
// #endif
|
||||
}, endtime);
|
||||
break;
|
||||
case 4:
|
||||
//关闭当前所有页面跳转至非table页面
|
||||
setTimeout(function() {
|
||||
uni.reLaunch({
|
||||
url: url,
|
||||
})
|
||||
}, endtime);
|
||||
break;
|
||||
case 5:
|
||||
//关闭当前页面跳转至非table页面
|
||||
setTimeout(function() {
|
||||
uni.redirectTo({
|
||||
url: url,
|
||||
})
|
||||
}, endtime);
|
||||
break;
|
||||
}
|
||||
|
||||
} else if (typeof to_url == 'function') {
|
||||
setTimeout(function() {
|
||||
to_url && to_url();
|
||||
}, endtime);
|
||||
} else {
|
||||
//没有提示时跳转不延迟
|
||||
setTimeout(function() {
|
||||
uni.navigateTo({
|
||||
url: to_url,
|
||||
})
|
||||
}, title ? endtime : 0);
|
||||
}
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 移除数组中的某个数组并组成新的数组返回
|
||||
* @param array array 需要移除的数组
|
||||
* @param int index 需要移除的数组的键值
|
||||
* @param string | int 值
|
||||
* @return array
|
||||
*
|
||||
*/
|
||||
ArrayRemove: function(array, index, value) {
|
||||
const valueArray = [];
|
||||
if (array instanceof Array) {
|
||||
for (let i = 0; i < array.length; i++) {
|
||||
if (typeof index == 'number' && array[index] != i) {
|
||||
valueArray.push(array[i]);
|
||||
} else if (typeof index == 'string' && array[i][index] != value) {
|
||||
valueArray.push(array[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return valueArray;
|
||||
},
|
||||
/**
|
||||
* 生成海报获取文字
|
||||
* @param string text 为传入的文本
|
||||
* @param int num 为单行显示的字节长度
|
||||
* @return array
|
||||
*/
|
||||
textByteLength: function(text, num) {
|
||||
let strLength = 0;
|
||||
let rows = 1;
|
||||
let str = 0;
|
||||
let arr = [];
|
||||
for (let j = 0; j < text.length; j++) {
|
||||
if (text.charCodeAt(j) > 255) {
|
||||
strLength += 2;
|
||||
if (strLength > rows * num) {
|
||||
strLength++;
|
||||
arr.push(text.slice(str, j));
|
||||
str = j;
|
||||
rows++;
|
||||
}
|
||||
} else {
|
||||
strLength++;
|
||||
if (strLength > rows * num) {
|
||||
arr.push(text.slice(str, j));
|
||||
str = j;
|
||||
rows++;
|
||||
}
|
||||
}
|
||||
}
|
||||
arr.push(text.slice(str, text.length));
|
||||
return [strLength, arr, rows] // [处理文字的总字节长度,每行显示内容的数组,行数]
|
||||
},
|
||||
// 生成海报
|
||||
PosterCanvas:function(arrImages, storeName, price, successFn){
|
||||
uni.showLoading({
|
||||
title: '海报生成中',
|
||||
mask: true
|
||||
});
|
||||
let context = uni.createCanvasContext('firstCanvas')
|
||||
context.clearRect(0, 0, 0, 0);
|
||||
let that = this;
|
||||
uni.getImageInfo({
|
||||
src: arrImages[0],
|
||||
success: function (image) {
|
||||
context.drawImage(arrImages[0], 0, 0, 750, 1190);
|
||||
context.drawImage(arrImages[1], 0, 0, 750, 750);
|
||||
context.save();
|
||||
context.drawImage(arrImages[2], 110, 1000, 140, 140);
|
||||
context.restore();
|
||||
context.setFontSize(30);
|
||||
context.setTextAlign('center');
|
||||
let maxText = 28;
|
||||
let text = storeName;
|
||||
let topText = '';
|
||||
let bottomText = '';
|
||||
let len = text.length;
|
||||
if(len>maxText*2){
|
||||
text = text.slice(0,maxText*2-4)+'......';
|
||||
topText = text.slice(0,maxText-1);
|
||||
bottomText = text.slice(maxText-1,len);
|
||||
}else{
|
||||
if(len>maxText){
|
||||
topText = text.slice(0,maxText-1);
|
||||
bottomText = text.slice(maxText-1,len);
|
||||
}else{
|
||||
topText = text;
|
||||
bottomText = '';
|
||||
}
|
||||
}
|
||||
context.fillText(topText, 750/2, 800);
|
||||
context.fillText(bottomText, 750/2, 840);
|
||||
context.setFontSize(37);
|
||||
context.setTextAlign('center');
|
||||
context.setFillStyle('#fc4141');
|
||||
context.fillText('¥' + price, 750 / 2, 900);
|
||||
context.draw(true,function(){
|
||||
uni.canvasToTempFilePath({
|
||||
destWidth: 750,
|
||||
destHeight: 1190,
|
||||
canvasId: 'firstCanvas',
|
||||
fileType: 'jpg',
|
||||
success: function(res) {
|
||||
// 在H5平台下,tempFilePath 为 base64
|
||||
uni.hideLoading();
|
||||
successFn && successFn(res.tempFilePath);
|
||||
// that.imagePath = res.tempFilePath;
|
||||
// that.canvasStatus = true;
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
fail: function(err) {
|
||||
uni.hideLoading();
|
||||
that.Tips({
|
||||
title: '无法获取图片信息'
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
/**
|
||||
* 获取分享海报
|
||||
* @param array arr2 海报素材
|
||||
* @param string store_name 素材文字
|
||||
* @param string price 价格
|
||||
* @param function successFn 回调函数
|
||||
*
|
||||
*
|
||||
*/
|
||||
// PosterCanvas: function(arr2, store_name, price, successFn) {
|
||||
// let that = this;
|
||||
// uni.showLoading({
|
||||
// title: '海报生成中',
|
||||
// mask: true
|
||||
// });
|
||||
// const ctx = uni.createCanvasContext('myCanvas');
|
||||
// ctx.clearRect(0, 0, 0, 0);
|
||||
// /**
|
||||
// * 只能获取合法域名下的图片信息,本地调试无法获取
|
||||
// *
|
||||
// */
|
||||
// uni.getImageInfo({
|
||||
// src: arr2[0],
|
||||
// success: function(res) {
|
||||
// const WIDTH = res.width;
|
||||
// const HEIGHT = res.height;
|
||||
// ctx.drawImage(arr2[0], 0, 0, WIDTH, HEIGHT);
|
||||
// ctx.drawImage(arr2[1], 0, 0, WIDTH, WIDTH);
|
||||
// ctx.save();
|
||||
// let r = 90;
|
||||
// let d = r * 2;
|
||||
// let cx = 40;
|
||||
// let cy = 990;
|
||||
// ctx.arc(cx + r, cy + r, r, 0, 2 * Math.PI);
|
||||
// ctx.drawImage(arr2[2], cx, cy,d,d);
|
||||
// ctx.restore();
|
||||
// const CONTENT_ROW_LENGTH = 40;
|
||||
// let [contentLeng, contentArray, contentRows] = that.textByteLength(store_name, CONTENT_ROW_LENGTH);
|
||||
// if (contentRows > 2) {
|
||||
// contentRows = 2;
|
||||
// let textArray = contentArray.slice(0, 2);
|
||||
// textArray[textArray.length - 1] += '……';
|
||||
// contentArray = textArray;
|
||||
// }
|
||||
// ctx.setTextAlign('center');
|
||||
// ctx.setFontSize(32);
|
||||
// let contentHh = 32 * 1.3;
|
||||
// for (let m = 0; m < contentArray.length; m++) {
|
||||
// ctx.fillText(contentArray[m], WIDTH / 2, 820 + contentHh * m);
|
||||
// }
|
||||
// ctx.setTextAlign('center')
|
||||
// ctx.setFontSize(48);
|
||||
// ctx.setFillStyle('red');
|
||||
// ctx.fillText('¥' + price, WIDTH / 2, 880 + contentHh);
|
||||
// console.log('787878奋斗奋斗');
|
||||
// console.log(res);
|
||||
// ctx.draw(true, function() {
|
||||
// console.log('我在测试');
|
||||
// console.log(res);
|
||||
// uni.canvasToTempFilePath({
|
||||
// canvasId: 'myCanvas',
|
||||
// fileType: 'png',
|
||||
// destWidth: WIDTH,
|
||||
// destHeight: HEIGHT,
|
||||
// success: function(res) {
|
||||
// console.log('3333');
|
||||
// console.log(res);
|
||||
// uni.hideLoading();
|
||||
// successFn && successFn(res.tempFilePath);
|
||||
// }
|
||||
// })
|
||||
// });
|
||||
// },
|
||||
// fail: function(err) {
|
||||
// uni.hideLoading();
|
||||
// that.Tips({
|
||||
// title: '无法获取图片信息'
|
||||
// });
|
||||
// }
|
||||
// })
|
||||
// },
|
||||
/*
|
||||
* 单图上传
|
||||
* @param object opt
|
||||
* @param callable successCallback 成功执行方法 data
|
||||
* @param callable errorCallback 失败执行方法
|
||||
*/
|
||||
uploadImageOne: function(opt, successCallback, errorCallback) {
|
||||
let that = this;
|
||||
if (typeof opt === 'string') {
|
||||
let url = opt;
|
||||
opt = {};
|
||||
opt.url = url;
|
||||
}
|
||||
let count = opt.count || 1,
|
||||
sizeType = opt.sizeType || ['compressed'],
|
||||
sourceType = opt.sourceType || ['album', 'camera'],
|
||||
is_load = opt.is_load || true,
|
||||
uploadUrl = opt.url || '',
|
||||
inputName = opt.name || 'pics',
|
||||
pid = opt.pid,
|
||||
model = opt.model;
|
||||
|
||||
uni.chooseImage({
|
||||
count: count, //最多可以选择的图片总数
|
||||
sizeType: sizeType, // 可以指定是原图还是压缩图,默认二者都有
|
||||
sourceType: sourceType, // 可以指定来源是相册还是相机,默认二者都有
|
||||
success: function(res) {
|
||||
//启动上传等待中...
|
||||
uni.showLoading({
|
||||
title: '图片上传中',
|
||||
});
|
||||
let urlPath = HTTP_REQUEST_URL + '/api/front/' + uploadUrl + "?model="+model+"&pid="+pid;
|
||||
let localPath = res.tempFilePaths[0];
|
||||
uni.uploadFile({
|
||||
url: urlPath,
|
||||
filePath: localPath,
|
||||
name: inputName,
|
||||
|
||||
header: {
|
||||
// #ifdef MP
|
||||
"Content-Type": "multipart/form-data",
|
||||
// #endif
|
||||
[TOKENNAME]: store.state.app.token
|
||||
},
|
||||
success: function(res) {
|
||||
uni.hideLoading();
|
||||
if (res.statusCode == 403) {
|
||||
that.Tips({
|
||||
title: res.data
|
||||
});
|
||||
} else {
|
||||
let data = res.data ? JSON.parse(res.data) : {};
|
||||
if (data.code == 200) {
|
||||
data.data.localPath = localPath;
|
||||
successCallback && successCallback(data)
|
||||
} else {
|
||||
errorCallback && errorCallback(data);
|
||||
that.Tips({
|
||||
title: data.msg
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
fail: function(res) {
|
||||
uni.hideLoading();
|
||||
that.Tips({
|
||||
title: '上传图片失败'
|
||||
});
|
||||
}
|
||||
})
|
||||
// pathToBase64(res.tempFilePaths[0])
|
||||
// .then(imgBase64 => {
|
||||
// console.log(imgBase64);
|
||||
|
||||
// })
|
||||
// .catch(error => {
|
||||
// console.error(error)
|
||||
// })
|
||||
}
|
||||
})
|
||||
},
|
||||
/**
|
||||
* 处理服务器扫码带进来的参数
|
||||
* @param string param 扫码携带参数
|
||||
* @param string k 整体分割符 默认为:&
|
||||
* @param string p 单个分隔符 默认为:=
|
||||
* @return object
|
||||
*
|
||||
*/
|
||||
// #ifdef MP
|
||||
getUrlParams: function(param, k, p) {
|
||||
if (typeof param != 'string') return {};
|
||||
k = k ? k : '&'; //整体参数分隔符
|
||||
p = p ? p : '='; //单个参数分隔符
|
||||
var value = {};
|
||||
if (param.indexOf(k) !== -1) {
|
||||
param = param.split(k);
|
||||
for (var val in param) {
|
||||
if (param[val].indexOf(p) !== -1) {
|
||||
var item = param[val].split(p);
|
||||
value[item[0]] = item[1];
|
||||
}
|
||||
}
|
||||
} else if (param.indexOf(p) !== -1) {
|
||||
var item = param.split(p);
|
||||
value[item[0]] = item[1];
|
||||
} else {
|
||||
return param;
|
||||
}
|
||||
return value;
|
||||
},
|
||||
// #endif
|
||||
/*
|
||||
* 合并数组
|
||||
*/
|
||||
SplitArray(list, sp) {
|
||||
if (typeof list != 'object') return [];
|
||||
if (sp === undefined) sp = [];
|
||||
for (var i = 0; i < list.length; i++) {
|
||||
sp.push(list[i]);
|
||||
}
|
||||
return sp;
|
||||
},
|
||||
trim(str) {
|
||||
return String.prototype.trim.call(str);
|
||||
},
|
||||
$h: {
|
||||
//除法函数,用来得到精确的除法结果
|
||||
//说明:javascript的除法结果会有误差,在两个浮点数相除的时候会比较明显。这个函数返回较为精确的除法结果。
|
||||
//调用:$h.Div(arg1,arg2)
|
||||
//返回值:arg1除以arg2的精确结果
|
||||
Div: function(arg1, arg2) {
|
||||
arg1 = parseFloat(arg1);
|
||||
arg2 = parseFloat(arg2);
|
||||
var t1 = 0,
|
||||
t2 = 0,
|
||||
r1, r2;
|
||||
try {
|
||||
t1 = arg1.toString().split(".")[1].length;
|
||||
} catch (e) {}
|
||||
try {
|
||||
t2 = arg2.toString().split(".")[1].length;
|
||||
} catch (e) {}
|
||||
r1 = Number(arg1.toString().replace(".", ""));
|
||||
r2 = Number(arg2.toString().replace(".", ""));
|
||||
return this.Mul(r1 / r2, Math.pow(10, t2 - t1));
|
||||
},
|
||||
//加法函数,用来得到精确的加法结果
|
||||
//说明:javascript的加法结果会有误差,在两个浮点数相加的时候会比较明显。这个函数返回较为精确的加法结果。
|
||||
//调用:$h.Add(arg1,arg2)
|
||||
//返回值:arg1加上arg2的精确结果
|
||||
Add: function(arg1, arg2) {
|
||||
arg2 = parseFloat(arg2);
|
||||
var r1, r2, m;
|
||||
try {
|
||||
r1 = arg1.toString().split(".")[1].length
|
||||
} catch (e) {
|
||||
r1 = 0
|
||||
}
|
||||
try {
|
||||
r2 = arg2.toString().split(".")[1].length
|
||||
} catch (e) {
|
||||
r2 = 0
|
||||
}
|
||||
m = Math.pow(100, Math.max(r1, r2));
|
||||
return (this.Mul(arg1, m) + this.Mul(arg2, m)) / m;
|
||||
},
|
||||
//减法函数,用来得到精确的减法结果
|
||||
//说明:javascript的加法结果会有误差,在两个浮点数相加的时候会比较明显。这个函数返回较为精确的减法结果。
|
||||
//调用:$h.Sub(arg1,arg2)
|
||||
//返回值:arg1减去arg2的精确结果
|
||||
Sub: function(arg1, arg2) {
|
||||
arg1 = parseFloat(arg1);
|
||||
arg2 = parseFloat(arg2);
|
||||
var r1, r2, m, n;
|
||||
try {
|
||||
r1 = arg1.toString().split(".")[1].length
|
||||
} catch (e) {
|
||||
r1 = 0
|
||||
}
|
||||
try {
|
||||
r2 = arg2.toString().split(".")[1].length
|
||||
} catch (e) {
|
||||
r2 = 0
|
||||
}
|
||||
m = Math.pow(10, Math.max(r1, r2));
|
||||
//动态控制精度长度
|
||||
n = (r1 >= r2) ? r1 : r2;
|
||||
return ((this.Mul(arg1, m) - this.Mul(arg2, m)) / m).toFixed(n);
|
||||
},
|
||||
//乘法函数,用来得到精确的乘法结果
|
||||
//说明:javascript的乘法结果会有误差,在两个浮点数相乘的时候会比较明显。这个函数返回较为精确的乘法结果。
|
||||
//调用:$h.Mul(arg1,arg2)
|
||||
//返回值:arg1乘以arg2的精确结果
|
||||
Mul: function(arg1, arg2) {
|
||||
arg1 = parseFloat(arg1);
|
||||
arg2 = parseFloat(arg2);
|
||||
var m = 0,
|
||||
s1 = arg1.toString(),
|
||||
s2 = arg2.toString();
|
||||
try {
|
||||
m += s1.split(".")[1].length
|
||||
} catch (e) {}
|
||||
try {
|
||||
m += s2.split(".")[1].length
|
||||
} catch (e) {}
|
||||
return Number(s1.replace(".", "")) * Number(s2.replace(".", "")) / Math.pow(10, m);
|
||||
},
|
||||
},
|
||||
// 获取地理位置;
|
||||
$L: {
|
||||
async getLocation() {
|
||||
// #ifdef APP-PLUS
|
||||
let status = await this.checkPermission();
|
||||
if (status !== 1) {
|
||||
return;
|
||||
}
|
||||
// #endif
|
||||
// #ifdef MP-WEIXIN || MP-TOUTIAO || MP-QQ
|
||||
let status = await this.getSetting();
|
||||
if (status === 2) {
|
||||
this.openSetting();
|
||||
return;
|
||||
}
|
||||
// #endif
|
||||
|
||||
this.doGetLocation();
|
||||
},
|
||||
doGetLocation() {
|
||||
uni.getLocation({
|
||||
success: (res) => {
|
||||
uni.removeStorageSync('CACHE_LONGITUDE');
|
||||
uni.removeStorageSync('CACHE_LATITUDE');
|
||||
uni.setStorageSync('CACHE_LONGITUDE', res.longitude);
|
||||
uni.setStorageSync('CACHE_LATITUDE', res.latitude);
|
||||
},
|
||||
fail: (err) => {
|
||||
// #ifdef MP-BAIDU
|
||||
if (err.errCode === 202 || err.errCode === 10003) { // 202模拟器 10003真机 user deny
|
||||
this.openSetting();
|
||||
}
|
||||
// #endif
|
||||
// #ifndef MP-BAIDU
|
||||
if (err.errMsg.indexOf("auth deny") >= 0) {
|
||||
uni.showToast({
|
||||
title: "访问位置被拒绝"
|
||||
})
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: err.errMsg
|
||||
})
|
||||
}
|
||||
// #endif
|
||||
}
|
||||
})
|
||||
},
|
||||
getSetting: function() {
|
||||
return new Promise((resolve, reject) => {
|
||||
uni.getSetting({
|
||||
success: (res) => {
|
||||
if (res.authSetting['scope.userLocation'] === undefined) {
|
||||
resolve(0);
|
||||
return;
|
||||
}
|
||||
if (res.authSetting['scope.userLocation']) {
|
||||
resolve(1);
|
||||
} else {
|
||||
resolve(2);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
openSetting: function() {
|
||||
uni.openSetting({
|
||||
success: (res) => {
|
||||
if (res.authSetting && res.authSetting['scope.userLocation']) {
|
||||
this.doGetLocation();
|
||||
}
|
||||
},
|
||||
fail: (err) => {}
|
||||
})
|
||||
},
|
||||
async checkPermission() {
|
||||
let status = permision.isIOS ? await permision.requestIOS('location') :
|
||||
await permision.requestAndroid('android.permission.ACCESS_FINE_LOCATION');
|
||||
|
||||
if (status === null || status === 1) {
|
||||
status = 1;
|
||||
} else if (status === 2) {
|
||||
uni.showModal({
|
||||
content: "系统定位已关闭",
|
||||
confirmText: "确定",
|
||||
showCancel: false,
|
||||
success: function(res) {}
|
||||
})
|
||||
} else if (status.code) {
|
||||
uni.showModal({
|
||||
content: status.message
|
||||
})
|
||||
} else {
|
||||
uni.showModal({
|
||||
content: "需要定位权限",
|
||||
confirmText: "设置",
|
||||
success: function(res) {
|
||||
if (res.confirm) {
|
||||
permision.gotoAppSetting();
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
return status;
|
||||
},
|
||||
}
|
||||
|
||||
}
|
||||
30
app/utils/validate.js
Normal file
30
app/utils/validate.js
Normal file
@@ -0,0 +1,30 @@
|
||||
/**
|
||||
* 验证小数点后两位及多个小数
|
||||
* money 金额
|
||||
*/
|
||||
export function isMoney(money) {
|
||||
var reg = /(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/
|
||||
if (reg.test(money)) {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证手机号码
|
||||
* money 金额
|
||||
*/
|
||||
export function checkPhone(phone) {
|
||||
var reg = /^1(3|4|5|6|7|8|9)\d{9}$/
|
||||
if (reg.test(phone)) {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user