import tui from '@/common/httpRequest' // 手机正则 export function reg(params1, params2) { let phone = '' let code = '' let ret = /^1(3\d|4[5-9]|5[0-35-9]|6[567]|7[0-8]|8\d|9[0-35-9])\d{8}$/ // 手机正则 let intPattern = /^[0-9]*$/ // 整数正则 if (params1 === '') { uni.showToast({ title: '请输入手机号', icon: "none" }) } else if (!ret.test(params1)) { uni.showToast({ title: '手机号不正确', icon: "none" }) } else if (params2 === 0) { uni.showToast({ title: '获取验证码', icon: "none" }) } else if (params2 === '') { uni.showToast({ title: '请输入验证码', icon: "none" }) } else if (params2 !== 0 && !intPattern.test(params2)) { uni.showToast({ title: '验证码不正确', icon: "none" }) } else if (params2 !== 0 && intPattern.test(params2)) { phone = ret code = intPattern } else { phone = ret code = intPattern } return phone, code } //名称脱敏 export function maskShopName(str) { var reg = /^(.).+(.)$/g; if (str != null && str != "") { if (str.length < 4) { str = str.replace(reg, "$1*$2"); } else { str = str.replace(reg, "$1***$2"); } } return str; } //电话脱敏 export function maskPhone(phone) { return phone.replace(/(\d{3})\d{4}(\d{4})/, '$1****$2'); } /** * 省市区、自治区分割 */ export function getArea(str) { let area = {}; //最终返回的地址 let un_pro_str = ''; //去掉省以后的地址 let un_city_str = ''; //去掉市以后的地址 // 第一个区域(省)截取开始 let _dominion = str.indexOf("自治区"); //自治区出现的位置(内蒙古自治区、广西壮族自治区、西藏自治区、宁夏回族自治区、新疆维吾尔自治区、) let _district = str.indexOf('行政区'); //特别行政区出现的位置(香港特别行政区、澳门特别行政区) let _province = str.indexOf("省"); //省出现的位置 let _city = str.indexOf('市'); //市出现的位置(北京市、天津市、上海市、重庆市) if (_dominion != -1) { //有自治区 area.province = str.substring(0, _dominion + 3) un_pro_str = str.substr(_dominion + 3); } else if (_province != -1) { //有省 area.province = str.substring(0, _province + 1) un_pro_str = str.substr(_province + 1); } else if (_district != -1) { //有行政区 area.province = str.substring(0, _district + 3) un_pro_str = str.substr(_district + 3); } else if (_city != -1) { //有市 area.province = str.substring(0, _city + 1) let deviceType uni.getSystemInfo({ success(res) { deviceType = res.osName } }) if (deviceType == 'android') { un_pro_str = str.substr(_city + 1); } else { un_pro_str = str } } // 第二个区域(市)截取开始 let _city1 = un_pro_str.indexOf('市'); //第二次出现市的位置 let _district1 = un_pro_str.indexOf('行政区'); //特别行政区出现的位置 let _county = un_pro_str.indexOf('县'); //县出现的位置 let _state = un_pro_str.indexOf('自治州'); //自治州出现的位置 let _region = un_pro_str.indexOf('区'); //区出现的位置 let _zoning = un_pro_str.indexOf('行政区划'); //行政区划出现的位置 let _alliance = un_pro_str.indexOf('盟'); //盟出现的位置 if (_zoning != -1) { //行政区划 area.city = un_pro_str.substring(0, _zoning + 4) un_city_str = un_pro_str.substr(_zoning + 4); } else if (_district1 != -1) { //行政区 area.city = un_pro_str.substring(0, _district1 + 3) un_city_str = un_pro_str.substr(_district1 + 3); } else if (_state != -1) { //自治州 area.city = un_pro_str.substring(0, _state + 3) un_city_str = un_pro_str.substr(_state + 3); } else if (_alliance != -1) { //盟 area.city = un_pro_str.substring(0, _alliance + 1) un_city_str = un_pro_str.substr(_alliance + 1); } else if (_city1 != -1) { //市 area.city = un_pro_str.substring(0, _city1 + 1) un_city_str = un_pro_str.substr(_city1 + 1); } else if (_region != -1) { //区 area.city = un_pro_str.substring(0, _region + 1) un_city_str = un_pro_str.substr(_region + 1); } else if (_county != -1) { //县 area.city = un_pro_str.substring(0, _county + 1) un_city_str = un_pro_str.substr(_county + 1); } var reg = /.+?(市|县|区|旗)/g; var aaa; aaa = un_city_str.match(reg); area.country = aaa[0]; var xiangxi = str.substring(str.indexOf(aaa[0]) + 3) area.address = xiangxi return area; } //生成短随机数 export function generateUUID() { let timestamp = new Date().getTime(); let uuid = 'xxxxxxxx4xxxyxxxxxx'.replace(/[xy]/g, function(c) { let r = (timestamp + Math.random() * 8) % 16 | 0; timestamp = Math.floor(timestamp / 16); return (c === 'x' ? r : (r & 0x3 | 0x8)).toString(16); }); return uuid; } //微信登录 export function wxLogin(customId,userId) { let that = this; uni.login({ provider: 'weixin', success(res) { uni.getUserInfo({ provider: 'weixin', success: function(infoRes) { tui.request("/user/login", "post", { jsCode: res.code, customId: customId, userId:userId, wechatName: infoRes.userInfo.nickName, userType: "2" }, false, false).then((res) => { if (res.code == 200) { uni.setStorageSync("hiver_token", res.result.accessToken) uni.setStorageSync("wayValue", "2") uni.setStorageSync("nickname", res.result.user.nickname) uni.setStorageSync("id", res.result.user.id) uni.setStorageSync('unionid', res.result.user.unionid) uni.setStorageSync('miniProgramOpenid', res.result.user .miniProgramOpenid) uni.setStorageSync('officialAccountOpenid', res.result.user .officialAccountOpenid) } else { tui.toast(res.message) } }).catch((res) => {}) } }); } }); return true } //洗涤说明 export function washingInstructions() { let list = [{ text: '禁止机洗', value: 'https://jewel-shop.oss-cn-beijing.aliyuncs.com/8e3c17467f3a4fda8990d287c5df69fc.png' }, { text: '不可干洗', value: 'https://jewel-shop.oss-cn-beijing.aliyuncs.com/737996f879844d36ad10fd9ab0809c0a.png' }, { text: '不可烘干', value: 'https://jewel-shop.oss-cn-beijing.aliyuncs.com/ef95a537642a479dbeda639469a80aeb.png' }, { text: '不可漂白', value: 'https://jewel-shop.oss-cn-beijing.aliyuncs.com/1ea72e5376714a7fa0419e7dac276ce5.png' }, { text: '不可熨烫', value: 'https://jewel-shop.oss-cn-beijing.aliyuncs.com/7ea3e4ede0fe485a876ac99a680b5f83.png' }, { text: '滴干', value: 'https://jewel-shop.oss-cn-beijing.aliyuncs.com/d04b0f9033c84b4395beff16937598b0.png' }, { text: '禁拧干', value: 'https://jewel-shop.oss-cn-beijing.aliyuncs.com/fdfda192fcc4413680e3715434dda0e9.png' }, { text: '可干洗', value: 'https://jewel-shop.oss-cn-beijing.aliyuncs.com/74967ee39fbb4d78b62199ae510e915e.png' }, { text: '可烘干', value: 'https://jewel-shop.oss-cn-beijing.aliyuncs.com/0ae66f5c30bb450fb17bf92c8ea2e6f0.png' }, { text: '可漂白', value: 'https://jewel-shop.oss-cn-beijing.aliyuncs.com/f660498771bc41cd985d9257c95863eb.png' }, { text: '可熨烫', value: 'https://jewel-shop.oss-cn-beijing.aliyuncs.com/d932cf4ab23d4bc9a29cbdb057c45642.png' }, { text: '拧干', value: 'https://jewel-shop.oss-cn-beijing.aliyuncs.com/35f53861b02e4007a9c34ef358c6cf9f.png' }, { text: '轻质洗涤剂', value: 'https://jewel-shop.oss-cn-beijing.aliyuncs.com/50d95cfe14ef4ae9a4a2bd9dc59b9a32.png' }, { text: '上衣', value: 'https://jewel-shop.oss-cn-beijing.aliyuncs.com/3ca734e1fa1e4e00809540a8e2694038.png' }, { text: '手洗', value: 'https://jewel-shop.oss-cn-beijing.aliyuncs.com/f5309f5656cd4ed38d86d799a8709260.png' }, { text: '不能水洗', value: 'https://jewel-shop.oss-cn-beijing.aliyuncs.com/da34ad44a7a64d829d16b152818bbe70.png' }, { text: '最高洗涤温度30度', value: 'https://jewel-shop.oss-cn-beijing.aliyuncs.com/6379c5f7f2664d24a8fc267ffad4fb90.png' }, { text: '最高洗涤温度40度', value: 'https://jewel-shop.oss-cn-beijing.aliyuncs.com/6c3d2ddcc8be4f659a827027d783ee1b.png' }, { text: '最高洗涤温度50度', value: 'https://jewel-shop.oss-cn-beijing.aliyuncs.com/5bb0eb8da3da43fcabc43182eede0f3d.png' }, { text: '最高洗涤温度60度', value: 'https://jewel-shop.oss-cn-beijing.aliyuncs.com/5c38b33ee5ec4a4a9531e0fb1061d783.png' }, { text: '最高洗涤温度70度', value: 'https://jewel-shop.oss-cn-beijing.aliyuncs.com/bc72724fe20b4b799c7cb83f98253040.png' }, { text: '最高洗涤温度95度', value: 'https://jewel-shop.oss-cn-beijing.aliyuncs.com/77eb86cc136145cf9e0f2920c756aac3.png' }, { text: '所有干洗剂', value: 'https://jewel-shop.oss-cn-beijing.aliyuncs.com/82bd257888044a5b9f1b6878c0123300.png' }, { text: '温和干洗', value: 'https://jewel-shop.oss-cn-beijing.aliyuncs.com/57985986ddaf4e8cbf17d1f08bc7e646.png' }, { text: '勿蒸汽熨烫', value: 'https://jewel-shop.oss-cn-beijing.aliyuncs.com/e45868c231b342429f6543b402d6fecb.png' }, { text: '洗涤时间要短', value: 'https://jewel-shop.oss-cn-beijing.aliyuncs.com/4c40c8cd61b64823a8e0e6301714089a.png' }, { text: '需垫布熨烫', value: 'https://jewel-shop.oss-cn-beijing.aliyuncs.com/eb1b5ac89785452ca15efa005480a7df.png' }, { text: '悬挂晾干', value: 'https://jewel-shop.oss-cn-beijing.aliyuncs.com/52466409f4b443538632211e3ebaec20.png' }, { text: '熨烫温度不超过110度', value: 'https://jewel-shop.oss-cn-beijing.aliyuncs.com/08cd9750f4684a90a24159f15f9288fd.png' }, { text: '蒸汽熨烫', value: 'https://jewel-shop.oss-cn-beijing.aliyuncs.com/88a72117ef034093ac219264c6151748.png' }, { text: '悬挂干燥', value: 'https://jewel-shop.oss-cn-beijing.aliyuncs.com/15740da372ae4652a57d7f06c4602c09.png' }, { text: '阴凉挂干', value: 'https://jewel-shop.oss-cn-beijing.aliyuncs.com/81697e06de2d4d01bc75be6faba0c0e8.png' }, { text: '自然干燥', value: 'https://jewel-shop.oss-cn-beijing.aliyuncs.com/54164c3d8c3e4483bf635a102bf2fbb4.jpg' }, { text: '悬挂阴干', value: 'https://jewel-shop.oss-cn-beijing.aliyuncs.com/e73b0d9c2a1b44d3a12fe19f37de9fd2.jpg' }, { text: '低温干洗', value: 'https://jewel-shop.oss-cn-beijing.aliyuncs.com/610b2bc446684a8fb253f0ae080e78c7.jpg' }, { text: '使用含氟漂白剂', value: 'https://jewel-shop.oss-cn-beijing.aliyuncs.com/8fc81f4e78484af48ef29ab94b851c8d.jpg' }, { text: '不可使用含氟漂白剂', value: 'https://jewel-shop.oss-cn-beijing.aliyuncs.com/08f56726d4594de88fc9b524312557c8.jpg' }, { text: '可水洗', value: 'https://jewel-shop.oss-cn-beijing.aliyuncs.com/7ca7dfb8fe2f4a00960c1ea505e0a517.jpg' }, ] return list; }