作者 乔蒙蒙

酒吧项目提交

1 //app.js 1 //app.js
2 App({ 2 App({
3 - onLaunch: function () {  
4 -  
5 - },  
6 - /**  
7 - * 自定义post函数,返回Promise  
8 - * +-------------------  
9 - * @param {String} url 接口网址  
10 - * @param {arrayObject} data 要传的数组对象 like: {name: 'name', age: 32}  
11 - * +-------------------  
12 - * @return {Promise} promise 返回promise供后续操作  
13 - */  
14 - post: function (url, data, headerParams) {  
15 - wx.showNavigationBarLoading()  
16 - wx.showLoading({  
17 - title: '加载中',  
18 - })  
19 - var promise = new Promise((resolve, reject) => {  
20 - let that = this;  
21 - let postData = data;  
22 - let baseUrl = 'http://saloon.w.bronet.cn/api/';  
23 - //网络请求  
24 - let header = {  
25 - 'content-type': 'application/x-www-form-urlencoded'  
26 - }  
27 - header = Object.assign(header, headerParams)  
28 - wx.request({  
29 - url: baseUrl + url,  
30 - data: postData,  
31 - method: 'POST',  
32 - header: header,  
33 - success: function (res) {//返回取得的数据  
34 - if (res.data.code == '20000') {  
35 - resolve(res.data.data);  
36 - } else if (res.data.code == '10001') {//用户未  
37 -  
38 - } else if (res.data.code == '40000') {  
39 - wx.showModal({  
40 - title: '提示',  
41 - content: res.data.msg,  
42 - showCancel: false,  
43 - success: function (res) {  
44 - }  
45 - })  
46 - } else if (res.data.code == '40005') {  
47 - wx.showModal({  
48 - title: '提示',  
49 - content: res.data.msg,  
50 - showCancel: false,  
51 - success: function (res) {  
52 - if (res.confirm) {  
53 - wx.reLaunch({  
54 - url: '/pages/start/start'  
55 - })  
56 - } else if (res.cancel) {  
57 - console.log('用户点击取消')  
58 - }  
59 - }  
60 - })  
61 - } else if (res.data.code == '40006') { 3 + onLaunch: function () {
62 4
63 - } else {  
64 - wx.showModal({  
65 - title: '提示',  
66 - content: res.data.msg,  
67 - showCancel: false,  
68 - })  
69 - reject(res.data)  
70 - }  
71 - wx.hideLoading()  
72 - wx.hideNavigationBarLoading()  
73 }, 5 },
74 - fail: function (e) {  
75 - console.log(e)  
76 - reject('网络出错');  
77 - // wx.hideLoading()  
78 - wx.hideNavigationBarLoading()  
79 - }  
80 - })  
81 - }); 6 + /**
  7 + * 自定义post函数,返回Promise
  8 + * +-------------------
  9 + * @param {String} url 接口网址
  10 + * @param {arrayObject} data 要传的数组对象 like: {name: 'name', age: 32}
  11 + * +-------------------
  12 + * @return {Promise} promise 返回promise供后续操作
  13 + */
  14 + post: function (url, data, headerParams) {
  15 + wx.showNavigationBarLoading()
  16 + wx.showLoading({
  17 + title: '加载中',
  18 + })
  19 + var promise = new Promise((resolve, reject) => {
  20 + let that = this;
  21 + let postData = data;
  22 + let baseUrl = 'http://saloon.w.bronet.cn/api/';
  23 + //网络请求
  24 + let header = {
  25 + 'content-type': 'application/x-www-form-urlencoded'
  26 + }
  27 + // console.log(baseUrl/ + url)
  28 + header = Object.assign(header, headerParams)
  29 + wx.request({
  30 + url: baseUrl + url,
  31 + data: postData,
  32 + method: 'POST',
  33 + header: header,
  34 + success: function (res) {//返回取得的数据
  35 + // console.log(res)
  36 + if (res.data.code == '20000') {
  37 + resolve(res.data);
  38 + } else if (res.data.code == '10001') {//用户未
  39 +
  40 + } else if (res.data.code == '40000') {
  41 + wx.showModal({
  42 + title: '提示',
  43 + content: res.data.msg,
  44 + showCancel: false,
  45 + success: function (res) {
  46 + }
  47 + })
  48 + } else if (res.data.code == '40005') {
  49 + wx.showModal({
  50 + title: '提示',
  51 + content: res.data.msg,
  52 + showCancel: false,
  53 + success: function (res) {
  54 + if (res.confirm) {
  55 + wx.reLaunch({
  56 + url: '/pages/start/start'
  57 + })
  58 + } else if (res.cancel) {
  59 + console.log('用户点击取消')
  60 + }
  61 + }
  62 + })
  63 + } else if (res.data.code == '40006') {
  64 +
  65 + } else {
  66 + wx.showModal({
  67 + title: '提示',
  68 + content: res.data.msg,
  69 + showCancel: false,
  70 + })
  71 + reject(res.data)
  72 + }
  73 + wx.hideLoading()
  74 + wx.hideNavigationBarLoading()
  75 + },
  76 + fail: function (e) {
  77 + console.log(e)
  78 + reject('网络出错');
  79 + // wx.hideLoading()
  80 + wx.hideNavigationBarLoading()
  81 + }
  82 + })
  83 + });
82 84
83 - return promise;  
84 - },  
85 - //根据年月日获取(星期等信息)////later=0 当前 later=1明天 later=2后天  
86 - dateLater(later) {  
87 - let dateObj = {};  
88 - let show_day = new Array('星期天', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六');  
89 - let date = new Date();  
90 - date.setDate(date.getDate() + later);  
91 - let day = date.getDay();  
92 - dateObj.year = date.getFullYear();  
93 - dateObj.month = ((date.getMonth() + 1) < 10 ? ("0" + (date.getMonth() + 1)) : date.getMonth() + 1);  
94 - dateObj.day = (date.getDate() < 10 ? ("0" + date.getDate()) : date.getDate());  
95 - dateObj.week = show_day[day];  
96 - dateObj.dataday = date.getFullYear() + '-' + ((date.getMonth() + 1) < 10 ? ("0" + (date.getMonth() + 1)) : date.getMonth() + 1) + '-' + (date.getDate() < 10 ? ("0" + date.getDate()) : date.getDate());  
97 - dateObj.houser = date.getHours();//当前时间点  
98 - console.log(date.getHours())  
99 - dateObj.housers = (date.getHours() < 10 ? ("0" + date.getHours()) : date.getHours()) + ':00:00';//当前时间点  
100 - 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';//当前时间并时间点  
101 - return dateObj;  
102 - },  
103 - globalData: {  
104 - userInfo: null  
105 - } 85 + return promise;
  86 + },
  87 + //根据年月日获取(星期等信息)////later=0 当前 later=1明天 later=2后天
  88 + dateLater(later) {
  89 + let dateObj = {};
  90 + let show_day = new Array('星期天', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六');
  91 + let date = new Date();
  92 + date.setDate(date.getDate() + later);
  93 + let day = date.getDay();
  94 + dateObj.year = date.getFullYear();
  95 + dateObj.month = ((date.getMonth() + 1) < 10 ? ("0" + (date.getMonth() + 1)) : date.getMonth() + 1);
  96 + dateObj.day = (date.getDate() < 10 ? ("0" + date.getDate()) : date.getDate());
  97 + dateObj.week = show_day[day];
  98 + dateObj.dataday = date.getFullYear() + '-' + ((date.getMonth() + 1) < 10 ? ("0" + (date.getMonth() + 1)) : date.getMonth() + 1) + '-' + (date.getDate() < 10 ? ("0" + date.getDate()) : date.getDate());
  99 + dateObj.houser = date.getHours();//当前时间点
  100 + console.log(date.getHours())
  101 + dateObj.housers = (date.getHours() < 10 ? ("0" + date.getHours()) : date.getHours()) + ':00:00';//当前时间点
  102 + 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';//当前时间并时间点
  103 + return dateObj;
  104 + },
  105 + globalData: {
  106 + userInfo: null
  107 + }
106 }) 108 })
1 // pages/kaishi/kaishi.js 1 // pages/kaishi/kaishi.js
2 -const app=getApp(); 2 +const app = getApp();
3 Page({ 3 Page({
4 4
5 - /**  
6 - * 页面的初始数据  
7 - */  
8 - data: {  
9 - imgUrls: [  
10 - '../../imgs/lunbo1@3x.png',  
11 - '../../imgs/lunbo2@3x.png',  
12 - '../../imgs/lunbo3@3x.png'  
13 - ],  
14 - indexs:0,  
15 - color:'#cccccc',  
16 - indicatorDots: false,  
17 - autoplay: true,  
18 - activecolor:'#ffffff',  
19 - interval: 5000,  
20 - duration: 1000  
21 - },  
22 -  
23 - start(e) {  
24 - let that = this;  
25 - app.globalData.userInfo = e.detail.userInfo;  
26 -  
27 - wx.login({  
28 - success: function (s) {  
29 - let url = 'wxapp/public/getSessionKey';  
30 - if (s.code) {  
31 - var code = s.code;  
32 - var param = {  
33 - code: code  
34 - }  
35 - app.post(url, param).then((res) => {  
36 - that.login(res.openid, res.session_key, e.detail.encryptedData, e.detail.iv);  
37 - }).catch((errMsg) => {  
38 - console.log(errMsg);  
39 - }) 5 + /**
  6 + * 页面的初始数据
  7 + */
  8 + data: {
  9 + imgUrls: [
  10 + '../../imgs/lunbo1@3x.png',
  11 + '../../imgs/lunbo2@3x.png',
  12 + '../../imgs/lunbo3@3x.png'
  13 + ],
  14 + indexs: 0,
  15 + color: '#cccccc',
  16 + indicatorDots: false,
  17 + autoplay: true,
  18 + activecolor: '#ffffff',
  19 + interval: 5000,
  20 + duration: 1000
  21 + },
  22 +
  23 + start(e) {
  24 + let that = this;
  25 + app.globalData.userInfo = e.detail.userInfo;
  26 + wx.login({
  27 + success: function (s) {
  28 + let url = 'wxapp/public/getSessionKey';
  29 + if (s.code) {
  30 + var code = s.code;
  31 + var param = {
  32 + code: s.code
  33 + }
  34 + app.post(url, param).then((res) => {
  35 + // console.log(res);
  36 + // console.log(e);
  37 + that.login(res.data.openid, res.data.session_key, e.detail.encryptedData, e.detail.iv, e.detail.rawData, e.detail.signature);
  38 + }).catch((errMsg) => {
  39 + console.log(errMsg);
  40 + })
  41 + }
  42 + }
  43 + });
  44 + },
  45 + login(openid, session_key, encrypted_data, iv,r,s) {
  46 + let that = this;
  47 + let param = {
  48 + openid: openid,
  49 + session_key: session_key,
  50 + encrypted_data: encrypted_data,
  51 + iv: iv,
  52 + rawData: r,
  53 + signature: s
  54 + }
  55 + let url = 'wxapp/public/login';
  56 + // wx.navigateTo({
  57 + // url: '/pages/login/login',
  58 + // success: function (res) { },
  59 + // fail: function (res) { },
  60 + // complete: function (res) { },
  61 + // })
  62 + app.post(url, param).then((res) => {
  63 + console.log(res)
  64 + wx.setStorageSync('token', res.data.token);
  65 + let u = "wxapp/public/isMobile";
  66 + let header = {
  67 + "XX-Token": res.data.token
  68 + }
  69 + let data = {
  70 + type: 1
  71 + }
  72 + app.post(u, data, header).then((r) => {
  73 + console.log(r)
  74 + }).catch((err) => {
  75 +
  76 + })
  77 + // wx.navigateTo({
  78 + // url: '/pages/login/login',
  79 + // success: function (res) { },
  80 + // fail: function (res) { },
  81 + // complete: function (res) { },
  82 + // })
  83 + }).catch((errMsg) => {
  84 + console.log(errMsg);
  85 + })
  86 + },
  87 + changeindexs(e) {
  88 + this.setData({
  89 + indexs: e.detail.current
  90 + })
  91 + },
  92 + /**
  93 + * 生命周期函数--监听页面加载
  94 + */
  95 + onLoad: function (options) {
  96 +
  97 + },
  98 +
  99 + /**
  100 + * 生命周期函数--监听页面初次渲染完成
  101 + */
  102 + onReady: function () {
  103 +
  104 + },
  105 +
  106 + /**
  107 + * 生命周期函数--监听页面显示
  108 + */
  109 + onShow: function () {
  110 +
  111 + },
  112 +
  113 + /**
  114 + * 生命周期函数--监听页面隐藏
  115 + */
  116 + onHide: function () {
  117 +
  118 + },
  119 +
  120 + /**
  121 + * 生命周期函数--监听页面卸载
  122 + */
  123 + onUnload: function () {
  124 +
  125 + },
  126 +
  127 + /**
  128 + * 页面相关事件处理函数--监听用户下拉动作
  129 + */
  130 + onPullDownRefresh: function () {
  131 +
  132 + },
  133 +
  134 + /**
  135 + * 页面上拉触底事件的处理函数
  136 + */
  137 + onReachBottom: function () {
  138 +
  139 + },
  140 +
  141 + /**
  142 + * 用户点击右上角分享
  143 + */
  144 + onShareAppMessage: function () {
  145 +
40 } 146 }
41 - }  
42 - });  
43 - },  
44 - login(openid, session_key, encrypted_data, iv) {  
45 - let that = this;  
46 - let param = {  
47 - openid: openid,  
48 - session_key: session_key,  
49 - encrypted_data: encrypted_data,  
50 - iv: iv  
51 - }  
52 - let url = 'wxapp/public/login';  
53 - app.post(url, param).then((res) => {  
54 - wx.setStorageSync('token', res.token);  
55 - wx.navigateTo({  
56 - url: '/pages/login/login',  
57 - success: function (res) { },  
58 - fail: function (res) { },  
59 - complete: function (res) { },  
60 - })  
61 - }).catch((errMsg) => {  
62 - console.log(errMsg);  
63 - })  
64 - },  
65 - changeindexs(e){  
66 - this.setData({  
67 - indexs: e.detail.current  
68 - })  
69 - },  
70 - /**  
71 - * 生命周期函数--监听页面加载  
72 - */  
73 - onLoad: function (options) {  
74 -  
75 - },  
76 -  
77 - /**  
78 - * 生命周期函数--监听页面初次渲染完成  
79 - */  
80 - onReady: function () {  
81 -  
82 - },  
83 -  
84 - /**  
85 - * 生命周期函数--监听页面显示  
86 - */  
87 - onShow: function () {  
88 -  
89 - },  
90 -  
91 - /**  
92 - * 生命周期函数--监听页面隐藏  
93 - */  
94 - onHide: function () {  
95 -  
96 - },  
97 -  
98 - /**  
99 - * 生命周期函数--监听页面卸载  
100 - */  
101 - onUnload: function () {  
102 -  
103 - },  
104 -  
105 - /**  
106 - * 页面相关事件处理函数--监听用户下拉动作  
107 - */  
108 - onPullDownRefresh: function () {  
109 -  
110 - },  
111 -  
112 - /**  
113 - * 页面上拉触底事件的处理函数  
114 - */  
115 - onReachBottom: function () {  
116 -  
117 - },  
118 -  
119 - /**  
120 - * 用户点击右上角分享  
121 - */  
122 - onShareAppMessage: function () {  
123 -  
124 - }  
125 }) 147 })
1 <!--pages/kaishi/kaishi.wxml--> 1 <!--pages/kaishi/kaishi.wxml-->
2 -<swiper indicator-dots="{{indicatorDots}}" interval="{{interval}}" duration="{{duration}}" indicator-active-color='{{activecolor}}' indicator-color='{{color}}' current='{{indexs}}' bindchange='changeindexs'>  
3 - <block wx:for="{{imgUrls}}" wx:key>  
4 - <swiper-item>  
5 - <image src="{{item}}" class="slide-image" width="355" height="150" />  
6 - </swiper-item>  
7 -  
8 - </block>  
9 - <swiper-item>  
10 - <view class='start_main'>  
11 - <image src='../../imgs/yonghushouyedenglubiejing@3x.png'></image>  
12 - <view class='head_txt'>  
13 - <view class='head_title'>从友</view>  
14 - <view>From·Friends</view>  
15 - <view class='head_subtitle'>让娱乐更简单</view>  
16 - </view>  
17 - <view class='logo'>  
18 - <image src='../../imgs/qdongtupian@3x.png'></image>  
19 - </view>  
20 - </view>  
21 - <view class='start_btnbox'>  
22 - <button class='start_btn' open-type='getUserInfo' bindgetuserinfo='start'>  
23 - <text class='txt'>一起来吧</text> </button>  
24 - </view>  
25 - </swiper-item> 2 +<swiper indicator-dots="{{indicatorDots}}" interval="{{interval}}" duration="{{duration}}" indicator-active-color='{{activecolor}}' indicator-color='{{color}}' current='{{indexs}}' bindchange='changeindexs'>
  3 + <block wx:for="{{imgUrls}}" wx:key>
  4 + <swiper-item>
  5 + <image src="{{item}}" class="slide-image" width="355" height="150" />
  6 + </swiper-item>
  7 +
  8 + </block>
  9 + <swiper-item>
  10 + <view class='start_main'>
  11 + <image src='../../imgs/yonghushouyedenglubiejing@3x.png'></image>
  12 + <view class='head_txt'>
  13 + <view class='head_title'>从友</view>
  14 + <view>From·Friends</view>
  15 + <view class='head_subtitle'>让娱乐更简单</view>
  16 + </view>
  17 + <view class='logo'>
  18 + <image src='../../imgs/qdongtupian@3x.png'></image>
  19 + </view>
  20 + </view>
  21 + <view class='start_btnbox'>
  22 + <button class='start_btn' open-type='getUserInfo' bindgetuserinfo='start'>
  23 + <text class='txt'>一起来吧</text>
  24 + </button>
  25 + </view>
  26 + </swiper-item>
26 </swiper> 27 </swiper>
27 <view class='botsbox'> 28 <view class='botsbox'>
28 -<view class='bots {{index==indexs?"activecolor":""}}' wx:for='{{imgUrls.length+1}}' wx:key ></view> 29 + <view class='bots {{index==indexs?"activecolor":""}}' wx:for='{{imgUrls.length+1}}' wx:key></view>
29 </view> 30 </view>
  1 +//logs.js
  2 +const util = require('../../utils/util.js')
  3 +
  4 +Page({
  5 + data: {
  6 + logs: []
  7 + },
  8 + onLoad: function () {
  9 + this.setData({
  10 + logs: (wx.getStorageSync('logs') || []).map(log => {
  11 + return util.formatTime(new Date(log))
  12 + })
  13 + })
  14 + }
  15 +})
  1 +{
  2 + "navigationBarTitleText": "查看启动日志",
  3 + "usingComponents": {}
  4 +}
  1 +<!--logs.wxml-->
  2 +<view class="container log-list">
  3 + <block wx:for="{{logs}}" wx:for-item="log">
  4 + <text class="log-item">{{index + 1}}. {{log}}</text>
  5 + </block>
  6 +</view>
  1 +.log-list {
  2 + display: flex;
  3 + flex-direction: column;
  4 + padding: 40rpx;
  5 +}
  6 +.log-item {
  7 + margin: 10rpx;
  8 +}
@@ -12,7 +12,7 @@ @@ -12,7 +12,7 @@
12 }, 12 },
13 "compileType": "miniprogram", 13 "compileType": "miniprogram",
14 "libVersion": "2.4.1", 14 "libVersion": "2.4.1",
15 - "appid": "wx4ac44ac1779dc6a6", 15 + "appid": "wx6e9436f62c626fb7",
16 "projectname": "bar", 16 "projectname": "bar",
17 "debugOptions": { 17 "debugOptions": {
18 "hidedInDevtools": [] 18 "hidedInDevtools": []