const b64 = require('b64.js')
const formatTime = date => {
const month = date.getMonth() + 1
const day = date.getDate()
const hour = date.getHours()
const minute = date.getMinutes()
return [month, day].map(formatNumber).join('/') + ' ' + [hour, minute].map(formatNumber).join(':')
}
const prettyTime = date => {
const month = date.getMonth() + 1
const day = date.getDate()
const hour = date.getHours()
const minute = date.getMinutes()
return month + '月' + day + '日 ' + [hour, minute].map(formatNumber).join(':')
}
const prettyTimeYMD = date => {
const month = date.getMonth() + 1
const day = date.getDate()
return month + '月' + day + '日 '
}
const minute = 1000 * 60;
const hour = minute * 60;
const day = hour * 24;
const week = day * 7;
const halfamonth = day * 15;
const month = day * 30;
const agoTime = dateTimeStamp => {
var now = new Date().getTime();
var diffValue = now - dateTimeStamp;
var v = 0
var result = ""
if ((v = diffValue/month) >= 1) {
if (v >= 3) {
result = "3 个月前"
} else {
result = "" + (v|0) + " 月前"
}
} else if ((v = diffValue/week) >= 1) {
result = "" + (v|0) + " 周前"
} else if ((v = diffValue/day) >= 1) {
result = "" + (v|0) + " 天前"
} else if ((v = diffValue/hour) >= 1) {
result = "" + (v|0) + " 小时前"
} else if ((v = diffValue/minute) >= 1) {
result = "" + (v|0) + " 分钟前"
} else {
result = "刚刚"
}
return result
}
const msgTime = (date) => {
const month = date.getMonth() + 1
const _day = date.getDate()
const hour = date.getHours()
const minute = date.getMinutes()
var now = new Date().getTime();
var diffValue = now - date;
if (diffValue/day >= 1) {
return [month, _day].map(formatNumber).join('-')
} else {
return [hour, minute].map(formatNumber).join(': ')
}
}
const getDaysFromNow = (created_at) => {
var thatTime = new Date(created_at * 1000)
var nowTime = new Date()
return Math.ceil((nowTime - thatTime) / (1000 * 3600 * 24))
}
const formatNumber = n => {
n = n.toString()
return n[1] ? n : '0' + n
}
// 从当前页面传递数据到上一个页面
function setResult(data) {
const pages = getCurrentPages();
if (pages.length >= 2) {
const prevPage = pages[pages.length - 2] //上一个页面
if (prevPage.onResult) {
prevPage.onResult(data)
}
}
}
// 从当前页面发送数据到目的页面,使用全局变量实现
// 需要用 getTransitData 方法提取
function setTransitData(key, value) {
var g = getApp().globalData
g.transit[key] = value
}
function getTransitData(key) {
var g = getApp().globalData
var v = g.transit[key]
g.transit[key] = null
return v
}
function jwtDecode(token) {
var base64 = token.split('.')[1];
var b = b64.atob(base64)
return JSON.parse(b)
}
// check to see if the user token is expired or
// will expire within the next 30 minutes (1800 seconds).
// If not, there is nothing we really need to do here.
function jwtExpire(token, ahead) {
if (!ahead) {
ahead = 1800
}
if (Date.now()/1000 < jwtDecode(token).exp - ahead) {
return false
}
return true
}
// hashtag
function hashtag(text) {
var regex = /#[^#]+#/g
if (text) {
return text.match(regex)
}
return null
}
// Test white space
// Instead of checking the entire string to see if there's only whitespace,
// just check to see if there's at least one character of non whitespace:
function isWhiteSpace(str) {
return !str || (!/\S/.test(str))
}
// Parse json
function jsonParse(str) {
var r = {}
try {
r.object = JSON.parse(str)
r.ok = true
} catch (e) {
r.ok = false
r.err = e
}
return r
}
// update list item
function getCityName(addr) {
var city = undefined
if (addr) {
console.log("get add:" + addr)
var index0 = addr.indexOf('省')
var index1 = addr.indexOf('市')
if (index0 > 0 && index1 > 0 && index1 > index0 ) {
city = addr.substring(index0+1, index1+1)
} else if (addr.includes('北京市')) {
city = '北京市'
} else if (addr.includes('上海市')) {
city = '上海市'
} else if (addr.includes('天津市')) {
city = '天津市'
} else if (addr.includes('重庆市')) {
city = '重庆市'
}
}
return city
}
function lightenColor(col, amt) {
if (col[0] == "#") {
col = col.slice(1);
}
var num = parseInt(col, 16);
var r = (num >> 16) + amt;
if (r > 255) r = 255;
else if (r < 0) r = 0;
var b = ((num >> 8) & 0x00FF) + amt;
if (b > 255) b = 255;
else if (b < 0) b = 0;
var g = (num & 0x0000FF) + amt;
if (g > 255) g = 255;
else if (g < 0) g = 0;
return "#" + padZero(r.toString(16)) + padZero(b.toString(16)) + padZero(g.toString(16));
}
function alphaColor(col, amt) {
if (col[0] == "#") {
col = col.slice(1);
}
var num = parseInt(col, 16);
var r = (num >> 16);
var g = ((num >> 8) & 0x00FF);
var b = (num & 0x0000FF);
return `rgba(${r}, ${g}, ${b}, ${amt})`
}
function invertColor(hex, bw) {
if (hex.indexOf('#') === 0) {
hex = hex.slice(1);
}
// convert 3-digit hex to 6-digits.
if (hex.length === 3) {
hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2];
}
if (hex.length !== 6) {
throw new Error('Invalid HEX color.');
}
var r = parseInt(hex.slice(0, 2), 16),
g = parseInt(hex.slice(2, 4), 16),
b = parseInt(hex.slice(4, 6), 16);
if (bw) {
// http://stackoverflow.com/a/3943023/112731
return (r * 0.299 + g * 0.587 + b * 0.114) > 186
? '#000000'
: '#ffffff';
}
// invert color components
r = (255 - r).toString(16);
g = (255 - g).toString(16);
b = (255 - b).toString(16);
// pad each with zeros and return
return "#" + padZero(r) + padZero(g) + padZero(b);
}
function padZero(str, len) {
len = len || 2;
var zeros = new Array(len).join('0');
return (zeros + str).slice(-len);
}
module.exports = {
formatTime: formatTime,
agoTime: agoTime,
msgTime: msgTime,
prettyTime: prettyTime,
prettyTimeYMD: prettyTimeYMD,
getDaysFromNow: getDaysFromNow,
setResult: setResult,
sendRequest: setTransitData,
getRequest: getTransitData,
jwtDecode: jwtDecode,
jwtExpire: jwtExpire,
hashtag: hashtag,
isWhiteSpace: isWhiteSpace,
jsonParse: jsonParse,
getCityName: getCityName,
lightenColor: lightenColor,
invertColor: invertColor,
alphaColor: alphaColor,
}
没有合适的资源?快使用搜索试试~ 我知道了~
云开发Wetour旅游打卡广场微信小程序源码
共108个文件
png:49个
js:14个
json:13个
4 下载量 103 浏览量
2023-04-20
14:05:44
上传
评论
收藏 1.38MB ZIP 举报
温馨提示
云开发Wetour旅游打卡广场微信小程序源码,使用云开发技术,taro 构建,主要功能有:景点列表、景点详情、打卡记录、打卡成功、评论、景点地图、景点导航、行程规划、行程线路等,注意搭建时候不兼容taro最新版本,请使用tarov1.3.18,后台为云开发管理后台。 搭建教程: 导入数据 1、先将所有的云函数右键上传。 2、在云数据库中新建comment(评论)、default_trip(系统默认路线)、mark(打卡记录)、scene(景点)、trip(用户行程)、user(用户)集合。 3、将 data 文件夹中对应的数据导入到集合中,剩下的数据则在小程序界面操作即可。 运行项目: $ git clone https://github.com/Mayandev/wetour.git$ cd wetour/client$ npm install$ npm run dev:weapp$ # 打包$ npm run build:weapp 开源地址:https://github.com/Mayandev/wetour 视频搭建教程:https://www.bilibili.
资源推荐
资源详情
资源评论
收起资源包目录
云开发Wetour旅游打卡广场微信小程序源码 (108个子文件)
tieba.jpg 196KB
news.jpg 193KB
从这联系我.jpg 59KB
从这联系我.jpg 59KB
从这联系我.jpg 59KB
从这联系我.jpg 59KB
1.jpg 38KB
2.jpg 37KB
3.jpg 25KB
util.js 7KB
article.js 4KB
controller.js 3KB
b64.js 3KB
index.js 3KB
send.js 2KB
article-detail.js 1KB
me.js 998B
message.js 912B
square.js 910B
search.js 878B
app.js 446B
me-info.js 246B
fishei.js 0B
project.config.json 2KB
app.json 1KB
project.private.config.json 410B
sitemap.json 197B
me.json 75B
me-info.json 51B
index.json 33B
message.json 29B
article-detail.json 29B
search.json 29B
article.json 29B
send.json 29B
square.json 29B
zafu.png 265KB
other.png 17KB
arrow_right.png 15KB
anonymous.png 14KB
share.png 14KB
edit_third.png 14KB
love-mood.png 13KB
message_active.png 13KB
send.png 13KB
search.png 13KB
part-time-job.png 12KB
me_active.png 11KB
news.png 11KB
found.png 11KB
communication.png 10KB
square_active.png 10KB
comment.png 10KB
study.png 10KB
message.png 9KB
second-hand.png 8KB
my.png 8KB
unlike.png 8KB
collect.png 8KB
comment-y.png 8KB
like.png 8KB
edit_second.png 8KB
nocollect.png 8KB
me.png 7KB
index.png 7KB
home_active.png 7KB
trade.png 7KB
message.png 7KB
square.png 7KB
back.png 7KB
home.png 7KB
question-ask.png 7KB
my_second.png 7KB
edit.png 7KB
directing.png 6KB
Sign.png 5KB
next.png 3KB
vertical.png 2KB
more.png 2KB
dwon.png 2KB
del.png 1KB
video.png 702B
clear.png 698B
plus.png 690B
photo.png 533B
VIP会员下载整站资源永久免费-98素材网.url 114B
下载说明.url 113B
index.wxml 6KB
me.wxml 5KB
article.wxml 4KB
article-detail.wxml 4KB
send.wxml 3KB
search.wxml 1KB
me-info.wxml 86B
message.wxml 76B
square.wxml 72B
weui.wxss 100KB
weui-icon.wxss 26KB
index.wxss 5KB
article-detail.wxss 4KB
共 108 条
- 1
- 2
资源评论
网创学长
- 粉丝: 2417
- 资源: 914
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 卡方数据.sav
- Python实现基于Django框架的二手物品购物网站设计源码+数据库.zip
- 基于Python和Django的二手物品购物网站设计源码+数据库脚本.zip
- 【计算机毕业设计】基于h5的移动网赚项目小程序【源码+lw+部署文档+讲解】
- 【计算机毕业设计】基于ssm-vue的oa系统设计与实现【源码+lw+部署文档+讲解】
- 基于pytorch实现的YOLOV5+SORT的车辆行人目标识别及追踪系统源码.zip
- 【计算机毕业设计】基于servlet+jdbc的在线选房系统设计与实现【源码+lw+部署文档+讲解】
- 投身科技创新,勇担时代先锋.pptx
- 【计算机毕业设计】基于SSM的仿微博系统的设计与实现【源码+lw+部署文档+讲解】
- 使用 Web Components 实现,遵循 Material You 设计规范的 Web 前端组件库
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功