"use strict";
function _typeof3(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof3 = function _typeof3(obj) { return typeof obj; }; } else { _typeof3 = function _typeof3(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof3(obj); }
function _objectSpread2(target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i] != null ? arguments[i] : {};
var ownKeys = Object.keys(source);
if (typeof Object.getOwnPropertySymbols === 'function') {
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) {
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
}));
}
ownKeys.forEach(function (key) {
_defineProperty2(target, key, source[key]);
});
}
return target;
}
function _defineProperty2(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
function _typeof2(obj) {
if (typeof Symbol === "function" && _typeof3(Symbol.iterator) === "symbol") {
_typeof2 = function _typeof2(obj) {
return _typeof3(obj);
};
} else {
_typeof2 = function _typeof2(obj) {
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : _typeof3(obj);
};
}
return _typeof2(obj);
}
function fullScreen(selector) {
var h = $(window).height();
selector.height(h);
}
var isEn = /^\/en\//.test(location.pathname) || /^\/en/.test(location.pathname);
var isJp = /^\/jp\//.test(location.pathname) || /^\/jp/.test(location.pathname);
window.isEn = isEn;
window.isJp = isJp;
if (isEn || isJp) {
$('#nav-product').addClass('old-nav-product');
}
/* 瀵艰埅閮ㄥ垎鐨勯€昏緫 */
var index = 1; // 璁板綍褰撳墠鐨勬墍鍦ㄧ殑瀵艰埅鐨勭骇鍒? 榛樿鍦ㄧ涓€绾
var cacheArr = []; // 瀛樺偍閫夋嫨鐨勬瘡涓€绾ч€変腑鐨勭储寮
function setHtml(data, el, needBack) {
// 璁剧疆鍒跺畾绾у埆鐨勯€夐」鐨勫唴瀹
var str = "";
if (needBack) {
str += setBack();
}
data.forEach(function (obj, index) {
str += setOption(obj.title, index, obj.url, obj.child ? 1 : 0);
});
el.html(str);
}
function setOption(title, index, url) {
var str = "\n
\n \n
").concat(title, "
\n
\n
\n \n ");
return str;
}
function setBack() {
console.log(isEn);
var str = "\n \n \n
\n
".concat(languageConfig.returnStr, "
\n
\n \n ");
return str;
}
function setLevel() {
var data = getData();
setHtml(data, $('.nav-level' + index), index !== 1);
}
function getData() {
var list = mobileData;
for (var i = 0; i < cacheArr.length; i++) {
list = list[cacheArr[i]].child;
}
return list;
}
function setClass(selector, className) {
// 鏈塩lassName鍚嶅垯鍒犻櫎,鏃犲垯娣诲姞
selector.hasClass(className) ? selector.removeClass(className) : selector.addClass(className);
}
function init(title, index) {
setLevel();
}
function getQueryString(name) {
// 鑾峰彇url涓殑query淇℃伅
var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i');
var r = window.location.search.substr(1).match(reg);
if (r != null) {
return unescape(r[2]);
}
return null;
}
init(); // 瀛樺偍閫変腑鐨勫鑸储寮
$('.nav-phone-options').on("click", ".nav-level-option", function () {
if (navIsSearching) {
return;
}
if (index === 3) {
// 鏈€楂樼骇鑱斾笉杩涜涓嬮潰鐨勬搷浣
var url = $(this).attr('data-url');
if (url) {
if (url.indexOf('http') !== -1) {
location.href = url;
} else {
url = url[0] === '/' ? url : '/' + url;
location.href = location.origin + url;
}
}
return;
}
var num = $(this).attr('data-index');
cacheArr.push(num);
index++;
if (getData().length === 0) {
var url = $(this).attr('data-url');
console.log(url);
if (url) {
if (url.indexOf('http') !== -1) {
location.href = url;
} else {
url = url[0] === '/' ? url : '/' + url;
location.href = location.origin + url;
}
return;
}
}
$('.nav-level' + index).animate({
left: 0
});
setLevel();
});
$('.nav-phone-options').on("click", ".nav-option-return", function () {
$('.nav-level' + index).animate({
left: '100%'
});
index--;
cacheArr.pop();
});
var navProductShow = false;
var navProductListLength = $('.nav-product-list li').length;
var navProductListRatio = Math.ceil(navProductListLength / 5);
$('#nav-product').hover(function (e) {
$('.nav-container').addClass('active-border');
$('.nav-popup').css({
height: isEn || isJp ? 220 * navProductListRatio + 'px' : 750 + 'px'
});
navProductShow = false;
}, function (e) {
$('.nav-popup').css({
height: '0'
});
navProductShow = true;
setTimeout(function () {
if (navProductShow) {
$('.nav-container').removeClass('active-border');
}
}, 400);
});
$('.nav-product-list li').hover(function () {
$('.nav-product-list .nav-product-name').removeClass('product-name-active');
$(this).find('.nav-product-name').addClass('product-name-active');
var ind = $(this).attr('data-vid');
$('.product-active-line').css({
top: 110 * ind + 'px'
});
$('.product-item-list').removeClass('product-item-active');
$('.product-item-list').eq(ind).addClass('product-item-active');
}, function () {});
$('.nav-option').hover(function () {
if (!$(this)[0].temHeight) {
var len = $(this).find('.nav-option-list li').length;
var val = 42 * len + 'px';
$(this)[0].temHeight = val;
}
var num = $(this).find('span').width();
$(this).find('.nav-option-list').css({
left: -1 * (160 - num) / 2 // 鎬诲 200 鍑忓幓 padding鐨勫20 鍑忓幓 鑷韩瀹藉害 闄や互2
// left: -1 * (180 - num) / 2 // 鎬诲 200 鍑忓幓 padding鐨勫20 鍑忓幓 鑷韩瀹藉害 闄や互2
});
$(this).find('.nav-option-list').css({
height: $(this)[0].temHeight
});
}, function () {
$(this).find('.nav-option-list').css({
height: 0
});
});
$('.nav-link').click(function () {
// 閫氳繃璁剧疆瀵艰埅鏍囩 nav-link 绫诲悕 鍜 data-link 灞炴€ц繘琛岃烦杞
var url = $(this).attr('data-link');
location.href = url;
});
$('.to-index').click(function () {
location.href = location.origin;
});
$('.to-index-en').click(function () {
location.href = location.origin + '/en';
});
$('.to-index-jp').click(function () {
location.href = location.origin + '/jp';
});
var showMenu = false;
var showLang = false;
$('.nav-bar').click(function () {
if (window.navConfig) {
window.navConfig.isHasLanguageHeader = false;
}
if ($('body').css('overflow') === 'visible') {
$('body').css('overflow', 'hidden');
} else {
$('body').css('overflow', 'visible');
}
if (showMenu) {
// 鏄剧ず鑿滃崟鐨勬椂鍊
$('.nav-phone').removeClass('nav-bar-active');
$('.nav-phone-option-container').removeClass('showNavOption');
$(this).removeClass('icon-quxiao1');
showMenu = false;
} else if (showLang) {
// 鏄剧ず璇█閫夋嫨鐨勬椂鍊
$('.nav-phone').removeClass('nav-bar-active');
$('.nav-phone-lang-container').removeClass('showNavOption');
$(this).removeClass('icon-quxiao1');
showLang = false;
} else {
$('.nav-phone').addClass('nav-bar-active');
$('.nav-phone-option-container').addClass('showNavOption');
$(this).addClass('icon-quxiao1');
showMenu = true;
}
/* setClass($('.nav-phone'), 'nav-bar-active')
setClass($('.nav-phone-option-container'), 'showNavOption')
setClass($(this), 'icon-quxiao1')*/
});
$('.nav-phone-lang').click(function () {
if (showLang) {
return;
}
if (showMenu) {
$('.nav-phone-option-container').removeClass('showNavOption');
showMenu = false;
}
$('.nav-phone').addClass('nav-bar-active');
$('.nav-phone-lang-container').addClass('showNavOption');
$('.nav-bar').addClass('icon-quxiao1');
showLang = true;
});
/* $('.icon-quxiao1').click(function (e) {
$('.nav-phone').removeClass('nav-bar-active')
$('.nav-phone-option-container').toggle()
}) */
/* if ($(window).width() <= 768) {
console.log(123)
$(window).scroll(function (e) {
var navScroll = $(window).scrollTop()
$('.nav-phone').css({
top: navScroll + 'px'
})
})
} */
/* 鍏ㄥ眬鎼滅储閮ㄥ垎 */
var navIsSearching = false;
$('.icon-search').click(function (e) {
if ($('.search-container').hasClass('search-active')) {
// 濡傛灉宸茬粡鏄睍寮€鐘舵€佺殑icon鐐瑰嚮鍚庣洿鎺ヨ繘琛屾悳绱
return;
}
$('.nav-content').find('li').removeClass('zoomIn').addClass('nav-animated zoomOut');
$('.single-icon').removeClass('zoomIn').addClass('nav-animated zoomOut');
$('.search-container').addClass('search-active zoomInLeft nav-animated');
setTimeout(function () {
$('.search-input').focus();
}, 100);
});
$('.search-cancel').click(function (e) {
$('.search-container').removeClass('search-active');
$('.nav-content').find('li').removeClass('zoomOut').addClass('zoomIn');
$('.single-icon').removeClass('zoomOut').addClass('zoomIn'); // $('.nav-content').show()
});
$('#searchKeyword').keydown(function (e) {
if (e.keyCode === 13) {// 璺宠浆鍒版悳绱㈤〉
}
});
$('.phone-search-input').focus(function (e) {
navIsSearching = true;
$('.nav-phone-search').css('z-index', 100);
$('.nav-phone').height(0);
$('.nav-phone-option-container').css('padding-top', 0);
$('.nav-phone-search-cancel').css('width', '47px');
$('.nav-level1 li').removeClass('fadeInUp').addClass('fadeOutDown nav-animated');
$('.hot-search-box').show().addClass('fadeInDown nav-animated');
});
/* .blur(function (e) {
console.log(123123)
$('.nav-phone').height(45)
$('.nav-phone-option-container').css('padding-top', '45px')
}) */
$('.nav-phone-search-cancel').click(function (e) {
$('.nav-phone-search').css('z-index', 10);
$('.nav-phone').height(45);
$('.nav-phone-option-container').css('padding-top', '45px');
$('.nav-phone-search-cancel').css('width', 0);
$('.nav-level1 li').removeClass('fadeOutDown').addClass('fadeInUp');
$('.hot-search-box').hide();
navIsSearching = false;
});
$('.nav-hot-item').click(function (e) {
// 鐐瑰嚮鐑瘝杩涜璺宠浆
console.log($(this).text().trim());
});
/* 鍏ㄥ眬鎼滅储閮ㄥ垎 */
/* 搴曢儴閮ㄥ垎鐨勯€昏緫 */
$('.back-to-top').click(function (e) {
$('html,body,window,.main-container').animate({
scrollTop: 0
}, 400);
});
$('.footer-phone-optionBox .iconfont').click(function () {
var $select = $(this).parent().parent().find('.footer-phone-child');
if (!$select.length) {
return;
}
if ($(this).hasClass('icon-minus')) {
$(this).addClass('icon-add');
$(this).removeClass('icon-minus');
$select.hide();
} else {
$(this).addClass('icon-minus');
$(this).removeClass('icon-add');
$select.show();
}
});
$('.open-link').click(function () {
var el = $('.footer-friend-link');
console.log(el.height());
el.height() > 18 ? el.height(17) : el.height(34);
});
/* 寰俊寮规 */
$('.icon-weixin-popup').click(function (e) {
var $select = $('#weixin-qrcode');
$select.width($(window).width());
$select.height($(window).height());
$select.show();
e.stopPropagation();
});
$('#weixin-qrcode').click(function () {
$(this).hide();
});
$('body').click(function () {
var $select = $('#weixin-qrcode');
$select.hide();
});
/* cover鎺т欢 */
/* 甯哥敤鍑芥暟 */
/*
鍦ㄨ瀹氱殑鏃堕棿鍐呴噸澶嶈Е鍙戜細閲嶇疆,鍦ㄥ仠姝㈠悗瑙﹀彂鏈€鏂扮殑
*/
function debouce(fn, time, context) {
var timeID;
var wrapFn = function wrapFn() {
var _arguments = arguments;
clearTimeout(timeID);
timeID = setTimeout(function () {
fn.apply(context, _arguments);
}, time);
};
return wrapFn;
}
/* 鑺傛祦鍑芥暟, 鍦ㄦ寚瀹氱殑鏃堕棿鍚庢墠鑳借Е鍙 */
var throttle = function () {
var lastFn = null; // 瀛樺偍鏈€鍚庝竴娆¤闃绘鐨勫嚱鏁
var cacheArg = [];
return function (fn, time, context) {
var arg = [];
var bool = true;
var delay = function delay() {
setTimeout(function () {
bool = true;
lastFn && lastFn.apply(context, arg);
}, time);
};
var wrapFn = function wrapFn() {
arg = [].slice.call(arguments);
if (bool) {
bool = false;
fn.apply(context, arg);
delay();
} else {
lastFn = fn;
cacheArg = arg;
}
};
return wrapFn;
};
}();
/* rem鏂规鐨勮瀹氬嚱鏁?鍙湪浣跨敤鐨勯〉闈㈣皟鐢 */
/* 寰崥鍒嗕韩鍒濆鍖 */
function weiboShareInit($select) {
var option = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var wb_shareBtn = $select,
wb_url = location.href,
//鍒嗕韩鐨勫湴鍧€
wb_appkey = "4279419411",
//浣犵殑app key
wb_title = encodeURIComponent(option.title || document.title),
wb_ralateUid = "鏋侀绉戞妧",
//寰崥id锛岃幏寰椾綘鐨勭敤鎴峰悕
wb_pic = "",
searchPic = true,
wb_language = "zh_cn";
var val = "//service.weibo.com/share/share.php?url=" + wb_url + "&appkey=" + wb_appkey + "&title=" + wb_title + "&pic=" + wb_pic + "&ralateUid=" + wb_ralateUid + "&language=" + wb_language + "&searchPic=" + searchPic + '';
wb_shareBtn.attr("href", val);
}
/* 璋冪敤鎾斁瑙嗛 */
$('.close-video').click(function () {
$('.cover-screen').hide(); // 鍒犻櫎杩欎釜瑙嗛, 涔嬪悗鍙互鑰冭檻鍙槸鏆傚仠
$('#cover-video').html('');
});
/* 娑堟伅鎻愮ず */
function showTips(str, type, cb) {
// type鍒ゆ柇鎴愬姛澶辫触 0 澶辫触 1 鎴愬姛 , str鏄彁绀虹殑娑堟伅鍐呭
if (str === undefined) {
return;
}
var icons;
if (type === 0) {
// 澶辫触
icons = 'icon-error';
} else if (type === 1) {
// 鎴愬姛
icons = 'icon-success';
} else {
// 璀﹀憡
icons = 'icon-warning';
}
var className = type === 1 ? 'infomation-tips-success' : '';
var childs;
if ($(window).width() > 768) {
childs = "\n \n
\n
").concat(str, "
\n
\n ");
} else {
childs = "\n \n ");
}
var el = $(childs);
$('body').append(el);
el.fadeIn();
setTimeout(function () {
el.fadeOut();
setTimeout(function () {
el.remove();
}, 200);
}, 3000);
}
/* 楠岃瘉瀵硅薄 */
var verify = {
email: function email(val) {
return /\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/.test(val);
},
phone: function phone(val) {
return /^1\d{10}$/.test(val);
}
};
/* 鐩掑瓙鍐呮樉绀簂oading鏍峰紡 */
(function ($) {
$.fn.extend({
"loadingInit": function loadingInit(param) {
var options = param || {}; // 鍒濆鍖栦竴涓彲浠ュ厖婊℃暣涓洅瀛愮殑閬僵,涓棿鏄痩oading
var id = 'lodingInit' + Date.now();
var $select = $(this);
var size = options.size || 100;
$select.addClass('loadingInt-relative');
function getEl() {
return $("\n \n "));
}
var showLoading = function showLoading() {
$select.append(getEl());
};
var hideLoading = function hideLoading() {
$('#' + id).remove();
};
return {
showLoading: showLoading,
hideLoading: hideLoading
};
}
});
})(jQuery);
/* 鍒ゆ柇鏄惁涓哄井淇℃祻瑙堝櫒 */
function isWeixin() {
//鍒ゆ柇鏄惁鏄井淇
var ua = navigator.userAgent.toLowerCase();
return ua.match(/MicroMessenger/i) == "micromessenger";
}
;
/* ajax璇锋眰 */
function $ajax(obj) {
var option = {
dataType: 'json'
};
for (var i in obj) {
option[i] = obj[i];
}
var error = obj.error;
option.error = function (err) {
var str = languageConfig.networkError;
showTips(str, 0);
error && error(err);
};
$.ajax(option);
}
$('.lazy').contextmenu(function () {
return false;
});
$(function () {
/* $.getScript(location.origin + '/js/vconsole.min.js', function () {
$('body').append('')
}) */
});
var judge = function () {
var isIos = function isIos() {
return /ip(hone|od|ad)/i.test(navigator.userAgent);
};
var isWeChat = function isWeChat() {
return /micromessenger/i.test(navigator.userAgent);
};
var isMac = function isMac() {
return /macintosh|mac os x/i.test(navigator.userAgent);
};
var isWindows = function isWindows() {
return /windows|win32/i.test(navigator.userAgent);
};
return {
isWeChat: isWeChat,
isIos: isIos,
isMac: isMac,
isWindows: isWindows
};
}();
if (judge.isWeChat() && judge.isIos()) {
$('body').addClass('ipone-wx');
}
var chineseTextConfig = {
copySuccessStr: '澶嶅埗鎴愬姛',
copyFailStr: '澶嶅埗澶辫触',
loadingTips: '姝e湪鍔犺浇...',
loadingMore: '鍔犺浇鏇村',
returnStr: '杩斿洖',
networkError: '缃戠粶閿欒'
};
var englishTextConfig = {
copySuccessStr: 'Copy success',
copyFailStr: 'Copy failed',
loadingTips: 'loading...',
loadingMore: 'More',
returnStr: 'Back',
networkError: 'Network error'
};
var japanTextConfig = {
copySuccessStr: '銈炽償銉兼垚鍔?,
copyFailStr: '銈炽償銉笺伀澶辨晽銇椼伨銇椼仧',
loadingTips: '瑾伩杈笺伩涓?..',
loadingMore: '銈儍銉椼儹銉笺儔',
returnStr: '鎴汇倠',
networkError: '銉嶃儍銉堛儻銉笺偗銈ㄣ儵銉?
};
var languageConfig = isJp ? japanTextConfig : !isEn ? chineseTextConfig : englishTextConfig;
(function (global, factory) {
(typeof exports === "undefined" ? "undefined" : _typeof2(exports)) === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : global.RModal = factory();
})(window, function () {
'use strict';
console.log(init);
var modalStyle = "\n body .modal-open {\n overflow-x: hidden;\n overflow-y: auto;\n }\n\n .modal {\n display: none;\n background: rgba(0, 0, 0, .30);\n z-index: 999;\n padding: 30px 0;\n\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n\n overflow-x: hidden;\n overflow-y: auto;\n }\n\n .modal .modal-dialog {\n position: absolute;\n width: ".concat($(window).width() > 768 ? '40%' : '94%', ";\n border-radius: 6px; \n -webkit-box-shadow: 0 3px 9px rgba(0, 0, 0, .5);\n box-shadow: 0 3px 9px rgba(0, 0, 0, .5);\n background: #fff;\n margin: auto;\n height: 500px;\n top: 0;\n left: 0;\n right: 0;\n background-color: white;\n bottom: 0;\n }\n .modal-header{\n padding: 16px;\n font-size: 16px;\n border: 1px solid #e5e5e5;\n }\n .modal-content{\n padding: 16px;\n }\n .modal-footer{\n display: flex;\n padding: 16px;\n justify-content: flex-end;\n }\n .modal-content{\n overflow-y: auto;\n height: 380px;\n border-bottom: 1px solid #e5e5e5;\n }\n .modal-button{\n font-size: 16px;\n padding: 6px 12px;\n text-align: center;\n margin-left: 8px;\n border-radius: 4px;\n cursor: pointer;\n background-color: #e3e3e3;\n }\n .modal-button[type='primary']{\n background-color: #0069d9;\n color: white;\n }\n ");
function addMoalClass() {
var style = document.createElement('style');
style.innerHTML = modalStyle;
document.querySelector('head').appendChild(style);
}
addMoalClass();
var is = function is(obj, type) {
return Object.prototype.toString.call(obj).toLowerCase() === "[object " + type + "]";
};
var addClass = function addClass(el, cls) {
var arr = el.className.split(/\s+/).filter(function (c) {
return !!c && c == cls;
});
if (!arr.length) {
el.className += " " + cls;
}
};
var removeClass = function removeClass(el, cls) {
el.className = el.className.split(/\s+/).filter(function (c) {
return !!c && c != cls;
}).join(' ');
};
var RModal = function RModal(el, opts) {
var this$1 = this;
this.opened = false;
this.opts = {
bodyClass: 'modal-open',
dialogClass: 'modal-dialog',
dialogOpenClass: 'bounceInDown',
dialogCloseClass: 'bounceOutUp',
focus: true,
focusElements: ['a[href]', 'area[href]', 'input:not([disabled]):not([type=hidden])', 'button:not([disabled])', 'select:not([disabled])', 'textarea:not([disabled])', 'iframe', 'object', 'embed', '*[tabindex]', '*[contenteditable]'],
escapeClose: true,
content: null,
closeTimeout: 0
};
Object.keys(opts || {}).forEach(function (key) {
/* istanbul ignore else */
if (opts[key] !== undefined) {
this$1.opts[key] = opts[key];
}
});
this.overlay = el;
this.dialog = el.querySelector("." + this.opts.dialogClass);
if (this.opts.content) {
this.content(this.opts.content);
}
};
RModal.prototype.open = function open(content) {
var this$1 = this;
this.content(content);
if (!is(this.opts.beforeOpen, 'function')) {
return this._doOpen();
}
this.opts.beforeOpen(function () {
this$1._doOpen();
});
};
RModal.prototype._doOpen = function _doOpen() {
addClass(document.body, this.opts.bodyClass);
removeClass(this.dialog, this.opts.dialogCloseClass);
addClass(this.dialog, this.opts.dialogOpenClass);
this.overlay.style.display = 'block';
if (this.opts.focus) {
this.focusOutElement = document.activeElement;
this.focus();
}
if (is(this.opts.afterOpen, 'function')) {
this.opts.afterOpen();
}
this.opened = true;
};
RModal.prototype.close = function close() {
var this$1 = this;
if (!is(this.opts.beforeClose, 'function')) {
return this._doClose();
}
this.opts.beforeClose(function () {
this$1._doClose();
});
};
RModal.prototype._doClose = function _doClose() {
var this$1 = this;
removeClass(this.dialog, this.opts.dialogOpenClass);
addClass(this.dialog, this.opts.dialogCloseClass);
removeClass(document.body, this.opts.bodyClass);
if (this.opts.focus) {
this.focus(this.focusOutElement);
}
if (is(this.opts.afterClose, 'function')) {
this.opts.afterClose();
}
this.opened = false;
setTimeout(function () {
this$1.overlay.style.display = 'none';
}, this.opts.closeTimeout);
};
RModal.prototype.content = function content(html) {
if (html === undefined) {
return this.dialog.innerHTML;
}
this.dialog.innerHTML = html;
};
RModal.prototype.elements = function elements(selector, fallback) {
fallback = fallback || window.navigator.appVersion.indexOf('MSIE 9.0') > -1;
selector = is(selector, 'array') ? selector.join(',') : selector;
return [].filter.call(this.dialog.querySelectorAll(selector), function (element) {
if (fallback) {
var style = window.getComputedStyle(element);
return style.display !== 'none' && style.visibility !== 'hidden';
}
return element.offsetParent !== null;
});
};
RModal.prototype.focus = function focus(el) {
el = el || this.elements(this.opts.focusElements)[0] || this.dialog.firstChild;
if (el && is(el.focus, 'function')) {
el.focus();
}
};
RModal.prototype.keydown = function keydown(ev) {
if (this.opts.escapeClose && ev.which == 27) {
this.close();
}
function stopEvent() {
ev.preventDefault();
ev.stopPropagation();
}
if (this.opened && ev.which == 9 && this.dialog.contains(ev.target)) {
var elements = this.elements(this.opts.focusElements),
first = elements[0],
last = elements[elements.length - 1];
if (first == last) {
stopEvent();
} else if (ev.target == first && ev.shiftKey) {
stopEvent();
last.focus();
} else if (ev.target == last && !ev.shiftKey) {
stopEvent();
first.focus();
}
}
};
RModal.prototype.version = '1.0.31';
RModal.version = '1.0.31';
return RModal;
});
/* 瑙嗛瀵硅薄 */
var playInsetVideo = function () {
var videoPlayer = function videoPlayer() {
this.play = function (url) {
$('.cover-screen').width($(window).width());
$('.cover-screen').height($(window).height());
$('.cover-screen').show();
$('#cover-video').append(this.setVideo(url));
this.cb && this.cb(); // 渚嬪浼橀叿闇€瑕佸湪append鍚庡垵濮嬪寲
};
this.setVideo = function (url) {
var vid = this.getVid(url);
return this.embed(vid);
};
this.getEmbed = function (option, type) {
var width = $(window).width() > 768 ? type === 'qiniu' ? 1200 : 1280 : $(window).width();
var height = $(window).width() > 768 ? 675 : $(window).width() / 2.2;
var str = Object.keys(option).map(function (key) {
return ' ' + key + '=' + option[key] + ' ';
}).join('');
if (type === 'qiniu') {
return "\n \n ");
} else {
return "\n \n ");
}
};
};
var playerVideo = {
youku: new videoPlayer(),
qq: new videoPlayer(),
youtube: new videoPlayer(),
qiniu: new videoPlayer()
};
playerVideo.judgeVideoType = function (url) {
if (url.indexOf('v.qq.com') !== -1) {
return 'qq';
} else if (url.indexOf('www.youtube.com') !== -1) {
return 'youtube';
} else if (url.indexOf('v.youku.com') !== -1) {
return 'youku';
} else {
return 'qiniu';
}
};
playerVideo.youku.getVid = function (str) {
return str.match(/id_(.+?)\.html/)[1];
};
playerVideo.youtube.getVid = function (str) {
var start = str.lastIndexOf('=') + 1;
return str.slice(start);
};
playerVideo.qq.getVid = function (str) {
var start = str.lastIndexOf('/') + 1;
var end = str.lastIndexOf('.');
return str.slice(start, end);
};
playerVideo.qiniu.getVid = function (str) {
return str;
};
playerVideo.qq.embed = function (vid) {
var embed = this.getEmbed({
// src: `//v.qq.com/iframe/player.html?vid=${vid}&tiny=0&auto=1`,
src: "//v.qq.com/txp/iframe/player.html?vid=".concat(vid, "&tiny=0&autoplay=true")
});
return embed;
};
playerVideo.qiniu.embed = function (url) {
return this.getEmbed({
// src: `//v.qq.com/iframe/player.html?vid=${vid}&tiny=0&auto=1`,
src: url
}, 'qiniu');
};
playerVideo.youku.embed = function (vid) {
var embed = this.getEmbed({
src: "//player.youku.com/embed/".concat(vid, "?client_id=417dca79f8434cc8&password=undefined&autoplay=true"),
scrolling: 'no',
allow: 'autoplay'
});
return embed;
};
playerVideo.youtube.embed = function (vid) {
var embed = this.getEmbed({
src: "//www.youtube.com/embed/".concat(vid),
scrolling: 'no',
allow: 'autoplay; encrypted-media'
});
return embed;
};
return function (url) {
console.log('url', url);
var type = playerVideo.judgeVideoType(url);
if (!type) {
console.log('瑙嗛閾炬帴閿欒');
return;
}
console.log(type);
playerVideo[type].play(url);
};
}();
window.playInsetVideo = playInsetVideo;
!function () {
'use strict';
function h(nodeName, attributes) {
var lastSimple,
child,
simple,
i,
children = EMPTY_CHILDREN;
for (i = arguments.length; i-- > 2;) {
stack.push(arguments[i]);
}
if (attributes && null != attributes.children) {
if (!stack.length) stack.push(attributes.children);
delete attributes.children;
}
while (stack.length) {
if ((child = stack.pop()) && void 0 !== child.pop) for (i = child.length; i--;) {
stack.push(child[i]);
} else {
if ('boolean' == typeof child) child = null;
if (simple = 'function' != typeof nodeName) if (null == child) child = '';else if ('number' == typeof child) child = String(child);else if ('string' != typeof child) simple = !1;
if (simple && lastSimple) children[children.length - 1] += child;else if (children === EMPTY_CHILDREN) children = [child];else children.push(child);
lastSimple = simple;
}
}
var p = new VNode();
p.nodeName = nodeName;
p.children = children;
p.attributes = null == attributes ? void 0 : attributes;
p.key = null == attributes ? void 0 : attributes.key;
if (void 0 !== options.vnode) options.vnode(p);
return p;
}
function extend(obj, props) {
for (var i in props) {
obj[i] = props[i];
}
return obj;
}
function applyRef(ref, value) {
if (null != ref) if ('function' == typeof ref) ref(value);else ref.current = value;
}
function cloneElement(vnode, props) {
return h(vnode.nodeName, extend(extend({}, vnode.attributes), props), arguments.length > 2 ? [].slice.call(arguments, 2) : vnode.children);
}
function enqueueRender(component) {
if (!component.__d && (component.__d = !0) && 1 == items.push(component)) (options.debounceRendering || defer)(rerender);
}
function rerender() {
var p;
while (p = items.pop()) {
if (p.__d) renderComponent(p);
}
}
function isSameNodeType(node, vnode, hydrating) {
if ('string' == typeof vnode || 'number' == typeof vnode) return void 0 !== node.splitText;
if ('string' == typeof vnode.nodeName) return !node._componentConstructor && isNamedNode(node, vnode.nodeName);else return hydrating || node._componentConstructor === vnode.nodeName;
}
function isNamedNode(node, nodeName) {
return node.__n === nodeName || node.nodeName.toLowerCase() === nodeName.toLowerCase();
}
function getNodeProps(vnode) {
var props = extend({}, vnode.attributes);
props.children = vnode.children;
var defaultProps = vnode.nodeName.defaultProps;
if (void 0 !== defaultProps) for (var i in defaultProps) {
if (void 0 === props[i]) props[i] = defaultProps[i];
}
return props;
}
function createNode(nodeName, isSvg) {
var node = isSvg ? document.createElementNS('http://www.w3.org/2000/svg', nodeName) : document.createElement(nodeName);
node.__n = nodeName;
return node;
}
function removeNode(node) {
var parentNode = node.parentNode;
if (parentNode) parentNode.removeChild(node);
}
function setAccessor(node, name, old, value, isSvg) {
if ('className' === name) name = 'class';
if ('key' === name) ;else if ('ref' === name) {
applyRef(old, null);
applyRef(value, node);
} else if ('class' === name && !isSvg) node.className = value || '';else if ('style' === name) {
if (!value || 'string' == typeof value || 'string' == typeof old) node.style.cssText = value || '';
if (value && 'object' == _typeof2(value)) {
if ('string' != typeof old) for (var i in old) {
if (!(i in value)) node.style[i] = '';
}
for (var i in value) {
node.style[i] = 'number' == typeof value[i] && !1 === IS_NON_DIMENSIONAL.test(i) ? value[i] + 'px' : value[i];
}
}
} else if ('dangerouslySetInnerHTML' === name) {
if (value) node.innerHTML = value.__html || '';
} else if ('o' == name[0] && 'n' == name[1]) {
var useCapture = name !== (name = name.replace(/Capture$/, ''));
name = name.toLowerCase().substring(2);
if (value) {
if (!old) node.addEventListener(name, eventProxy, useCapture);
} else node.removeEventListener(name, eventProxy, useCapture);
(node.__l || (node.__l = {}))[name] = value;
} else if ('list' !== name && 'type' !== name && !isSvg && name in node) {
try {
node[name] = null == value ? '' : value;
} catch (e) {}
if ((null == value || !1 === value) && 'spellcheck' != name) node.removeAttribute(name);
} else {
var ns = isSvg && name !== (name = name.replace(/^xlink:?/, ''));
if (null == value || !1 === value) {
if (ns) node.removeAttributeNS('http://www.w3.org/1999/xlink', name.toLowerCase());else node.removeAttribute(name);
} else if ('function' != typeof value) if (ns) node.setAttributeNS('http://www.w3.org/1999/xlink', name.toLowerCase(), value);else node.setAttribute(name, value);
}
}
function eventProxy(e) {
return this.__l[e.type](options.event && options.event(e) || e);
}
function flushMounts() {
var c;
while (c = mounts.shift()) {
if (options.afterMount) options.afterMount(c);
if (c.componentDidMount) c.componentDidMount();
}
}
function diff(dom, vnode, context, mountAll, parent, componentRoot) {
if (!diffLevel++) {
isSvgMode = null != parent && void 0 !== parent.ownerSVGElement;
hydrating = null != dom && !('__preactattr_' in dom);
}
var ret = idiff(dom, vnode, context, mountAll, componentRoot);
if (parent && ret.parentNode !== parent) parent.appendChild(ret);
if (! --diffLevel) {
hydrating = !1;
if (!componentRoot) flushMounts();
}
return ret;
}
function idiff(dom, vnode, context, mountAll, componentRoot) {
var out = dom,
prevSvgMode = isSvgMode;
if (null == vnode || 'boolean' == typeof vnode) vnode = '';
if ('string' == typeof vnode || 'number' == typeof vnode) {
if (dom && void 0 !== dom.splitText && dom.parentNode && (!dom._component || componentRoot)) {
if (dom.nodeValue != vnode) dom.nodeValue = vnode;
} else {
out = document.createTextNode(vnode);
if (dom) {
if (dom.parentNode) dom.parentNode.replaceChild(out, dom);
recollectNodeTree(dom, !0);
}
}
out.__preactattr_ = !0;
return out;
}
var vnodeName = vnode.nodeName;
if ('function' == typeof vnodeName) return buildComponentFromVNode(dom, vnode, context, mountAll);
isSvgMode = 'svg' === vnodeName ? !0 : 'foreignObject' === vnodeName ? !1 : isSvgMode;
vnodeName = String(vnodeName);
if (!dom || !isNamedNode(dom, vnodeName)) {
out = createNode(vnodeName, isSvgMode);
if (dom) {
while (dom.firstChild) {
out.appendChild(dom.firstChild);
}
if (dom.parentNode) dom.parentNode.replaceChild(out, dom);
recollectNodeTree(dom, !0);
}
}
var fc = out.firstChild,
props = out.__preactattr_,
vchildren = vnode.children;
if (null == props) {
props = out.__preactattr_ = {};
for (var a = out.attributes, i = a.length; i--;) {
props[a[i].name] = a[i].value;
}
}
if (!hydrating && vchildren && 1 === vchildren.length && 'string' == typeof vchildren[0] && null != fc && void 0 !== fc.splitText && null == fc.nextSibling) {
if (fc.nodeValue != vchildren[0]) fc.nodeValue = vchildren[0];
} else if (vchildren && vchildren.length || null != fc) innerDiffNode(out, vchildren, context, mountAll, hydrating || null != props.dangerouslySetInnerHTML);
diffAttributes(out, vnode.attributes, props);
isSvgMode = prevSvgMode;
return out;
}
function innerDiffNode(dom, vchildren, context, mountAll, isHydrating) {
var j,
c,
f,
vchild,
child,
originalChildren = dom.childNodes,
children = [],
keyed = {},
keyedLen = 0,
min = 0,
len = originalChildren.length,
childrenLen = 0,
vlen = vchildren ? vchildren.length : 0;
if (0 !== len) for (var i = 0; i < len; i++) {
var _child = originalChildren[i],
props = _child.__preactattr_,
key = vlen && props ? _child._component ? _child._component.__k : props.key : null;
if (null != key) {
keyedLen++;
keyed[key] = _child;
} else if (props || (void 0 !== _child.splitText ? isHydrating ? _child.nodeValue.trim() : !0 : isHydrating)) children[childrenLen++] = _child;
}
if (0 !== vlen) for (var i = 0; i < vlen; i++) {
vchild = vchildren[i];
child = null;
var key = vchild.key;
if (null != key) {
if (keyedLen && void 0 !== keyed[key]) {
child = keyed[key];
keyed[key] = void 0;
keyedLen--;
}
} else if (min < childrenLen) for (j = min; j < childrenLen; j++) {
if (void 0 !== children[j] && isSameNodeType(c = children[j], vchild, isHydrating)) {
child = c;
children[j] = void 0;
if (j === childrenLen - 1) childrenLen--;
if (j === min) min++;
break;
}
}
child = idiff(child, vchild, context, mountAll);
f = originalChildren[i];
if (child && child !== dom && child !== f) if (null == f) dom.appendChild(child);else if (child === f.nextSibling) removeNode(f);else dom.insertBefore(child, f);
}
if (keyedLen) for (var i in keyed) {
if (void 0 !== keyed[i]) recollectNodeTree(keyed[i], !1);
}
while (min <= childrenLen) {
if (void 0 !== (child = children[childrenLen--])) recollectNodeTree(child, !1);
}
}
function recollectNodeTree(node, unmountOnly) {
var component = node._component;
if (component) unmountComponent(component);else {
if (null != node.__preactattr_) applyRef(node.__preactattr_.ref, null);
if (!1 === unmountOnly || null == node.__preactattr_) removeNode(node);
removeChildren(node);
}
}
function removeChildren(node) {
node = node.lastChild;
while (node) {
var next = node.previousSibling;
recollectNodeTree(node, !0);
node = next;
}
}
function diffAttributes(dom, attrs, old) {
var name;
for (name in old) {
if ((!attrs || null == attrs[name]) && null != old[name]) setAccessor(dom, name, old[name], old[name] = void 0, isSvgMode);
}
for (name in attrs) {
if (!('children' === name || 'innerHTML' === name || name in old && attrs[name] === ('value' === name || 'checked' === name ? dom[name] : old[name]))) setAccessor(dom, name, old[name], old[name] = attrs[name], isSvgMode);
}
}
function createComponent(Ctor, props, context) {
var inst,
i = recyclerComponents.length;
if (Ctor.prototype && Ctor.prototype.render) {
inst = new Ctor(props, context);
Component.call(inst, props, context);
} else {
inst = new Component(props, context);
inst.constructor = Ctor;
inst.render = doRender;
}
while (i--) {
if (recyclerComponents[i].constructor === Ctor) {
inst.__b = recyclerComponents[i].__b;
recyclerComponents.splice(i, 1);
return inst;
}
}
return inst;
}
function doRender(props, state, context) {
return this.constructor(props, context);
}
function setComponentProps(component, props, renderMode, context, mountAll) {
if (!component.__x) {
component.__x = !0;
component.__r = props.ref;
component.__k = props.key;
delete props.ref;
delete props.key;
if (void 0 === component.constructor.getDerivedStateFromProps) if (!component.base || mountAll) {
if (component.componentWillMount) component.componentWillMount();
} else if (component.componentWillReceiveProps) component.componentWillReceiveProps(props, context);
if (context && context !== component.context) {
if (!component.__c) component.__c = component.context;
component.context = context;
}
if (!component.__p) component.__p = component.props;
component.props = props;
component.__x = !1;
if (0 !== renderMode) if (1 === renderMode || !1 !== options.syncComponentUpdates || !component.base) renderComponent(component, 1, mountAll);else enqueueRender(component);
applyRef(component.__r, component);
}
}
function renderComponent(component, renderMode, mountAll, isChild) {
if (!component.__x) {
var rendered,
inst,
cbase,
props = component.props,
state = component.state,
context = component.context,
previousProps = component.__p || props,
previousState = component.__s || state,
previousContext = component.__c || context,
isUpdate = component.base,
nextBase = component.__b,
initialBase = isUpdate || nextBase,
initialChildComponent = component._component,
skip = !1,
snapshot = previousContext;
if (component.constructor.getDerivedStateFromProps) {
state = extend(extend({}, state), component.constructor.getDerivedStateFromProps(props, state));
component.state = state;
}
if (isUpdate) {
component.props = previousProps;
component.state = previousState;
component.context = previousContext;
if (2 !== renderMode && component.shouldComponentUpdate && !1 === component.shouldComponentUpdate(props, state, context)) skip = !0;else if (component.componentWillUpdate) component.componentWillUpdate(props, state, context);
component.props = props;
component.state = state;
component.context = context;
}
component.__p = component.__s = component.__c = component.__b = null;
component.__d = !1;
if (!skip) {
rendered = component.render(props, state, context);
if (component.getChildContext) context = extend(extend({}, context), component.getChildContext());
if (isUpdate && component.getSnapshotBeforeUpdate) snapshot = component.getSnapshotBeforeUpdate(previousProps, previousState);
var toUnmount,
base,
childComponent = rendered && rendered.nodeName;
if ('function' == typeof childComponent) {
var childProps = getNodeProps(rendered);
inst = initialChildComponent;
if (inst && inst.constructor === childComponent && childProps.key == inst.__k) setComponentProps(inst, childProps, 1, context, !1);else {
toUnmount = inst;
component._component = inst = createComponent(childComponent, childProps, context);
inst.__b = inst.__b || nextBase;
inst.__u = component;
setComponentProps(inst, childProps, 0, context, !1);
renderComponent(inst, 1, mountAll, !0);
}
base = inst.base;
} else {
cbase = initialBase;
toUnmount = initialChildComponent;
if (toUnmount) cbase = component._component = null;
if (initialBase || 1 === renderMode) {
if (cbase) cbase._component = null;
base = diff(cbase, rendered, context, mountAll || !isUpdate, initialBase && initialBase.parentNode, !0);
}
}
if (initialBase && base !== initialBase && inst !== initialChildComponent) {
var baseParent = initialBase.parentNode;
if (baseParent && base !== baseParent) {
baseParent.replaceChild(base, initialBase);
if (!toUnmount) {
initialBase._component = null;
recollectNodeTree(initialBase, !1);
}
}
}
if (toUnmount) unmountComponent(toUnmount);
component.base = base;
if (base && !isChild) {
var componentRef = component,
t = component;
while (t = t.__u) {
(componentRef = t).base = base;
}
base._component = componentRef;
base._componentConstructor = componentRef.constructor;
}
}
if (!isUpdate || mountAll) mounts.push(component);else if (!skip) {
if (component.componentDidUpdate) component.componentDidUpdate(previousProps, previousState, snapshot);
if (options.afterUpdate) options.afterUpdate(component);
}
while (component.__h.length) {
component.__h.pop().call(component);
}
if (!diffLevel && !isChild) flushMounts();
}
}
function buildComponentFromVNode(dom, vnode, context, mountAll) {
var c = dom && dom._component,
originalComponent = c,
oldDom = dom,
isDirectOwner = c && dom._componentConstructor === vnode.nodeName,
isOwner = isDirectOwner,
props = getNodeProps(vnode);
while (c && !isOwner && (c = c.__u)) {
isOwner = c.constructor === vnode.nodeName;
}
if (c && isOwner && (!mountAll || c._component)) {
setComponentProps(c, props, 3, context, mountAll);
dom = c.base;
} else {
if (originalComponent && !isDirectOwner) {
unmountComponent(originalComponent);
dom = oldDom = null;
}
c = createComponent(vnode.nodeName, props, context);
if (dom && !c.__b) {
c.__b = dom;
oldDom = null;
}
setComponentProps(c, props, 1, context, mountAll);
dom = c.base;
if (oldDom && dom !== oldDom) {
oldDom._component = null;
recollectNodeTree(oldDom, !1);
}
}
return dom;
}
function unmountComponent(component) {
if (options.beforeUnmount) options.beforeUnmount(component);
var base = component.base;
component.__x = !0;
if (component.componentWillUnmount) component.componentWillUnmount();
component.base = null;
var inner = component._component;
if (inner) unmountComponent(inner);else if (base) {
if (null != base.__preactattr_) applyRef(base.__preactattr_.ref, null);
component.__b = base;
removeNode(base);
recyclerComponents.push(component);
removeChildren(base);
}
applyRef(component.__r, null);
}
function Component(props, context) {
this.__d = !0;
this.context = context;
this.props = props;
this.state = this.state || {};
this.__h = [];
}
function render(vnode, parent, merge) {
return diff(merge, vnode, {}, !1, parent, !1);
}
function createRef() {
return {};
}
var VNode = function VNode() {};
var options = {};
var stack = [];
var EMPTY_CHILDREN = [];
var defer = 'function' == typeof Promise ? Promise.resolve().then.bind(Promise.resolve()) : setTimeout;
var IS_NON_DIMENSIONAL = /acit|ex(?:s|g|n|p|$)|rph|ows|mnc|ntw|ine[ch]|zoo|^ord/i;
var items = [];
var mounts = [];
var diffLevel = 0;
var isSvgMode = !1;
var hydrating = !1;
var recyclerComponents = [];
extend(Component.prototype, {
setState: function setState(state, callback) {
if (!this.__s) this.__s = this.state;
this.state = extend(extend({}, this.state), 'function' == typeof state ? state(this.state, this.props) : state);
if (callback) this.__h.push(callback);
enqueueRender(this);
},
forceUpdate: function forceUpdate(callback) {
if (callback) this.__h.push(callback);
renderComponent(this, 2);
},
render: function render() {}
});
var preact = {
h: h,
createElement: h,
cloneElement: cloneElement,
createRef: createRef,
Component: Component,
render: render,
rerender: rerender,
options: options
};
if ('undefined' != typeof module) module.exports = preact;else self.preact = preact;
}();
'use strict';
/*
* 浠ュ悗杩欓噷鍙互涓簐node娣诲姞灞炴€
*/
function Vnode() {}
var toString = Object.prototype.toString;
var isObject = function isObject(val) {
return toString.call(val) === '[object Object]';
};
var isArray = function isArray(val) {
return toString.call(val) === '[object Array]';
};
var extendNewProperty = function extendNewProperty(oldVal) {
// 鍙鍔犺嚜韬病鏈夌殑灞炴€
var arr = [].slice.call(arguments, 1);
arr.forEach(function (obj) {
for (var i in obj) {
if (obj.hasOwnProperty(i) && !oldVal.hasOwnProperty(i)) {
oldVal[i] = obj[i];
}
}
});
return oldVal;
};
var defer = typeof Promise == 'function' ? Promise.resolve().then.bind(Promise.resolve()) : setTimeout;
/**
*
* @param {string | function} nodeName An element name. Ex: `div`, `a`, `span`, etc.
* @param {object | null} attributes Any attributes/props to set on the created element.
*
* @public
*/
function h(nodeName) {
var attributes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; // 鐢熸垚铏氭嫙dom鑺傜偣
var children;
if (attributes && attributes.children) {
children = isArray(attributes.children) ? attributes.children : [];
delete attributes.children;
}
/* 鍏煎jsx缂栬瘧鍑烘潵鍚? 瀛愯妭鐐规槸浣滀负鍙傛暟浼犺繘鏉ョ殑 */
if (arguments.length > 2) {
children = children || [];
for (var i = 2; i < arguments.length; i++) {
isArray(arguments[i]) ? arguments[i].forEach(function (child) {
return transformTextNode(children, child);
}) : transformTextNode(children, arguments[i]);
}
}
/* 閫氳繃寰幆鐢熸垚鑺傜偣, 鍙傛暟浼氭槸涓€涓暟缁 */
var vn = new Vnode();
vn.nodeName = nodeName;
vn.children = children || [];
vn.attr = attributes || {};
vn.key = attributes && attributes.key !== void 0 ? attributes.key : '';
return vn;
}
var transformTextNode = function transformTextNode(arr, child) {
// 鍦ㄥ線children鏁扮粍push鐨勬椂鍊
/*
* child 瀛樺湪鏂囨湰瀛楃涓层€佸璞°€乽ndefined涓夌鎯呭喌锛寀ndefined鎸夌┖瀛楃涓插鐞
*/
if (child === void 0) {
child = '';
}
arr.push(typeof child === 'string' || typeof child === 'number' ? h('', {
text: child
}) : child);
};
function _typeof(obj) {
if (typeof Symbol === "function" && _typeof2(Symbol.iterator) === "symbol") {
_typeof = function _typeof(obj) {
return _typeof2(obj);
};
} else {
_typeof = function _typeof(obj) {
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : _typeof2(obj);
};
}
return _typeof(obj);
}
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}
function _defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
function _createClass(Constructor, protoProps, staticProps) {
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
if (staticProps) _defineProperties(Constructor, staticProps);
return Constructor;
}
function _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
function _objectSpread(target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i] != null ? arguments[i] : {};
var ownKeys = Object.keys(source);
if (typeof Object.getOwnPropertySymbols === 'function') {
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) {
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
}));
}
ownKeys.forEach(function (key) {
_defineProperty(target, key, source[key]);
});
}
return target;
}
function bindRef(component, value, el) {
if (!component) {
return;
}
component.refs = component.refs || {};
component.refs[value] = el;
}
/**
*
* @param {HTMLElement} el dom鑺傜偣
* @param {string} name 灞炴€у悕
* @param {string | function} value 灞炴€у€
* @param {import(../component.js)} vc 缁勪欢瀹炰緥
*
* @public
*/
function bindAttr(el, name, value, component) {
// 瀵逛簬浼犲叆attr灞炴€х殑缁戝畾
if (name === 'className') {
name = 'class';
}
if (name === 'key') ;else if (name === 'class') {
el.className = value;
} else if (name[0] === 'o' && name[1] === 'n') {
// 澶勭悊绫讳技onClick鐨勪簨浠
var eventType = name.slice(2).toLowerCase();
var porxyEvent = eventProxy(value);
el.addEventListener(eventType, porxyEvent, false);
el._listener = el._listener || {};
el._listener[eventType] = porxyEvent;
} else if (name === 'style') {
if (typeof value === 'string') {
el.style.cssText = value;
} else if (_typeof(value) === 'object') {
for (var i in value) {
el.style[i] = value[i];
}
}
} else if (name === 'ref') {
// 缁戝畾ref
bindRef(component, value, el);
} else {
el.setAttribute(name, value);
}
}
function eventProxy(fn) {
return function (e) {
fn(e);
};
}
var insertBefore = function insertBefore(parent, newnode, existingnode) {
if (parent.nodeType === 11) {
parent = existingnode.parentNode;
}
parent.insertBefore(newnode, existingnode);
};
var removeChild = function removeChild(parent, node) {
parent.removeChild(node);
};
var appendChild = function appendChild(parent, child) {
parent.appendChild(child);
};
var nextSibling = function nextSibling(node) {
return node.nextSibling;
};
var diff = function diff(dom, oldVnode, newVnode, component) {
// component鏄diff鐨勮嚜瀹氫箟缁勪欢
patchReuseDom(dom, oldVnode, newVnode, component);
};
var diffAttr = function diffAttr(dom, oldAttr, newAttr, component) {
// 灞炴€у姣
for (var name in oldAttr) {
if (newAttr.hasOwnProperty(name)) break; // 鏂板睘鎬т笂涓嶅瓨鍦ㄧ殑鏄绉婚櫎鐨
isEventAttr(name) ? removeDomListener(dom, name) : removeAttribute(dom, name);
}
for (var _name in newAttr) {
if (oldAttr.hasOwnProperty(_name)) {
if (isEventAttr(_name)) {
removeDomListener(dom, _name);
} else if (_name === 'ref' || newAttr[_name] !== oldAttr[_name]) {
bindAttr(dom, _name, newAttr[_name], component);
}
} else {
bindAttr(dom, _name, newAttr[_name], component);
}
}
};
var removeAttribute = function removeAttribute(dom, key) {
if (key === 'className') {
key = 'class';
}
dom.removeAttribute(key);
};
var isEventAttr = function isEventAttr(name) {
// 鍒ゆ柇鏄惁涓轰簨浠剁被鍨嬬殑灞炴€
return name[0] === 'o' && name[1] === 'n';
};
var removeDomListener = function removeDomListener(dom, name) {
// 绉婚櫎灞炴€
var eventType = name.slice(1).toLowerCase();
dom.removeEventListener(eventType, dom._listener[eventType]);
};
var diffChildNode = function diffChildNode(parent, oldChildren, newChildren, component) {
// 姣旇緝瀛愯妭鐐
var oldStartInd = 0;
var newStartInd = 0;
var oldEndInd = oldChildren.length - 1;
var newEndInd = newChildren.length - 1;
var oldStartVnode = oldChildren[0];
var newStartVnode = newChildren[0];
var oldEndVnode = oldChildren[oldEndInd];
var newEndVnode = newChildren[newEndInd];
var keyMap = null;
while (oldStartInd <= oldEndInd && newStartInd <= newEndInd) {
if (!oldStartVnode) {
oldStartVnode = oldChildren[++oldStartInd]; // Vnode might have been moved left
} else if (!oldEndVnode) {
oldEndVnode = oldChildren[--oldEndInd];
} else if (!newStartVnode) {
newStartVnode = newCh[++newStartInd];
} else if (!newEndVnode) {
newEndVnode = newCh[--newEndInd];
} else if (isSameVnode(oldStartVnode, newStartVnode)) {
// 濡傛灉澶撮儴鐩稿悓
patchReuseDom(oldStartVnode._dom, oldStartVnode, newStartVnode, component);
newStartVnode = newChildren[++newStartInd];
oldStartVnode = oldChildren[++oldStartInd];
} else if (isSameVnode(oldEndVnode, newEndVnode)) {
// 濡傛灉灏鹃儴鐩稿悓
patchReuseDom(oldEndVnode._dom, oldEndVnode, newEndVnode, component);
oldEndVnode = oldChildren[--oldEndInd];
newEndVnode = newChildren[--newEndInd];
} else if (isSameVnode(oldStartVnode, newEndVnode)) {
// 鏃уご鍜屾柊灏句竴鑷存椂,鎶婃棫澶寸Щ鍔ㄥ埌鏈€鍚
patchReuseDom(oldStartVnode._dom, oldStartVnode, newEndVnode, component);
insertBefore(parent, oldStartVnode._dom, nextSibling(oldEndVnode._dom));
oldStartVnode = oldChildren[++oldStartInd];
newEndVnode = newChildren[--newEndInd];
} else if (isSameVnode(oldEndVnode, newStartVnode)) {
// 鏃у熬鍜屾柊澶翠竴鑷存椂
patchReuseDom(oldEndVnode._dom, oldEndVnode, newStartVnode, component);
insertBefore(parent, oldEndVnode._dom, oldStartVnode._dom);
newStartVnode = newChildren[++newStartInd];
oldEndVnode = oldChildren[--oldEndInd];
} else {
if (!keyMap) {
keyMap = flattenMapKey(oldChildren, oldStartInd, oldEndInd);
}
var ind = keyMap[newStartVnode.key];
var oldElm = oldStartVnode._dom;
if (ind !== void 0 && newStartVnode.nodeName === oldChildren[ind].nodeName) {
// 濡傛灉瀛樺湪key鐩稿悓鐨勫苟涓攏ode绫诲瀷涓€鑷
var reuseEl = oldChildren[ind]._dom;
patchReuseDom(reuseEl, oldChildren[ind], newStartVnode, component);
insertBefore(parent, reuseEl, oldElm);
oldChildren[ind] = undefined;
} else {
// 涓嶅瓨鍦ㄧ浉鍚岀殑key鐨勬椂鍊? 鐩存帴鍒ゅ畾涓洪渶瑕佹柊澧炵殑鑺傜偣
var el = parseObjectVnode(newStartVnode);
if (parent.nodeType === 11) {
parent = oldElm.parentNode;
}
insertBefore(parent, el, oldElm);
}
newStartVnode = newChildren[++newStartInd];
}
}
if (oldStartInd > oldEndInd) {
if (newStartInd > newEndInd) {
// 闃叉娌℃湁鐨勬柊鐨勫厓绱犲彲鍔犵殑鎯呭喌
return;
}
/* newChildren鍓╀綑閮ㄥ垎搴斿叏閮芥坊鍔犲埌dom閲 */
var before = newChildren[newEndInd + 1] && newChildren[newEndInd + 1]._dom;
addVnodes(parent, newChildren.slice(newStartInd, newEndInd + 1), before);
} else if (newStartInd > newEndInd) {
// 鏂拌妭鐐瑰凡缁忓鐞嗗畬姣? 鍒犻櫎oldStartIndex 鍜 oldEndIndex涔嬮棿鐨
if (oldStartInd > oldEndInd) {
return;
}
removeVnodes(parent, oldChildren.slice(oldStartInd, oldEndInd + 1));
}
};
var isSameVnode = function isSameVnode(node1, node2) {
// 鍒ゆ柇鏄惁澶嶇敤dom鑺傜偣
return node1.nodeName === node2.nodeName && node1.key === node2.key;
};
var patchTextTypeNode = function patchTextTypeNode(dom, oldVnode, newVnode) {
/*
* 褰撳鐢ㄧ殑dom鑺傜偣鏂拌櫄鎷焏om鐨勭被鍨嬪瓨鍦ㄦ椂鏂囨湰鏃
* oldvnode鏄枃鏈椂, 鑻ewVnode涔熸槸, 鐩存帴淇敼鏂囨湰鍐呭
*/
var oldIsText = isTextNode(oldVnode);
var newIsText = isTextNode(newVnode);
if (!oldIsText || oldIsText && newIsText) {
// 涓よ€呴兘鏄枃鏈
if (newVnode.attr.text === oldVnode.attr.text) {
return;
}
dom.textContent = newVnode.attr.text;
} else if (oldIsText && !newIsText) {
var el = parseObjectVnode(newVnode);
parent.replaceChild(el);
}
};
var patchReuseDom = function patchReuseDom(dom, oldVnode, newVnode, component) {
// 澶勭悊鍙鐢ㄧ殑dom
newVnode._dom = dom;
if (isTextNode(oldVnode) || isTextNode(newVnode)) {
patchTextTypeNode(dom, oldVnode, newVnode);
return;
}
/* 濡傛灉涓や釜鏄彲澶嶇敤鐨勮嚜瀹氫箟缁勪欢, 閭d箞灏唕ender鍚庣殑缁勪欢瀵规瘮 */
if (typeof oldVnode.nodeName === 'function') {
var props = getProps(newVnode);
oldVnode._com.prevProps = oldVnode._com.props;
setComponentProps(oldVnode._com, props); // 淇敼鏃х粍浠跺疄渚嬬殑props, 鐒跺悗rerender
newVnode._com = oldVnode._com;
newVnode._parent = oldVnode._parent;
rerenderComponent(oldVnode._com);
return;
}
if (dom.nodeType !== 11) {
// nodeType 涓?1 鐨勬椂鍊欐槸Fragment, 娌℃湁缁戝畾灞炴€х殑闇€瑕
diffAttr(dom, oldVnode.attr, newVnode.attr, component);
}
diffChildNode(dom, oldVnode.children, newVnode.children, component);
};
var flattenMapKey = function flattenMapKey(arr, oldStartIdx, oldEndIdx) {
var map = {};
for (var i = oldStartIdx; i <= oldEndIdx; i++) {
if (arr[i].key !== '' && arr[i].key !== undefined) {
map[arr[i].key] = i;
}
}
return map;
};
var isTextNode = function isTextNode(vnode) {
return vnode.nodeName === '';
};
var removeVnodes = function removeVnodes(parent, arr) {
// 闇€瑕佸垹闄ょ殑vnode鏁扮粍
var len = arr.length;
for (var i = 0; i < len; i++) {
if (arr[i]) {
unMountComponent(arr[i]);
removeChild(parent, arr[i]._dom);
}
}
};
var addVnodes = function addVnodes(parent, arr, before) {
var len = arr.length;
for (var i = 0; i < len; i++) {
if (before) {
insertBefore(parent, parseObjectVnode(arr[i]), before);
} else {
appendChild(parent, parseObjectVnode(arr[i]));
}
}
};
var unMountComponent = function unMountComponent(vnode) {
// 铏氭嫙dom鍗歌浇鏃舵墽琛寀nMount鐨勭敓鍛藉懆鏈
if (typeof vnode.nodeName !== 'function') {
return;
}
var _com = vnode._com;
if (_com.componentWillUnmount) {
_com.componentWillUnmount();
}
_com._vnode.children.forEach(function (vnode) {
return unMountComponent(vnode);
});
};
var renderQueue = [];
function equeueRender(component) {
// 灏嗙粍浠跺疄渚嬫帹鍏ュ緟rerender闃熷垪
if (!component.dirty) {
renderQueue.push(component);
component.dirty = true;
defer(rerender);
}
}
function rerender() {
var p;
while (p = renderQueue.pop()) {
rerenderComponent(p);
}
}
/**
* 澶勭悊鑷畾涔夌粍浠堕噸鏂版覆鏌
* @param {import(./component.js)} component 鑷畾涔夌粍浠跺疄渚
*
* @public
*/
function rerenderComponent(component) {
/* debugger */
var vnode = component._vnode; // 鑾峰彇缁戝畾鐨剉node
var dom = component._dom;
var snap = '';
var skip = false; // 鏍囧織鏄惁瑕佽烦杩囨覆鏌
/* 璋冪敤shouldComponentUpdate */
var props = component.props;
var state = component.state;
var prevProps = component.prevProps || props;
var prevState = component.prevState || state;
var shouComponentUpdate = component.shouldComponentUpdate;
if (shouComponentUpdate) {
component.state = prevState;
component.props = prevProps;
if (shouComponentUpdate.call(component, props, state) === false) {
skip = true;
}
}
component.state = state;
component.props = props;
if (skip) return;
var rendered = component.render(props);
rendered._com = component;
component._vnode = rendered;
if (component.getSnapshotBeforeUpdate) {
snap = component.getSnapshotBeforeUpdate(prevProps, prevState);
console.log(snap);
}
diff(dom, vnode, rendered, component);
if (component.componentDidUpdate) {
component.componentDidUpdate(prevProps, prevState, snap);
}
component.dirty = false;
}
/**
*
* @param {object | null} props 浼犻€掔粰缁勪欢鐨勫睘鎬
*
* @public
*/
var Component = /*#__PURE__*/function () {
function Component(props) {
_classCallCheck(this, Component);
this.state = {};
this.props = props;
}
_createClass(Component, [{
key: "render",
value: function render() {}
}]);
return Component;
}();
var PureComponent = /*#__PURE__*/function () {
function PureComponent(props) {
_classCallCheck(this, PureComponent);
this.state = {};
this.props = props;
}
_createClass(PureComponent, [{
key: "shouldComponentUpdate",
value: function shouldComponentUpdate(nextProps, nextState) {
if (nextProps === this.props && nextState === this.state) {
return false;
}
return true;
}
}, {
key: "render",
value: function render() {}
}]);
return PureComponent;
}();
function setState(newState, callback) {
if (!this.prevState) {
this.prevState = this.state;
}
this.state = extendNewProperty(newState, this.state);
this.refs = {};
equeueRender(this);
}
PureComponent.prototype.setState = setState;
Component.prototype.setState = setState;
function createFragmentNode(vnode) {
var el = document.createDocumentFragment(); // 瀵规瘮createNode灏戜簡娣诲姞灞炴€х殑鐜妭
return el;
}
function createNode(vnode, component) {
// components鏄粍寤哄疄渚
var el = document.createElement(vnode.nodeName);
var attr = vnode.attr;
Object.keys(attr).forEach(function (key) {
// 涓篹l鑺傜偣娣诲姞灞炴€
bindAttr(el, key, attr[key], vnode._com);
});
return el;
}
function childVnodeRender(vnode, parent, parentVnode) {
// 瀵瑰瓙铏氭嫙dom鑺傜偣鐨勮В鏋
vnode._parent = parentVnode;
parseObjectVnode(vnode, parent);
}
function parseObjectVnode(vnode, parent) {
// vnode 涓哄璞? 鏈€甯歌鐨勫舰寮
var el;
var nodeName = vnode.nodeName;
if (typeof nodeName === 'string') {
if (!nodeName) {
// 鏂囨湰鑺傜偣鐨勬椂鍊
el = parseStringOrNumberVnode(vnode.attr.text);
} else if (nodeName === 'Frag') {
// 纰庣墖鏂囨湰鑺傜偣
el = createFragmentNode(vnode);
} else {
el = createNode(vnode);
}
if (vnode.children && vnode.children.length > 0) {
// 濡傛灉瀛樺湪瀛愯妭鐐
vnode.children.forEach(function (childVnode) {
childVnodeRender(childVnode, el, vnode);
});
}
} else if (typeof nodeName === 'function') {
// 鑷畾涔夌粍浠剁殑鏃跺€
el = createCustomElement(vnode);
var componentDidMount = vnode._com.componentDidMount;
if (componentDidMount) componentDidMount.call(vnode._com);
}
vnode._dom = el;
if (parent) {
parent.appendChild(el);
}
return el;
}
function parseStringOrNumberVnode(vnode, parent) {
// vnode涓哄瓧绗︿覆鎴栬€
return document.createTextNode(vnode);
}
function createCustomElement(vnode, ins) {
// 鍒涘缓鑷畾涔夌粍浠惰妭鐐? ins鏄師缁勪欢瀹炰緥
var renderVnode = createCustomRenderVnode(vnode, ins);
var el = parseObjectVnode(renderVnode, null);
ins ? ins._dom = el : renderVnode._com._dom = el;
return el;
}
function createCustomRenderVnode(vnode, ins) {
// 鐢熸垚缁勪欢娓叉煋鐨勮櫄鎷焏om, ins鏄粍浠跺疄渚
var props = getProps(vnode);
if (!ins) {
if (!isOnlyFunctionComponent(vnode)) {
// 濡傛灉鏄竴涓崟绾殑鍑芥暟, 缁ф壙Component骞剁敓鎴愬疄渚
ins = new Component(props);
ins.render = vnode.nodeName;
if (vnode.isContextChild) {
ins.contextProps = vnode.contextProps;
}
} else {
ins = new vnode.nodeName();
}
}
setComponentProps(ins, props);
var insVnode = ins.render(ins.contextProps || props);
console.log(insVnode);
vnode.renderVnode = ins;
insVnode._com = ins;
vnode._com = ins;
ins._vnode = insVnode;
return insVnode;
}
function getProps(vnode) {
// vnode铏氭嫙dom瀵硅薄, 鐢県鐢熸垚
var attr = _objectSpread({}, vnode.attr, {
children: vnode.children
});
var defaultProps = vnode.nodeName.defaultProps;
if (!defaultProps) {
if (isObject(defaultProps)) {
attr = _objectSpread({}, defaultProps, attr);
}
}
return attr;
}
function setComponentProps(component, props) {
// 涓篶omponent瀹炰緥璁剧疆props灞炴€
component._key = props.key;
component._ref = props.ref;
delete props.key;
delete props.ref;
component.props = props;
var getDerivedStateFromProps = component.constructor.getDerivedStateFromProps;
if (getDerivedStateFromProps) {
getDerivedStateFromProps.call(null, props, component.state);
}
}
function isOnlyFunctionComponent(vnode) {
// 鍒ゆ柇涓€涓嚜瀹氫箟缁勪欢鏄惁鍙槸涓€涓崟绾殑鍑芥暟
var proto = vnode.nodeName.prototype;
return proto && proto.render;
}
/**
*
* @param {import('./vnode').VNode} vnode 铏氭嫙dom鑺傜偣
* @param {HTMLElement} parent DOM ELement
*
* @public
*/
var render = function render(vnode, parent) {
var result = parseObjectVnode(vnode);
parent.appendChild(result);
};
function renderToString(vnode) {
var str;
if (typeof vnode.nodeName === 'function') {
str = renderClassComponent(vnode, 1);
} else if (typeof vnode.nodeName === 'string') {
str = renderNormalString(vnode, 1);
}
return str;
}
function renderClassComponent(vnode, str) {
var ins = new vnode.nodeName();
var props = getProps(vnode);
ins.props = props;
var insVNode = ins.render();
if (insVNode.nodeName && typeof insVNode.nodeName === 'string') {
return renderNormalString(insVNode, str);
} else if (typeof insVNode.nodeName === 'function') {
return renderClassComponent(insVNode, str);
}
}
function renderNormalString(vnode, str) {
var container = templateFactory(vnode.nodeName, str);
var child;
if (vnode.children.length) {
child = vnode.children.map(function (vnode, index) {
var nodeName = vnode.nodeName;
if (nodeName === '') {
// 濡傛灉鏄枃鏈妭鐐
return vnode.attr.text;
} else if (typeof nodeName === 'string') {
return renderNormalString(vnode, str + '-' + index);
} else if (typeof nodeName === 'function') {
return renderClassComponent(vnode, str + '-' + index);
}
}).join('');
}
if (child) {
container = container.replace('$$', child);
}
return container;
}
function templateFactory(nodeName, str) {
return "<".concat(nodeName, " r-vid=").concat(str, ">$$").concat(nodeName, ">");
}
function createContext() {
var contextProps;
return {
Provider: function Provider(props) {
contextProps = props.value;
return h('Frag', null, props.children);
},
Consumer: function Consumer(props) {
var children = [];
var len = props.children.length;
for (var i = 0; i < len; i++) {
var vnode = void 0;
var val = props.children[i];
if (typeof val === 'function') {
vnode = h(val, null);
vnode.isContextChild = true;
vnode.contextProps = contextProps;
} else {
vnode = val;
}
children[i] = vnode;
}
return h('Frag', null, children);
}
};
}
function domBindVnode(vnode, el) {
parseObjectVnode$1(vnode, el);
}
function childVnodeRender$1(vnode, parentVnode, el) {
// 瀵瑰瓙铏氭嫙dom鑺傜偣鐨勮В鏋
vnode._parent = parentVnode;
parseObjectVnode$1(vnode, el);
}
function parseObjectVnode$1(vnode, el) {
// vnode 涓哄璞? 鏈€甯歌鐨勫舰寮
var nodeName = vnode.nodeName;
if (typeof nodeName === 'string') {
if (nodeName) {
// 闈炴枃鏈妭鐐圭殑鏃跺€
var attr = vnode.attr;
Object.keys(attr).forEach(function (key) {
// 涓篹l鑺傜偣娣诲姞灞炴€
bindAttr(el, key, attr[key], vnode._com);
});
}
vnode._dom = el;
if (vnode.children && vnode.children.length > 0) {
// 濡傛灉瀛樺湪瀛愯妭鐐
var elChildren = el.children;
var elChildrenLen = elChildren.length;
var vnodeChildrenLen = vnode.children.length;
if (vnodeChildrenLen === elChildrenLen) {
// 璇ヨ妭鐐逛笅鏃犳枃鏈妭鐐圭殑鎯呭喌
vnode.children.forEach(function (childVnode, ind) {
childVnodeRender$1(childVnode, vnode, el.children[ind]);
});
} else if (vnodeChildrenLen > elChildrenLen) {
// vnode涓嬪瓨鍦ㄦ枃鏈妭鐐圭殑鏃跺€? el.children闀垮害鏄皬浜巚node鐨勫瓙鑺傜偣鐨?鐩墠鍙鐞嗕竴涓厓绱犱粎鏈変竴涓枃鏈妭鐐圭殑鎯呭喌
childVnodeRender$1(vnode.children[0], vnode, el.firstChild);
}
}
} else if (typeof nodeName === 'function') {
// 鑷畾涔夌粍浠剁殑鏃跺€
createCustomElement$1(vnode, el);
var componentDidMount = vnode._com.componentDidMount;
if (componentDidMount) componentDidMount.call(vnode._com);
}
return el;
}
function createCustomElement$1(vnode, el) {
// 鍒涘缓鑷畾涔夌粍浠惰妭鐐? ins鏄師缁勪欢瀹炰緥
var renderVnode = createCustomRenderVnode$1(vnode, el);
parseObjectVnode$1(renderVnode, el);
}
function createCustomRenderVnode$1(vnode, el) {
// 鐢熸垚缁勪欢娓叉煋鐨勮櫄鎷焏om, ins鏄粍浠跺疄渚
var props = getProps$1(vnode);
var ins;
if (!isOnlyFunctionComponent$1(vnode)) {
// 濡傛灉鏄竴涓崟绾殑鍑芥暟, 缁ф壙Component骞剁敓鎴愬疄渚
ins = new Component(props);
ins.render = vnode.nodeName;
} else {
ins = new vnode.nodeName();
}
setComponentProps$1(ins, props);
var insVnode = ins.render(props);
vnode.renderVnode = ins;
insVnode._com = ins;
vnode._com = ins;
ins._vnode = insVnode;
ins._dom = el;
return insVnode;
}
function getProps$1(vnode) {
// vnode铏氭嫙dom瀵硅薄, 鐢県鐢熸垚
var attr = _objectSpread({}, vnode.attr, {
children: vnode.children
});
var defaultProps = vnode.nodeName.defaultProps;
if (!defaultProps) {
if (isObject(defaultProps)) {
attr = _objectSpread({}, defaultProps, attr);
}
}
return attr;
}
function setComponentProps$1(component, props) {
// 涓篶omponent瀹炰緥璁剧疆props灞炴€
component._key = props.key;
component._ref = props.ref;
delete props.key;
delete props.ref;
component.props = props;
var getDerivedStateFromProps = component.constructor.getDerivedStateFromProps;
if (getDerivedStateFromProps) {
getDerivedStateFromProps.call(null, props, component.state);
}
}
function isOnlyFunctionComponent$1(vnode) {
// 鍒ゆ柇涓€涓嚜瀹氫箟缁勪欢鏄惁鍙槸涓€涓崟绾殑鍑芥暟
var proto = vnode.nodeName.prototype;
return proto && proto.render;
}
var myReact = {
h: h,
render: render,
Component: Component,
PureComponent: PureComponent,
renderToString: renderToString,
Fragment: 'Frag',
createContext: createContext,
domBindVnode: domBindVnode
};
window.myReact = myReact;
/* export default myReact */
/* window.fbAsyncInit = function() {
FB.init({
appId : '1586833361466371',
autoLogAppEvents : true,
xfbml : true,
version : 'v6.0'
});
}; */
var shareTo = function () {
var share = {
facebook: function facebook(obj) {
window.open('https://www.facebook.com/sharer.php?u=' + obj.url);
/* FB.ui({
method: 'share',
href: obj.url,
}, function(response){
console.log(response)
}) */
},
twitter: function twitter(obj) {
var str = [];
for (var i in obj) {
str.push(i + '=' + obj[i]);
}
window.open('https://twitter.com/intent/tweet?' + str.join('&'));
},
linkedin: function linkedin(obj) {
var str = [];
for (var i in obj) {
str.push(i + '=' + obj[i]);
}
window.open('http://www.linkedin.com/shareArticle?' + str.join('&'));
}
};
return function (type, url) {
share[type](url);
};
}();
/* 寰俊閰嶇疆鏂囦欢 */
var jsApiList = ['updateAppMessageShareData', 'updateTimelineShareData', 'onMenuShareAppMessage', 'onMenuShareTimeline', 'getLocation'];
var wxShare = {};
wxShare.updateAppMessageShareData = function (option) {
wx && wx.updateAppMessageShareData({
// 鍒嗕韩缁欐湅鍙
title: document.title || option.title,
//鍒嗕韩鏍囬
desc: '鏋侀绉戞妧鎴愮珛浜 2007 骞达紝浠モ€滄彁鍗囧叏鐞冨啘涓氱敓浜ф晥鐜団€濅负浼佷笟浣垮懡' || option.desc,
//鍒嗕韩鎻忚堪
link: location.href,
imgUrl: 'https://static.xag.cn/img/weixin-share.png' || option.imgUrl // 鍒嗕韩鍥炬爣
}, function (res) {// 鎴愬姛鍥炶皟
});
};
wxShare.updateTimelineShareData = function (option) {
wx && wx.updateTimelineShareData({
// 鍒嗕韩鍒版湅鍙嬪湀
title: '',
// 鍒嗕韩鏍囬
link: '',
// 鍒嗕韩閾炬帴锛岃閾炬帴鍩熷悕鎴栬矾寰勫繀椤讳笌褰撳墠椤甸潰瀵瑰簲鐨勫叕浼楀彿JS瀹夊叏鍩熷悕涓€鑷
imgUrl: '' // 鍒嗕韩鍥炬爣
}, function (res) {//杩欓噷鏄洖璋冨嚱鏁
});
};
wxShare.shareConfig = function () {
var option = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; // 鍒嗕韩鏈嬪弸鍦堝拰鍒嗕韩鍒版湅鍙嬬粺涓€閰嶇疆
$.get('/site/get-wechat-data', {
url: location.href
}, function (data) {
data = JSON.parse(data).data;
wx.config({
debug: option.debug || false,
// 寮€鍚皟璇曟ā寮?璋冪敤鐨勬墍鏈塧pi鐨勮繑鍥炲€间細鍦ㄥ鎴风alert鍑烘潵锛岃嫢瑕佹煡鐪嬩紶鍏ョ殑鍙傛暟锛屽彲浠ュ湪pc绔墦寮€锛屽弬鏁颁俊鎭細閫氳繃log鎵撳嚭锛屼粎鍦╬c绔椂鎵嶄細鎵撳嵃銆
appId: data.appId,
// 蹇呭~锛屽叕浼楀彿鐨勫敮涓€鏍囪瘑
timestamp: data.timestamp,
// 蹇呭~锛岀敓鎴愮鍚嶇殑鏃堕棿鎴
nonceStr: data.nonceStr,
// 蹇呭~锛岀敓鎴愮鍚嶇殑闅忔満涓
signature: data.signature,
// 蹇呭~锛岀鍚
jsApiList: jsApiList // 蹇呭~锛岄渶瑕佷娇鐢ㄧ殑JS鎺ュ彛鍒楄〃
});
wx.ready(function () {
var defaultOption = _objectSpread2({
title: document.title,
desc: '鏋侀绉戞妧鎴愮珛浜 2007 骞达紝浠モ€滄彁鍗囧叏鐞冨啘涓氱敓浜ф晥鐜団€濅负浼佷笟浣垮懡',
link: location.href,
imgUrl: 'https://static.xag.cn/img/weixin-share.png'
}, option, {
success: function success() {}
});
wx.onMenuShareAppMessage(defaultOption);
wx.onMenuShareTimeline(defaultOption);
wx.updateAppMessageShareData(defaultOption);
wx.updateTimelineShareData(defaultOption);
});
});
};
wx.error(function (error) {
console.log(error);
});
window.wxShare = wxShare;
setTimeout(function () {
if (!window.isRecruit && !window.isJetSeed && !window.isCustomShare) {
wxShare.shareConfig();
}
}, 100);