拷贝华弘

This commit is contained in:
2024-07-18 10:13:18 +08:00
commit 930b32f6b9
133 changed files with 23569 additions and 0 deletions

1894
utils/CLodopfuncs.js Normal file

File diff suppressed because it is too large Load Diff

194
utils/getData2.js Normal file
View File

@@ -0,0 +1,194 @@
import request from './request.js'
// 版本更新测试
export const pdaUpdate = () => request({
url:'api/pda/update'
})
// export const pdaUpdate = () => {
// let res = {
// versionName: '1.0.1',
// url: 'https://mp-e979e0eb-882b-42b3-a4a1-923ad08ea194.cdn.bspapp.com/cloudstorage/f72ec59f-7b25-487d-a034-fead1b6654c6.apk'
// }
// return res
// }
// 登录
export const handLogin = (user, password) => request({
url:'mobile/auth/login',
data: {
username: user,
password: password
}
})
/**
* 混碾搬运
*/
// 查询货架上未拆包料盅信息
export const unpackShelfInfo = () => request({
url:'api/pda/unpackShelfInfo',
data: {}
})
// 查询拆包机点位
export const getCbjPoint = () => request({
url:'api/pda/getCbjPoint',
data: {}
})
// 拆包机叫料
export const cbjqlTask = (sp, ep) => request({
url:'api/pda/cbjqlTask',
data: {
startPoint: sp,
endPoint: ep
}
})
// 查询混碾工单
export const hnWorkOrder = () => request({
url:'api/pda/hnWorkOrder',
data: {}
})
// 拆包机下料位满料入货架
export const cbjmlTask = (code, bcode, sp) => request({
url:'api/pda/cbjmlTask',
data: {orderCode: code,barCode: bcode,startPoint: sp}
})
// 拆包机下料位叫空蛊
export const cbjqkTask = (ep) => request({
url:'api/pda/cbjqkTask',
data: {endPoint: ep}
})
// 拆包机空料位送空蛊
export const cbjskTask = (type, sp) => request({
url:'api/pda/cbjskTask',
data: {nextType: type, startPoint: sp}
})
/**
* 压机搬运
*/
// 压机上料位下拉框
export const yjslwPointList = () => request({
url:'api/pda/yjslwPointList',
data: {}
})
// 压机上料位强制回货架
export const qzhhjTask = (code) => request({
url:'api/pda/qzhhjTask',
data: {deviceCode: code}
})
// 查询货架上已拆包料盅信息
export const packShelfInfo = () => request({
url:'api/pda/packShelfInfo',
data: {}
})
// 困料货架点对点到布料机上料位
export const yzqlTask = (sp, ep) => request({
url:'api/pda/yzqlTask',
data: {startPoint: sp, endPoint: ep}
})
/**
* 物料报废
*/
// 物料报废
export const materialScrap = (code) => request({
url:'api/pda/materialScrap',
data: {
barCode: code
}
})
/**
* 人工分拣
*/
// 查询人工分拣点位
export const rgfjPoint = () => request({
url:'api/pda/rgfjPoint',
data: {}
})
// 查询缓存货架点位
export const hchjPoint = () => request({
url:'api/pda/hchjPoint',
data: {}
})
// 人工分拣叫料
export const rgfjqlTask = (sp, code) => request({
url:'api/pda/rgfjqlTask',
data: {startPoint: sp, deviceCode: code}
})
// 人工分拣送空盘
export const rgfjskTask = (code) => request({
url:'api/pda/rgfjskTask',
data: {deviceCode: code}
})
/**
* 任务管理
*/
// 1.1 1.1 查询无指令的任务(任务号为-开头)
export const handTasks = () => request({
url:'api/hand/tasks',
acsurl: true,
data: {}
})
// 1.2 任务操作
export const handTaskoperation = (type, id) => request({
url:'api/hand/taskoperation',
acsurl: true,
data: {
type: type,
task_uuid: id
}
})
/**
* 指令管理
*/
// 1.1 查询未完成指令(生成任务号为-开头)
export const handInsts = () => request({
url:'api/hand/insts',
acsurl: true,
data: {}
})
// 1.2 指令操作
export const handInst = (type, id) => request({
url:'api/hand/inst',
acsurl: true,
data: {
type: type,
inst_uuid: id
}
})
/**
* 压制混碾满料搬运
*/
export const mlTask = (code, vcode, weight, qty) => request({
url:'api/pda/mlTask',
data: {
deviceCode: code,
vehicle_code: vcode,
weight: weight,
qty: qty
}
})
/**
* 条码解绑
*/
export const vehicleUnbind = (code) => request({
url:'api/pda/vehicleUnbind',
data: {
point_code: code
}
})
/**
* 组盘查看
*/
export const zpxxTask = (code) => request({
url:'api/pda/zpxxTask',
data: {
vehicle_code: code
}
})

