Commit 449025c4af5d3452e436f3a756c6b9ef0e6ea32a

Authored by vking
1 parent 31039a9f

fenli

@@ -65,7 +65,8 @@ @@ -65,7 +65,8 @@
65 "pages/book/smsbatch/list", 65 "pages/book/smsbatch/list",
66 "pages/book/smsbatch/result", 66 "pages/book/smsbatch/result",
67 "pages/book/roomtype/roomtype", 67 "pages/book/roomtype/roomtype",
68 - "pages/book/b_reserve" 68 + "pages/book/b_reserve",
  69 + "pages/book/common/newSellerLite"
69 ] 70 ]
70 } 71 }
71 ], 72 ],
1 -var mta=require('mta-wechat-analysis') 1 +var mta = require('mta-wechat-analysis')
2 var util = require('../../../utils/util.js') 2 var util = require('../../../utils/util.js')
3 -var uri=require('../../../utils/uri.js')  
4 -var bookOrder=require('../../../utils/bookCommon.js') 3 +var uri = require('../../../utils/uri.js')
  4 +var bookOrder = require('../../../utils/bookCommon.js')
5 import App from '../../../utils/api'; 5 import App from '../../../utils/api';
  6 +
6 const {regeneratorRuntime} = global 7 const {regeneratorRuntime} = global
7 Page({ 8 Page({
8 - data:{  
9 - isloading:false,  
10 - pagex:1,  
11 - pagey:10,  
12 - sort:null,  
13 - dateStr:'',  
14 - calendarMaskLoad:false,  
15 - calendarMask:false,  
16 - dayStyle:[  
17 - { month: 'current', day: new Date().getDate(), color: 'white', background: '#AAD4F5' },  
18 - { month: 'current', day: new Date().getDate(), color: 'white', background: '#AAD4F5' }  
19 - ],  
20 - keywords:'',  
21 - sort:'',  
22 - form:{  
23 - time:-1,  
24 - },  
25 - timePickerArray:[  
26 - [],  
27 - [],  
28 - [],  
29 - ],  
30 - speciallist:[],  
31 - ReservesCountMonth:[],  
32 - ReservesTotal:0,  
33 - timeStrLabel:bookOrder.timeStrLabel 9 + data: {
  10 + isloading: false,
  11 + pagex: 1,
  12 + pagey: 10,
  13 + sort: null,
  14 + dateStr: '',
  15 + calendarMaskLoad: false,
  16 + calendarMask: false,
  17 + dayStyle: [
  18 + {month: 'current', day: new Date().getDate(), color: 'white', background: '#AAD4F5'},
  19 + {month: 'current', day: new Date().getDate(), color: 'white', background: '#AAD4F5'}
  20 + ],
  21 + keywords: '',
  22 + sort: '',
  23 + form: {
  24 + time: -1,
34 }, 25 },
35 - sellerid:0,  
36 - indexOpt:null,  
37 - YYYY:'YYYY',  
38 - onLoad:async function(opt){  
39 - if(opt.rid){  
40 - this.reserveId=opt.rid  
41 - delete opt.rid  
42 - }  
43 - this.indexOpt=opt;  
44 - mta.Page.init({  
45 - "appID":"500667280",  
46 - "eventID":"500667287",  
47 - "statPullDownFresh":true,  
48 - "statShareApp":true,  
49 - "statReachBottom":true,  
50 - "lauchOpts":opt, //渠道分析  
51 - });  
52 - let d=new Date()/1000;  
53 - let dateStr=util.unixtoTime(d,'MM-DD DAY');  
54 - var radio=750/util.getsystem().windowWidth;  
55 - var contentHeight=util.getsystem().windowHeight-Math.ceil(120/radio)  
56 - if(opt.seller_id){  
57 - this.sellerid=opt.seller_id;  
58 - util.cache('sellerid',opt.seller_id)  
59 - util.cache('enter_params',opt)  
60 - App.Reserve.SellerInfo(opt)  
61 - }else{  
62 - this.sellerid=util.cache('sellerid');  
63 - }  
64 - //this.sellerid=opt.seller_id ? opt.seller_id : util.cache('sellerid');  
65 - let timePickerArray= await bookOrder.getDayTimeSpace();  
66 - let speciallist=[  
67 - { date: util.unixtoTime(d,'YYYY-MM-DD'), background: '', text:'今 天' },  
68 - { date: util.unixtoTime(d+86400,'YYYY-MM-DD'), background: '', text: '明 天' },  
69 - { date: util.unixtoTime(d+86400*2,'YYYY-MM-DD'), background: '', text: '后 天' },  
70 - ];  
71 - this.setData({  
72 - listHeight:contentHeight-Math.ceil(210/radio),  
73 - dateStr:dateStr,  
74 - timePickerArray: timePickerArray,  
75 - speciallist:speciallist,  
76 - })  
77 - //util.setBarTitle('预订本');  
78 - this.indexOpt=opt;  
79 - this.ReservesCountDay(util.unixtoTime(d,'YYYY-MM-DD'));  
80 - this.ReservesCountMonth(util.unixtoTime(d,'YYYY-MM'));  
81 - },  
82 - onShow:function(){ 26 + timePickerArray: [
  27 + [],
  28 + [],
  29 + [],
  30 + ],
  31 + speciallist: [],
  32 + ReservesCountMonth: [],
  33 + ReservesTotal: 0,
  34 + timeStrLabel: bookOrder.timeStrLabel
  35 + },
  36 + sellerid: 0,
  37 + indexOpt: null,
  38 + YYYY: 'YYYY',
  39 + onLoad: async function (opt) {
  40 + if (opt.rid) {
  41 + this.reserveId = opt.rid
  42 + delete opt.rid
  43 + }
  44 + let enter_params=util.cache('enter_params')
  45 + if(enter_params && enter_params.hasNewLite){
  46 + opt.hasNewLite=1
  47 + }
  48 + this.indexOpt = opt;
  49 + mta.Page.init({
  50 + "appID": "500667280",
  51 + "eventID": "500667287",
  52 + "statPullDownFresh": true,
  53 + "statShareApp": true,
  54 + "statReachBottom": true,
  55 + "lauchOpts": opt, //渠道分析
  56 + });
  57 + let d = new Date() / 1000;
  58 + let dateStr = util.unixtoTime(d, 'MM-DD DAY');
  59 + var radio = 750 / util.getsystem().windowWidth;
  60 + var contentHeight = util.getsystem().windowHeight - Math.ceil(120 / radio)
  61 + if (opt.seller_id) {
  62 + this.sellerid = opt.seller_id;
  63 + util.cache('sellerid', opt.seller_id)
  64 + util.cache('enter_params', opt)
  65 + App.Reserve.SellerInfo(opt)
  66 + } else {
  67 + this.sellerid = util.cache('sellerid');
  68 + }
  69 + //this.sellerid=opt.seller_id ? opt.seller_id : util.cache('sellerid');
  70 + let timePickerArray = await bookOrder.getDayTimeSpace();
  71 + let speciallist = [
  72 + {date: util.unixtoTime(d, 'YYYY-MM-DD'), background: '', text: '今 天'},
  73 + {date: util.unixtoTime(d + 86400, 'YYYY-MM-DD'), background: '', text: '明 天'},
  74 + {date: util.unixtoTime(d + 86400 * 2, 'YYYY-MM-DD'), background: '', text: '后 天'},
  75 + ];
  76 + this.setData({
  77 + listHeight: contentHeight - Math.ceil(210 / radio),
  78 + dateStr: dateStr,
  79 + timePickerArray: timePickerArray,
  80 + speciallist: speciallist,
  81 + })
  82 + //util.setBarTitle('预订本');
  83 + this.indexOpt = opt;
  84 + this.ReservesCountDay(util.unixtoTime(d, 'YYYY-MM-DD'));
  85 + this.ReservesCountMonth(util.unixtoTime(d, 'YYYY-MM'));
  86 + },
  87 + onShow: function () {
  88 + this.setData({
  89 + isloading: false,
  90 + })
  91 + this.getbooklist();
  92 + this.selectComponent('#nav').init();
  93 + setTimeout(() => {
83 this.setData({ 94 this.setData({
84 - isloading:false, 95 + calendarMaskLoad: true,
85 }) 96 })
86 - this.getbooklist();  
87 - this.selectComponent('#nav').init();  
88 - setTimeout(()=>{  
89 - this.setData({  
90 - calendarMaskLoad:true,  
91 - })  
92 - let openid=getApp().openid;  
93 - if(openid && this.indexOpt.seller_id){  
94 - App.Reserve.SellerForOpenid({openid:openid,sedata:JSON.stringify(this.indexOpt)})  
95 - //客户经理=>人人都是客户经理  
96 - //if(this.indexOpt.manager_id){  
97 - App.Reserve.UpdateSellerUser({seat_openid:openid,kid:this.indexOpt.manager_id});  
98 - //}  
99 - }else{  
100 - console.log('index-opt',openid,this.indexOpt);  
101 - }  
102 -  
103 - },1000);  
104 - if(this.reserveId){  
105 - let url='./b_detail?id='+this.reserveId  
106 - this.reserveId=''  
107 - return wx.navigateTo({  
108 - url:url  
109 - })  
110 - }  
111 - },  
112 - async getbooklist(isExport=false){  
113 - let time=0;  
114 - if(this.data.form.time<0){  
115 - let sid=await bookOrder.getTimeSpaceIndexData();  
116 - time=sid.timeIndex  
117 - }else{  
118 - time=this.data.form.time; 97 + let openid = getApp().openid;
  98 + if (openid && this.indexOpt.seller_id) {
  99 + App.Reserve.SellerForOpenid({openid: openid, sedata: JSON.stringify(this.indexOpt)})
  100 + //客户经理=>人人都是客户经理
  101 + //if(this.indexOpt.manager_id){
  102 + App.Reserve.UpdateSellerUser({seat_openid: openid, kid: this.indexOpt.manager_id});
  103 + //}
  104 + } else {
  105 + console.log('index-opt', openid, this.indexOpt);
119 } 106 }
120 - var formdata={};  
121 - if(this.data.sort!=''){  
122 - formdata.sort=this.data.sort  
123 - }  
124 - if(this.data.keywords!=''){  
125 - formdata.keywords=this.data.keywords  
126 - }  
127 - formdata.sid=this.sellerid;  
128 - formdata.x=1;  
129 - formdata.y=200;  
130 - let rdate=await bookOrder.getTimeSpace(this.data.dateStr,time,null,null,this.YYYY);  
131 - formdata.rdate=rdate;  
132 - if(isExport){  
133 - this.__exportFile(formdata);  
134 - }else{  
135 - var that=this;  
136 - App.Reserve.GetReserveList(formdata).then(function(json){  
137 - console.log(json)  
138 - if(json.ret==200){  
139 - that.setData({  
140 - isloading:true,  
141 - bookList:json.data.length==0 ? null : json.data,  
142 - form:{time:time},  
143 - })  
144 - that.boolists=that.selectAllComponents('.orderbook');  
145 - that.boolists.forEach(function(v,i){  
146 - v.changeitem();  
147 - })  
148 - }  
149 - }).catch(e=>{})  
150 - }  
151 - },  
152 - timeorder:function(){  
153 - if(this.data.sort==''){  
154 - this.data.sort=1;  
155 - }else{  
156 - this.data.sort='';  
157 - }  
158 107
159 - this.setData({  
160 - sort:this.data.sort  
161 - })  
162 - this.getbooklist();  
163 - },  
164 - searchinput:function(e){  
165 - this.data.keywords=e.detail.value;  
166 - this.setData({  
167 - keywords:this.data.keywords  
168 - })  
169 - if(e.detail.value==''){  
170 - this.getbooklist(); 108 + }, 1000);
  109 + if (!this.indexOpt.hasNewLite) {//没有登陆过新商户
  110 + let url = './common/newSellerLite'
  111 + return wx.redirectTo({
  112 + url: url
  113 + })
  114 + }
  115 + if (this.reserveId) {
  116 + let url = './b_detail?id=' + this.reserveId
  117 + this.reserveId = ''
  118 + return wx.navigateTo({
  119 + url: url
  120 + })
  121 + }
  122 + },
  123 + async getbooklist(isExport = false) {
  124 + let time = 0;
  125 + if (this.data.form.time < 0) {
  126 + let sid = await bookOrder.getTimeSpaceIndexData();
  127 + time = sid.timeIndex
  128 + } else {
  129 + time = this.data.form.time;
  130 + }
  131 + var formdata = {};
  132 + if (this.data.sort != '') {
  133 + formdata.sort = this.data.sort
  134 + }
  135 + if (this.data.keywords != '') {
  136 + formdata.keywords = this.data.keywords
  137 + }
  138 + formdata.sid = this.sellerid;
  139 + formdata.x = 1;
  140 + formdata.y = 200;
  141 + let rdate = await bookOrder.getTimeSpace(this.data.dateStr, time, null, null, this.YYYY);
  142 + formdata.rdate = rdate;
  143 + if (isExport) {
  144 + this.__exportFile(formdata);
  145 + } else {
  146 + var that = this;
  147 + App.Reserve.GetReserveList(formdata).then(function (json) {
  148 + console.log(json)
  149 + if (json.ret == 200) {
  150 + that.setData({
  151 + isloading: true,
  152 + bookList: json.data.length == 0 ? null : json.data,
  153 + form: {time: time},
  154 + })
  155 + that.boolists = that.selectAllComponents('.orderbook');
  156 + that.boolists.forEach(function (v, i) {
  157 + v.changeitem();
  158 + })
171 } 159 }
172 - },  
173 - calendarShow(){  
174 - console.log('xxxxx')  
175 - this.setData({  
176 - calendarMask:true  
177 - })  
178 - console.log(this.data.calendarMask)  
179 - },  
180 - dateChange(event){  
181 - this.YYYY=event.detail.date.substr(0,4);  
182 - let cktime=util.timetouUnix(event.detail.date)  
183 - console.log('cktime',cktime,this.YYYY)  
184 - let clickDay = event.detail.date.substr(8,2);  
185 - let changeDay = `dayStyle[1].day`;  
186 - let changeBg = `dayStyle[1].background`;  
187 - this.setData({  
188 - dateStr:util.unixtoTime(cktime,'MM-DD `DAY/周WW`'),  
189 - [changeDay]: clickDay,  
190 - [changeBg]: "#84e7d0" 160 + }).catch(e => {
191 }) 161 })
  162 + }
  163 + },
  164 + timeorder: function () {
  165 + if (this.data.sort == '') {
  166 + this.data.sort = 1;
  167 + } else {
  168 + this.data.sort = '';
  169 + }
  170 +
  171 + this.setData({
  172 + sort: this.data.sort
  173 + })
  174 + this.getbooklist();
  175 + },
  176 + searchinput: function (e) {
  177 + this.data.keywords = e.detail.value;
  178 + this.setData({
  179 + keywords: this.data.keywords
  180 + })
  181 + if (e.detail.value == '') {
192 this.getbooklist(); 182 this.getbooklist();
193 - this.calendarClose();  
194 - this.ReservesCountDay(event.detail.date);  
195 - },  
196 - calendarClose(){  
197 - this.setData({  
198 - calendarMask:false  
199 - })  
200 - },  
201 - selectedValue:function (e) {  
202 - this.setData({  
203 - form:{time:e.currentTarget.dataset.value}  
204 - })  
205 - this.getbooklist();  
206 - },  
207 - searchbook:function(e){  
208 - console.log(this.data.form)  
209 - this.getbooklist();  
210 - },  
211 - __exportFile(formdata){  
212 - App.Reserve.ExportReserve(formdata).then(res=>{  
213 - let url=res.data;  
214 - if(!url){  
215 - return util.toast('没有预订数据','none') 183 + }
  184 + },
  185 + calendarShow() {
  186 + console.log('xxxxx')
  187 + this.setData({
  188 + calendarMask: true
  189 + })
  190 + console.log(this.data.calendarMask)
  191 + },
  192 + dateChange(event) {
  193 + this.YYYY = event.detail.date.substr(0, 4);
  194 + let cktime = util.timetouUnix(event.detail.date)
  195 + console.log('cktime', cktime, this.YYYY)
  196 + let clickDay = event.detail.date.substr(8, 2);
  197 + let changeDay = `dayStyle[1].day`;
  198 + let changeBg = `dayStyle[1].background`;
  199 + this.setData({
  200 + dateStr: util.unixtoTime(cktime, 'MM-DD `DAY/周WW`'),
  201 + [changeDay]: clickDay,
  202 + [changeBg]: "#84e7d0"
  203 + })
  204 + this.getbooklist();
  205 + this.calendarClose();
  206 + this.ReservesCountDay(event.detail.date);
  207 + },
  208 + calendarClose() {
  209 + this.setData({
  210 + calendarMask: false
  211 + })
  212 + },
  213 + selectedValue: function (e) {
  214 + this.setData({
  215 + form: {time: e.currentTarget.dataset.value}
  216 + })
  217 + this.getbooklist();
  218 + },
  219 + searchbook: function (e) {
  220 + console.log(this.data.form)
  221 + this.getbooklist();
  222 + },
  223 + __exportFile(formdata) {
  224 + App.Reserve.ExportReserve(formdata).then(res => {
  225 + let url = res.data;
  226 + if (!url) {
  227 + return util.toast('没有预订数据', 'none')
216 } 228 }
217 wx.downloadFile({ 229 wx.downloadFile({
218 url: url, 230 url: url,
219 - success: function(res) { 231 + success: function (res) {
220 const filePath = res.tempFilePath; 232 const filePath = res.tempFilePath;
221 - console.log('filePath',filePath); 233 + console.log('filePath', filePath);
222 wx.previewImage({ 234 wx.previewImage({
223 current: filePath, 235 current: filePath,
224 urls: [filePath] 236 urls: [filePath]
225 }) 237 })
226 wx.saveImageToPhotosAlbum({ 238 wx.saveImageToPhotosAlbum({
227 - filePath:filePath,  
228 - fail (res) {  
229 - util.toast('保存失败','none') 239 + filePath: filePath,
  240 + fail(res) {
  241 + util.toast('保存失败', 'none')
230 } 242 }
231 }) 243 })
232 } 244 }
@@ -234,51 +246,51 @@ Page({ @@ -234,51 +246,51 @@ Page({
234 }); 246 });
235 247
236 }, 248 },
237 - exportFile(){ 249 + exportFile() {
238 this.getbooklist(true); 250 this.getbooklist(true);
239 }, 251 },
240 - ReservesCountDay(day){ 252 + ReservesCountDay(day) {
241 App.Reserve.ReservesCountDay({ 253 App.Reserve.ReservesCountDay({
242 - sid:this.sellerid,  
243 - day:day  
244 - }).then(res=>{ 254 + sid: this.sellerid,
  255 + day: day
  256 + }).then(res => {
245 257
246 - let ReservesTotal=0;  
247 - let ReservesCountDay={};  
248 - if(res.ret==200){  
249 - ReservesCountDay=res.data;  
250 - Object.keys(res.data).forEach(k=>{  
251 - if(res.data[k]!=-1){  
252 - ReservesTotal+=parseInt(res.data[k]) 258 + let ReservesTotal = 0;
  259 + let ReservesCountDay = {};
  260 + if (res.ret == 200) {
  261 + ReservesCountDay = res.data;
  262 + Object.keys(res.data).forEach(k => {
  263 + if (res.data[k] != -1) {
  264 + ReservesTotal += parseInt(res.data[k])
253 } 265 }
254 }) 266 })
255 } 267 }
256 this.setData({ 268 this.setData({
257 - ReservesTotal:ReservesTotal,  
258 - ReservesCountDay:ReservesCountDay, 269 + ReservesTotal: ReservesTotal,
  270 + ReservesCountDay: ReservesCountDay,
259 }) 271 })
260 }) 272 })
261 }, 273 },
262 - ReservesCountMonth(month){ 274 + ReservesCountMonth(month) {
263 App.Reserve.ReservesCountMonth({ 275 App.Reserve.ReservesCountMonth({
264 - sid:this.sellerid,  
265 - month:month  
266 - }).then(res=>{  
267 - let ReservesCountMonth=[];  
268 - if(res.ret==200){  
269 - res.data.forEach(v=>{  
270 - ReservesCountMonth.push(v>=1?1:0) 276 + sid: this.sellerid,
  277 + month: month
  278 + }).then(res => {
  279 + let ReservesCountMonth = [];
  280 + if (res.ret == 200) {
  281 + res.data.forEach(v => {
  282 + ReservesCountMonth.push(v >= 1 ? 1 : 0)
271 }) 283 })
272 } 284 }
273 this.setData({ 285 this.setData({
274 - ReservesCountMonth:ReservesCountMonth, 286 + ReservesCountMonth: ReservesCountMonth,
275 }) 287 })
276 }) 288 })
277 }, 289 },
278 - clickMonth(e){  
279 - this.ReservesCountMonth(e.detail.currentYear+'-'+e.detail.currentMonth); 290 + clickMonth(e) {
  291 + this.ReservesCountMonth(e.detail.currentYear + '-' + e.detail.currentMonth);
280 }, 292 },
281 - gotoday(e){  
282 - this.ReservesCountMonth(e.detail.date.substr(0,7)); 293 + gotoday(e) {
  294 + this.ReservesCountMonth(e.detail.date.substr(0, 7));
283 } 295 }
284 }) 296 })
  1 +// pack-book/pages/book/common/newSellerLite.js
  2 +Page({
  3 +
  4 + /**
  5 + * 页面的初始数据
  6 + */
  7 + data: {
  8 +
  9 + },
  10 +
  11 + /**
  12 + * 生命周期函数--监听页面加载
  13 + */
  14 + onLoad: function (options) {
  15 +
  16 + },
  17 +
  18 + /**
  19 + * 生命周期函数--监听页面初次渲染完成
  20 + */
  21 + onReady: function () {
  22 +
  23 + },
  24 +
  25 + /**
  26 + * 生命周期函数--监听页面显示
  27 + */
  28 + onShow: function () {
  29 +
  30 + },
  31 +
  32 + /**
  33 + * 生命周期函数--监听页面隐藏
  34 + */
  35 + onHide: function () {
  36 +
  37 + },
  38 +
  39 + /**
  40 + * 生命周期函数--监听页面卸载
  41 + */
  42 + onUnload: function () {
  43 +
  44 + },
  45 +
  46 + /**
  47 + * 页面相关事件处理函数--监听用户下拉动作
  48 + */
  49 + onPullDownRefresh: function () {
  50 +
  51 + },
  52 +
  53 + /**
  54 + * 页面上拉触底事件的处理函数
  55 + */
  56 + onReachBottom: function () {
  57 +
  58 + },
  59 +
  60 + /**
  61 + * 用户点击右上角分享
  62 + */
  63 + onShareAppMessage: function () {
  64 +
  65 + }
  66 +})
  1 +{
  2 + "backgroundTextStyle":"light",
  3 + "navigationBarBackgroundColor": "#fff",
  4 + "navigationBarTextStyle":"black",
  5 + "usingComponents": {
  6 + "nav":"/components/nav/nav"
  7 + }
  8 +}
  1 +<!--pack-book/pages/book/common/newSellerLite.wxml-->
  2 +<nav>周到商户</nav>
  3 +<view class="pages flex-vc">
  4 + <view style="font-size: 20px; margin-top: 60px;">升级了商户,将获得如下收益</view>
  5 + <view>1. 稳定的商户服务</view>
  6 + <view>2. 独立私有商户服务</view>
  7 + <view>3. 更加精准化统计及营销策略</view>
  8 +
  9 + <view style="font-size: 20px; margin-top: 60px;">你只需这样操作</view>
  10 + <view>1. 进入商户</view>
  11 + <view>2. 完成授权登录</view>
  12 + <view>3. 通过商户预定本回到预订安排</view>
  13 +
  14 + <button style="margin-top: 100px; width: 90%"
  15 + type="primary" size="{{primarySize}}" loading="{{loading}}" plain="{{plain}}"
  16 + disabled="{{disabled}}" bindtap="primary"> 进入商户 </button>
  17 +</view>
  1 +/* pack-book/pages/book/common/newSellerLite.wxss */