Ejemplo n.º 1
0
	// 计算当前总值
	function totalValue()
	{
		var stockNum = $(_pageId + "#stockNum").val();
		var stockCode = $(_pageId + ".trade_form2 .info_box small").text().substring(0, 6);
		var stockPrice = $(_pageId + "#stockPrice").val();
		if (stockCode && validatorUtil.isNumberFloat(stockPrice) && validatorUtil.isNumeric(stockNum))
		{
			$(_pageId + ".ce_btn small").show();
			$(_pageId + ".ce_btn small").text("(¥" + common.numToMoneyType("" + (stockPrice * stockNum).toFixed(blxiaoshuNum)) + ")");
		} else
		{
			$(_pageId + ".ce_btn small").hide();
		}
	}
Ejemplo n.º 2
0
		appUtils.bindEvent($(_pageId + ".form_box .input_value2:eq(0) .less"), function(e)
		{
			if ($(_pageId + "#stockPrice").attr("disabled") != "disabled")
			{

				var stockCode = $(_pageId + ".trade_form2 .info_box small").text();

				if (stockCode && stockCode.length > 0)
				{
					var curPrice = $(_pageId + "#stockPrice").val();
					if (curPrice == "" || !validatorUtil.isNumberFloat(curPrice))
					{
						$(_pageId + "#stockPrice").val("");
						return false;
					}
					curPrice = Number(curPrice);
					if (curPrice >= 0 && curPrice < 999999999)
					{
						curPrice = ((parseFloat(curPrice) - parseFloat(keepDPdecimal)).toFixed(blxiaoshuNum));
						$(_pageId + "#stockPrice").val(curPrice);
					}
				} else
				{
					layerUtils.iAlert("当前禁止操作!");
					return false;
				}
				totalValue();
				var stockPrice = $(_pageId + "#stockPrice").val();
				var needDatas = "1,3,4,5,7"; // 价格变动的时候需要
				// 查询最大可买的页面
				// 同_orderType
				if (stockPrice && stockPrice != "0" && needDatas.indexOf(_orderType) != -1)
				{
					var stockCode = $(_pageId + ".trade_form2 .info_box small").text().substring(0, 6);
					queryMaxAmount(stockCode, stkType);
				}
			}
			e.stopPropagation();
		}, "touchstart");
Ejemplo n.º 3
0
	/**
	 * 股票买卖委托下单(普通)
	 * */
	function entrustStock(){
		if(stock_code.length != 6){
			layerUtils.iAlert("请输入正确的股票代码");
			return false;
		}
		if(!validator.isNumeric(stock_code)){
			layerUtils.iAlert("请输入正确的股票代码");
			return false;
		}
		
		//验证价格
		var now_price = $(_pageId+"#price ").val();
		if (now_price.substring(now_price.length-1,now_price.length) == "."){
			now_price = now_price.substring(0,now_price.length-1);
			//去掉小数点
			$(_pageId+"#price").val(now_price);
		}
		now_price = Number($(_pageId+"#price ").val());
		if(now_price.length == 0)
		{
			layerUtils.iAlert("请输入正确的价格");
			return false;
		}
		if((!validator.isNumberFloat(now_price)) || parseFloat(now_price) <= 0)
		{
			layerUtils.iAlert("请输入正确的价格");
			return false;
		}
		var up_stop = Number($(_pageId + " #up_limit").html());
		var down_stop = Number($(_pageId + " #down_limit").html());
		if(now_price > up_stop){
			layerUtils.iAlert("委托价格超出涨停价格"+up_stop+"!");
			return false;
		}
		if(now_price < down_stop){
			layerUtils.iAlert("委托价格超出跌停价格"+down_stop+"!");
			return false;
		}
		
		var amount = $(_pageId + "#amount").val();
		if(amount.length==0)
		{
			layerUtils.iAlert("请输入委托数量");
			return false;
		}
		if(!validator.isNumeric(amount)||amount <= 0)
		{
			layerUtils.iAlert("输入的委托数量无效");
			return false;
		}
		amount = Number(amount);
		
		//获取最大可买数量,最大可买根据委托价格和账户余额相关
		var tradingVolume = $(_pageId+"#maxBuy").html();
		//无购买数量
		if(tradingVolume == "--"){
			layerUtils.iAlert("可买数量不足");
			return false;
		}
		//购买数量大于最大可买数量
		if(amount > tradingVolume){
			layerUtils.iAlert("购买数量大于最大可买数量");
			return false;
		}
		//购买数量必须是100的整数倍
		if(amount % 100 != 0 ){
			layerUtils.iAlert("买入数量必须为100的整数倍");
			return false;
		}
		
		var btn = "买入";
		var tipStr ="<h2 style=\"padding:5px 0;border-bottom: 1px solid #AAA;\">委托买卖</h2>";
		tipStr+="<dl><dt  style=\"text-align: center;margin: 10px 0;\">您是否确认下单?</dt>";
		tipStr+="<div  style=\"text-align: left;padding-left: 35%;\">";
		tipStr+= stock_name+" "+stock_code;
		tipStr+="<br>买卖方向:"+btn;
		tipStr+="<br>委托价格:"+(now_price).toFixed(2);
		tipStr+="<br>委托数量:"+amount;
		tipStr+="</div>";
		tipStr+="</dl>";
		layerUtils.iConfirm(tipStr, null, function success(){	
			doneEntrust();//确认下单		
		}, "取消", "确定");
		$("#pop_tip_confirm").find("p").css("padding","5px");//修改提示框的边框高度
		
	}
