| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- import { type } from "os";
- export default {
- //数据存放到缓存
- setCache: function (key, val) {
- if (val instanceof Array) {
- let str = JSON.stringify(val);
- window.sessionStorage.setItem(key, str);
- } else {
- window.sessionStorage.setItem(key, val);
- }
- },
- //获取缓存数据
- getCache: function (key) {
- return window.sessionStorage.getItem(key);
- },
- /**
- * 比赛时间计时器
- * @param {分钟} f
- * @param {秒} s
- * @param {回掉方法} fun
- */
- timer: function (f, s, fun) {
- let timing = setInterval(function () {
- s++;
- if (s < 10) {
- s = "0" + s;
- }
- if (s == 60) {
- f++;
- s = '00';
- }
- fun && fun(f, s);
- }, 1000)
- },
- /**
- * 玩法投注公共方法
- * @param {玩法组件的选择赔率id数组} betting
- * @param {*当前玩法赔率及相关数据} bettingInfo
- * @param {*当前玩法赔率数据信息列表} data
- * @param {*Vuex里面的投注列表} getBettingList
- * @param {*当前组的玩法的title} name
- * @param {*判断当前组件是否已有投注} dataNum
- * @param {*修改当前样式回调方法} callback
- * @param {*更新Vuex投注列表} fun
- */
- bettingFunction: function (betting, bettingInfo, data, getBettingList, name, dataNum, callback, fun) {
- let isTrue = true;
- betting.forEach((e, index) => {
- if (bettingInfo.id == e.id) {
- data.forEach((res) => {
- if (bettingInfo.id == res.id) {
- callback && callback(res, false);
- betting.splice(index, 1);
- }
- })
- isTrue = false;
- }
- });
- if (isTrue) {
- betting.push(bettingInfo);
- betting.forEach((e) => {
- if (bettingInfo.id == e.id) {
- data.forEach(res => {
- if (bettingInfo.id == res.id) {
- callback && callback(res, true);
- }
- })
- isTrue = false;
- }
- })
- }
- let obj = {
- title: name,
- data: betting
- };
- let array = [];
- if (dataNum != 10000) {
- getBettingList[dataNum] = obj;
- } else {
- if (getBettingList) {
- if (getBettingList.length > 0) {
- getBettingList.push(obj);
- }
- } else {
- array.push(obj);
- }
- }
- fun && fun(getBettingList, array);
- },
- /**
- * 获取vuex相对应玩法index下标和投注数据集合
- * @param {组件类所有玩法数据集合} data
- * @param {组件里玩法别名} title
- * @param {从Vuex里面的投注列表的匹配对应的投注数据集合} betting
- * @param {相对应玩法index下标} dataNum
- */
- getBettingId(data, title, callback) {
- if (data) {
- data.forEach((res, index) => {
- if (res.title == title) {
- callback && callback(res.data, index);
- }
- });
- }
- }
- }
|