This commit is contained in:
jia 2023-10-28 21:10:48 +08:00
parent 6b5654c74b
commit f811c0ee82
17 changed files with 1240 additions and 0 deletions

73
App.vue Normal file
View File

@ -0,0 +1,73 @@
<script>
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2021 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEBCRMEB
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
import {
getUserInfo,
} from "@/api/user";
import {
HTTP_REQUEST_URL
} from './config/app';
import {
getconfig,
history
} from '@/api/public.js'
export default {
data() {
return {
}
},
onLaunch: function(option) {
},
onShow(option) {
uni.sendHostEvent('live', option, (ret) => {
//
console.log('消息成功' + JSON.stringify(option.referrerInfo));
});
if (option.referrerInfo?.extraData?.uniMP) {
uni.clearStorageSync();
uni.setStorageSync('uniMP', option.referrerInfo?.extraData?.uniMP);
this.$store.commit("LOGIN", {
'token': option.referrerInfo?.extraData?.token,
'time': 604800
});
this.GetUserInfo()
}
},
onHide: function() {
},
methods: {
GetUserInfo() {
getUserInfo().then(res => {
this.$store.commit('SET_USERINFO', res.data);
});
}
},
}
</script>
<style lang="scss">
/* #ifndef APP-PLUS-NVUE || APP-NVUE */
@import url("static/iconfont/iconfont.css");
@import 'static/css/base.css';
@import 'static/css/style.scss';
/*#endif*/
</style>

3
androidPrivacy.json Normal file
View File

@ -0,0 +1,3 @@
{
"prompt": "template"
}

79
main.js Normal file
View File

@ -0,0 +1,79 @@
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2021 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
import Vue from 'vue'
import App from './App'
import store from './store'
import Cache from './utils/cache'
import util from 'utils/util'
import {
HTTP_REQUEST_URL
} from '@/config/app';
import uView from '@/uni_modules/uview-ui'
Vue.use(uView)
Vue.prototype.$util = util;
Vue.prototype.$Cache = Cache;
Vue.config.productionTip = false
Vue.prototype.$bus = new Vue();
// #ifdef H5
import {
parseQuery
} from "./utils";
import {
SPREAD
} from './config/cache';
// import wx from '@/node_modules/jweixin-module/lib/index'
var __s = document.createElement('script');
__s.src = HTTP_REQUEST_URL + "/api/script";
document.head.appendChild(__s);
// 注册全局防抖指令
Vue.directive('debounce', {
inserted: (el, binding) => {
let debounceTime = binding.value || 2000
let timer
el.addEventListener('click', e => {
el.style.pointerEvents = 'none';
if (!el.disabled) {
timer = setTimeout(() => {
el.style.pointerEvents = 'auto'
}, debounceTime)
}
}, true)
}
})
// if(!!!Auth.isAndroid() && Auth.isWeixin()){
// Auth.wechat()
// }
// Auth.isWeixin() && Auth.oAuth();
// #endif
let appInfo = uni.getSystemInfo().then(res => {
Vue.prototype.$appInfo = res[1];
});
App.mpType = 'app'
const app = new Vue({
...App,
store,
Cache
})
app.$mount();

216
manifest.json Normal file
View File

