tongji.js 1.8 KB
import * as user_api from '@/api/user_api';
import { default as moment } from 'moment';
// 投票方法  
const gntj = async (number) => {
    // 构建GraphQL查询
    await user_api.toupiao_vote({
        lottery_id: 999,
        play_type: 'live2_game',
        issue_name: moment().format("YY/MM/DD"),
        number: number,
        vote_type: 1
    }).then((res) => {
        console.info(res);
    });
};
// 处理点击事件  
const handleClick = (event) => {
    const target = event.target;
    const nogntj = target.getAttribute('nogntj');
    if (nogntj === '' || nogntj)
        return;
    const gntjText = target.getAttribute('gntj');
    let number = '';
    if (!gntjText || gntjText.split('_').length < 2) {
        number = gntjText && gntjText !== '' && gntjText !== '2' ? gntjText : target.textContent.trim();
        if (gntjText === '2' && hasClass(target, ['select', 'check', 'sel', 'choice'])) {
            number += '_选中';
        }
        else if (gntjText === '2' && !hasClass(target, ['select', 'check', 'sel', 'choice'])) {
            number += '_取消';
        }
    }
    else {
        const [type, gntjTextValue] = gntjText.split('_');
        number = gntjTextValue && gntjTextValue !== '' ? gntjTextValue : target.textContent.trim();
        if (type === '2' && hasClass(target, ['select', 'check', 'sel', 'choice'])) {
            number += '_选中';
        }
        else if (type === '2' && !hasClass(target, ['select', 'check', 'sel', 'choice'])) {
            number += '_取消';
        }
    }
    // 调用gntj方法  
    gntj(number);
};
// 辅助函数,检查元素是否具有某个或多个类  
const hasClass = (element, classes) => {
    return classes.every((o) => element.classList.contains(o));
};
export { gntj, handleClick };
//# sourceMappingURL=tongji.js.map