作者 乔蒙蒙

酒吧项目提交

//app.js
App({
onLaunch: function () {
},
/**
* 自定义post函数,返回Promise
* +-------------------
* @param {String} url 接口网址
* @param {arrayObject} data 要传的数组对象 like: {name: 'name', age: 32}
* +-------------------
* @return {Promise} promise 返回promise供后续操作
*/
post: function (url, data, headerParams) {
wx.showNavigationBarLoading()
wx.showLoading({
title: '加载中',
})
var promise = new Promise((resolve, reject) => {
let that = this;
let postData = data;
let baseUrl = 'http://saloon.w.bronet.cn/api/';
//网络请求
let header = {
'content-type': 'application/x-www-form-urlencoded'
}
header = Object.assign(header, headerParams)
wx.request({
url: baseUrl + url,
data: postData,
method: 'POST',
header: header,
success: function (res) {//返回取得的数据
if (res.data.code == '20000') {
resolve(res.data.data);
} else if (res.data.code == '10001') {//用户未
} else if (res.data.code == '40000') {
wx.showModal({
title: '提示',
content: res.data.msg,
showCancel: false,
success: function (res) {
}
})
} else if (res.data.code == '40005') {
wx.showModal({
title: '提示',
content: res.data.msg,
showCancel: false,
success: function (res) {
if (res.confirm) {
wx.reLaunch({
url: '/pages/start/start'
})
} else if (res.cancel) {
console.log('用户点击取消')
}
}
})
} else if (res.data.code == '40006') {
onLaunch: function () {
} else {
wx.showModal({
title: '提示',
content: res.data.msg,
showCancel: false,
})
reject(res.data)
}
wx.hideLoading()
wx.hideNavigationBarLoading()
},
fail: function (e) {
console.log(e)
reject('网络出错');
// wx.hideLoading()
wx.hideNavigationBarLoading()
}
})
});
/**
* 自定义post函数,返回Promise
* +-------------------
* @param {String} url 接口网址
* @param {arrayObject} data 要传的数组对象 like: {name: 'name', age: 32}
* +-------------------
* @return {Promise} promise 返回promise供后续操作
*/
post: function (url, data, headerParams) {
wx.showNavigationBarLoading()
wx.showLoading({
title: '加载中',
})
var promise = new Promise((resolve, reject) => {
let that = this;
let postData = data;
let baseUrl = 'http://saloon.w.bronet.cn/api/';
//网络请求
let header = {
'content-type': 'application/x-www-form-urlencoded'
}
// console.log(baseUrl/ + url)
header = Object.assign(header, headerParams)
wx.request({
url: baseUrl + url,
data: postData,
method: 'POST',
header: header,
success: function (res) {//返回取得的数据
// console.log(res)
if (res.data.code == '20000') {
resolve(res.data);
} else if (res.data.code == '10001') {//用户未
} else if (res.data.code == '40000') {
wx.showModal({
title: '提示',
content: res.data.msg,
showCancel: false,
success: function (res) {
}
})
} else if (res.data.code == '40005') {
wx.showModal({
title: '提示',
content: res.data.msg,
showCancel: false,
success: function (res) {
if (res.confirm) {
wx.reLaunch({
url: '/pages/start/start'
})
} else if (res.cancel) {
console.log('用户点击取消')
}
}
})
} else if (res.data.code == '40006') {
} else {
wx.showModal({
title: '提示',
content: res.data.msg,
showCancel: false,
})
reject(res.data)
}
wx.hideLoading()
wx.hideNavigationBarLoading()
},
fail: function (e) {
console.log(e)
reject('网络出错');
// wx.hideLoading()
wx.hideNavigationBarLoading()
}
})
});
return promise;
},
//根据年月日获取(星期等信息)////later=0 当前 later=1明天 later=2后天
dateLater(later) {
let dateObj = {};
let show_day = new Array('星期天', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六');
let date = new Date();
date.setDate(date.getDate() + later);
let day = date.getDay();
dateObj.year = date.getFullYear();
dateObj.month = ((date.getMonth() + 1) < 10 ? ("0" + (date.getMonth() + 1)) : date.getMonth() + 1);
dateObj.day = (date.getDate() < 10 ? ("0" + date.getDate()) : date.getDate());
dateObj.week = show_day[day];
dateObj.dataday = date.getFullYear() + '-' + ((date.getMonth() + 1) < 10 ? ("0" + (date.getMonth() + 1)) : date.getMonth() + 1) + '-' + (date.getDate() < 10 ? ("0" + date.getDate()) : date.getDate());
dateObj.houser = date.getHours();//当前时间点
console.log(date.getHours())
dateObj.housers = (date.getHours() < 10 ? ("0" + date.getHours()) : date.getHours()) + ':00:00';//当前时间点
dateObj.datadayhouser = date.getFullYear() + '/' + ((date.getMonth() + 1) < 10 ? ("0" + (date.getMonth() + 1)) : date.getMonth() + 1) + '/' + (date.getDate() < 10 ? ("0" + date.getDate()) : date.getDate()) + ' ' + (date.getHours() < 10 ? ("0" + date.getHours()) : date.getHours()) + ':00';//当前时间并时间点
return dateObj;
},
globalData: {
userInfo: null
}
return promise;
},
//根据年月日获取(星期等信息)////later=0 当前 later=1明天 later=2后天
dateLater(later) {
let dateObj = {};
let show_day = new Array('星期天', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六');
let date = new Date();
date.setDate(date.getDate() + later);
let day = date.getDay();
dateObj.year = date.getFullYear();
dateObj.month = ((date.getMonth() + 1) < 10 ? ("0" + (date.getMonth() + 1)) : date.getMonth() + 1);
dateObj.day = (date.getDate() < 10 ? ("0" + date.getDate()) : date.getDate());
dateObj.week = show_day[day];
dateObj.dataday = date.getFullYear() + '-' + ((date.getMonth() + 1) < 10 ? ("0" + (date.getMonth() + 1)) : date.getMonth() + 1) + '-' + (date.getDate() < 10 ? ("0" + date.getDate()) : date.getDate());
dateObj.houser = date.getHours();//当前时间点
console.log(date.getHours())
dateObj.housers = (date.getHours() < 10 ? ("0" + date.getHours()) : date.getHours()) + ':00:00';//当前时间点
dateObj.datadayhouser = date.getFullYear() + '/' + ((date.getMonth() + 1) < 10 ? ("0" + (date.getMonth() + 1)) : date.getMonth() + 1) + '/' + (date.getDate() < 10 ? ("0" + date.getDate()) : date.getDate()) + ' ' + (date.getHours() < 10 ? ("0" + date.getHours()) : date.getHours()) + ':00';//当前时间并时间点
return dateObj;
},
globalData: {
userInfo: null
}
})
\ No newline at end of file
... ...
// pages/kaishi/kaishi.js
const app=getApp();
const app = getApp();
Page({
/**
* 页面的初始数据
*/
data: {
imgUrls: [
'../../imgs/lunbo1@3x.png',
'../../imgs/lunbo2@3x.png',
'../../imgs/lunbo3@3x.png'
],
indexs:0,
color:'#cccccc',
indicatorDots: false,
autoplay: true,
activecolor:'#ffffff',
interval: 5000,
duration: 1000
},
start(e) {
let that = this;
app.globalData.userInfo = e.detail.userInfo;
wx.login({
success: function (s) {
let url = 'wxapp/public/getSessionKey';
if (s.code) {
var code = s.code;
var param = {
code: code
}
app.post(url, param).then((res) => {
that.login(res.openid, res.session_key, e.detail.encryptedData, e.detail.iv);
}).catch((errMsg) => {
console.log(errMsg);
})
/**
* 页面的初始数据
*/
data: {
imgUrls: [
'../../imgs/lunbo1@3x.png',
'../../imgs/lunbo2@3x.png',
'../../imgs/lunbo3@3x.png'
],
indexs: 0,
color: '#cccccc',
indicatorDots: false,
autoplay: true,
activecolor: '#ffffff',
interval: 5000,
duration: 1000
},
start(e) {
let that = this;
app.globalData.userInfo = e.detail.userInfo;
wx.login({
success: function (s) {
let url = 'wxapp/public/getSessionKey';
if (s.code) {
var code = s.code;
var param = {
code: s.code
}
app.post(url, param).then((res) => {
// console.log(res);
// console.log(e);
that.login(res.data.openid, res.data.session_key, e.detail.encryptedData, e.detail.iv, e.detail.rawData, e.detail.signature);
}).catch((errMsg) => {
console.log(errMsg);
})
}
}
});
},
login(openid, session_key, encrypted_data, iv,r,s) {
let that = this;
let param = {
openid: openid,
session_key: session_key,
encrypted_data: encrypted_data,
iv: iv,
rawData: r,
signature: s
}
let url = 'wxapp/public/login';
// wx.navigateTo({
// url: '/pages/login/login',
// success: function (res) { },
// fail: function (res) { },
// complete: function (res) { },
// })
app.post(url, param).then((res) => {
console.log(res)
wx.setStorageSync('token', res.data.token);
let u = "wxapp/public/isMobile";
let header = {
"XX-Token": res.data.token
}
let data = {
type: 1
}
app.post(u, data, header).then((r) => {
console.log(r)
}).catch((err) => {
})
// wx.navigateTo({
// url: '/pages/login/login',
// success: function (res) { },
// fail: function (res) { },
// complete: function (res) { },
// })
}).catch((errMsg) => {
console.log(errMsg);
})
},
changeindexs(e) {
this.setData({
indexs: e.detail.current
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
}
});
},
login(openid, session_key, encrypted_data, iv) {
let that = this;
let param = {
openid: openid,
session_key: session_key,
encrypted_data: encrypted_data,
iv: iv
}
let url = 'wxapp/public/login';
app.post(url, param).then((res) => {
wx.setStorageSync('token', res.token);
wx.navigateTo({
url: '/pages/login/login',
success: function (res) { },
fail: function (res) { },
complete: function (res) { },
})
}).catch((errMsg) => {
console.log(errMsg);
})
},
changeindexs(e){
this.setData({
indexs: e.detail.current
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})
\ No newline at end of file
... ...
<!--pages/kaishi/kaishi.wxml-->
<swiper indicator-dots="{{indicatorDots}}" interval="{{interval}}" duration="{{duration}}" indicator-active-color='{{activecolor}}' indicator-color='{{color}}' current='{{indexs}}' bindchange='changeindexs'>
<block wx:for="{{imgUrls}}" wx:key>
<swiper-item>
<image src="{{item}}" class="slide-image" width="355" height="150" />
</swiper-item>
</block>
<swiper-item>
<view class='start_main'>
<image src='../../imgs/yonghushouyedenglubiejing@3x.png'></image>
<view class='head_txt'>
<view class='head_title'>从友</view>
<view>From·Friends</view>
<view class='head_subtitle'>让娱乐更简单</view>
</view>
<view class='logo'>
<image src='../../imgs/qdongtupian@3x.png'></image>
</view>
</view>
<view class='start_btnbox'>
<button class='start_btn' open-type='getUserInfo' bindgetuserinfo='start'>
<text class='txt'>一起来吧</text> </button>
</view>
</swiper-item>
<swiper indicator-dots="{{indicatorDots}}" interval="{{interval}}" duration="{{duration}}" indicator-active-color='{{activecolor}}' indicator-color='{{color}}' current='{{indexs}}' bindchange='changeindexs'>
<block wx:for="{{imgUrls}}" wx:key>
<swiper-item>
<image src="{{item}}" class="slide-image" width="355" height="150" />
</swiper-item>
</block>
<swiper-item>
<view class='start_main'>
<image src='../../imgs/yonghushouyedenglubiejing@3x.png'></image>
<view class='head_txt'>
<view class='head_title'>从友</view>
<view>From·Friends</view>
<view class='head_subtitle'>让娱乐更简单</view>
</view>
<view class='logo'>
<image src='../../imgs/qdongtupian@3x.png'></image>
</view>
</view>
<view class='start_btnbox'>
<button class='start_btn' open-type='getUserInfo' bindgetuserinfo='start'>
<text class='txt'>一起来吧</text>
</button>
</view>
</swiper-item>
</swiper>
<view class='botsbox'>
<view class='bots {{index==indexs?"activecolor":""}}' wx:for='{{imgUrls.length+1}}' wx:key ></view>
<view class='bots {{index==indexs?"activecolor":""}}' wx:for='{{imgUrls.length+1}}' wx:key></view>
</view>
\ No newline at end of file
... ...
//logs.js
const util = require('../../utils/util.js')
Page({
data: {
logs: []
},
onLoad: function () {
this.setData({
logs: (wx.getStorageSync('logs') || []).map(log => {
return util.formatTime(new Date(log))
})
})
}
})
... ...
{
"navigationBarTitleText": "查看启动日志",
"usingComponents": {}
}
\ No newline at end of file
... ...
<!--logs.wxml-->
<view class="container log-list">
<block wx:for="{{logs}}" wx:for-item="log">
<text class="log-item">{{index + 1}}. {{log}}</text>
</block>
</view>
... ...
.log-list {
display: flex;
flex-direction: column;
padding: 40rpx;
}
.log-item {
margin: 10rpx;
}
... ...
... ... @@ -12,7 +12,7 @@
},
"compileType": "miniprogram",
"libVersion": "2.4.1",
"appid": "wx4ac44ac1779dc6a6",
"appid": "wx6e9436f62c626fb7",
"projectname": "bar",
"debugOptions": {
"hidedInDevtools": []
... ...