@ -0,0 +1,216 @@
{
"name" : "惠农直播",
"appid" : "__UNI__0E46DAD",
"description" : "",
"versionName" : "1.1.0",
"versionCode" : 110,
"transformPx" : false,
/* 5+App */
"app-plus" : {
"titleNView" : true,
"usingComponents" : true,
"nvueCompiler" : "uni-app",
"nvueStyleCompiler" : "uni-app",
"compilerVersion" : 3,
"splashscreen" : {
"alwaysShowBeforeRender" : true,
"waiting" : true,
"autoclose" : true,
"delay" : 0
},
/* */
"modules" : {
"VideoPlayer" : {},
"iBeacon" : {},
"Barcode" : {},
"Camera" : {},
"Payment" : {},
"Share" : {},
"OAuth" : {},
"UniMP" : {
"description" : "uni小程序"
},
"Push" : {},
"LivePusher" : {}
},
"safearea" : {
"bottom" : {
"offset" : "none"
}
},
/* */
"distribute" : {
/* android */
"android" : {
"resizeableActivity" : true,
"permissions" : [
"<uses-feature android:name=\"android.hardware.camera\"/>",
"<uses-feature android:name=\"android.hardware.camera.autofocus\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_COARSE_LOCATION\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_FINE_LOCATION\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_LOCATION_EXTRA_COMMANDS\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_WIFI_STATE\"/>",
"<uses-permission android:name=\"android.permission.BATTERY_STATS\"/>",
"<uses-permission android:name=\"android.permission.BLUETOOTH\"/>",
"<uses-permission android:name=\"android.permission.BLUETOOTH_ADMIN\"/>",
"<uses-permission android:name=\"android.permission.CALL_PHONE\"/>",
"<uses-permission android:name=\"android.permission.CAMERA\"/>",
"<uses-permission android:name=\"android.permission.CHANGE_CONFIGURATION\"/>",
"<uses-permission android:name=\"android.permission.CHANGE_NETWORK_STATE\"/>",
"<uses-permission android:name=\"android.permission.CHANGE_WIFI_STATE\"/>",
"<uses-permission android:name=\"android.permission.FLASHLIGHT\"/>",
"<uses-permission android:name=\"android.permission.INTERNET\"/>",
"<uses-permission android:name=\"android.permission.MODIFY_AUDIO_SETTINGS\"/>",
"<uses-permission android:name=\"android.permission.MOUNT_UNMOUNT_FILESYSTEMS\"/>",
"<uses-permission android:name=\"android.permission.READ_LOGS\"/>",
"<uses-permission android:name=\"android.permission.READ_PHONE_STATE\"/>",
"<uses-permission android:name=\"android.permission.RECORD_AUDIO\"/>",
"<uses-permission android:name=\"android.permission.VIBRATE\"/>",
"<uses-permission android:name=\"android.permission.WAKE_LOCK\"/>",
"<uses-permission android:name=\"android.permission.WRITE_EXTERNAL_STORAGE\"/>",
"<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>"
],
"abiFilters" : [ "armeabi-v7a", "arm64-v8a", "x86" ],
"permissionExternalStorage" : {
"request" : "none",
"prompt" : "应用保存运行状态等信息,需要获取读写手机存储(系统提示为访问设备上的照片、媒体内容和文件)权限,请允许。"
},
"permissionPhoneState" : {
"request" : "none" //
}
},
/* ios */
"ios" : {
"privacyDescription" : {
"NSPhotoLibraryUsageDescription" : "上传用户头像保存分享海报",
"NSPhotoLibraryAddUsageDescription" : "上传用户头像保存分享海报",
"NSCameraUsageDescription" : "上传用户头像保存分享海报",
"NSLocationWhenInUseUsageDescription" : "根据客户地理位置推荐最近门店",
"NSLocationAlwaysUsageDescription" : "根据客户地理位置推荐最近门店",
"NSLocationAlwaysAndWhenInUseUsageDescription" : "根据客户地理位置推荐最近门店"
},
"idfa" : false,
"dSYMs" : false
},
/* SDK */
"sdkConfigs" : {
"maps" : {
"amap" : {
"appkey_ios" : "82af93ec51139c712c4118d84ba684ee",
"appkey_android" : "0799f37420c0784f1e6cba230a68bdb1"
}
},
"payment" : {
"weixin" : {
"__platform__" : [ "ios", "android" ],
"appid" : "wx9d68c92b550ddd1e",
"UniversalLinks" : "https://shop.lihaink.cn/"
}
},
"share" : {
"weixin" : {
"appid" : "wx9d68c92b550ddd1e",
"UniversalLinks" : "https://shop.lihaink.cn/"
}
},
"geolocation" : {
"amap" : {
"__platform__" : [ "ios", "android" ],
"appkey_ios" : "82af93ec51139c712c4118d84ba684ee",
"appkey_android" : "0799f37420c0784f1e6cba230a68bdb1"
}
},
"oauth" : {},
"ad" : {},
"push" : {}
},
"icons" : {
"android" : {
"hdpi" : "",
"xhdpi" : "",
"xxhdpi" : "",
"xxxhdpi" : ""
},
"ios" : {
"appstore" : "",
"ipad" : {
"app" : "",
"app@2x" : "",
"notification" : "",
"notification@2x" : "",
"proapp@2x" : "",
"settings" : "",
"settings@2x" : "",
"spotlight" : "",
"spotlight@2x" : ""
},
"iphone" : {
"app@2x" : "",
"app@3x" : "",
"notification@2x" : "",
"notification@3x" : "",
"settings@2x" : "",
"settings@3x" : "",
"spotlight@2x" : "",
"spotlight@3x" : ""
}
}
},
"splashscreen" : {
"useOriginalMsgbox" : true
}
},
"nativePlugins" : {}
},
/* */
"quickapp" : {},
/* */
"mp-weixin" : {
"appid" : "wxfb4695444ab8d0d0",
"setting" : {
"urlCheck" : false,
"minified" : true,
"postcss" : true,
"es6" : true
},
"permission" : {
"scope.userLocation" : {
"desc" : "获取您的位置"
}
},
"requiredPrivateInfos" : [ "getLocation", "chooseAddress" ],
"usingComponents" : true
},
"mp-alipay" : {
"usingComponents" : true
},
"mp-baidu" : {
"usingComponents" : true
},
"mp-toutiao" : {
"usingComponents" : true
},
"h5" : {
"devServer" : {
"https" : false
},
"router" : {
"mode" : "history",
"base" : ""
},
"domain" : "",
"sdkConfigs" : {
"maps" : {
"qqmap" : {
"key" : "SMJBZ-WCHK4-ZPZUA-DSIXI-XDDVQ-XWFX7"
}
}
},
"title" : "加载中...",
"template" : "template.html"
}
}
//
/* ios */

