$(function () { 'use strict'; function cookieTolocalStorage() { // 获取localStorage是否有user var user = localStorage.getItem("user"); if (!user || user === 'false') { // 没有就找cookie user = $.cookie('user') ? $.cookie('user') : null; if (!user) { // 没有就返回null return null; } // var dec_user = $.caesar(JSON.stringify(user)); // 存在就保存到localStorage // console.log(JSON.stringify(user)) $.caesarCache('user', user); $.removeCookie('user'); } else { $.removeCookie('user'); } } cookieTolocalStorage(); window.addEventListener( 'COMMUNICATION', function (e) { var camera_scan = localStorage.getItem('camera_scan'); var camera_photo = localStorage.getItem('camera_photo'); var write_storage_photo = localStorage.getItem('write_storage_photo'); var write_storage_data = localStorage.getItem('write_storage_data'); var photo_data = localStorage.getItem('photo_data'); switch (e.detail.action) { case 'openAuthPromptWin': //从弹出 $.popup(".authPromptWin"); if(e.detail.type == 'CAMERA'){ $(".authPromptWin .camera").show(); $(".authPromptWin .storage").hide(); }else if(e.detail.type == 'STORAGE'){ $(".authPromptWin .camera").hide(); $(".authPromptWin .storage").show(); } break; case 'closeAuthPromptWin': // 关闭 $.closeModal(".authPromptWin"); $(".authPromptWin .camera, .authPromptWin .storage").hide(); var auth_list = androidJs.getHasSelfPermissionsJS(); if(auth_list.indexOf("CAMERA") !== -1){ localStorage.setItem('camera_scan', true); localStorage.setItem('camera_photo', true); } if (auth_list.indexOf("WRITE_EXTERNAL_STORAGE") !== -1) { localStorage.setItem('write_storage_data', true); } if (auth_list.indexOf("READ_EXTERNAL_STORAGE") !== -1) { localStorage.setItem('write_storage_photo', true); } break; case 'openCameraPromptWin': // 上传头像 - 相机 if(camera_scan == 'false'){ $.modal({ title:'
该服务需要申请使用以下权限:
', text: '相机权限:用于扫码、拍照时使用。
人脸影像数据仅用于饭堂取餐与现场消费用,如您不同意请不要进行后续操作。
', buttons: [{ text: '拒绝', onClick: () => { return "拒绝0"; } },{ text: '同意', onClick: ()=>{ localStorage.setItem('camera_scan', true); return "同意1"; } }] }); } break; case 'openAlbumPromptWin': // 上传头像 - 选取照片 if(camera_photo == 'false' || write_storage_photo == 'false' || write_storage_data == 'false'){ $.modal({ title:'该服务需要申请使用以下权限:
', text: '读写外部存储权限:用于用户拍摄时临时存储照片、上传照片。
人脸影像数据仅用于饭堂取餐与现场消费用,如您不同意请不要进行后续操作。
', buttons: [{ text: '拒绝', onClick: () => { return "拒绝0"; } },{ text: '同意', onClick: () => { localStorage.setItem('camera_photo', true); localStorage.setItem('write_storage_photo', true); localStorage.setItem('write_storage_data', true); return "同意1"; } }] }); } break; } }, false ); $(document).on( 'click', '.menu_list p a:not(.changeFt):not(.meal-order):not(.meal-vote)', function () { var user = $.parseJSON($.caesarCache('user') ? $.caesarCache('user') : null); $.closePanel(); var tar = $(this).attr('class'); switch (tar) { case 'listFood': var token = user.token ? user.token : null; location.href = '/jtj_admin/?act=login&token=' + token; break; default: tar = tar + '.html'; //fix 路由翻页时候不会关闭panel setTimeout(function () { $.router.loadPage(tar); }, 450); break; } } ); $(document).on('click', 'a.changePwd', function () { $.closePanel(); setTimeout(function () { $.router.loadPage('changePwd.html'); }, 450); }); $(document).on('click', 'a.noticeList', function () { $.closePanel(); setTimeout(function () { $.router.loadPage('noticeList.html'); }, 450); }); // 点击二维码关闭按钮 $(document).on('click', '.closeQr', function () { // 2019-11-06 yw // ios 亮度; if (typeof window.webkit !== 'undefined') { try { screenBrightnessBack(); } catch (error) {} } }); // 临时增加 饭堂窗口列表(小岛) $(document).on('pageInit', '#page-hallChannelList', function (e, pageId, page){ var user = $.parseJSON($.caesarCache('user') ? $.caesarCache('user') : null); initPage(); function initPage() { getData(); } function innerData(data) { $(page).find('.title').html(data.title); $('title').html(data.title); var channel_list = ''; if (data.list.length > 0) { $.each(data.list, function (i, item) { channel_list += '' + this.count + '
' : ''); $('#page-index4 .notice-view').html(notice_view); } /* ------------- */ function handleNoticeStatus(id) { var _this = this; var token = user.token; $.ajax({ type: 'GET', url: '../api/dishes/get_notice', dataType: 'json', data: { token: token, notice_id: id, }, success: function (res) { if (res.status == 1) { _this.count--; _this.renderIndex(); } }, error: function () { $.hideIndicator(); $.alert('请检查网络!'); }, }); } initPage(); if (!user.cellphone2) { $.alert( '云中美食即将启用短信验证码登录,请先绑定手机号', '温馨提示', function () { $.router.loadPage('bindCellphone.html'); } ); } function setHeight() { $('.main .cp-list').height( $(window).height() - $('.bar-tab').innerHeight() - $('header').innerHeight() ); $('.main .cs-list').height( $(window).height() - $('.bar-tab').innerHeight() - $('header').innerHeight() ); } function initPage() { var pid = $.getURLParameter('pid'); var did = $.getURLParameter('did'); //高度撑开 //var user = $.parseJSON($.cookie("user")); setHeight(); indexNotice.showNotice(); getData(pid, did); } function innerData(data) { beginTime = new Date().getTime(); dining_hall_id = data.dining_hall_id; date_id = data.date_id; //初始化title与页面标题 $('title').html(data.title); $(page).find('.title').html('饭堂用餐'); //实时取餐码 //这里接口处理不标准,增加一个判断 data.take_info===null||data.take_info.take_qrcode===null $(page) .find('.open-mypopover') .attr( 'data-url', data.take_info === null || data.take_info.take_qrcode === null ? ' ' : data.take_info.take_qrcode ); $(page) .find('.open-mypopover') .attr( 'data-name', data.take_info === null || data.take_info.take_qrcode === null ? ' ' : data.take_info.meal_text ); $(page) .find('.open-mypopover') .attr( 'data-num', data.take_info === null || data.take_info.take_qrcode === null ? ' ' : data.take_info.take_code ); $(page) .find('.open-mypopover') .attr( 'data-order_detail', data.take_info === null || data.take_info.take_qrcode === null ? ' ' : JSON.stringify(data.take_info.order_detail) ); $('.userinfo .ye').html(data.user.account); $('.userinfo .jf').html(data.user.jf); $('.userinfo .srjf').html(data.user.srjf); if(data.user.company_id == 58){ $('.userinfo .jf_txt').text('总积分'); } $(page).find('.title').removeAttr('data-type'); $(page).find('.title').attr('data-type', 'changeDate'); $(page).find('input[name=changeDate]').remove(); if (parseInt(date_id) > 0) { $(page) .find('.title') .after( '' ); } if (data.user.company_id == '34') { $('.company-tips').show(); } else { $('.company-tips').hide(); } var jcdataName = []; var jcdataValue = []; var myFtName = ''; if (data.jcdata && data.jcdata.length > 0) { $.each(data.jcdata, function (i, date) { if ( parseInt(user.dining_hall_id) === parseInt(date.jcplace.id) && date.jctime.length > 0 ) { $.each(date.jctime, function (i, meal) { jcdataName.push(meal.datename); jcdataValue.push(date.jcplace.id + '-' + meal.meal_list[0].id); }); jcdataName = JSON.parse(JSON.stringify(jcdataName)); jcdataValue = JSON.parse(JSON.stringify(jcdataValue)); $(page) .find('input[name=changeDate]') .picker({ toolbarTemplate: '暂无菜式
' ); } else { var tab_html = ' ' + '暂无菜式
'; look_date = look_date ? look_date : '暂无菜式
'; $('#page-index4 .cs-list #tab-list-order').html(cs_date); $('#page-index4 .cs-list #tab-list-look').html(look_date); } checkXhlBtn(); //初始化菜品 var cp_li = ''; var gdj_jcdata = data.meal_list; $.each(gdj_jcdata, function (k, cp) { cp.active = cp.id == data.now_meal_id ? 'active' : ''; cp.cpnum = parseInt(cp.cart_num) ? cp.cart_num : ''; cp_li += '' + ret.data.name + '
' + '' + '扫二维码进行支付操作
' + '' + num + '
' + '' + '扫二维码或按小键盘输入取餐码进行取餐
' + '该服务需要申请使用以下权限:
', text: '相机权限:用于扫码时使用。
仅用于饭堂扫码用,如您不同意请不要进行后续操作。
', buttons: [{ text: '拒绝', onClick: function (){ // localStorage.setItem('camera_scan', false); // localStorage.setItem('camera_photo', false); // localStorage.setItem('write_storage_photo', false); // localStorage.setItem('write_storage_data', false); // localStorage.setItem('photo_data', false); } },{ text: '同意', onClick: function (){ localStorage.setItem('camera_scan', true); window.androidJs.startScan(); // localStorage.setItem('camera_photo', true); // localStorage.setItem('write_storage_photo', true); // localStorage.setItem('write_storage_data', true); // localStorage.setItem('photo_data', true); } }] }); } } catch (e) {} } else if (typeof window.webkit !== 'undefined') { try { // ios QRScannerOpen(); } catch (e) {} } else { // $.alert('请使用App操作'); } }); } } else { $.alert('页面已过期,将刷新', function () { getData(); }); } }); $(page).on('click', '.order-open-btn', function () { var get_date_id = $(this).next().data('id'); var el = $(this).next().hasClass('card-look') ? '.card-look-' + get_date_id : '.card-order-' + get_date_id; var _this = this; if (!$(page).find(el).is(':animated')) { $(page).find(el).slideToggle('slow'); $(_this).find('.icon').hasClass('icon-prev') ? $(_this).find('.icon').removeClass('icon-prev') : $(_this).find('.icon').addClass('icon-prev'); } }); }); // 针对珠海电信定制 $(document).on('pageInit', '#page-index6', function (e, pageId, page) { var beginTime = 0; var user = $.parseJSON($.caesarCache('user') ? $.caesarCache('user') : null); var rise_tips = false; var dining_hall_id; var date_id; var totalNum = 0; var totalPrice = 0; var dining_halls = ''; var user_birthMsg = ''; var indexNotice = { list: [], count: 0, showNotice: showNotice, openNotice: openNoticeHtml, renderIndex: renderNoticeIndex, handleNoticeStatus: handleNoticeStatus, }; if (user && $('.noticeNum').find('a').hasClass('noticeList')) { $('.noticeNum').find('a').removeClass('noticeList'); $('.noticeNum').find('a').addClass('noticeList2'); } if ( user && user.hasOwnProperty('theme') && user.theme && user.theme != '6' ) { $.router.replacePage(initTheme(user.theme)); // $.router.replacePage(initTheme(user.theme)); return; } if (user && (user.company_id == '42' || user.company_id == '58')) { $('.changeFt').parent('p').hide(); } // 获取notice数据 function showNotice() { // return false; var _this = this; var token = user.token; $.ajax({ type: 'POST', url: '../show/jtj.php?act=gdj_findNoticeByUser', dataType: 'json', headers: { 'Content-Type': 'application/json;', }, data: JSON.stringify({ token: token, // 假数据 }), success: function success(ret) { if (typeof ret.code !== 'undefined') { $.closePanel(); if (ret.code === -1) { $.closePanel(); return; } else if (ret.code === 0) { _this.list = ret.content.notice; _this.count = ret.content.unreadCount; var sessionStorage = window.sessionStorage; var open_notice_count = sessionStorage.getItem( 'open_notice_count' ); // 默认第一次进入APP都打开 if (!open_notice_count) { setTimeout(function () { indexNotice.openNotice(); open_notice_count++; sessionStorage.setItem( 'open_notice_count', open_notice_count ); }, 400); } $('.noticeNum') .find('.noticeList2') .find('.num') .html(ret.content.unreadCount ? ret.content.unreadCount : '0'); /* 渲染未阅读数据 */ _this.renderIndex(); /* ------------- */ } } }, error: function error() { $.hideIndicator(); // $.alert("请检查网络!"); }, }); return; } // 打开公告弹出渲染 function openNoticeHtml() { var _this = this; var list = this.list; var point_html = ''; for (var index = list.length - 1; index >= 0; index--) { if (index || index === 0) { var popupHTML = '' + this.count + '
' : ''); $('#page-index6 .notice-view').html(notice_view); } /* ------------- */ function handleNoticeStatus(id) { var _this = this; var token = user.token; $.ajax({ type: 'GET', url: '../api/dishes/get_notice', dataType: 'json', data: { token: token, notice_id: id, }, success: function (res) { if (res.status == 1) { _this.count--; _this.renderIndex(); } }, error: function () { $.hideIndicator(); $.alert('请检查网络!'); }, }); } initPage(); if (!user.cellphone2) { $.alert( '云中美食即将启用短信验证码登录,请先绑定手机号', '温馨提示', function () { $.router.loadPage('bindCellphone.html'); } ); } function setHeight() { $('.main .cp-list').height( $(window).height() - $('.bar-tab').innerHeight() - $('header').innerHeight() ); $('.main .cs-list').height( $(window).height() - $('.bar-tab').innerHeight() - $('header').innerHeight() ); } function initPage() { var pid = $.getURLParameter('pid'); var did = $.getURLParameter('did'); //高度撑开 //var user = $.parseJSON($.cookie("user")); setHeight(); indexNotice.showNotice(); getData(pid, did); } function innerData(data) { beginTime = new Date().getTime(); dining_hall_id = data.dining_hall_id; // date_id = data.date_id; //初始化title与页面标题 $('title').html(data.title); $(page).find('.title').html('饭堂用餐'); //实时取餐码 //这里接口处理不标准,增加一个判断 data.take_info===null||data.take_info.take_qrcode===null $(page) .find('.open-mypopover') .attr( 'data-url', data.take_info === null || data.take_info.take_qrcode === null ? ' ' : data.take_info.take_qrcode ); $(page) .find('.open-mypopover') .attr( 'data-name', data.take_info === null || data.take_info.take_qrcode === null ? ' ' : data.take_info.meal_text ); $(page) .find('.open-mypopover') .attr( 'data-num', data.take_info === null || data.take_info.take_qrcode === null ? ' ' : data.take_info.take_code ); $(page) .find('.open-mypopover') .attr( 'data-order_detail', data.take_info === null || data.take_info.take_qrcode === null ? ' ' : JSON.stringify(data.take_info.order_detail) ); $('.userinfo .ye').html(data.user.account); $('.userinfo .jf').html(data.user.jf); $('.userinfo .srjf').html(data.user.srjf); if(data.user.company_id == 58){ $('.userinfo .jf_txt').text('总积分'); } $(page).find('.title').removeAttr('data-type'); $(page).find('.title').attr('data-type', 'changeDate'); $(page).find('input[name=changeDate]').remove(); // if (parseInt(date_id) > 0) { // $(page) // .find('.title') // .after( // '' // ); // } if (data.user.company_id == '34') { $('.company-tips').show(); } else { $('.company-tips').hide(); } var jcdataName = []; var jcdataValue = []; var myFtName = ''; // if (data.jcdata && data.jcdata.length > 0) { // $.each(data.jcdata, function (i, date) { // if ( // parseInt(user.dining_hall_id) === parseInt(date.jcplace.id) && // date.jcdate.length > 0 // ) { // $.each(date.jcdate, function (i, meal) { // jcdataName.push(meal.datename); // jcdataValue.push(date.jcplace.id + '-' + meal.meal_list[0].id); // }); // jcdataName = JSON.parse(JSON.stringify(jcdataName)); // jcdataValue = JSON.parse(JSON.stringify(jcdataValue)); // $(page) // .find('input[name=changeDate]') // .picker({ // toolbarTemplate: // '暂无菜式
' ); } else { var tab_html = ' ' + '暂无菜式
'; look_date = look_date ? look_date : '暂无菜式
'; $('#page-index6 .cs-list #tab-list-order').html(cs_date); $('#page-index6 .cs-list #tab-list-look').html(look_date); } checkXhlBtn(); //初始化菜品 var cp_li = ''; var jcdata = data.jcdata; $.each(jcdata.jcmeal, function (k, cp) { cp.active = k == data.date ? 'active' : ''; cp.cpnum = parseInt(cp.cart_num) ? cp.cart_num : ''; cp_li += '' + ret.data.name + '
' + '' + '扫二维码进行支付操作
' + '' + num + '
' + '' + '扫二维码或按小键盘输入取餐码进行取餐
' + '该服务需要申请使用以下权限:
', text: '相机权限:用于扫码时使用。
仅用于饭堂扫码用,如您不同意请不要进行后续操作。
', buttons: [{ text: '拒绝', onClick: function (){ // localStorage.setItem('camera_scan', false); // localStorage.setItem('camera_photo', false); // localStorage.setItem('write_storage_photo', false); // localStorage.setItem('write_storage_data', false); // localStorage.setItem('photo_data', false); } },{ text: '同意', onClick: function (){ localStorage.setItem('camera_scan', true); window.androidJs.startScan(); // localStorage.setItem('camera_photo', true); // localStorage.setItem('write_storage_photo', true); // localStorage.setItem('write_storage_data', true); // localStorage.setItem('photo_data', true); } }] }); } } catch (e) {} } else if (typeof window.webkit !== 'undefined') { try { // ios QRScannerOpen(); } catch (e) {} } else { // $.alert('请使用App操作'); } }); } } else { $.alert('页面已过期,将刷新', function () { getData(); }); } }); $(page).on('click', '.order-open-btn', function () { var get_date_id = $(this).next().data('id'); var el = $(this).next().hasClass('card-look') ? '.card-look-' + get_date_id : '.card-order-' + get_date_id; var _this = this; if (!$(page).find(el).is(':animated')) { $(page).find(el).slideToggle('slow'); $(_this).find('.icon').hasClass('icon-prev') ? $(_this).find('.icon').removeClass('icon-prev') : $(_this).find('.icon').addClass('icon-prev'); } }); }); $(document).on('pageInit', '#page-index5', function (e, pageId, page) { var beginTime = 0; var user = $.parseJSON($.caesarCache('user') ? $.caesarCache('user') : null); var rise_tips = false; var dining_hall_id; var date_id; var totalNum = 0; var totalPrice = 0; var dining_halls = ''; var user_birthMsg = ''; var indexNotice = { list: [], count: 0, }; if (user && $('.noticeNum').find('a').hasClass('noticeList')) { $('.noticeNum').find('a').removeClass('noticeList'); $('.noticeNum').find('a').addClass('noticeList2'); } if ( user && user.hasOwnProperty('theme') && user.theme && user.theme != '5' ) { $.router.replacePage(initTheme(user.theme)); return; } if (user && (user.company_id == '42' || user.company_id == '58')) { $('.changeFt').parent('p').hide(); } function showBirth() { var birth_img = 0; $.ajax({ type: 'GET', url: '../api/birthdayimg/list?token=' + user.token, success: function success(ret) { if (typeof ret.status !== 'undefined') { $.closePanel(); if (ret.status === -1) { $.closePanel(); setTimeout(function () { location.href = 'login.php'; }, 200); return; } else if (ret.status === 1) { // 渲染生日图片 birth_img = ret.data.list.length; for (var index = ret.data.list.length - 1; index >= 0; index--) { if (index || index === 0) { var src = ret.data.list[index].img_resize; var popupHTML = '暂无菜式
' ); } else { var tab_html = ' ' + '暂无菜式
'; look_date = look_date ? look_date : '暂无菜式
'; $('#page-index5 .cs-list #tab-list-order').html(cs_date); } checkXhlBtn(); //初始化菜品 var cp_li = ''; var gdj_jcdata = data.meal_list; $.each(gdj_jcdata, function (k, cp) { cp.active = cp.id == data.now_meal_id ? 'active' : ''; cp.cpnum = parseInt(cp.cart_num) ? cp.cart_num : ''; cp_li += '' + ret.data.name + '
' + '' + '扫二维码进行支付操作
' + '' + num + '
' + '' + '扫二维码或按小键盘输入取餐码进行取餐
' + '" + meal_time[i] + '
暂无菜式
'; $('#page-index3 .cs-list .list-block').html(cs_li); //初始化footer totalPrice = parseFloat(data.order.price); totalNum = parseInt(data.order.num); $('#page-index3 .total-num').html(totalNum ? totalNum : ''); $('#page-index3 .total-price').html(totalPrice ? totalPrice : 0); checkXhlBtn(); //初始化菜品 var cp_li = ''; if (data.jcdata.length > 0) { $.each(data.jcdata, function (i, jcdata) { if (parseInt(user.dining_hall_id) === parseInt(jcdata.jcplace.id)) { $.each(jcdata.jctime, function (j, time) { if (time.datename === data.page) { $.each(time.meal_list, function (k, cp) { cp.active = parseInt(cp.active) ? 'active' : ''; cp.cpnum = parseInt(cp.cart_num) ? cp.cart_num : ''; cp_li += '暂无菜式
'; $('#page-index3 .cs-list .list-block').html(cs_li); } function renderOederData(data) { var cs_li = ''; $.each(data.cs, function (i, cs) { var addClass = parseInt(cs.csnum) >= parseInt(cs.limit) ? 'style="opacity: 0;"' : ''; var minusClass = parseInt(cs.csnum) <= 0 ? 'style="display: none;"' : ''; cs.rest_num = parseInt(cs.rest_num) >= 0 ? cs.rest_num : '999+'; //fix 汕头 cs.total_max_num = parseInt(cs.total_max_num) == -1 ? '0' : parseInt(cs.total_max_num) > 0 ? cs.total_max_num : '999+'; var kc = '剩' + cs.rest_num + '/' + cs.total_max_num; cs.csnum = cs.csnum ? cs.csnum : ''; var init_str = ''; var add_str = '暂无菜式
'; $('#page-index3 .cs-list .list-block').html(cs_li); } function printReload(self, num, limit, price, type) { var thisCpNum = $('.cp .active .badge').html() ? parseInt($('.cp .active .badge').html()) : 0; if (type === 'add') { num++; totalNum++; totalPrice = $.accAdd(totalPrice, price); thisCpNum++; } else if (type === 'minus') { num--; totalNum--; thisCpNum--; totalPrice = $.Subtr(totalPrice, price); } else { } $('.cp .active .badge').html(thisCpNum <= 0 ? '' : thisCpNum); $('.total-num').html(totalNum ? totalNum : ''); $('.total-price').html(totalPrice); self .parent('p') .children('.num') .html(num <= 0 ? '' : num); if (num <= 0) { self.parent('p').children('.minus').css('display', 'none'); self.parent('p').children('.add').css('opacity', 1); } else if (num > 0 && num < limit) { self.parent('p').children('.minus').css('display', 'block'); self.parent('p').children('.add').css('opacity', 1); } else if (num >= limit) { self.parent('p').children('.minus').css('display', 'block'); self.parent('p').children('.add').css('opacity', 0); } checkXhlBtn(); return num; } function checkXhlBtn() { if (!$(page).find('.xhl').hasClass('btnDisabled') && totalNum === 0) { $(page).find('.xhl').addClass('btnDisabled'); } else if ( totalNum !== 0 && $(page).find('.xhl').hasClass('btnDisabled') ) { $(page).find('.xhl').removeClass('btnDisabled'); } } function changeFt(pid) { pid = parseInt(pid); var token = user.token; $.showIndicator(); $.ajax({ type: 'POST', url: '../api/user/alter/', dataType: 'json', data: { token: token, dining_hall_id: pid, }, success: function success(ret) { $.hideIndicator(); if (typeof ret.status !== 'undefined') { $.closePanel(); if (ret.status === -1) { $.closePanel(); setTimeout(function () { location.href = 'login.php'; }, 200); return; } else if (ret.status === 1) { user = ret.data.user; $.caesarCache('user', JSON.stringify(ret.data.user), { expires: 365 * 10, }); if (meal_func !== 'meal-order') getVoteData(); else getData(); } $.alert(ret.message); } }, error: function error() { $.hideIndicator(); $.alert('请检查网络!'); }, }); } function getData(pid, did, dish_type) { //cookie不存在 date_click_id = did; if (user === null) { $.closePanel(); setTimeout(function () { location.href = 'login.php'; }, 200); return false; } setTimeout(function () { $.showIndicator(); }, 0); var token = user.token; $.ajax({ type: 'GET', url: '../api/dishes/index2', dataType: 'json', data: { token: token, dining_hall_id: pid, date_id: did, dish_type: dish_type, }, timeout: 3 * 1000, success: function success(ret) { setTimeout(function () { $.hideIndicator(); }, 0); if (typeof ret.status !== 'undefined') { if (ret.status === 1) { if(ret.data.user.init_pass_modify_time === null || ret.data.user.init_pass_modify_time === ''){ // 提示去修改密码 $.modal({ text: "欢迎使用“云中美食”,首次登陆请修改初始密码。", buttons: [{ text: '修改密码', onClick: function (){ $.router.replacePage('changePwd.html'); } }] }) } var times = $.cookie('getTimes') ? $.cookie('getTimes') : 0; if ( ret.data.user['jtj_adminInfo'] && (ret.data.user['jtj_adminInfo'].role == '11' || ret.data.user['jtj_adminInfo'].role == '12' || ret.data.user['jtj_adminInfo'].role == '13') ) { window.location.href = '/jtj_admin/?act=login&token=' + token; return; } else if ( (!times || times < 1) && ret.data.user['jtj_adminInfo'] && ret.data.user['jtj_adminInfo'].role == '14' ) { times++; var cookie_date = new Date(); cookie_date.setTime(cookie_date.getTime() + 5 * 60 * 1000); $.cookie('getTimes', times, { expires: cookie_date, }); window.location.href = '/jtj_admin/?act=login&token=' + token; return; } if (ret.data.user.need_submit_birth == '1') { $.router.replacePage('setBirthday.html'); } else { // if (ret.data.birthMsg) { // // 查看cookie // user_birthMsg = ret.data.birthMsg; // var now_date = // new Date().getDate() >= 10 // ? new Date().getDate() // : '0' + new Date().getDate(); // // 判读是否今天生日----如果是则会在关闭弹窗时弹出生日订餐提示 // if ( // 1 || // (user && // user.birthday && // user.birthday == // new Date().getMonth() + 1 + '-' + now_date) // ) { // var hbTimes = $.cookie('getHBTimes') // ? $.cookie('getHBTimes') // : 0; // if (hbTimes <= 0) { // hbTimes++; // $.cookie('getHBTimes', hbTimes, { // expires: 1, // }); // $.closePanel(); // $.closeModal(); // showBirth(); // } // } else { // ////不弹出 // // var birth_tips_json = $.parseJSON( // // $.cookie('birth_tips') ? $.cookie('birth_tips') : null // // ); // // if ( // // birth_tips_json == null || // // birth_tips_json.is_show != true // // ) { // // $.alert(user_birthMsg, function () { // // // 确认后,设置cookie // // var cookie_date = new Date(); // // cookie_date.setTime( // // cookie_date.getTime() + 3 * 60 * 1000 // // ); // 3分钟 // // $.cookie( // // 'birth_tips', // // JSON.stringify({ is_show: true }), // // { expires: cookie_date } // // ); // // }); // // } // } // } $(page).find('.col-day-menu').hide(); $(page).find('.col-meal').hide(); $(page).find('header').css({ height: '2.2rem', }); $(page).find('.content').css({ top: '2.2rem', }); innerData(ret.data); // 记录长度进行判断 // if (count === 0 || count !== ret.data.jcdata[0].jctime.length) { // meal_meanu(ret.data.jcdata); // count = ret.data.jcdata[0].jctime ? ret.data.jcdata[0].jctime.length : null; // } $.caesarCache('user', JSON.stringify(ret.data.user), { expires: 365 * 10, }); } } else if (ret.status === -1) { $.closePanel(); $.closeModal(); setTimeout(function () { location.href = 'login.php'; }, 200); return; } else { meal_func = 'meal-vote'; getVoteData(); $.alert(ret.message); } } }, error: function error() { meal_func = 'meal-vote'; // getVoteData(); $.hideIndicator(); $.alert('请检查网络!'); }, }); } function getVoteData(pid, did, vid, dtid, dish_type) { pid = dining_hall_id; //cookie不存在 date_click_id = did; vdid = vid; if (user === null) { $.closePanel(); setTimeout(function () { location.href = 'login.php'; }, 200); return false; } setTimeout(function () { $.showIndicator(); }, 0); var token = user.token; $.ajax({ type: 'GET', url: '../api/dishvote/list', dataType: 'json', data: { token: token, dining_hall_id: pid, vote_date_id: vid, date: did, dish_type: dish_type, dc_type: dtid, }, success: function success(ret) { setTimeout(function () { $.hideIndicator(); }, 0); if (typeof ret.status !== 'undefined') { if (ret.status === 1) { innerVoteData(ret.data); if (count === 0 || count !== ret.data.jcdata[0].jctime.length) { $(page).find('.col-day-menu').show(); $(page).find('.col-meal').show(); meal_meanu(ret.data.jcdata, { hid: ret.data.dining_hall_id, date: ret.data.date, dtype: ret.data.dc_type, }); for (var i = 0; i < ret.data.jcdata.length; i++) { if ( ret.data.jcdata[i].jcplace.id == ret.data.dining_hall_id ) { count = ret.data.jcdata[i].jctime.length; break; } } } $.caesarCache('user', JSON.stringify(ret.data.user), { expires: 365 * 10, }); } else if (ret.status === -1) { $.closePanel(); $.closeModal(); setTimeout(function () { location.href = 'login.php'; }, 200); return; } else { meal_func = 'meal-order'; getData(); $.alert(ret.message); return; } } }, error: function error() { meal_func = 'meal-order'; // getData(); $.hideIndicator(); $.alert('请检查网络!'); }, }); } function payResult(recharge, action_text) { var payIcon = ''; var payTips = '' + ret.data.name + '
' + '' + '扫二维码进行支付操作
' + '' + num + '
' + '' + '扫二维码或按小键盘输入取餐码进行取餐
' + '暂无菜式
'; $('#page-index2 .cs-list .list-block').html(cs_li); //初始化footer totalPrice = parseFloat(data.order.price); totalNum = parseInt(data.order.num); $('#page-index2 .total-num').html(totalNum ? totalNum : ''); $('#page-index2 .total-price').html(totalPrice ? totalPrice : 0); checkXhlBtn(); //初始化菜品 var cp_li = ''; $.each(data.cp, function (i, cp) { cp.cpactive = cp.cpactive ? cp.cpactive : ''; cp.cpnum = cp.cpnum ? cp.cpnum : ''; cp_li += '' + ret.data.name + '
' + '' + '扫二维码进行支付操作
' + '' + num + '
' + '' + '扫二维码或按小键盘输入取餐码进行取餐
' + '暂无菜式
'; $('#page-index .cs-list .list-block').html(cs_li); //初始化footer totalPrice = parseFloat(data.order.price); totalNum = parseInt(data.order.num); $('#page-index .total-num').html(totalNum ? totalNum : ''); $('#page-index .total-price').html(totalPrice ? totalPrice : 0); checkXhlBtn(); //初始化菜品 var cp_li = ''; if (data.jcdata.length > 0) { $.each(data.jcdata, function (i, jcdata) { if (parseInt(user.dining_hall_id) === parseInt(jcdata.jcplace.id)) { $.each(jcdata.jctime, function (j, time) { if (time.datename === data.page) { $.each(time.meal_list, function (k, cp) { cp.active = parseInt(cp.active) ? 'active' : ''; cp.cpnum = parseInt(cp.cart_num) ? cp.cart_num : ''; cp_li += '' + ret.data.name + '
' + '' + '扫二维码进行支付操作
' + '取餐号:"+serial_num+"
"; } var popupHTML = '' + num + '
' + '' + serial_num_html + '扫二维码或按小键盘输入取餐码进行取餐
' + '' + cs.dish_name + '
' + (user.theme === '3' ? '' : '' + cs.price + '元/份
') + '' + meal.rise_info.rise_tip + '
备注:
你的订单为空,赶紧点餐吧!
你的订单为空,赶紧点餐吧!
订单编号:' + order.code + '
取消时间:' + order.cancel_time + '
取餐号:"+serial_num+"
"; } var popupHTML = '' + num + '
' + '' + serial_num_html + '扫二维码或按小键盘输入取餐码进行取餐
' + '订单编号:' + order.code + '
取消时间:' + order.cancel_time + '
上传图片
上传图片
' + num + '
' + '' + '扫二维码或按小键盘输入取餐码进行取餐
' + '订单编号:' + order.code + '
取消时间:' + order.cancel_time + '
' + num + '
' + '' + '扫二维码或按小键盘输入取餐码进行取餐
' + '订单编号:' + order.code + '
下单时间:' + order.create_time + '
取消时间:' + order.cancel_time + '
' + order.total_num + '份菜品
¥' + order.total_price + '
暂无记录
' : cardHtml ); if (parseInt(data.order_total_page) <= parseInt(pageNum)) { $.detachInfiniteScroll($(page).find('.infinite-scroll')); } loading = false; } function getData(page) { if (user === null) { location.href = 'login.php'; return; } var token = user.token; $.ajax({ type: 'GET', url: '../api/order/list/', dataType: 'json', data: { token: token, page: page, }, success: function (ret) { if (typeof ret.status !== 'undefined') { if (ret.status === 1) { innerData(ret.data); } else if (ret.status === -1) { location.href = 'login.php'; return; } else { $.alert(ret.message); } } }, error: function () { $.alert('请检查网络!'); }, }); } $(page).on('click', '.qc', function () { var url = $(this).data('url'); var name = $(this).data('name'); var num = $(this).data('num'); var serial_num = $(this).data('serial-num'); var serial_num_html = ""; if(serial_num != '' && serial_num != undefined){ serial_num_html = "取餐号:"+serial_num+"
"; } var popupHTML = '' + num + '
' + '' + serial_num_html + '扫二维码或按小键盘输入取餐码进行取餐
' + '暂无记录
' : cardHtml; //要是第一页,先清空内容 //要是第一页,先清空内容 if (parseInt(pageNum) === 1) { $(page).find('.bills-list').empty(); } $(page).find('.bills-list').append(cardHtml); if (parseInt(data.recharge_total_page) <= parseInt(pageNum)) { $.detachInfiniteScroll($(page).find('.infinite-scroll')); } loading = false; } $(page).on('click', '.choose', function () { if ($(this).hasClass('active')) { return false; } $(this).siblings().removeClass('active'); $(this).addClass('active'); pageNum = 1; getData(pageNum); }); function getData(p) { if (user === null) { location.href = 'login.php'; return; } var token = user.token; var gettype = $(page).find('.gettype').children('.active').data('type'); var type_id = parseInt( $(page).find('.type_id').children('.active').data('typeid') ); setTimeout(function () { $.showIndicator(); }, 0); $.ajax({ type: 'GET', url: '../api/recharge/list/', dataType: 'json', data: { token: token, page: p, size: 15, gettype: gettype, type_id: type_id, }, success: function (ret) { setTimeout(function () { $.hideIndicator(); }, 0); if (typeof ret.status !== 'undefined') { if (ret.status === 1) { innerData(ret.data); //对充值成功回调时候处理 //reFreshMenu(ret.data.user); $.caesarCache('user', JSON.stringify(ret.data.user), { expires: 365 * 10, }); } else if (ret.status === -1) { location.href = 'login.php'; return; } else { $.alert(ret.message); } } }, error: function () { setTimeout(function () { $.hideIndicator(); }, 0); $.alert('请检查网络!'); }, }); } }); $(document).on('pageInit', '#page-recharge', function (e, pageId, page) { var user = $.parseJSON($.caesarCache('user') ? $.caesarCache('user') : null); var wxuser = /micromessenger/.test(navigator.userAgent.toLowerCase()) ? true : false; var initCode = $.getURLParameter('code') ? $.getURLParameter('code') : ''; var max_recharge_amount = ''; initPage(); function initPage() { if (user === null) { location.href = 'login.php'; return; } getData(); } function innerData(data) { max_recharge_amount = data.allow_max_recharge_value; $.alert(data.recharge_tips); $('title').html(data.title); $(page).find('.title').html(data.page); var czHtml = ''; $.each(data.recharge_allow_values, function (idx, val) { czHtml += ''; }); if (data.custom_recharge == 1) { // 自定义金额 czHtml += ''; } var allow_pay = data.allow_pay.join(','); if (allow_pay.indexOf('wx') === -1) { $(page).find('.submit_wx').hide(); } else { //$(page).find('.submit_yzf').show(); } if (allow_pay.indexOf('yzf') === -1) { $(page).find('.submit_yzf').hide(); } else { //$(page).find('.submit_wx').show(); } $(page).find('.content ul').html(czHtml); if (initCode) { $.modal({ title: '请确认支付是否已经完成', text: '', verticalButtons: true, buttons: [ { text: '已完成支付', onClick: function () { requestWxPayRe(initCode); }, }, { text: '支付遇到问题,重新支付', onClick: function () { $.closeModal(); getData(); }, }, { text: '放弃支付', onClick: function () { $.closeModal(); }, }, ], }); } } function getData() { var token = user.token; $.showIndicator(); $.ajax({ type: 'GET', url: '../api/user/info/', dataType: 'json', data: { token: token, }, success: function (ret) { $.hideIndicator(); if (typeof ret.status !== 'undefined') { if (ret.status === 1) { innerData(ret.data); } else if (ret.status === -1) { location.href = 'login.php'; return; } else { $.alert(ret.message); } } }, error: function () { $.hideIndicator(); $.alert('请检查网络!'); }, }); } // 点击自定义金额触发 (yw) $(page).on('click', '.list-block li label input', function () { var _this = $(this); var choice_inp = _this.val(); if (choice_inp == 'custom') { // 选择了自定义金额 $("input[name='custom_recharge']").remove(); $('.custom').append( '' ); } else { // 删除自定义金额 input $("input[name='custom_recharge']").remove(); } }); function requestWxPayRe(code) { //var token = user.token; $.showIndicator(); $.ajax({ type: 'GET', url: '../show/get.php', dataType: 'json', data: { act: 'get_wxpay_status', code: code, }, success: function (ret) { if (typeof ret.status !== 'undefined') { $.hideIndicator(); if (ret.status === 1) { //$.showIndicator(); //支付成功 $.router.loadPage('bills.html'); } else if (ret.status === 0) { $.modal({ title: '暂未收到支付结果', text: '', verticalButtons: true, buttons: [ { text: '再次查询', onClick: function () { requestWxPayRe(code); }, }, { text: '放弃查询', onClick: function () { $.closeModal(); }, }, ], }); //setTimeout(requestWxPayRe(code),2000); //轮询 } } else { $.hideIndicator(); $.alert('请求出错'); } }, error: function () { $.hideIndicator(); $.alert('请检查网络!'); }, }); } $(page).on('click', '.submit_wx', function () { var value = $('input[name=value]:checked').val(); if (value == 'custom') { value = $('.custom_recharge').val(); if (parseFloat(value) > max_recharge_amount) { $.alert('最大充值金额为 ' + max_recharge_amount + ' 元'); return false; } else if (parseInt(value) <= 0) { $.alert('充值金额不少于1元'); return false; } } else { if (!value) { $.alert('请选择充值金额'); return; } } //var ispc = 0; var token = user.token; $.showIndicator(); //增加微信判断 $.ajax({ type: 'GET', url: '../show/get.php', dataType: 'json', data: { token: token, total_fee: value, act: 'wxpay_unifiedorder', type: wxuser ? 'qr' : '', }, success: function (ret) { $.hideIndicator(); if (typeof ret.status !== 'undefined') { if (ret.status === 1) { //$.showIndicator(); //requestWxPayRe(ret.data.code); if (wxuser) { //微信端发起 location.href = ret.data.mweb_url; return true; //end of wx } else if (typeof iosJs !== 'undefined') { try { //alert(decodeURIComponent(ret.data.mweb_url)); iosJs.openInSafari( 'https://' + window.location.host + '/m/wx.html?beginurl=' + encodeURIComponent(decodeURIComponent(ret.data.mweb_url)) ); } catch (e) {} } else if (typeof androidJs !== 'undefined') { try { //alert(decodeURIComponent(ret.data.mweb_url)); androidJs.openAndroidWebview( 'https://' + window.location.host + '/m/wx.html?beginurl=' + encodeURIComponent(decodeURIComponent(ret.data.mweb_url)) ); } catch (e) {} } else if (typeof window.webkit !== 'undefined') { // 2019-11-06 yw try { promptOpenInSafari( 'https://' + window.location.host + '/m/wx.html?beginurl=' + encodeURIComponent(decodeURIComponent(ret.data.mweb_url)) ); } catch (e) {} } else { location.href = ret.data.mweb_url; return true; } $.modal({ title: '请确认支付是否已经完成', text: '', verticalButtons: true, buttons: [ { text: '已完成支付', onClick: function () { requestWxPayRe(ret.data.code); }, }, { text: '支付遇到问题,重新支付', onClick: function () { $.closeModal(); getData(); }, }, { text: '放弃支付', onClick: function () { $.closeModal(); }, }, ], }); //requestWxPayRe(ret.data.code); } else if (ret.status === -1) { location.href = 'login.php'; return; } else { $.alert(ret.message); } } }, error: function () { $.hideIndicator(); $.alert('请检查网络!'); }, }); }); $(page).on('click', '.submit_yzf', function () { var value = $('input[name=value]:checked').val(); if (value == 'custom') value = $('input[name=custom_recharge]').val(); if (!value) { $.alert('请选择充值金额'); return; } var ispc = 0; var token = user.token; $.showIndicator(); $.ajax({ type: 'POST', url: '../api/recharge/', dataType: 'json', data: { token: token, value: value, ispc: ispc, }, success: function (ret) { $.hideIndicator(); if (typeof ret.status !== 'undefined') { if (ret.status === 1) { $.showIndicator(); location.href = decodeURIComponent(ret.data.url); } else if (ret.status === -1) { location.href = 'login.php'; return; } else { $.alert(ret.message); } } }, error: function () { $.hideIndicator(); $.alert('请检查网络!'); }, }); }); }); $(document).on('pageInit', '#page-transfer', function (e, pageId, page) { var user = $.parseJSON($.caesarCache('user') ? $.caesarCache('user') : null); initPage(); function initPage() { if (user === null) { location.href = 'login.php'; return; } getData(); } function innerData(data) { //$.alert(data.recharge_tips); $('title').html(data.title); $(page).find('.title').html(data.page); //$('input[name=zy_amount]').attr('placeholder', "剩余" + data.user.jf + "积分,金额" + data.user.account + "元"); $(page) .find('.userinfo .zh') .html('帐号:' + data.user.smsCellphone); $(page) .find('.userinfo .hz') .html('姓名:' + data.user.username); $(page) .find('.userinfo .ye') .html('余额:' + data.total + '元'); //$('.userinfo .jf').html('积分:' + data.user.jf); var acList = data.acList; for (var key in acList) { //alert(key+" = "+acList[key]); var info = acList[key]; var op = new Option( '余额' + info.amount + '元(' + info.supplier_name + ')', key ); var select = $(page).find('select[name=accountId]')[0]; select.options.add(op); } } function setitv() { var countTime = null; var t = 30; countTime = setInterval(function () { if (t === 0) { $(page).find('.yzm').html('发送'); $(page).find('.yzm').removeAttr('disabled'); clearInterval(countTime); return; } $(page) .find('.yzm') .html(t + '秒'); t--; }, 1000); } $(page).on('click', '.yzm', function () { var token = user.token; $.showIndicator(); $.ajax({ type: 'POST', url: '../api/recharge/yezy_yzm', dataType: 'json', data: { token: token, }, success: function (ret) { $.hideIndicator(); if (typeof ret.status !== 'undefined') { if (ret.status === 1) { setitv(); $(page).find('.yzm').attr('disabled', true); //短信验证码倒计时 } else if (ret.status === -1) { location.href = 'login.php'; return; } else { $.alert(ret.message); } } }, error: function () { $.hideIndicator(); $.alert('请检查网络!'); }, }); }); function getData() { var token = user.token; $.showIndicator(); $.ajax({ type: 'GET', url: '../api/recharge/yezypage', dataType: 'json', data: { token: token, }, success: function (ret) { $.hideIndicator(); if (typeof ret.status !== 'undefined') { if (ret.status === 1) { innerData(ret.data); } else if (ret.status === -1) { location.href = 'login.php'; return; } else { $.alert(ret.message); } } }, error: function () { $.hideIndicator(); $.alert('请检查网络!'); }, }); } function checkItem() { if ($(page).find('input[name=mypass]').val() === '') { $.alert('登陆密码不能为空'); return false; } else if ( !new RegExp(/[A-Za-z0-9]{1,16}$/).test( $(page).find('input[name=yzm]').val() ) ) { $.alert('验证码不能为空'); return false; } else if ( !new RegExp(/^1\d{10}$/).test( $(page).find('input[name=to_user_phone]').val() ) ) { $.alert('转移的号码不正确'); return false; } else if ( !new RegExp(/^[0-9]\d*(?:\.\d{1,2}|\d*)$/).test( $(page).find('input[name=zy_amount]').val() ) ) { $.alert('输入的金额不正确'); return false; } else if ($(page).find('select[name=accountId]').val() == '') { $.alert('请选择要转出的账户'); return false; } else { return true; } } $(page).on('click', '.submit', function () { if (checkItem()) { var token = user.token; var mypass = $.trim($(page).find('input[name=mypass]').val()); var yzm = $.trim($(page).find('input[name=yzm]').val()); var to_user_phone = $.trim( $(page).find('input[name=to_user_phone]').val() ); var zy_amount = $.trim($(page).find('input[name=zy_amount]').val()); var accountId = $.trim($(page).find('select[name=accountId]').val()); $.showIndicator(); $.ajax({ type: 'POST', url: '../api/recharge/yezy', dataType: 'json', data: { token: token, mypass: md5(mypass), yzm: yzm, to_user_phone: to_user_phone, zy_amount: zy_amount, accountId: accountId, }, success: function (ret) { $.hideIndicator(); if (typeof ret.status !== 'undefined') { if (ret.status === 1) { $.router.loadPage('bills.html'); } else if (ret.status === -1) { location.href = 'login.php'; return; } else { $.alert(ret.message); } } }, error: function () { $.hideIndicator(); $.alert('请检查网络!'); }, }); } }); }); $(document).on( 'pageInit', '#page-transfer-internal', function (e, pageId, page) { var user = $.parseJSON($.caesarCache('user') ? $.caesarCache('user') : null); initPage(); function initPage() { if (user === null) { location.href = 'login.php'; return; } getData(); } function innerData(data) { //$.alert(data.recharge_tips); $('title').html(data.title); $(page).find('.title').html(data.page); //$('input[name=zy_amount]').attr('placeholder', "剩余" + data.user.jf + "积分,金额" + data.user.account + "元"); $(page) .find('.userinfo .zh') .html('帐号:' + data.user.smsCellphone); $(page) .find('.userinfo .hz') .html('姓名:' + data.user.username); $(page) .find('.userinfo .ye') .html('余额:' + data.zy_total + '元'); //$('.userinfo .jf').html('积分:' + data.user.jf); var zyList = data.zyList; var zyToList = data.zyToList; for (var key in zyList) { var info = zyList[key]; var op = new Option('余额' + info.amount + '元(积分1)', key); var select = $(page).find('select[name=accountId]')[0]; select.options.add(op); } var toUserAccount = $(page).find('select[name=toUserAccountId]')[0]; if(zyToList){ for (var key in zyToList) { var info = zyToList[key]; var op = new Option( '余额' + info.amount + '元(积分2)', key ); toUserAccount.options.add(op); } }else{ var op = new Option( '余额0元(积分二)', '' ); toUserAccount.options.add(op); } } function setitv() { var countTime = null; var t = 30; countTime = setInterval(function () { if (t === 0) { $(page).find('.yzm').html('发送'); $(page).find('.yzm').removeAttr('disabled'); clearInterval(countTime); return; } $(page) .find('.yzm') .html(t + '秒'); t--; }, 1000); } $(page).on('click', '.yzm', function () { var token = user.token; $.showIndicator(); $.ajax({ type: 'POST', url: '../api/recharge/yezy_yzm', dataType: 'json', data: { token: token, }, success: function (ret) { $.hideIndicator(); if (typeof ret.status !== 'undefined') { if (ret.status === 1) { setitv(); $(page).find('.yzm').attr('disabled', true); //短信验证码倒计时 } else if (ret.status === -1) { location.href = 'login.php'; return; } else { $.alert(ret.message); } } }, error: function () { $.hideIndicator(); $.alert('请检查网络!'); }, }); }); function getData() { var token = user.token; $.showIndicator(); $.ajax({ type: 'GET', url: '../api/recharge/yezypage', dataType: 'json', data: { token: token, }, success: function (ret) { $.hideIndicator(); if (typeof ret.status !== 'undefined') { if (ret.status === 1) { innerData(ret.data); } else if (ret.status === -1) { location.href = 'login.php'; return; } else { $.alert(ret.message); } } }, error: function () { $.hideIndicator(); $.alert('请检查网络!'); }, }); } function checkItem() { if ( !new RegExp(/[A-Za-z0-9]{1,16}$/).test( $(page).find('input[name=mypass]').val() ) ) { $.alert('登陆密码不能为空'); return false; } else if ( !new RegExp(/[A-Za-z0-9]{1,16}$/).test( $(page).find('input[name=yzm]').val() ) ) { $.alert('验证码不能为空'); return false; } else if ($(page).find('input[name=toUserAccountId]').val() == '') { $.alert('转移目标账户不能为空'); return false; } else if ( !new RegExp(/^[0-9]\d*(?:\.\d{1,2}|\d*)$/).test( $(page).find('input[name=zy_amount]').val() ) ) { $.alert('输入的金额不正确'); return false; } else if ($(page).find('select[name=accountId]').val() == '') { $.alert('请选择要转出的账户'); return false; } else { return true; } } $(page).on('click', '.submit', function () { if (checkItem()) { var token = user.token; var mypass = $.trim($(page).find('input[name=mypass]').val()); var yzm = $.trim($(page).find('input[name=yzm]').val()); // var to_user_phone = $.trim( // $(page).find('input[name=to_user_phone]').val() // ); var zy_amount = $.trim($(page).find('input[name=zy_amount]').val()); var toUserAccountId = $.trim( $(page).find('select[name=toUserAccountId]').val() ); var accountId = $.trim($(page).find('select[name=accountId]').val()); $.showIndicator(); $.ajax({ type: 'POST', url: '../api/recharge/zhyezy', dataType: 'json', data: { token: token, mypass: md5(mypass), yzm: yzm, toUserAccountId: toUserAccountId, zy_amount: zy_amount, accountId: accountId, }, success: function (ret) { $.hideIndicator(); if (typeof ret.status !== 'undefined') { if (ret.status === 1) { $.router.loadPage('bills.html'); } else if (ret.status === -1) { location.href = 'login.php'; return; } else { $.alert(ret.message); } } }, error: function () { $.hideIndicator(); $.alert('请检查网络!'); }, }); } }); } ); $(document).on('pageInit', '#page-findPwd', function (e, pageId, page) { $(page).on('click', '.submit', function () { var cellphone = $.trim($(page).find($('input[name=cellphone]')).val()); var yzm = $.trim($(page).find($('input[name=yzm]')).val()); var password = $.trim($(page).find($('input[name=cpw]')).val()); if (checkItem()) { $.showIndicator(); $.ajax({ type: 'GET', url: '../api/user/repass/', dataType: 'json', data: { cellphone: cellphone, newpass: md5(password), yzm: yzm, }, success: function (ret) { if (typeof ret.status !== 'undefined') { $.hideIndicator(); if (ret.status === 1) { $.alert(ret.message, function () { location.href = 'login.php'; }); } else if (ret.status === 0) { $.alert(ret.message); } } }, error: function () { $.hideIndicator(); $.alert('请检查网络!'); }, }); } }); function setitv() { var countTime = null; var t = 30; countTime = setInterval(function () { if (t === 0) { $(page).find($('.yzm')).html('发送'); $(page).find($('.yzm')).removeAttr('disabled'); clearInterval(countTime); return; } $(page) .find($('.yzm')) .html(t + '秒'); t--; }, 1000); } $(page).on('click', '.yzm', function () { if ( !new RegExp(/^1\d{10}$/).test( $(page).find($('input[name=cellphone]')).val() ) ) { $.alert('手机号码不正确'); return false; } var cellphone = $.trim($(page).find($('input[name=cellphone]')).val()); $.showIndicator(); $.ajax({ type: 'GET', url: '../api/user/repass_yzm/', dataType: 'json', data: { cellphone: cellphone, }, success: function (ret) { $.hideIndicator(); if (typeof ret.status !== 'undefined') { if (ret.status === 1) { setitv(); $(page).find($('.yzm')).attr('disabled', true); //短信验证码倒计时 } else { $.alert(ret.message); } } }, error: function () { $.hideIndicator(); $.alert('请检查网络!'); }, }); }); function checkItem() { if ( !new RegExp(/^1\d{10}$/).test( $(page).find($('input[name=cellphone]')).val() ) ) { $.alert('手机号码不正确'); return false; } else if ( !new RegExp(/[A-Za-z0-9]{1,16}$/).test( $(page).find($('input[name=yzm]')).val() ) ) { $.alert('验证码不能为空'); return false; } else if ( !new RegExp(/[A-Za-z0-9]{1,16}$/).test( $(page).find($('input[name=npw]')).val() ) ) { $.alert('密码不能为空'); return false; } else if ( !new RegExp(/[A-Za-z0-9]{1,16}$/).test( $(page).find($('input[name=cpw]')).val() ) ) { $.alert('密码不能为空'); return false; } else if ( $(page).find($('input[name=cpw]')).val() !== $(page).find($('input[name=npw]')).val() ) { $.alert('两次密码不一致'); return false; } else { return true; } } }); $(document).on('pageInit', '#page-bindCellphone', function (e, pageId, page) { var user = $.parseJSON($.caesarCache('user') ? $.caesarCache('user') : null); $(page).on('click', '.submit', function () { var cellphone = $.trim($(page).find($('input[name=cellphone]')).val()); var yzm = $.trim($(page).find($('input[name=yzm]')).val()); if (checkItem()) { $.showIndicator(); $.ajax2({ type: 'POST', url: '../api/user/update_cellphone2', dataType: 'json', data: { cellphone: cellphone, yzm: yzm, token: user.token }, success: function (res) { $.hideIndicator(); if (typeof res.status !== 'undefined') { if (res.status === 1) { $(page).find($('input[name=yzm]')).val(''); $(page).find($('input[name=cellphone]')).val(''); $.caesarCache('user', JSON.stringify(res.data.user), { expires: 365 * 10, }); $.alert(res.message); } else if (res.status === 0) { $.alert(res.message); } } }, error: function () { $.hideIndicator(); $.alert('请检查网络!'); }, }); } }); $(page).on('click', '.yzm', function () { var cellphone = $.trim($(page).find($('input[name=cellphone]')).val()); if (!/^1[3456789]\d{9}$/.test(cellphone)) { $.alert('手机号码不正确'); return false; } $.showIndicator(); $.ajax2({ type: 'POST', url: '../api/user/send_yzmphone/', dataType: 'json', data: { cellphone: cellphone, token: user.token }, success: function (res) { $.hideIndicator(); if (typeof res.status !== 'undefined') { if (res.status === 1) { setitv(); $(page).find($('.yzm')).attr('disabled', true); //短信验证码倒计时 } $.alert(res.message); } }, error: function () { $.hideIndicator(); $.alert('请检查网络!'); }, }); }); function setitv() { var countTime = null; var t = 60; countTime = setInterval(function () { if (t === 0) { $(page).find($('.yzm')).html('发送'); $(page).find($('.yzm')).removeAttr('disabled'); clearInterval(countTime); return; } $(page) .find($('.yzm')) .html(t + '秒'); t--; }, 1000); } function checkItem() { if (!new RegExp(/^1\d{10}$/).test($(page).find($('input[name=cellphone]')).val())) { $.alert('手机号码不正确'); return false; } else if (!new RegExp(/[A-Za-z0-9]{1,16}$/).test($(page).find($('input[name=yzm]')).val())) { $.alert('验证码不能为空'); return false; } else { return true; } } }); // $(document).on("pageInit", "#page-login", function (e, pageId, page) { // initPage(); // //fix android 2.0 4.2 switch bug // if ($.device.android && $.compareVersion('4.4', $.device.osVersion)) { // $(page).on('click', '.checkbox', function (e) { // e.preventDefault(); // if (!$(page).find($('input[name=remember]')).prop("disabled")) { // $(page).find($('input[name=remember]')).prop("disabled", true); // setTimeout(function () { // $(page).find($('input[name=remember]')).prop("disabled", false); // }, 400); // $(page).find($('input[name=remember]')).prop("checked", $(page).find($('input[name=remember]')).prop("checked") ? false : true); // } // }); // } // $(page).on('submit', 'form', function () { // e.preventDefault(); // var cellphone = $.trim($(page).find($('input[name=cellphone]')).val()); // var password = $.trim($(page).find($('input[name=password]')).val()); // if (checkItem()) { // $.showIndicator(); // $.ajax({ // type: 'POST', // url: '../api/user/login/', // dataType: 'json', // data: { // cellphone: cellphone, // password: md5(password) // }, // success: function (ret) { // if (typeof ret.status !== "undefined") { // $.hideIndicator(); // if (ret.status === 1) { // if (ret.data.type_id === "4") { // $.alert("公务账号不允许登录手机"); // } else { // if ($(page).find($('input[name=remember]')).prop("checked")) { // $.cookie("remember", true, { // expires: 365 * 10 // }); // $.cookie("cellphone", cellphone, { // expires: 365 * 10 // }); // $.cookie("password", password, { // expires: 365 * 10 // }); // } else { // $.cookie("remember", false, { // expires: 365 * 10 // }); // $.removeCookie("cellphone"); // $.removeCookie("password"); // } // //fix bug // $.closePanel(); // $.cookie("user", JSON.stringify(ret.data), { // expires: 365 * 10 // }); // $.router.replacePage(initTheme(user.theme)); // } // } else if (ret.status === 0) { // $.alert(ret.message); // } // } // }, // error: function () { // $.hideIndicator(); // $.alert("请检查网络!"); // } // }); // } // return false; // }); // function initPage() { // if ($.cookie("remember")) { // if ($.cookie("cellphone")) { // $(page).find($('input[name=remember]')).prop("checked", true); // $(page).find($('input[name=cellphone]')).val($.cookie("cellphone")); // $(page).find($('input[name=password]')).val($.cookie("password")); // } // } // } // function checkItem() { // if (!new RegExp(/^1\d{10}$/).test($(page).find($('input[name=cellphone]')).val()) && $('input[name=cellphone]').val().indexOf("ccvip") === -1) { // $.alert("请输入正确格式的账户"); // return false; // } else if (!new RegExp(/[A-Za-z0-9]{1,16}$/).test($(page).find($('input[name=password]')).val())) { // $.alert("密码不能为空"); // return false; // } else { // return true; // } // } // }); $(document).on('pageInit', '#page-userPanel', function (e, pageId, page) { var user = $.parseJSON($.caesarCache('user') ? $.caesarCache('user') : null); var is_weixin = false; var data = ''; initPage(); function initPage() { if (user === null) { location.href = 'login.php'; return; } getData(); } function getData() { var token = user.token; $.showIndicator(); $.ajax({ type: 'GET', url: '../api/user/profile/', dataType: 'json', data: { token: token, }, success: function (ret) { $.hideIndicator(); if (typeof ret.status !== 'undefined') { if (ret.status === 1) { data = ret.data; is_weixin = data.is_weixin; innerData(data); } else if (ret.status === -1) { location.href = 'login.php'; return; } else { $.alert(ret.message); } } }, error: function () { $.hideIndicator(); $.alert('请检查网络!'); }, }); } $(page).on('change', 'input[type=file]', function (e) { if (typeof e.target.files != 'undefined') { base64Pic(e.target.files[0]); } }); $(page).on('click.init', '.icon-edit', function (e) { $.router.loadPage('bindCellphone.html'); }); $(page).on('click.init', '.withdraw', function (e) { $.modal({ title:'撤回隐私政策
', text: '请注意,您撤回隐私政策同意后,将无法使用云中美食功能,需要重新授权同意隐私政策后,方可重新使用云中美食各项功能。
', buttons: [{ text: '否', },{ text: '是', onClick: function (){ localStorage.removeItem('camera_scan'); localStorage.removeItem('camera_photo'); localStorage.removeItem('write_storage_photo'); localStorage.removeItem('write_storage_data'); localStorage.removeItem('photo_data'); localStorage.removeItem('user'); var token = user.token; $.ajax({ type: 'POST', url: '../api/user/logout/', dataType: 'json', data: { token: token, }, success: function (ret) { if (typeof ret.status !== 'undefined') { if (ret.status === 1 || ret.status === -1) { $.closePanel(); setTimeout(function () { location.href = 'login.php'; }, 200); return; } else { $.alert(ret.message); } } }, error: function () { $.alert('请检查网络!'); }, }); } }] }); }); // 跳转个人账户明细 $(page).on("click", ".individual_account_detail", function (e){ // 异步获取账户信息 $.showIndicator(); $.post("../api/user/get_account_list/",{ token: user.token, },function (j){ $.hideIndicator(); if(j.status == 1){ var html = ''; var list = j.data.account_list; var data = j; for (let j in list) { var account = list[j].account; var accClass = list[j].class; const length = Object.keys(account).length; if (list[j].account.length == 0)continue; for (let k in account) { console.log(account[k]); console.log(accClass); var account_total = account[k].account_total ? account[k].account_total : 0 var accountName = ""; if ($.isEmptyObject(account[k].notes))accountName = account[k].supplier_name; else accountName = account[k].notes; html += ``+list[j].name+`
`+accountName+`
¥`+account_total+`' + con + '
' + '账户注销后:
1. 饭卡余额不能退,仅能到饭堂处提取;
2. 不能复通,仅能到饭堂处重新开通。
确定注销该账户吗?
该服务需要申请使用以下权限:
', text: '相机权限:用于扫码、拍照时使用。
读写外部存储权限:用于用户拍摄时临时存储照片、上传照片。
人脸影像数据仅用于饭堂取餐与现场消费用,如您不同意请不要进行后续操作。
', buttons: [{ text: '拒绝', onClick: function (){ } },{ text: '同意', onClick: function (){ $(_this).removeAttr('disabled') $("#upload_face").click(); localStorage.setItem('camera_scan', true); localStorage.setItem('camera_photo', true); // localStorage.setItem('write_storage_photo', true); // localStorage.setItem('write_storage_data', true); // localStorage.setItem('photo_data', true); } }] }); } }) function getRules() { var token = user.token; $.ajax({ type: 'GET', url: '../api/poschannelrule/get_pos_channel_user', dataType: 'json', data: { token: token, }, success: function (res) { console.log(res); var rule_list = res.data.channel_rule_list; var check_html = ''; for (var i = 0; i < rule_list.length; i++) { var item = rule_list[i]; check_html += '暂无记录
' : cardHtml ); loading = false; } function getData() { // 年份 var month_html = ''; for (var i = 1; i <= 12; i++) { if (i < 10) { month_html += ''; } else { month_html += ''; } } $(page).find('.b_month').html(month_html); // 月份 var day_html = ''; for (var i = 1; i <= 31; i++) { if (i < 10) { day_html += ''; } else { day_html += ''; } } $(page).find('.b_day').html(day_html); } $(page).on('click', '.tijiao', function () { loading = true; var b_month = $('.b_month').val(); var b_day = $('.b_day').val(); if (b_month == '') { $.alert('月份不能为空'); } else if (b_day == '') { $.alert('日期不能为空'); } else { $.modal({ text: '录入后不能修改,请确认!', buttons: [ { text: '取消', }, { text: '确认', onClick: function () { var token = user.token; $.showIndicator(); $.ajax2({ type: 'POST', url: '../api/user/set_birth?token=' + token, dataType: 'json', data: { birth: b_month + '-' + b_day, }, success: function (ret) { $.hideIndicator(); if (typeof ret.status !== 'undefined') { if (ret.status === 1) { user.birthday = b_month + '-' + b_day; $.caesarCache('user', JSON.stringify(user), { expires: 365 * 10, }); $.alert(ret.message, function () { $.router.replacePage('index.html'); }); } else if (ret.status === -1) { location.href = 'login.php'; return; } else { $.alert(ret.message); } } }, error: function () { $.hideIndicator(); $.alert('请检查网络!'); }, }); }, }, ], }); } }); }); $(document).on('pageInit', '#page-noticeList', function (e, pageId, page) { var user = $.parseJSON($.caesarCache('user') ? $.caesarCache('user') : null); var data = ''; initPage(); function initPage() { if (user === null) { location.href = 'login.php'; return; } getData(); } function getData() { var token = user.token; $.showIndicator(); $.ajax({ type: 'GET', url: '../api/dishes/noticelist', dataType: 'json', data: { token: token, }, success: function (ret) { $.hideIndicator(); if (typeof ret.status !== 'undefined') { if (ret.status === 1) { data = ret.data; innerData(data); } else if (ret.status === -1) { location.href = 'login.php'; return; } else { $.alert(ret.message); } } }, error: function () { $.hideIndicator(); $.alert('请检查网络!'); }, }); } function innerData(data) { $('title').html(data.page); $('.title').html(data.title); var itemListHtml = ''; if (data.list !== null && data.list.length > 0) { itemListHtml += '折扣价:' + goods.price + '
原价:' + goods.original_price + '
' + supply_name + '
' + '' + goodsItem.name + '
' + '' + goodsItem.price + '元
' + '你的购物车为空,赶紧填满吧!
你的购物车为空,赶紧填满吧!
原价
' ); $(page) .find('.yj-price') .html('原价:' + data.goods_list.original_price); $(page).find('.yj-price').addClass('active'); } $(page) .find('.goods-title') .html(data.goods_list.name + ' ' + unitname); $(page).find('.supply').html(supply_name); $(page) .find('.refunded') .html(data.goods_list.refund != 0 ? '支持退货' : '不支持退货'); $(page) .find('.card-content-inner.content_list') .html(data.goods_list.intro); if (data.kf_phone) { $(page) .find('.kf') .html('客服电话:' + data.kf_phone); } var comment_html = data.pj_list.map(function (item) { return '订单编号:' + order.code + '
下单时间:' + order.addtime + '
取消时间:' + order.cancel_time + '
' + order.total_num + '件商品
' + order.total_price + '
暂无记录
' : cardHtml ); if (parseInt(data.pagecount) <= parseInt(pageNum)) { $.detachInfiniteScroll($(page).find('.infinite-scroll')); } loading = false; } function getData(page) { if (user === null) { location.href = 'login.php'; return; } var token = user.token; $.ajax2({ type: 'GET', url: '../show/mall.php?act=get_myorders', dataType: 'json', data: { token: token, page: page, }, success: function (ret) { if (typeof ret.status !== 'undefined') { if (ret.status === 1) { innerData(ret.data); } else if (ret.status === -1) { location.href = 'login.php'; return; } else { $.alert(ret.message); } } }, error: function () { $.alert('请检查网络!'); }, }); } $(page).on('click', '.showQr', function () { var url = $(this).data('url'); var name = $(this).data('name'); var num = $(this).data('num'); var popupHTML = '' + num + '
' + '' + '扫二维码进行取货
' + '' + num + '
' + '' + '扫二维码或按小键盘输入取餐码进行取餐
' + '' + ret.data.name + '
' + '' + '扫二维码进行支付操作
' + '