12
utils/jsencrypt.js Normal file
View File

@@ -0,0 +1,12 @@
import JSEncrypt from './jsencrypt2.js'
let publicKey = 'MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBANL378k3RiZHWx5AfJqdH9xRNBmD9wGD\n' +
'2iRe41HdTNF8RUhNnHit5NpMNtGL0NPTSSpPjjI1kJfVorRvaQerUgkCAwEAAQ==';
function RSAencrypt(pas){
//实例化jsEncrypt对象
let jse = new JSEncrypt();
//设置公钥
jse.setPublicKey(publicKey);
return jse.encrypt(pas);
}
export {RSAencrypt}

5373
utils/jsencrypt2.js Normal file

File diff suppressed because it is too large Load Diff

632
utils/mork2.js Normal file
View File

@@ -0,0 +1,632 @@
// 查询货架上未拆包料盅信息
export const unpackShelfInfo = () => {
let res = [
{
"pointCode": "KLHW03",
"materialCode": "ML-60BT",
"instorageTime": "2024-01-11 16:26:55"
}
]
return res
}
// 查询拆包机点位
export const getCbjPoint = () => {
let res = [
{
"value": "CBJKLW",
"text": "拆包机空料位"
},
{
"value": "CBJMLW",
"text": "拆包机满料位"
},
{
"value": "CBJXLW ",
"text": "拆包机下料位"
}
]
return res
}
// 拆包机叫料
export const cbjqlTask = () => {
let res = {
"message": "拆包机缺料请求成功"
}
return res
}
// 查询混碾工单
export const hnWorkOrder = () => {
let res = [
{
"workorder_id": "1762660775601770496",
"workorder_code": "240228003",
"plan_qty": 0,
"real_qty": 66,
"plan_weight": 1000,
"real_weight": 33,
"real_new_weight": 0,
"real_old_weight": 0,
"material_ratio": 0,
"material_id": "1771048061557149696",
"raw_material_code": "111",
"produce_order": null,
"batch_no": null,
"team": null,
"produce_date": "20240307",
"vehicle_type": "LZ",
"planproducestart_date": "2024-02-28 10:07:28",
"planproduceend_date": "2024-02-29 00:00:00",
"realproducestart_date": "2024-03-22 17:10:37",
"realproduceend_date": "2024-03-22 17:40:58",
"standing_time": 1,
"point_code": "HNJ01",
"point_name": "混碾机01",
"region_code": "HN",
"region_name": "混碾区域",
"workorder_status": "5",
"is_needmove": true,
"workorder_type": "1",
"production_order": null,
"passback_status": null,
"workshop_code": null,
"ext_id": null,
"ext_data": "0",
"is_delete": false,
"is_new": true,
"create_id": "1",
"create_name": "管理员",
"create_time": "2024-02-28 10:07:32",
"update_id": "1",
"update_name": "管理员",
"update_time": "2024-03-28 10:09:43",
"is_urgent": false,
"operator": "管理员",
"customer": "",
"inspector": null,
"qualified_qty": 0,
"unqualified_qty": 0,
"material_name": null,
"material_code": null,
"material_spec": null,
"half_material_code": null,
"order_no": null,
"custer_no": null,
"order_subnum": 0,
"guadansum": 0,
"pack_method": null,
"order_number": null,
"product_code": null,
"material_model": null
},
{
"workorder_id": "1762660775601770496",
"workorder_code": "2402280031",
"plan_qty": 0,
"real_qty": 66,
"plan_weight": 1000,
"real_weight": 33,
"real_new_weight": 0,
"real_old_weight": 0,
"material_ratio": 0,
"material_id": "1771048061557149696",
"raw_material_code": "111",
"produce_order": null,
"batch_no": null,
"team": null,
"produce_date": "20240307",
"vehicle_type": "LZ",
"planproducestart_date": "2024-02-28 10:07:28",
"planproduceend_date": "2024-02-29 00:00:00",
"realproducestart_date": "2024-03-22 17:10:37",
"realproduceend_date": "2024-03-22 17:40:58",
"standing_time": 1,
"point_code": "HNJ01",
"point_name": "混碾机01",
"region_code": "HN",
"region_name": "混碾区域",
"workorder_status": "5",
"is_needmove": true,
"workorder_type": "1",
"production_order": null,
"passback_status": null,
"workshop_code": null,
"ext_id": null,
"ext_data": "0",
"is_delete": false,
"is_new": true,
"create_id": "1",
"create_name": "管理员",
"create_time": "2024-02-28 10:07:32",
"update_id": "1",
"update_name": "管理员",
"update_time": "2024-03-28 10:09:43",
"is_urgent": false,
"operator": "管理员",
"customer": "",
"inspector": null,
"qualified_qty": 0,
"unqualified_qty": 0,
"material_name": null,
"material_code": null,
"material_spec": null,
"half_material_code": null,
"order_no": null,
"custer_no": null,
"order_subnum": 0,
"guadansum": 0,
"pack_method": null,
"order_number": null,
"product_code": null,
"material_model": null
}
]
return res
}
// 拆包机下料位满料入货架
export const cbjmlTask = () => {
let res = {"message":"满料入库请求成功"}
return res
}
// 拆包机下料位叫空蛊
export const cbjqkTask = () => {
let res = {"message":"空蛊出库请求成功"}
return res
}
// 压机上料位下拉框
export const yjslwPointList = () => {
let res = [
{
"value": "YJ01SLW01",
"text": "压机01上料位01"
},
{
"value": "YJ01SLW02",
"text": "压机01上料位02"
},
{
"value": "YJ02SLW01",
"text": "压机02上料位01"
},
{
"value": "YJ02SLW02",
"text": "压机02上料位02"
},
{
"value": "YJ03SLW01",
"text": "压机03上料位01"
},
{
"value": "YJ03SLW02",
"text": "压机03上料位02"
},
{
"value": "YJ04SLW01",
"text": "压机04上料位01"
},
{
"value": "YJ04SLW02",
"text": "压机04上料位02"
},
{
"value": "YJ05SLW01",
"text": "压机05上料位01"
},
{
"value": "YJ05SLW02",
"text": "压机05上料位02"
},
{
"value": "YJ06SLW01",
"text": "压机06上料位01"
},
{
"value": "YJ06SLW02",
"text": "压机06上料位02"
},
{
"value": "YJ07SLW01",
"text": "压机07上料位01"
},
{
"value": "YJ07SLW02",
"text": "压机07上料位02"
},
{
"value": "YJ08SLW01",
"text": "压机08上料位01"
},
{
"value": "YJ08SLW02",
"text": "压机08上料位02"
},
{
"value": "YJ09SLW01",
"text": "压机09上料位01"
},
{
"value": "YJ09SLW02",
"text": "压机09上料位02"
}
]
return res
}
// 压机上料位强制回货架
export const qzhhjTask = (code) => {
let res = {"message":"压制上料位强制回库请求成功"}
return res
}
// 查询货架上已拆包料盅信息
export const packShelfInfo = () => {
let res = [
{
"pointCode": "KLHW10",
"materialCode": "MT-14AT",
"instorageTime": "2024-04-07 16:08:59"
}
]
return res
}
// 困料货架点对点到布料机上料位
export const yzqlTask = (sp, ep) => {
let res = {
"message": "布料机上料位请求成功"
}
return res
}
// 物料报废
export const materialScrap = () => {
let res = {"message":"物料作废成功"}
return res
}
// 查询人工分拣点位
export const rgfjPoint = () => {
let res = [
{
"value": "RGFJC01",
"text": "人工分拣拆01"
},
{
"value": "RGFJC02",
"text": "人工分拣拆02"
},
{
"value": "RGFJC03",
"text": "人工分拣拆03"
},
{
"value": "RGFJC04",
"text": "人工分拣拆04"
},
{
"value": "RGFJC05",
"text": "人工分拣拆05"
},
{
"value": "RGFJC06",
"text": "人工分拣拆06"
}
]
return res
}
// 查询缓存货架点位
export const hchjPoint = () => {
let res = [
{
"value": "HCHJ01",
"text": "缓存货架01"
},
{
"value": "HCHJ02",
"text": "缓存货架02"
},
{
"value": "HCHJ03",
"text": "缓存货架03"
},
{
"value": "HCHJ04",
"text": "缓存货架04"
},
{
"value": "HCHJ05",
"text": "缓存货架05"
},
{
"value": "HCHJ06",
"text": "缓存货架06"
},
{
"value": "HCHJ07",
"text": "缓存货架07"
},
{
"value": "HCHJ08",
"text": "缓存货架08"
},
{
"value": "HCHJ09",
"text": "缓存货架09"
},
{
"value": "HCHJ10",
"text": "缓存货架10"
},
{
"value": "HCHJ11",
"text": "缓存货架11"
},
{
"value": "HCHJ12",
"text": "缓存货架12"
},
{
"value": "HCHJ13",
"text": "缓存货架13"
},
{
"value": "HCHJ14",
"text": "缓存货架14"
},
{
"value": "HCHJ15",
"text": "缓存货架15"
},
{
"value": "HCHJ16",
"text": "缓存货架16"
},
{
"value": "HCHJ17",
"text": "缓存货架17"
},
{
"value": "HCHJ18",
"text": "缓存货架18"
},
{
"value": "HCHJ19",
"text": "缓存货架19"
},
{
"value": "HCHJ20",
"text": "缓存货架20"
},
{
"value": "HCHJ21",
"text": "缓存货架21"
},
{
"value": "HCHJ22",
"text": "缓存货架22"
},
{
"value": "HCHJ23",
"text": "缓存货架23"
},
{
"value": "HCHJ24",
"text": "缓存货架24"
},
{
"value": "HCHJ25",
"text": "缓存货架25"
},
{
"value": "HCHJ26",
"text": "缓存货架26"
},
{
"value": "HCHJ27",
"text": "缓存货架27"
},
{
"value": "HCHJ28",
"text": "缓存货架28"
},
{
"value": "HCHJ29",
"text": "缓存货架29"
},
{
"value": "HCHJ30",
"text": "缓存货架30"
},
{
"value": "HCHJ31",
"text": "缓存货架31"
},
{
"value": "HCHJ32",
"text": "缓存货架32"
},
{
"value": "HCHJ33",
"text": "缓存货架33"
},
{
"value": "HCHJ34",
"text": "缓存货架34"
},
{
"value": "HCHJ35",
"text": "缓存货架35"
},
{
"value": "HCHJ36",
"text": "缓存货架36"
},
{
"value": "HCHJ37",
"text": "缓存货架37"
},
{
"value": "HCHJ38",
"text": "缓存货架38"
},
{
"value": "HCHJ39",
"text": "缓存货架39"
},
{
"value": "HCHJ40",
"text": "缓存货架40"
},
{
"value": "HCHJ41",
"text": "缓存货架41"
},
{
"value": "HCHJ42",
"text": "缓存货架42"
},
{
"value": "HCHJ43",
"text": "缓存货架43"
},
{
"value": "HCHJ44",
"text": "缓存货架44"
}
]
return res
}
// 人工分拣叫料
export const rgfjqlTask = (sp, code) => {
let res = {"message":"人工分拣缺料请求成功"}
return res
}
// 人工分拣送空盘
export const rgfjskTask = (code) => {
let res = {"message":"人工分拣送空请求成功"}
return res
}
// 任务管理
export const handTasks = (key, scode, ncode) => {
let res = {
"result": [
{
"material_type": "",
"task_status": "1",
"carrier": "0033",
"task_no": "1800358896351711233",
"create_time": "2024-06-11 10:47:33",
"task_status_name": "执行中",
"next_devicecode": "HCHJ01",
"start_devicecode": "CYHCX39",
"material_type_name": "",
"task_uuid": "718e14a17b744a81bc51a51945355daa",
"task_type": "1",
"priority": "1"
},
{
"material_type": "",
"task_status": "1",
"carrier": "3010",
"task_no": "1800768187059539969",
"create_time": "2024-06-12 13:56:04",
"task_status_name": "执行中",
"next_devicecode": "HNJ03DJW",
"start_devicecode": "KLHW19",
"material_type_name": "",
"task_uuid": "f8e5ab3341f64bee887f4acaf403a4be",
"task_type": "1",
"priority": "1"
},
{
"material_type": "",
"task_status": "1",
"carrier": "3011",
"task_no": "1800771496990347265",
"create_time": "2024-06-12 14:06:44",
"task_status_name": "执行中",
"next_devicecode": "KLHW36",
"start_devicecode": "HNJ03DJW",
"material_type_name": "",
"task_uuid": "177eb5d976d245efbe3d5d56c8e93e22",
"task_type": "1",
"priority": "1"
},
{
"material_type": "",
"task_status": "1",
"carrier": "4011",
"task_no": "1800773119993057281",
"create_time": "2024-06-12 14:15:54",
"task_status_name": "执行中",
"next_devicecode": "HNJ04DJW",
"start_devicecode": "KLHW23",
"material_type_name": "",
"task_uuid": "29053a22a18b489eb0af483d897c0468",
"task_type": "1",
"priority": "1"
},
{
"material_type": "",
"task_status": "1",
"carrier": "0030",
"task_no": "1800819807675879425",
"create_time": "2024-06-12 17:18:44",
"task_status_name": "执行中",
"next_devicecode": "RYHCX01",
"start_devicecode": "YJ02XLW02",
"material_type_name": "",
"task_uuid": "6f8642c70ee14bfc8d2699477fa977c7",
"task_type": "1",
"priority": "1"
},
{
"material_type": "",
"task_status": "0",
"carrier": "",
"task_no": "1800820183942696961",
"create_time": "2024-06-12 17:20:14",
"task_status_name": "就绪",
"next_devicecode": "YJ02XLW02",
"start_devicecode": "CPJCK",
"material_type_name": "",
"task_uuid": "f41e5bfb7b32472fa940a8085c1e6d5e",
"task_type": "1",
"priority": "1"
}
],
"code": "1",
"desc": "查询成功"
}
return res
}
// 1.2 任务操作
export const handTaskoperation = (type, id) => {
let res = {
"message": "001"
}
return res
}
// 指令管理
export const handInsts = () => {
let res = {
"data": [
{
"task_no": "-087",
"inst_status": "2",
"create_time": "2024-03-28 10:54:39",
"carrier": '001',
"carno": '1号车',
"inst_uuid": "012bc5e653ce48949020f1147333aa7f",
"inst_step": "3",
"instruction_code": '11100',
"next_devicecode": "L1",
"start_devicecode": "RKSSX2",
"instruction_code": "163",
"priority": "1"
}
],
"message": "操作成功"
}
return res
}
export const handInst = (code) => {
let res = {
"message": "001"
}
return res
}