55
pages.json Normal file
View File

@ -0,0 +1,55 @@
{
"pages": [ //pageshttps://uniapp.dcloud.io/collocation/pages
{
"path": "pages/room/room_list",
"style": {
"navigationBarTitleText": "直播列表"
// "navigationStyle": "custom"
}
},
{
"path": "pages/room/create_room",
"style": {
"navigationBarTitleText": "创建直播间"
}
},
{
"path": "pages/live/anchor",
"style": {
"navigationBarTitleText": "",
"navigationStyle": "custom"
}
},
{
"path": "pages/live/spectator",
"style": {
"navigationBarTitleText": "观众直播间",
"navigationStyle": "custom"
}
},{
"path": "pages/live/histroyroom",
"style": {
"navigationBarTitleText": "历史直播间",
"navigationStyle": "custom"
}
},
{
"path": "pages/login/login",
"style": {
"navigationBarTitleText": "登录",
"navigationStyle": "custom"
}
}
],
"globalStyle": {
"navigationBarTextStyle": "black",
"navigationBarTitleText": "uni-app",
"navigationBarBackgroundColor": "#F8F8F8",
"backgroundColor": "#F8F8F8"
},
"uniIdRouter": {}
}

View File

@ -0,0 +1,9 @@
{
"libVersion": "2.32.1",
"description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
"projectname": "nk-shop2.0",
"setting": {
"compileHotReLoad": true,
"urlCheck": false
}
}

6
sitemap.json Normal file
View File

@ -0,0 +1,6 @@
{
"rules": [{
"action": "allow",
"page": "*"
}]
}

31
template.html Normal file
View File

@ -0,0 +1,31 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<!-- <meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests"> -->
<title>
<%= htmlWebpackPlugin.options.title %>
</title>
<!-- Open Graph data -->
<!-- <meta property="og:title" content="Title Here" /> -->
<!-- <meta property="og:url" content="http://www.example.com/" /> -->
<!-- <meta property="og:image" content="http://example.com/image.jpg" /> -->
<!-- <meta property="og:description" content="Description Here" /> -->
<script>
var coverSupport = 'CSS' in window && typeof CSS.supports === 'function' && (CSS.supports('top: env(a)') || CSS.supports('top: constant(a)'))
document.write('<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0' + (coverSupport ? ', viewport-fit=cover' : '') + '" />')
if(window.location.protocol == 'https:'){
document.write('<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">')
}
</script>
<link rel="stylesheet" href="<%= BASE_URL %>static/index.<%= VUE_APP_INDEX_CSS_HASH %>.css" />
</head>
<body>
<noscript>
<strong>Please enable JavaScript to continue.</strong>
</noscript>
<div id="app"></div>
<!-- built files will be auto injected -->
</body>
</html>

78
uni.scss Normal file
View File

