Commit 6bfb418fef63acd58c342fb00c1c0c1f85a1cdcd

Authored by zhangyan
0 parents

no message

Showing 74 changed files with 3897 additions and 0 deletions
App({
})
\ No newline at end of file
... ...
{
"pages":[
"pages/book/b_index",
"pages/book/b_detail",
"pages/book/b_add",
"pages/book/b_info",
"pages/book/b_desk"
],
"window":{
"backgroundTextStyle":"light",
"navigationBarBackgroundColor": "#199095",
"navigationBarTitleText": "点餐商户端",
"navigationBarTextStyle":"light"
},
"networkTimeout": {
"request": 10000,
"downloadFile": 10000
},
"debug": true
}
\ No newline at end of file
... ...
/*水平方向左右分布*/
.flex-lr{
display: flex;
display: -webkit-flex;
justify-content: space-between;
align-items:center;
flex-direction: row;
-webkit-flex-direction: row;
}
.flex-ll{
display: flex;
display: -webkit-flex;
justify-content: flex-start;
align-items: center;
flex-direction: row;
-webkit-flex-direction: row;
}
.flex-rr{
display: flex;
display: -webkit-flex;
justify-content: flex-end;
align-items: center;
flex-direction: row;
-webkit-flex-direction: row;
}
/*垂直方向居中分布*/
.flex-vc{
display: flex;
display: -webkit-flex;
justify-content: center;
align-items: center;
flex-direction: column;
-webkit-flex-direction: column;
}
/*垂直方向居左分布*/
.flex-vl{
display: flex;
display: -webkit-flex;
justify-content: flex-start;
align-items: left;
flex-direction: column;
-webkit-flex-direction: column;
}
.flex-vr{
display: flex;
display: -webkit-flex;
justify-content: flex-end;
align-items: center;
flex-direction: column;
-webkit-flex-direction: column;
}
/*水平方向居中分布*/
.flex-cc{
display: flex;
display: -webkit-flex;
justify-content: center;
align-items: center;
flex-direction: row;
-webkit-flex-direction: row;
}
/*基准线对齐*/
.flex-bc{
display: flex;
display: -webkit-flex;
justify-content: center;
align-items: baseline;
flex-direction: row;
-webkit-flex-direction: row;
}
/*流式布局*/
.flex-auto{
display: flex;
display: -webkit-flex;
justify-content: space-around;
align-content: flex-start;
flex-flow:wrap;
}
.font34r{
font-size:34rpx;
}
.font28r{
font-size:28rpx;
}
.font30r{
font-size:30rpx;
}
.font32r{
font-size:32rpx;
}
.font26r{
font-size:26rpx;
}
.font24r{
font-size:24rpx;
}
.font38r{
font-size:38rpx;
}
.font40r{
font-size:40rpx;
}
.font44r{
font-size:44rpx;
}
.font20r{
font-size:20rpx;
}
.black-font{
color:#353535;
}
.white-font{
color:#fff;
}
.green-font{
color:#199095;
}
.flex-rc{
display:flex;
display: -webkit-flex;
justify-content:center;
align-items:center;
}
.flex-rs{
display:flex;
display: -webkit-flex;
justify-content:flex-start;
align-items:center;
flex-direction: row;
flex-wrap:wrap;
}
.flex-cmc{
display:flex;
display: -webkit-flex;
justify-content:center;
align-items:center;
flex-direction: column;
}
.flex-re{
display:flex;
display: -webkit-flex;
justify-content:flex-end;
}
.default-setting{
color:#999;
font-size:38rpx;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.cut{
width:100%;
height:20rpx;
}
.smooth{
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
button::after{
border:0;
}
.font-bold{
font-weight:bold;
}
.font-more{
overflow:hidden;
text-overflow:ellipsis;
white-space:nowrap;
}
.font-more-two{
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
overflow: hidden;
}
image{
background:transparent;
}
.gray-font{
color:#999;
}
.gray-deep-font{
color:#666;
}
.icon12-22{
width:12rpx;
height:22rpx;
background:transparent;
}
.bg_white{
background:#fff;
}
.bg_green{
background:#199095;
}
.bg_gray{
background:#efeef3;
}
.font-siny{
font-weight:300;
}
.cut{
width:100%;
height:20rpx;
}
.border-right{
border-right:1px solid #efeef3;
}
\ No newline at end of file
... ...
var util = require('../../../utils/util.js')
var uri=require('../../../utils/uri.js');
var systemInfo=util.getsystem();
Component({
properties:{
},
data:{
height:systemInfo.windowHeight
},
methods:{
addBook:function(){
wx.navigateTo({
url:'/pages/book/b_add'
})
}
}
})
\ No newline at end of file
... ...
{
"component": true
}
\ No newline at end of file
... ...
<view class="fixed-button white-font font34r flex-lr smooth">
<view class="book-button flex-cc">查空位</view>
<view class="book-button flex-cc" bindtap="addBook">录入订座</view>
</view>
\ No newline at end of file
... ...
@import '../common.wxss';
.fixed-button{
width:700rpx;
height:85rpx;
margin:0 auto;
position:fixed;
left:0;
right:0;
bottom:60rpx;
padding-top:40rpx;
background:transparent;
}
.book-button{
width:320rpx;
height:100%;
background:#199095;
border-radius:10rpx;
}
\ No newline at end of file
... ...
.font34r{
font-size:34rpx;
}
.font28r{
font-size:28rpx;
}
.font30r{
font-size:30rpx;
}
.font32r{
font-size:32rpx;
}
.font26r{
font-size:26rpx;
}
.font24r{
font-size:24rpx;
}
.font36r{
font-size:36rpx;
}
.font38r{
font-size:38rpx;
}
.font40r{
font-size:40rpx;
}
.font44r{
font-size:44rpx;
}
.font72r{
font-size:72rpx;
}
.black-font{
color:#353535;
}
.white-font{
color:#fff;
}
.green-font{
color:#199095;
}
.flex-rc{
display:flex;
display: -webkit-flex;
justify-content:center;
align-items:center;
}
.flex-rs{
display:flex;
display: -webkit-flex;
justify-content:flex-start;
align-items:center;
flex-direction: row;
flex-wrap:wrap;
}
.flex-cmc{
display:flex;
display: -webkit-flex;
justify-content:center;
align-items:center;
flex-direction: column;
}
.flex-re{
display:flex;
display: -webkit-flex;
justify-content:flex-end;
}
/*水平方向左右分布*/
.flex-lr{
display: flex;
display: -webkit-flex;
justify-content: space-between;
align-items:center;
flex-direction: row;
-webkit-flex-direction: row;
}
.flex-ll{
display: flex;
display: -webkit-flex;
justify-content: flex-start;
align-items: center;
flex-direction: row;
-webkit-flex-direction: row;
}
.flex-rr{
display: flex;
display: -webkit-flex;
justify-content: flex-end;
align-items: center;
flex-direction: row;
-webkit-flex-direction: row;
}
/*垂直方向居中分布*/
.flex-vc{
display: flex;
display: -webkit-flex;
justify-content: center;
align-items: center;
flex-direction: column;
-webkit-flex-direction: column;
}
/*垂直方向居左分布*/
.flex-vl{
display: flex;
display: -webkit-flex;
justify-content: flex-start;
align-items: left;
flex-direction: column;
-webkit-flex-direction: column;
}
.flex-vr{
display: flex;
display: -webkit-flex;
justify-content: flex-end;
align-items: center;
flex-direction: column;
-webkit-flex-direction: column;
}
/*水平方向居中分布*/
.flex-cc{
display: flex;
display: -webkit-flex;
justify-content: center;
align-items: center;
flex-direction: row;
-webkit-flex-direction: row;
}
/*基准线对齐*/
.flex-bc{
display: flex;
display: -webkit-flex;
justify-content: center;
align-items: baseline;
flex-direction: row;
-webkit-flex-direction: row;
}
/*流式布局*/
.flex-auto{
display: flex;
display: -webkit-flex;
justify-content: space-around;
align-content: flex-start;
flex-flow:wrap;
}
.cut{
width:100%;
height:20rpx;
}
.smooth{
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
button::after{
border:0;
}
.font-bold{
font-weight:bold;
}
.font-more{
overflow:hidden;
text-overflow:ellipsis;
white-space:nowrap;
}
.font-more-two{
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
overflow: hidden;
}
image{
background:transparent;
}
.gray-font{
color:#999;
}
.gray-deep-font{
color:#666;
}
.icon12-22{
width:12rpx;
height:22rpx;
background:transparent;
}
.bg-white{
background:#fff;
}
.green-font{
color:#199095;
}
.font-more{
overflow:hidden;
text-overflow:ellipsis;
white-space:nowrap;
}
button{
margin:0;
padding:0;
background:transparent;
}
\ No newline at end of file
... ...
var util = require('../../../utils/util.js')
var uri=require('../../../utils/uri.js');
Component({
properties:{
list:Array
},
data:{
},
methods:{
selectdesk:function(e){
var tebleid=e.currentTarget.dataset.id;
var tables=util.cache('tableid') ? util.cache('tableid') : [];
var list=this.data.list;
list.forEach(function(v,i){
if(v.id==tebleid){
if(v.isselect==true){
var thisindex=tables.indexOf(tebleid);
tables.splice(thisindex,1)
}else{
tables.push(tebleid)
}
v.isselect=!v.isselect
}
})
util.cache('tableid',tables);
this.triggerEvent("changedesk");
this.setData({
list:list
})
}
}
})
\ No newline at end of file
... ...
{
"component": true
}
\ No newline at end of file
... ...
<view class="desk-list flex-rs">
<block wx:for="{{list}}">
<block wx:if="{{!item.r_status}}">
<view class="desk-single flex-vc green-deep-bg desk-can black-font" data-id="{{item.id}}" bindtap="selectdesk">
<view class="font38r font-bold desk-name flex-cc font-more">{{item.name}}</view>
<view class="font34r desk-pnum flex-cc">{{item.table_pnum}}人桌</view>
<view class="desk-mask {{item.isselect==true ? 'desk-mask-active white-font flex-vc font24r' : ''}}">
<block wx:if="{{item.isselect==false}}">
<icon type="success_no_circle" class="icon-success" color="#fff" size="13"></icon>
</block>
<block wx:else>
{{index+1}}
</block>
</view>
</view>
</block>
<block wx:if="{{item.r_status==1}}">
<view class="desk-single flex-vc gray-deep-bg desk-nocan black-font">
<view class="font38r desk-name flex-cc font-more">{{item.name}}</view>
<view class="font34r desk-pnum flex-cc">{{item.table_pnum}}人桌</view>
<view class="desk-status white-font flex-cc font32r">已预订</view>
</view>
</block>
<!--<block wx:if="{{item.rstatus==2}}">
<view class="desk-single flex-vc green-light-bg desk-nocan black-font">
<view class="font38r desk-name flex-ll font-more">{{item.name}}</view>
<view class="font34r desk-pnum flex-lr">
<view class="gray-deep-font font34r">{{item.pnum}}人</view>
<view class="flex-rr">
<image class="desk-time" src="/pages/image/clock.png"></image>
<view class="font24r gray-font">10</view>
</view>
</view>
<view class="desk-status white-font flex-cc font32r">用餐中</view>
</view>
</block>-->
</block>
</view>
\ No newline at end of file
... ...
@import '../common.wxss';
.desk-list{
width:740rpx;
height:auto;
margin:0 auto;
}
.desk-single{
width:200rpx;
height:200rpx;
box-sizing:border-box;
border-radius:10rpx;
margin-left:35rpx;
margin-top:40rpx;
position:relative;
}
.desk-can{
padding-top:10rpx;
}
.desk-nocan{
padding-bottom:55rpx;
}
.desk-name{
width:100%;
padding:0 20rpx;
box-sizing:border-box;
display:inline-block;
text-align:center;
}
.desk-pnum{
width:100%;
padding:0 20rpx;
box-sizing:border-box;
margin-top:10rpx;
}
.desk-mask{
width:36rpx;
height:36rpx;
border-radius:50%;
border:1px solid #fff;
position:absolute;
right:10rpx;
top:10rpx;
}
.desk-mask-active{
border:1px solid #199095;
background:#199095;
}
.icon-success{
position:absolute;
left:4rpx;
top:6rpx;
}
.green-deep-bg{
border:1px solid #199095;
background:#A9E3E6;
}
.gray-deep-bg{
border:1px solid #999;
background:#e0e0e0;
}
.green-light-bg{
border:1px solid #999;
background:#EBF8F8;
}
.desk-time{
width:28rpx;
height:28rpx;
margin-right:6rpx;
}
.desk-status{
position:absolute;
left:0;
bottom:0;
width:100%;
height:55rpx;
background:#777;
}
\ No newline at end of file
... ...
var util = require('../../../utils/util.js')
var uri=require('../../../utils/uri.js');
Component({
properties:{
item:Object
},
data:{
},
methods:{
detail:function(e){
var obj=e.currentTarget.dataset.obj;
var path='';
var i=0;
for (var key in obj){
i++;
if(i==1){
path=path+'?'+key+'='+obj[key]
}else{
path=path+'&'+key+'='+obj[key]
}
}
wx.navigateTo({
url:'b_detail'+path
})
},
}
})
\ No newline at end of file
... ...
{
"component": true
}
\ No newline at end of file
... ...
<view class="book-list-tds flex-lr font30r black-font" data-obj="{{item}}" bindtap="detail">
<view class="book-list-td flex-cc">
<view class="book-list-info font-more-two" style="display:block;">{{item.name}}</view>
</view>
<view class="book-list-td flex-cc">{{item.order_time}}</view>
<view class="book-list-td flex-cc">
<block wx:if="{{item.status==1}}">已预订</block>
<block wx:if="{{item.status==2}}">点餐中</block>
</view>
<view class="book-list-td flex-rr green-font">查看详情</view>
</view>
\ No newline at end of file
... ...
@import '../common.wxss';
.book-list-tds{
width:100%;
height:160rpx;
padding:0 40rpx;
box-sizing:border-box;
}
.book-list-td{
width:25%;
height:100%;
}
.book-list-info{
width:100%;
line-height:1.2;
}
\ No newline at end of file
... ...
var util = require('../../../utils/util.js')
var uri=require('../../../utils/uri.js');
var systemInfo=util.getsystem();
Component({
properties:{
height:{
type:Number,
value:systemInfo.windowHeight
}
},
data:{
},
methods:{
}
})
\ No newline at end of file
... ...
{
"component": true
}
\ No newline at end of file
... ...
<view style="height:{{height}}px;" class="nothing-page flex-vc bg-white">
<image class="nothing-booklist" src="/pages/image/nothing-booklist.png"></image>
<view class="black-font font34r smooth nothing-content">暂无内容</view>
</view>
\ No newline at end of file
... ...
@import '../common.wxss';
.nothing-page{
width:100%;
padding-bottom:90rpx;
box-sizing:border-box;
}
.nothing-booklist{
width:384rpx;
height:296rpx;
}
.nothing-content{
margin-top:40rpx;
}
\ No newline at end of file
... ...
var util = require('../../../utils/util.js')
var uri=require('../../../utils/uri.js');
Component({
properties:{
phoneNumber:String
},
data:{
list:[
{
imgurl:'/pages/image/notice-wx.png',
title:'微信'
},
{
imgurl:'/pages/image/notice-msg.png',
title:'短信'
},
{
imgurl:'/pages/image/notice-call.png',
title:'电话'
}
],
noticeHidden:true
},
methods:{
show:function(){
this.setData({
noticeHidden:false
})
},
close:function(){
this.setData({
noticeHidden:true
})
},
callcustom:function(e){
var idx=e.currentTarget.dataset.idx;
if(idx==2){
var that=this;
wx.makePhoneCall({
phoneNumber: this.data.phoneNumber, //仅为示例,并非真实的电话号码
complete:function(){
that.close();
}
})
}
if(idx==0){
this.triggerEvent("share");
}
}
}
})
\ No newline at end of file
... ...
{
"component": true
}
\ No newline at end of file
... ...
<view class="notice-mask" hidden="{{noticeHidden}}" bindtap="close"></view>
<view class="notice-fixed flex-lr {{noticeHidden==false ? 'notice-fixed-active' : ''}}">
<block wx:for="{{list}}">
<block wx:if="{{index!=0}}">
<view class="notice-single flex-vc" bindtap="callcustom" data-idx="{{index}}">
<view class="notice-image flex-vc">
<image src="{{item.imgurl}}" class="notice-image-icon"></image>
</view>
<view class="black-font font30r">{{item.title}}</view>
</view>
</block>
<block wx:else>
<button class="notice-single flex-vc" open-type="share">
<view class="notice-image flex-vc">
<image src="{{item.imgurl}}" class="notice-image-icon"></image>
</view>
<view class="black-font font30r">{{item.title}}</view>
</button>
</block>
</block>
</view>
\ No newline at end of file
... ...
@import '../common.wxss';
.notice-mask{
position:fixed;
left:0;
right:0;
top:0;
bottom:0;
background:rgba(0,0,0,0);
}
.notice-fixed{
width:100%;
height:322rpx;
padding:0 50rpx;
box-sizing:border-box;
background:#F0F0F1;
position:fixed;
left:0;
bottom:-322rpx;
transition:bottom .3s ease;
}
.notice-fixed-active{
bottom:0;
}
.notice-single{
width:160rpx;
height:auto;
}
.notice-image{
width:100%;
height:160rpx;
background:#fff;
border-radius:10rpx;
margin-bottom:30rpx;
}
.notice-image-icon{
width:100rpx;
height:100rpx;
}
\ No newline at end of file
... ...
var util = require('../../../utils/util.js')
var uri=require('../../../utils/uri.js');
var systemInfo=util.getsystem();
Component({
properties:{
pnum:String
},
data:{
},
methods:{
editPnum:function(e){
this.setData({
pnum:parseInt(e.detail.pnum)
})
util.cache('order_pnum',this.data.pnum)
this.triggerEvent("changepnum",this.data.pnum);
},
addPnum:function(){
var pnum=parseInt(this.data.pnum);
if(this.data.pnum<10000) {
this.setData({
pnum: pnum + 1
})
util.cache('order_pnum',this.data.pnum)
this.triggerEvent("changepnum",this.data.pnum);
}
},
reducePnum:function(){
var pnum=parseInt(this.data.pnum);
if(pnum>1){
this.setData({
pnum:pnum-1
})
util.cache('order_pnum',this.data.pnum)
this.triggerEvent("changepnum",this.data.pnum);
}
}
}
})
\ No newline at end of file
... ...
{
"component": true
}
\ No newline at end of file
... ...
<view class="selected-time flex-cc">
<view class="flex-vc padding-topbottom padding-left25" bindtap="reducePnum">
<image src="/pages/image/reduce-act.png" class="select-act"></image>
</view>
<input value="{{pnum}}" class="select-input flex-cc green-font font34r" bindunput="editpnum"/>
<view class="flex-vc padding-topbottom padding-right25" bindtap="addPnum">
<image src="/pages/image/add-act.png" class="select-act"></image>
</view>
</view>
\ No newline at end of file
... ...
@import '../common.wxss';
.selected-time{
width:375rpx;
height:100%;
}
.select-act{
width:48rpx;
height:48rpx;
}
.select-input{
width:100rpx;
height:44rpx;
text-align:center;
margin:0 15rpx;
}
.padding-topbottom{
padding:25rpx 0;
}
.padding-left25{
padding-left:25rpx;
}
.padding-right25{
padding-right:25rpx;
}
\ No newline at end of file
... ...
var util = require('../../../utils/util.js')
var uri=require('../../../utils/uri.js');
Component({
properties:{
item:Object
},
data:{
},
methods:{
selecttime:function(e){
var time_dur=e.currentTarget.dataset.time_dur;
console.log(e)
this.triggerEvent("changelist",time_dur);
var title=e.currentTarget.dataset.title;
var timelist=this.data.item;
timelist.list.forEach(function(v,i){
v.isselect=false
if(v.time_dur==time_dur){
v.isselect=true;
}
})
this.setData({
item:timelist
})
}
}
})
\ No newline at end of file
... ...
{
"component": true
}
\ No newline at end of file
... ...
<view class="time-dur">
<view class="border-line"></view>
<view class="time-dur-title black-font font30r">{{item.title}} <text class="font26r smooth gray-deep-font">({{item.time_dur}})</text></view>
<view class="time-list flex-rs">
<block wx:for="{{item.list}}" wx:for-item="list">
<view class="time-single flex-cc gray-deep-font {{list.isselect==true ? 'time-single-active' : ''}} font30r smooth" data-time_dur="{{list.time_dur}}" bindtap="selecttime" data-title="{{item.title}}">{{list.time_dur}}</view>
</block>
</view>
</view>
\ No newline at end of file
... ...
@import '../common.wxss';
.time-dur{
width:100%;
height:auto;
padding-bottom:45rpx;
}
.border-line{
width:680rpx;
height:1px;
background:#efeef3;
margin:0 auto;
}
.time-single{
width:120rpx;
height:75rpx;
border:1px solid #999;
box-sizing:border-box;
border-radius:8rpx;
margin-left:44rpx;
margin-right:16rpx;
margin-top:30rpx;
}
.time-dur-title{
width:100%;
padding:0 44rpx;
padding-top:35rpx;
box-sizing:border-box;
}
.time-single-active{
border:0;
background:#A9E3E6;
}
\ No newline at end of file
... ...
var util = require('../../utils/util.js')
var uri=require('../../utils/uri.js')
var bookOrder=require('../../utils/bookCommon.js')
Page({
data:{
},
onLoad:function(){
util.setBarTitle('选择用餐时间');
this.getdatelist()
this.getimelist();
wx.removeStorage({
key:'order_pnum',
})
wx.removeStorage({
key:'tabletype',
})
},
onShow:function(){
},
changelist:function(e){
console.log('xxxx',e)
var timelist=this.data.timeList;
timelist.forEach(function(v,i){
v.list.forEach(function(r,n){
r.isselect=false
})
})
this.setData({
timeList:timelist,
time_dur:e.detail
})
},
//日期选择
selectdate:function(e){
var title=e.currentTarget.dataset.title;
var datelist=this.data.dateList;
var selectdate=''
datelist.forEach(function(v,i){
v.isActive=false
if(v.title==title){
v.isActive=true;
selectdate=v.date
}
})
this.setData({
dateList:datelist,
selectdate:selectdate,
time_dur:null
})
this.getimelist();
},
selectOther:function(){
var currentTime=Date.parse(new Date());
var timeobj=bookOrder.changedate(currentTime)
console.log(this.data.selectdate,this.data.time_dur)
wx.navigateTo({
url:'b_info?year='+timeobj.year+'&date='+this.data.selectdate+'&time='+this.data.time_dur
})
},
//获取日期列表
getdatelist:function(){
var currentTime=Date.parse(new Date());
var dur=24*60*60*1000;
var list=[currentTime,currentTime+dur,currentTime+2*dur];
var desklist=[];
for(var i=0;i<list.length;i++){
var dd=bookOrder.changedate(list[i]);
if(i==0){
var title='今天';
var isselect=true
}
if(i==1){
var title='明天';
var isselect=false
}
if(i==2){
var myDate = new Date(list[2]);
var title=bookOrder.getweek(myDate.getDay());
var isselect=false
}
desklist.push({
title:title,
date:'0'+dd.month+(dd.day<10 ? '-0'+dd.day : '-'+dd.day),
isActive:isselect,
year:dd.year
})
}
this.setData({
dateList:desklist,
selectdate:desklist[0].date
})
console.log(this.data.selectdate)
},
//获取时间列表
getimelist:function(){
var currentTime=Date.parse(new Date());
var timeobj=bookOrder.changedate(currentTime)
var timelist=[
{
title:'早市',
time_dur:'6:00-10:00',
list:[
{
time_dur:'6:00',
isselect:false,
time_mask:6
}
],
starttime:6,
endtime:10
},
{
title:'午市',
time_dur:'11:00-15:00',
list:[
{
time_dur:'11:00',
isselect:false,
time_mask:11
}
],
starttime:11,
endtime:15
},
{
title:'晚市',
time_dur:'17:00-22:00',
list:[
{
time_dur:'17:00',
isselect:false,
time_mask:17
}
],
starttime:17,
endtime:22
},
];
var that=this;
timelist.forEach(function(v,i){
var len=(v.endtime-v.starttime)/0.5;
var time=v.starttime;
console.log(len)
for(var j=0;j<len;j++){
time+=0.5;
if(bookOrder.isInteger(time)==true){
v.list.push(
{
time_dur:time+':00',
isselect:false,
time_mask:time
}
)
}else{
v.list.push(
{
time_dur:Math.floor(time)+':30',
isselect:false,
time_mask:time
}
)
}
}
})
var thisdate=0;
if(that.data.selectdate.split('-')[1].length>1){
thisdate=parseInt(that.data.selectdate.split('-')[1][0]=='0' ? that.data.selectdate.split('-')[1].slice(1,2) : that.data.selectdate.split('-')[1])
}else{
thisdate=parseInt(that.data.selectdate.split('-')[1])
}
if(thisdate==timeobj.day){
var thistime=timeobj.hour+timeobj.minute/60;
var dd=[]
timelist.forEach(function(v,i){
if(thistime<v.endtime){
dd.push(v)
}
})
timelist=dd;
timelist.forEach(function(v,i){
if(thistime>=v.starttime && thistime<=v.endtime){
var list=[]
v.list.forEach(function(r,n){
if(thistime<r.time_mask){
list.push(r)
}
})
v.list=list
}
})
}
this.setData({
timeList:timelist
})
},
})
\ No newline at end of file
... ...
{
"backgroundTextStyle":"light",
"navigationBarBackgroundColor": "#fff",
"navigationBarTextStyle":"black",
"usingComponents": {
"timeDuration":"/components/book/time/time"
}
}
\ No newline at end of file
... ...
<!--日期-->
<view style="padding-bottom:160rpx;">
<view class="select-date flex-lr smooth">
<block wx:for="{{dateList}}">
<view class="single-date gray-deep-font flex-vc" bindtap="selectdate" data-title="{{item.title}}">
<view class="font30r {{item.isActive==true ? 'black-font' : ''}}">{{item.title}}</view>
<view class="font34r date-num flex-cc {{item.isActive==true ? 'select-date-active black-font' : ''}}">{{item.date}}</view>
</view>
</block>
<view class="single-date gray-deep-font flex-vc">
<view class="font30r">更多</view>
<view class="date-num flex-vc">
<image src="../image/more-dot.png" class="more-dot"></image>
</view>
</view>
</view>
<block wx:for="{{timeList}}">
<timeDuration item="{{item}}" bind:changelist="changelist"></timeDuration>
</block>
</view>
<view class="confirm-button white-font flex-vc font34r {{time_dur ? 'confirm-button-active' : ''}}" bindtap="{{time_dur ? 'selectOther' : ''}}">确定</view>
<date-picker
startTime="{{startTime}}"
endTime="{{endTime}}"
unit="{{unit}}"
reserveUnit="{{reserveUnit}}"
unreserveTime="{{unreserveTime}}"
activedConst="{{activedConst}}"
disabledConst="{{disabledConst}}"
themeColor="#1f78d1"
bind:selectTime="onSelectTime"
/>
\ No newline at end of file
... ...
.select-date{
width:680rpx;
height:180rpx;
margin:0 auto;
}
.more-dot{
width:50rpx;
height:10rpx;
}
.date-num{
padding:0 10rpx;
height:70rpx;
}
.select-date-active{
border-bottom:2px solid #199095;
box-sizing:border-box;
}
.confirm-button{
width:680rpx;
height:85rpx;
background:#74BBBE;
position:fixed;
left:0;
right:0;
bottom:60rpx;
margin:0 auto;
border-radius:10rpx;
}
.confirm-button-active{
background:#199095;
}
\ No newline at end of file
... ...
var util = require('../../utils/util.js')
var uri=require('../../utils/uri.js')
var bookOrder=require('../../utils/bookCommon.js')
Page({
data:{
desk_type:[
{
type:2,
type_name:'包厢',
isselect:true
},
{
type:1,
type_name:'散座',
isselect:false,
},
{
type:'',
type_name:'全部',
isselect:false
}
],
tabletype:2
},
onLoad:function(opt){
console.log(opt)
util.setBarTitle('选择桌位');
var radio=750/util.getsystem().windowWidth;
var contentHeight=util.getsystem().windowHeight-Math.ceil(350/radio);
var temdate=bookOrder.get_date(opt.date);
var stringTime =opt.year+'-'+temdate+' ' +opt.time_dur+':00';
console.log(stringTime)
var time=bookOrder.gettimestamp(stringTime);
this.setData({
sellerid:util.cache('sellerid'),
selectdate:opt.date,
time_dur:opt.time_dur,
pnum:opt.pnum,
contentHeight:contentHeight,
time:time,
thisyear:opt.year
})
console.log(time)
var thistype=util.cache('tabletype');
var fixedtype=this.data.desk_type;
var dd=[];
for(var key in thistype){
var type=key.split('_')[1];
fixedtype.forEach(function(v,i){
if(v.type==type){
v.isselect=false;
if(type==2){
dd.unshift(v)
}else{
dd.push(v)
}
}
})
}
dd.push({
type:'',
type_name:'全部',
isselect:false
})
dd[0].isselect=true;
this.setData({
desk_type:dd,
tabletype:dd[0].type
})
this.getdesklist();
},
onShow:function(){
var that=this;
util.postSuccessFun=function(json,uri_code){
switch (uri_code) {
case uri.CGI_USER_GETTABLELIST__CODE:
console.log(json)
var desklist=json.data;
var thisdesk=[];
for(var key in desklist){
if(bookOrder.isInteger(key)==true){
desklist[key].list.forEach(function(r,n){
r.isselect=false;
if(util.cache('tableid')){
var tables=util.cache('tableid');
tables.forEach(function(v,i){
if(v==r.id){
r.isselect=true;
}
})
}
})
thisdesk.push(desklist[key])
}
}
if(that.data.tabletype!=''){
that.selectdesk(thisdesk);
}else{
that.setData({
desklist:thisdesk
})
}
console.log(that.data.desklist)
break;
}
}
},
selectType:function(e){
var type=e.currentTarget.dataset.type;
var desktype=this.data.desk_type;
desktype.forEach(function(v,i){
v.isselect=false
if(v.type==type){
v.isselect=true
}
})
this.setData({
desk_type:desktype,
tabletype:type
})
this.getdesklist();
},
selectdesk:function(desklist){
var type=this.data.tabletype;
console.log('tttt',desklist)
var thislist=[];
var temp={}
desklist.forEach(function(v,i){
v.list.forEach(function(r,n){
if(r.tid==type){
if(!temp.hasOwnProperty(v.name)){
temp[v.name]=true;
thislist.push({
name:v.name,
list:[]
})
}
}
})
})
console.log(thislist)
desklist.forEach(function(v,i){
thislist.forEach(function(r,n){
if(v.name==r.name){
v.list.forEach(function(r1,n1){
if(r1.tid==type){
r.list.push(r1)
}
})
}
})
})
this.setData({
desklist:thislist
})
},
changepnum:function(e){
this.setData({
pnum:e.detail
})
this.getdesklist();
},
changedesk:function(e){
var tableid=e.detail;
this.setData({
tableid:util.cache('tableid') && util.cache('tableid').length>0 ? util.cache('tableid') :null
})
},
back:function(){
this.setData({
buttonClick:true
})
wx.navigateBack()
},
getdesklist:function(){
util.post(uri.CGI_USER_GETTABLELIST,{sid:this.data.sellerid,pnum:parseInt(this.data.pnum),rdate:this.data.time},uri.CGI_USER_GETTABLELIST__CODE)
},
backtime:function () {
var pages=getCurrentPages();
var len=pages.length;
var timelist=pages[len-3].data.timeList;
var datelist=pages[len-3].data.dateList;
var currendate=bookOrder.get_date(this.data.selectdate)
var time_dur=this.data.time_dur;
var dateindex;
datelist.forEach(function(v,i){
if(v.date==currendate){
dateindex=i;
}
})
var that=this;
var timeIndex;
var durIndex;
timelist.forEach(function(v,i){
v.list.forEach(function(r,n){
r.isselect=false;
if(r.time_dur==time_dur){
console.log('xxxx',n,i,time_dur)
timeIndex=n;
durIndex=i;
if(n==0 && i==0){
if(dateindex==0){
console.log('不能再退了')
}else{
console.log(11111)
dateindex=dateindex-1;
datelist.forEach(function(r1,n1){
r1.isActive=false;
if(dateindex==n1){
r1.isActive=true;
that.setData({
thisyear:r1.year
})
}
})
pages[len-3].setData({
selectdate:datelist[dateindex].date,
dateList:datelist
})
pages[len-3].getimelist();
timelist=pages[len-3].data.timeList;
that.setData({
selectdate:bookOrder.getdate_num(pages[len-3].data.selectdate),
time_dur:'22:00'
})
pages[len-2].setData({
selectdate:bookOrder.getdate_num(pages[len-3].data.selectdate),
time_dur:'22:00'
})
console.log(that.data.time_dur)
timelist.forEach(function(r1,n1){
r1.list.forEach(function(r2,n2){
r2.isselect=false;
console.log(r2)
if(r2.time_dur==that.data.time_dur){
console.log('xxxxx',r2)
r2.isselect=true;
}
})
})
console.log(timelist)
pages[len-3].setData({
timeList:timelist,
time_dur:'22:00'
})
}
}
if(n>0 && i==0){
that.setData({
time_dur:v.list[n-1].time_dur
})
v.list[n-1].isselect=true;
pages[len-3].setData({
timeList:timelist,
time_dur:v.list[n-1].time_dur
})
pages[len-2].setData({
time_dur:v.list[n-1].time_dur
})
}
if(n==0 && i>0){
console.log('xxxx',2)
that.setData({
time_dur:timelist[i-1].list[timelist[i-1].list.length-1].time_dur,
})
timelist[i-1].list[timelist[i-1].list.length-1].isselect=true;
pages[len-3].setData({
timeList:timelist,
time_dur:timelist[i-1].list[timelist[i-1].list.length-1].time_dur,
})
pages[len-2].setData({
time_dur:timelist[i-1].list[timelist[i-1].list.length-1].time_dur
})
}
if(n>0 && i>0){
that.setData({
time_dur:v.list[n-1].time_dur
})
v.list[n-1].isselect=true;
pages[len-3].setData({
timeList:timelist,
time_dur:timelist[i-1].list[timelist[i-1].list.length-1].time_dur,
})
pages[len-2].setData({
time_dur:v.list[n-1].time_dur
})
}
}
})
})
var temdate=bookOrder.get_date(this.data.selectdate);
var stringTime =this.data.thisyear+'-'+temdate+' ' +this.data.time_dur;
var time=bookOrder.gettimestamp(stringTime);
this.setData({
time:time
})
pages[len-3].setData({
time:time
})
pages[len-2].setData({
time:time
})
this.getdesklist();
},
aftertime:function(){
var pages=getCurrentPages();
var len=pages.length;
console.log(len)
var timelist=pages[len-3].data.timeList;
var datelist=pages[len-3].data.dateList;
var currendate=bookOrder.get_date(this.data.selectdate);
var time_dur=this.data.time_dur;
var dateindex;
datelist.forEach(function(v,i){
if(v.date==currendate){
dateindex=i;
}
})
var that=this;
timelist.forEach(function(v,i){
v.list.forEach(function(r,n){
r.isselect=false
if(r.time_dur==time_dur){
if(i==timelist.length-1 && n==v.list.length-1){
if(dateindex==2){
console.log('不能再加了')
}else{
console.log('tttttt')
dateindex=dateindex+1;
datelist.forEach(function(r1,n1){
r1.isActive=false;
if(dateindex==n1){
r1.isActive=true;
that.setData({
thisyear:r1.year
})
}
})
pages[len-3].setData({
selectdate:datelist[dateindex].date,
dateList:datelist
})
pages[len-3].getimelist();
timelist=pages[len-3].data.timeList;
that.setData({
selectdate:bookOrder.getdate_num(pages[len-3].data.selectdate),
time_dur:'6:00'
})
console.log(time_dur)
console.log('hhhh',that.data.time_dur)
pages[len-2].setData({
selectdate:bookOrder.getdate_num(pages[len-3].data.selectdate),
time_dur:'6:00'
})
console.log(timelist)
timelist.forEach(function(r1,n1){
r1.list.forEach(function(r2,n2){
r2.isselect=false;
if(r2.time_dur==that.data.time_dur){
r2.isselect=true;
}
})
})
timelist[2].list[0].isselect=false
console.log('ffff',timelist)
pages[len-3].setData({
timeList:timelist,
time_dur:'6:00'
})
var temdate=bookOrder.get_date(that.data.selectdate);
var stringTime =that.data.thisyear+'-'+temdate+' ' +that.data.time_dur;
var time=bookOrder.gettimestamp(stringTime);
that.setData({
time:time
})
pages[len-3].setData({
time:time
})
pages[len-2].setData({
time:time
})
that.getdesklist();
return;
}
}
if(i==timelist.length-1 && n<v.list.length-1){
that.setData({
time_dur:v.list[n+1].time_dur
})
v.list[n+1].isselect=true
pages[len-3].setData({
time_dur:v.list[n+1].time_dur,
timeList:timelist
})
pages[len-2].setData({
time_dur:v.list[n+1].time_dur
})
}
if(i<timelist.length-1 && n==v.list.length-1){
that.setData({
time_dur:timelist[i+1].list[0].time_dur,
})
timelist[i+1].list[0].isselect=true;
pages[len-3].setData({
time_dur:timelist[i+1].list[0].time_dur,
timeList:timelist
})
pages[len-2].setData({
time_dur:timelist[i+1].list[0].time_dur,
})
}
if(i<timelist.length-1 && n<v.list.length-1){
that.setData({
time_dur:v.list[n+1].time_dur
})
v.list[n+1].isselect=true
pages[len-3].setData({
time_dur:v.list[n+1].time_dur,
timeList:timelist
})
pages[len-2].setData({
time_dur:v.list[n+1].time_dur
})
}
}
})
})
var temdate=bookOrder.get_date(this.data.selectdate);
var stringTime =this.data.thisyear+'-'+temdate+' ' +this.data.time_dur;
var time=bookOrder.gettimestamp(stringTime);
this.setData({
time:time
})
pages[len-3].setData({
time:time
})
pages[len-2].setData({
time:time
})
this.getdesklist();
},
})
\ No newline at end of file
... ...
{
"backgroundTextStyle":"light",
"navigationBarBackgroundColor": "#fff",
"navigationBarTextStyle":"black",
"usingComponents": {
"selectPeople":"/components/book/people/people",
"orderDesk":"/components/book/desk/desk"
}
}
\ No newline at end of file
... ...
<view class="other-info flex-lr">
<view class="selected-time flex-lr">
<view style="padding:30rpx 40rpx;" bindtap="backtime">
<image src="../image/green-click-reduce.png" class="icon12-22"></image>
</view>
<view class="flex-vc">
<view class="font34r green-font">{{selectdate}}</view>
<view class="actual-time green-font font34r">{{time_dur}}</view>
</view>
<view style="padding:30rpx 40rpx;" bindtap="aftertime">
<image src="../image/green-click-add.png" class="icon12-22"></image>
</view>
</view>
<selectPeople bind:changepnum="changepnum" pnum="{{pnum}}"></selectPeople>
</view>
<view class="cut"></view>
<!--桌位状态-->
<view class="desk-type flex-lr">
<block wx:for="{{desk_type}}">
<view class="desk-type-single flex-cc {{item.isselect==true ? 'desk-type-single-active white-font' : 'black-font'}} font34r" bindtap="selectType" data-type="{{item.type}}">{{item.type_name}}</view>
</block>
</view>
<view class="desk-list" style="padding-bottom:180rpx;">
<block wx:for="{{desklist}}">
<view class="desk-region black-font font34r font-bold">{{item.name}}</view>
<orderDesk list="{{item.list}}" bind:changedesk="changedesk"></orderDesk>
</block>
</view>
<view class="confirm-button white-font flex-vc font34r {{tableid ? 'confirm-button-active' : ''}}" bindtap="back">确定</view>
\ No newline at end of file
... ...
view{
line-height:1.2;
}
.other-info{
width:100%;
height:220rpx;
padding:20rpx 0;
box-sizing:border-box;
}
.selected-time{
width:375rpx;
height:100%;
border-right:1px solid #efeef3;
box-sizing:border-box;
}
.actual-time{
margin-top:10rpx;
}
.cut{
width:100%;
height:4px;
background:#efeef3;
}
.desk-type{
width:680rpx;
padding:40rpx 0 20rpx;
margin:0 auto;
}
.desk-type-single{
width:160rpx;
height:60rpx;
border:1px solid #199095;
border-radius:30rpx;
background:#EBF8F8;
}
.desk-type-single-active{
background:#199095;
}
.desk-list{
width:100%;
}
.desk-region{
width:680rpx;
padding-top:40rpx;
margin:0 auto;
}
.confirm-button{
width:680rpx;
height:85rpx;
background:#74BBBE;
position:fixed;
left:0;
right:0;
bottom:60rpx;
margin:0 auto;
border-radius:10rpx;
}
.confirm-button-active{
background:#199095;
}
\ No newline at end of file
... ...
var util = require('../../utils/util.js')
var uri=require('../../utils/uri.js')
Page({
onLoad:function (opt) {
util.setBarTitle('预定详情');
console.log(opt)
opt.name=opt.name.length>3 ? opt.name.slice(0,3)+'...' : opt.name
this.setData({
sellerid:util.cache('sellerid'),
phoneNumber:opt.phone,
bookInfo:opt
})
wx.showShareMenu({
withShareTicket: true,
success:function(res){
console.log(res)
}
})
},
onShow:function(){
this.getsellerInfo();
this.getdesklist();
var that=this;
this.notice=this.selectComponent('#notice');
util.postSuccessFun=function(json,uri_code){
switch (uri_code) {
case uri.CGI__USER_GETSELLERBYID__CODE:
console.log(json)
if(json.ret==200){
that.setData({
storeInfo:json.data.data
})
}
break;
case uri.CGI_USER_GETTABLELIST__CODE:
var list=json.data;
var templist=[];
for(var key in list){
if(key!='typex' && key!='typey'){
list[key].list.forEach(function(v,i){
templist.push(v)
})
}
}
var tables=that.data.bookInfo.tid.split(',');
var selecttable=[];
templist.forEach(function (v,i) {
tables.forEach(function(r,n){
if(r==v.id){
v.name=v.name.length>4 ? v.name.slice(0,3)+'...' : v.name;
selecttable.push(v)
}
})
})
console.log(selecttable)
that.setData({
selecttable:selecttable
})
break;
}
}
},
noticeCall:function(){
this.notice.show();
},
getsellerInfo:function(){
util.post(uri.CGI__USER_GETSELLERBYID,{sellerid:this.data.sellerid},uri.CGI__USER_GETSELLERBYID__CODE);
},
getdesklist:function(){
util.post(uri.CGI_USER_GETTABLELIST,{sid:this.data.sellerid,pnum:parseInt(this.data.bookInfo.pnum),rdate:this.data.bookInfo.rdate},uri.CGI_USER_GETTABLELIST__CODE)
},
lookLocation:function(){
wx.openLocation({
latitude:Number(this.data.storeInfo.lat),
longitude:Number(this.data.storeInfo.long),
scale:17,
address:this.data.storeInfo.map_address,
success:function (res) {
console.log(res)
}
})
},
onShareAppMessage: function () {
this.notice.close();
var obj=this.data.bookInfo;
var path='b_detail?sellerid='+this.data.sellerid;
for (var key in obj){
path=path+'&'+key+'='+obj[key]
}
path=path+'&code=1'
return {
title: '恭喜订座成功,点击查看详情,及时通知用餐人员',
path: '/pages/book/'+path,
success: function (res) {
console.log(res,666666)
},
fail:function(){
console.log('ccccc')
},
complete:function(){
console.log('ccccc')
}
};
},
getcall:function(){
var that=this;
wx.makePhoneCall({
phoneNumber: this.data.phoneNumber, //仅为示例,并非真实的电话号码
complete:function(){
this.notice.close();
}
})
}
})
\ No newline at end of file
... ...
{
"backgroundTextStyle":"light",
"navigationBarBackgroundColor": "#fff",
"navigationBarTextStyle":"black",
"usingComponents": {
"noticeCall":"/components/book/notice/notice"
}
}
\ No newline at end of file
... ...
<!--商家信息-->
<view class="flex-lr seller-info">
<view class="flex-ll">
<image src="{{storeInfo.seller_image}}" class="seller-image"></image>
<view class="flex-vl black-font">
<view class="font30r">{{storeInfo.sellername}}</view>
<view class="font24r gray-deep-font seller-address">{{storeInfo.map_address}}</view>
</view>
</view>
<view style="padding:20rpx 20rpx;" bindtap="lookLocation">
<image src="../image/gps-icon.png" class="seller-location"></image>
</view>
</view>
<!--订单信息-->
<view class="order-info">
<view class="flex-lr order-detail">
<view class="gray-deep-font font30r">用餐时间</view>
<view class="black-font font34r">{{bookInfo.order_date}}{{bookInfo.order_time}}</view>
</view>
<view class="flex-lr order-detail">
<view class="gray-deep-font font30r">用餐人数</view>
<view class="black-font font34r">{{bookInfo.pnum}}人</view>
</view>
<view class="flex-lr order-desk">
<view class="gray-deep-font font30r">预定座位</view>
<image class="order-status" src="../image/order-mask-before.png"></image>
<view class="flex-re" style="width:80%;flex-wrap:wrap;">
<block wx:for="{{selecttable}}">
<view class="order-desk-info">
<view class="flex-vc order-desk-detail" style="height:{{item.tid==2 ? '90' : '120'}}rpx;">
<view class="font28r black-font smooth">{{item.name}}</view>
<view class="font26r black-font" style="margin-top:6rpx;">{{item.table_pnum}}人</view>
</view>
<block wx:if="{{item.tid==2}}">
<view class="order-desk-type flex-cc white-font font20r">包间</view>
</block>
</view>
</block>
</view>
</view>
<view class="flex-lr order-detail">
<text class="gray-deep-font font30r" space="true" decode="true">预&ensp;订&ensp;人</text>
<view class="black-font font34r">{{bookInfo.rname}}</view>
</view>
<view class="flex-lr order-detail">
<view class="gray-deep-font font30r">手机号码</view>
<view class="black-font font34r" bindtap="getcall">{{bookInfo.phone}}</view>
</view>
<block wx:if="{{bookInfo.cusdem!='' && bookInfo.cusdem!='null'}}">
<view class="flex-lr order-detail">
<view class="gray-deep-font font30r">备注信息</view>
<view class="black-font font34r">{{bookInfo.cusdem}}</view>
</view>
</block>
</view>
<block wx:if="{{bookInfo.cusman!='' && bookInfo.cusman!='null'}}">
<view class="seller-staff flex-lr black-font font34r">
<view>客户经理</view>
<view>{{bookInfo.cusman}}</view>
</view>
</block>
<!--通知预订人-->
<block wx:if="{{!bookInfo.code}}">
<view class="notice-button white-font font34r flex-cc" bindtap="noticeCall">通知预订人</view>
<noticeCall id="notice" phoneNumber="{{phoneNumber}}"></noticeCall>
</block>
... ...
view{
line-height:1.2;
}
/*商家信息*/
.seller-info{
width:680rpx;
height:auto;
padding:40rpx 0;
margin:0 auto;
border-bottom:1px solid #efeef3;
}
.seller-image{
width:60rpx;
height:60rpx;
border-radius:50%;
margin-right:20rpx;
}
.seller-address{
margin-top:10rpx;
}
.seller-location{
width:32rpx;
height:34rpx;
}
/*订单信息*/
.order-info{
width:680rpx;
height:auto;
padding:0 20rpx;
margin:0 auto;
border-bottom:1px solid #efeef3;
box-sizing:border-box;
}
.order-detail{
width:100%;
padding:40rpx 0;
}
.order-desk{
width:100%;
height:auto;
position:relative;
}
.order-status{
width:172rpx;
height:100rpx;
position:absolute;
left:0;
right:0;
top:0;
bottom:0;
margin:auto;
z-index:2;
}
.order-desk-info{
width:120rpx;
height:120rpx;
background:#A9E3E6;
border:1px solid #199095;
border-radius:10rpx;
position:relative;
overflow:hidden;
margin-left:20rpx;
margin-top:20rpx;
}
.order-desk-detail{
width:100%;
height:90rpx;
}
.order-desk-type{
width:100%;
height:30rpx;
background:#199095;
position:absolute;
left:0;
bottom:0;
}
.seller-staff{
width:680rpx;
padding:40rpx 20rpx;
box-sizing:border-box;
margin:0 auto;
}
.notice-button{
width:675rpx;
height:85rpx;
background:#199095;
border-radius:10rpx;
margin:0 auto;
position:fixed;
left:0;
right:0;
bottom:50rpx;
}
... ...
var util = require('../../utils/util.js')
var uri=require('../../utils/uri.js')
var bookOrder=require('../../utils/bookCommon.js')
Page({
data:{
isloading:false,
pagex:1,
pagey:10,
sort:null
},
onLoad:function(opt){
var radio=750/util.getsystem().windowWidth;
var contentHeight=util.getsystem().windowHeight-Math.ceil(165/radio)
this.setData({
sellerid:opt.sellerid ? opt.sellerid : util.cache('sellerid'),
systemInfo:util.getsystem(),
contentHeight:contentHeight,
listHeight:contentHeight-Math.ceil(140/radio)
})
util.cache('sellerid',opt.sellerid)
console.log(this.data.sellerid)
util.setBarTitle('预定本');
},
onShow:function(){
var that=this;
this.setData({
pagex:1,
bookList:null,
isloading:false,
})
this.getbooklist();
var currentTime=Date.parse(new Date());
var timeobj=bookOrder.changedate(currentTime);
var afterobj=bookOrder.changedate(currentTime+24*60*60*1000);
console.log(afterobj)
util.postSuccessFun=function(json,uri_code){
switch (uri_code) {
case uri.CGI_USER_GETRESERVELIST__CODE:
if(json.ret==200){
if(json.data.length>0){
var list=json.data;
var templist=[];
var temp=[]
if(list.length>0){
}
list.forEach(function(v,i){
var thisobj=bookOrder.changedate(parseInt(v.rdate)*1000);
var thisdate=thisobj.year+'年'+thisobj.month+'月'+thisobj.day;
var ifdate=false
if(temp.length>0){
if(temp.indexOf(thisdate)==-1){
ifdate=true
}else{
ifdate=false
}
}else{
temp.push(thisdate);
if(thisobj.year==timeobj.year && thisobj.month==timeobj.month && timeobj.day==thisobj.day){
templist.push({
date:thisdate,
datemask:'今天',
list:[]
})
}else if(thisobj.year==afterobj.year && thisobj.month==afterobj.month && afterobj.day==thisobj.day){
templist.push({
date:thisdate,
datemask:'明天',
list:[]
})
}else{
var myDate = new Date(parseInt(v.rdate)*1000);
var title=bookOrder.getweek(myDate.getDay());
templist.push({
date:thisdate,
datemask:title,
list:[]
})
}
}
if(ifdate==true){
temp.push(thisdate);
if(thisobj.year==timeobj.year && thisobj.month==timeobj.month && timeobj.day==thisobj.day){
templist.push({
date:thisdate,
datemask:'今天',
list:[]
})
}else if(thisobj.year==afterobj.year && thisobj.month==afterobj.month && afterobj.day==thisobj.day){
templist.push({
date:thisdate,
datemask:'明天',
list:[]
})
}else{
var myDate = new Date(parseInt(v.rdate)*1000);
var title=bookOrder.getweek(myDate.getDay());
templist.push({
date:thisdate,
datemask:title,
list:[]
})
}
}
})
if(temp.length>0){
list.forEach(function(v,i){
var thisobj=bookOrder.changedate(parseInt(v.rdate)*1000);
console.log(thisobj)
var thisdate=thisobj.year+'年'+thisobj.month+'月'+thisobj.day;
templist.forEach(function(r,n) {
if (r.date == thisdate) {
v.order_date = thisobj.month + '月' + thisobj.day + '日';
v.order_time = thisobj.hour + ':' + (thisobj.minute == 0 ? thisobj.minute + '0' : thisobj.minute);
v.name=v.name.length>9 ? v.name.slice(0,9)+'等' : v.name;
r.list.push(v)
}
})
})
}
if(that.data.bookList && that.data.pagex>1){
var booklist=that.data.bookList;
if(booklist[booklist.length-1].date==templist[0].date){
templist[0].list.forEach(function(v,i){
booklist[booklist.length-1].list.push(v)
})
templist.forEach(function(v,i){
if(i!=0){
booklist.push(v)
}
})
}else{
templist.forEach(function(v,i){
booklist.push(v)
})
}
console.log(booklist)
that.setData({
bookList:booklist,
})
}else{
that.setData({
bookList:templist,
})
}
}
that.setData({
isloading:true,
currenlist:json.data
})
}else{
that.setData({
isloading:true
})
}
break;
}
}
},
getbooklist:function(){
util.post(uri.CGI_USER_GETRESERVELIST,{sid:this.data.sellerid,x:this.data.pagex,y:10,sort:this.data.p_sort},uri.CGI_USER_GETRESERVELIST__CODE)
},
timeorder:function(){
if(this.data.p_sort==null){
this.setData({
p_sort:1
})
}else{
this.setData({
p_sort:null
})
}
var booklist=this.data.bookList;
booklist.forEach(function(v,i){
var thislist=[];
v.list.forEach(function(r,n){
thislist.unshift(r)
})
v.list=thislist;
})
this.setData({
bookList:booklist.reverse()
})
console.log(this.data.bookList)
},
addbooklist: function(e){
console.log(e)
if(e.detail.scrollTop>200*this.data.pagex && this.data.currenlist.length>0){
this.setData({
pagex:this.data.pagex+1
})
console.log(this.data.pagex)
this.getbooklist();
}
}
})
\ No newline at end of file
... ...
{
"backgroundTextStyle":"light",
"navigationBarBackgroundColor": "#fff",
"navigationBarTextStyle":"black",
"usingComponents": {
"nothingBook":"/components/book/nothing/nothing",
"bookList":"/components/book/list/list",
"actButton":"/components/book/action/action"
}
}
\ No newline at end of file
... ...
<block wx:if="{{isloading==true}}">
<block wx:if="{{!bookList}}">
<nothingBook></nothingBook>
</block>
<block wx:else>
<view style="height:{{contentHeight}}px;" bindcsroll="onPullDownRefresh">
<view class="book-page bg_white">
<view class="book-search flex-ll">
<image src="../image/search.png" class="search-icon"></image>
<input placeholder="桌位·预定人姓名·手机号" placeholder-class="font30r gray-font smooth" class="font30r black-font smooth search-input"/>
</view>
<scroll-view class="book-list" style="height:{{listHeight}}px;" scroll-y bindscroll="addbooklist">
<view class="book-list-thead flex-lr font34r black-font">
<view>桌号</view>
<view class="flex-cc" bindtap="timeorder">时间<image src="../image/direction.png" class="icon22-26" background-size="cover"></image></view>
<view class="flex-cc">状态</view>
<view class="flex-rr">操作</view>
</view>
<view class="book-list-body">
<block wx:for="{{bookList}}">
<view class="book-list-cut flex-ll font26r black-font">
<text space='true'>{{item.date}} {{item.datemask}}</text>
</view>
<block wx:for="{{item.list}}" wx:for-item="list">
<block wx:if="{{index!=0}}">
<view class="border-line"></view>
</block>
<bookList item="{{list}}"></bookList>
</block>
</block>
</view>
</scroll-view>
</view>
</view>
</block>
</block>
<actButton></actButton>
\ No newline at end of file
... ...
page{
background:#efeef3;
}
.book-page{
width:100%;
padding-top:20rpx;
}
.book-search{
width:590rpx;
height:80rpx;
border-radius:40rpx;
box-shadow: 0 0 8px #ccc;
margin:0 auto;
margin-bottom:20rpx;
}
.search-icon{
width:40rpx;
height:40rpx;
margin-left:30rpx;
}
.search-input{
width:520rpx;
height:100%;
padding:10rpx;
box-sizing:border-box;
}
.book-list-thead{
width:100%;
height:120rpx;
padding:0 40rpx;
box-sizing:border-box;
font-weight:400;
}
.book-list-thead>view{
width:25%;
}
.icon22-26{
width:22rpx;
height:26rpx;
margin-left:8rpx;
}
.book-list-body{
width:100%;
height:auto;
box-sizing:border-box;
}
.book-list-cut{
width:100%;
height:80rpx;
background:#efeef3;
padding:0 40rpx;
box-sizing:border-box;
}
.border-line{
width:670rpx;
height:1px;
background:#efeef3;
margin:0 auto;
}
\ No newline at end of file
... ...
var util = require('../../utils/util.js')
var uri=require('../../utils/uri.js')
var bookOrder=require('../../utils/bookCommon.js')
Page({
data:{
grand:[
{
sex:1,
grand_title:'先生',
isselect:true
},
{
sex:2,
grand_title:'女士',
isselect:false
}
],
name:'',
sex:1,
phone:'',
remark:'',
buttonhide:true,
pnum:'6'
},
onLoad:function(opt){
wx.removeStorage({
key:'tableid',
})
wx.removeStorage({
key:'tabletype',
})
util.setBarTitle('录入订座信息');
var selectmonth=opt.date.split('-')[0][0]=='0' ? opt.date.split('-')[0][1] : opt.date.split('-')[0];
var selectday=opt.date.split('-')[1][0]=='0' ? opt.date.split('-')[1][1] : opt.date.split('-')[1];
console.log(opt)
var stringTime =opt.year+'-'+opt.date+' ' +opt.time+':00';
console.log(stringTime)
var time=bookOrder.gettimestamp(stringTime);
console.log(time)
this.setData({
thisyear:opt.year,
selectdate:selectmonth+'月'+selectday+'日',
time_dur:opt.time,
sellerid:util.cache('sellerid'),
time:time,
pnum:util.cache('order_pnum') ? util.cache('order_pnum') : this.data.pnum,
})
this.getdesklist();
},
onShow:function(){
var that=this;
if(util.cache('tableid')){
var tables=util.cache('tableid');
var templist=this.data.templist;
var showdesk=[];
for(var i=0;i<tables.length;i++){
templist.forEach(function(r,n){
if(tables[i]==r.id){
r.isselect=true;
if(r.tid==2){
r.name=r.name.length>4 ? r.name.slice(0,3)+'...' : r.name;
showdesk.unshift(r);
}else {
r.name=r.name.length>4 ? r.name.slice(0,3)+'...' : r.name;
showdesk.push(r);
}
}
})
}
this.setData({
showdesk:showdesk.slice(0,2)
})
}
if(util.cache('tableid') && util.cache('tableid').length>0){
if(this.data.name!='' && this.data.phone!='' && !this.data.reminder){
this.setData({
buttonhide:false
})
}
}
util.postSuccessFun=function(json,uri_code){
switch (uri_code) {
case uri.CGI_USER_SETRESERVEINFO__CODE:
if(json.ret==200){
wx.showToast({
title:'添加成功',
duration:2000,
success:function(){
setTimeout(function () {
wx.navigateBack({
delta: 2
})
},2500)
}
})
}
break;
case uri.CGI_USER_GETTABLELIST__CODE:
console.log('xxxx',json.data);
var list=json.data;
var templist=[];
for(var key in list){
if(key!='typex' && key!='typey'){
list[key].list.forEach(function(v,i){
templist.push(v)
})
}
}
var tempsan=[];
var tempbao=[];
var showdesk=[];
var temp={};
templist.forEach(function(v,i){
v.name=v.name.length>4 ? v.name.slice(0,3)+'...' : v.name;
if(!v.r_status){
if(v.tid==2){
tempbao.push(v);
v.isselect=false;
showdesk.unshift(v);
}else{
tempsan.push(v);
v.isselect=false;
showdesk.push(v);
}
}
if(v.tid==2){
if(!temp.hasOwnProperty("tabletype_2")){
temp['tabletype_2']=true
}
}else{
if(!temp.hasOwnProperty("tabletype_1")){
temp['tabletype_1']=true
}
}
})
util.cache('tabletype',temp);
console.log(showdesk)
that.setData({
sancount:list.typex, //typex散座
baocount:list.typey, //typey包间
showdesk:showdesk.slice(0,2),
templist:templist
})
break;
}
}
},
changetime:function(){
wx.navigateBack()
},
selectgrand:function(e){
var sex=e.currentTarget.dataset.sex;
console.log(sex)
var grandlist=this.data.grand;
grandlist.forEach(function(v,i){
v.isselect=false;
if(v.sex==sex){
v.isselect=true;
}
})
this.setData({
grand:grandlist,
sex:sex
})
},
condition:function(e){
var name=this.data.name;
var phone=e.detail.value;
var regExp = /^(86)?((13\d{9})|(15[0,1,2,3,5,6,7,8,9]\d{8})|(18[0,5,6,7,8,9]\d{8}))$/
if(!(regExp.test(phone))){
this.setData({
reminder:'手机格式不正确'
})
}else{
this.setData({
reminder:null
})
}
if(name!='' && !this.data.reminder && phone!='' && util.cache('tableid')){
this.setData({
buttonhide:false
})
}
},
changename:function(e){
this.setData({
name:e.detail.value
})
},
changephone:function(e){
this.setData({
phone:e.detail.value
})
},
changeremark:function(e){
this.setData({
remark:e.detail.value
})
},
ifAll:function(){
var name=this.data.name;
var phone=this.data.phone;
if(name!='' && !this.data.reminder && phone!='' && util.cache('tableid')){
this.setData({
buttonhide:false
})
}
},
formsubmit:function(){
console.log(this.data.time)
var formData={
sid:this.data.sellerid,
tid:util.cache('tableid').toString(),
rname:this.data.name, //姓名
phone:this.data.phone, //手机号
sex:this.data.sex, //性别
pnum:this.data.pnum, //人数
rdate:this.data.time, //时间
cusdem:this.data.remark //备注
}
console.log(formData)
util.post(uri.CGI_USER_SETRESERVEINFO,formData,uri.CGI_USER_SETRESERVEINFO__CODE)
},
changepnum:function(e){
console.log(e)
this.setData({
pnum:e.detail
})
this.getdesklist();
},
selectdesk:function(){
wx.navigateTo({
url:'b_desk?pnum='+this.data.pnum+'&year='+this.data.thisyear+'&date='+this.data.selectdate+'&time_dur='+this.data.time_dur
})
},
getdesklist:function(){
util.post(uri.CGI_USER_GETTABLELIST,{sid:this.data.sellerid,pnum:parseInt(this.data.pnum),rdate:this.data.time},uri.CGI_USER_GETTABLELIST__CODE)
},
binddesk:function(e){
var id=e.currentTarget.dataset.id;
var tables=util.cache('tableid') ? util.cache('tableid') : [];
var showdesk=this.data.showdesk;
showdesk.forEach(function(v,i){
if(v.id==id){
if(v.isselect==true){
var thisindex=tables.indexOf(id);
tables.splice(thisindex,1)
}else{
tables.push(id)
}
v.isselect=!v.isselect
}
})
util.cache('tableid',tables);
this.setData({
showdesk:showdesk
})
var name=this.data.name;
var phone=this.data.phone;
if(name!='' && !this.data.reminder && phone!='' && util.cache('tableid')){
this.setData({
buttonhide:false
})
}
}
})
\ No newline at end of file
... ...
{
"backgroundTextStyle":"light",
"navigationBarBackgroundColor": "#fff",
"navigationBarTextStyle":"black",
"usingComponents": {
"selectPeople":"/components/book/people/people"
}
}
\ No newline at end of file
... ...
<view class="other-info flex-lr">
<view class="selected-time flex-vc" bindtap="changetime">
<view class="font30r black-font">时间</view>
<view class="actual-time green-font font34r">{{selectdate}} {{time_dur}}</view>
</view>
<selectPeople bind:changepnum="changepnum" pnum="{{pnum}}"></selectPeople>
</view>
<view class="border-line"></view>
<view class="advice-desk flex-lr">
<view class="black-font font30r">桌位</view>
<view>
<view class="font26r gray-deep-font flex-rr">(包间余{{baocount}}个,散座余{{sancount}}个)</view>
<view class="advice-desk-detail flex-rr">
<block wx:for="{{showdesk}}">
<block wx:if="{{item.tid==2}}">
<view class="order-desk-info {{item.isselect==true ? 'desk-active' : ''}}" bindtap="binddesk" data-id="{{item.id}}" data-type="{{item.tid}}">
<view class="flex-vc order-desk-detail">
<view class="font28r black-font smooth">{{item.name}}</view>
<view class="font26r black-font" style="margin-top:6rpx;">{{item.table_pnum}}人</view>
</view>
<view class="order-desk-type flex-cc white-font font20r">包间</view>
</view>
</block>
<block wx:else>
<view class="order-desk-info {{item.isselect==true ? 'desk-active' : ''}}" bindtap="binddesk" data-id="{{item.id}}" data-type="{{item.tid}}">
<view class="flex-vc order-desk-detail" style="height:100%;">
<view class="font28r black-font smooth">{{item.name}}</view>
<view class="font26r black-font" style="margin-top:6rpx;">6人</view>
</view>
</view>
</block>
</block>
<view class="flex-rr advice-more" bindtap="selectdesk">
<view style="padding-right:30rpx;" class="gray-deep-font font26r">更多</view>
<image src="../image/click.png" class="icon12-22"></image>
</view>
</view>
</view>
</view>
<view class="cut"></view>
<view class="book-info">
<view class="book-info-single flex-lr" style="align-items:flex-start;">
<input placeholder="请输入预订人姓名(必填)" placeholder-class="gray-font font34r" class="black-font font34r" maxlength="5" style="width:450rpx;" value="{{name}}" bindinput="changename" bindblur="ifAll"/>
<view class="book-info-grand flex-rr font28r gray-deep-font">
<block wx:for="{{grand}}">
<view class="book-grand flex-cc {{index==0 ? 'book-grand-border' : ''}} {{item.isselect==true ? 'book-grand-active white-font' : ''}}" bindtap="selectgrand" data-sex="{{item.sex}}">{{item.grand_title}}</view>
</block>
</view>
</view>
<view class="book-info-single flex-lr" style="align-items:flex-start;">
<input placeholder="请输入预订人手机号码(必填)" placeholder-class="gray-font font34r" class="black-font font34r" type="number" maxlength="11" bindblur="condition" bindinput="changephone" value="{{phone}}" style="color:{{reminder ? '#E14553' : '#353535'}};width:{{reminder ? 400 : 680}}rpx;"/>
<block wx:if="{{reminder}}">
<view class="flex-rr" style="height:100rpx;">
<view style="color:#E14553;" class="font28r">{{reminder}}</view>
<image src="../image/name-have.png" class="phone-reminder"></image>
</view>
</block>
</view>
<view class="book-info-single">
<input placeholder="请输入顾客要求(25字以内,选填)" placeholder-class="gray-font font34r" class="black-font font34r" maxlength="25" value="{{remark}}" bindinput="changeremark"/>
</view>
</view>
<view class="zhanwei"></view>
<view class="confirm-button white-font flex-vc font34r {{buttonhide==false ? 'confirm-button-active' : ''}}" bindtap="{{buttonhide==false ? 'formsubmit' : ''}}">确定</view>
\ No newline at end of file
... ...
view{
line-height:1.2;
}
.other-info{
width:100%;
height:220rpx;
padding:20rpx 0;
box-sizing:border-box;
}
.selected-time{
width:375rpx;
height:100%;
border-right:1px solid #efeef3;
box-sizing:border-box;
}
.actual-time{
margin-top:30rpx;
}
.border-line{
width:680rpx;
height:1px;
background:#efeef3;
margin:0 auto;
}
.advice-desk{
width:680rpx;
height:auto;
padding:40rpx 0;
margin:0 auto;
}
.advice-desk-detail{
margin-top:30rpx;
}
.order-desk-info{
width:120rpx;
height:120rpx;
background:#EBF8F8;
border:1px solid #199095;
border-radius:10rpx;
position:relative;
overflow:hidden;
margin-right:40rpx;
}
.desk-active{
background:#A9E3E6;
}
.order-desk-detail{
width:100%;
height:90rpx;
}
.order-desk-type{
width:100%;
height:30rpx;
background:#199095;
position:absolute;
left:0;
bottom:0;
}
.advice-more{
padding:20rpx 0;
padding-left:30rpx;
}
.cut{
width:100%;
height:4px;
background:#efeef3;
}
.book-info{
width:680rpx;
padding-top:20rpx;
margin:0 auto;
}
.book-info-single{
width:100%;
height:120rpx;
padding-top:80rpx;
border-bottom:1px solid #efeef3;
}
.book-info-single>input{
width:100%;
height:100rpx;
}
.book-info-grand{
height:50rpx;
border:1px solid #199095;
margin-top:20rpx;
}
.book-grand{
width:90rpx;
height:100%;
box-sizing:border-box;
}
.book-grand-active{
background:rgba(25,153,149,.8);
}
.book-grand-border{
border-right:1px solid #199095;
}
.phone-reminder{
width:32rpx;
height:32rpx;
margin-left:20rpx;
}
.zhanwei{
width:100%;
height:205rpx;
background:#efeef3;
}
.confirm-button{
width:680rpx;
height:85rpx;
background:#199095;
position:fixed;
left:0;
right:0;
bottom:60rpx;
margin:0 auto;
border-radius:10rpx;
opacity:.6;
}
.confirm-button-active{
opacity:1;
}
\ No newline at end of file
... ...
{
"description": "项目配置文件。",
"setting": {
"urlCheck": true,
"es6": true,
"postcss": true,
"minified": true,
"newFeature": true
},
"compileType": "miniprogram",
"libVersion": "1.9.91",
"appid": "wxd3dc4206c76f14fc",
"projectname": "xcx-book",
"isGameTourist": false,
"condition": {
"search": {
"current": -1,
"list": []
},
"conversation": {
"current": -1,
"list": []
},
"game": {
"currentL": -1,
"list": []
},
"miniprogram": {
"current": 0,
"list": [
{
"id": 0,
"name": "预定本",
"pathName": "pages/book/b_index",
"query": "sellerid=1"
},
{
"id": 1,
"name": "经营报表",
"pathName": "pages/report/r_index",
"query": ""
},
{
"id": -1,
"name": "经营中心",
"pathName": "pages/me/s_index",
"query": ""
},
{
"id": -1,
"name": "报表详情",
"pathName": "pages/report/r_detail",
"query": ""
},
{
"id": -1,
"name": "菜品列表",
"pathName": "pages/report/r_cook",
"query": ""
},
{
"id": -1,
"name": "时间选择",
"pathName": "pages/report/r_time",
"query": ""
}
]
}
}
}
\ No newline at end of file
... ...
var util = require('util.js')
var uri=require('uri.js')
module.exports = {
onShareAppMessage:function() {
var token=util.cache(uri.CACHE__TOKEN);
if(!token) {
wx.navigateTo({
url:"/pages/login/index"
});
}else{
console.log("this.data.share_xcx_url",this.data.share_xcx_url)
this.sharecallback();
return {
title: this.data.share_xcx_name?this.data.share_xcx_name:(this.data.share_xcx_title?this.data.share_xcx_title:'纳极,最懂你的店铺管家'),
desc: this.data.share_xcx_desc?this.data.share_xcx_desc:'',
path: this.data.share_xcx_url?this.data.share_xcx_url:'/pages/index/index',
}
}
},
sharecallback:function(){
util.post(uri.CGI__ASYN_TOURIST_OPRRATION,{provider_id:this.data.provider_id,type:this.data.sharetype},uri.CGI__ASYN_TOURIST_OPRRATION__CODE);
},
onRefresh:function(){
this.setData({
refreshpage:true
})
var pageinfo=getCurrentPages();
var pagelength=pageinfo.length;
var n_pageinfo=pageinfo[pagelength-1];
var turnpage='/'+n_pageinfo.route;
if(JSON.stringify(n_pageinfo.options)!='{}'){
turnpage+='?';
for(var opt in n_pageinfo.options){
turnpage+=opt+'='+n_pageinfo.options[opt]+'&';
}
}
wx.redirectTo({
url: turnpage,
})
},
restartLogin:function(){
console.log('hahah');
var pages = getCurrentPages();
var num = pages.length;
console.log('hahah');
wx.openSetting({
success: (res) => {
console.log('openSetting',res);
res.authSetting = {
"scope.userInfo": true,
"scope.userLocation": true
}
/*wx.redirectTo({
url:'/pages/index/s_index',
})*/
wx.redirectTo({
url:'../index/s_index',
})
},
fail:(res) => {
console.log('failsetting');
wx.redirectTo({
url:'../me/s_index',
})
}
})
},
};
\ No newline at end of file
... ...
module.exports ={
//时间戳转化日期
changedate:function(timestamp){
var date = new Date(timestamp);//时间戳为10位需*1000,时间戳为13位的话不需乘1000
var Y= date.getFullYear();
var M =date.getMonth()+1;
var D =date.getDate();
var h = date.getHours();
var m = date.getMinutes();
var s = date.getSeconds();
return {year:Y,month:M,day:D,hour:h,minute:m,second:s};
},
//获取星期
getweek:function (index) {
var week=['周日','周一','周二','周三','周四','周五','周六'];
return week[index]
},
//判断是否是整数
isInteger:function (obj) {
return obj%1 === 0
},
//时间转化时间戳
gettimestamp:function(stringTime){
var date = new Date(stringTime.replace(/-/g, '/'));
var timestamp2=Date.parse(date)/1000;
return timestamp2
},
//日期转换 8月8日----08-08
get_date:function(thiadate){
var thismoth=thiadate.split('月')[0];
var thisday=thiadate.split('月')[1].slice(0,-1);
var timedate=(parseInt(thismoth)<10 ? '0'+thismoth : thismoth)+'-'+(parseInt(thisday)<10 ? '0'+thisday : thisday);
return timedate;
},
//日期转换 08-08----8月8日
getdate_num:function(thisdate){
var thismonth=thisdate.split('-')[0][0]=='0' ? thisdate.split('-')[0][1] : thisdate.split('-')[0];
var thisday=thisdate.split('-')[1][0]=='0' ? thisdate.split('-')[1][1] : thisdate.split('-')[1];
console.log()
var timedate=thismonth+'月'+thisday+'日';
return timedate;
}
}
... ...
//application id got from MTAMTA analysis
var MTA_APP_ID = ''; //常规统计id
var MTA_EVENT_ID = ''; //自定义事件id
//data report remote address
var MTA_API_BASE = 'https://pingtas.qq.com/pingd';
//MTA wechat apps analysis storage key prefix
var MTA_VAR_PREFIX = '_mta_';
function getNetworkType(a){wx.getNetworkType({success:function(b){a(b.networkType)}})}function getSystemInfo(){var a=wx.getSystemInfoSync();return{adt:a.model,scl:a.pixelRatio,scr:a.windowWidth+"x"+a.windowHeight,lg:a.language,fl:a.version}}function getUID(){try{return wx.getStorageSync(MTA_VAR_PREFIX+"auid")}catch(a){}}function setUID(){try{var a=getRandom();wx.setStorageSync(MTA_VAR_PREFIX+"auid",a);return a}catch(b){}}
function getSID(){try{return wx.getStorageSync(MTA_VAR_PREFIX+"ssid")}catch(a){}}function setSID(){try{var a="s"+getRandom();wx.setStorageSync(MTA_VAR_PREFIX+"ssid",a);return a}catch(b){}}function getRandom(a){return(a||"")+Math.round(2147483647*(Math.random()||.5))*+new Date%1E10}function getPagePath(){try{var a=getCurrentPages(),b="/";0<a.length&&(b=a.pop().__route__);return b}catch(e){console.log("get current page path error:"+e)}}
function getMainInfo(){var a={dm:"wechat.apps.xx",url:getPagePath(),pvi:"",si:"",ty:2};a.pvi=function(){var b=getUID();b||(a.ty=1,b=setUID());return b}();a.si=function(){var a=getSID();a||(a=setSID());return a}();return a}function getBasicInfo(){var a=getSystemInfo();getNetworkType(function(a){wx.setStorageSync(MTA_VAR_PREFIX+"ntdata",a)});a.ct=wx.getStorageSync(MTA_VAR_PREFIX+"ntdata")||"4g";return a}function getExtentInfo(){return{r2:MTA_APP_ID,r4:"wx"}}
module.exports={initLaunch:function(){setSID()},rptMain:function(){if(""!=MTA_APP_ID){for(var a=[],b=0,e=[getMainInfo(),getBasicInfo(),getExtentInfo(),{random:+new Date}],d=e.length;b<d;b++)for(var f in e[b])e[b].hasOwnProperty(f)&&a.push(f+"="+(e[b][f]||""));wx.request({url:MTA_API_BASE+"?"+a.join("&").toLowerCase()})}},eventStat:function(a,b){if(""!=MTA_EVENT_ID){var e=[],d=getMainInfo(),f=getExtentInfo();d.dm="wxapps.click";d.url=a;f.r2=MTA_EVENT_ID;var c;c="undefined"===typeof b?{}:b;var k=[],
g;for(g in c)c.hasOwnProperty(g)&&k.push(g+"="+c[g]);c=k.join(";");f.r5=c;c=0;d=[d,getBasicInfo(),f,{random:+new Date}];for(f=d.length;c<f;c++)for(var h in d[c])d[c].hasOwnProperty(h)&&e.push(h+"="+(d[c][h]||""));wx.request({url:MTA_API_BASE+"?"+e.join("&").toLowerCase()})}}};
\ No newline at end of file
... ...
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var n;n="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,n.pingpp=e()}}(function(){return function e(n,t,r){function i(a,l){if(!t[a]){if(!n[a]){var c="function"==typeof require&&require;if(!l&&c)return c(a,!0);if(o)return o(a,!0);var u=new Error("Cannot find module '"+a+"'");throw u.code="MODULE_NOT_FOUND",u}var d=t[a]={exports:{}};n[a][0].call(d.exports,function(e){var t=n[a][1][e];return i(t?t:e)},d,d.exports,e,n,t,r)}return t[a].exports}for(var o="function"==typeof require&&require,a=0;a<r.length;a++)i(r[a]);return i}({1:[function(e,n,t){var r=e('./payment_elements.js');n.exports={userCallback:void 0,innerCallback:function(e,n){'function'==typeof this.userCallback&&('undefined'==typeof n&&(n=this.error()),this.userCallback(e,n),this.userCallback=void 0,r.clear())},error:function(e,n){return e='undefined'==typeof e?'':e,n='undefined'==typeof n?'':n,{msg:e,extra:n}}}},{"./payment_elements.js":8}],2:[function(e,n,t){var r=e('../stash'),i=e('../callbacks'),o={}.hasOwnProperty;n.exports={handleCharge:function(e){for(var n=e.credential[e.channel],t=['appId','timeStamp','nonceStr','package','signType','paySign'],a=0;a<t.length;a++)if(!o.call(n,t[a]))return void i.innerCallback('fail',i.error('invalid_credential','missing_field_'+t[a]));r.jsApiParameters=n,this.callpay()},wxLiteEnabled:function(){return'undefined'!=typeof wx&&wx.requestPayment},callpay:function(){if(!this.wxLiteEnabled())return void console.log('请在微信小程序中打开');var e=r.jsApiParameters;delete e.appId,e.complete=function(e){'requestPayment:ok'===e.errMsg&&i.innerCallback('success'),'requestPayment:cancel'===e.errMsg&&i.innerCallback('cancel',i.error('用户取消支付')),'undefined'!==e.err_code&&'undefined'!==e.err_desc&&i.innerCallback('fail',i.error(e.err_desc,e))},wx.requestPayment(e)},runTestMode:function(e){wx.showModal({title:'提示',content:'因 "微信小程序" 限制 域名的原因 暂不支持 模拟付款 请使用 livekey 获取 charge 进行支付'})}}},{"../callbacks":1,"../stash":9}],3:[function(e,n,t){var r=e('./utils'),i=e('./stash'),o=e('./libs/md5'),a={seperator:'###',limit:1,report_url:'https://statistics.pingxx.com/one_stats',timeout:100},l=function(e,n){var t=new RegExp('(^|&)'+n+'=([^&]*)(&|$)','i'),r=e.substr(0).match(t);return null!==r?unescape(r[2]):null},c=function(){return navigator.userAgent},u=function(){return window.location.host};a.store=function(e){if('undefined'!=typeof localStorage&&null!==localStorage){var n=this,t={};t.app_id=e.app_id||i.app_id||'app_not_defined',t.ch_id=e.ch_id||'',t.channel=e.channel||'',t.type=e.type||'',t.user_agent=c(),t.host=u(),t.time=(new Date).getTime(),t.puid=i.puid;var r='app_id='+t.app_id+'&channel='+t.channel+'&ch_id='+t.ch_id+'&host='+t.host+'&time='+t.time+'&type='+t.type+'&user_agent='+t.user_agent+'&puid='+t.puid,o=r;null!==localStorage.getItem('PPP_ONE_STATS')&&0!==localStorage.getItem('PPP_ONE_STATS').length&&(o=localStorage.getItem('PPP_ONE_STATS')+n.seperator+r);try{localStorage.setItem('PPP_ONE_STATS',o)}catch(a){}}},a.send=function(){if('undefined'!=typeof localStorage&&null!==localStorage){var e=this,n=localStorage.getItem('PPP_ONE_STATS');if(!(null===n||n.split(e.seperator).length<e.limit))try{for(var t=[],i=n.split(e.seperator),a=o(i.join('&')),c=0;c<i.length;c++)t.push({app_id:l(i[c],'app_id'),channel:l(i[c],'channel'),ch_id:l(i[c],'ch_id'),host:l(i[c],'host'),time:l(i[c],'time'),type:l(i[c],'type'),user_agent:l(i[c],'user_agent'),puid:l(i[c],'puid')});r.request(e.report_url,'POST',t,function(e,n){200==n&&localStorage.removeItem('PPP_ONE_STATS')},void 0,{'X-Pingpp-Report-Token':a})}catch(u){}}},a.report=function(e){var n=this;n.store(e),setTimeout(function(){n.send()},n.timeout)},n.exports=a},{"./libs/md5":5,"./stash":9,"./utils":11}],4:[function(e,n,t){var r=e('./stash'),i=e('./utils'),o=e('./collection');n.exports={SRC_URL:'https://cookie.pingxx.com',init:function(){var e=this;i.documentReady(function(){e.initPuid()})},initPuid:function(){if('undefined'!=typeof window&&'undefined'!=typeof localStorage){var e=localStorage.getItem('pingpp_uid');if(null===e){e=i.randomString();try{localStorage.setItem('pingpp_uid',e)}catch(n){}}if(r.puid=e,!document.getElementById('p_analyse_iframe')){var t=document.createElement('iframe');t.id='p_analyse_iframe',t.src=this.SRC_URL+'/?puid='+e,t.style.display='none',document.body.appendChild(t)}setTimeout(function(){o.send()},0)}}}},{"./collection":3,"./stash":9,"./utils":11}],5:[function(e,n,t){!function(){function e(e,n){var t=(65535&e)+(65535&n),r=(e>>16)+(n>>16)+(t>>16);return r<<16|65535&t}function t(e,n){return e<<n|e>>>32-n}function r(n,r,i,o,a,l){return e(t(e(e(r,n),e(o,l)),a),i)}function i(e,n,t,i,o,a,l){return r(n&t|~n&i,e,n,o,a,l)}function o(e,n,t,i,o,a,l){return r(n&i|t&~i,e,n,o,a,l)}function a(e,n,t,i,o,a,l){return r(n^t^i,e,n,o,a,l)}function l(e,n,t,i,o,a,l){return r(t^(n|~i),e,n,o,a,l)}function c(n,t){n[t>>5]|=128<<t%32,n[(t+64>>>9<<4)+14]=t;var r,c,u,d,s,f=1732584193,p=-271733879,h=-1732584194,m=271733878;for(r=0;r<n.length;r+=16)c=f,u=p,d=h,s=m,f=i(f,p,h,m,n[r],7,-680876936),m=i(m,f,p,h,n[r+1],12,-389564586),h=i(h,m,f,p,n[r+2],17,606105819),p=i(p,h,m,f,n[r+3],22,-1044525330),f=i(f,p,h,m,n[r+4],7,-176418897),m=i(m,f,p,h,n[r+5],12,1200080426),h=i(h,m,f,p,n[r+6],17,-1473231341),p=i(p,h,m,f,n[r+7],22,-45705983),f=i(f,p,h,m,n[r+8],7,1770035416),m=i(m,f,p,h,n[r+9],12,-1958414417),h=i(h,m,f,p,n[r+10],17,-42063),p=i(p,h,m,f,n[r+11],22,-1990404162),f=i(f,p,h,m,n[r+12],7,1804603682),m=i(m,f,p,h,n[r+13],12,-40341101),h=i(h,m,f,p,n[r+14],17,-1502002290),p=i(p,h,m,f,n[r+15],22,1236535329),f=o(f,p,h,m,n[r+1],5,-165796510),m=o(m,f,p,h,n[r+6],9,-1069501632),h=o(h,m,f,p,n[r+11],14,643717713),p=o(p,h,m,f,n[r],20,-373897302),f=o(f,p,h,m,n[r+5],5,-701558691),m=o(m,f,p,h,n[r+10],9,38016083),h=o(h,m,f,p,n[r+15],14,-660478335),p=o(p,h,m,f,n[r+4],20,-405537848),f=o(f,p,h,m,n[r+9],5,568446438),m=o(m,f,p,h,n[r+14],9,-1019803690),h=o(h,m,f,p,n[r+3],14,-187363961),p=o(p,h,m,f,n[r+8],20,1163531501),f=o(f,p,h,m,n[r+13],5,-1444681467),m=o(m,f,p,h,n[r+2],9,-51403784),h=o(h,m,f,p,n[r+7],14,1735328473),p=o(p,h,m,f,n[r+12],20,-1926607734),f=a(f,p,h,m,n[r+5],4,-378558),m=a(m,f,p,h,n[r+8],11,-2022574463),h=a(h,m,f,p,n[r+11],16,1839030562),p=a(p,h,m,f,n[r+14],23,-35309556),f=a(f,p,h,m,n[r+1],4,-1530992060),m=a(m,f,p,h,n[r+4],11,1272893353),h=a(h,m,f,p,n[r+7],16,-155497632),p=a(p,h,m,f,n[r+10],23,-1094730640),f=a(f,p,h,m,n[r+13],4,681279174),m=a(m,f,p,h,n[r],11,-358537222),h=a(h,m,f,p,n[r+3],16,-722521979),p=a(p,h,m,f,n[r+6],23,76029189),f=a(f,p,h,m,n[r+9],4,-640364487),m=a(m,f,p,h,n[r+12],11,-421815835),h=a(h,m,f,p,n[r+15],16,530742520),p=a(p,h,m,f,n[r+2],23,-995338651),f=l(f,p,h,m,n[r],6,-198630844),m=l(m,f,p,h,n[r+7],10,1126891415),h=l(h,m,f,p,n[r+14],15,-1416354905),p=l(p,h,m,f,n[r+5],21,-57434055),f=l(f,p,h,m,n[r+12],6,1700485571),m=l(m,f,p,h,n[r+3],10,-1894986606),h=l(h,m,f,p,n[r+10],15,-1051523),p=l(p,h,m,f,n[r+1],21,-2054922799),f=l(f,p,h,m,n[r+8],6,1873313359),m=l(m,f,p,h,n[r+15],10,-30611744),h=l(h,m,f,p,n[r+6],15,-1560198380),p=l(p,h,m,f,n[r+13],21,1309151649),f=l(f,p,h,m,n[r+4],6,-145523070),m=l(m,f,p,h,n[r+11],10,-1120210379),h=l(h,m,f,p,n[r+2],15,718787259),p=l(p,h,m,f,n[r+9],21,-343485551),f=e(f,c),p=e(p,u),h=e(h,d),m=e(m,s);return[f,p,h,m]}function u(e){var n,t='';for(n=0;n<32*e.length;n+=8)t+=String.fromCharCode(e[n>>5]>>>n%32&255);return t}function d(e){var n,t=[];for(t[(e.length>>2)-1]=void 0,n=0;n<t.length;n+=1)t[n]=0;for(n=0;n<8*e.length;n+=8)t[n>>5]|=(255&e.charCodeAt(n/8))<<n%32;return t}function s(e){return u(c(d(e),8*e.length))}function f(e,n){var t,r,i=d(e),o=[],a=[];for(o[15]=a[15]=void 0,i.length>16&&(i=c(i,8*e.length)),t=0;t<16;t+=1)o[t]=909522486^i[t],a[t]=1549556828^i[t];return r=c(o.concat(d(n)),512+8*n.length),u(c(a.concat(r),640))}function p(e){var n,t,r='0123456789abcdef',i='';for(t=0;t<e.length;t+=1)n=e.charCodeAt(t),i+=r.charAt(n>>>4&15)+r.charAt(15&n);return i}function h(e){return unescape(encodeURIComponent(e))}function m(e){return s(h(e))}function _(e){return p(m(e))}function y(e,n){return f(h(e),h(n))}function g(e,n){return p(y(e,n))}function v(e,n,t){return n?t?y(n,e):g(n,e):t?m(e):_(e)}n.exports=v}()},{}],6:[function(e,n,t){var r=e('./version').v,i=e('./testmode'),o=e('./callbacks'),a=e('./mods'),l=e('./stash'),c=e('./collection'),u=e('./payment_elements'),d={}.hasOwnProperty,PingppSDK=function(){e('./init').init()};PingppSDK.prototype={version:r,createPayment:function(e,n,t,r){if('function'==typeof n&&(o.userCallback=n),u.init(e),!d.call(u,'id'))return void o.innerCallback('fail',o.error('invalid_charge','no_charge_id'));if(!d.call(u,'channel'))return void o.innerCallback('fail',o.error('invalid_charge','no_channel'));d.call(u,'app')&&('string'==typeof u.app?l.app_id=u.app:'object'==typeof u.app&&'string'==typeof u.app.id&&(l.app_id=u.app.id)),c.report({type:'pure_sdk_click',channel:u.channel,ch_id:u.id});var s=u.channel;if(!d.call(u,'credential'))return void o.innerCallback('fail',o.error('invalid_charge','no_credential'));if(!u.credential)return void o.innerCallback('fail',o.error('invalid_credential','credential_is_undefined'));if(!d.call(u.credential,s))return void o.innerCallback('fail',o.error('invalid_credential','credential_is_incorrect'));if(!d.call(u,'livemode'))return void o.innerCallback('fail',o.error('invalid_charge','no_livemode_field'));var f=a.getChannelModule(s);return'undefined'==typeof f?(console.error('channel module "'+s+'" is undefined'),void o.innerCallback('fail',o.error('invalid_channel','channel module "'+s+'" is undefined'))):u.livemode===!1?void(d.call(f,'runTestMode')?f.runTestMode(u):i.runTestMode(u)):('undefined'!=typeof t&&(l.signature=t),'boolean'==typeof r&&(l.debug=r),void f.handleCharge(u))},setAPURL:function(e){l.APURL=e}},n.exports=new PingppSDK},{"./callbacks":1,"./collection":3,"./init":4,"./mods":7,"./payment_elements":8,"./stash":9,"./testmode":10,"./version":12}],7:[function(e,n,t){var r={}.hasOwnProperty,i={};n.exports=i,i.channels={wx_lite:e('./channels/wx_lite')},i.extras={},i.getChannelModule=function(e){if(r.call(i.channels,e))return i.channels[e]},i.getExtraModule=function(e){if(r.call(i.extras,e))return i.extras[e]}},{"./channels/wx_lite":2}],8:[function(e,n,t){var r=e('./callbacks'),i={}.hasOwnProperty;n.exports={id:null,or_id:null,channel:null,app:null,credential:{},extra:null,livemode:null,order_no:null,time_expire:null,init:function(e){var n;if('string'==typeof e)try{n=JSON.parse(e)}catch(t){return void r.innerCallback('fail',r.error('json_decode_fail',t))}else n=e;if('undefined'==typeof n)return void r.innerCallback('fail',r.error('json_decode_fail'));if(i.call(n,'object')&&'order'==n.object){n.or_id=n.id,n.id=n.charge,n.order_no=n.merchant_order_no;var o=n.charge_essentials;n.channel=o.channel,n.credential=o.credential,n.extra=o.extra}for(var a in this)i.call(n,a)&&(this[a]=n[a]);return this},clear:function(){for(var e in this)'function'!=typeof this[e]&&(this[e]=null)}}},{"./callbacks":1}],9:[function(e,n,t){n.exports={}},{}],10:[function(e,n,t){var r=e('./utils'),i={}.hasOwnProperty;n.exports={PINGPP_MOCK_URL:'http://sissi.pingxx.com/mock.php',runTestMode:function(e){var n={ch_id:e.id,scheme:'http',channel:e.channel};i.call(e,'or_id')&&null!==e.or_id&&(n.or_id=e.or_id),i.call(e,'order_no')?n.order_no=e.order_no:i.call(e,'orderNo')&&(n.order_no=e.orderNo),i.call(e,'time_expire')?n.time_expire=e.time_expire:i.call(e,'timeExpire')&&(n.time_expire=e.timeExpire),i.call(e,'extra')&&(n.extra=encodeURIComponent(JSON.stringify(e.extra))),r.redirectTo(this.PINGPP_MOCK_URL+'?'+r.stringifyData(n))}}},{"./utils":11}],11:[function(e,n,t){var r={}.hasOwnProperty,i=n.exports={stringifyData:function(e,n,t){'undefined'==typeof t&&(t=!1);var i=[];for(var o in e)r.call(e,o)&&'function'!=typeof e[o]&&('bfb_wap'==n&&'url'==o||'yeepay_wap'==n&&'mode'==o||'channel_url'!=o&&i.push(o+'='+(t?encodeURIComponent(e[o]):e[o])));return i.join('&')},request:function(e,n,t,o,a,l){if('undefined'==typeof XMLHttpRequest)return void console.log('Function XMLHttpRequest is undefined.');var c=new XMLHttpRequest;if('undefined'!=typeof c.timeout&&(c.timeout=6e3),n=n.toUpperCase(),'GET'===n&&'object'==typeof t&&t&&(e+='?'+i.stringifyData(t,'',!0)),c.open(n,e,!0),'undefined'!=typeof l)for(var u in l)r.call(l,u)&&c.setRequestHeader(u,l[u]);'POST'===n?(c.setRequestHeader('Content-type','application/json; charset=utf-8'),c.send(JSON.stringify(t))):c.send(),'undefined'==typeof o&&(o=function(){}),'undefined'==typeof a&&(a=function(){}),c.onreadystatechange=function(){4==c.readyState&&o(c.responseText,c.status,c)},c.onerror=function(e){a(c,0,e)}},formSubmit:function(e,n,t){if('undefined'==typeof window)return void console.log('Not a browser, form submit url: '+e);var i=document.createElement('form');i.setAttribute('method',n),i.setAttribute('action',e);for(var o in t)if(r.call(t,o)){var a=document.createElement('input');a.setAttribute('type','hidden'),a.setAttribute('name',o),a.setAttribute('value',t[o]),i.appendChild(a)}document.body.appendChild(i),i.submit()},randomString:function(e){'undefined'==typeof e&&(e=32);for(var n='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789',t=n.length,r='',i=0;i<e;i++)r+=n.charAt(Math.floor(Math.random()*t));return r},redirectTo:function(e){return'undefined'==typeof window?void console.log('Not a browser, redirect url: '+e):void(window.location.href=e)},inWeixin:function(){if('undefined'==typeof navigator)return!1;var e=navigator.userAgent.toLowerCase();return e.indexOf('micromessenger')!==-1},documentReady:function(e){return'undefined'==typeof document?void e():void('loading'!=document.readyState?e():document.addEventListener('DOMContentLoaded',e))},loadUrlJs:function(e,n,t){var r=document.getElementsByTagName('head')[0],i=null;null==document.getElementById(e)?(i=document.createElement('script'),i.setAttribute('type','text/javascript'),i.setAttribute('src',n),i.setAttribute('id',e),i.async=!0,null!=t&&(i.onload=i.onreadystatechange=function(){return!i.ready&&void(i.readyState&&'loaded'!=i.readyState&&'complete'!=i.readyState||(i.ready=!0,t()))}),r.appendChild(i)):null!=t&&t()}}},{}],12:[function(e,n,t){n.exports={v:'2.1.7'}},{}]},{},[6])(6)});
//# sourceMappingURL=pingpp.js.map
... ...
//正式
var uri={
HOST__LINE:'https://xt05.colorcun.com/?s=',
//获取商家信息
CGI__USER_GETSELLERBYID: 'App.Seller.GetSellerById',
CGI__USER_GETSELLERBYID__CODE: 18001,
//录入订座信息
CGI_USER_SETRESERVEINFO:'App.Reserve.SetReserveInfo',
CGI_USER_SETRESERVEINFO__CODE:19016,
//商家预订本列表
CGI_USER_GETRESERVELIST:'App.Reserve.GetReserveList',
CGI_USER_GETRESERVELIST__CODE:19017,
//获取座位信息
CGI_USER_GETTABLELIST:'App.Reserve.GetTableList',
CGI_USER_GETTABLELIST__CODE:19018,
//查询某个商家下营业信息
CGI_USER_GETOPERDATEBYDAY:'App.Report.GetOperDateByDay',
CGI_USER_GETOPERDATEBYDAY__CODE:19019,
//热销、滞销菜品列表
CGI_USER_GETSALESBYCOOKBOOK:'App.Report.GetSalesByCookbook',
CGI_USER_GETSALESBYCOOKBOOK__CODE:19020,
//获取打开的商户信息、当前打开的用户信息
CGI_USER_GETSYSTEMBYOPENID:'App.Seller.GetSystemByOpenid',
CGI_USER_GETSYSTEMBYOPENID__CODE:19021,
//缓存key
CACHE__COMMON:'common',
CACHE__TOKEN:'token',
CACHE__SYSTEM_INFO:'system.info',
CACHE__LOGINCODE:'login_code',
CACHE__USER:'user',
//图片尺寸
IMAGE__MAX:720,
IMAGE__MED:360,
IMAGE__MIN:180,
//over
end:0
}
module.exports = uri;
\ No newline at end of file
... ...
var uri=require('uri.js')
var Pingpp=require('pingpp.js')
function formatTime(date,type,connect) {
var year = date.getFullYear()
var month = date.getMonth() + 1
var day = date.getDate()
var hour = date.getHours()
var minute = date.getMinutes()
var second = date.getSeconds()
if(type==1){
if(connect){
return [year, month, day].map(formatNumber).join(connect)
}else{
return [year, month, day].map(formatNumber).join('/')
}
}else if(type==2){
return [month, day].map(formatNumber).join('/')
}else{
return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':')
}
}
function formatNumber(n) {
n = n.toString()
return n[1] ? n : '0' + n
}
//时间戳转为时间
function unixtoTime(ns,format) {
var result;
var time = new Date(ns*1000);
//result=format || 'YYYY年MM月DD日 HH时II分SS秒 WW';
result=format || 'YYYY年MM月DD日';
console.log(format);
result=result.toUpperCase();
result=result.replace('YYYY',time.getFullYear());
var m=time.getMonth()+1;
result=result.replace('MM',m>9?m:"0"+m);
var d=time.getDate();
result=result.replace('DD',d>9?d:'0'+d);
var hh=time.getHours();
result=result.replace('HH',hh>9?hh:'0'+hh);
var ii=time.getMinutes();
result=result.replace('II',ii>9?ii:'0'+ii);
var ss=time.getSeconds();
result=result.replace('SS',ss>9?ss:'0'+ss);
var week;
switch (time.getDay()) {
case 0:week="星期天";break
case 1:week="星期一";break
case 2:week="星期二";break
case 3:week="星期三";break
case 4:week="星期四";break
case 5:week="星期五";break
case 6:week="星期六";break
}
result=result.replace('WW',week);
return result;
}
//时间转为时间戳
function timetouUnix(dasr,connect)
{
if(connect){
var newstr = dasr.replace(/-/g,connect);
}else{
var newstr = dasr.replace(/-/g,'/');
}
var date = new Date(newstr);
var time_str = date.getTime().toString();
return time_str.substr(0, 10);
}
//支付
function orderPay(charge){
var that=this;
console.log(charge);
var obj = JSON.parse(charge)
console.log('obj:',obj);
wx.requestPayment({
'timeStamp': obj.timeStamp,
'nonceStr': obj.nonceStr,
'package': obj.package,
'signType': 'MD5',
'paySign': obj.paySign,
'success':function(res){
console.log('success:',res);
},
'fail':function(res){
console.log('fail:',res);
},
'complete':function(res){
}
})
}
module.exports = {
formatTime: formatTime,
unixtoTime:unixtoTime,
timetouUnix:timetouUnix,
orderPay:orderPay,
cgi:function(act){
return uri.HOST__LINE+act //正式
//return uri.HOST__TEST+act //测试
},
wxApiIsUse:function(api){
if(wx.canIUse(api)){
return true;
}else{
this.alert('当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。');
}
},
openXcx:function(data){
if(this.wxApiIsUse('navigateToMiniProgram')){
wx.navigateToMiniProgram({
appId: data.appId,
path: data.path,
extraData: {
foo: 'bar'
},
envVersion: 'trial',
//envVersion: '',
success(res) {
// 打开成功
}
})
}
},
loading:function(flag){
if(flag=='clear' || flag=="clean"){
wx.hideNavigationBarLoading();
return;
}
wx.showNavigationBarLoading();
},
postSuccessFun:function(json,uri_code){
console.log("APP::postSuccessFun",uri_code,json);
},
postFailFun:function(json,uri_code){
console.log(json,uri_code);
},
getToken:function(n_function){
var token=this.cache(uri.CACHE__TOKEN);
console.log("token:",token);
if(!token) {
this.loginStart(n_function);
return;
}
return token;
},
asyn:function(act,data,uri_code,n_function){//静默方式,不带loading
data=data||{};
var that=this;
data.token=that.cache(uri.CACHE__TOKEN);
wx.request({
url: that.cgi(act),
method:'POST',
data: data,
header: {
'content-type': 'application/x-www-form-urlencoded'
},
success: function(res) {
console.log('asyn_success:',act,uri_code,res);
that.loading('clear');
if(n_function){
that.loginStart(n_function);
}
/*if(typeof res.data!='string'){
if(res.data.code!=200&&res.data.code!=1000){
console.log(res.data.code==-1,res.data.code);
if(res.data.code==-1) {
that.loginStart(n_function);
return;
}else{
that.alert(res.data.message);
return;
}
}
}*/
that.postSuccessFun(res.data,uri_code);
},
fail: function(res) {
console.log('asyn_fail:',act,uri_code,res);
that.loading('clear');
that.toast(res.errMsg);
that.postFailFun(res.data,uri_code);
}
})
},
post:function(act,data,uri_code,is_load,n_function,header={'Content-Type': 'application/x-www-form-urlencoded'}){
console.log('act:',act)
if(is_load!='0'){
this.loading();
}
this.asyn(act,data,uri_code,n_function,header);
},
upload:function(filePath,fileIndex,uri_code,sellerid,type,file){
var that=this;
this.loading();
if(this.wxApiIsUse('uploadFile')){
wx.uploadFile({
url: that.cgi('Seller/Index/UploadImages'),
filePath: filePath,
name: 'file',
formData:{
sellerid:sellerid,
type:type
},
success: function(res){
that.loading('clear');
that.postSuccessFun(res.data,uri_code,fileIndex);
},
fail: function(res) {
that.loading('clear');
that.toast("上传失败,请重试");
that.postFailFun(res.data,uri_code,fileIndex);
}
});
}
},
uploading:function(filePath,fileIndex,dir,uri_code,file){
var that=this;
this.loading();
console.log(filePath,fileIndex,dir,uri_code);
if(this.wxApiIsUse('uploadFile')){
wx.uploadFile({
url: 'https://xt05.colorcun.com/?s=App.Cookbook.UpLoadFile',
filePath: filePath,
name: 'file',
formData:{
dir:dir
},
success: function(res){
console.log('上传成功')
console.log(res)
that.loading('clear');
that.postSuccessFun(res.data,uri_code,fileIndex);
},
fail: function(res) {
that.toast("上传失败,请重试");
that.postFailFun(res.data,uri_code,fileIndex);
}
});
}
},
uploadImg:function(filePath,fileIndex,uri_code){
var that=this;
if(this.wxApiIsUse('uploadFile')){
wx.uploadFile({
url: that.cgi('bargainimage'),
filePath: filePath,
name: 'path',
formData:{
'token': that.getToken()
},
success: function(res){
console.log(res);
res.data=JSON.parse(res.data);
if(res.data.code!=200){
if(res.data.code==-1) {
wx.navigateTo({url:'/pages/login/index'});
return;
}else{
that.alert(res.data.message);
}
}
console.log("res-code-data",uri_code,res.data);
that.postSuccessFun(res.data,uri_code,fileIndex);
},
fail:function(res){
console.log(res);
}
});
}
},
download:function(id,uri_code,width){
var that=this;
this.loading();
if(this.wxApiIsUse('downloadFile')){
wx.downloadFile({
url: that.cgi('download'),
success: function(res) {
console.log("res-code-data",uri_code,res);
wx.playVoice({
filePath: res.tempFilePath
})
that.postSuccessFun(id,uri_code,width,res.data);
}
});
}
},
alert:function(msg,success,cancel,title){
wx.showModal({
title:title?title:"提示信息",
content:msg,
showCancel:typeof cancel=='undefined'?false:true,
success:function(res){
if(res.confirm){
if(success) success();
}else{
if(cancel) cancel();
}
}
});
},
toast:function(title){
wx.showToast({
title:title,
icon:"success"
})
},
showLoading:function(title){
wx.showLoading({
title: '加载中',
})
},
getCommonType:function(key){
var that=this;
var common = that.cache(uri.CACHE__COMMON) || {time:0};
var time=Date.now();
if(common.time<time-600000){
wx.request({
url: that.cgi('commontype'),
header: {
'Content-Type': 'application/json'
},
success: function(res) {
if(res.data.code==200){
common={data:res.data.data,time:time};
//wx.setStorageSync(uri.CACHE__COMMON,common);
that.cache(uri.CACHE__COMMON,common)
}
}
})
}
if(!key) return common.data;
common = that.cache(uri.CACHE__COMMON) || {time:0};
return common.data[key];
},
getCommonTag:function(key,v_id){
var that=this;
var tagsdata=this.cache(uri.CACHE__COMMONTAG);
if(!tagsdata){
wx.request({
url: that.cgi(uri.CGI__USER_TCOMMONTAG),
data:{
'token': that.getToken()
},
header: {
'Content-Type': 'application/json'
},
success: function(res) {
if(res.data.code==200){
that.cache(uri.CACHE__COMMONTAG,res.data.data);
}
}
})
}
tagsdata=this.cache(uri.CACHE__COMMONTAG);
var result;
if(v_id){
tagsdata[key].map(function(v){
if(v.id==v_id){
result=v.tag_name;
}
})
}else{
result=tagsdata[key];
}
return result;
},
cache:function(key,value){
if(value){
wx.setStorageSync(key,value);
}
return wx.getStorageSync(key);
},
remove:function(key){
if(key){
wx.removeStorage({key: key})
}
},
image:function(id,width=""){
var url=this.cgi(uri.CGI__DOWNLOAD+'/id/'+id);
if(width){
url+='/width/'+width;
}
return url;
},
avatar:function(id,t='pu'){
return this.cgi(uri.CGI__AVATAR +'/'+t+'/'+id);
},
trim:function(str){
return str.replace(/^([ ]+)/,"").replace(/([ ]+)$/,"");
},
clear:function(str){//去除html标签
return this.trim(str.replace(/<[^>]+>/ig,""));
},
clearHtml:function(html){//去除html中特殊字符
html=html.replace(/[\n\r\t]+/ig,'');
html=html.replace(/<html[^>]*>(.*)<body[^>]*>/ig,'');
html=html.replace(/<div[^>]*>(.*)<article[^>]*>/ig,'');
html=html.replace(/<\/article[^>]*>(.*)<\/div[^>]*>/ig,'');
html=html.replace(/<style[^>]*>(.*)<\/style>/ig,'');
html=html.replace(/<\/body.*/ig,'');
html=html.replace(/<!--[^>]+>/ig,'');
html=html.replace(/&quot;/ig,'');
return html;
},
val:function(e){
return e.detail.value;
},
attr:function(e,key){
return e.currentTarget.dataset[key];
},
extend:function(destination, source) {
for (var property in source) {
destination[property] = source[property];
}
return destination;
},
getToken:function(n_function){
var token=this.cache(uri.CACHE__TOKEN);
console.log("token:",token);
if(!token) {
this.loginStart(n_function);
return;
}
return token;
},
loginStart:function(n_function){
console.log("n_function:",n_function,1111);
var that=this;
wx.login({
success: function(login_res) {
if (login_res.code) {
console.log('success');
console.log('wx.login.res' , login_res);
that.cache(uri.CACHE__LOGINCODE,login_res.code);
wx.getUserInfo({
success: function(res) {
res.code=login_res.code;
console.log('wx.getProviderInfo.res' , res);
var data={
code:login_res.code,
encryptData:res.encryptData,
encryptedData:res.encryptedData,
iv:res.iv,
rawData:res.rawData,
signature:res.signature,
appid:'wxc359908817c7bdd9',
secret:'a14a8415a501ade9542968d8a6504820',
}
wx.request({
url: that.cgi(uri.CGI__USER_XCXLOGIN),
data: data,
header: {
'content-type': 'application/json'
},
success: function(res) {
that.cache('setting','success');
that.cache(uri.CACHE__LOGINCODE,login_res.code);
/*if(n_function){
var pagelength=getCurrentPages().length;
console.log("pagelength:",pagelength);
console.log("getCurrentPages:",getCurrentPages());
if(typeof getCurrentPages()[pagelength-1][n_function]()!='undefined'){
getCurrentPages()[pagelength-1][n_function]();
}
}*/
return;
}
})
},
fail:function(){
that.cache('loginfail','fail');
if(n_function){
var pagelength=getCurrentPages().length;
console.log('hahahah');
getCurrentPages()[pagelength-1].onShow();
}
}
});
} else {
console.log('获取用户登录态失败!' + res.errMsg)
}
}
});
},
//重新调起授权
userInfoHandler:function(etarget){
if(this.wxApiIsUse('button.open-type.getUserInfo')){
if(etarget.detail&& etarget.detail.errMsg=='getUserInfo:ok'){
return true
//this.dc_loginStart()
}
}
},
getAccess_token: function (a, s, n_tempmessage) {
var that = this;
wx.request({
url: 'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=' + a + '&secret=' + s, //仅为示例,并非真实的接口地址
header: {
'content-type': 'application/json'
},
success: function (res) {
console.log('access_token!!!!console:', res)
console.log('access_token:', res.data.access_token)
that.sendMessage(res.data.access_token, n_tempmessage);
}
})
},
//模板消息
sendMessage: function (a_t, dd) {
var that = this;
wx.request({
url: 'https://api.weixin.qq.com/cgi-bin/message/wxopen/template/send?access_token=' + a_t, //仅为示例,并非真实的接口地址
data: dd,
method: 'POST',
header: {
'content-type': 'application/json'
},
success: function (res) {
console.log('发送模板消息:',res)
//that.sendMessuc(res);
}
})
},
//获取当前网络状态
getNetwork:function(){
var that=this;
if(this.wxApiIsUse('getNetworkType')){
wx.getNetworkType({
success: function(res) {
that.getNetworkSuccess(res.networkType);
},
fail:function(res){
that.toast('获取网络状况失败!');
}
})
}
},
getNetworkSuccess:function(network){
return network;
},
compare:function(property){
return function(a,b){
var value1 = a[property];
var value2 = b[property];
return value1 - value2;
}
},
getJsonLength:function(jsonData){
var jsonLength = 0;
for(var item in jsonData){
jsonLength++;
}
return jsonLength;
},
testPhone:function(phone){
if(!/^1[3-9][0-9]{9}$/.test(phone)){
this.alert("请输入正确的电话号码");
return false;
}
},
//加入卡包
addInCard:function(sellerid){
var that = this;
wx.request({
url: that.cgi(uri.CGI__USER_GETSIGNOPENCARD),
method:'GET',
header: {
'content-type': 'application/x-www-form-urlencoded'
},
data:{
sellerid:1,
},
success: function(res) {
console.log(res)
var cardExtstr = res.data.data.cardExt
var cardId = res.data.data.cardid
console.log('cardExtstr:',cardExtstr);
wx.addCard({
cardList: [
{
cardId: cardId,
cardExt: cardExtstr,
}
],
success: function(res) {
console.log('success:',res)
that.cache('cardList',res.cardList);
},
fail:function(res) {
console.log('fail:',res)
},
})
}
})
},
//保存图片
saveImage: function(url){
var that = this;
wx.downloadFile({
url:url,
success:function(res){
var path = res.tempFilePath
wx.saveImageToPhotosAlbum({
filePath: path,
success(res) {
},
//保存图片重新授权
fail(res) {
wx.openSetting({
success: (res) => {
res.authSetting = {
"scope.writePhotosAlbum": true
}
}
})
},
})
},
fail:function(res){
}
})
},
//根据source判断会员卡1 或优惠券2
sourceFrom:function(){
var source = this.cache('source')
console.log('source:',source)
var title = ''
if(source==1){
title = '会员卡'
}else{
title = '优惠券'
}
wx.setNavigationBarTitle({
title:title
})
return source
},
//返回会员卡 优惠券的开通进度
stepSetting:function(stepnum){
var source = this.cache('source')
var step = {
content:['会员卡开通','会员卡设置','发放确认','发放完成'],
step:[{id:'0'},{id:'1'},{id:'2'},{id:'3'}],
stepnum:stepnum
}
if(step&&source==2){
step.content[0] = '优惠券开通'
step.content[1] = '优惠券设置'
}
return step
},
setBarTitle:function(title){
wx.setNavigationBarTitle({
title:title
})
},
//小数规则:小数只能存在一个小数点并且至多保留两位小数 数字首位可以为0 第二位不能为0
limitDigit:function(value,firsezero){
if(value.length==1&value=='.'){
value = '0'+'.'
}
if(value=='00'){
value = '0'
}
value = value.replace(/\.{2,}/g,"."); //只保留第一个. 清除多余的
value = value.replace(".","$#$").replace(/\./g,"").replace("$#$",".");
value = value.replace(/^(\-)*(\d+)\.(\d\d).*$/,'$1$2.$3');//只能输入两个小数
//firsezero存在 首位不能为0
if(firsezero){
if(value.indexOf(".")< 0 && value !=""){//以上已经过滤,此处控制的是如果没有小数点,首位不能为类似于 01、02的金额
value= parseFloat(value);
}
}
return value
},
//
isEOne : function(arr,value){
for(var i = 0,vlen = arr.length; i < vlen; i++){
if(arr[i] == value){
return i;
}
}
return -1;
},
linkTo:function(url,sellerid,code){
var path='pages/menu/'+url;
if(code!=''){
path+='?sellerid='+sellerid+'&code='+code
}
if(sellerid!=''){
path+='?sellerid='+sellerid
}
console.log(path)
wx.navigateToMiniProgram({
appId: 'wx52646daaa3f42a4f',
path: path,
envVersion: 'release',
success:function(res) {
console.log(path)
}
})
},
setting:function(){
if(wx.canIUse('openSetting')==true){
wx.openSetting({
success:function(res){
console.log(res.authSetting)
return res.authSetting
}
})
}
},
//获取设备信息
getsystem:function(){
try {
var res = wx.getSystemInfoSync()
return res;
} catch (e) {
return false
}
}
}
... ...