初始化
This commit is contained in:
76
common/css/base.scss
Normal file
76
common/css/base.scss
Normal file
@@ -0,0 +1,76 @@
|
||||
page {
|
||||
background: #f6f7f8;
|
||||
}
|
||||
|
||||
.hide-txt {
|
||||
overflow-x: hidden;
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
word-break: break-all;
|
||||
-webkit-line-clamp: 1;
|
||||
}
|
||||
|
||||
.clamp-txt {
|
||||
overflow: hidden;
|
||||
display: -webkit-box;
|
||||
-webkit-box-orient: vertical;
|
||||
-webkit-line-clamp: 2;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
|
||||
.bg-blue {
|
||||
background: #277bc0;
|
||||
}
|
||||
|
||||
.list {
|
||||
.list-card {
|
||||
margin-bottom: 20rpx;
|
||||
padding: 24rpx 20rpx;
|
||||
background: #fff;
|
||||
.list-card-title {
|
||||
font-size: 28rpx;
|
||||
color: #111;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.list-card-des {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-top: 22rpx;
|
||||
color: #999999;
|
||||
font-size: 24rpx;
|
||||
|
||||
.list-card-des-btn {
|
||||
margin-left: 20rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
height: 48rpx;
|
||||
width: 120rpx;
|
||||
border-radius: 4rpx;
|
||||
color: #fff;
|
||||
background: #449dff;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.fixed-btn {
|
||||
position: fixed;
|
||||
right: 80rpx;
|
||||
bottom: 200rpx;
|
||||
width: 126rpx;
|
||||
height: 126rpx;
|
||||
background: #fff;
|
||||
border-radius: 50%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
box-shadow: 0 0 10rpx rgba(0, 0, 0, 0.2);
|
||||
image {
|
||||
height: 66rpx;
|
||||
width: 66rpx;
|
||||
}
|
||||
}
|
||||
26
common/js/config.js
Normal file
26
common/js/config.js
Normal file
@@ -0,0 +1,26 @@
|
||||
const debug = false // true 是连地服务端本地,false 是连接线上
|
||||
|
||||
const development = {
|
||||
domain: 'http://192.168.1.60:8094',
|
||||
STATIC: '',
|
||||
tenantId: 'rocanOA',
|
||||
|
||||
}
|
||||
|
||||
const production = {
|
||||
domain: 'http://192.168.1.60:8094',
|
||||
STATIC: 'http://192.168.1.60:8094',
|
||||
tenantId: 'rocanOA',
|
||||
}
|
||||
|
||||
const config = debug ? development : production
|
||||
|
||||
// #ifdef H5
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
config.domain = '/api'
|
||||
} else {
|
||||
config.domain = window.location.origin
|
||||
}
|
||||
// #endif
|
||||
|
||||
export default config
|
||||
93
common/js/list.js
Normal file
93
common/js/list.js
Normal file
@@ -0,0 +1,93 @@
|
||||
export default {
|
||||
onPullDownRefresh () {
|
||||
this.store && this.store.reload();
|
||||
this.store.loadedCallback = () => {
|
||||
uni.stopPullDownRefresh();
|
||||
};
|
||||
},
|
||||
onReachBottom () {
|
||||
if (this.store.status != "noMore") {
|
||||
this.store.next && this.store.next();
|
||||
}
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
store: {},
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
DataSource (url) {
|
||||
var me = this;
|
||||
return {
|
||||
data: [],
|
||||
status: "more",
|
||||
empty: false,
|
||||
total: 0,
|
||||
header: {},
|
||||
params: {
|
||||
pages: 1,
|
||||
step: 20,
|
||||
entity: {},
|
||||
},
|
||||
reload () {
|
||||
this.data = [];
|
||||
this.status = "loading";
|
||||
this.empty = false;
|
||||
this.params.pages = 1;
|
||||
this.next();
|
||||
},
|
||||
callBack: null,
|
||||
firstCallBack: null,
|
||||
loadedCallback: null,
|
||||
next () {
|
||||
me.$request({
|
||||
url: url,
|
||||
data: Object.assign(
|
||||
{
|
||||
// page: {
|
||||
// current: this.params.pages,
|
||||
// orders: [],
|
||||
// size: this.params.step,
|
||||
// total: 0,
|
||||
// },
|
||||
offset: this.params.pages,
|
||||
limit: this.params.step,
|
||||
current: this.params.pages,
|
||||
pageSize: this.params.step,
|
||||
},
|
||||
this.params
|
||||
),
|
||||
header: this.header,
|
||||
method: "POST",
|
||||
}).then((res) => {
|
||||
console.warn(res);
|
||||
let resultData = res.rows || res.data?.list || res.data?.result?.records || [];
|
||||
if (this.params.pages == 1) {
|
||||
this.data = resultData;
|
||||
if (resultData.length == 0 || resultData == 0) {
|
||||
this.empty = true;
|
||||
} else if (resultData.length < this.params.step) {
|
||||
this.status = "noMore";
|
||||
} else if (res.total == resultData.length) {
|
||||
this.status = "noMore";
|
||||
}
|
||||
} else {
|
||||
this.data.push(...resultData);
|
||||
if (resultData.length < this.params.step) {
|
||||
this.status = "noMore";
|
||||
}
|
||||
}
|
||||
|
||||
if (this.params.pages == 1) {
|
||||
this.firstCallBack && this.firstCallBack();
|
||||
}
|
||||
this.loadedCallback && this.loadedCallback();
|
||||
this.params.pages++;
|
||||
this.total = res.total;
|
||||
this.loading = false;
|
||||
});
|
||||
},
|
||||
};
|
||||
},
|
||||
},
|
||||
};
|
||||
85
common/js/request.js
Normal file
85
common/js/request.js
Normal file
@@ -0,0 +1,85 @@
|
||||
|
||||
import config from "./config";
|
||||
let arr = []
|
||||
export default (options = {}) => {
|
||||
if (options.data == undefined) {
|
||||
options.data = {}
|
||||
}
|
||||
// 防止接口重复点击
|
||||
if (arr.indexOf(options.url) === -1) {
|
||||
arr.push(options.url)
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
reject({
|
||||
code: -1,
|
||||
msg: '请勿重复提交'
|
||||
})
|
||||
})
|
||||
}
|
||||
return new Promise((reslove, reject) => {
|
||||
uni.request({
|
||||
url: options.url.indexOf('http') === -1 ? config.domain + options.url : options.url,
|
||||
data: {
|
||||
...options.data,
|
||||
},
|
||||
header: {
|
||||
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
|
||||
'Authorization': uni.getStorageSync('Authorization'),
|
||||
'Cookie': uni.getStorageSync('Cookie'),
|
||||
...options.header
|
||||
},
|
||||
method: options.method || 'GET',
|
||||
success: async (res) => {
|
||||
console.warn(res);
|
||||
if (options.url.indexOf('/org/login/valid') > -1) {
|
||||
uni.setStorageSync('Cookie', res.header['Set-Cookie']);
|
||||
}
|
||||
if (arr.indexOf(options.url) > -1) {
|
||||
arr.splice(arr.indexOf(options.url), 1)
|
||||
}
|
||||
if (res.data.isOk === false) {
|
||||
reject(res.data)
|
||||
errHandler(res.data)
|
||||
} else {
|
||||
reslove(res.data)
|
||||
}
|
||||
},
|
||||
fail: (err) => {
|
||||
if (arr.indexOf(options.url) > -1) {
|
||||
arr.splice(arr.indexOf(options.url), 1)
|
||||
}
|
||||
reject(err)
|
||||
uni.showToast({
|
||||
icon: 'none',
|
||||
title: '网络异常,请稍后再试',
|
||||
})
|
||||
uni.reLaunch({
|
||||
url: '/pages/login/login',
|
||||
});
|
||||
},
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 错误处理
|
||||
* @param {Number} code 错误码
|
||||
*/
|
||||
function errHandler (res) {
|
||||
switch (res.code) {
|
||||
case '401':
|
||||
// #ifdef MP
|
||||
uni.removeStorageSync('Cookie');
|
||||
uni.clearStorageSync();
|
||||
// #endif
|
||||
uni.reLaunch({ url: '/pages/login/login' })
|
||||
break
|
||||
default:
|
||||
uni.showToast({
|
||||
title: res.msg || '服务端未知错误',
|
||||
duration: 2000,
|
||||
icon: 'none'
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
21
common/js/share.js
Normal file
21
common/js/share.js
Normal file
@@ -0,0 +1,21 @@
|
||||
export default {
|
||||
data () {
|
||||
return {
|
||||
|
||||
};
|
||||
},
|
||||
// #ifdef MP
|
||||
onShareAppMessage (res) {
|
||||
return {
|
||||
title: "荣创科技",
|
||||
path: "/pages/index/index",
|
||||
};
|
||||
},
|
||||
onShareTimeline () {
|
||||
return {
|
||||
title: "荣创科技",
|
||||
path: "/pages/index/index",
|
||||
};
|
||||
},
|
||||
// #endif
|
||||
};
|
||||
258
common/js/util.js
Normal file
258
common/js/util.js
Normal file
@@ -0,0 +1,258 @@
|
||||
import request from './request'
|
||||
import config from './config.js'
|
||||
const toast = (title, duration = 1500, call, mask = false, icon = 'none') => {
|
||||
if (Boolean(title) === false) {
|
||||
return
|
||||
}
|
||||
uni.showToast({
|
||||
title,
|
||||
duration,
|
||||
mask,
|
||||
icon,
|
||||
})
|
||||
setTimeout(() => {
|
||||
call && call()
|
||||
}, duration);
|
||||
}
|
||||
/**
|
||||
* @description 格式化时间
|
||||
* @param time
|
||||
* @param cFormat
|
||||
* @returns {string|null}
|
||||
*/
|
||||
function parseTime (time, cFormat) {
|
||||
if (arguments.length === 0) {
|
||||
return null
|
||||
}
|
||||
const format = cFormat || '{y}-{m}-{d} {h}:{i}:{s}'
|
||||
let date
|
||||
if (typeof time === 'object') {
|
||||
date = time
|
||||
} else {
|
||||
if (typeof time === 'string' && /^[0-9]+$/.test(time)) {
|
||||
time = parseInt(time)
|
||||
}
|
||||
if (typeof time === 'number' && time.toString().length === 10) {
|
||||
time = time * 1000
|
||||
}
|
||||
date = new Date(time)
|
||||
}
|
||||
const formatObj = {
|
||||
y: date.getFullYear(),
|
||||
m: date.getMonth() + 1,
|
||||
d: date.getDate(),
|
||||
h: date.getHours(),
|
||||
i: date.getMinutes(),
|
||||
s: date.getSeconds(),
|
||||
a: date.getDay()
|
||||
}
|
||||
return format.replace(/{([ymdhisa])+}/g, (result, key) => {
|
||||
let value = formatObj[key]
|
||||
if (key === 'a') {
|
||||
return ['日', '一', '二', '三', '四', '五', '六'][value]
|
||||
}
|
||||
if (result.length > 0 && value < 10) {
|
||||
value = '0' + value
|
||||
}
|
||||
return value || 0
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @description 格式化时间
|
||||
* @param time
|
||||
* @param option
|
||||
* @returns {string}
|
||||
*/
|
||||
function formatTime (time, option) {
|
||||
if (('' + time).length === 10) {
|
||||
time = parseInt(time) * 1000
|
||||
} else {
|
||||
time = +time
|
||||
}
|
||||
if (option) {
|
||||
return parseTime(time, option)
|
||||
} else {
|
||||
const d = new Date(time)
|
||||
const now = Date.now()
|
||||
const diff = (now - d) / 1000
|
||||
if (diff < 30) {
|
||||
return '刚刚'
|
||||
} else if (diff < 3600) {
|
||||
// less 1 hour
|
||||
return Math.ceil(diff / 60) + '分钟前'
|
||||
} else if (diff < 3600 * 24) {
|
||||
return Math.ceil(diff / 3600) + '小时前'
|
||||
} else if (diff < 3600 * 24 * 2) {
|
||||
return '1天前'
|
||||
}
|
||||
return (
|
||||
d.getMonth() +
|
||||
1 +
|
||||
'月' +
|
||||
d.getDate() +
|
||||
'日'
|
||||
// +
|
||||
// d.getHours() +
|
||||
// '时'
|
||||
// +
|
||||
// d.getMinutes() +
|
||||
// '分'
|
||||
)
|
||||
}
|
||||
}
|
||||
const h5Helper = {
|
||||
isAndroid: function () {
|
||||
return window.navigator.appVersion.toLowerCase().indexOf('android') != -1
|
||||
},
|
||||
isIOS: function () {
|
||||
return window.navigator.appVersion.toLowerCase().indexOf('iphone') != -1
|
||||
},
|
||||
isWeiXinWeb: function () {
|
||||
var ua = window.navigator.userAgent.toLowerCase()
|
||||
return ua.match(/MicroMessenger/i) == 'micromessenger'
|
||||
},
|
||||
}
|
||||
|
||||
// 验证手机号格式
|
||||
const validatePhoneNumber = (phone) => {
|
||||
if (!phone) return false
|
||||
var testReg = /^1[23456789]\d{9}$/
|
||||
return testReg.test(phone)
|
||||
}
|
||||
|
||||
|
||||
const getUserLocation = (call) => {
|
||||
uni.getLocation({
|
||||
type: 'wgs84',
|
||||
success: function (address) {
|
||||
call(address)
|
||||
},
|
||||
fail: err => {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '定位失败,请打开定位权限',
|
||||
success: function (res) {
|
||||
if (res.confirm) {
|
||||
uni.openSetting({
|
||||
success: resSett => {
|
||||
if (resSett.authSetting['scope.userLocation']) {
|
||||
uni.getLocation({
|
||||
success: address => {
|
||||
call && call(address)
|
||||
},
|
||||
})
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
// 加载用户配置
|
||||
var globalConfigIsLoading = false,
|
||||
global_config = null,
|
||||
globalConfigCallbacks = [];
|
||||
/**
|
||||
* 加载用户配置
|
||||
* @param call 加载成功后的回调
|
||||
* @param need_fresh 是否及时刷新用户配置
|
||||
*/
|
||||
const loadConfig = (call, need_fresh = false) => {
|
||||
if (call && global_config && !need_fresh) {
|
||||
call(global_config);
|
||||
return;
|
||||
}
|
||||
if (globalConfigIsLoading) {
|
||||
globalConfigCallbacks.push(call);
|
||||
return;
|
||||
}
|
||||
globalConfigIsLoading = true;
|
||||
request({
|
||||
url: '/org/userResource/userMsg',
|
||||
}).then(rs => {
|
||||
|
||||
globalConfigIsLoading = false;
|
||||
global_config = rs.data;
|
||||
uni.setStorage({
|
||||
key: 'userInfo',
|
||||
data: global_config,
|
||||
})
|
||||
if (call) {
|
||||
call(global_config);
|
||||
}
|
||||
for (var i = 0; i < globalConfigCallbacks.length; i++) {
|
||||
globalConfigCallbacks[i](global_config);
|
||||
}
|
||||
globalConfigCallbacks = [];
|
||||
}).catch(err => {
|
||||
globalConfigIsLoading = false;
|
||||
console.warn(err);
|
||||
// uni.reLaunch({ url: '/pages/login/login' })
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 获取表单信息
|
||||
const getInstanceData = (params) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
request({
|
||||
url: '/bpm/instance/getInstanceData',
|
||||
data: params,
|
||||
method: 'POST',
|
||||
}).then(rs => {
|
||||
resolve(rs.data)
|
||||
}).catch(err => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
|
||||
}
|
||||
// 获取表单信息
|
||||
const getNextIdByAlias = (alias, call) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
request({
|
||||
url: '/sys/serialNo/getNextIdByAlias',
|
||||
data: {
|
||||
alias: alias,
|
||||
},
|
||||
method: 'POST',
|
||||
}).then(rs => {
|
||||
resolve(rs.data)
|
||||
}).catch(err => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
// 获取流程信息
|
||||
const getFlowImageInfo = (params) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
request({
|
||||
url: '/bpm/instance/getFlowImageInfo',
|
||||
data: params,
|
||||
method: 'POST',
|
||||
}).then(rs => {
|
||||
resolve(rs.data)
|
||||
}).catch(err => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export default {
|
||||
validatePhoneNumber,
|
||||
toast,
|
||||
formatTime,
|
||||
parseTime,
|
||||
h5Helper,
|
||||
getUserLocation,
|
||||
loadConfig,
|
||||
getNextIdByAlias,
|
||||
getInstanceData,
|
||||
getFlowImageInfo
|
||||
}
|
||||
Reference in New Issue
Block a user