@ -0,0 +1,78 @@
/**
* 这里是uni-app内置的常用样式变量
*
* uni-app 官方扩展插件及插件市场https://ext.dcloud.net.cn上很多三方插件均使用了这些样式变量
* 如果你是插件开发者建议你使用scss预处理并在插件代码中直接使用这些变量无需 import 这个文件方便用户通过搭积木的方式开发整体风格一致的App
*
*/
/**
* 如果你是App开发者插件使用者你可以通过修改这些变量来定制自己的插件主题实现自定义主题功能
*
* 如果你的项目同样使用了scss预处理你也可以直接在你的 scss 代码中使用如下变量同时无需 import 这个文件
*/
@import '@/uni_modules/uview-ui/theme.scss';
/* 颜色变量 */
$uni-theme-color: #f45846;
$uni-theme-bg-color: linear-gradient(180deg, #f98649 0%, #f34e45 100%);
/* 行为相关颜色 */
$uni-color-primary: #007aff;
$uni-color-success: #4cd964;
$uni-color-warning: #f0ad4e;
$uni-color-error: #dd524d;
$uni-nothing-text: #999; //空白页文字
$theme-color: #e93323;
$theme-color-opacity: rgba(233, 51, 35, 0.6);
$bg-star: #f62c2c;
$bg-end: #f96e29;
/* 背景颜色 */
$uni-bg-color: #ffffff;
$uni-bg-color-grey: #f8f8f8;
$uni-bg-color-hover: #f1f1f1; //点击状态颜色
$uni-bg-color-mask: rgba(0, 0, 0, 0.4); //遮罩颜色
/* 边框颜色 */
$uni-border-color: #c8c7cc;
/* 尺寸变量 */
/* 文字尺寸 */
$uni-font-size-sm: 24upx;
$uni-font-size-base: 28upx;
$uni-font-size-lg: 32upx;
/* 图片尺寸 */
$uni-img-size-sm: 40upx;
$uni-img-size-base: 52upx;
$uni-img-size-lg: 80upx;
/* Border Radius */
$uni-border-radius-sm: 4upx;
$uni-border-radius-base: 6upx;
$uni-border-radius-lg: 12upx;
$uni-border-radius-circle: 50%;
/* 水平间距 */
$uni-spacing-row-sm: 10px;
$uni-spacing-row-base: 20upx;
$uni-spacing-row-lg: 30upx;
/* 垂直间距 */
$uni-spacing-col-sm: 8upx;
$uni-spacing-col-base: 16upx;
$uni-spacing-col-lg: 24upx;
/* 透明度 */
$uni-opacity-disabled: 0.3; // 组件禁用态的透明度
/* 文章场景相关 */
$uni-color-title: #2c405a; // 文章标题颜色
$uni-font-size-title: 40upx;
$uni-color-subtitle: #555555; // 二级标题颜色
$uni-font-size-subtitle: 36upx;
$uni-color-paragraph: #3f536e; // 文章段落颜色
$uni-font-size-paragraph: 30upx;

155
utils/cache.js Normal file
View File

@ -0,0 +1,155 @@
// +----------------------------------------------------------------------
// | 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 = '_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
utils/dayjs.min.js vendored Normal file

File diff suppressed because one or more lines are too long

138
utils/index.js Normal file
View File

@ -0,0 +1,138 @@
import {
spread
} from "@/api/user";
import Cache from "@/utils/cache";
import Store from '@/store/index';
export function configMap(args, init) {
if(Array.isArray(args)) {
return args.reduce((i, v)=>{
i[v] = () => Store.getters.globalData[v];
return i;
}, init || {})
}else{
return Object.keys(args).reduce((i, v)=>{
i[v] = () => {
const val = Store.getters.globalData[v];
return (val === undefined || val === null || val === '') ? args[v] : val;
};
return i;
}, init || {})
}
}
export function redirect(url){
uni.switchTab({
url,
fail(){
uni.redirectTo({
url
})
}
})
}
/**
* 转换商户跳转链接, 自动追加商户 id
* @param {string} path
* @param {int} mer_id
* @param {string} name 商户id 参数名, 默认 mer_id
*/
export function merPath(path, mer_id, name){
if(!mer_id) return path;
path += ((path.indexOf('?') > -1 ? '&' : '?') + (name || 'mer_id') + '=' + mer_id);
return path;
}
/**
* 绑定用户授权
* @param {Object} puid
*/
export function silenceBindingSpread() {
//#ifdef H5
let puid = Cache.get('spread');
//#endif
//#ifdef MP || APP-PLUS
let puid = getApp().globalData.spid;
if (!puid) {
puid = getApp().globalData.code;
}
//#endif
puid = parseInt(puid);
if (Number.isNaN(puid)) {
puid = 0;
}
if (puid) {
//#ifdef H5
Cache.clear('spread');
//#endif
//#ifdef MP || APP-PLUS
getApp().globalData.spid = 0;
getApp().globalData.code = 0;
//#endif
}
}
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;
}
// const VUE_APP_WS_URL = process.env.VUE_APP_WS_URL || `ws://${location.hostname}:20003`;
// const ishttps = 'https:' == document.location.protocol ? true : false;
// const VUE_APP_WS_URL = ishttps ? `wss://mer.crmeb.net?type=user&token=${token}` : `ws://mer.crmeb.net?type=user&token=${token}`;
// export { VUE_APP_WS_URL }
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;
}
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2021 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
let token = ''
try {
token = uni.getStorageSync('LOGIN_STATUS_TOKEN')
// console.log(token, 'this')
} catch (error) {
}
// const VUE_APP_WS_URL = process.env.VUE_APP_WS_URL || `ws://${location.hostname}?type=user&token=${token}`;
// const VUE_APP_WS_URL = `wss://mer.crmeb.net?type=user&token=${token}`
export default parseQuery;

