You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

698 lines
18 KiB
JavaScript

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

let data = {
globalConstantData: {
requestComeFrom: 'dandelion_platform_miniapp',
},
/* 固定数据
*/
store () {
return {
appid: 'wxa7b4864efbcff191', //
cdnBaseImg: "https://bocai-cms.oss-cn-beijing.aliyuncs.com/web-resource/dailibaoming/", // 图片公共前缀路径
svgBaseImg: "https://bocai-cms.oss-cn-beijing.aliyuncs.com/web-resource/1shoudan/",// svg
fadanBaseImg: "https://bocai-cms.oss-cn-beijing.aliyuncs.com/web-resource/dailibaoming/",
coziID: '7543074655566102537',
// coziID: '7491244881596809243',
baseUrl: "https://daotian.matripe.com.cn",// 网络请求的基础路径
// baseUrl: "http://192.168.3.83:8001", // 网络请求的基础路径
// baseUrl: "http://192.168.1.3:8001",// 118
// #ifdef MP-WEIXIN
version: uni.getAccountInfoSync().miniProgram.version || "1.0.0",
mapKey: 'LHQBZ-MLTEG-BO4QK-QJ2TH-NLGZJ-7GFAS',
// #endif
// #ifdef H5 || APP-PLUS || MP-TOUTIAO || MP-KUAISHOU
version: "1.0.0"
// #endif
}
},
/* 分享给好友
*/
shareFun (
path = "/pages/home/index",
image = "",
title = ''
) {
// console.log(uni.getStorageSync('miniApp-info'));
let appInfo = uni.getStorageSync('miniApp-info')
let params = {
path: path +
`?userId=${uni.getStorageSync("apply-userinfo") ? uni.getStorageSync("apply-userinfo").user.id : ''}`,
imageUrl: appInfo.sharePoster ||
"https://bocai-cms.oss-cn-beijing.aliyuncs.com/web-resource/pugongying/share.jpeg", // image ? image :
title: appInfo.slogan || ' '
};
return params;
},
/*
判断是否登录,未登录,强制跳转至登录页
*/
isLogin () {
let that = this;
if (!uni.getStorageSync("apply-token")) {
uni.reLaunch({
url: '/root/login/index?path=' + that.getPath().path + '&level=' + that.getPath().level
});
return false;
} else {
return true;
}
},
/* 获取当前path
*/
getPath () {
const pages = getCurrentPages();
if (pages.length > 0) {
let _path = pages[pages.length - 1].route;
return {
path: _path,
level: _path.slice(0, 4)
}
} else {
return {
path: '',
level: ''
};
}
},
/**
* 全拷贝
*/
fullCopy (data) {
return JSON.parse(JSON.stringify(data))
},
/**
* 获取头部nav高度
*/
getNavInfo () {
if (uni.getSystemInfoSync()) {
var {
statusBarHeight,
platform,
windowHeight
} = uni.getSystemInfoSync();
}
// #ifdef APP-PLUS || H5 || MP-TOUTIAO || MP-KUAISHOU
var {
top,
height
} = this.getMobileInfo;
// #endif
if (uni.getMenuButtonBoundingClientRect) {
var {
top,
height
} = uni.getMenuButtonBoundingClientRect();
}
// #ifdef MP-WEIXIN
// #endif
let info = {}
info.statusBarHeight = statusBarHeight;
info.menuButtonHeight = height ? height : 32;
info.windowHeight = windowHeight;
if (top && top !== 0 && height && height !== 0) {
const navigationBarHeight = (top - statusBarHeight) * 2 + height;
// 导航栏高度
info.navigationBarHeight = navigationBarHeight;
} else {
info.navigationBarHeight = platform === "android" ? 48 : 40;
}
return info
},
/**
* 根据传递的scene参数获取里面的内容
*/
sceneToJson (sceneStr) {
let json = {};
let array = sceneStr.split(",");
array.forEach((item) => {
let arr = item.split("=");
let key = arr[0];
let value = arr[1];
json[key] = value;
});
return json;
},
/* 扫一扫
*/
handleScanCode () {
let that = this;
function errorMsg () {
that.handleConfirm('无法识别该二维码', () => { }, () => { });
}
uni.scanCode({
success: function (res) {
// console.log('获取扫码结果:', res.result)
if (res.result) {
if (res.result.indexOf('=') > -1) {
// 前往详情页
let params = {
id: res.result.split('=')[1],
isShowMore: false,
isShowJob: false
};
uni.navigateTo({
url: "/root/detail/user?" + that.objToStr(params),
});
} else {
errorMsg();
}
} else {
errorMsg();
}
}
});
},
/* 设置导航条
*/
setNavStyle ($form = 'default') {
},
// 年月日
formatDateYMD (val) {
// model -> view在更新 `<input>` 元素之前格式化值
if (val == null || val == "") {
return null;
}
if ((val != null || val == "") && typeof val == "string") {
if (val.indexOf("T")) {
val = val.replace("T", " "); //原来L端可能返回的时间格式有带T的格式处理一下
}
val = val.replace("-", "/").replace("-", "/");
}
var value = new Date(val);
// console.log(val);
var fmt = "yyyy-MM-dd";
var o = {
"M+": value.getMonth() + 1, //月份
"d+": value.getDate(), //日
// "H+": value.getHours(), //小时
//"h+": val.getHours()%12 == 0 ? 12 : val.getHours()%12, //小时
// "m+": value.getMinutes(), //分
// "s+": value.getSeconds() //秒
//"S": val.getMilliseconds() //毫秒
//"q+": Math.floor((val.getMonth() + 3) / 3) //季度
};
if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (value.getFullYear() + "").substr(4 - RegExp.$1.length));
for (var k in o) {
if (new RegExp("(" + k + ")").test(fmt)) {
fmt = fmt.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length));
}
}
return fmt;
},
policyNumToHanZi (i, type = 'other') {
let pickerStr;
if (i <= 9) {
switch (i) {
case 1:
pickerStr = type == 'add' ? '一条政策' : "政策一";
break;
case 2:
pickerStr = type == 'add' ? '二条政策' : "政策二";
break;
case 3:
pickerStr = type == 'add' ? '三条政策' : "政策三";
break;
case 4:
pickerStr = type == 'add' ? '四条政策' : "政策四";
break;
case 5:
pickerStr = type == 'add' ? '五条政策' : "政策五";
break;
case 6:
pickerStr = type == 'add' ? '六条政策' : "政策六";
break;
case 7:
pickerStr = type == 'add' ? '七条政策' : "政策七";
break;
case 8:
pickerStr = type == 'add' ? '八条政策' : "政策八";
break;
case 9:
pickerStr = type == 'add' ? '九条政策' : "政策九";
break;
case 10:
pickerStr = type == 'add' ? '十条政策' : "政策十";
break;
default:
pickerStr = type == 'add' ? (i + 1) + '条政策' : "政策" + (i + 1);
break;
}
}
return pickerStr
},
/* 姓名/性别/年龄/民族
*/
titleToStr ($obj) {
let _sex = '',
_age = '',
_nation = '';
if ($obj.sex == 0) {
_sex = ''
} else if ($obj.sex == 1) {
_sex = '/男'
} else if ($obj.sex == 2) {
_sex = '/女'
} else {
_sex = ''
}
if ($obj.age) {
_age = '/' + $obj.age
} else {
_age = ''
}
if ($obj.nation) {
_nation = '/' + $obj.nation
} else {
_nation = ''
}
return _sex + _age + _nation;
},
/* 交互反馈:取消确认弹窗
*/
handleConfirm (
options
) {
// console.log(options);
uni.showModal({
title: options.title || '',
content: options.content || '',
showCancel: options.showCancel === false ? false : true,
confirmText: options.confirmText || "确定",
confirmColor: options.confirmColor || "#576b95",
cancelColor: options.cancelColor || "#000",
cancelText: options.cancelText || "取消",
success (res) {
options.success(res);
}
});
},
/* 清除登录信息存储
*/
clearLocalStorage () {
uni.removeStorageSync("apply-avatar");
uni.removeStorageSync("apply-username");
uni.removeStorageSync("apply-tel");
uni.removeStorageSync("apply-token");
uni.removeStorageSync("apply-userinfo");
uni.removeStorageSync("apply-userinfo-copy");
uni.removeStorageSync("apply-agencyId");
uni.removeStorageSync("apply-supplierAccount");
uni.removeStorageSync("IS_MINIAPP_MEMBER");
uni.removeStorageSync("IS_MINIAPP_ADMIN");
uni.removeStorageSync("apply-uid")
uni.removeStorageSync("agencyInfo");
uni.removeStorageSync("HAS_PERMISSION")
uni.removeStorageSync("user_ServicePermission")
uni.removeStorageSync("is_teamleader")
},
/* 对象重组成字符串 */
objToStr (obj = {}, type = 'url') {
let str = '';
if (type == 'url') {
str = Object.keys(obj)
.map(key => `${key}=${obj[key]}`)
.join('&');
} else if (type == 'copy') {
str = Object.keys(obj)
.map(key => `${key}${obj[key]}`)
.join('');
}
return str;
},
/**
* 分割电话号
*/
splitPhone (str) {
// 判断是否为11位
// console.log(str);
if (str.length != 11) return str;
var arr = str.split('');
arr.splice(3, 0, ' ');
arr.splice(8, 0, ' ');
return arr.join('')
},
/* 上传图片 (裁剪)
*/
uploadImage ($num = 1, callback = () => { }, $sourceType = ['album', 'camera']) {
uni.chooseImage({
crop: {
width: 100,
height: 100,
quality: 100,
resize: false,
// destWidth: 100,
},
count: $num, //默认9
sizeType: ['original'], //可以指定是原图还是压缩图,默认二者都有
sourceType: $sourceType, //album 从相册选图camera 使用相机
success: function (res) {
// console.log('选取文件数据:', res)
callback(JSON.stringify(res.tempFilePaths));
}
});
},
getOrderStatus () {
return [{
id: '0',
name: '新简历',
value: 0,
text: '新简历',
num: 0
},
{
id: '1',
name: '推工作',
value: 1,
text: '推工作',
num: 0
},
{
id: '2',
name: '已放弃',
value: 2,
text: '已放弃',
num: 0
},
{
id: '10',
name: '待审核',
value: 10,
text: '待审核',
num: 0
},
{
id: '20',
name: '待接待',
value: 20,
text: '待接待',
num: 0
},
{
id: '21',
name: '审核未通过',
value: 21,
text: '审核未通过',
num: 0
},
{
id: '25',
name: '待面试',
value: 25,
text: '待面试',
num: 0
},
{
id: '26',
name: '未接到',
value: 26,
text: '未接到',
num: 0
},
{
id: '30',
name: '待入职',
value: 30,
text: '待入职',
num: 0
},
{
id: '35',
name: '面试未通过',
value: 35,
text: '面试未通过',
num: 0
},
{
id: '40',
name: '已入职',
value: 40,
text: '已入职',
num: 0
},
{
id: '48',
name: '约离职',
value: 48,
text: '约离职',
num: 0
},
{
id: '45',
name: '通过未入职',
value: 45,
text: '通过未入职',
num: 0
},
{
id: '50',
name: '已离职',
value: 50,
text: '已离职',
num: 0
},
{
id: "100",
name: "待确认",
value: "50",
text: "待确认",
num: 0
},
{
id: "101",
name: "已取消",
value: "50",
text: "已取消",
num: 0
},
{
id: "102",
name: "官方审核中",
value: "50",
text: "官方审核中",
num: 0
},
{
id: "103",
name: "审核不通过",
value: "50",
text: "审核不通过",
num: 0
},
]
},
isValidIdCard (idCard) {
const idCardRegex = /^[1-9]\d{5}(18|19|20)\d{2}(0[1-9]|1[0-2])(0[1-9]|[1-2][0-9]|3[0-1])\d{3}[\dXx]$/;
if (!idCardRegex.test(idCard)) {
return false;
}
const factors = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2];
const checkCodeList = ['1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2'];
let sum = 0;
for (let i = 0; i < 17; i++) {
sum += parseInt(idCard[i]) * factors[i];
}
const checkCode = checkCodeList[sum % 11];
return checkCode === idCard[17].toUpperCase();
},
getInfoByIDcard (idCard) {
let info = {}
let birthday
// 获取性别
if (idCard.length === 15) {
info.sex = ['女', '男'][idCard.substr(14, 1) % 2]
birthday = Y + [idCard.substr(6, 2), idCard.substr(8, 2), idCard.substr(10, 2)].join('-')
} else if (idCard.length === 18) {
info.sex = ['女', '男'][idCard.substr(16, 1) % 2]
birthday = [idCard.substr(6, 4), idCard.substr(10, 2), idCard.substr(12, 2)].join('-')
}
// 获取年龄
let currentYear = new Date().getFullYear() //当前的年份
let calculationYear = new Date(birthday).getFullYear() //计算的年份
const wholeTime = currentYear + birthday.substring(4) //周岁时间
const calculationAge = currentYear - calculationYear //按照年份计算的年龄
//判断是否过了生日
if (new Date().getTime() > new Date(wholeTime).getTime()) {
info.age = calculationAge
} else {
info.age = calculationAge - 1
}
// console.log('info', info);
return info
},
/* 正则
*/
setReg ($str, $type = 'default') {
if ($type == 'tel') {
return /^1[3-9]\d{9}$/.test($str);
}
if ($type == 'idcard') {
return /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/.test($str);
}
},
getHrDom (_str) {
return `
<view class="g-components-panel-hr g_flex_row_center" style="padding-bottom: 50px;">
<view class="g_flex_column_center">
<view class="doc-left"></view>
</view>
<view class="g_flex_column_center g_fs_14 g_c_9 g_mr_10 g_ml_10 g_pt_10 g_pb_10">${_str}</view>
<view class="g_flex_column_center">
<view class="doc-right"></view>
</view>
</view>`;
},
getEmptyDom (text = "暂无数据", subText = "") {
const cdnBaseImg = this.store().cdnBaseImg;
const clickAttr = text == '请登录' ? ` @click="${clickHandler}"` : '';
function clickHandler () {
uni.reLaunch({
url: '/root/login/index?path=' + that.getPath().path + '&level=' + that.getPath().level
});
}
// console.log('getEmptyDom', text, subText);
return `
<view class="g_flex_column_center" style="min-height: 69px;">
<view class="btn" ${clickAttr}>
<view class="u-empty"
>
<div class='g_flex_row_center' style='color:rgb(192, 196, 204);margin: 5px 0px 0px;'>${text}</div>
<div class='g_flex_row_center'>
<img src="${cdnBaseImg}noData.svg" alt="" />
</div>
</view>
${subText ? `<view class="g_text_c g_fs_13" style="color: #c0c4cc;">${subText}</view>` : ''}
</view>
</view>
`;
},
/* 综合月薪 正则规则
* 价格中间的特殊字符
*/
specStrReg ($str) {
let list = [
'~', '!', '@', '#', '%', '^', '&', '*', '(', ')',
'', '', '', '+', '`', '-', '=', '·',
'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', '[', ']', '{', '}', '|', '|',
'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', ':', "'", '"', '', '“', '”',
'z', 'x', 'c', 'v', 'b', 'n', 'm', ',', '.', '/', '<', '>', '?', '《', '》', '',
'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P',
'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L',
'Z', 'X', 'C', 'V', 'B', 'N', 'M', ' ', '——'
],
obj = {
min: 0,
max: 0
}
if ($str) {
list.forEach((item, index) => {
if ($str.indexOf(item) > -1 && $str.split(item)[1]) {
let newlist = [$str.split(item)[0], $str.split(item)[1]]
newlist.sort(function (a, b) {
return a - b
})
obj = {
min: newlist[0],
max: newlist[1],
}
}
})
}
return obj;
},
/**
* canvas绘图 start
*/
/**
* 文字绘制
*/
fillTextLineBreak (ctx, text, x, y, lw, lh, color = "#333", font = "32", weight = "500") {
// , align = "center"
var i = 0;
var n = 0;
var r = -1;
// var initHeight = 0;
ctx.font = weight + " " + font + "px Arial"; //字体大小
ctx.fillStyle = color; //字体颜色
// ctx.textBaseline = align;
// ctx.textAlign = align;
while (i < text.length) {
while (ctx.measureText(text.substring(n, i)).width < lw && i < text.length) {
i++;
}
r++;
ctx.fillText(text.substring(n, i), x, y + lh * r);
n = i;
}
},
/**
* 背景图绘制
*/
roundRect (ctx, img, bg_x, bg_y, bg_w, bg_h, bg_r) {
// 开始绘制
ctx.save();
ctx.beginPath();
ctx.arc(bg_x + bg_r, bg_y + bg_r, bg_r, Math.PI, Math.PI * 1.5);
ctx.arc(bg_x + bg_w - bg_r, bg_y + bg_r, bg_r, Math.PI * 1.5, Math.PI * 2);
ctx.arc(bg_x + bg_w - bg_r, bg_y + bg_h - bg_r, bg_r, 0, Math.PI * 0.5);
ctx.arc(bg_x + bg_r, bg_y + bg_h - bg_r, bg_r, Math.PI * 0.5, Math.PI);
ctx.clip();
ctx.drawImage(img, bg_x, bg_y, bg_w, bg_h);
// 恢复之前保存的绘图上下文
ctx.restore();
},
roundRect_yuan (ctx, x, y, size) {
// 开始绘制
ctx.save(); // 保存
ctx.beginPath(); // 开始绘制
// ctx.arc(100, 75, 50, 0, 2 * Math.PI)
ctx.arc(size / 2 + x, size / 2 + y, size / 2, 0, Math.PI * 2, false);
ctx.clip();
// 恢复之前保存的绘图上下文
ctx.restore();
},
roundRect1 (ctx, x, y, w, h, r, color) {
//绘制圆角矩形(无填充色))
ctx.save();
ctx.fillStyle = color;
ctx.strokeStyle = color;
ctx.lineJoin = "round"; //交点设置成圆角
ctx.lineWidth = r;
ctx.strokeRect(x + r / 2, y + r / 2, w - r, h - r);
ctx.fillRect(x + r, y + r, w - r * 2, h - r * 2);
ctx.stroke();
ctx.closePath();
},
/**
* canvas绘图 end
*/
handleSetSex ($obj = {}) {
if (Boolean($obj.minAgeWoman) === true && Boolean($obj.minAgeMan) === false) {
$obj.gender = "女";
} else if (Boolean($obj.minAgeWoman) === false && Boolean($obj.minAgeMan) === true) {
$obj.gender = "男";
} else {
$obj.gender = "男女不限";
}
return $obj;
},
}
export default data;