新增(电量栏,状态栏,主体内容)组件

master
吃肉的饺子 2022-04-17 19:57:56 +08:00
parent 9723f0435f
commit 81a2174045
9 changed files with 617 additions and 384 deletions

View File

@ -0,0 +1,71 @@
<template>
<view>
<status-nav
:ifReturn="ifReturn"
:returnColor="returnc"
:titleColor="titlec"
:navBarTitle="titlet"
:ifTitle="ifTitle"
:ifCenter="ifTitleCenter"
:backgroudColor="backgroundc"></status-nav>
<view class="pad-zy20" :style="{paddingBottom: '70px'}">
<slot name="content"></slot>
</view>
</view>
</template>
<script>
import statusNav from '../status-navs/status-nav.vue';
export default {
name:"status-container",
components:{
statusNav
},
props:{
//
ifTitle:{
type:Boolean,
default:true
},
//
titlet:{
type:String,
default:'标题'
},
//
ifTitleCenter:{
type:Boolean,
default:true
},
//
titlec:{
type:String,
default:'#000000'
},
//
ifReturn:{
type:Boolean,
default:true
},
//
returnc:{
type:String,
default:"#333333"
},
//
backgroundc:{
type:String,
default:"#FFFFFF"
}
},
data() {
return {
};
}
}
</script>
<style>
</style>

View File

@ -9,7 +9,7 @@
<!-- 返回键 start -->
<view class="disjcac left-box" @tap="backEv" v-if="ifReturn" :style="{height: navBarHeight}" >
<slot name="leftcontent">
<i class="icon icon-return" style="font-size: 32rpx;" :style="{color: returnColor}"></i>
<i class="icon icon-return" style="font-size: 38rpx;" :style="{color: returnColor}"></i>
</slot>
</view>
<!-- 返回键 end -->

190
jsFile/map/yaya-map.js Normal file
View File

@ -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;

View File

@ -6,6 +6,12 @@ export default {
}
},
onShareTimeline(res) {//分享到朋友圈
return {}
return {
title: '分享到朋友圈',
query: {
key: '参数'
},
imageUrl: '',
}
},
}

202
jsFile/time/yaya-time.js Normal file
View File

@ -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;

View File

@ -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(/\<img/g, '<img @tap="pre" style="max-width:100%!important;height:auto" ')
.replace(/src=\"/g,'src="https://oss.hmzfyy.cn');
},
// 检查网络状态
/**
* @description 检查网络状态
*/
networkStatus(){
uni.getNetworkType({
success: (res)=> {
@ -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、mac3.1.10+、windows3.1.10+、linux3.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)
}
});
}
}

View File

@ -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, //APPH5
"bounce": "none",

View File

