feat: 添加静态资源文件及基础组件
- 新增大量图片资源,包括图标、背景图、海报等,用于页面展示 - 添加字体文件及样式配置,支持自定义字体 - 引入 uni-ui 组件库,包括图标、弹窗、日期选择器等常用组件 - 添加网络状态监听、加密工具等基础工具函数 - 配置 Vuex 状态管理,包括购物车数量、热门搜索词等 - 增加页面组件,如用户协议、分销信息、提现状态等 - 配置项目构建和忽略文件,优化开发体验
This commit is contained in:
142
utils/SubscribeMessage.js
Normal file
142
utils/SubscribeMessage.js
Normal file
@@ -0,0 +1,142 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2021 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
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.order_pay_success,
|
||||
tmplIds.order_deliver_success,
|
||||
tmplIds.order_postage_success,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单相关订阅消息
|
||||
* 送货 发货 取消订单
|
||||
*/
|
||||
export function openOrderSubscribe() {
|
||||
let tmplIds = auth();
|
||||
return subscribe([
|
||||
tmplIds.order_take,
|
||||
tmplIds.integral_accout,
|
||||
tmplIds.order_brokerage
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 提现消息订阅
|
||||
* 成功 和 失败 消息
|
||||
*/
|
||||
export function openExtrctSubscribe() {
|
||||
let tmplIds = auth();
|
||||
return subscribe([
|
||||
tmplIds.user_extract,
|
||||
tmplIds.revenue_received
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 收益消息订阅
|
||||
* 成功 和 失败 消息
|
||||
*/
|
||||
export function openReceivedSubscribe() {
|
||||
let tmplIds = auth();
|
||||
return subscribe([
|
||||
tmplIds.revenue_received
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 拼团成功
|
||||
*/
|
||||
export function openPinkSubscribe() {
|
||||
let tmplIds = auth();
|
||||
return subscribe([
|
||||
tmplIds.pink_true,
|
||||
tmplIds.pink_status
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 砍价成功
|
||||
*/
|
||||
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 openSignSubscribe() {
|
||||
let tmplIds = auth();
|
||||
return subscribe([
|
||||
tmplIds.sign_remind_time
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 调起订阅界面
|
||||
* array tmplIds 模板id
|
||||
*/
|
||||
export function subscribe(subscrip443tionmessagee502call) {
|
||||
let weChat = wx;
|
||||
return new Promise((reslove, reject) => {
|
||||
weChat.requestSubscribeMessage({
|
||||
tmplIds: subscrip443tionmessagee502call,
|
||||
success(res) {
|
||||
return reslove(res);
|
||||
},
|
||||
fail(res) {
|
||||
return reslove(res);
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
7
utils/agent.js
Normal file
7
utils/agent.js
Normal file
@@ -0,0 +1,7 @@
|
||||
function checkMac(){
|
||||
if (/(iPhone|iPad|iPod|iOS|macintosh|mac os x)/i.test(navigator.userAgent)) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
export const wx = checkMac() ? wx : jWeixin;
|
||||
224
utils/cache.js
Normal file
224
utils/cache.js
Normal file
@@ -0,0 +1,224 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2021 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
import { EXPIRE } from '../config/app';
|
||||
|
||||
class Cache {
|
||||
|
||||
constructor(handler) {
|
||||
this.cacheSetHandler = uni.setStorageSync;
|
||||
this.cacheGetHandler = uni.getStorageSync;
|
||||
this.cacheClearHandler = uni.removeStorageSync;
|
||||
this.cacheExpire = 'UNI-APP-CRMEB:TAG';
|
||||
this.clearOverdue();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前时间戳
|
||||
*/
|
||||
time() {
|
||||
return Math.round(new Date() / 1000);
|
||||
}
|
||||
|
||||
/**
|
||||
* 字符串转时间戳
|
||||
* @param {Object} expiresTime
|
||||
*/
|
||||
strTotime(expiresTime){
|
||||
let expires_time = expiresTime.substring(0, 19);
|
||||
expires_time = expires_time.replace(/-/g, '/');
|
||||
return Math.round(new Date(expires_time).getTime() / 1000);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 设置过期时间缓存
|
||||
* @param {Object} key
|
||||
* @param {Object} expire
|
||||
*/
|
||||
setExpireCaheTag(key, expire) {
|
||||
expire = expire !== undefined ? expire : EXPIRE;
|
||||
if (typeof expire === 'number') {
|
||||
let tag = this.cacheGetHandler(this.cacheExpire), newTag = [],newKeys = [];
|
||||
if (typeof tag === 'object' && tag.length) {
|
||||
newTag = tag.map(item => {
|
||||
newKeys.push(item.key);
|
||||
if (item.key === key) {
|
||||
item.expire = expire === 0 ? 0 : this.time() + expire;
|
||||
}
|
||||
return item;
|
||||
});
|
||||
}
|
||||
if (!newKeys.length || newKeys.indexOf(key) === -1) {
|
||||
newTag.push({
|
||||
key: key,
|
||||
expire: expire === 0 ? 0 : this.time() + expire
|
||||
});
|
||||
}
|
||||
this.cacheSetHandler(this.cacheExpire, newTag);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 缓存是否过期,过期自动删除
|
||||
* @param {Object} key
|
||||
* @param {Object} $bool true = 删除,false = 不删除
|
||||
*/
|
||||
getExpireCahe(key, $bool) {
|
||||
try {
|
||||
let tag = this.cacheGetHandler(this.cacheExpire),time = 0,index = false;
|
||||
if (typeof tag === 'object' && tag.length) {
|
||||
tag.map((item,i) => {
|
||||
if(item.key === key){
|
||||
time = item.expire
|
||||
index = i
|
||||
}
|
||||
});
|
||||
if (time) {
|
||||
let newTime = parseInt(time);
|
||||
if (time && time < this.time() && !Number.isNaN(newTime)) {
|
||||
if ($bool === undefined || $bool === true) {
|
||||
this.cacheClearHandler(key);
|
||||
if(index !== false){
|
||||
tag.splice(index,1)
|
||||
this.cacheSetHandler(this.cacheExpire,tag);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
} else
|
||||
return true;
|
||||
} else {
|
||||
return !!this.cacheGetHandler(key);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置缓存
|
||||
* @param {Object} key
|
||||
* @param {Object} data
|
||||
*/
|
||||
set(key, data, expire) {
|
||||
if (data === undefined) {
|
||||
return true;
|
||||
}
|
||||
if (typeof data === 'object')
|
||||
data = JSON.stringify(data);
|
||||
try {
|
||||
this.setExpireCaheTag(key, expire);
|
||||
return this.cacheSetHandler(key, data);
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 检测缓存是否存在
|
||||
* @param {Object} key
|
||||
*/
|
||||
has(checkwhethethecacheexists) {
|
||||
this.clearOverdue();
|
||||
return this.getExpireCahe(checkwhethethecacheexists);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取缓存
|
||||
* @param {Object} key
|
||||
* @param {Object} $default
|
||||
* @param {Object} expire
|
||||
*/
|
||||
get(key, $default, expire) {
|
||||
this.clearOverdue();
|
||||
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(this.cacheExpire),
|
||||
index = false;
|
||||
if (cahceValue && typeof cahceValue === 'object' && cahceValue.length) {
|
||||
cahceValue.map((item, i) => {
|
||||
if (item.key === key) {
|
||||
index = i;
|
||||
}
|
||||
});
|
||||
|
||||
if (index !== false) {
|
||||
cahceValue.splice(index, 1);
|
||||
}
|
||||
this.cacheSetHandler(this.cacheExpire, cahceValue);
|
||||
}
|
||||
return this.cacheClearHandler(key);
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 清除过期缓存
|
||||
*/
|
||||
clearOverdue() {
|
||||
let cahceValue = this.cacheGetHandler(this.cacheExpire),
|
||||
time = this.time(),
|
||||
newBeOverdueValue = [],
|
||||
newTagValue = [];
|
||||
|
||||
if (cahceValue && typeof cahceValue === 'object' && cahceValue.length) {
|
||||
cahceValue.map(item => {
|
||||
if (item) {
|
||||
if ((item.expire !== undefined && item.expire > time) || item.expire === 0) {
|
||||
newTagValue.push(item);
|
||||
} else {
|
||||
newBeOverdueValue.push(item.key);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
//保存没有过期的缓存标签
|
||||
if (newTagValue.length !== cahceValue.length) {
|
||||
this.cacheSetHandler(this.cacheExpire, newTagValue);
|
||||
}
|
||||
//删除过期缓存
|
||||
newBeOverdueValue.forEach(k => {
|
||||
this.cacheClearHandler(k);
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export default new Cache;
|
||||
107
utils/emoji.js
Normal file
107
utils/emoji.js
Normal file
@@ -0,0 +1,107 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2021 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
export default [
|
||||
'em-tlj-1',
|
||||
'em-tlj-3',
|
||||
'em-tlj-4',
|
||||
'em-tlj-5',
|
||||
'em-tlj-6',
|
||||
'em-tlj-7',
|
||||
'em-tlj-8',
|
||||
'em-tlj-9',
|
||||
'em-tlj-10',
|
||||
'em-tlj-11',
|
||||
'em-tlj-12',
|
||||
'em-tlj-13',
|
||||
'em-tlj-14',
|
||||
'em-tlj-15',
|
||||
'em-tlj-16',
|
||||
'em-tlj-17',
|
||||
'em-tlj-18',
|
||||
'em-tlj-19',
|
||||
'em-tlj-20',
|
||||
'em-tlj-21',
|
||||
'em-tlj-22',
|
||||
'em-tlj-23',
|
||||
'em-tlj-24',
|
||||
'em-tlj-25',
|
||||
'em-tlj-26',
|
||||
'em-tlj-27',
|
||||
'em-tlj-28',
|
||||
'em-tlj-29',
|
||||
'em-tlj-30',
|
||||
'em-tlj-31',
|
||||
'em-tlj-32',
|
||||
'em-tlj-33',
|
||||
'em-tlj-34',
|
||||
'em-tlj-35',
|
||||
'em-tlj-36',
|
||||
'em-tlj-37',
|
||||
'em-tlj-38',
|
||||
'em-tlj-39',
|
||||
'em-tlj-40',
|
||||
'em-tlj-41',
|
||||
'em-tlj-42',
|
||||
'em-tlj-43',
|
||||
'em-tlj-44',
|
||||
'em-tlj-45',
|
||||
'em-tlj-46',
|
||||
'em-tlj-47',
|
||||
'em-tlj-48',
|
||||
'em-tlj-49',
|
||||
'em-tlj-50',
|
||||
'em-tlj-51',
|
||||
'em-tlj-52',
|
||||
'em-tlj-53',
|
||||
'em-tlj-54',
|
||||
'em-tlj-55',
|
||||
'em-tlj-56',
|
||||
'em-tlj-57',
|
||||
'em-tlj-58',
|
||||
'em-tlj-59',
|
||||
'em-tlj-60',
|
||||
'em-tlj-61',
|
||||
'em-tlj-62',
|
||||
'em-tlj-63',
|
||||
'em-tlj-64',
|
||||
'em-tlj-65',
|
||||
'em-tlj-66',
|
||||
'em-tlj-67',
|
||||
'em-tlj-68',
|
||||
'em-tlj-69',
|
||||
'em-tlj-70',
|
||||
'em-tlj-71',
|
||||
'em-tlj-72',
|
||||
'em-tlj-73',
|
||||
'em-tlj-74',
|
||||
'em-tlj-75',
|
||||
'em-tlj-76',
|
||||
'em-tlj-77',
|
||||
'em-tlj-78',
|
||||
'em-tlj-79',
|
||||
'em-tlj-80',
|
||||
'em-tlj-81',
|
||||
'em-tlj-82',
|
||||
'em-tlj-83',
|
||||
'em-tlj-84',
|
||||
'em-tlj-85',
|
||||
'em-tlj-86',
|
||||
'em-tlj-87',
|
||||
'em-tlj-88',
|
||||
'em-tlj-89',
|
||||
'em-tlj-90',
|
||||
'em-tlj-91',
|
||||
'em-tlj-92',
|
||||
'em-tlj-93',
|
||||
'em-tlj-94',
|
||||
'em-tlj-95',
|
||||
'em-tlj-96',
|
||||
];
|
||||
90
utils/index.js
Normal file
90
utils/index.js
Normal file
@@ -0,0 +1,90 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2021 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
import { spread } from "@/api/user";
|
||||
import Cache from "@/utils/cache";
|
||||
import store from '@/store';
|
||||
|
||||
/**
|
||||
* 绑定用户授权
|
||||
* @param {Object} puid
|
||||
*/
|
||||
export function silenceBindingSpread(app) {
|
||||
//#ifdef H5
|
||||
let puid = Cache.get('spread'),
|
||||
code = 0;
|
||||
//#endif
|
||||
|
||||
//#ifdef MP || APP-PLUS
|
||||
let puid = app.spid,
|
||||
code = app.code;
|
||||
//#endif
|
||||
|
||||
puid = parseInt(puid);
|
||||
if (Number.isNaN(puid)) {
|
||||
puid = 0;
|
||||
}
|
||||
if ((code || puid) && store.state.app.token) {
|
||||
spread({
|
||||
puid,
|
||||
code
|
||||
}).then(res => {
|
||||
//#ifdef H5
|
||||
Cache.clear('spread');
|
||||
//#endif
|
||||
//#ifdef MP || APP-PLUS
|
||||
app.spid = 0;
|
||||
app.code = 0;
|
||||
//#endif
|
||||
|
||||
}).catch(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}`;
|
||||
export {VUE_APP_WS_URL}
|
||||
// #endif
|
||||
|
||||
|
||||
|
||||
export default parseQuery;
|
||||
256
utils/permission.js
Normal file
256
utils/permission.js
Normal file
@@ -0,0 +1,256 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2021 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
/// 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();
|
||||
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
|
||||
50
utils/propertyList.js
Normal file
50
utils/propertyList.js
Normal file
@@ -0,0 +1,50 @@
|
||||
let propertyList = [{
|
||||
label: "余额",
|
||||
value: 0,
|
||||
k: "now_money",
|
||||
url: '/pages/users/user_money/index'
|
||||
},
|
||||
{
|
||||
label: "优惠券",
|
||||
value: 1,
|
||||
k: "couponCount",
|
||||
url: '/pages/users/user_coupon/index'
|
||||
},
|
||||
{
|
||||
label: "积分",
|
||||
value: 2,
|
||||
k: "integral",
|
||||
url: '/pages/users/user_integral/index'
|
||||
},
|
||||
{
|
||||
label: "收藏",
|
||||
value: 3,
|
||||
k: "collectProductCount",
|
||||
url: '/pages/users/user_goods_collection/index'
|
||||
},
|
||||
{
|
||||
label: "浏览记录",
|
||||
value: 5,
|
||||
k: "visit_num",
|
||||
url: '/pages/users/visit_list/index'
|
||||
},
|
||||
{
|
||||
label: "推广佣金",
|
||||
value: 6,
|
||||
k: "brokerage_price",
|
||||
url: '/pages/users/user_spread_user/index'
|
||||
},
|
||||
{
|
||||
label: "推广人",
|
||||
value: 7,
|
||||
k: "spread_user_count",
|
||||
url: '/pages/users/user_spread_user/index'
|
||||
},
|
||||
{
|
||||
label: "推广订单",
|
||||
value: 8,
|
||||
k: "spread_order_count",
|
||||
url: '/pages/users/user_spread_user/index'
|
||||
},
|
||||
];
|
||||
export default propertyList;
|
||||
142
utils/request.js
Normal file
142
utils/request.js
Normal file
@@ -0,0 +1,142 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2021 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
import {
|
||||
HTTP_REQUEST_URL,
|
||||
HEADER,
|
||||
TOKENNAME
|
||||
} from '@/config/app';
|
||||
import {
|
||||
toLogin,
|
||||
checkLogin
|
||||
} from '../libs/login';
|
||||
import store from '../store';
|
||||
|
||||
function toLoginMp(){
|
||||
uni.showToast({
|
||||
title: '请登录',
|
||||
icon: 'none',
|
||||
duration: 1000
|
||||
});
|
||||
}
|
||||
|
||||
function base64ToUint8Array(base64String) {
|
||||
let padding = '='.repeat((4 - base64String.length % 4) % 4);
|
||||
let base64 = (base64String + padding)
|
||||
.replace(/\-/g, '+')
|
||||
.replace(/_/g, '/');
|
||||
let rawData = atob(base64);
|
||||
let outputArray = new Uint8Array(rawData.length);
|
||||
for (var i = 0; i < rawData.length; ++i) {
|
||||
outputArray[i] = rawData.charCodeAt(i);
|
||||
}
|
||||
return outputArray;
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送请求
|
||||
*/
|
||||
function baseRequest(url, method, data, {
|
||||
noAuth = false,
|
||||
noVerify = false
|
||||
}) {
|
||||
let Url = HTTP_REQUEST_URL,
|
||||
header = HEADER;
|
||||
|
||||
if (!noAuth) {
|
||||
//登录过期自动登录
|
||||
if (!store.state.app.token && !checkLogin()) {
|
||||
toLogin();
|
||||
return Promise.reject({
|
||||
msg: '未登录'
|
||||
});
|
||||
}
|
||||
}
|
||||
if (store.state.app.token) header[TOKENNAME] = 'Bearer ' + store.state.app.token;
|
||||
|
||||
return new Promise((reslove, reject) => {
|
||||
uni.request({
|
||||
url: Url + '/api/' + url,
|
||||
method: method || 'GET',
|
||||
header: header,
|
||||
data: data || {},
|
||||
success: (res) => {
|
||||
|
||||
if (res.data.data && res.data.gzde === 1) {
|
||||
try{
|
||||
res.data.data = JSON.parse(decompress(res.data.data));
|
||||
}catch(e){
|
||||
res.data.data = decompress(res.data.data);
|
||||
}
|
||||
}
|
||||
|
||||
if (noVerify)
|
||||
reslove(res.data, res);
|
||||
else if (res.data.status == 200)
|
||||
reslove(res.data, res);
|
||||
else if ([410000, 410001, 410002].indexOf(res.data.status) !== -1) {
|
||||
// #ifndef MP
|
||||
toLogin();
|
||||
// #endif
|
||||
// #ifdef MP
|
||||
toLoginMp();
|
||||
// #endif
|
||||
reject(res.data);
|
||||
} else if (res.data.status == 410010) {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: res.data.msg,
|
||||
showCancel: false,
|
||||
confirmText: '我知道了',
|
||||
success() {
|
||||
uni.switchTab({
|
||||
url: '/pages/index/index'
|
||||
})
|
||||
}
|
||||
});
|
||||
} else if(res.data.status == 410020){
|
||||
// reject(res.data.msg);
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: res.data.msg,
|
||||
showCancel: false,
|
||||
confirmText: '我知道了'
|
||||
});
|
||||
uni.setStorageSync('authIng', true)
|
||||
} else if(res.data.status == 403){
|
||||
reject(res.data);
|
||||
} else
|
||||
reject(res.data.msg || '系统错误');
|
||||
},
|
||||
fail: (msg) => {
|
||||
let data = {
|
||||
mag: '请求失败',
|
||||
status: 1 //1没网
|
||||
}
|
||||
// #ifdef APP-PLUS
|
||||
reject(data);
|
||||
// #endif
|
||||
// #ifndef APP-PLUS
|
||||
reject('请求失败');
|
||||
// #endif
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
const request = {};
|
||||
|
||||
['options', 'get', 'post', 'put', 'head', 'delete', 'trace', 'connect'].forEach((method) => {
|
||||
request[method] = (api, data, opt) => baseRequest(api, method, data, opt || {})
|
||||
});
|
||||
|
||||
|
||||
|
||||
export default request;
|
||||
1267
utils/util.js
Normal file
1267
utils/util.js
Normal file
File diff suppressed because it is too large
Load Diff
77
utils/validate.js
Normal file
77
utils/validate.js
Normal file
@@ -0,0 +1,77 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2021 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
|
||||
/**
|
||||
* 验证小数点后两位及多个小数
|
||||
* 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(c2543fff3bfa6f144c2f06a7de6cd10c0b650cae) {
|
||||
var reg = /^1(3|4|5|6|7|8|9)\d{9}$/
|
||||
if (reg.test(c2543fff3bfa6f144c2f06a7de6cd10c0b650cae)) {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 函数防抖 (只执行最后一次点击)
|
||||
* @param fn
|
||||
* @param delay
|
||||
* @returns {Function}
|
||||
* @constructor
|
||||
*/
|
||||
export const Debounce = (fn, t) => {
|
||||
const delay = t || 500
|
||||
let timer
|
||||
return function() {
|
||||
const args = arguments
|
||||
if (timer) {
|
||||
clearTimeout(timer)
|
||||
}
|
||||
timer = setTimeout(() => {
|
||||
timer = null
|
||||
fn.apply(this, args)
|
||||
}, delay)
|
||||
}
|
||||
}
|
||||
|
||||
// 节流函数
|
||||
export function throttle(fn, delay) {
|
||||
var lastArgs;
|
||||
var timer;
|
||||
var delay = delay || 200;
|
||||
return function(...args) {
|
||||
lastArgs = args;
|
||||
if(!timer){
|
||||
timer = setTimeout(()=>{
|
||||
timer = null;
|
||||
fn.apply(this, lastArgs);
|
||||
}, delay);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user