From 81a2174045a91636fec0536323eac429ef8248a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=83=E8=82=89=E7=9A=84=E9=A5=BA=E5=AD=90?= <2659004835@qq.com> Date: Sun, 17 Apr 2022 19:57:56 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=EF=BC=88=E7=94=B5=E9=87=8F?= =?UTF-8?q?=E6=A0=8F=EF=BC=8C=E7=8A=B6=E6=80=81=E6=A0=8F=EF=BC=8C=E4=B8=BB?= =?UTF-8?q?=E4=BD=93=E5=86=85=E5=AE=B9=EF=BC=89=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/containers/status-container.vue | 71 ++++ components/status-navs/status-nav.vue | 2 +- jsFile/map/yaya-map.js | 190 +++++++++++ jsFile/share.js | 8 +- jsFile/time/yaya-time.js | 202 +++++++++++ jsFile/tools.js | 369 +++++---------------- pages.json | 23 +- pagesA/my-address/my-address.vue | 114 ++++--- pagesA/test/test.vue | 22 -- 9 files changed, 617 insertions(+), 384 deletions(-) create mode 100644 components/containers/status-container.vue create mode 100644 jsFile/map/yaya-map.js create mode 100644 jsFile/time/yaya-time.js delete mode 100644 pagesA/test/test.vue diff --git a/components/containers/status-container.vue b/components/containers/status-container.vue new file mode 100644 index 0000000..dbcac84 --- /dev/null +++ b/components/containers/status-container.vue @@ -0,0 +1,71 @@ + + + + + diff --git a/components/status-navs/status-nav.vue b/components/status-navs/status-nav.vue index 5791bde..c0f0af6 100644 --- a/components/status-navs/status-nav.vue +++ b/components/status-navs/status-nav.vue @@ -9,7 +9,7 @@ - + diff --git a/jsFile/map/yaya-map.js b/jsFile/map/yaya-map.js new file mode 100644 index 0000000..1dd84ed --- /dev/null +++ b/jsFile/map/yaya-map.js @@ -0,0 +1,190 @@ +const tools = require('../tools.js') +// 解决微信小程序 +var QQMapWX = require('./qqmap-wx-jssdk.min.js'); +// 腾讯地图 +var qqmapsdk = new QQMapWX({ + key: 'QNHBZ-55RKF-OMFJJ-NPU7O-EPSDH-ACBAA' +}); +// 解决H5跨域 +const jsonp = function(url, data) { + return new Promise((resolve, reject) => { + // 1.初始化url + let dataString = url.indexOf('?') === -1 ? '?' : '&' + let callbackName = `jsonpCB_${ Date.now() }`; + url += `${ dataString }callback=${ callbackName }` + if(data) { + // 2.有请求参数,依次添加到url + for(let k in data) { + url += `&${ k }=${ data[k] }` + } + } + let scriptNode = document.createElement('script'); + scriptNode.src = url; + // 3. callback + window[callbackName] = (result) => { + result ? resolve(result) : reject('没有返回数据'); + delete window[callbackName]; + document.body.removeChild(scriptNode); + } + // 4. 异常情况 + scriptNode.addEventListener('error', () => { + reject('接口返回数据失败'); + delete window[callbackName]; + document.body.removeChild(scriptNode); + }, false) + // 5. 开始请求 + document.body.appendChild(scriptNode) + }) +} +const yayaMap = { + // 平台判断 + platformEv(){ + // #ifdef APP-PLUS + this.getAddress(); + // #endif + // #ifdef MP-WEIXIN + this.getAddressWx(); + // #endif + // #ifdef H5 + this.getAddressH5(); + // #endif + }, + /** + * @description app获取经纬度和详细地址方法 + */ + getAddress(){ + uni.getLocation({ + type: 'gcj02', + geocode:true, + success: (res)=> { + // console.log(res,'地址信息'); + let params = { + latitude:res.latitude, + longitude:res.longitude, + address:`${res.address.province}${res.address.city}${res.address.district || ''}${res.address.street || ''}${res.address.streetNum || ''}${res.address.poiName || ''}` + } + console.log(params,'APP'); + } + }); + }, + /** + * @description 微信获取经纬度和详细地址方法 + */ + getAddressWx(){ + uni.getLocation({ + type: 'gcj02', + geocode:true, + success: (res)=> { + // console.log(res,'地址信息'); + qqmapsdk.reverseGeocoder({ + location: {latitude: res.latitude, longitude: res.longitude}, + success:(res)=> { + // console.log(res,'WX'); + let params = { + latitude:res.result.location.lat, + longitude:res.result.location.lng, + address:`${res.result.address}` + } + console.log(params,'WX'); + }, + fail(err) { + console.log(err) + } + }) + } + }); + }, + /** + * @description H5获取经纬度和详细地址方法 + */ + getAddressH5(){ + uni.showLoading({ + title: '定位中...', + mask:true + }); + uni.getLocation({ + type: 'gcj02', // wgs84 gcj02 + altitude: true, + // geocode: true, // wgs84 + success: (res)=> { + let str = `output=jsonp&key=QNHBZ-55RKF-OMFJJ-NPU7O-EPSDH-ACBAA&location=${res.latitude},${res.longitude}` + jsonp('https://apis.map.qq.com/ws/geocoder/v1/?'+str,{}).then(res=>{ + // console.log(res,'H5'); + uni.hideLoading(); + if(res.status == 0){ + // that.locationName = res.result.address; //当前定位 + let params = { + latitude:res.result.location.lat, + longitude:res.result.location.lng, + address:`${res.result.address}` + } + console.log(params,'H5'); + } + }) + } + }); + }, + /** + * @description 打开地图导航 + */ + openLocation(latitude,longitude,name,address){ + uni.openLocation({ + latitude: parseFloat(latitude), + longitude: parseFloat(longitude), + name:name, + address:address, + success: function () { + console.log('success'); + }, + fail:function(err){ + console.log(err) + } + }); + }, + /** + * @description 传入目的地的经纬度、地点名称、详细地址,打开地图导航到达目的地 + */ + goFlag:true, + goThere(latitude=30.656693,longitude=104.136425,name="大向天诚有限责任公司",address="四川省成都市成华区双店路B口"){ + if(this.goFlag){ + this.goFlag = false; + // #ifdef MP-WEIXIN + wx.getLocation({//获取当前经纬度 + type: 'wgs84', //返回可以用于wx.openLocation的经纬度,官方提示bug: iOS 6.3.30 type 参数不生效,只会返回 wgs84 类型的坐标信息 + success: (res)=> { + wx.openLocation({//​使用微信内置地图查看位置。 + latitude: parseFloat(latitude),//要去的纬度-地址 + longitude: parseFloat(longitude),//要去的经度-地址 + name: name, + address: address, + fail:err=>{ + tools.showToast('地址信息错误'); + } + }) + } + }) + // #endif + + // #ifdef APP-PLUS || H5 + uni.openLocation({ + latitude: parseFloat(latitude), + longitude: parseFloat(longitude), + name:name, + address:address, + success:()=> { + console.log('success'); + }, + fail:err=>{ + console.log(err) + } + }); + // #endif + setTimeout(()=>{ + this.goFlag = true; + },2000) + } else { + tools.showToast('请勿多次点击'); + } + } +} +export default yayaMap; \ No newline at end of file diff --git a/jsFile/share.js b/jsFile/share.js index c115a8f..be2f879 100644 --- a/jsFile/share.js +++ b/jsFile/share.js @@ -6,6 +6,12 @@ export default { } }, onShareTimeline(res) {//分享到朋友圈 - return {} + return { + title: '分享到朋友圈', + query: { + key: '参数' + }, + imageUrl: '', + } }, } \ No newline at end of file diff --git a/jsFile/time/yaya-time.js b/jsFile/time/yaya-time.js new file mode 100644 index 0000000..1582182 --- /dev/null +++ b/jsFile/time/yaya-time.js @@ -0,0 +1,202 @@ +const yayaTime = { + /** + * @description 获取未来七天星期几,几号 + */ + weekDate(){ + let date = new Date() + let year = date.getFullYear() + let month = date.getMonth()+1 + let day = date.getDate() + let nth = date.getDay()//星期几 + console.log(year,month,day,nth); + let xingq = ['周日','周一','周二','周三','周四','周五','周六'] + console.log(`${year}-${month}-${day} ${xingq[nth]}`); + }, + /** + * @description 将时间转换成几天前,几个月前,几小时前等 + */ + timeago(datetime) { + if(datetime == undefined || datetime == ''){ + return + } + var timePublish = new Date(datetime.replace(/-/gi, '/')); + var timeNow = new Date(); + var minute = 1000 * 60; + var hour = minute * 60; + var day = hour * 24; + var month = day * 30; + var result = "0"; + var diffValue = timeNow - timePublish; + var diffMonth = diffValue / month; + var diffWeek = diffValue / (7 * day); + var diffDay = diffValue / day; + var diffHour = diffValue / hour; + var diffMinute = diffValue / minute; + + if (diffValue < 0) { + console.log('错误时间') + } + else if (diffDay > 1) { + var year = timePublish.getFullYear(); + var month = timePublish.getMonth() + 1; + var date = timePublish.getDate(); + var hours = timePublish.getHours(); + var minutes = timePublish.getMinutes(); + var seconds = timePublish.getSeconds(); + if(month<=9){month = '0'+month} + if(date<=9){date = '0'+date} + if(hours<=9){hours = '0'+hours} + if(minutes<=9){minutes = '0'+minutes} + if(seconds<=9){seconds = '0'+seconds} + result = year+'-'+month+'-'+date; + + } + else if (diffMonth > 1) { + result = parseInt(diffMonth) + "月前"; + } + else if (diffWeek > 1) { + result = parseInt(diffWeek) + "周前"; + } + else if (diffDay > 1 ) { + result = parseInt(diffDay) + "天前"; + } + else if (diffHour > 1) { + result = parseInt(diffHour) + "小时前"; + } + else if (diffMinute > 1) { + result = parseInt(diffMinute) + "分钟前"; + } + else { + result = "刚刚"; + } + return result; + }, + /** + * @description 时间戳===>日期 + */ + timestampToTime(timestamp) { + var date = timestamp.toString().length==13 ? new Date(timestamp*1) : new Date(timestamp * 1000);//时间戳为10位需*1000,时间戳为13位的话不需乘1000 + var Y = date.getFullYear(); + var M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1); + var D = date.getDate() < 10 ? '0'+date.getDate() : date.getDate(); + var h = date.getHours() < 10 ? '0'+date.getHours() : date.getHours(); + var m = date.getMinutes() < 10 ? '0'+date.getMinutes() : date.getMinutes(); + var s = date.getSeconds() < 10 ? '0'+date.getSeconds() : date.getSeconds(); + return Y + '-' + M + '-' + D + ' ' + h + ':' + m + ':' +s; + }, + /** + * @description 返回当前时间 + */ + returnCurrentTime(format,type) { + let date = new Date(); + let year = date.getFullYear(); // 年 + let month = date.getMonth() + 1; // 月 + let day = date.getDate(); // 日 + let time = date.getHours(); // 时 + let minu = date.getSeconds(); // 分 + let second = date.getMinutes(); // 秒 + + let newTime = ''; + switch (type){ + case 0: + newTime = `${year}${format}${month < 10? '0' + month : month}${format}${day < 10 ? '0' + day : day} ${time < 10 ? '0' + time : time}:${minu < 10 ? '0' + minu : minu}`; // 2022-03-31 16:05 + break; + case 1: + newTime = `${year}${format}${month < 10? '0' + month : month}${format}${day < 10 ? '0' + day : day} ${time < 10 ? '0' + time : time}:${minu < 10 ? '0' + minu : minu}:${second < 10 ? '0' + second : second}`; // 2022-03-31 16:10:07 + break; + } + return newTime; + }, + /** + * @description 日期===>时间戳 + */ + timeToTimestamp(time){ + var date = new Date(time); + var timestamp = date.getTime();//精确到毫秒 + return timestamp + // var date = new Date('2014-04-23 18:55:49:123'); + // 有三种方式获取 + // var time1 = date.getTime();//精确到毫秒 + // var time2 = date.valueOf();//精确到毫秒 + // var time3 = Date.parse(date);//只能精确到秒,毫秒用000替代 + // console.log(time1);//1398250549123 + // console.log(time2);//1398250549123 + // console.log(time3);//1398250549000 + }, + /** + * @description 返回时间xx天xx小时xx分钟 + */ + returnTimeFormat(startTime,endTime){ + let currentTimestamp = this.timeToTimestamp(endTime) - this.timeToTimestamp(startTime); + let timeStr = ''; + var day = parseInt((currentTimestamp % (1000 * 60 * 60 * 24 * 12)) / (1000 * 60 * 60 * 24)); + var hours = parseInt((currentTimestamp % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)); + var seconds = parseInt((currentTimestamp % (1000 * 60 * 60)) / (1000 * 60)); + day = day < 10 ? ('0' + day) : day; + hours = hours < 10 ? ('0' + hours) : hours; + seconds = seconds < 10 ? ('0' + seconds) : seconds; + if(day*1==0) { + if(hours*1==0) { + seconds*1==0 ? timeStr = 0 : timeStr = `${seconds}分钟`; + } else { + timeStr = `${hours}小时${seconds}分钟`; + } + } else { + timeStr = `${day}天${hours}小时${seconds}分钟`; + } + return timeStr; + }, + /** + * @description 时间戳转时分秒 00 : 00 : 00 + */ + formatDuring(mss) { + // let dangTime = Math.round(new Date()/1000)//获取当前时间戳 + var hours = parseInt((mss % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)); + var seconds = parseInt((mss % (1000 * 60 * 60)) / (1000 * 60)); + var minutes = (mss % (1000 * 60)) / 1000; + hours = hours < 10 ? ('0' + hours) : hours; + seconds = seconds < 10 ? ('0' + seconds) : seconds; + minutes = minutes < 10 ? ('0' + minutes) : minutes; + return hours + ' : ' + seconds + ' : ' + minutes; + }, + /** + * @description 开启倒计时 + */ + dayTime(endTime,startTime=''){ + let totalSecond = ''; + // 本地倒计时 + // if(startTime=='') totalSecond = Math.floor((new Date(endTime).getTime() - new Date().getTime())/1000); + // 解决苹果手机问题 + let date = endTime; + date = endTime.replace(/-/g,'/') + // 服务器倒计时 + if(startTime!='') totalSecond = Math.floor((new Date(date).getTime() - startTime)/1000); + // 总秒数 + let second = totalSecond; + // 天数 + let day = Math.floor(second / 3600 / 24); + let dayStr = day.toString(); + if(dayStr.length == 1) dayStr = '0' + dayStr; + // 小时 + let hr = Math.floor((second - day * 3600 * 24) / 3600); + let hrStr = hr.toString(); + if(hrStr.length == 1) hrStr = '0' + hrStr; + // 分钟 + let min = Math.floor((second - day * 3600 * 24 - hr * 3600) / 60); + let minStr = min.toString(); + if(minStr.length == 1) minStr = '0' + minStr; + // 秒 + let sec = second - day * 3600 * 24 - hr * 3600 - min * 60; + let secStr = sec.toString(); + if(secStr.length == 1) secStr = '0' + secStr; + + let newTime = ''; + if(dayStr==0) { + newTime = hrStr +'时'+ minStr +'分'+ secStr +'秒'; + } else { + newTime = dayStr +'天'+ hrStr +'时'+ minStr +'分'+ secStr +'秒'; + } + return newTime; + }, +} +export default yayaTime; \ No newline at end of file diff --git a/jsFile/tools.js b/jsFile/tools.js index 5ca8e74..b98356c 100644 --- a/jsFile/tools.js +++ b/jsFile/tools.js @@ -1,7 +1,9 @@ const app = getApp(); const tools = { timer:'', - // 埋点倒计时 + /** + * @description 埋点倒计时 + */ daoTime(){ let daoTime = uni.getStorageSync('daoTime') if(daoTime==''){//初次判断倒计时是否为空 @@ -34,101 +36,38 @@ const tools = { clearInterval(this.timer)//关闭倒计时 console.log('倒计时清空了'); }, - weekDate(){//获取未来七天星期几,几号 - let date = new Date() - let year = date.getFullYear() - let month = date.getMonth()+1 - let day = date.getDate() - let nth = date.getDay()//星期几 - // console.log(year,month,day); - let xingq = ['周一','周二','周三','周四','周五','周六','周日'] - - }, - //将时间转换成几天前,几个月前,几小时前等 - timeago(datetime) { - if(datetime == undefined || datetime == ''){ - return - } - var timePublish = new Date(datetime.replace(/-/gi, '/')); - var timeNow = new Date(); - var minute = 1000 * 60; - var hour = minute * 60; - var day = hour * 24; - var month = day * 30; - var result = "0"; - var diffValue = timeNow - timePublish; - var diffMonth = diffValue / month; - var diffWeek = diffValue / (7 * day); - var diffDay = diffValue / day; - var diffHour = diffValue / hour; - var diffMinute = diffValue / minute; - - // console.log(datetime) - // console.log(timePublish) - // console.log(timeNow) - // console.log('diffValue:'+diffValue+' ' +'diffMonth:'+diffMonth+' ' +'diffWeek:'+diffWeek+' ' +'diffDay:'+diffDay+' ' +'diffHour:'+diffHour+' ' +'diffMinute:'+diffMinute); - - if (diffValue < 0) { - console.log('错误时间') - } - else if (diffDay > 1) { - var year = timePublish.getFullYear(); - var month = timePublish.getMonth() + 1; - var date = timePublish.getDate(); - var hours = timePublish.getHours(); - var minutes = timePublish.getMinutes(); - var seconds = timePublish.getSeconds(); - if(month<=9){month = '0'+month} - if(date<=9){date = '0'+date} - if(hours<=9){hours = '0'+hours} - if(minutes<=9){minutes = '0'+minutes} - if(seconds<=9){seconds = '0'+seconds} - // result = year+'-'+month+'-'+date+' '+hours+':'+minutes+':'+seconds - result = year+'-'+month+'-'+date; - - } - else if (diffMonth > 1) { - result = parseInt(diffMonth) + "月前"; - } - else if (diffWeek > 1) { - result = parseInt(diffWeek) + "周前"; - } - else if (diffDay > 1 ) { - result = parseInt(diffDay) + "天前"; - } - else if (diffHour > 1) { - result = parseInt(diffHour) + "小时前"; - } - else if (diffMinute > 1) { - result = parseInt(diffMinute) + "分钟前"; - } - else { - result = "刚刚"; - } - return result; - }, - // 手机号验证 + /** + * @description 手机号验证 + */ isPhone:function(phone){ // 手机号正则表达式 let reg_tel = /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/; return !reg_tel.test(phone); }, - // 电子邮箱验证 + /** + * @description 电子邮箱验证 + */ isEmail(email){ let reg_email = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/; return !reg_email.test(email); }, - // 身份证验证 + /** + * @description 身份证验证 + */ isIdentity(identity) { let reg_identity = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/; return !reg_identity.test(identity); }, - // 手机号中间四位用"****"带替 + /** + * @description 手机号中间四位用"****"带替 + */ hideMPhone(phone){ return `${phone.substr(0, 3)}****${phone.substr(7)}` }, - // 手机号中间加字符 - phoneAddChat(phone,startNum=3,endNum=7,character=' '){ + /** + * @description 手机号中间加字符 + */ + phoneAddChat(phone,character=' ',startNum=3,endNum=7){ let phoneStr = phone; phoneStr = phoneStr.replace(/\s*/g, ""); var phoneArr = []; @@ -142,11 +81,15 @@ const tools = { phone = phoneArr.join(""); return phone; }, - // 昵称从第一个字开始,后面的都用"*"代替 + /** + * @description 昵称从第一个字开始,后面的都用"*"代替 + */ hideName(name,num){ return `${name.substr(0, 1)}****${name.substr(name.length-1)}` }, - // 金额转换各三位数使用英文","隔开 + /** + * @description 金额转换各三位数使用英文","隔开 + */ changeNum(num){ if (num) { // 针对整数部分进行格式化处理,这是此方法的核心,也是稍难理解的一个地方,逆向的来思考或者采用简单的事例来实现就容易多了 @@ -163,7 +106,9 @@ const tools = { return num; } }, - // 整数添加.00,小数就不添加 + /** + * @description 整数添加.00,小数就不添加 + */ addXiaoShu(num){ console.log(num,120); let str = num.toString(); @@ -174,9 +119,12 @@ const tools = { } return str.includes('.') ? str : str = num + '.00'; }, - // type:+加、-减、*乘、/除 - // len:小数后保留几位 - operationEv(num1,num2,type,len=0){ + /** + * type:+加、-减、*乘、/除 + * len:小数后保留几位 + * @description 数字换算 + */ + operationEv(num1,num2,type,len=2){ // 将数字转化成字符串 num1 = num1.toString(); num2 = num2.toString(); @@ -263,108 +211,9 @@ const tools = { len!=0 ? sum = sum.toFixed(len) : ''; return sum; }, - // 时间戳===>日期 - timestampToTime(timestamp) { - var date = timestamp.toString().length==13 ? new Date(timestamp*1) : new Date(timestamp * 1000);//时间戳为10位需*1000,时间戳为13位的话不需乘1000 - var Y = date.getFullYear(); - var M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1); - var D = date.getDate() < 10 ? '0'+date.getDate() : date.getDate(); - var h = date.getHours() < 10 ? '0'+date.getHours() : date.getHours(); - var m = date.getMinutes() < 10 ? '0'+date.getMinutes() : date.getMinutes(); - var s = date.getSeconds() < 10 ? '0'+date.getSeconds() : date.getSeconds(); - return Y + '-' + M + '-' + D + ' ' + h + ':' + m + ':' +s; - }, - // 日期===>时间戳 - timeToTimestamp(time){ - var date = new Date(time); - var timestamp = date.getTime();//精确到毫秒 - return timestamp - // var date = new Date('2014-04-23 18:55:49:123'); - // 有三种方式获取 - // var time1 = date.getTime();//精确到毫秒 - // var time2 = date.valueOf();//精确到毫秒 - // var time3 = Date.parse(date);//只能精确到秒,毫秒用000替代 - // console.log(time1);//1398250549123 - // console.log(time2);//1398250549123 - // console.log(time3);//1398250549000 - }, - // 返回当前时间 - returnCurrentTime(format,type) { - let date = new Date(); - let year = date.getFullYear(); // 年 - let month = date.getMonth() + 1; // 月 - let day = date.getDate(); // 日 - let time = date.getHours(); // 时 - let minu = date.getSeconds(); // 分 - let second = date.getMinutes(); // 秒 - - let newTime = ''; - switch (type){ - case 0: - newTime = `${year}${format}${month < 10? '0' + month : month}${format}${day < 10 ? '0' + day : day} ${time < 10 ? '0' + time : time}:${minu < 10 ? '0' + minu : minu}`; // 2022-03-31 16:05 - break; - case 1: - newTime = `${year}${format}${month < 10? '0' + month : month}${format}${day < 10 ? '0' + day : day} ${time < 10 ? '0' + time : time}:${minu < 10 ? '0' + minu : minu}:${second < 10 ? '0' + second : second}`; // 2022-03-31 16:10:07 - break; - } - return newTime; - }, - // 返回时间xx天xx小时xx分钟 - returnTimeFormat(startTime,endTime){ - console.log(startTime,endTime); - let newTimeFormat = ''; - let currentTimestamp = this.timeToTimestamp(endTime) - this.timeToTimestamp(startTime); - return this.returnTimestampToTime(currentTimestamp); - }, - // 返回时间戳转时、分对象 - returnTimestampToTime(timestamp){ - let timeStr = ''; - var day = parseInt((timestamp % (1000 * 60 * 60 * 24 * 12)) / (1000 * 60 * 60 * 24)); - var hours = parseInt((timestamp % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)); - var seconds = parseInt((timestamp % (1000 * 60 * 60)) / (1000 * 60)); - day = day < 10 ? ('0' + day) : day; - hours = hours < 10 ? ('0' + hours) : hours; - seconds = seconds < 10 ? ('0' + seconds) : seconds; - if(day*1==0) { - if(hours*1==0) { - seconds*1==0 ? timeStr = 0 : timeStr = `${seconds}分钟`; - } else { - timeStr = `${hours}小时${seconds}分钟`; - } - } else { - timeStr = `${day}天${hours}小时${seconds}分钟`; - } - return timeStr; - }, - // 时间戳转时分秒 00 : 00 : 00 - formatDuring: function(mss) { - // let dangTime = Math.round(new Date()/1000)//获取当前时间戳 - var hours = parseInt((mss % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)); - var seconds = parseInt((mss % (1000 * 60 * 60)) / (1000 * 60)); - var minutes = (mss % (1000 * 60)) / 1000; - hours = hours < 10 ? ('0' + hours) : hours; - seconds = seconds < 10 ? ('0' + seconds) : seconds; - minutes = minutes < 10 ? ('0' + minutes) : minutes; - return hours + ' : ' + seconds + ' : ' + minutes; - }, - // 随机数生成 - randomStr(){ - var strData = ""; - //如果觉得12个数太少也可以多放点,将i<4修改即可 - for(var i=0;i<4;i++){ - var num = random(0,9); //数字 - var upper = String.fromCharCode(random(65,90)); //大写字母 - var lower = String.fromCharCode(random(97,122)); //小写字母 - strData = strData+num+upper+lower; //将所有结果放进strData中 - - } - var str = ""; - for (var i = 0; i < 4; i++) { - str += strData[random(0,strData.length-1)]; //在strData里面随机抽取四个数 - } - return str; - }, - // 金额输入框验证 + /** + * @description 金额输入框验证 + */ checkPrice(number,zong){ let reg = /^[0-9]*$/;//数字正则表达式 let newObj = {} @@ -385,7 +234,9 @@ const tools = { } return newObj }, - // 提示方法 + /** + * @description 提示方法 + */ showToast: function(msg, icon='none',time) { // 弹框显示时间:默认2秒 var newTime = 2000 @@ -396,7 +247,10 @@ const tools = { duration:newTime }) }, - // 富文本 + /** + * @param {Object} str + * @description 富文本 + */ escape2Html(str) { var arrEntities = { 'lt': '<', 'gt': '>', 'nbsp': ' ', 'amp': '&', 'quot': '"' }; return str.replace(/&(lt|gt|nbsp|amp|quot|src);/ig, function (all, t) { @@ -406,7 +260,9 @@ const tools = { .replace(/\ { @@ -424,7 +280,9 @@ const tools = { } }); }, - // app、小程序的检测版本并更新 + /** + * @description app、小程序的检测版本并更新 + */ checkUpdate(){ // 检测app // #ifdef APP-PLUS @@ -496,7 +354,10 @@ const tools = { }) }) }, - // 文本复制 + /** + * @param {Object} data + * @description 文本复制 + */ clickCopy(data){ uni.setClipboardData({ data: data, @@ -505,43 +366,9 @@ const tools = { } }); }, - dayTime(endTime,startTime=''){//开启倒计时 - let totalSecond = ''; - // 本地倒计时 - // if(startTime=='') totalSecond = Math.floor((new Date(endTime).getTime() - new Date().getTime())/1000); - // 解决苹果手机问题 - let date = endTime; - date = endTime.replace(/-/g,'/') - // 服务器倒计时 - if(startTime!='') totalSecond = Math.floor((new Date(date).getTime() - startTime)/1000); - // 总秒数 - let second = totalSecond; - // 天数 - let day = Math.floor(second / 3600 / 24); - let dayStr = day.toString(); - if(dayStr.length == 1) dayStr = '0' + dayStr; - // 小时 - let hr = Math.floor((second - day * 3600 * 24) / 3600); - let hrStr = hr.toString(); - if(hrStr.length == 1) hrStr = '0' + hrStr; - // 分钟 - let min = Math.floor((second - day * 3600 * 24 - hr * 3600) / 60); - let minStr = min.toString(); - if(minStr.length == 1) minStr = '0' + minStr; - // 秒 - let sec = second - day * 3600 * 24 - hr * 3600 - min * 60; - let secStr = sec.toString(); - if(secStr.length == 1) secStr = '0' + secStr; - - let newTime = ''; - if(dayStr==0) { - newTime = hrStr +'时'+ minStr +'分'+ secStr +'秒'; - } else { - newTime = dayStr +'天'+ hrStr +'时'+ minStr +'分'+ secStr +'秒'; - } - return newTime; - }, - // 刷新token + /** + * @description 刷新token + */ refreshToken(){ console.log('进入检测token是否过期'); var date = new Date(); @@ -578,7 +405,9 @@ const tools = { }); } }, - // 判断是否授权,没授权,前往登录页面授权 + /** + * @description 判断是否授权,没授权,前往登录页面授权 + */ authTimer:null, judgeAuth(){ let auth = false; @@ -593,7 +422,9 @@ const tools = { } return auth; }, - // 判断当前环境、清空日志、设置全局域名 + /** + * @description 判断当前环境、清空日志、设置全局域名 + */ currentContext(){ // #ifdef APP-PLUS if(uni.getSystemInfoSync().platform != "devtools"){//devtools:开发版 值域为:ios、android、mac(3.1.10+)、windows(3.1.10+)、linux(3.1.10+) @@ -615,7 +446,9 @@ const tools = { } // #endif }, - // 禁止小程序使用分享 + /** + * @description 禁止小程序使用分享 + */ disableShareEv(){ // #ifdef MP-WEIXIN wx.hideShareMenu({ @@ -623,7 +456,9 @@ const tools = { }) // #endif }, - // 获取当前页面url,不带参数 + /** + * @description 获取当前页面url + */ obtainPagePath(){ let pages = getCurrentPages(); // 获取纯页面路径 @@ -635,50 +470,9 @@ const tools = { uni.setStorageSync('page-path-options',routeParam); console.log(uni.getStorageSync('page-path-options'),'当前页面完整路径'); }, - // 去这里 - goFlag:true, - goThere(){ - if(this.flag){ - this.flag = false; - // #ifdef MP-WEIXIN - wx.getLocation({//获取当前经纬度 - type: 'wgs84', //返回可以用于wx.openLocation的经纬度,官方提示bug: iOS 6.3.30 type 参数不生效,只会返回 wgs84 类型的坐标信息 - success: (res)=> { - wx.openLocation({//​使用微信内置地图查看位置。 - latitude: 30.656693,//要去的纬度-地址 - longitude: 104.136425,//要去的经度-地址 - name: '大向天诚有限责任公司', - address: '四川省成都市成华区双店路B口', - fail:err=>{ - this.showToast('地址信息错误'); - } - }) - } - }) - // #endif - - // #ifdef APP-PLUS || H5 - uni.openLocation({ - latitude: parseFloat(latitude), - longitude: parseFloat(longitude), - name:name, - address:address, - success: function () { - console.log('success'); - }, - fail:function(err){ - console.log(err) - } - }); - // #endif - setTimeout(()=>{ - this.flag = true; - },2000) - } else { - this.showToast('请勿多次点击'); - } - }, - // 拨打电话 + /** + * @description 拨打电话 + */ countCustomer(phone){ const res = uni.getSystemInfoSync(); if(res.platform=='ios'){ @@ -701,7 +495,9 @@ const tools = { }) } }, - // 图片上传 + /** + * @description 图片上传 + */ uploadImg(count) { let imgArr = []; uni.chooseImage({ @@ -718,20 +514,7 @@ const tools = { }) return imgArr; }, - openLocation(latitude,longitude,name,address){ - uni.openLocation({ - latitude: parseFloat(latitude), - longitude: parseFloat(longitude), - name:name, - address:address, - success: function () { - console.log('success'); - }, - fail:function(err){ - console.log(err) - } - }); - } + } diff --git a/pages.json b/pages.json index 2dd9b8f..5b2de0e 100644 --- a/pages.json +++ b/pages.json @@ -80,20 +80,13 @@ ], "subPackages": [{ //A包 "root": "pagesA", - "pages": [{ - "path": "test/test", - "style": { - "navigationBarTitleText": "", - "enablePullDownRefresh": false - } - } ,{ + "pages": [ + { "path" : "my-address/my-address", - "style" : - { - "navigationBarTitleText": "", - "enablePullDownRefresh": false - } - + "style" : { + "navigationBarTitleText": "", + "enablePullDownRefresh": false + } } ] }, @@ -143,8 +136,10 @@ "globalStyle": { "navigationBarTextStyle": "black", "navigationBarBackgroundColor": "#FFFFFF", //导航栏背景色 - "backgroundColor": "#FFFFFF", //窗口背景色 "navigationStyle": "custom", //禁用原生导航栏,微信小程序可用 + "backgroundColor":"#FFFFFF",//下拉显示出来的窗口的背景色 + "backgroundTextStyle":"light",//下拉 loading 的样式,仅支持 dark / light + "transparentTitle":"none",//导航栏整体(前景、背景)透明设置。支持 always 一直透明 / auto 滑动自适应 / none 不透明 "app-plus": { "titleNView": false, //禁用原生导航栏,APP和H5可用 "bounce": "none", diff --git a/pagesA/my-address/my-address.vue b/pagesA/my-address/my-address.vue index 3da68db..1735b54 100644 --- a/pagesA/my-address/my-address.vue +++ b/pagesA/my-address/my-address.vue @@ -1,58 +1,60 @@ @@ -62,12 +64,16 @@ import addressTwo from '@/components/choose-address/address-two/address-two.vue'; import addressThree from '@/components/choose-address/address-three/address-three.vue'; import addressFour from '@/components/choose-address/address-four/address-four.vue'; + import yayaMap from '@/jsFile/map/yaya-map.js'; + import yayaTime from '@/jsFile/time/yaya-time.js'; + import statusContainer from '@/components/containers/status-container.vue'; export default { components:{ addressOne, addressTwo, addressThree, - addressFour + addressFour, + statusContainer }, data() { return { @@ -94,6 +100,8 @@ }, mounted() { this.getDistrict(); + yayaMap.getAddressH5(); + yayaTime.weekDate(); }, computed:{ regionName(){ diff --git a/pagesA/test/test.vue b/pagesA/test/test.vue deleted file mode 100644 index 8183fd0..0000000 --- a/pagesA/test/test.vue +++ /dev/null @@ -1,22 +0,0 @@ - - - - -