<!doctype html> <html> <head> <meta charset="UTF-8"> <title>OTC</title> <meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no,viewport-fit=cover"> <link href="../../../lib/css/mui.min.css" rel="stylesheet" /> <!--引入公共样式--> <link rel="stylesheet" type="text/css" href="../../../lib/css/icons-extra2.css" /> <link rel="stylesheet" type="text/css" href="../../../lib/css/icons-extra3.css" /> <link href="../../../lib/css/mui.pullToRefresh.css" rel="stylesheet" /> <link href="../../../lib/css/basic.css" rel="stylesheet" /> <link href="../css/OTC_index.css" rel="stylesheet" /> <!--下拉刷新上拉加载css--> <script src="../../../lib/js/rem-layout.js"></script> <script src="../../../lib/js/mui.min.js"></script> <script src="../../../lib/js/vue.js"></script> <script src="../../../lib/js/app.js"></script> <!--下拉刷新上拉加载js--> <script src="../../../lib/js/mui.pullToRefresh.js"></script> <script src="../../../lib/js/mui.pullToRefresh.material.js"></script> <!--baseJs--> <script src='../js/base/base.compute.js'></script> <script src="../js/base/requestUrl.js"></script> <script src="../js/ajax/coin_ajax.js"></script> <script src="../js/ajax/ad_ajax.js"></script> <script src="../js/ajax/order_ajax.js"></script> <script src="../js/ajax/userpay_ajax.js"></script> <script src="../js/ajax/config_ajax.js"></script> <script src="../../../lib/js/jsencrypt.min.js"></script> <script src="../../wallet/js/wallet.inner.js"></script> </head> <style> .no-data-img { text-align: center; margin: 2rem 0 0 0; font-size: 0.25rem; color: rgb(51, 51, 51); } .no-data-img img { width: 2rem !important; } .mui-slider .mui-segmented-control.mui-segmented-control-inverted~.mui-slider-group .mui-slider-item { border-top: none; } </style> <body> <div id="data-info"> <header class="mui-bar mui-bar-nav" id="header"> <!--<a class="mui-icon-left" id="coin-choice" style="font-size: .34rem;">BTC <span class="icon_more"></span></a>--> <div class="select mui-icon-left"> <select name="slct1" v-model="coin_index" @change="coinChange"> <option v-for="(item,index) in coins" :value="index">{{item.coinName}}</option> </select> </div> <a id="rules" class="mui-icon iconfont icon-shangjiadianpu mui-pull-right mui-icon-right-nav" style="margin-right:2.2rem; color: #000000;"></a> <a id="order" class="mui-icon iconfont icon-dingdan mui-pull-right mui-icon-right-nav" style="margin-right:1rem; color: #000000;"></a> <a id="tap-top-popover" href="#topPopover" class="mui-icon iconfont icon-Shape mui-pull-right mui-icon-right-nav" style=" color: #000000;"></a> </header> <div class="mui-content"> <div id="slider" class="mui-slider mui-fullscreen"> <div id="sliderSegmentedControl" class="mui-slider-indicator mui-segmented-control mui-segmented-control-inverted "> <a class="mui-control-item mui-active" href="#item1">{{langue.buy}}</a> <a class="mui-control-item" href="#item2">{{langue.sell}}</a> </div> <div class="mui-slider-group"> <!--全部订单--> <div id="item1" class="mui-slider-item mui-control-content mui-active"> <div class="no-data-img" v-show="ad_sells.length <= 0"> <img src="../img/no_data.png" /> <div>{{langue.noAd}}</div> </div> <div id="scroll1" class="mui-scroll-wrapper"> <div class="mui-scroll"> <ul class="mui-table-view"> <li class="mui-table-view-cell" v-for="(item,index) in ad_sells"> <div class="left-box"> <div class="person"> <div class="person-img"> <img :src="base_avatar_url + item.userImg" v-if='item.userImg != null' /> <img src="../../../mine/img/touxiang_mr.png" v-if='item.userImg == null' /> </div> <span class="person-name">{{item.nickname}}</span> </div> <p class="info">{{item.adTransNum}} | {{computeAdMarkNum(item.adTransNum,item.adMarkNum)}}%</p> <p class="limit-money"><label>{{langue.limit}}:</label>{{item.minLimit}}-{{item.maxLimit}} {{item.unitName}}</p> <p class="limit-num"><label>{{langue.num}}:</label>{{item.lastNum | toFixNum(coin.coinDecimal)}} {{item.coinName}}</p> </div> <div class="right-box"> <p class="total-num">{{item.price | toFixNum(coin.unitDecimal)}} <label>{{item.unitName}}</label></p> <div class="icon"> <span class="mui-icon iconfont icon-zhifubap" style="color: #0062CC;" v-if="item.adPay.indexOf('ZFB') != -1"></span> <span class="mui-icon iconfont icon-weixin-copy" style="color: #007849;" v-if="item.adPay.indexOf('WX') != -1"></span> <span class="mui-icon iconfont icon-yinhangka" style="color: #F4A41F;" v-if="item.adPay.indexOf('BANK') != -1"></span> </div> <button class="mui-btn-outlined buys js-tap-deal" :data-ad-index='index'>{{langue.buy}}</button> </div> </li> </ul> </div> </div> </div> <div id="item2" class="mui-slider-item mui-control-content"> <div class="no-data-img" v-show="ad_buys.length <= 0"> <img src="../img/no_data.png" /> <div>{{langue.noAd}}</div> </div> <div id="scroll2" class="mui-scroll-wrapper"> <div class="mui-scroll"> <ul class="mui-table-view"> <li class="mui-table-view-cell" v-for="(item,index) in ad_buys"> <div class="left-box"> <div class="person"> <div class="person-img"> <img :src="base_avatar_url + item.userImg" v-if='item.userImg != null' /> <img src="../../../mine/img/touxiang_mr.png" v-if='item.userImg == null' /> </div> <span class="person-name">{{item.nickname}}</span> </div> <p class="info">{{item.adTransNum}} | {{computeAdMarkNum(item.adTransNum,item.adMarkNum)}}%</p> <p class="limit-money"><label>{{langue.limit}}:</label>{{item.minLimit}}-{{item.maxLimit}} {{item.unitName}}</p> <p class="limit-num"><label>{{langue.num}}:</label>{{item.lastNum | toFixNum(coin.coinDecimal)}} {{item.coinName}}</p> </div> <div class="right-box"> <p class="total-num">{{item.price | toFixNum(coin.unitDecimal)}} <label>{{item.unitName}}</label></p> <div class="icon"> <span class="mui-icon iconfont icon-zhifubap" style="color: #0062CC;" v-if="item.adPay.indexOf('ZFB') != -1"></span> <span class="mui-icon iconfont icon-weixin-copy" style="color: #007849;" v-if="item.adPay.indexOf('WX') != -1"></span> <span class="mui-icon iconfont icon-yinhangka" style="color: #F4A41F;" v-if="item.adPay.indexOf('BANK') != -1"></span> </div> <button class="mui-btn-outlined sales js-tap-deal" :data-ad-index='index'>{{langue.sell}}</button> </div> </li> </ul> </div> </div> </div> </div> </div> <!--下单信息弹出框--> <div id="popover" class="mui-popover mui-popover-action"> <div class="popover-info"> <div class="info-txt"> <h4 v-if="ad_type == 'BUY'">{{langue.buy}} {{ad.coinName}}</h4> <h4 v-if="ad_type == 'SELL'">{{langue.sell}} {{ad.coinName}}</h4> <div class="money">{{ad.price | toFixNum(coin.unitDecimal)}} {{ad.unitName}}</div> </div> <p>{{langue.limit}}:{{ad.minLimit}}-{{ad.maxLimit}} {{ad.unitName}} </p> </div> <div class="icon"> <span class="mui-icon iconfont icon-zhifubap" style="color: #0062CC;" v-if="ad.adPay.indexOf('ZFB') != -1"><label>{{langue.Alipay}}</label></span> <span class="mui-icon iconfont icon-weixin-copy" style="color: #007849;" v-if="ad.adPay.indexOf('WX') != -1"><label>{{langue.WeChat}}</label></span> <span class="mui-icon iconfont icon-yinhangka" style="color: #F4A41F;" v-if="ad.adPay.indexOf('BANK') != -1"><label>{{langue.Bankcard}}</label></span> </div> <div class="input-group"> <template v-if="ad_type == 'BUY'"> <input type="text" class="one" :placeholder="ad.maxLimit | toFixNum(coin.unitDecimal,langue.limit_buy)" v-model.number="deal_money" @input="change_deal_money" oninput="formatNumber(this,dataInfo.coin.unitDecimal)" /> <label class="unit">{{ad.unitName}}</label> <label class="all" @click="allBuysell">{{langue.all_buy}}</label> </template> <template v-if="ad_type == 'SELL'"> <input type="text" class="one" :placeholder="ad.maxLimit | toFixNum(coin.unitDecimal,langue.limit_sell)" v-model.number="deal_money" @input="change_deal_money" oninput="formatNumber(this,dataInfo.coin.unitDecimal)" /> <label class="unit">{{ad.unitName}}</label> <label class="all" @click="allBuysell">{{langue.all_sell}}</label> </template> </div> <div class="input-group"> <template v-if="ad_type == 'BUY'"> <input type="text" :placeholder="ad.lastNum | toFixNum(coin.coinDecimal,langue.limit_buy)" v-model.number="deal_amount" @input="change_deal_amount" oninput="formatNumber(this,dataInfo.coin.coinDecimal)" /> <label>{{ad.coinName}}</label> <p class="note" v-if="auto_cancel_interval != null">{{langue.note1}} {{auto_cancel_interval}} {{langue.note2}}</p> </template> <template v-if="ad_type == 'SELL'"> <input type="text" :placeholder="ad.lastNum | toFixNum(coin.coinDecimal,langue.limit_sell)" v-model.number="deal_amount" @input="change_deal_amount" oninput="formatNumber(this,dataInfo.coin.coinDecimal)" /> <label>{{ad.coinName}}</label> <p class="note"><br /></p> </template> </div> <div class="btn"> <button class="app-btn mui-btn-outlined" id="deal-btn"> <span v-if="ad_type == 'BUY'">{{langue.buy}}</span> <span v-if="ad_type == 'SELL'">{{langue.sell}}</span> </button> </div> </div> <!--右上角弹出菜单--> <div id="topPopover" class="mui-popover"> <div class="mui-popover-arrow"></div> <ul> <li class="mui-table-view-cell" id="ad"> <a href="#">{{langue.Place_ad}}</a> </li> <li class="mui-table-view-cell" id="ad-manager"> <a href="#">{{langue.ad_manager}}</a> </li> </ul> </div> <!--灰色背景图蒙版--> <div id="bg" class="bg" v-show="mask_status"></div> <!--卖出交易密码确认--> <div class="confirm animated bounceInUp" id="confirm" v-show="pass_status"> <form class="input-group"> <div class="title-top"> <span class="mui-icon mui-icon-closeempty icon js-tap-pass-close"></span> <span id="title" class="title">{{langue.Order}}</span> </div> <div class="mui-input-row"> <label for="confirm-password">{{langue.Password}}</label> <input type="password" id="confirm-password" class="mui-input-password" v-model="pass" :placeholder="langue.enter_pass"> </div> <div class="mui-button-row"> <button id="confirmBtn" type="button" class="mui-btn mui-btn-primary">{{langue.confirm}}</button> </div> </form> </div> </div> </div> </body> <script type="text/javascript"> /***公共变量***/ //页码 var buyPageNum = 1; var sellPageNum = 1; //上下拉刷新控件 var pullToRefreshObj = null; var langues = { zh_CN: { sell: '出售', buy: '购买', noAd: "暂无广告", limit: "限额", num: "数量", all_buy: '全部买入', all_sell: '全部卖出', limit_buy: '最多买入', limit_sell: '最多卖出', Alipay: '支付宝', WeChat: '微信', Bankcard: '银行卡', note1: '提交信息即生成订单,请在', note2: '分钟内完成付款', buyNow: '立即购买', sellNow: '立即出售', Place_ad: '发布广告', ad_manager: '广告管理', Order: '下单', Password: '密码', confirm: '确认', enter_pass: '请输入密码', contentdown: '上拉显示更多', contentrefresh: '正在加载...', note3: '未登录跳转登录页', note4: '请勿与自己发布的广告进行交易!', note5: '分鐘内完成付款', note6: '您需激活至少一种买方的收款方式,才可进行出售!', note7: '请输入交易数量!', note8: '请输入交易金额!', note9: '交易金额不符合广告限额', note10: '密码存储时间已过期,请重新输入', note11: '请输入交易密码!', note12: '等待中...', note13: '下单成功!', note14: '您的账号在别处登录!', note15: '网络异常,请刷新重试!' }, zh_HK: { sell: '出售', buy: '購買', noAd: "暫無廣告", limit: "限額", num: "數量", all_buy: '全部買入', all_sell: '全部賣出', limit_buy: '最多買入', limit_sell: '最多賣出', Alipay: '支付寶', WeChat: '微信', Bankcard: '銀行卡', note1: '提交信息即生成訂單,請在', note2: '分鐘内完成付款', buyNow: '立即購買', sellNow: '立即出售', Place_ad: '發佈廣告', ad_manager: '廣告管理', Order: '下單', Password: '密碼', confirm: '確認', enter_pass: '請輸入密碼', contentdown: '上拉顯示更多', contentrefresh: '正在加載...', note3: '未登錄跳轉登錄頁', note4: '請勿與自己發佈的廣告進行交易!', note5: '分鐘内完成付款', note6: '您需激活至少一種買方的收款方式,才可進行出售!', note7: '請輸入交易數量!', note8: '請輸入交易金額!', note9: '交易金額不符合廣告限額', note10: '密碼存儲時間已過期,請重新輸入', note11: '請輸入交易密碼!', note12: '等待中...', note13: '下單成功!', note14: '您的賬號在別處登陸!', note15: '網絡異常,請刷新重試!' }, en_US: { sell: 'Sell', buy: 'Buy', noAd: "No ad", limit: "Limit", num: "Num", all_buy: 'All buy', all_sell: 'All sell', limit_buy: 'Limit buy ', limit_sell: 'Limit sell ', Alipay: 'Alipay', WeChat: 'WeChat', Bankcard: 'Bankcard', note1: 'Please in', note2: 'minutes complete payment', buyNow: 'Buy', sellNow: 'Sell', Place_ad: 'Place ad', ad_manager: 'Ad manager', Order: 'Order', Password: 'Password', confirm: 'Confirm', enter_pass: 'Please enter your password', contentdown: 'Pull up to show more', contentrefresh: 'Loading...', note3: 'Not logged in to the login page', note4: 'Do not trade with ads you post!', note5: 'Complete payment within minutes', note6: 'You need to activate at least one buyer’s payment method before you can sell it.!', note7: 'Please enter the number of transactions!', note8: 'Please enter the transaction amount!', note9: 'Transaction amount does not match the ad limit', note10: 'Password storage time has expired, please re-enter', note11: 'Please enter the transaction password!', note12: 'Waiting...', note13: 'Successfully ordered!', note14: 'Your account is logged in elsewhere!', note15: 'Network exception, please refresh!' } }; //2、页面上所有需要国际化的文字,包括提示,都通过Vue去引用,例子: var langueKey = app.getLanguageLocalStorage(); //获取国际化语种 var langue = langues[langueKey]; // 获取国际化语种数据 //3、每个页面都需要加上以下的方法: window.addEventListener('switchLangueData', function(e) { //dataInfo为Vue对象的名称 dataInfo.langue = langues[e.detail]; }); </script> <script type="text/javascript"> /***vue***/ //全局过滤器-保留小数点 Vue.filter('toFixNum', function(value, fix_num, preStr) { var realNum = app.formatValueStr(value, fix_num); //判断是否存在字符串说明前缀 if (preStr == '' || preStr == null) { //返回计算好的小数 return realNum; } else { return preStr + ' ' + realNum; } }); var dataInfo = new Vue({ el: '#data-info', data: { langue: langue, coins: [], //代币列表 coin_index: 0, //代币下拉控件索引 coin: { //当前选择的代币 coinName: '', //当前选择的代币 unitName: '', //当前代币的交易单位 coinDecimal: 6, //代币小数长度 unitDecimal: 2, //代币交易单位小数长度 }, ad_type: 'BUY', //当前选择的广告类型 买/卖 ad: { //下单时选择的广告的信息 id: '', //广告id price: 0, //广告单价 minLimit: 0, //广告最低限额 maxLimit: 0, //广告最高限额 lastNum: 0, //广告剩余数量 adPay: '', //广告支付方式 coinName: '', //广告币种 unitName: '', //广告法币 }, ad_buys: [], //买入广告列表 ad_sells: [], //卖出广告列表 deal_amount: '', //下单代币数量 deal_money: '', //下单法币数量 pass: '', //支付密码 public_pass: '', //公钥加密后的支付密码 mask_status: false, //蒙版显示状态 pass_status: false, //密码框显示状态 base_avatar_url: app.walletFileUrl, //服务器访问图片路径前缀 auto_cancel_interval: null, //自动撤单倒计时时间 // nowDate: '', //获取当前时间 }, // created() { // //判断是否在其他页面输入过密码 以下是 是的情况 // if(localStorage.getItem('nowPassNOValue')) { // //控制密码框的出现 // this.pass_status = localStorage.getItem('nowPassNOValue'); // } // if( // localStorage.getItem('userpass') != '' && // localStorage.getItem('userpass') != null // ) { // if( // localStorage.getItem('userdate') != '' && // localStorage.getItem('userdate') != null // ) { // this.pass_status = false; // this.pass = localStorage.getItem('userpass'); // this.nowDate = localStorage.getItem('userdate'); // } // } // }, methods: { //全部买入、全部卖出 allBuysell: function() { this.deal_amount = dataInfo.ad.lastNum; this.change_deal_amount(); }, //下单代币数量改变时 change_deal_amount: function() { //下单法币数量 = 下单代币数量 * 广告单价 this.deal_money = compute.Mul(this.deal_amount, this.ad.price, this.coin.unitDecimal); }, //下单法币数量改变时 change_deal_money: function() { //下单法币数量 = 下单代币数量 * 广告单价 this.deal_amount = compute.Div(this.deal_money, this.ad.price, this.coin.coinDecimal); }, //立即出售点击时,弹出密码框 popPassword: function() { //显示蒙版、密码框 this.mask_status = true; this.pass_status = true; }, //隐藏密码框 hidePassword: function() { //显示蒙版、密码框 this.mask_status = false; this.pass_status = false; document.activeElement.blur(); }, //关闭蒙版、密码框、所有弹出 hideEle: function() { this.hidePassword(); mui('#popover').popover('hide'); }, //弹出/隐藏下单详情框 popDealInfo: function() { mui('#popover').popover('toggle'); }, //币种切换时触发方法 coinChange: function(e) { //当前下拉框选择索引 var index = this.coin_index; //更换当前币种 this.coin = JSON.parse(JSON.stringify(this.coins[index])); //清空数据 this.ad_buys = []; this.ad_sells = []; //查询广告列表 this.listAdByAdType(); }, //根据广告类型查询广告列表 listAdByAdType: function() { //查询广告列表 if (this.ad_type == 'BUY') { listSellAds(); } if (this.ad_type == 'SELL') { listBuyAds(); } }, //计算广告成交百分百 computeAdMarkNum: function(adTransNum, adMarkNum) { var per = (adMarkNum / adTransNum); if (isNaN(per)) { return 0; } return per.toFixed(2); }, //清空成交数量、成交金额输入框 emptyDealInput: function() { this.deal_amount = ''; this.deal_money = ''; }, //清空密码变量的值 emptyPass: function() { this.pass = ''; this.public_pass = ''; }, //是否登录 tap_is_login: function() { //未登录跳转登录页 if (JSON.stringify(app.getUserLocalStorage()) == "{}") { app.openWin(requestUrl.LOGIN.getUrl, requestUrl.LOGIN.getId); throw new Error(dataInfo.langue.note3); } }, //判断广告用户id和当前登录的用户id是否相同 tap_check_ad_userId: function() { var userLocalId = app.getUserLocalStorage().id; var adUserId = this.ad.userId; if (userLocalId == adUserId) { mui.toast(dataInfo.langue.note4); throw new Error(dataInfo.langue.note4) } } }, }) </script> <script type="text/javascript"> /***mui.plusReday***/ mui.plusReady(function() { //查询币种后,查询广告列表 getCoins(function() { //根据类型查询广告列表 dataInfo.listAdByAdType(); }); //查询自动撤单倒计时时间 selectAutoCancelInterval(); //上拉加载 pullToRefreshObj = mui('.mui-scroll').pullToRefresh({ up: { callback: function() { var self = this; setTimeout(function() { pullUpFunction(self); }, 1000); }, contentdown: dataInfo.langue.contentdown, contentrefresh: dataInfo.langue.contentrefresh, contentnomore: "- End -" } }); //下拉刷新 mui(".mui-content").pullToRefresh({ down: { callback: function() { var self = this; //查询订单 dataInfo.listAdByAdType(); //区域滑动对象 if (dataInfo.ad_type == 'BUY') { pullToRefreshObj[0].refresh(true); } if (dataInfo.ad_type == 'SELL') { pullToRefreshObj[1].refresh(true); } setTimeout(function() { self.endPullDownToRefresh(); }, 1000); } }, }); }); </script> <script type="text/javascript"> /***事件绑定***/ //商家申請页面按钮监听 document.getElementById('rules').addEventListener('tap', function() { dataInfo.tap_is_login(); mui('#topPopover').popover('hide'); app.openWin('merchant.html', 'merchant.html'); }); //订单记录页面按钮监听 document.getElementById('order').addEventListener('tap', function() { dataInfo.tap_is_login(); mui('#topPopover').popover('hide'); app.openWin('order.html', 'order.html'); }); //购买/出售按钮监听 mui(".mui-table-view").on('tap', '.mui-table-view-cell .js-tap-deal', function() { dataInfo.tap_is_login(); //选择广告列表的索引 var adIndex = this.getAttribute("data-ad-index"); //根据广告类型判断广告列表,并渲染下单详情数据 if (dataInfo.ad_type == 'BUY') { dataInfo.ad = dataInfo.ad_sells[adIndex]; //判断是否与自己交易 dataInfo.tap_check_ad_userId(); //显示下单详情框 dataInfo.popDealInfo(); } if (dataInfo.ad_type == 'SELL') { dataInfo.ad = dataInfo.ad_buys[adIndex]; //判断是否与自己交易 dataInfo.tap_check_ad_userId(); //出售时是否绑定广告相关的支付信息 listUserPays(function(flag) { //未绑定 if (!flag) { mui.toast(dataInfo.langue.note6); return; } else { //显示下单详情框 dataInfo.popDealInfo(); } }); } }); //监听购买、出售组件轮播切换 document.querySelector(".mui-slider").addEventListener("slide", function(e) { //组件索引 var slider_index = e.detail.slideNumber; //广告状态改为买入 if (slider_index == 0) { dataInfo.ad_type = 'BUY' //查询广告卖出接口 listSellAds(); } //广告状态改为卖出 if (slider_index == 1) { dataInfo.ad_type = 'SELL' //查询广告买入接口 listBuyAds(); } }); // 发布广告监听 document.getElementById('ad').addEventListener('tap', function() { dataInfo.tap_is_login(); mui('#topPopover').popover('hide'); app.openWin('advertisement.html', "advertisement.html"); }); // 广告管理监听 document.getElementById('ad-manager').addEventListener('tap', function() { dataInfo.tap_is_login(); mui('#topPopover').popover('hide'); app.openWin('ad_manager.html', "ad_manager.html"); }); //蒙版背景监听 document.getElementById('bg').addEventListener('tap', function() { dataInfo.emptyPass(); dataInfo.hidePassword(); }); //密码框取消按钮监听 mui(".confirm").on('tap', '.input-group .js-tap-pass-close', function() { dataInfo.emptyPass(); dataInfo.hidePassword(); }); //交易控件隐藏事件 mui('body').on('hidden', '.mui-popover', function(e) { //清空输入框 dataInfo.emptyDealInput(); }); //立即出售或者立即购买按钮点击事件 document.getElementById("deal-btn").addEventListener("tap", function() { //交易数量是否为空、为0 if (dataInfo.deal_amount <= 0 || dataInfo.deal_amount == '') { mui.toast(dataInfo.langue.note7); return; } //交易金额是否为空、为0 if (dataInfo.deal_money <= 0 || dataInfo.deal_money == '') { mui.toast(dataInfo.langue.note8); return; } //交易金额是否符合广告限额 if (dataInfo.deal_money > dataInfo.ad.maxLimit || dataInfo.deal_money < dataInfo.ad.minLimit) { mui.toast(dataInfo.langue.note9); return; } //下单买单并跳转至订单详情页 if (dataInfo.ad_type == 'BUY') { //下单买单 buyOrder(); } //下单卖单,弹出密码框 if (dataInfo.ad_type == 'SELL') { // // 判断5分钟 密码存储时间是否过期 // if(!dataInfo.pass_status) { // var data = dataInfo.nowDate.replace(new RegExp(/-/gm), '/'); // //结束时间戳 // var lastTime = Date.parse(new Date(data)) + '5' * 60 * 1000; // //当前时间戳 // var now = Date.parse(new Date()); // //剩余时间戳 // var msec = lastTime - now; // //时间已结束 // if(msec <= 0) { // mui.toast(dataInfo.langue.note10); // // 密码输入框出现,清除缓存 // dataInfo.pass = ''; // dataInfo.pass_status = true; // dataInfo.mask_status = true; // localStorage.removeItem('userpass'); // localStorage.removeItem('userdate'); // localStorage.removeItem('nowPassNOValue'); // return; // } // } // // 弹窗前先判断是否有缓存密码 // if( // localStorage.getItem('userpass') != '' && // localStorage.getItem('userpass') != null // ) { // if( // localStorage.getItem('userdate') != '' && // localStorage.getItem('userdate') != null // ) { // dataInfo.pass = localStorage.getItem('userpass'); // dataInfo.nowDate = localStorage.getItem('userdate'); // dataInfo.pass_status = false; // //获取非对称加密的公钥 // walletApi.getPublicKey(dataInfo.pass, function(data) { // dataInfo.public_pass = data; // //发布订单 // sellOrder(); // }); // // } // } else { //关闭小键盘 document.activeElement.blur(); //显示密码框 dataInfo.popPassword(); // } } }); //密码框确认按钮监听 document.getElementById('confirmBtn').addEventListener('tap', function() { //支付密码为空 if (dataInfo.pass == '' || dataInfo.pass == null) { mui.toast(dataInfo.langue.note11); return; } //获取非对称加密的公钥 walletApi.getPublicKey(dataInfo.pass, function(data) { dataInfo.public_pass = data; //发布订单 sellOrder(); }); }); </script> <script type="text/javascript"> /***function***/ //查询法币币种列表 function getCoins(callback) { mui.ajax(coinAjax.GET_COINS.getUrl, { headers: { "X-Requested-Token": app.getTokenStorage(), // token头部 "locale": app.getLanguageLocalStorage() // 语种头部 }, data: {}, dataType: 'json', type: coinAjax.GET_COINS.getType, timeout: 10000, //超时时间设置为10秒 success: function(data) { if (data.code == 200) { //渲染数据 dataInfo.coins = data.data; dataInfo.coin = data.data[0]; //回调函数 callback(); } } }); } //查询广告买入列表 function listBuyAds() { mui.ajax(adAjax.LIST_BUY_ADS.getUrl, { headers: { "X-Requested-Token": app.getTokenStorage(), // token头部 "locale": app.getLanguageLocalStorage() // 语种头部 }, data: { coinName: dataInfo.coin.coinName, unitName: dataInfo.coin.unitName, }, dataType: 'json', type: adAjax.LIST_BUY_ADS.getType, timeout: 10000, //超时时间设置为10秒 success: function(data) { if (data.code == 200) { //渲染数据 dataInfo.ad_buys = data.data; //初始化页码 buyPageNum = 1; //滑动至顶部 mui('#scroll2').scroll().scrollTo(0, 0, 500); //数据小于10条,禁用上拉 if (data.data.length < 10) { pullToRefreshObj[1].endPullUpToRefresh(true); } else { pullToRefreshObj[1].refresh(true); } } else { pullToRefreshObj[1].endPullUpToRefresh(true); } } }); } //查询广告卖出列表 function listSellAds() { mui.ajax(adAjax.LIST_SELL_ADS.getUrl, { headers: { "X-Requested-Token": app.getTokenStorage(), // token头部 "locale": app.getLanguageLocalStorage() // 语种头部 }, data: { coinName: dataInfo.coin.coinName, unitName: dataInfo.coin.unitName, }, dataType: 'json', type: adAjax.LIST_SELL_ADS.getType, timeout: 10000, //超时时间设置为10秒 success: function(data) { if (data.code == 200) { //渲染数据 dataInfo.ad_sells = data.data; //初始化页码 sellPageNum = 1; //滑动至顶部 mui('#scroll1').scroll().scrollTo(0, 0, 500); //数据小于10条,禁用上拉 if (data.data.length < 10) { pullToRefreshObj[0].endPullUpToRefresh(true); } else { pullToRefreshObj[0].refresh(true); } } else { pullToRefreshObj[0].endPullUpToRefresh(true); } } }); } //下单卖单 function sellOrder() { plus.nativeUI.showWaiting(dataInfo.langue.note12); mui.ajax(orderAjax.SELL_ORDER.getUrl, { headers: { "X-Requested-Token": app.getTokenStorage(), // token头部 "locale": app.getLanguageLocalStorage() // 语种头部 }, data: { adId: dataInfo.ad.id, amount: dataInfo.deal_amount, price: dataInfo.ad.price, turnover: dataInfo.deal_money, pass: dataInfo.public_pass, }, dataType: 'json', type: orderAjax.SELL_ORDER.getType, timeout: 10000, //超时时间设置为10秒 success: function(data) { plus.nativeUI.closeWaiting(); if (data.code == 200) { // // 5分钟内不输入密码 获取当前时间 布尔 密码存入缓存 // dataInfo.nowDate = formatDate(new Date(), 'yyyy-MM-dd hh:mm:ss'); // dataInfo.pass_status = false; // localStorage.setItem('userpass', dataInfo.pass); // localStorage.setItem('userdate', dataInfo.nowDate); // localStorage.setItem('nowPassNOValue', dataInfo.pass_status); //清空密码、下单参数、弹窗控件 dataInfo.emptyDealInput(); dataInfo.emptyPass(); dataInfo.hideEle(); mui.toast(dataInfo.langue.note13); //跳转订单页 app.openWin('payment.html', 'payment.html', {}, { orderId: data.data }); } else if (data.code == 201) { //未登录,跳转登录页面 app.openWin(requestUrl.LOGIN.getUrl, requestUrl.LOGIN.getId); } else if (data.code == 202) { mui.toast(dataInfo.langue.note14); app.openWin(requestUrl.LOGIN.getUrl, requestUrl.LOGIN.getId); } else { mui.toast(data.msg); } // else if(data.code == 12710) { // //密码错误的情况 单独判断,以防原因是用户修改了资金密码 // mui.toast(data.msg); // dataInfo.pass = ''; // // 密码输入框出现,清除缓存 // dataInfo.pass_status = true; // // localStorage.removeItem('userpass'); // localStorage.removeItem('userdate'); // localStorage.removeItem('nowPassNOValue'); // } //清空密码、下单参数、弹窗控件 dataInfo.emptyDealInput(); dataInfo.emptyPass(); dataInfo.hideEle(); }, error: function(xhr, type, errorThrown) { plus.nativeUI.closeWaiting(); app.toast(dataInfo.langue.note15); } }); } //下单买单 function buyOrder() { plus.nativeUI.showWaiting(dataInfo.langue.note12); mui.ajax(orderAjax.BUY_ORDER.getUrl, { headers: { "X-Requested-Token": app.getTokenStorage(), // token头部 "locale": app.getLanguageLocalStorage() // 语种头部 }, data: { adId: dataInfo.ad.id, amount: dataInfo.deal_amount, price: dataInfo.ad.price, turnover: dataInfo.deal_money, }, dataType: 'json', type: orderAjax.BUY_ORDER.getType, timeout: 10000, //超时时间设置为10秒 success: function(data) { plus.nativeUI.closeWaiting(); //清空密码、下单参数、弹窗控件 dataInfo.emptyDealInput(); dataInfo.emptyPass(); dataInfo.hideEle(); if (data.code == 200) { mui.toast(dataInfo.langue.note13); //跳转订单页 app.openWin('payment.html', 'payment.html', {}, { orderId: data.data }); } else if (data.code == 201) { //未登录,跳转登录页面 app.openWin(requestUrl.LOGIN.getUrl, requestUrl.LOGIN.getId); } else if (data.code == 202) { mui.toast(dataInfo.langue.note14); app.openWin(requestUrl.LOGIN.getUrl, requestUrl.LOGIN.getId); } else { mui.toast(data.msg); } }, error: function(xhr, type, errorThrown) { plus.nativeUI.closeWaiting(); app.toast(dataInfo.langue.note15); } }); } //卖出时查询用户是否绑定其中一种收款方式 function listUserPays(callback) { plus.nativeUI.showWaiting(dataInfo.langue.note12); mui.ajax(userpayAjax.LIST_USER_PAY.getUrl, { headers: { "X-Requested-Token": app.getTokenStorage(), // token头部 "locale": app.getLanguageLocalStorage() // 语种头部 }, dataType: 'json', type: userpayAjax.LIST_USER_PAY.getType, timeout: 10000, //超时时间设置为10秒 success: function(data) { plus.nativeUI.closeWaiting(); if (data.code == 200) { //广告的支付方式 var adPays = dataInfo.ad.adPay; //当前用户已激活的支付方式 var userPays = data.data; //用于记录是否绑定了其中一种支付方式 var flag = false; //循环当前用户已激活的支付方式 for (var i = 0; i < userPays.length; i++) { //用户已激活的支付方式匹配广告其中一种支付方式 if (adPays.indexOf(userPays[i].payType) != -1) { flag = true; } } callback(flag); } else if (data.code == 201) { //未登录,跳转登录页面 app.openWin(requestUrl.LOGIN.getUrl, requestUrl.LOGIN.getId); } else if (data.code == 202) { mui.toast(dataInfo.langue.note14); app.openWin(requestUrl.LOGIN.getUrl, requestUrl.LOGIN.getId); } } }); } //查询定时撤单间隔时间 function selectAutoCancelInterval() { mui.ajax(otcConfigAjax.SELECT_AUTO_CANCEL_INTERVAL.getUrl, { headers: { "X-Requested-Token": app.getTokenStorage(), // token头部 "locale": app.getLanguageLocalStorage() // 语种头部 }, dataType: 'json', type: otcConfigAjax.SELECT_AUTO_CANCEL_INTERVAL.getType, timeout: 10000, //超时时间设置为10秒 success: function(data) { if (data.code == 200) { dataInfo.auto_cancel_interval = data.data; } } }); } /** * 上拉加载事件 */ function pullUpFunction(_self) { //判断请求的接口 var ajaxObj = ''; var pageNum = 1; if (dataInfo.ad_type == 'BUY') { ajaxObj = adAjax.LIST_SELL_ADS; pageNum = sellPageNum; } if (dataInfo.ad_type == 'SELL') { ajaxObj = adAjax.LIST_BUY_ADS; pageNum = buyPageNum; } mui.ajax(ajaxObj.getUrl, { headers: { "X-Requested-Token": app.getTokenStorage(), // token头部 "locale": app.getLanguageLocalStorage() // 语种头部 }, data: { coinName: dataInfo.coin.coinName, unitName: dataInfo.coin.unitName, pageNum: pageNum + 1 }, dataType: 'json', //服务器返回json格式数据 type: ajaxObj.getType, //HTTP请求类型 timeout: 10000, success: function(data) { if (data.code == "200") { if (data.data.length > 0) { //渲染数据 if (dataInfo.ad_type == 'BUY') { dataInfo.ad_sells = dataInfo.ad_sells.concat(data.data); } if (dataInfo.ad_type == 'SELL') { dataInfo.ad_buys = dataInfo.ad_buys.concat(data.data); } if (dataInfo.ad_type == 'BUY') { sellPageNum += 1; } if (dataInfo.ad_type == 'SELL') { buyPageNum += 1; } } //如果数据小于10条 if (data.data.length < 10) { _self.endPullUpToRefresh(true); //关闭上拉,并禁用,显示没有更多数据了 } else { _self.endPullUpToRefresh(false); } } else if (data.code == 201) { //未登录,跳转登录页面 app.openWin(requestUrl.LOGIN.getUrl, requestUrl.LOGIN.getId); } else if (data.code == 202) { mui.toast(dataInfo.langue.note14); //未登录,跳转登录页面 app.openWin(requestUrl.LOGIN.getUrl, requestUrl.LOGIN.getId); } }, error: function(xhr, type, errorThrown) { _self.endPullUpToRefresh(false); } }); } </script> </html>