index.js 1.61 KB
var base = require('./public/base');
var Login = require('./public/login');
var Goto = require('./public/goto');
var wxCtrl = require('./public/share');
var lazyLoad = require('./public/lazyLoad');
var common = require('./utils/common');
var dialoger = require('./utils/dialoger');
var Promotion = require('./public/promotion');
var node = require('./utils/element');
var indiv = require('./public/individuation');
require('./css/featuretip.scss'); //eslint-disable-line

var env = base.env();
var loginUrl = base.loginUrl();
var login = new Login({loginUrl: loginUrl, env: env});
var goto = new Goto(env);
var wx = new wxCtrl();
var authList = document.querySelectorAll('.auth');
var couponList = document.querySelectorAll('.yoho-conpon');
var redList = document.querySelectorAll('.yoho-redenvelope');
var source = document.querySelectorAll('.product-source');
if (authList.length || couponList.length || redList.length) {
    base.getUser().then(function (user) {
        authList.length && login.auth(authList, user);
        couponList.length && Promotion.Coupon(couponList, user);
        redList.length && Promotion.RedEnvelope(redList, user);
        source.length && indiv(source, user, env);
    })
}
module.exports = {
    goLogin: login.goLogin.bind(login),
    getUser: base.getUser,
    env: env,
    link: goto.link.bind(goto),
    goBack: goto.goBack.bind(goto),
    wxShare: wx.wxShare.bind(wx),
    wxSignature: wx.wxSignature,
    getQueryObj: common.getQueryObj,
    invokeMethod: common.invokeMethod,
    lazyload: lazyLoad,
    tip: dialoger.showTip,
    toast: dialoger.toast,
    favourite: Promotion.favourite,
    $: node
};