76
utils/request.js Normal file
View File

@ -0,0 +1,76 @@
// +----------------------------------------------------------------------
// | 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_ONE,
HEADER,
TOKENNAME
} from '@/config/app';
import store from '../store';
/**
* 发送请求
*/
function baseRequest(url, method, data, {
noAuth = false,
noVerify = false
}) {
let Url = HTTP_REQUEST_URL_ONE,
header = HEADER;
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) => {
// #ifdef APP-PLUS
// console.log('app', Url + '/api/' + url, method);
// #endif
if (noVerify)
reslove(res.data, res);
else if (res.data.status == 200)
reslove(res.data, res);
else if ([410000, 410001, 410002, 40000].indexOf(res.data.status) !== -1) {
reject(res.data);
} else if (res.data.code==0||res.data.code==1) {
reslove(res.data, res);
}else if (res.data.status == 501) {
uni.reLaunch({
url: '/pages/error/index'
})
reject(res.data);
} else
reject(res.data.message || '系统错误');
},
fail: (message) => {
console.log(url, method, data)
reject('请求失败',message);
}
})
});
}
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;

70
utils/requesta.js Normal file
View File

@ -0,0 +1,70 @@
// +----------------------------------------------------------------------
// | 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 store from '../store';
/**
* 发送请求
*/
function baseRequest(url, method, data, {
noAuth = false,
noVerify = false
}) {
let Url = HTTP_REQUEST_URL,
header = HEADER;
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) => {
// #ifdef APP-PLUS
// console.log('app', Url + '/api/' + url, method);
// #endif
if (noVerify)
reslove(res.data, res);
else if (res.data.status == 200)
reslove(res.data, res);
else if ([410000, 410001, 410002, 40000].indexOf(res.data.status) !== -1) {
reject(res.data);
} else if (res.data.code==0||res.data.code==1) {
reslove(res.data, res);
}else if (res.data.status == 501) {
reject(res.data);
} else
reject(res.data.message || '系统错误');
},
fail: (message) => {
console.log(url, method, data)
reject('请求失败',message);
}
})
});
}
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;

192
utils/util.js Normal file
View File

@ -0,0 +1,192 @@
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2021 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
import {
TOKENNAME,
HTTP_REQUEST_URL
} from '../config/app.js';
export default {
/*
* 合并数组
*/
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;
},
/**
* 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 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 || 'field';
uni.chooseImage({
count: count, //最多可以选择的图片总数
sizeType: sizeType, // 可以指定是原图还是压缩图,默认二者都有
sourceType: sourceType, // 可以指定来源是相册还是相机,默认二者都有
success: function(res) {
//启动上传等待中...
uni.showLoading({
title: '图片上传中',
});
uni.uploadFile({
url: HTTP_REQUEST_URL + '/api/' + uploadUrl + '/' + inputName,
filePath: res.tempFilePaths[0],
name: inputName,
formData: {
'filename': inputName
},
header: {
// #ifdef MP
"Content-Type": "multipart/form-data",
// #endif
[TOKENNAME]: 'Bearer ' + uni.getStorageSync('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.status == 200) {
successCallback && successCallback(data)
} else {
errorCallback && errorCallback(data);
that.Tips({
title: data.message
});
}
}
},
fail: function(res) {
uni.hideLoading();
that.Tips({
title: '上传图片失败'
});
}
})
}
})
}
}

47
utils/validate.js Normal file
View File

@ -0,0 +1,47 @@
// +----------------------------------------------------------------------
// | 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
}
}
/**
* 验证手机号码
*/
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
}
}
/**
* 验证邮箱
*/
export function isEmailAvailable(emailInput) {
var myreg = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
if (!myreg.test(emailInput)) {
return false;
} else {
return true;
}
}

11
vue.config.js Normal file
View File

@ -0,0 +1,11 @@
module.exports = {
productionSourceMap: false, // 生产打包时不输出map文件增加打包速度
configureWebpack: config => {
if (process.env.NODE_ENV === 'production') {
config.optimization.minimizer[0].options.terserOptions.compress.warnings = false
config.optimization.minimizer[0].options.terserOptions.compress.drop_console = true
config.optimization.minimizer[0].options.terserOptions.compress.drop_debugger = true
config.optimization.minimizer[0].options.terserOptions.compress.pure_funcs = ['console.log']
}
}
}