UNPKG

lixin-web

Version:

vue and bootstrap

518 lines (508 loc) 14.6 kB
var Lottery3d = function(){ /** * 彩票投注辅助 */ var LotteryUtils = function() { /** * 输入框类型检测 */ var _inputCheck_Num = function(datasel, l, fun, sort) { fun = $.isFunction(fun) ? fun : function(n, l) { return true; } var newsel = []; // 新的号码 if(sort) { // 如果需要号码排序 var sortsel = []; $.each(datasel, function(i, n) { sortsel.push(n.split('').sort().toString().replace(/\,/g, '')); }); datasel = sortsel; } datasel = ArrayUtil.unique(datasel); // 去除重复 var regex = new RegExp('^[0-9]{' + l + '}$'); $.each(datasel, function(i, n) { if(regex.test(n) && fun(n, l)) { newsel.push(n); } }); return newsel; } /** * 和值检测 */ var _HHZXCheck_Num = function(n, l) { var a = new Array(); if (l == 2) {//两位 a = [ '00', '11', '22', '33', '44', '55', '66', '77', '88', '99' ]; } else {//三位[默认] a = [ '000', '111', '222', '333', '444', '555', '666', '777', '888', '999' ]; } return $.inArray(n, a) == -1 ? true : false; }; /** * 多少注计算 */ var _inputNumbers = function(type, datasel) { var nums = 0, tmp_nums = 1; // 输入号 switch (type) { case 'sanxzhixds': nums = _inputCheck_Num(datasel, 3).length; break; case 'sanxhhzx': nums = _inputCheck_Num(datasel, 3, _HHZXCheck_Num, true).length; break; case 'exzhixdsh': case 'exzhixdsq': nums = _inputCheck_Num(datasel, 2).length; break; case 'exzuxdsh': case 'exzuxdsq': nums = _inputCheck_Num(datasel, 2, _HHZXCheck_Num, true).length; break; case 'sanxzs': var maxplace = 1; for (var i = 0; i < maxplace; i++) { var s = datasel[i].length; // 组三必须选两位或者以上 if (s > 1) { nums += s * (s - 1); } } break; case 'sanxzl': var maxplace = 1; for (var i = 0; i < maxplace; i++) { var s = datasel[i].length; // 组六必须选三位或者以上 if (s > 2) { nums += s * (s - 1) * (s - 2) / 6; } } break; case 'sanxzhixhz': case 'exzhixhzh': case 'exzhixhzq': var cc = {0 : 1,1 : 3,2 : 6,3 : 10,4 : 15,5 : 21,6 : 28,7 : 36,8 : 45,9 : 55,10 : 63,11 : 69,12 : 73,13 : 75,14 : 75,15 : 73,16 : 69,17 : 63,18 : 55,19 : 45,20 : 36,21 : 28,22 : 21,23 : 15,24 : 10,25 : 6,26 : 3,27 : 1}; if(type == 'exzhixhzh' || type == 'exzhixhzq') { cc = {0 : 1,1 : 2,2 : 3,3 : 4,4 : 5,5 : 6,6 : 7,7 : 8,8 : 9,9 : 10,10 : 9,11 : 8,12 : 7,13 : 6,14 : 5,15 : 4,16 : 3,17 : 2,18 : 1}; } for (var i = 0; i < datasel[0].length; i++) { nums += cc[parseInt(datasel[0][i], 10)]; } break; case 'dwd': //定位胆所有在一起特殊处理 var maxplace = 3; for (var i = 0; i < maxplace; i++) { nums += datasel[i].length; } break; case 'exzuxfsh': case 'exzuxfsq': var maxplace = 1; for (var i = 0; i < maxplace; i++) { var s = datasel[i].length; // 二码不定位必须选两位或者以上 if (s > 1) { nums += s * (s - 1) / 2; } } break; default: var maxplace = 0; switch (type) { case "sanxzhixfs": maxplace = 3; break; case "exzhixfsh": case "exzhixfsq": maxplace = 2; break; case "yimabdw": maxplace = 1; break; } for (var i = 0; i < maxplace; i++) { // 有位置上没有选择 if (datasel[i].length == 0) { tmp_nums = 0; break; } tmp_nums *= datasel[i].length; } nums += tmp_nums; } return nums; } var _formatSelect_Num = function(datasel, m, n) { var newsel = new Array(); if(!m) m = 0; if(!n) n = 0; for (var i = 0; i < m; i++) { newsel.push('-'); } for (var i = 0; i < datasel.length; i++) { var f = datasel[i].toString().replace(/\,/g, ''); if(f == '') { newsel.push('-'); } else { newsel.push(f); } } for (var i = 0; i < n; i++) { newsel.push('-'); } return newsel.toString(); } var _formatTextarea_Num = function(type, datasel) { switch (type) { case 'sanxzhixds': datasel = _inputCheck_Num(datasel, 3); break; case 'sanxhhzx': datasel = _inputCheck_Num(datasel, 3, _HHZXCheck_Num, true); break; case 'exzhixdsh': case 'exzhixdsq': datasel = _inputCheck_Num(datasel, 2); break; case 'exzuxdsh': case 'exzuxdsq': datasel = _inputCheck_Num(datasel, 2, _HHZXCheck_Num, true); break; default: break; } return datasel.toString().replace(/\,/g, ' '); } var _inputFormat = function(type, datasel) { switch (type) { case 'sanxzhixds': case 'sanxhhzx': case 'exzhixdsh': case 'exzhixdsq': case 'exzuxdsh': case 'exzuxdsq': return _formatTextarea_Num(type, datasel); case 'sanxzs': case 'sanxzl': case 'exzuxfsh': case 'exzuxfsq': case 'yimabdw': case 'sanxzhixhz': case 'exzhixhzh': case 'exzhixhzq': return datasel.toString(); case 'sanxzhixfs': return _formatSelect_Num(datasel); case 'exzhixfsh': return _formatSelect_Num(datasel, 1); case 'exzhixfsq': return _formatSelect_Num(datasel, 0, 1); default: return _formatSelect_Num(datasel); } } var _typeFormat = function(code) { var a = [code[0], code[1], code[2]]; var _a = a.uniquelize(); var arr = []; if(_a.length == 1) arr[0] = '豹子'; if(_a.length == 2) arr[0] = '组三'; if(_a.length == 3) arr[0] = '组六'; return arr; } return { inputNumbers: _inputNumbers, inputFormat: _inputFormat, typeFormat: _typeFormat } }(); /** * TODO 彩票投注主要方法 */ var LotteryMain = function() { var that = this; LotteryBaBa.call(this); this.LotteryUtils = LotteryUtils; // 布局 this.Layout = [{ title: '三码', rows: [[{ title: '直选', columns: [{ showname: '复式', shortname: 'sanxzhixfs', realname: '[三码_复式]', tips: '从个、十、百位各选一个号码组成一注。', example: '', help: '从百位、十位、个位中选择一个3位数号码组成一注,所选号码与开奖号码相同,且顺序一致,即为中奖。', select: { layout: [{ title: '百位', balls: [0,1,2,3,4,5,6,7,8,9], tools: true }, { title: '十位', balls: [0,1,2,3,4,5,6,7,8,9], tools: true }, { title: '个位', balls: [0,1,2,3,4,5,6,7,8,9], tools: true }] } }, { showname: '单式', shortname: 'sanxzhixds', realname: '[三码_单式]', tips: '手动输入号码,至少输入1个三位数号码组成一注。', example: '', help: '手动输入一个3位数号码组成一注,所选号码与开奖号码相同,且顺序一致,即为中奖。', textarea: {} }, { showname: '直选和值', shortname: 'sanxzhixhz', realname: '[三码_和值]', tips: '从0-27中任意选择1个或1个以上号码', example: '', help: '所选数值等于开奖号码的三个数字相加之和,即为中奖。', select: { layout: [{ balls: [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27], tools: false, cls: 'hz' }] } }] }], [{ title: '组选', columns: [{ showname: '组三', shortname: 'sanxzs', realname: '[三码_组三]', tips: '从0-9中任意选择2个或2个以上号码。', example: '', help: '从0-9中选择2个数字组成两注,所选号码与开奖号码相同,且顺序不限,即为中奖。', select: { layout: [{ title: '组三', balls: [0,1,2,3,4,5,6,7,8,9], tools: true }] } }, { showname: '组六', shortname: 'sanxzl', realname: '[三码_组六]', tips: '从0-9中任意选择3个或3个以上号码。', example: '', help: '从0-9中任意选择3个号码组成一注,所选号码与开奖号码相同,顺序不限,即为中奖。', select: { layout: [{ title: '组六', balls: [0,1,2,3,4,5,6,7,8,9], tools: true }] } }, { showname: '混合组选', shortname: 'sanxhhzx', realname: '[后三码_混合组选]', tips: '手动输入号码,至少输入1个三位数号码。', example: '', help: '键盘手动输入购买号码,3个数字为一注,开奖号码符合组三或组六均为中奖。', textarea: {} }] }]] }, { title: '二码', rows: [[{ title: '后二码 直选', columns: [{ showname: '复式', shortname: 'exzhixfsh', realname: '[后二码_直选_复式]', tips: '从十、个位各选一个号码组成一注。', example: '', help: '从十位、个位中选择一个2位数号码组成一注,所选号码与开奖号码的十位、个位相同,且顺序一致,即为中奖。', select: { layout: [{ title: '十位', balls: [0,1,2,3,4,5,6,7,8,9], tools: true }, { title: '个位', balls: [0,1,2,3,4,5,6,7,8,9], tools: true }] } }, { showname: '单式', shortname: 'exzhixdsh', realname: '[后二码_直选_单式]', tips: '手动输入号码,至少输入1个两位数号码。', example: '', help: '手动输入一个2位数号码组成一注,所选号码的十位、个位与开奖号码相同,且顺序一致,即为中奖。', textarea: {} }, { showname: '直选和值', shortname: 'exzhixhzh', realname: '[后二码_直选_和值]', tips: '从0-18中任意选择1个或1个以上的和值号码。', example: '', help: '所选数值等于开奖号码的十位、个位二个数字相加之和,即为中奖。', select: { layout: [{ balls: [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18], tools: false, cls: 'hz' }] } }] }, { title: '组选', columns: [{ showname: '复式', shortname: 'exzuxfsh', realname: '[后二码_组选_复式]', tips: '从0-9中任意选择2个或2个以上号码。', example: '', help: '从0-9中选2个号码组成一注,所选号码与开奖号码的十位、个位相同,顺序不限,即中奖。', select: { layout: [{ title: '组选', balls: [0,1,2,3,4,5,6,7,8,9], tools: true }] } }, { showname: '单式', shortname: 'exzuxdsh', realname: '[后二码_组选_单式]', tips: '手动输入号码,至少输入1个两位数号码。', example: '', help: '手动输入一个2位数号码组成一注,所选号码的十位、个位与开奖号码相同,顺序不限,即为中奖。', textarea: {} }] }], [{ title: '前二码 直选', columns: [{ showname: '复式', shortname: 'exzhixfsq', realname: '[前二码_直选_复式]', tips: '从百、十位各选一个号码组成一注。', example: '', help: '从百位、十位中选择一个2位数号码组成一注,所选号码与开奖号码的前2位相同,且顺序一致,即为中奖。', select: { layout: [{ title: '百位', balls: [0,1,2,3,4,5,6,7,8,9], tools: true }, { title: '十位', balls: [0,1,2,3,4,5,6,7,8,9], tools: true }] } }, { showname: '单式', shortname: 'exzhixdsq', realname: '[前二码_直选_单式]', tips: '手动输入号码,至少输入1个两位数号码。', example: '', help: '手动输入一个2位数号码组成一注,所选号码的百位、十位与开奖号码相同,且顺序一致,即为中奖。', textarea: {} }, { showname: '直选和值', shortname: 'exzhixhzq', realname: '[前二码_直选_和值]', tips: '从0-18中任意选择1个或1个以上的和值号码。', example: '', help: '所选数值等于开奖号码的百位、十位二个数字相加之和,即为中奖。', select: { layout: [{ balls: [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18], tools: false, cls: 'hz' }] } }] }, { title: '组选', columns: [{ showname: '复式', shortname: 'exzuxfsq', realname: '[前二码_组选_复式]', tips: '从0-9中任意选择2个或2个以上号码。', example: '', help: '从0-9中选2个号码组成一注,所选号码与开奖号码的百位、十位相同,顺序不限,即中奖。', select: { layout: [{ title: '组选', balls: [0,1,2,3,4,5,6,7,8,9], tools: true }] } }, { showname: '单式', shortname: 'exzuxdsq', realname: '[前二码_组选_单式]', tips: '手动输入号码,至少输入1个两位数号码。', example: '', help: '手动输入一个2位数号码组成一注,所选号码的百位、十位与开奖号码相同,顺序不限,即为中奖。', textarea: {} }] }]] }, { title: '定位胆', rows: [[{ title: '定位胆', columns: [{ showname: '定位胆', shortname: 'dwd', realname: '定位胆', tips: '在百位,十位,个位任意位置上任意选择1个或1个以上号码。', example: '', help: '从百位、十位、个位任意位置上至少选择1个以上号码,所选号码与相同位置上的开奖号码一致,即为中奖。', select: { layout: [{ title: '百位', balls: [0,1,2,3,4,5,6,7,8,9], tools: true }, { title: '十位', balls: [0,1,2,3,4,5,6,7,8,9], tools: true }, { title: '个位', balls: [0,1,2,3,4,5,6,7,8,9], tools: true }] } }] }]] }, { title: '不定胆', rows: [[{ title: '不定胆', columns: [{ showname: '一码不定胆', shortname: 'yimabdw', realname: '[不定胆_后三一码]', tips: '从0-9中任意选择1个以上号码。', example: '', help: '从0-9中选择1个号码,每注由1个号码组成,只要开奖号码包含所选号码,即为中奖。', select: { layout: [{ title: '不定胆', balls: [0,1,2,3,4,5,6,7,8,9], tools: true }] }, bwd: true }] }]] }]; }; return {LotteryMain:new LotteryMain()} }()