import * as config from '../config' const rolesList = [] const ossUploadUrl = 'https://taohaoliang.oss-cn-beijing.aliyuncs.com/'; const chooseImage = { count: '1', sizeType: ['original', 'compressed'], sourceType: ['album'], } const imgType = '请选择图片来源' const imgTypeList = [{ name: '相册', }, { name: '拍照', } ] const makeValidityPeriod = function(type,name) { //获取当前年 let nowDate = new Date(); let year = nowDate.getFullYear() let _list = [] let _list1 = [] // let _list2 = ["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"] let _list2 = ["01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"] let _list3 = ["01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31" ] let _ValidityPeriod = [] for (let i = 0; i < 30; i++) { _list1.push(year + i) } if (type == 0) { _list1.unshift(name) _list2.unshift('') _list3.unshift('') } _list.push(_list1, _list2, _list3) return _list } const getListByUserId = function() { let baseUrlNew = config.def().baseUrlNew var userInfo = uni.getStorageSync("userInfo") console.log("------", userInfo) if (userInfo) { uni.request({ url: baseUrlNew + '/roleMenu/query/getListByUserId', data: { userId: userInfo.id ? userInfo.id : userInfo.data.id }, method: 'GET', success: (res) => { if (res.statusCode === 200) { uni.setStorageSync("jurisdiction", res.data.data) let list = getUserAllRoles(res.data.data); uni.setStorageSync("rolesList", list) } } }) } } const getUserAllRoles = (item) => { console.log(item) for (let i = 0; i < item.length; i++) { rolesList.push(item[i].name) // console.log('用户权限',rolesList) if (item[i].children && item[i].children.length > 0) { getUserAllRoles(item[i].children) } } return rolesList; } const setAudit = (item) => { let _list = uni.getStorageSync("copyTaskInfo") let _isShowbtn = true if (_list.length == 0) { _isShowbtn = false } for (let i = 0; i < _list.length; i++) { if (_list[i].businessId == item.id) { _list.splice(i, 1) uni.setStorageSync("copyTaskInfo", _list) } } if (_list.length > 0) { uni.navigateTo({ url: _list[0].itemUrl + '&isShowbtn=' + _isShowbtn, }) } console.log(item) } const contactCustomerService = (item) => { console.log(item) console.log("联系客服") uni.makePhoneCall({ phoneNumber: '114' //仅为示例 }); } // const getAddress = (item) => { // let regex = "(?[^省]+省|.+自治区)(?[^自治州]+自治州|[^市]+市|[^盟]+盟|[^地区]+地区|.+区划)(?[^市]+市|[^县]+县|[^旗]+旗|.+区)?(?[^区]+区|.+镇)?(?.*)"; // return item.match(regex).groups // } const formatLocation = (res) => { var regex = /^(北京市|天津市|重庆市|上海市|香港特别行政区|澳门特别行政区)/; var REGION_PROVINCE = []; var addressBean = { REGION_PROVINCE: null, REGION_COUNTRY: null, REGION_CITY: null, ADDRESS: null }; function regexAddressBean(address, addressBean) { // regex = /^(.*?[市州]|.*?地区|.*?特别行政区)(.*?[市区县])(.*?)$/g; regex = /^(.*?[市]|.*?地区|.*?特别行政区)(.*?[市区县])(.*?)$/g; var addxress = regex.exec(address); addressBean.REGION_CITY = addxress[1]; addressBean.REGION_COUNTRY = addxress[2]; addressBean.ADDRESS = addxress[3] + "(" + res.name + ")"; // console.log(addxress); }; if (!(REGION_PROVINCE = regex.exec(res.address))) { regex = /^(.*?(省|自治区))(.*?)$/; REGION_PROVINCE = regex.exec(res.address); addressBean.REGION_PROVINCE = REGION_PROVINCE[1]; regexAddressBean(REGION_PROVINCE[3], addressBean); } else { addressBean.REGION_PROVINCE = REGION_PROVINCE[1]; regexAddressBean(res.address, addressBean); } return addressBean } //获取省份简称 const getProvinceAbbreviation = (province) => { // console.log(province) if (province == "北京市" || province == "北京") return "京"; else if (province == "天津市" || province == "天津") return "津"; else if (province == "重庆市" || province == "重庆") return "渝"; else if (province == "上海市" || province == "上海") return "沪"; else if (province == "河北省" || province == "河北") return "冀"; else if (province == "山西省" || province == "山西") return "晋"; else if (province == "辽宁省" || province == "辽宁") return "辽"; else if (province == "吉林省" || province == "吉林") return "吉"; else if (province == "黑龙江省" || province == "黑龙江") return "黑"; else if (province == "江苏省" || province == "江苏") return "苏"; else if (province == "浙江省" || province == "浙江") return "浙"; else if (province == "安徽省" || province == "安徽") return "皖"; else if (province == "福建省" || province == "福建") return "闽"; else if (province == "江西省" || province == "江西") return "赣"; else if (province == "山东省" || province == "山东") return "鲁"; else if (province == "河南省" || province == "河南") return "豫"; else if (province == "湖北省" || province == "湖北") return "鄂"; else if (province == "湖南省" || province == "湖南") return "湘"; else if (province == "广东省" || province == "广东") return "粤"; else if (province == "海南省" || province == "海南") return "琼"; else if (province == "四川省" || province == "四川") return "川"; else if (province == "贵州省" || province == "贵州") return "贵"; else if (province == "云南省" || province == "云南") return "云"; else if (province == "陕西省" || province == "陕西") return "陕"; else if (province == "甘肃省" || province == "甘肃") return "甘"; else if (province == "青海省" || province == "青海") return "青"; else if (province == "台湾省" || province == "台湾") return "台"; else if (province == "内蒙古自治区" || province == "内蒙古") return "蒙"; else if (province == "广西壮族自治区" || province == "广西") return "桂"; else if (province == "宁夏回族自治区" || province == "宁夏") return "宁"; else if (province == "新疆维吾尔自治区" || province == "新疆") return "新"; else if (province == "西藏自治区" || province == "西藏") return "藏"; else if (province == "香港特别行政区" || province == "香港") return "港"; else if (province == "澳门特别行政区" || province == "澳门") return "澳"; } export default { getListByUserId, setAudit, ossUploadUrl, contactCustomerService, chooseImage, imgType, imgTypeList, makeValidityPeriod, getProvinceAbbreviation, // getAddress, formatLocation }