245
utils/permission.js Normal file
View 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
}
export default permission

131
utils/request.js Normal file
View File

@@ -0,0 +1,131 @@
// import qs from 'qs' // 处理data
import store from '@/vuex/store'
const request = (params) => {
let _self = this;
let url = params.url;
let method = params.method || 'POST';
let data = params.data || {};
let acsurl = params.acsurl
// data.token = "default-access_token"
// if (!params.token) {
// let token = uni.getStorageSync('token');
// if (!token) {
// uni.navigateTo({
// url: '/pages/login/login'
// });
// } else {
// data.token = '179509245-9c91827e0224bdc18d0b118b8be1b5af';
// }
// }
let token = ''
if (store.getters.saveToken !== '') {
token = store.getters.saveToken
}
let defaultOpot = {
// 'Content-Type': 'application/x-www-form-urlencoded',
'Terminal-Type': 'innerH5',
'Content-Type': 'application/json;charset=UTF-8',
}
let header = {}
method = method.toUpperCase()
if (method == 'POST') {
header = {
'Content-Type': 'application/json;charset=UTF-8',
'Authorization': token
}
// data = qs.stringify(data)
}
let requestUrl = `${store.getters.baseUrl}/` + url;
if (acsurl) {
requestUrl = `${store.getters.acsUrl}/` + url;
}
uni.showLoading({
title: '加载中...'
});
return new Promise((resolve, reject) => {
uni.request({
url: requestUrl,
method: method,
header: Object.assign({}, defaultOpot, header),
data: data,
dataType: 'json',
})
.then(res => { // 成功
if (res.length === 1) {
uni.showModal({
content: 'request:fail',
showCancel: false
})
reject('request:fail')
} else if (res[1] && res[1].statusCode === 400) {
uni.showModal({
content: res[1].data.message,
showCancel: false
})
reject(res[1].data.message)
} else if (res[1] && res[1].statusCode === 401) {
uni.showModal({
content: res[1].data.message,
showCancel: false
})
store.dispatch('delUserInfo', '')
uni.redirectTo({
url: '/pages/login/login'
})
} else if (res[1] && res[1].statusCode === 200) {
let {
data: dataType
} = res[1]
resolve(dataType)
// switch (dataType.code * 1) { // 拦截返回参数
// case 0:
// resolve(dataType)
// break;
// case 1003:
// uni.showModal({
// title: '登录已过期',
// content: '很抱歉,登录已过期,请重新登录',
// confirmText: '重新登录',
// success: function(res) {
// if (res.confirm) {
// uni.navigateTo({
// // 切记这儿需要哈pages.json保持一致不能有.vue后缀
// url: '/pages/login/login'
// });
// } else if (res.cancel) {
// console.log('用户点击取消');
// }
// }
// })
// break;
// case -1:
// uni.showModal({
// title: '请求数据失败',
// content: '获取数据失败!',
// confirmText: '确定',
// showCancel: false,
// success: function(res) {
// if (res.confirm) {} else if (res.cancel) {
// console.log('用户点击取消');
// }
// }
// })
// break
// }
}else {
uni.showModal({
content: res[1].data.message,
showCancel: false
})
reject(res[1].data.message)
}
})
.catch(err => { // 错误
reject(err)
})
.finally(() => {
uni.hideLoading();
})
})
}
export default request

39
utils/utils.js Normal file
View File

@@ -0,0 +1,39 @@
/**
* yy-mm-dd
*/
export const dateFtt = date => {
if (date == null) {
return ''
}
let year = date.getFullYear()
let month = date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1
let day = date.getDate() < 10 ? '0' + date.getDate() : date.getDate()
return `${year}-${month}-${day}`
}
/**
* yy-mm-dd hh:mm:ss
*/
export const dateTimeFtt = date => {
if (date == null) {
return ''
}
let year = date.getFullYear()
let month = date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1
let day = date.getDate() < 10 ? '0' + date.getDate() : date.getDate()
let hh = date.getHours() < 10 ? '0' + date.getHours() : date.getHours()
let mm = date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()
let ss = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds()
return `${year}-${month}-${day} ${hh}:${mm}:${ss}`
}
/**
* 将字符串形式的日期转换成日期对象
*/
export const dateNew = date => {
if (date === undefined || date === 'undefined') {
return new Date()
}
return new Date(Date.parse(date))
}