{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./js/app.sdk.js"],"names":["installedModules","__webpack_require__","moduleId","exports","module","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","win","$","uuid","chars","split","Array","rnd","Math","random","join","ua","navigator","userAgent","toLowerCase","appEvents","siteLoginSuccess","siteLogoutSuccess","loginSuccess","logoutSuccess","loginCancel","loginChain","isInApp","indexOf","isPassport","isWap","handlers","loginChainHandler","siteLoginSuccessHandler","siteLoginSuccessOnceHandler","siteLogoutSuccessHandler","siteLogoutSuccessOnceHandler","loginSuccessOnceHandler","logoutSuccessOnceHandler","App","this","EVENTS","Passport","wap","init","isSiteLogin","login","rediretUrl","logout","location","href","passport","isInMobile","encodeURIComponent","Dialog","show","isLogin","isLoggedIn","isLogined","on","eventName","f","functionName","toString","match","off","one","self","trigger","_event","triggerHandler","runOnce","funcName","tmpFunction","loginCallback","logoutCallback","Error","getUserFace","bigFace","getUserPortrait","data","app","dialogClose","load","iframe","window","frames","context","document","contentWindow","e","jQuery"],"mappings":"aACE,IAAIA,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUC,QAGnC,IAAIC,EAASJ,EAAiBE,GAAY,CACzCG,EAAGH,EACHI,GAAG,EACHH,QAAS,IAUV,OANAI,EAAQL,GAAUM,KAAKJ,EAAOD,QAASC,EAAQA,EAAOD,QAASF,GAG/DG,EAAOE,GAAI,EAGJF,EAAOD,QAKfF,EAAoBQ,EAAIF,EAGxBN,EAAoBS,EAAIV,EAGxBC,EAAoBU,EAAI,SAASR,EAASS,EAAMC,GAC3CZ,EAAoBa,EAAEX,EAASS,IAClCG,OAAOC,eAAeb,EAASS,EAAM,CAAEK,YAAY,EAAMC,IAAKL,KAKhEZ,EAAoBkB,EAAI,SAAShB,GACX,oBAAXiB,QAA0BA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E,EAAIiC,IApBnBV,EACHa,SAASiB,GAAGjB,SAASD,OAAOyC,aAAa,WACpCxC,SAASe,aACZwB,EAAIb,QAAQhD,EAAUM,YAEtBuD,EAAIb,QAAQhD,EAAUK,gBAGdK,GACVvB,EAAE,YAAY4E,MAAK,WAClB,IAAIC,EAASC,OAAOC,OAAgB,QAAEC,SAAWF,OAAOC,OAAgB,QAAEE,UAAYH,OAAOC,OAAgB,QAAEG,cAC/GlF,EAAE6E,GAAQzB,GAAG,QAAS,YAAY,SAAS+B,GAC1CT,EAAIb,QAAQhD,EAAUK,sBA7V3B,CAwWG4D,OAAQM","file":"lib/app.sdk.min.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"//ue.17173cdn.com/a/hao/index/v4.6.1/\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 46);\n","/**\r\n * 17173App SDK\r\n *\r\n *\r\n */\r\n(function(win, $) {\r\n\tfunction uuid() {\r\n\t\tvar CHARS = 'abcdefghijklmnopqrstuvwxyz'.split('');\r\n\t\tvar chars = CHARS, uuid = new Array(36), rnd = 0, r;\r\n\t\tfor (var i = 0; i < 16; i++) {\r\n\t\t\tif (rnd <= 0x02) {\r\n\t\t\t\trnd = 0x2000000 + (Math.random()*0x1000000)|0;\r\n\t\t\t}\r\n\t\t\tr = rnd & 0xf;\r\n\t\t\trnd = rnd >> 4;\r\n\t\t\tuuid[i] = chars[r];\r\n\t\t}\r\n\t\treturn uuid.join('');\r\n\t}\r\n\r\n\tvar cookie = {\r\n\t\tset: function (name, value, expires, domain) {\r\n\t\t\tvar cookieString = name + '=' + escape(value);\r\n\t\t\t//判断是否设置过期时间\r\n\t\t\tif (expires) {\r\n\t\t\t\tvar date = new Date();\r\n\t\t\t\tdate.setTime(date.getTime() + expires);\r\n\t\t\t\tcookieString += '; expires=' + date.toGMTString();\r\n\t\t\t}\r\n\t\t\tif (domain) {\r\n\t\t\t\tcookieString += '; domain=' + domain;\r\n\t\t\t}\r\n\t\t\tdocument.cookie = cookieString;\r\n\t\t},\r\n\t\tget: function (name) {\r\n\t\t\tvar arr, reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)');\r\n\t\t\tarr = document.cookie.match(reg);\r\n\t\t\tif (arr) {\r\n\t\t\t\treturn unescape(arr[2]);\r\n\t\t\t}\r\n\t\t\treturn null;\r\n\t\t}\r\n\t};\r\n\r\n\tvar ua = win.navigator.userAgent.toLowerCase(),\r\n\t\t// APP事件列表\r\n\t\tappEvents = {\r\n\t\t\t// 站点登录\r\n\t\t\tsiteLoginSuccess: 'siteLoginSuccess',\r\n\t\t\t// 站点注销\r\n\t\t\tsiteLogoutSuccess: 'siteLogoutSuccess',\r\n\t\t\t// passport登录\r\n\t\t\tloginSuccess: 'loginSuccess',\r\n\t\t\t// passport注销\r\n\t\t\tlogoutSuccess: 'logoutSuccess',\r\n\t\t\t// 登录过程中取消\r\n\t\t\tloginCancel: 'loginCancel',\r\n\t\t\t// 触发登录联动\r\n\t\t\tloginChain: 'loginChain'\r\n\t\t},\r\n\t\t// APP登录地址\r\n\t\tloginURL = 'app.17173://passport/login?rediretUrl=',\r\n\t\t// 判断是否处于App环境内\r\n\t\tisInApp = ua.indexOf('17173_') !== -1 || ua.indexOf('17173gl') !== -1 || ua.indexOf('appjiaoyi') !== -1,\r\n\t\t// 是否passport\r\n\t\tisPassport = false,\r\n\t\t// 是否topbar依赖的wap登录组件\r\n\t\tisWap = false,\r\n\t\t// 回调方法\r\n\t\thandlers = {\r\n\t\t\t// 登录联动事件回调(仅触发一次)\r\n\t\t\tloginChainHandler: null,\r\n\t\t\t// 站点登录成功回调\r\n\t\t\tsiteLoginSuccessHandler : {},\r\n\t\t\t// 站点登录成功回调(仅触发一次)\r\n\t\t\tsiteLoginSuccessOnceHandler : {},\r\n\t\t\t// 站点注销成功回调\r\n\t\t\tsiteLogoutSuccessHandler : {},\r\n\t\t\t// 站点注销成功回调(仅触发一次)\r\n\t\t\tsiteLogoutSuccessOnceHandler : {},\r\n\t\t\t// passport登录成功回调方法(仅触发一次)\r\n\t\t\tloginSuccessOnceHandler: {},\r\n\t\t\t// passport注销成功回调方法(仅触发一次)\r\n\t\t\tlogoutSuccessOnceHandler: {}\r\n\t\t};\r\n\t\t// 站点是否登录\r\n\t\tisSiteLogin = false;\r\n\r\n\tfunction App() {\r\n\t\tthis.EVENTS = appEvents;\r\n\t\tthis.isInApp = isInApp;\r\n\t\tif (!!win.Passport && typeof win.Passport == 'function') {\r\n\t\t\tisPassport = true;\r\n\t\t} else if (!!win.wap && typeof win.wap == 'object') {\r\n\t\t\tisWap = true;\r\n\t\t\twin.wap.init();\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * 登录\r\n\t */\r\n\tApp.prototype.login = function(rediretUrl) {\r\n\t\t// 强制注销\r\n\t\tthis.logout();\r\n\t\tif (this.isInApp) {\r\n\t\t\twin.location.href = loginURL + (rediretUrl || location.href);\r\n\t\t} else {\r\n\t\t\tif (isPassport) {\r\n\t\t\t\t// 强制注销passport登录\r\n\t\t\t\tthis.passport().logout();\r\n\t\t\t\tif (win.isInMobile) {\r\n\t\t\t\t\twin.location = 'https://passport.17173.com/wap?return_url=' + encodeURIComponent(location.href);\r\n\t\t\t\t} else {\r\n\t\t\t\t\t// 弹出登录窗\r\n\t this.passport().Dialog.show();\r\n\t\t\t\t}\r\n\t\t\t} else if (isWap) {\r\n\t\t\t\tthis.passport().show();\r\n\t\t\t}\r\n\t\t}\r\n\t};\r\n\r\n\t/**\r\n\t * 登出\r\n\t */\r\n\tApp.prototype.logout = function(rediretUrl) {\r\n\t\tif (isPassport) {\r\n\t\t\t// 注销passport登录\r\n\t\t\tthis.passport().logout();\r\n\t\t} else if (isWap) {\r\n\t\t\twap.logout();\r\n\t\t}\r\n\t};\r\n\r\n\t/**\r\n\t * 判断是否已经登录\r\n\t * @return {Boolean} true: 已登录 false: 未登录\r\n\t */\r\n\tApp.prototype.isLogin = function() {\r\n\t\tif (isPassport) {\r\n\t\t\treturn this.passport().isLoggedIn();\r\n\t\t} else if (isWap) {\r\n\t\t\treturn this.passport().isLogined;\r\n\t\t}\r\n\t\treturn false;\r\n\t};\r\n\r\n\t/**\r\n\t * 注册APP事件响应函数\r\n\t * @return {string} 注册的函数名,如果有函数名则返回函数名,否则返回函数引用变量名。如果是匿名函数,则分配一个uuid作为函数名并返回\r\n\t */\r\n\tApp.prototype.on = function(eventName, f) {\r\n\t\tvar functionName = f.name || f.toString().match(/function\\s*([^(]*)\\(/)[1] || uuid();\r\n\r\n\t\t// 已登录情况下\r\n\t\tif (this.isLogin()) {\r\n\t\t\t// 如果绑定的是passport登录,且passport已登录;或者绑定站点登录,passport和站点都已登录,则立即触发一次\r\n\t\t\tif ( (appEvents.loginSuccess == eventName) || (isSiteLogin && appEvents.siteLoginSuccess == eventName)) {\r\n\t\t\t\tf();\r\n\t\t\t}\r\n\t\t} else {// 未登录情况下\r\n\t\t\t// 如果绑定的是注销,且passport已登出;或者绑定站点注销,passport和站点都已注销,则立即触发一次\r\n\t\t\tif (appEvents.logoutSuccess == eventName || (!isSiteLogin && appEvents.siteLogoutSuccess == eventName)) {\r\n\t\t\t\tf();\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// 绑定到passport的方法\r\n\t\tif (appEvents.loginSuccess == eventName || appEvents.logoutSuccess == eventName) {\r\n\t\t\tthis.passport().on(eventName, f);\r\n\t\t} else {// 绑定到站点登录的方法\r\n\t\t\tif (handlers[eventName+'Handler'] != 'undefined' && typeof handlers[eventName+'Handler'] == 'object') {\r\n\t\t\t\thandlers[eventName+'Handler'][functionName] = f;\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn functionName;\r\n\t};\r\n\r\n\t/**\r\n\t * 取消APP对应事件注册方法\r\n\t * @return {boolean} 是否删除了指定的方法\r\n\t */\r\n\tApp.prototype.off = function(eventName, functionName) {\r\n\t\tif (!!eventName && typeof handlers[eventName+'Handler'] != 'undefined') {\r\n\t\t\tif (!! functionName && typeof handlers[eventName+'Handler'][functionName] == 'function') {\r\n\t\t\t\tdelete handlers[eventName+'Handler'][functionName];\r\n\t\t\t\treturn true;\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn false;\r\n\t};\r\n\r\n\t/**\r\n\t * 注册APP事件响应函数(仅执行一次)\r\n\t * @return {string} 注册的函数名,如果有函数名则返回函数名,否则返回函数引用变量名。如果是匿名函数,则分配一个uuid作为函数名并返回\r\n\t */\r\n\tApp.prototype.one = function(eventName, f) {\r\n\t\tvar self = this;\r\n\t\tvar functionName = f.name || f.toString().match(/function\\s*([^(]*)\\(/)[1] || uuid();\r\n\r\n\t\t// 如果绑定的是passport登录,且passport已登录;或者绑定站点登录,passport和站点都已登录,则立即触发一次\r\n\t\tif (this.isLogin() && ( (appEvents.loginSuccess == eventName) || (isSiteLogin && appEvents.siteLoginSuccess == eventName))) {\r\n\t\t\tf();\r\n\t\t// 如果绑定的是passport注销,且passport已注销;或者绑定站点注销,passport和站点都已注销,则立即触发一次\r\n\t\t} else if (!this.isLogin() && ((appEvents.logoutSuccess == eventName) || (!isSiteLogin && appEvents.siteLogoutSuccess == eventName))) {\r\n\t\t\tf();\r\n\t\t} else {\r\n\t\t\t// 绑定到passport的方法\r\n\t\t\tif (appEvents.loginSuccess == eventName || appEvents.logoutSuccess == eventName) {\r\n\t\t\t\thandlers[eventName+'OnceHandler'][functionName] = function() {\r\n\t\t\t\t\tf();\r\n\t\t\t\t\tself.passport().off(eventName, handlers[eventName+'OnceHandler'][functionName]);\r\n\t\t\t\t\tdelete handlers[eventName+'OnceHandler'][functionName];\r\n\t\t\t\t};\r\n\t\t\t\tself.passport().on(eventName, handlers[eventName+'OnceHandler'][functionName]);\r\n\t\t\t} else {\r\n\t\t\t\t// 注册到事件对应的回调函数集合对象中\r\n\t\t\t\tif (handlers[eventName+'OnceHandler'] != 'undefined' && typeof handlers[eventName+'OnceHandler'] == 'object') {\r\n\t\t\t\t\thandlers[eventName+'OnceHandler'][functionName] = f;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn functionName;\r\n\t};\r\n\r\n\t/**\r\n\t * 注册事前登录操作,仅当登录成功后回调一次,当登录事件中止时立即放弃回调\r\n\t * @param Function f 回调方法\r\n\t */\r\n\tApp.prototype.loginChain = function(f) {\r\n\t\thandlers['loginChainHandler'] = f;\r\n\t}\r\n\r\n\t/**\r\n\t * 触发APP事件,不处理passport事件\r\n\t * @param {string} event\r\n\t */\r\n\tApp.prototype.trigger = function(_event) {\r\n\t\tswitch (_event) {\r\n\t\t\t// 站点登录\r\n\t\t\tcase appEvents.siteLoginSuccess:\r\n\t\t\t\t// 执行当前所有注册的一次回调方法\r\n\t\t\t\tthis.triggerHandler(handlers.siteLoginSuccessOnceHandler, true);\r\n\t\t\t\t// 执行注册的回调\r\n\t\t\t\tthis.triggerHandler(handlers.siteLoginSuccessHandler, false);\r\n\t\t\t\t// 移动端登录成功直接触发联动事件\r\n\t\t\t\tif (!isPassport) {\r\n\t\t\t\t\tthis.triggerHandler(handlers.loginChainHandler, true);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\t// 站点登出\r\n\t\t\tcase appEvents.siteLogoutSuccess:\r\n\t\t\t\t// 执行当前所有注册的一次回调方法\r\n\t\t\t\tthis.triggerHandler(handlers.siteLogoutSuccessOnceHandler, true);\r\n\t\t\t\t// 执行注册的回调\r\n\t\t\t\tthis.triggerHandler(handlers.siteLogoutSuccessHandler, false);\r\n\t\t\t\tbreak;\r\n\t\t\t// 登录联动响应(只在passport组件中触发)\r\n\t\t\tcase appEvents.loginChain:\r\n\t\t\t\tthis.triggerHandler(handlers.loginChainHandler, true);\r\n\t\t\t\thandlers.loginChainHandler = null;\r\n\t\t\t\tbreak;\r\n\t\t\t// 登录联动响应(只在passport组件中触发)\r\n\t\t\tcase appEvents.loginCancel:\r\n\t\t\t\thandlers.loginChainHandler = null;\r\n\t\t\t\tbreak;\r\n\t\t\tdefault:\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\t};\r\n\r\n\t/**\r\n\t * 执行函数集,然后清空集合\r\n\t * @param {object} handlers 函数集合对象\r\n\t * @param {Boolean} runOnce 是否只执行一次\r\n\t */\r\n\tApp.prototype.triggerHandler = function(handlers, runOnce) {\r\n\t\tif (typeof handlers == 'function') {\r\n\t\t\t// 登录联动事件回调执行\r\n\t\t\tif (!!handlers && typeof handlers == 'function') {\r\n\t\t\t\thandlers();\r\n\t\t\t\thandlers = null;\r\n\t\t\t}\r\n\t\t} else {\r\n\t\t\tfor (var funcName in handlers) {\r\n\t\t\t\tvar tmpFunction = handlers[funcName];\r\n\t\t\t\tif (!!tmpFunction && typeof tmpFunction == 'function') {\r\n\t\t\t\t\ttmpFunction();\r\n\t\t\t\t\t// 如果只执行一次,则调用后从回调函数集合中清除此函数\r\n\t\t\t\t\tif (!!runOnce) {\r\n\t\t\t\t\t\tdelete handlers[funcName];\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t};\r\n\r\n\t/**\r\n\t * 判断用户Passport登录状态,并执行状态对应的对调方法\r\n\t * @param {Function} loginCallback 登录状态下的回调方法\r\n\t * @param {Function} logoutCallback 登出状态下的回调方法\r\n\t */\r\n\tApp.prototype.loginCallback = function(loginCallback, logoutCallback) {\r\n\t\tif (this.isLogin()) {// 已经登录\r\n\t\t\tif (!!loginCallback && typeof loginCallback == 'function') {\r\n\t\t\t\tloginCallback();\r\n\t\t\t}\r\n\t\t} else {// 未登录\r\n\t\t\tif (!!logoutCallback && typeof logoutCallback == 'function') {\r\n\t\t\t\tlogoutCallback();\r\n\t\t\t}\r\n\t\t}\r\n\t};\r\n\r\n\t/**\r\n\t * 获取Passort对象\r\n\t */\r\n\tApp.prototype.passport = function() {\r\n\t\tif (isPassport) {\r\n\t\t\treturn win.Passport;\r\n\t\t} else if (isWap) {\r\n\t\t\treturn win.wap;\r\n\t\t} else {\r\n\t\t\tthrow new Error('Passport not found');\r\n\t\t}\r\n\t};\r\n\r\n\tApp.prototype.getUserFace = function(bigFace) {\r\n\t\tbigFace = !!bigFace? 1: 0;\r\n\t\tif (this.isLogin()) {\r\n\t\t\tif (isPassport) {\r\n\t\t\t\treturn this.passport().getUserPortrait(this.passport().data('uid'), bigFace);\r\n\t\t\t} else if (isWap) {\r\n\t\t\t\treturn this.passport().getUserFace(this.passport().data('uid'), bigFace);\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn '';\r\n\t};\r\n\r\n\t// 监听登陆窗体关闭按钮点击,移除loginChain绑定事件\r\n\tfunction loginChainListener(app) {\r\n\t\tif (isPassport) {\r\n\t\t\tPassport.on(Passport.EVENTS.dialogClose, function() {\r\n\t\t\t\tif (Passport.isLoggedIn()) {\r\n\t\t\t\t\tapp.trigger(appEvents.loginChain);\r\n\t\t\t\t} else {\r\n\t\t\t\t\tapp.trigger(appEvents.loginCancel);\r\n\t\t\t\t}\r\n\t\t\t});\r\n\t\t} else if (isWap) {\r\n\t\t\t$('#passwap').load(function() {\r\n\t\t\t\tvar iframe = window.frames['passwap'].context || window.frames['passwap'].document || window.frames['passwap'].contentWindow;\r\n\t\t\t\t$(iframe).on('click', 'i.return', function(e) {\r\n\t\t\t\t\tapp.trigger(appEvents.loginCancel);\r\n\t\t\t\t});\r\n\t\t\t});\r\n\t\t}\r\n\t}\r\n\r\n\t$(function() {\r\n\t\twin.App = new App();\r\n\t\tloginChainListener(win.App);\r\n\t});\r\n\r\n})(window, jQuery);\r\n"],"sourceRoot":""}