//index.js
//获取应用实例
const app = getApp();
function DateMinus(start, end) {
var start_date = new Date(start.replace(/-/g, "/"));
var end_date = new Date(end.replace(/-/g, "/"));
var days = end_date.getTime() - start_date.getTime();
var day = parseInt(days / (1000 * 60 * 60 * 24));
return day;
}
Page({
data: {
motto: 'Hello World',
userInfo: {},
num: 1,
hasUserInfo: false,
start_date: '',
end_date: '',
canIUse: wx.canIUse('button.open-type.getUserInfo')
},
//事件处理函数
bindViewTap: function () {
wx.navigateTo({
url: '../logs/logs'
})
},
onShow: function () {
var date = new Date();
var FullYear = date.getFullYear();
var day = date.getDate();
var Month = (date.getMonth() + 1);
if (day < 10) {
var day_1 = '0' + day
var day_2 = '0' + (parseInt(day) + 1)
}
if (Month < 10) {
Month = '0' + Month
}
var start_date = FullYear + '-' + Month + '-' + day_1;
var end_date = FullYear + '-' + Month + '-' + day_2
this.setData({
data: date,
start_date: start_date,
end_date: end_date
})
},
order: function (e) {
if (this.data.num >0) {
wx.navigateTo({
url: '../book/book',
})
} else {
wx.showToast({
image: '/image/false.png',
title: '日期有误',
})
}
this.num_data()
},
// 日期结算
num_data: function (e) {
var start_date = new Date(this.data.start_date.replace(/-/g, "/"));
console.log(start_date)
var end_date = new Date(this.data.end_date.replace(/-/g, "/"));
var days = end_date.getTime() - start_date.getTime();
var day = parseInt(days / (1000 * 60 * 60 * 24));
if (day>0) {
this.setData({
num: day
})
} else {
wx.showToast({
image: '/image/false.png',
title: '日期有误',
})
this.onShow()
}
},
// 入驻日期
start_date: function (e) {
this.setData({
start_date: e.detail.value
})
},
// 离店日期
end_date: function (e) {
this.setData({
end_date: e.detail.value
})
this.num_data()
},
onLoad: function () {
if (app.globalData.userInfo) {
this.setData({
userInfo: app.globalData.userInfo,
hasUserInfo: true
})
} else if (this.data.canIUse) {
// 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
// 所以此处加入 callback 以防止这种情况
app.userInfoReadyCallback = res => {
this.setData({
userInfo: res.userInfo,
hasUserInfo: true
})
}
} else {
// 在没有 open-type=getUserInfo 版本的兼容处理
wx.getUserInfo({
success: res => {
app.globalData.userInfo = res.userInfo
this.setData({
userInfo: res.userInfo,
hasUserInfo: true
})
}
})
}
},
getUserInfo: function (e) {
console.log(e)
app.globalData.userInfo = e.detail.userInfo
this.setData({
userInfo: e.detail.userInfo,
hasUserInfo: true
})
},
// 转发
onShareAppMessage: function () {
},
// 打开位置
location: function () {
wx.getLocation({
type: 'gcj02', //返回可以用于wx.openLocation的经纬度
success: function (res) {
var latitude = res.latitude
var longitude = res.longitude
wx.openLocation({
latitude: latitude,
longitude: longitude,
scale: 28
})
}
})
},
// 打电话
makePhoneCall: function () {
var that = this
wx.makePhoneCall({
phoneNumber: '13977284413',
success: function () {
console.log("成功拨打电话")
}
})
}
})
没有合适的资源?快使用搜索试试~ 我知道了~
微信小程序酒店类型Demo
共46个文件
png:21个
js:7个
json:6个
需积分: 50 100 下载量 91 浏览量
2018-03-21
09:34:17
上传
评论 5
收藏 474KB ZIP 举报
温馨提示
微信小程序酒店类型的Demo,有在线导航,拨打客服电话,房间预订,下单等功能。
资源推荐
资源详情
资源评论
收起资源包目录
酒店.zip (46个子文件)
酒店
image
top_img.jpg 194KB
04.png 2KB
01.png 1KB
add_icon.png 2KB
icon_2.png 6KB
011.png 1KB
gantanhao.png 188KB
022.png 2KB
icon_3.png 12KB
icon_1.png 9KB
02.png 2KB
044.png 2KB
false.png 3KB
033.png 1KB
phone.png 1KB
icon_8.png 10KB
03.png 1024B
icon_5.png 5KB
icon_4.png 7KB
icon_7.png 5KB
icon_6.png 6KB
arrowright.png 1KB
app.json 1KB
pages
index
index.js 4KB
index.wxss 2KB
index.wxml 3KB
logs
logs.js 261B
logs.json 52B
logs.wxml 173B
logs.wxss 106B
book
book.json 36B
book.wxml 1KB
book.wxss 973B
book.js 351B
user
user.js 1KB
user.wxml 2KB
user.wxss 905B
user.json 2B
order
order.wxss 908B
order.json 2B
order.wxml 759B
order.js 1KB
app.wxss 247B
app.js 1KB
project.config.json 540B
utils
util.js 472B
共 46 条
- 1
资源评论
a_靖
- 粉丝: 4650
- 资源: 32
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功