@ -1,58 +1,60 @@
<template>
<view>
<view class="pad20">
<!-- 方式一 start -->
<view class="disjbac width100 pad-sx20 bbot" @tap="openPicker">
<view>{{region}}</view>
<i class="icon icon-next col9" style="font-size: 30rpx;"></i>
<status-container titlet="我的地址">
<view slot="content">
<!-- 方式一 start -->
<view class="disjbac width100 pad-sx20 bbot" @tap="openPicker">
<view>{{region}}</view>
<i class="icon icon-next col9" style="font-size: 30rpx;"></i>
</view>
<addressOne @choseVal="choseValue" :lotusAddressData="lotusAddressData"></addressOne>
<!-- 方式一 end -->
<!-- 方式二 start -->
<view class="disjbac width100 pad-sx20 bbot" @tap="chooseRegion">
<view>{{region1}}</view>
<i class="icon icon-next col9" style="font-size: 30rpx;"></i>
</view>
<!-- 方式二 end -->
<!-- 方式三 start -->
<view class="disjbac width100 pad-sx20 bbot" @tap="chooseAddress1">
<view>{{region2}}</view>
<i class="icon icon-next col9" style="font-size: 30rpx;"></i>
</view>
<!-- 方式三 end -->
<!-- 方式四 start -->
<addressThree :defaultRegion="defaultRegionCode" @getRegion="handleGetRegion">
<h2>点击选择省市区</h2>
</addressThree>
<view class="disjbac width100 pad-sx20 bbot">
<view>{{regionName}}</view>
<i class="icon icon-next col9" style="font-size: 30rpx;"></i>
</view>
<!-- 方式四 end -->
<!-- 方式五 start -->
<view class="disjbac width100 pad-sx20 bbot" @tap="openAddres">
<view>默认打开地址</view>
<i class="icon icon-next col9" style="font-size: 30rpx;"></i>
</view>
<view class="disjbac width100 pad-sx20 bbot" @tap="openAddres2">
<view>自定义根据省市区名称打开地址</view>
<i class="icon icon-next col9" style="font-size: 30rpx;"></i>
</view>
<view class="disjbac width100 pad-sx20 bbot" @tap="openAddres3">
<view>自定义根据省市区code打开地址</view>
<i class="icon icon-next col9" style="font-size: 30rpx;"></i>
</view>
<textarea v-model="pickerText" cols="30" rows="10"></textarea>
<!--
mask-bg-color="rgba(0, 229, 238, 0.4)" //
-->
<addressFour ref="simpleAddress" :pickerValueDefault="cityPickerValueDefault" @onConfirm="onConfirm" themeColor="#007AFF"></addressFour>
<!-- 方式五 end -->
</view>
<addressOne @choseVal="choseValue" :lotusAddressData="lotusAddressData"></addressOne>
<!-- 方式一 end -->
<!-- 方式二 start -->
<view class="disjbac width100 pad-sx20 bbot" @tap="chooseRegion">
<view>{{region1}}</view>
<i class="icon icon-next col9" style="font-size: 30rpx;"></i>
</view>
<!-- 方式二 end -->
<!-- 方式三 start -->
<view class="disjbac width100 pad-sx20 bbot" @tap="chooseAddress1">
<view>{{region2}}</view>
<i class="icon icon-next col9" style="font-size: 30rpx;"></i>
</view>
<!-- 方式三 end -->
<!-- 方式四 start -->
<addressThree :defaultRegion="defaultRegionCode" @getRegion="handleGetRegion">
<h2>点击选择省市区</h2>
</addressThree>
<view class="disjbac width100 pad-sx20 bbot">
<view>{{regionName}}</view>
<i class="icon icon-next col9" style="font-size: 30rpx;"></i>
</view>
<!-- 方式四 end -->
<!-- 方式五 start -->
<view class="disjbac width100 pad-sx20 bbot" @tap="openAddres">
<view>默认打开地址</view>
<i class="icon icon-next col9" style="font-size: 30rpx;"></i>
</view>
<view class="disjbac width100 pad-sx20 bbot" @tap="openAddres2">
<view>自定义根据省市区名称打开地址</view>
<i class="icon icon-next col9" style="font-size: 30rpx;"></i>
</view>
<view class="disjbac width100 pad-sx20 bbot" @tap="openAddres3">
<view>自定义根据省市区code打开地址</view>
<i class="icon icon-next col9" style="font-size: 30rpx;"></i>
</view>
<textarea v-model="pickerText" cols="30" rows="10"></textarea>
<!--
mask-bg-color="rgba(0, 229, 238, 0.4)" //
-->
<addressFour ref="simpleAddress" :pickerValueDefault="cityPickerValueDefault" @onConfirm="onConfirm" themeColor="#007AFF"></addressFour>
<!-- 方式五 end -->
</view>
</status-container>
<addressTwo @conceal="conceal" v-if="popup"></addressTwo>
</view>
</template>
@ -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(){

View File

@ -1,22 +0,0 @@
<template>
<view>
</view>
</template>
<script>
export default {
data() {
return {
}
},
methods: {
}
}
</script>
<style>
</style>