Ejemplo n.º 4
0
	/**
	 * 下单验证
	 */
	function vailSubmitOrder()
	{
		var typeText = "买入";
		if (_orderType == "1" || _orderType == "3" || _orderType == "5" || _orderType == "7")
		{
			typeText = "买入";
		} else
		{
			typeText = "卖出";
		}

		// 股票代码
		var buy_stockCode = $(_pageId + ".trade_form2 .info_box small").text();

		// 验证股票价格输入是否正确
		var now_price = $(_pageId + "#stockPrice").val();
		if ($.trim(now_price).length <= 0)
		{
			layerUtils.iMsg(-1, "请输入" + typeText + "价格");
			return false;
		} else if (!validatorUtil.isNumberFloat(now_price))
		{
			layerUtils.iMsg(-1, "请正确输入价格");
			return false;
		}

		// 验证最大可买
		var mostBuy = $(_pageId + ".limit span:eq(0)").text();
		if ($.trim(mostBuy).length <= 0 || parseFloat(mostBuy) <= 0)
		{
			layerUtils.iMsg(-1, "最大可" + typeText + "为0");
			return false;
		}

		// 验证买入数量
		var mountBuy = $(_pageId + "#stockNum").val();
		if ($.trim(mountBuy).length <= 0)
		{
			layerUtils.iMsg(-1, "请输入" + typeText + "数量");
			return false;
		} else if (parseFloat(mountBuy) <= 0)
		{
			layerUtils.iMsg(-1, "数量必须大于0");
			return false;
		} else if (parseFloat(mostBuy) < parseFloat(mountBuy))
		{
			layerUtils.iMsg(-1, "最大可" + typeText + "数量不足");
			return false;
		}

		if (_orderType == "1")
		{
			if (mountBuy % Number(lotsOf) != 0)
			{
				layerUtils.iMsg(-1, typeText + "数量应为" + lotsOf + "的倍数");
				return false;
			} else if (mountBuy >= 1000000)
			{
				layerUtils.iMsg(-1, typeText + "数量必须小于100万股");
				return false;
			}

		} else if (_orderType == "2")
		{
			// if (mostBuy != mountBuy && mountBuy % Number(lotsOf) != 0)
			// {
			// layerUtils.iMsg(-1, "卖出数量应为" + lotsOf + "的倍数");
			// return false;
			// }
		}

		// if (Number(up_stop) < Number(now_price))
		// {
		// layerUtils.iMsg(-1, "委托价格不能超过涨停价");
		// return false;
		// }
		// if (Number(down_stop) > Number(now_price))
		// {
		// layerUtils.iMsg(-1, "委托价格不能低于跌停价");
		// return false;
		// }

		// if (Number(up_stop) < Number(now_price)||Number(down_stop) >
		// Number(now_price))
		if (Number(up_stop).toFixed(2) < Number(now_price) || Number(down_stop).toFixed(2) > Number(now_price))
		{
			var tipStr = "<div class=\"pop_header\">";
			tipStr += "<h3>交易提示</h3>";
			tipStr += "</div>";
			tipStr += "<div class=\"pop_main\">";
			tipStr += "<ul>";
			tipStr += "    <li> <strong>您输入的价格已超出涨跌停限制:[" + Number(down_stop).toFixed(2) + "-" + Number(up_stop).toFixed(2) + "]是否继续该笔委托?</strong></li>";
			tipStr += "</ul>";
			tipStr += "  </div>";
			common.btnConfirm(tipStr, function success()
			{
				getStockBuy();
			}, function fail()
			{
				return;
			});
		} else
		{
			getStockBuy();
		}

		function getStockBuy()
		{
			var exchange_type = _market;

			var entrust_bs = "";

			var page_name = appUtils.getSStorageInfo("_curPageCode", "");
			if (page_name == "stock/stockBuy" && $(_pageId + ".form_box .input_select .select_box p").text() == "限价委托")
			{
				entrust_bs = "0";
			} else if (page_name == "stock/stockSell" && $(_pageId + ".form_box .input_select .select_box p").text() == "限价委托")
			{
				entrust_bs = "1";
			} else
			{
				entrust_bs = $(_pageId + ".form_box .input_select .select_box p").attr("id");
			}

			var tipStr = "<div class=\"pop_header\">";
			tipStr += "<h3>" + orderName[_orderType] + "</h3>";
			tipStr += "</div>";
			tipStr += "<div class=\"pop_main\">";
			tipStr += "<ul>";

			if(buy_stockCode=="002441")
			{
				tipStr += "    <li>证券名称 <em>" + "众业达" + "</em></li>";
				tipStr += "    <li>证券代码 <strong>" + buy_stockCode + "</strong></li>";
			}
			else
			{
				tipStr += "    <li>证券名称 <em>" + $(_pageId + ".trade_form2 .info_box h5").text() + "</em></li>";
				tipStr += "    <li>证券代码 <strong>" + buy_stockCode + "</strong></li>";
			}


			if (entrust_bs == "0" || entrust_bs == "1")
			{
				tipStr += "<li>委托价格 <strong>" + now_price + "</strong></li>";
			} else
			{
				tipStr += "<li>委托价格 <strong>" + $(_pageId + ".form_box .input_select .select_box p").text() + "</strong></li>";
			}
			tipStr += "    <li>委托数量 <strong>" + mountBuy + "</strong></li>";
			tipStr += "</ul>";
			tipStr += "  </div>";

			common.btnConfirm(tipStr, function success()
			{
				var cust_code = userInfo.cust_code; // 客户代码
				var fund_account = userInfo.fund_account; // 资产账户
				var branch_no = userInfo.branch_no; // 分支机构
				var sessionid = userInfo.session_id;
				var entrust_way = global.entrust_way; // 委托方式 在configuration配置
				var stock_account = _stockAccount;
				var stock_code = buy_stockCode;
				var entrust_price = now_price;
				var entrust_amount = mountBuy;
				var param =
				{
					"entrust_way" : entrust_way,
					"branch_no" : branch_no,
					"fund_account" : fund_account,
					"cust_code" : cust_code,
					"sessionid" : sessionid,
					"entrust_bs" : entrust_bs,
					"exchange_type" : exchange_type,
					"stock_account" : stock_account,
					"stock_code" : stock_code,
					"entrust_price" : entrust_price,
					"entrust_amount" : entrust_amount,
				};
				if (_orderType == "1" || _orderType == "2")
				{
					service_stock.getStockBuy(param, getStockBuyCallBack);
				} else
				{
					param.entrust_type = entrustType[_orderType];
					service_credit.entrust_trade(param, getStockBuyCallBack);
				}
			}, function fail()
			{
			});
		}
	}