define(['app', 'service', 'directive/hightStock', 'jquery', 'kline', 'layer'], function (app) { 'use strict'; //大盘列表 app.controller('marketListCtrl', function ($scope,$rootScope, Market, Storage, $state, ENV, Auth, $interval) { layui.use(['layer','form','laydate'],function() { var layer = layui.layer, laydate = layui.laydate, form = layui.form(); $(window).scrollTop(0); //用户id $scope.userInfo = Storage.get('user'); $scope.getProductList = function () { Market.productList().then(function (data) { angular.forEach(data, function (v, k) { //v.marketinfo.thumb = ENV.imgSrc + "/" + v.marketinfo.thumb; }) $scope.pageData = data; console.log(data); }, function (data) { if(data.code==403){ layer.msg(data.msg); $rootScope.loginExit(); }else{ layer.msg(data.msg); } }) }; if ($scope.userInfo == null) {//不存在的情况下登录 $state.go("root.auth"); } else {// uid存在的情况下,请求数据 $scope.getProductList(); var marketListTime = $interval(function () { $scope.getProductList(); }, 5000); $scope.$on("$destroy", function () { $interval.cancel(marketListTime); }) } }) }); //大盘详情 app.controller('marketDetailCtrl', function ($rootScope,$scope, $stateParams, Market, $timeout, $location, Storage, $interval, $state, $window, fixedFun, Auth,$filter) { $scope.floatMax=4;//小数点的显示问题种子为5 其他为 4 $scope.ProductCodeActive=$stateParams.pid; layui.use(['layer','form','laydate'],function() { var layer = layui.layer, laydate = layui.laydate, form = layui.form(); $(window).scrollTop(0); $scope.userInfo = Storage.get("user");//用户信息 layer.msg("数据加载中,请稍等片刻……"); //分时刷新 $scope.dataDaPanMinute = { "data": { "TimeShare": [ { "Time": '', "Price": '', "Volume": '' } ], "MarketInfo": { "ProductId": '', "ProductName": "", "ProductCode": "", "IncreaseRate": '', "Increase": '', "Price": '', "OpenPrice": '', "HighestPrice": '', "LowestPrice": '', "LimitUp": '', "LimitDown": '', "Volume": '', "ProductImage": null }, "SysDT": '' } }; //日k $scope.dataDaPanRi = { "data": { "KLineList": [ { "Date": '', "OpeningPrice": '', "ClosingPrice": '', "HighestPrice": '', "LowestPrice": '', "Volume": '', "ChangePrice": '', "ChangeRate": '' } ], "MarketInfo": { "ProductId": '', "ProductName": "", "ProductCode": "", "IncreaseRate": 0, "Increase": 0, "Price": 0, "OpenPrice": 0, "HighestPrice": 0, "LowestPrice": 0, "LimitUp": 0, "LimitDown": 0, "Volume": 0, "ProductImage": null } } }; if ($scope.userInfo == null) { $state.go("root.auth"); } else { $scope.charts = { options: {}, series: [] }; //当前产品的 $stateParams.pid $scope.entrustData = {buy: [], sell: []}; //获取价格等初始化信息 $scope.productCurrent = $stateParams.pid;//判断当前的品种显示状态 $scope.currentPorImg = $stateParams.imgSrc; $scope.numLimitPro='';//设置交易数量的限制问题 $scope.getPriceREload = function () { //重新获取价格等基本信息 并且拼合 marketinfo数据 Market.getPrice($stateParams.pid*1).then(function (data) { if(data.marketinfo.sid=='1'){//种子 $scope.floatMax=5; }else{ $scope.floatMax=4; } data.marketinfo.buyprice=data.marketinfo.buyprice ? data.marketinfo.buyprice: data.marketinfo.nowOpen; //console.log( data.marketinfo.buyprice ,typeof data.marketinfo.buyprice ) $scope.getmakertinfo = data; var dataTemp = data.marketinfo; $scope.numLimitPro=data.marketinfo.group ? data.marketinfo.group : "";//设置倍数 var numProREset=$scope.numLimitPro==""?100:$scope.numLimitPro*1; // if(data.marketinfo.sid==1){//种子设置涨停跌停的问题 // data.marketinfo.riseStop=data.marketinfo.nowOpen*1 + 0.0003; // data.marketinfo.fallStop=data.marketinfo.nowOpen*1-0.0003; // } $scope.buyInfo = data.marketinfo;//后台获取的正确的值 //console.log($scope.buyInfo.buyprice-$scope.buyInfo.nowOpen,"打印");//打印 $scope.buyInfo.price=$scope.buyInfo.price; if(!$scope.sellprice ){ $scope.sellprice= $filter('number')($scope.buyInfo.buyprice,$scope.floatMax);//卖出价格 } if(!$scope.buypriceAnother){ $scope.buypriceAnother=$filter('number')( $scope.buyInfo.buyprice,$scope.floatMax);//购买价格 } $scope.productSid=data.marketinfo.sid;//用来判断数量的问题 if($scope.productSid=='80011'){ $scope.sellNum = 10; $scope.buyNum=10; }else{ $scope.sellNum = numProREset; $scope.buyNum=numProREset; } $scope.buyMoney = $scope.buypriceAnother * $scope.buyNum; $scope.sellMoney = $scope.sellprice * $scope.sellNum; if (dataTemp.HighestPrice == 0) { $scope.buyInfo.HighestPrice = dataTemp.riseStop; } if (dataTemp.LowestPrice == 0) { $scope.buyInfo.LowestPrice = dataTemp.fallStop; } //拼合分时信息 $scope.dataDaPanMinute.data.MarketInfo.ProductId = 0;//产品ID $scope.dataDaPanMinute.data.MarketInfo.ProductName = data.marketinfo.title;//产品名称 //用来做页面判断 $scope.dataDaPanMinute.data.MarketInfo.ProductCode = data.marketinfo.sid;//产品编号 $scope.dataDaPanMinute.data.MarketInfo.IncreaseRate = (data.marketinfo.buyprice-data.marketinfo.nowOpen)/data.marketinfo.nowOpen; $scope.dataDaPanMinute.data.MarketInfo.Increase = data.marketinfo.buyprice-data.marketinfo.nowOpen; $scope.dataDaPanMinute.data.MarketInfo.ProductImage = null;//产品图片 $scope.dataDaPanMinute.data.MarketInfo.Price = data.marketinfo.buyprice;//现价 $scope.dataDaPanMinute.data.MarketInfo.OpenPrice = data.marketinfo.nowOpen;//开盘价 $scope.dataDaPanMinute.data.MarketInfo.HighestPrice = data.marketinfo.HighestPrice;//最高价 $scope.dataDaPanMinute.data.MarketInfo.LowestPrice = data.marketinfo.LowestPrice;//最低价 $scope.dataDaPanMinute.data.MarketInfo.LimitUp = data.marketinfo.riseStop;//涨停 $scope.dataDaPanMinute.data.MarketInfo.LimitDown = data.marketinfo.fallStop;//跌停 $scope.dataDaPanMinute.data.MarketInfo.Volume = data.marketinfo.successNum;//成交数量 //手续费 $scope.FeeSell = $scope.sellMoney * ($scope.buyInfo.fee*1); }, function (data) { if(data.code==403){ layer.msg(data.msg); $rootScope.loginExit(); }else{ layer.msg(data.msg); } }); } $scope.getPriceREload(); //获得商品列表 Market.productList().then(function (data) { $scope.pageDataList = data; },function (data) { if(data.code==403){ layer.msg(data.msg); $rootScope.loginExit(); }else{ layer.msg(data.msg); } }); //重生设置 $scope.haveChongSheng = true; if ($stateParams.title == '种子') { $scope.haveChongSheng = false; } //键盘弹起的时候判断是数字还是其他 $scope.keyFun = function (val, type) {//价格 /* if(val*1<1){//针对小数处理 var num=val.indexOf('.'); if(num!=1){ val=('0'+val)*1; } val=$filter('limitTo')(val,6); }*/ if (type == 1) { $scope.buypriceAnother = val;//$filter('number')(val,$scope.floatMax); $scope.changeNumber($scope.buyNum, 1); } else if (type == 2) { $scope.sellprice = val;//$filter('number')(val,$scope.floatMax); $scope.changeNumber($scope.sellNum, 2); } } $scope.keyUpChangePrice = function (val, type) {//数量 var numProREset=$scope.numLimitPro==""?100:$scope.numLimitPro; if (type == 1) {//买 if (val < 0) { $scope.buyNum = numProREset; } $scope.buyMoney = $scope.buypriceAnother * $scope.buyNum; } else if (type == 2) {//卖 if (val < 0) { $scope.sellNum = numProREset; } $scope.sellMoney = $scope.sellprice * $scope.sellNum; $scope.FeeSell = fixedFun($scope.sellMoney * ($scope.buyInfo.fee*numProREset)/numProREset); } } //买卖价格涨停跌停范围限制 $scope.changePrice = function (price, type) {//blur $scope.inputBlueStop=true; $scope.priceTimer=$interval(function () { $scope.getPriceREload(); }, 5000); price = Number(price); if (price *1 > $scope.buyInfo.riseStop*1|| price *1 < $scope.buyInfo.fallStop*1) { layer.msg("委托价格不在今日涨跌停范围内"); $scope.changePriceReturn=false; }else{ $scope.changePriceReturn=true; } }; if ($stateParams.pid) { //大盘数据画图 $scope.refreshFroduct = function () {//大盘数据函数 Market.product($stateParams.pid).then(function (data) { //图表绘制 // $scope.charts.series = data.KLineList; //获取数据,赋值 $scope.dataDaPanRi.data.MarketInfo = $scope.dataDaPanMinute.data.MarketInfo angular.forEach(data.KLineList, function (v, k) { $scope.dataDaPanRi.data.KLineList[k] = v }); //画日K Candle($scope.dataDaPanRi,$scope.floatMax); },function (data) { if(data.code==403){ layer.msg(data.msg); $rootScope.loginExit(); }else{ layer.msg(data.msg); } }); } $scope.refreshFroduct();//大盘数据(ri K) //分时 //分时 日式切换; $scope.dayOrMinuteChecked = "dayChecked";// $scope.dayOrMinuteFun = function (val) { $scope.dayOrMinuteChecked = val; if (val == 'dayChecked') {//日K刷新 调用kline.js 文件函数 $scope.refreshFroduct();//大盘数据 } ; if (val == 'minuteChecked') {//分时刷新 var minute = new Date().getTime(); Market.getMinuteData($stateParams.pid, minute).then(function (data) { //图表绘制 // $scope.charts.series = data.KLineList; //获取数据,赋值 $scope.dataDaPanMinute.data.SysDT = minute;//当前的分时数据 angular.forEach(data, function (v, k) { if (v.Price == null) { v.Price = 0; } if (v.Volume == null) { v.Volume = 0; } }); $scope.dataDaPanMinute.data.TimeShare = data; //画分时 Minute($scope.dataDaPanMinute); },function (data) { if(data.code==403){ layer.msg(data.msg); $rootScope.loginExit(); }else{ layer.msg(data.msg); } }); } } //获取刷新最新委托 $scope.inputBlueStop=true;//获得焦点的时候为false 反之true $scope.inputBlueStopFun=function () { $scope.inputBlueStop=false; $interval.cancel($scope.priceTimer);//清除定时期 } //委托信息重新修改 委托函数 $scope.weiTuoNew=function(){ var numArr=['一','二','三','四','五']; $scope.entrustData={'sell':[],'buy':[]};//数据 for(var i=0;i<5;i++){ $scope.entrustData.sell[i]={}; $scope.entrustData.buy[i]={}; $scope.entrustData.sell[i].title='卖'+numArr[i]; $scope.entrustData.buy[i].title='买'+numArr[i]; $scope.entrustData.buy[i].price=$scope.entrustData.sell[i].price=0; $scope.entrustData.buy[i].num=$scope.entrustData.sell[i].num='--'; } } $scope.weiTuoNew(); $scope.refreshFun = function () { $scope.changePriceReturn=true; Market.newEntrust($stateParams.pid).then(function (data) {//success $scope.weiTuoNew();//委托函数 for(var i=0;i<5;i++){ $scope.entrustData.sell[i].num=data['sell'][i]?data['sell'][i].num:'--'; $scope.entrustData.sell[i].price=data['sell'][i]?data['sell'][i].price:0; $scope.entrustData.buy[i].num=data['buy'][i]?data['buy'][i].num:'--'; $scope.entrustData.buy[i].price=data['buy'][i]?data['buy'][i].price:0; } var tempSell=[]; for(var i=0;i<5;i++){ tempSell.push($scope.entrustData.sell[4-i]); } $scope.entrustData.sell=tempSell; if($scope.inputBlueStop){ //设定卖出的价格 if (data["buy"].length>0) { // data["buy"]=$filter('orderBy')(data["buy"],'price','true'); $scope.sellprice = $filter('number')(data["buy"][0].price,$scope.floatMax); }else{ $scope.sellprice=$filter('number')($scope.buyInfo.buyprice,$scope.floatMax); } $scope.sellMoney = $scope.sellprice * $scope.sellNum; //手续费 $scope.FeeSell = $scope.sellMoney * ($scope.buyInfo.fee*1); //设定买入的价格 if (data["sell"].length>0) { var num=data["sell"].length; $scope.buypriceAnother = $filter('number')(data["sell"][0].price,$scope.floatMax); }else{ $scope.buypriceAnother=$filter('number')($scope.buyInfo.buyprice,$scope.floatMax); } $scope.buyMoney = $scope.buypriceAnother * $scope.buyNum; }; }, function (data) { if(data.code==403){ layer.msg(data.msg); $rootScope.loginExit(); }else{ layer.msg(data.msg); } }); } $scope.refreshFun(); //委托信息 当前 - 历史 $scope.getEntrustList = function () { Market.entrustHistory($stateParams.pid).then(function (data) {//success $scope.entrustNew = data['newlist'];//当前 $scope.pageTotalNum = Math.ceil(data['oldlist'].length / 10); $scope.pageDataOld = data['oldlist'];//元数据 $scope.currentPageNews = 1; $scope.getNewsList(1); }, function (data) { if(data.code==403){ layer.msg(data.msg); $rootScope.loginExit(); }else{ layer.msg(data.msg); } }); } $scope.getEntrustList(); //分页制作 $scope.currentPageNews = 1; $scope.pageInput = function (num) {//页码校验 var num = parseInt(num); $scope.currentPageNews = num; if ($scope.currentPageNews >= $scope.pageTotalNum || $scope.currentPageNews <= 0) { if ($scope.currentPageNews >= $scope.pageTotalNum) { $scope.currentPageNews = $scope.pageTotalNum; } else if ($scope.currentPageNews <= 0) { $scope.currentPageNews = 1; } } return $scope.currentPageNews; ; }; // 点击获取列表数据 $scope.goToGetList = function () { return { homePage: function () {//首页 if ($scope.currentPageNews == 1) { $scope.currentPageNews = 1; return false; } $scope.currentPageNews = 1; $scope.getNewsList($scope.currentPageNews);//获取数据 }, lasePage: function () {//末页 if ($scope.currentPageNews == $scope.pageTotalNum) { $scope.currentPageNews = $scope.pageTotalNum; return false; } $scope.currentPageNews = $scope.pageTotalNum; $scope.getNewsList($scope.currentPageNews);//获取数据 }, nextPage: function () {//下一页 $scope.currentPageNews += 1; if ($scope.currentPageNews > $scope.pageTotalNum) { $scope.currentPageNews = $scope.pageTotalNum return false; } $scope.getNewsList($scope.currentPageNews);//获取数据 }, prePage: function () {//上一页 $scope.currentPageNews -= 1; if ($scope.currentPageNews <= 0) { $scope.currentPageNews = 1; return false; } $scope.getNewsList($scope.currentPageNews);//获取数据 }, goToPageFun: function () { $scope.getNewsList($scope.currentPageNews);//获取数据 } } }(); $scope.getNewsList = function (pageNum, num) {//对数据分页 var num = num ? num : 10;//显示条数 var startPos = (pageNum - 1) * num; var totalNum = $scope.pageTotalNum; var newData = []; for (var i = startPos; i < (startPos + num); i++) { if ($scope.pageDataOld[i] == undefined || $scope.pageDataOld[i] == null || $scope.pageDataOld[i] == '') { break; } newData.push($scope.pageDataOld[i]); } angular.forEach(newData, function (v, k) { if (v.dealnum == v.number) { v.statusName = '完全成交'; } else if (v.dealnum == 0) { v.statusName = '已撤销'; } else if (v.number - v.dealnum > 0) { v.statusName = '未完全成交'; } }); $scope.entrustOld = newData;//历史纪录 } //撤销委托 $scope.cancelEntrustWait = true; $scope.cancelEntrust = function (id) { if ($scope.cancelEntrustWait) { $scope.cancelEntrustWait = false; Market.cancelFun(id).then(function (data) {//success layer.msg(data.msg); $scope.cancelEntrustWait = true; $scope.getPriceREload(); $scope.refreshFroduct();//大盘 $scope.refreshFun();//卖五卖五 $scope.getEntrustList();//委托记录 }, function (data) { if(data.code==403){ layer.msg(data.msg); $rootScope.loginExit(); }else{ layer.msg(data.msg); } }) } } } ; //买入卖出百分比显示及数量百分比计算 $scope.showPcent1 = false; $scope.showPcent2 = false; $scope.Persent = 1;//百分比 $scope.toggle = function (type) { $scope.inputBlueStopFun(); if (type == 1) { $scope.showPcent1 = !$scope.showPcent1; } else if (type == 2) { $scope.showPcent2 = !$scope.showPcent2 } }; //点击百分比重新计算数量及价格 $scope.persentFun = function (val, type) { $scope.Persent = val; if (type == 1) {//买入 var money=$scope.buyInfo.gold*val; $scope.buyNum = money/$scope.buypriceAnother; $scope.showPcent1 = !$scope.showPcent1; $scope.changeNumber($scope.buyNum, 1); } else if (type == 2) {//卖出 var haveProNum=$scope.buyInfo.num; $scope.sellNum = Number(haveProNum)* Number(val); $scope.showPcent2 = !$scope.showPcent2; $scope.changeNumber($scope.sellNum, 2); } ; } $scope.changeNumber = function (num, type,value) {// if(value=='true'){ $scope.inputBlueStop=true; $scope.priceTimer=$interval(function () { $scope.getPriceREload(); }, 5000); } var tempNumPro = $scope.numLimitPro!=""?$scope.numLimitPro:100; if($scope.productSid=='80011'){//玫瑰 if (type == 1) {//买入 if (num % 10 != 0) { $scope.changePriceReturn=false; if (num < 10) { layer.msg("输入的数量必须为10的整数倍"); $scope.buyNum = 10; } else {//大于等于100,小数的整数部分进行计算 layer.msg("输入的数量必须为10的整数倍"); $scope.buyNum = Math.floor(num / 10) * 10; if ($scope.buypriceAnother * $scope.buyNum > $scope.buyInfo.gold) { layer.msg("您的金币不足,请充值!"); $scope.buyNum = Math.floor($scope.buyInfo.gold / ($scope.buypriceAnother * 10)) * 10; } } } else { if ($scope.buypriceAnother * $scope.buyNum > $scope.buyInfo.gold) { layer.msg("您的金币不足,请充值!"); $scope.changePriceReturn=false; $scope.buyNum = Math.floor($scope.buyInfo.gold / ($scope.buypriceAnother * 10)) * 10; } } $scope.buyMoney = $scope.buypriceAnother * $scope.buyNum; } else if (type == 2) {//卖出 if (num % 10 != 0) {//sellNum 卖出数量 buyInfo.num sellMoney $scope.changePriceReturn=false; if (num < 10) { layer.msg("输入的数量必须为10的整数倍"); $scope.sellNum = 10; } else {//大于等于100,小数的整数部分进行计算 layer.msg("输入的数量必须为10的整数倍"); $scope.sellNum = Math.floor(num / 10) * 10; if ($scope.sellNum > $scope.buyInfo.num) { layer.msg("持有量不足!") $scope.sellNum = Math.floor($scope.buyInfo.num / 10) * 10; } } } else { if ($scope.sellNum > $scope.buyInfo.num) { layer.msg("持有量不足!") $scope.changePriceReturn=false; $scope.sellNum = Math.floor($scope.buyInfo.num / 10) * 10; } } $scope.sellMoney = $scope.sellprice * $scope.sellNum; $scope.FeeSell = fixedFun($scope.sellMoney * ($scope.buyInfo.fee*10)/10); } }else{ if (type == 1) {//买入 if (num % tempNumPro != 0) { $scope.changePriceReturn=false; if (num < tempNumPro) { layer.msg("输入的数量必须为"+tempNumPro+"的整数倍"); $scope.buyNum = tempNumPro; } else {//大于等于100,小数的整数部分进行计算 layer.msg("输入的数量必须为"+tempNumPro+"的整数倍"); $scope.buyNum = Math.floor(num / tempNumPro) * tempNumPro; if ($scope.buypriceAnother * $scope.buyNum > $scope.buyInfo.gold) { layer.msg("您的金币不足,请充值!"); $scope.buyNum = Math.floor($scope.buyInfo.gold / ($scope.buypriceAnother * tempNumPro)) * tempNumPro; } } } else { if ($scope.buypriceAnother * $scope.buyNum > $scope.buyInfo.gold) { layer.msg("您的金币不足,请充值!"); $scope.changePriceReturn=false; $scope.buyNum = Math.floor($scope.buyInfo.gold / ($scope.buypriceAnother * tempNumPro)) * tempNumPro; } } $scope.buyMoney = $scope.buypriceAnother * $scope.buyNum; } else if (type == 2) {//卖出 if (num % tempNumPro != 0) {//sellNum 卖出数量 buyInfo.num sellMoney $scope.changePriceReturn=false; if (num < tempNumPro) { layer.msg("输入的数量必须为"+tempNumPro+"的整数倍"); $scope.sellNum = tempNumPro; } else {//大于等于100,小数的整数部分进行计算 layer.msg("输入的数量必须为"+tempNumPro+"的整数倍"); $scope.sellNum = Math.floor(num / tempNumPro) * tempNumPro; if ($scope.sellNum > $scope.buyInfo.num) { layer.msg("持有量不足!") $scope.sellNum = Math.floor($scope.buyInfo.num / tempNumPro) * tempNumPro; } } } else { if ($scope.sellNum > $scope.buyInfo.num) { layer.msg("持有量不足!") $scope.changePriceReturn=false; $scope.sellNum = Math.floor($scope.buyInfo.num / tempNumPro) * tempNumPro; } } $scope.sellMoney = $scope.sellprice * $scope.sellNum; $scope.FeeSell = fixedFun($scope.sellMoney * ($scope.buyInfo.fee*tempNumPro)/tempNumPro); } } } //买卖提交 $scope.orderRepeat=true;//提交订单重复限制 $scope.BuyPersent = function (type) { var tempNumPro = $scope.numLimitPro!=""?$scope.numLimitPro:100; /*var tempTime=new Date(); var tempHour=tempTime.getHours(); if(tempHour<9){ layer.msg("大盘交易还未开启,请等待……"); return; }*/ if(!$scope.changePriceReturn){ return false; } $scope.inputBlueStopFun(); if($scope.productSid=='80011'){//玫瑰 if (type == 'buy') {//买 if ($scope.buyNum % 10 != 0) { layer.msg("交易数量为10的整数倍!请重新输入"); return false; } ; if ($scope.buyInfo.gold - $scope.buyMoney < 0) { layer.msg("您的金币不足!") return false; } if($scope.buypriceAnother *1> $scope.buyInfo.riseStop*1|| $scope.buypriceAnother *1< $scope.buyInfo.fallStop*1){ layer.msg("委托价格不在今日涨跌停范围内"); return false; } layer.confirm("买入价格:" + $scope.buypriceAnother + "
买入数量:" + $scope.buyNum + "
总计金币:" + $filter('number')($scope.buyMoney,$scope.floatMax), { btn: ['确定', '取消'], title: '果园' }, function () {//确定 if($scope.orderRepeat){ $scope.priceTimer=$interval(function () { $scope.getPriceREload(); }, 5000); $scope.orderRepeat=false; Market.detailProduct($scope.buypriceAnother, $scope.buyNum, $scope.buyMoney, type, $stateParams.pid).then(function (data) { // 刷新数据 layer.msg(data.msg); $scope.buyNum = 10; $scope.refreshFroduct();//大盘 $scope.refreshFun();//卖五卖五 $scope.getEntrustList();//委托记录 $scope.getPriceREload();//重新获取最新基础数据 $scope.inputBlueStop=true; $scope.dayOrMinuteChecked = "dayChecked";//重置日卡选中 $timeout(function(){ $scope.orderRepeat=true; },1500); }, function (data) { if(data.code==403){ layer.msg(data.msg); $rootScope.loginExit(); }else{ layer.msg(data.msg); } $scope.inputBlueStop=true; $timeout(function(){ $scope.orderRepeat=true; },1500); $scope.priceTimer=$interval(function () { $scope.getPriceREload(); }, 5000); }) } },function(){//取消 $scope.changePrice($scope.buypriceAnother,1); $scope.orderRepeat=true; $scope.priceTimer=$interval(function () { $scope.getPriceREload(); }, 5000); }) } else if (type == 'sell') {//卖 if ($scope.sellNum % 10 != 0) { layer.msg("交易数量为10的整数倍!请重新输入"); return; } if ($scope.buyInfo.num - $scope.sellNum <0) { layer.msg("您的持有量不足!"); return; } if($scope.sellprice *1> $scope.buyInfo.riseStop*1 || $scope.sellprice *1 <$scope.buyInfo.fallStop*1){ layer.msg("委托价格不在今日涨跌停范围内"); return false; } layer.confirm("卖出价格:" + $scope.sellprice + "
卖出数量:" + $scope.sellNum + "
总计金币:" + $filter('number')($scope.sellMoney,$scope.floatMax) + "
手续费:" + $filter('number')($scope.FeeSell,$scope.floatMax), { btn: ['确定', '取消'], title: '果园' }, function () { if($scope.orderRepeat){ $scope.priceTimer=$interval(function () { $scope.getPriceREload(); }, 5000); $scope.orderRepeat=false; Market.detailProduct($scope.sellprice, $scope.sellNum, $scope.sellMoney, type, $stateParams.pid).then(function (data) { //刷新数据 layer.msg(data.msg); $scope.sellNum = 10; $scope.refreshFroduct();//大盘 $scope.refreshFun();//卖五卖五 $scope.getEntrustList();//委托记录 $scope.getPriceREload();//重新获取最新基础数据 $scope.inputBlueStop=true; $scope.dayOrMinuteChecked = "dayChecked";//重置日卡选中 $timeout(function(){ $scope.orderRepeat=true; },1500); }, function (data) { if(data.code==403){ layer.msg(data.msg); $rootScope.loginExit(); }else{ layer.msg(data.msg); } $scope.inputBlueStop=true; $timeout(function(){ $scope.orderRepeat=true; },1500); // Auth.loginExit(); }); } },function(){ $scope.changePrice($scope.sellprice,2); $scope.orderRepeat=true; $scope.priceTimer=$interval(function () { $scope.getPriceREload(); }, 5000); }) } }else{//处理不是玫瑰 if (type == 'buy') {//买 if ($scope.buyNum % tempNumPro != 0) { layer.msg("交易数量为"+tempNumPro+"的整数倍!请重新输入"); return; } ; if ($scope.buyInfo.gold - $scope.buyMoney < 0) { layer.msg("您的金币不足!") return; } if($scope.buypriceAnother *1> $scope.buyInfo.riseStop *1 || $scope.buypriceAnother *1 < $scope.buyInfo.fallStop*1){ layer.msg("委托价格不在今日涨跌停范围内"); return false; } layer.confirm("买入价格:" + $scope.buypriceAnother + "
买入数量:" + $scope.buyNum + "
总计金币:" + $filter('number')($scope.buyMoney,$scope.floatMax), { btn: ['确定', '取消'], title: '果园' }, function () {//确定 if($scope.orderRepeat){ $scope.priceTimer=$interval(function () { $scope.getPriceREload(); }, 5000); $scope.orderRepeat=false; Market.detailProduct($scope.buypriceAnother, $scope.buyNum, $scope.buyMoney, type, $stateParams.pid).then(function (data) { // 刷新数据 layer.msg(data.msg); $scope.buyNum = tempNumPro; $scope.refreshFroduct();//大盘 $scope.refreshFun();//卖五卖五 $scope.getEntrustList();//委托记录 $scope.getPriceREload();//重新获取最新基础数据 $scope.inputBlueStop=true; $scope.dayOrMinuteChecked = "dayChecked";//重置日卡选中 $timeout(function(){ $scope.orderRepeat=true; },1500); }, function (data) { if(data.code==403){ layer.msg(data.msg); $rootScope.loginExit(); }else{ layer.msg(data.msg); } $scope.inputBlueStop=true; $timeout(function(){ $scope.orderRepeat=true; },1500); }) } },function(){//取消 $scope.changePrice($scope.buypriceAnother,1); $scope.orderRepeat=true; $scope.priceTimer=$interval(function () { $scope.getPriceREload(); }, 5000); }) } else if (type == 'sell') {//卖 if ($scope.sellNum % tempNumPro != 0) { layer.msg("交易数量为"+tempNumPro+"的整数倍!请重新输入"); return; } if ($scope.buyInfo.num - $scope.sellNum < 0) { layer.msg("您的持有量不足!"); return; } if($scope.sellprice *1> $scope.buyInfo.riseStop *1 || $scope.sellprice *1 < $scope.buyInfo.fallStop *1){ layer.msg("委托价格不在今日涨跌停范围内"); return false; } layer.confirm("卖出价格:" + $scope.sellprice + "
卖出数量:" + $scope.sellNum + "
总计金币:" + $filter('number')($scope.sellMoney,$scope.floatMax) + "
手续费:" + $filter('number')($scope.FeeSell,$scope.floatMax), { btn: ['确定', '取消'], title: '果园' }, function () { if($scope.orderRepeat){ $scope.priceTimer=$interval(function () { $scope.getPriceREload(); }, 5000); $scope.orderRepeat=false; Market.detailProduct($scope.sellprice, $scope.sellNum, $scope.sellMoney, type, $stateParams.pid).then(function (data) { //刷新数据 layer.msg(data.msg); $scope.sellNum = tempNumPro; $scope.refreshFroduct();//大盘 $scope.refreshFun();//卖五卖五 $scope.getEntrustList();//委托记录 $scope.getPriceREload();//重新获取最新基础数据 $scope.inputBlueStop=true; $scope.dayOrMinuteChecked = "dayChecked";//重置日卡选中 $timeout(function(){ $scope.orderRepeat=true; },1500); }, function (data) { if(data.code==403){ layer.msg(data.msg); $rootScope.loginExit(); }else{ layer.msg(data.msg); } $scope.inputBlueStop=true; $timeout(function(){ $scope.orderRepeat=true; },1500); // Auth.loginExit(); }); } },function(){ $scope.changePrice($scope.sellprice,2); $scope.orderRepeat=true; $scope.priceTimer=$interval(function () { $scope.getPriceREload(); }, 5000); }) } } }; //自动刷新 $scope.refreshAuto = false;//0 手动刷新(默认), 1 自动刷新 $scope.refreshClcik = function () { $scope.refreshAuto = !$scope.refreshAuto; if ($scope.refreshAuto) { var timer = $interval(function () { $scope.refreshFroduct();//大盘 }, 5000); $scope.$on("$destroy", function () { $interval.cancel(timer); }) } }; //实时刷新一些数据 var timerList = $interval(function () { $scope.refreshFun();//卖五卖五 }, 5000); $scope.priceTimer=$interval(function () { $scope.getPriceREload(); }, 5000); $scope.$on("$destroy", function () { $interval.cancel(timerList);//清除定时期 $interval.cancel($scope.priceTimer);//清除定时期 }) //委托列表刷新 $scope.FlushMyEntrust=function(){ $scope.getEntrustList();//委托记录 } } }) }); });