diff --git a/sites/m.veryhuo.com/components/mip-veryhuo-androidsoft/README.md b/sites/m.veryhuo.com/components/mip-veryhuo-androidsoft/README.md new file mode 100644 index 000000000..57e93b336 --- /dev/null +++ b/sites/m.veryhuo.com/components/mip-veryhuo-androidsoft/README.md @@ -0,0 +1,31 @@ +# mip-veryhuo-androidsoft + +移动端样式、逻辑 + +标题|内容 +----|---- +类型|通用 +支持布局|responsive, fixed-height, fill, container, fixed +所需脚本| [https://c.mipcdn.com/extensions/platform/v2/m.veryhuo.com/mip-veryhuo-androidsoft/mip-veryhuo-androidsoft.js](https://c.mipcdn.com/extensions/platform/v2/m.veryhuo.com/mip-veryhuo-androidsoft/mip-veryhuo-androidsoft.js) + +## 示例 + +### 基本使用 + +```html + +``` + +## 属性 + +### url + +说明:点击搜索按钮跳转;顶部菜单按钮点击显示隐藏;下方点击加载更多,请求数据 + +必选项:是 + +类型:字符串 + +取值范围:URL + +默认值:无 diff --git a/sites/m.veryhuo.com/components/mip-veryhuo-androidsoft/example/index.html b/sites/m.veryhuo.com/components/mip-veryhuo-androidsoft/example/index.html new file mode 100644 index 000000000..b96a4ae82 --- /dev/null +++ b/sites/m.veryhuo.com/components/mip-veryhuo-androidsoft/example/index.html @@ -0,0 +1,18 @@ + + + + + + MIP page + + + + + + + + + + diff --git a/sites/m.veryhuo.com/components/mip-veryhuo-androidsoft/index.less b/sites/m.veryhuo.com/components/mip-veryhuo-androidsoft/index.less new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/sites/m.veryhuo.com/components/mip-veryhuo-androidsoft/index.less @@ -0,0 +1 @@ + diff --git a/sites/m.veryhuo.com/components/mip-veryhuo-androidsoft/mip-veryhuo-androidsoft.js b/sites/m.veryhuo.com/components/mip-veryhuo-androidsoft/mip-veryhuo-androidsoft.js new file mode 100644 index 000000000..a8882d8e6 --- /dev/null +++ b/sites/m.veryhuo.com/components/mip-veryhuo-androidsoft/mip-veryhuo-androidsoft.js @@ -0,0 +1,218 @@ +/** + * @file 评论模块 + * @author fl + */ + +const { CustomElement, util } = MIP +const { css } = util + +export default class MIPMhotComment extends CustomElement { + build () { + let bnum = 0 + let nnum = 0 + let mclassifyCont = this.element.querySelectorAll('#mclassifyCont')[0] + let ztheader = this.element.querySelectorAll('.ztheader') + let oDiv = this.element.querySelectorAll('.SearchBox')[0] + let searBtn = this.element.querySelectorAll('.SBBtn button')[0] + let alert = this.element.querySelectorAll('#confirm')[0] + let csearchDiv = this.element.querySelectorAll('.searchDiv')[0] + let sear = this.element.querySelectorAll('.searchDiv input') + let cnav = this.element.querySelectorAll('nav')[0] + let mclassify = this.element.querySelectorAll('#mclassify')[0] + let pullNav = this.element.querySelectorAll('#nav .pullNav') + let moreNav = this.element.querySelectorAll('#nav .moreNav') + let cmslass = this.element.querySelectorAll('#mclassifyCont p span') + let cul = this.element.querySelectorAll('#mclassifyCont ul') + let fixNav = this.element.querySelector('.fixNav') + let cbacktop = this.element.querySelectorAll('#Cbacktop')[0] + let zxNav = this.element.querySelector('#zxNav') + searBtn.onclick = function () { + if (oDiv.length === 0) { + css(alert, {display: 'block'}) + } else { + css(alert, {display: 'none'}) + } + } + window.addEventListener('scroll', function () { + if (document.documentElement.scrollTop > 80) { + css(fixNav, {display: 'block'}) + css(zxNav, {display: 'none'}) + } else if (document.documentElement.scrollTop < 30) { + css(fixNav, {display: 'none'}) + css(zxNav, {display: 'block'}) + } + if (document.documentElement.scrollTop > 300) { + css(cbacktop, {display: 'block'}) + } else { + css(cbacktop, {display: 'none'}) + } + }) + cbacktop.onclick = function () { + document.documentElement.scrollTop = 0 + } + if (ztheader.length === 0) { + oDiv.onclick = function () { + if (bnum === 0) { + css(mclassifyCont, {display: 'none'}) + css(csearchDiv, {display: 'block'}) + if (sear.length > 0) { + sear[0].focus() + } + bnum = 1 + nnum = 0 + } else { + if (nnum === 1) { + css(mclassifyCont, {display: 'none'}) + nnum = 0 + } else { + css(cnav, {height: 40}) + css(csearchDiv, {display: 'none'}) + bnum = 0 + } + } + } + for (let i = 0; i < cmslass.length; i++) { + cmslass[i].onclick = function () { + let siblings = this.parentNode.childNodes + for (let i = 0; i < siblings.length; i++) { + if (siblings[i].nodeType === 1) { + siblings[i].className = '' + this.className = 'cur' + cmslass[i].index = i + } + } + if (this.index === 0) { + cul[0].className = 'on' + } else { + cul[0].className = '' + } + if (this.index === 1) { + cul[1].className = 'on' + } else { + cul[1].className = '' + } + } + } + mclassify.onclick = function () { + if (nnum === 0) { + css(mclassifyCont, {display: 'block'}) + if (pullNav.length > 0) { + pullNav[0].classList.remove('open') + } + if (moreNav.length > 0) { + css(moreNav[0], {display: 'none'}) + } + nnum = 1 + } else { + css(mclassifyCont, {display: 'none'}) + nnum = 0 + } + } + } + let browser1 = { + versions: (function () { + let u = navigator.userAgent + return { + trident: u.indexOf('Trident') > -1, + presto: u.indexOf('Presto') > -1, + webKit: u.indexOf('AppleWebKit') > -1, + gecko: u.indexOf('Gecko') > -1 && u.indexOf('KHTML') === -1, + mobile: !!u.match(/AppleWebKit.*Mobile/i) || !!u.match(/MIDP|SymbianOS|NOKIA|SAMSUNG|LG|NEC|TCL|Alcatel|BIRD|DBTEL|Dopod|PHILIPS|HAIER|LENOVO|MOT-|Nokia|SonyEricsson|SIE-|Amoi|ZTE/), + ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), + android: u.indexOf('Android') > -1 || u.indexOf('Linux') > -1, + iPhone: u.indexOf('iPhone') > -1 || u.indexOf('Mac') > -1, + iPad: u.indexOf('iPad') > -1, + webApp: u.indexOf('Safari') === -1 + } + })(), + language: (navigator.browserLanguage || navigator.language).toLowerCase() + } + if (location.href.indexOf('m.veryhuo.com') > -1 && browser1.versions.mobile === false && browser1.versions.ios === false && browser1.versions.android === false && browser1.versions.iPhone === false && browser1.versions.iPad === false) { + window.location = 'http://www.veryhuo.com' + } + let moreBtn = this.element.querySelector('#androidsoft-more') + let asmUl = this.element.querySelector('#asm') + let asm = 18 + moreBtn.onclick = function () { + let req = new Request('https://admin.veryhuo.com/mobile/open/more_soft?p=' + asm + '&type=2' + '&isgame=0', { + method: 'GET', + cache: 'reload' + }) + fetch(req).then(function (response) { + return response.json() + }).then(function (data) { + if (data === '') { + moreBtn.innerText = '加载完毕啦,么么哒~' + return false + } else { + moreBtn.innerText = '加载中...' + let khtml = '' + let len = data.length + for (let i = 0; i < len; i++) { + let dt = data[i] + dt.pubdate = toDate(dt.pubdate) + khtml = document.createElement('li') + khtml.innerHTML = '

' + dt.title + '' + dt.typename + '' + dt.softsize + '' + dt.os + '' + dt.pubdate + '

下载' + asmUl.appendChild(khtml) + } + if (len < 20) { + moreBtn.innerText = '加载完毕啦,么么哒~' + } else { + moreBtn.innerText = '点击有惊喜,萌萌哒~' + } + asm = asm + 20 + } + function toDate (phpstr) { + let str = parseInt(phpstr) * 1000 + let newDate = new Date(str) + let yy = newDate.getUTCFullYear() + let mm = newDate.getUTCMonth() + 1 + let dd = newDate.getUTCDate() + return yy + '-' + mm + '-' + dd + } + }) + } + let gameBtn = this.element.querySelector('#androidgame-more') + let agmUl = this.element.querySelector('#agm') + let agm = 18 + gameBtn.onclick = function () { + let req = new Request('https://admin.veryhuo.com/mobile/open/more_soft?p=' + agm + '&type=2' + '&isgame=1', { + method: 'GET', + cache: 'reload' + }) + fetch(req).then(function (response) { + return response.json() + }).then(function (data) { + if (data === '') { + gameBtn.innerText = '加载完毕啦,么么哒~' + return false + } else { + gameBtn.innerText = '加载中...' + let ghtml = '' + let len = data.length + for (let i = 0; i < len; i++) { + let dt = data[i] + dt.pubdate = toDate(dt.pubdate) + ghtml = document.createElement('li') + ghtml.innerHTML = '

' + dt.title + '' + dt.typename + '' + dt.softsize + '' + dt.os + '' + dt.pubdate + '

下载' + agmUl.appendChild(ghtml) + } + if (len < 20) { + gameBtn.innerText = '加载完毕啦,么么哒~' + } else { + gameBtn.innerText = '点击有惊喜,萌萌哒~' + } + agm = agm + 20 + } + function toDate (phpstr) { + let str = parseInt(phpstr) * 1000 + let newDate = new Date(str) + let yy = newDate.getUTCFullYear() + let mm = newDate.getUTCMonth() + 1 + let dd = newDate.getUTCDate() + return yy + '-' + mm + '-' + dd + } + }) + } + } +} diff --git a/sites/m.veryhuo.com/components/mip-veryhuo-azyy-azyx/README.md b/sites/m.veryhuo.com/components/mip-veryhuo-azyy-azyx/README.md new file mode 100644 index 000000000..6bda9ce10 --- /dev/null +++ b/sites/m.veryhuo.com/components/mip-veryhuo-azyy-azyx/README.md @@ -0,0 +1,31 @@ +# mip-veryhuo-azyy-azyx + +移动端样式、逻辑 + +标题|内容 +----|---- +类型|通用 +支持布局|responsive, fixed-height, fill, container, fixed +所需脚本| [https://c.mipcdn.com/extensions/platform/v2/m.veryhuo.com/mip-veryhuo-azyy-azyx/mip-veryhuo-azyy-azyx.js](https://c.mipcdn.com/extensions/platform/v2/m.veryhuo.com/mip-veryhuo-azyy-azyx/mip-veryhuo-azyy-azyx.js) + +## 示例 + +### 基本使用 + +```html + +``` + +## 属性 + +### url + +说明:顶部菜单按钮点击显示隐藏;点击搜索按钮跳转到新网页;下方点击加载更多,请求数据。 + +必选项:是 + +类型:字符串 + +取值范围:URL + +默认值:无 diff --git a/sites/m.veryhuo.com/components/mip-veryhuo-azyy-azyx/example/index.html b/sites/m.veryhuo.com/components/mip-veryhuo-azyy-azyx/example/index.html new file mode 100644 index 000000000..c4deb942d --- /dev/null +++ b/sites/m.veryhuo.com/components/mip-veryhuo-azyy-azyx/example/index.html @@ -0,0 +1,18 @@ + + + + + + MIP page + + + + + + + + + + diff --git a/sites/m.veryhuo.com/components/mip-veryhuo-azyy-azyx/index.less b/sites/m.veryhuo.com/components/mip-veryhuo-azyy-azyx/index.less new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/sites/m.veryhuo.com/components/mip-veryhuo-azyy-azyx/index.less @@ -0,0 +1 @@ + diff --git a/sites/m.veryhuo.com/components/mip-veryhuo-azyy-azyx/mip-veryhuo-azyy-azyx.js b/sites/m.veryhuo.com/components/mip-veryhuo-azyy-azyx/mip-veryhuo-azyy-azyx.js new file mode 100644 index 000000000..76d316ce4 --- /dev/null +++ b/sites/m.veryhuo.com/components/mip-veryhuo-azyy-azyx/mip-veryhuo-azyy-azyx.js @@ -0,0 +1,192 @@ +/** + * @file 评论模块 + * @author fl + */ + +const { CustomElement, util } = MIP +const { css } = util + +export default class MIPMhotComment extends CustomElement { + build () { + let bnum = 0 + let nnum = 0 + // let PageType = '' + let mclassifyCont = this.element.querySelectorAll('#mclassifyCont')[0] + let ztheader = this.element.querySelectorAll('.ztheader') + // let cSOHUCS = this.element.querySelectorAll('#SOHUCS') + // if (cSOHUCS.length > 0) { + // if (cSOHUCS[0].attributes['PageType'].value !== undefined) { + // PageType = cSOHUCS[0].attributes['PageType'].value + // } + // } + let oDiv = this.element.querySelectorAll('.SearchBox')[0] + let searBtn = this.element.querySelectorAll('.SBBtn button')[0] + let alert = this.element.querySelectorAll('#confirm')[0] + let csearchDiv = this.element.querySelectorAll('.searchDiv')[0] + let sear = this.element.querySelectorAll('.searchDiv input') + let cnav = this.element.querySelectorAll('nav')[0] + let mclassify = this.element.querySelectorAll('#mclassify')[0] + let pullNav = this.element.querySelectorAll('#nav .pullNav') + let moreNav = this.element.querySelectorAll('#nav .moreNav') + let cmslass = this.element.querySelectorAll('#mclassifyCont p span') + let cul = this.element.querySelectorAll('#mclassifyCont ul') + let fixNav = this.element.querySelector('.fixNav') + let cbacktop = this.element.querySelectorAll('#Cbacktop')[0] + let zxNav = this.element.querySelector('#zxNav') + searBtn.onclick = function () { + if (oDiv.length === 0) { + css(alert, {display: 'block'}) + } else { + css(alert, {display: 'none'}) + } + } + window.addEventListener('scroll', function () { + // 页面滚动一定高度时,显示吸顶导航盒子 + if (document.documentElement.scrollTop > 80) { + css(fixNav, {display: 'block'}) + css(zxNav, {display: 'none'}) + } else if (document.documentElement.scrollTop < 30) { + css(fixNav, {display: 'none'}) + css(zxNav, {display: 'block'}) + } + // 页面滚动一定高度时,显示回到顶部按钮 + if (document.documentElement.scrollTop > 300) { + css(cbacktop, {display: 'block'}) + } else { + css(cbacktop, {display: 'none'}) + } + }) + // 点击回到顶部按钮 + cbacktop.onclick = function () { + document.documentElement.scrollTop = 0 + } + if (ztheader.length === 0) { + // 点击搜索按钮,显示搜索框盒子,隐藏分类盒子 + oDiv.onclick = function () { + if (bnum === 0) { + css(mclassifyCont, {display: 'none'}) + css(csearchDiv, {display: 'block'}) + if (sear.length > 0) { + sear[0].focus() + } + bnum = 1 + nnum = 0 + } else { + if (nnum === 1) { + css(mclassifyCont, {display: 'none'}) + nnum = 0 + } else { + css(cnav, {height: 40}) + css(csearchDiv, {display: 'none'}) + bnum = 0 + } + } + } + // 给隐藏的分类 tab 标题添加类样式 + for (let i = 0; i < cmslass.length; i++) { + cmslass[i].onclick = function () { + let siblings = this.parentNode.childNodes + for (let i = 0; i < siblings.length; i++) { + if (siblings[i].nodeType === 1) { + siblings[i].className = '' + this.className = 'cur' + cmslass[i].index = i + } + } + // 点击隐藏的分类 tab 标题切换ul列表数据 + if (this.index === 0) { + cul[0].className = 'on' + } else { + cul[0].className = '' + } + if (this.index === 1) { + cul[1].className = 'on' + } else { + cul[1].className = '' + } + } + } + // 点击顶部分类按钮 + mclassify.onclick = function () { + if (nnum === 0) { + css(mclassifyCont, {display: 'block'}) + if (pullNav.length > 0) { + pullNav[0].classList.remove('open') + } + if (moreNav.length > 0) { + css(moreNav[0], {display: 'none'}) + } + nnum = 1 + } else { + css(mclassifyCont, {display: 'none'}) + nnum = 0 + } + } + } + let browser1 = { + versions: (function () { + let u = navigator.userAgent + return { + trident: u.indexOf('Trident') > -1, + presto: u.indexOf('Presto') > -1, + webKit: u.indexOf('AppleWebKit') > -1, + gecko: u.indexOf('Gecko') > -1 && u.indexOf('KHTML') === -1, + mobile: !!u.match(/AppleWebKit.*Mobile/i) || !!u.match(/MIDP|SymbianOS|NOKIA|SAMSUNG|LG|NEC|TCL|Alcatel|BIRD|DBTEL|Dopod|PHILIPS|HAIER|LENOVO|MOT-|Nokia|SonyEricsson|SIE-|Amoi|ZTE/), + ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), + android: u.indexOf('Android') > -1 || u.indexOf('Linux') > -1, + iPhone: u.indexOf('iPhone') > -1 || u.indexOf('Mac') > -1, + iPad: u.indexOf('iPad') > -1, + webApp: u.indexOf('Safari') === -1 + } + })(), + language: (navigator.browserLanguage || navigator.language).toLowerCase() + } + if (location.href.indexOf('m.veryhuo.com') > -1 && browser1.versions.mobile === false && browser1.versions.ios === false && browser1.versions.android === false && browser1.versions.iPhone === false && browser1.versions.iPad === false) { + window.location = 'http://www.veryhuo.com' + } + let moreBtn = this.element.querySelector('#soft-more') + let sUl = this.element.querySelector('#soft-list') + let softP = 20 + let isgame = document.getElementById('isgame').getAttribute('value') + moreBtn.onclick = function () { + // 创建一个Request对象 + let req = new Request('https://admin.veryhuo.com/mobile/open/more_soft?p=' + softP + '&type=2&isgame=' + isgame, { + method: 'GET', + cache: 'reload' + }) + fetch(req).then(function (response) { + return response.json() + }).then(function (data) { + if (data === '') { + moreBtn.innerText = '加载完毕啦,么么哒~' + return false + } else { + moreBtn.innerText = '加载中...' + let khtml = '' + let len = data.length + for (let i = 0; i < len; i++) { + let dt = data[i] + dt.pubdate = toDate(dt.pubdate) + khtml = document.createElement('li') + khtml.innerHTML = '

' + dt.title + '' + dt.typename + '' + dt.softsize + '' + dt.os + '' + dt.pubdate + '

下载' + sUl.appendChild(khtml) + } + if (len < 20) { + moreBtn.innerText = '加载完毕啦,么么哒~' + } else { + moreBtn.innerText = '点击有惊喜,萌萌哒~' + } + softP = softP + 20 + } + function toDate (phpstr) { + let str = parseInt(phpstr) * 1000 + let newDate = new Date(str) + let yy = newDate.getUTCFullYear() + let mm = newDate.getUTCMonth() + 1 + let dd = newDate.getUTCDate() + return yy + '-' + mm + '-' + dd + } + }) + } + } +} diff --git a/sites/m.veryhuo.com/components/mip-veryhuo-column/README.md b/sites/m.veryhuo.com/components/mip-veryhuo-column/README.md new file mode 100644 index 000000000..e2e486038 --- /dev/null +++ b/sites/m.veryhuo.com/components/mip-veryhuo-column/README.md @@ -0,0 +1,31 @@ +# mip-veryhuo-column + +移动端样式、逻辑 + +标题|内容 +----|---- +类型|通用 +支持布局|responsive, fixed-height, fill, container, fixed +所需脚本| [https://c.mipcdn.com/extensions/platform/v2/m.veryhuo.com/mip-veryhuo-column/mip-veryhuo-column.js](https://c.mipcdn.com/extensions/platform/v2/m.veryhuo.com/mip-veryhuo-column/mip-veryhuo-column.js) + +## 示例 + +### 基本使用 + +```html + +``` + +## 属性 + +### url + +说明:判断机型跳转;点击搜索按钮跳转;顶部菜单按钮点击显示隐藏;下方点击加载更多,请求数据。 + +必选项:是 + +类型:字符串 + +取值范围:URL + +默认值:无 diff --git a/sites/m.veryhuo.com/components/mip-veryhuo-column/example/index.html b/sites/m.veryhuo.com/components/mip-veryhuo-column/example/index.html new file mode 100644 index 000000000..e5935c67e --- /dev/null +++ b/sites/m.veryhuo.com/components/mip-veryhuo-column/example/index.html @@ -0,0 +1,18 @@ + + + + + + MIP page + + + + + + + + + + diff --git a/sites/m.veryhuo.com/components/mip-veryhuo-column/index.less b/sites/m.veryhuo.com/components/mip-veryhuo-column/index.less new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/sites/m.veryhuo.com/components/mip-veryhuo-column/index.less @@ -0,0 +1 @@ + diff --git a/sites/m.veryhuo.com/components/mip-veryhuo-column/mip-veryhuo-column.js b/sites/m.veryhuo.com/components/mip-veryhuo-column/mip-veryhuo-column.js new file mode 100644 index 000000000..02173cc2a --- /dev/null +++ b/sites/m.veryhuo.com/components/mip-veryhuo-column/mip-veryhuo-column.js @@ -0,0 +1,312 @@ +/** + * @file 评论模块 + * @author fl + */ + +const { CustomElement, util } = MIP +const { css } = util + +export default class MIPMhotComment extends CustomElement { + build () { + let bnum = 0 + let nnum = 0 + let mclassifyCont = this.element.querySelectorAll('#mclassifyCont')[0] + let ztheader = this.element.querySelectorAll('.ztheader') + let oDiv = this.element.querySelectorAll('.SearchBox')[0] + let searBtn = this.element.querySelectorAll('.SBBtn button')[0] + let alert = this.element.querySelectorAll('#confirm')[0] + let csearchDiv = this.element.querySelectorAll('.searchDiv')[0] + let sear = this.element.querySelectorAll('.searchDiv input') + let cnav = this.element.querySelectorAll('nav')[0] + let mclassify = this.element.querySelectorAll('#mclassify')[0] + let pullNav = this.element.querySelectorAll('#nav .pullNav') + let moreNav = this.element.querySelectorAll('#nav .moreNav') + let cmslass = this.element.querySelectorAll('#mclassifyCont p span') + let cul = this.element.querySelectorAll('#mclassifyCont ul') + let fixNav = this.element.querySelector('.fixNav') + let cbacktop = this.element.querySelectorAll('#Cbacktop')[0] + let zxNav = this.element.querySelector('#zxNav') + searBtn.onclick = function () { + if (oDiv.length === 0) { + css(alert, {display: 'block'}) + } else { + css(alert, {display: 'block'}) + } + } + window.addEventListener('scroll', function () { + // 页面滚动一定高度时,显示吸顶导航盒子 + if (document.documentElement.scrollTop > 80) { + css(fixNav, {display: 'block'}) + css(zxNav, {display: 'none'}) + } else if (document.documentElement.scrollTop < 30) { + css(fixNav, {display: 'none'}) + css(zxNav, {display: 'block'}) + } + // 页面滚动一定高度时,显示回到顶部按钮 + if (document.documentElement.scrollTop > 300) { + css(cbacktop, {display: 'block'}) + } else { + css(cbacktop, {display: 'none'}) + } + }) + // 点击回到顶部按钮 + cbacktop.onclick = function () { + document.documentElement.scrollTop = 0 + } + if (ztheader.length === 0) { + // 点击搜索按钮,显示搜索框盒子,隐藏分类盒子 + oDiv.onclick = function () { + if (bnum === 0) { + css(mclassifyCont, {display: 'none'}) + css(csearchDiv, {display: 'block'}) + if (sear.length > 0) { + sear[0].focus() + } + bnum = 1 + nnum = 0 + } else { + if (nnum === 1) { + css(mclassifyCont, {display: 'none'}) + nnum = 0 + } else { + css(cnav, {height: 40}) + css(csearchDiv, {display: 'none'}) + bnum = 0 + } + } + } + // 给隐藏的分类 tab 标题添加类样式 + for (let i = 0; i < cmslass.length; i++) { + cmslass[i].onclick = function () { + let siblings = this.parentNode.childNodes + for (let i = 0; i < siblings.length; i++) { + if (siblings[i].nodeType === 1) { + siblings[i].className = '' + this.className = 'cur' + cmslass[i].index = i + } + } + // 点击隐藏的分类 tab 标题切换ul列表数据 + if (this.index === 0) { + cul[0].className = 'on' + } else { + cul[0].className = '' + } + if (this.index === 1) { + cul[1].className = 'on' + } else { + cul[1].className = '' + } + } + } + // 点击顶部分类按钮 + mclassify.onclick = function () { + if (nnum === 0) { + css(mclassifyCont, {display: 'block'}) + if (pullNav.length > 0) { + pullNav[0].classList.remove('open') + } + if (moreNav.length > 0) { + css(moreNav[0], {display: 'none'}) + } + nnum = 1 + } else { + css(mclassifyCont, {display: 'none'}) + nnum = 0 + } + } + } + // 如果不是手机打开,则跳转到pc页面 + let browser1 = { + versions: (function () { + let u = navigator.userAgent + return { + trident: u.indexOf('Trident') > -1, + presto: u.indexOf('Presto') > -1, + webKit: u.indexOf('AppleWebKit') > -1, + gecko: u.indexOf('Gecko') > -1 && u.indexOf('KHTML') === -1, + mobile: !!u.match(/AppleWebKit.*Mobile/i) || !!u.match(/MIDP|SymbianOS|NOKIA|SAMSUNG|LG|NEC|TCL|Alcatel|BIRD|DBTEL|Dopod|PHILIPS|HAIER|LENOVO|MOT-|Nokia|SonyEricsson|SIE-|Amoi|ZTE/), + ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), + android: u.indexOf('Android') > -1 || u.indexOf('Linux') > -1, + iPhone: u.indexOf('iPhone') > -1 || u.indexOf('Mac') > -1, + iPad: u.indexOf('iPad') > -1, + webApp: u.indexOf('Safari') === -1 + } + })(), + language: (navigator.browserLanguage || navigator.language).toLowerCase() + } + if (location.href.indexOf('m.veryhuo.com') > -1 && browser1.versions.mobile === false && browser1.versions.ios === false && browser1.versions.android === false && browser1.versions.iPhone === false && browser1.versions.iPad === false) { + let pcurl = location.href.replace('m.', 'www.') + if (location.href.indexOf('/androidsoft.html') > -1) { + location.href = pcurl + } + if (location.href.indexOf('/down/class/') > -1) { + location.href = pcurl + } + } + // 机型判断 + let u = navigator.userAgent + let isIphone = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/) + let typeNum = document.getElementById('typeid').getAttribute('value') + let classweb = document.getElementById('classweb').getAttribute('value') + let typename = document.getElementById('typename').getAttribute('value') + let isios = document.getElementById('isios').getAttribute('value') + let classid = document.getElementById('classid').getAttribute('value') + let type = isios === '0' ? '2' : '3' + if (isIphone) { + if (classweb === '2') { + let azurl = window.location.href + let azurlarr = azurl.split('/') + let azurlid = azurlarr[4].replace('.html', '') + if (isios === '0') { + azurl = azurl.replace(azurlid, classid) + window.location.href = azurl + } + } + } else { + if (classweb === '2') { + let azurl = window.location.href + let azurlarr = azurl.split('/') + let azurlid = azurlarr[4].replace('.html', '') + if (isios === '1') { + azurl = azurl.replace(azurlid, classid) + window.location.href = azurl + } + } + } + let btn1 = this.element.querySelector('#btn1') + let btn2 = this.element.querySelector('#btn2') + let btn3 = this.element.querySelector('#btn3') + let lists1 = this.element.querySelector('.lists1') + let lists2 = this.element.querySelector('.lists2') + let lists3 = this.element.querySelector('.lists3') + let p = 10 + let zz = 13 + btn1.onclick = function () { + if (btn1.innerText === '加载完毕啦') return false + // 创建一个Request对象 + let req = new Request('https://admin.veryhuo.com/mobile/open/list_more_zuixin?type=' + type + '&p=' + p + '&type_id=' + typeNum, { + method: 'GET', + cache: 'reload' + }) + fetch(req).then(function (response) { + return response.json() + }).then(function (data) { + if (data === '') { + btn1.innerText = '加载完毕啦,么么哒~' + return false + } else { + btn1.innerText = '加载中...' + let khtml = '' + let len = data.length + for (let i = 0; i < len; i++) { + let dt = data[i] + if (dt.litpic === '') { + dt.litpic = '/images/nologo.png' + } + if (dt.version === 0) { + dt.version = dt.os + } else { + dt.softrank = 5 + } + khtml = document.createElement('li') + khtml.innerHTML = '

' + dt.title + '' + typename + '|' + dt.version + '|' + dt.softsize + '

下载' + zz = zz + 1 + lists1.appendChild(khtml) + } + if (len < 10) { + btn1.innerText = '加载完毕啦,么么哒~' + } else { + btn1.innerText = '点击有惊喜,萌萌哒~' + } + p = p + 30 + } + }) + } + let hqp = 10 + btn2.onclick = function () { + if (btn2.innerText === '加载完毕啦') return false + let req = new Request('https://admin.veryhuo.com/mobile/open/list_more_zuire?type=' + type + '&p=' + hqp + '&type_id=' + typeNum, { + method: 'GET', + cache: 'reload' + }) + fetch(req).then(function (response) { + return response.json() + }).then(function (data) { + if (data === '') { + btn2.innerText = '加载完毕啦,么么哒~' + return false + } else { + btn2.innerText = '加载中...' + let rhtml = '' + let len = data.length + for (let i = 0; i < len; i++) { + let dt = data[i] + console.log(dt) + if (dt.litpic === '') { + dt.litpic = '/images/nologo.png' + } + if (dt.version === 0) { + dt.version = dt.os + } else { + dt.softrank = 5 + } + rhtml = document.createElement('li') + rhtml.innerHTML = '

' + dt.title + '' + typename + '|' + dt.version + '|' + dt.softsize + '

下载' + zz = zz + 1 + lists2.appendChild(rhtml) + } + if (len < 20) { + btn2.innerText = '加载完毕啦,么么哒~' + } else { + btn2.innerText = '点击有惊喜,萌萌哒~' + } + hqp = hqp + 30 + } + }) + } + let zxp = 10 + btn3.onclick = function () { + if (btn3.innerText === '加载完毕啦') return false + // 创建一个Request对象 + let req = new Request('https://admin.veryhuo.com/mobile/open/list_more_paihang?type=' + type + '&p=' + zxp + '&type_id=' + typeNum, { + method: 'GET', + cache: 'reload' + }) + fetch(req).then(function (response) { + return response.json() + }).then(function (data) { + if (data === '') { + btn3.innerText = '加载完毕啦,么么哒~' + return false + } else { + btn3.innerText = '加载中...' + let phtml = '' + let len = data.length + for (let i = 0; i < len; i++) { + let dt = data[i] + console.log(dt) + if (dt.litpic === '') { + dt.litpic = '/images/nologo.png' + } + if (dt.version === 0) { + dt.version = dt.os + } else { + dt.softrank = 5 + } + phtml = document.createElement('li') + phtml.innerHTML = '

' + dt.title + '' + typename + '|' + dt.version + '|' + dt.softsize + '

下载' + zz = zz + 1 + lists3.appendChild(phtml) + } + if (len < 20) { + btn3.innerText = '加载完毕啦,么么哒~' + } else { + btn3.innerText = '点击有惊喜,萌萌哒~' + } + zxp = zxp + 30 + } + }) + } + } +} diff --git a/sites/m.veryhuo.com/components/mip-veryhuo-comment/mip-veryhuo-comment.js b/sites/m.veryhuo.com/components/mip-veryhuo-comment/mip-veryhuo-comment.js index d40018d3e..2137b04ef 100644 --- a/sites/m.veryhuo.com/components/mip-veryhuo-comment/mip-veryhuo-comment.js +++ b/sites/m.veryhuo.com/components/mip-veryhuo-comment/mip-veryhuo-comment.js @@ -53,6 +53,18 @@ export default class MIPMpc6Comment extends CustomElement { css(cDSContent, {display: 'none'}) } } + let bodya = this.element.querySelectorAll('body') + let ssid = cSOHUCS[0].attributes['sid'].value + css(bodya, {display: 'none'}) + fetch('/ForbidCity.php?id=' + ssid).then(function (e) { + return e.text() + }).then(function (text) { + if (text === 1) { + MIP.viewer.href('https://m.veryhuo.com') + } else { + css(bodya, {display: 'block'}) + } + }) let coryverlist = this.element.querySelectorAll('.oryverlist')[0] let cBContent = this.element.querySelectorAll('#BBContent')[0] if (loryverbox.length > 0) { diff --git a/sites/m.veryhuo.com/components/mip-veryhuo-index/README.md b/sites/m.veryhuo.com/components/mip-veryhuo-index/README.md new file mode 100644 index 000000000..07ee74c1a --- /dev/null +++ b/sites/m.veryhuo.com/components/mip-veryhuo-index/README.md @@ -0,0 +1,31 @@ +# mip-veryhuo-index + +移动端样式、逻辑 + +标题|内容 +----|---- +类型|通用 +支持布局|responsive, fixed-height, fill, container, fixed +所需脚本| [https://c.mipcdn.com/extensions/platform/v2/m.veryhuo.com/mip-veryhuo-index/mip-veryhuo-index.js](https://c.mipcdn.com/extensions/platform/v2/m.veryhuo.com/mip-veryhuo-index/mip-veryhuo-index.js) + +## 示例 + +### 基本使用 + +```html + +``` + +## 属性 + +### url + +说明:判断机型跳转;点击搜索按钮跳转;顶部菜单按钮点击显示隐藏;下方点击加载更多,请求数据。 + +必选项:是 + +类型:字符串 + +取值范围:URL + +默认值:无 diff --git a/sites/m.veryhuo.com/components/mip-veryhuo-index/example/index.html b/sites/m.veryhuo.com/components/mip-veryhuo-index/example/index.html new file mode 100644 index 000000000..6e6bf41df --- /dev/null +++ b/sites/m.veryhuo.com/components/mip-veryhuo-index/example/index.html @@ -0,0 +1,18 @@ + + + + + + MIP page + + + + + + + + + + diff --git a/sites/m.veryhuo.com/components/mip-veryhuo-index/index.less b/sites/m.veryhuo.com/components/mip-veryhuo-index/index.less new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/sites/m.veryhuo.com/components/mip-veryhuo-index/index.less @@ -0,0 +1 @@ + diff --git a/sites/m.veryhuo.com/components/mip-veryhuo-index/mip-veryhuo-index.js b/sites/m.veryhuo.com/components/mip-veryhuo-index/mip-veryhuo-index.js new file mode 100644 index 000000000..1cb25b700 --- /dev/null +++ b/sites/m.veryhuo.com/components/mip-veryhuo-index/mip-veryhuo-index.js @@ -0,0 +1,229 @@ +/** + * @file 评论模块 + * @author fl + */ + +const { CustomElement, util } = MIP +const { css } = util + +export default class MIPMhotComment extends CustomElement { + build () { + let bnum = 0 + let nnum = 0 + let mclassifyCont = this.element.querySelectorAll('#mclassifyCont')[0] + let ztheader = this.element.querySelectorAll('.ztheader') + let oDiv = this.element.querySelectorAll('.SearchBox')[0] + let searBtn = this.element.querySelectorAll('.SBBtn button')[0] + let alert = this.element.querySelectorAll('#confirm')[0] + let csearchDiv = this.element.querySelectorAll('.searchDiv')[0] + let sear = this.element.querySelectorAll('.searchDiv input') + let cnav = this.element.querySelectorAll('nav')[0] + let mclassify = this.element.querySelectorAll('#mclassify')[0] + let pullNav = this.element.querySelectorAll('#nav .pullNav') + let moreNav = this.element.querySelectorAll('#nav .moreNav') + let cmslass = this.element.querySelectorAll('#mclassifyCont p span') + let cul = this.element.querySelectorAll('#mclassifyCont ul') + let fixNav = this.element.querySelector('.fixNav') + let cbacktop = this.element.querySelectorAll('#Cbacktop')[0] + let zxNav = this.element.querySelector('#zxNav') + if (searBtn !== undefined) { + searBtn.onclick = function () { + if (oDiv.length === 0) { + css(alert, { display: 'block' }) + } else { + css(alert, { display: 'none' }) + } + } + } + window.addEventListener('scroll', function () { + // 页面滚动一定高度时,显示吸顶导航盒子 + if (document.documentElement.scrollTop > 80) { + css(fixNav, { display: 'block' }) + css(zxNav, { display: 'none' }) + } else if (document.documentElement.scrollTop < 30) { + css(fixNav, { display: 'none' }) + css(zxNav, { display: 'block' }) + } + // 页面滚动一定高度时,显示回到顶部按钮 + if (document.documentElement.scrollTop > 300) { + css(cbacktop, { display: 'block' }) + } else { + css(cbacktop, { display: 'none' }) + } + }) + // 点击回到顶部按钮 + if (cbacktop !== undefined) { + cbacktop.onclick = function () { + document.documentElement.scrollTop = 0 + } + } + if (ztheader !== undefined && ztheader.length === 0) { + // 点击搜索按钮,显示搜索框盒子,隐藏分类盒子 + if (oDiv !== undefined) { + oDiv.onclick = function () { + if (bnum === 0) { + css(mclassifyCont, { display: 'none' }) + css(csearchDiv, { display: 'block' }) + if (sear.length > 0) { + sear[0].focus() + } + bnum = 1 + nnum = 0 + } else { + if (nnum === 1) { + css(mclassifyCont, {display: 'none'}) + nnum = 0 + } else { + css(cnav, {height: 40}) + css(csearchDiv, {display: 'none'}) + bnum = 0 + } + } + } + } + // 给隐藏的分类 tab 标题添加类样式 + for (let i = 0; i < cmslass.length; i++) { + cmslass[i].onclick = function () { + let siblings = this.parentNode.childNodes + for (let i = 0; i < siblings.length; i++) { + if (siblings[i].nodeType === 1) { + siblings[i].className = '' + this.className = 'cur' + cmslass[i].index = i + } + } + // 点击隐藏的分类 tab 标题切换ul列表数据 + if (this.index === 0) { + cul[0].className = 'on' + } else { + cul[0].className = '' + } + if (this.index === 1) { + cul[1].className = 'on' + } else { + cul[1].className = '' + } + } + } + // 点击顶部分类按钮 + if (mclassify !== undefined) { + mclassify.onclick = function () { + if (nnum === 0) { + css(mclassifyCont, { display: 'block' }) + if (pullNav.length > 0) { + pullNav[0].classList.remove('open') + } + if (moreNav.length > 0) { + css(moreNav[0], {display: 'none'}) + } + nnum = 1 + } else { + css(mclassifyCont, {display: 'none'}) + nnum = 0 + } + } + } + } + let browser1 = { + versions: (function () { + let u = navigator.userAgent + return { + trident: u.indexOf('Trident') > -1, + presto: u.indexOf('Presto') > -1, + webKit: u.indexOf('AppleWebKit') > -1, + gecko: u.indexOf('Gecko') > -1 && u.indexOf('KHTML') === -1, + mobile: !!u.match(/AppleWebKit.*Mobile/i) || !!u.match(/MIDP|SymbianOS|NOKIA|SAMSUNG|LG|NEC|TCL|Alcatel|BIRD|DBTEL|Dopod|PHILIPS|HAIER|LENOVO|MOT-|Nokia|SonyEricsson|SIE-|Amoi|ZTE/), + ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), + android: u.indexOf('Android') > -1 || u.indexOf('Linux') > -1, + iPhone: u.indexOf('iPhone') > -1 || u.indexOf('Mac') > -1, + iPad: u.indexOf('iPad') > -1, + webApp: u.indexOf('Safari') === -1 + } + })(), + language: (navigator.browserLanguage || navigator.language).toLowerCase() + } + if (location.href.indexOf('m.veryhuo.com') > -1 && browser1.versions.mobile === false && browser1.versions.ios === false && browser1.versions.android === false && browser1.versions.iPhone === false && browser1.versions.iPad === false) { + window.location = 'http://www.veryhuo.com' + } + // 判断机型 + let u = navigator.userAgent + let isIphone = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/) + let iosweb = document.getElementById('iosweb').getAttribute('value') + let type = iosweb === '0' ? '2' : '3' + let lm = '' + if (type === '2') { + lm = '1' + } else if (type === '3') { + lm = '2' + } + if (isIphone) { + if (iosweb === '0') { + window.stop ? window.stop() : document.execCommand('Stop') + window.location.href = '/apple/index.html' + } + } else if (iosweb === '1') { + window.stop ? window.stop() : document.execCommand('Stop') + window.location.href = '/index.html' + } + let moreBtn = this.element.querySelector('#moreApp') + let iList = this.element.querySelector('.Apply .iList') + // 发送请求 + let p = 15 + let doing = 0 + if (moreBtn !== undefined) { + moreBtn.onclick = function () { + if (doing === 1) return false + // 创建一个Request对象 + let req = new Request('https://admin.veryhuo.com/mobile/open/more_soft?type=' + type + '&p=' + p, { + method: 'GET', + cache: 'reload' + }) + fetch(req).then(function (response) { + return response.json() + }).then(function (data) { + if (data === '') { + moreBtn.innerText = '加载完毕啦,么么哒~' + return false + } else { + moreBtn.innerText = '加载中...' + let khtml = '' + let len = data.length + for (let i = 0; i < len; i++) { + let dt = data[i] + dt.pubdate = toDate(dt.pubdate) + khtml = document.createElement('li') + khtml.innerHTML = '

' + dt.title + '' + dt.typename + '' + dt.softsize + '' + dt.os + '' + dt.pubdate + '

下载' + iList.appendChild(khtml) + } + if (len < 20) { + doing = 1 + moreBtn.innerText = '加载完毕啦,么么哒~' + } else { + moreBtn.innerText = '点击有惊喜,萌萌哒~' + } + p = p + 30 + } + let SBBtn = this.element.querySelector('.SBBtn') + let SBInp = this.element.querySelectorAll('.SBInp input') + SBBtn.click(function () { + search() + }) + function search () { + let sV = SBInp.value + let forpath = '/search.php?wd=' + encodeURI(sV) + '&lm=' + lm + window.location.href = forpath + } + // 将时间戳转换成 yy-mm-dd + function toDate (phpstr) { + let str = parseInt(phpstr) * 1000 + let newDate = new Date(str) + let yy = newDate.getUTCFullYear() + let mm = newDate.getUTCMonth() + 1 + let dd = newDate.getUTCDate() + return yy + '-' + mm + '-' + dd + } + }) + } + } + } +} diff --git a/sites/m.veryhuo.com/components/mip-veryhuo-notfound/README.md b/sites/m.veryhuo.com/components/mip-veryhuo-notfound/README.md new file mode 100644 index 000000000..467e9ff3f --- /dev/null +++ b/sites/m.veryhuo.com/components/mip-veryhuo-notfound/README.md @@ -0,0 +1,31 @@ +# mip-veryhuo-notfound + +移动端样式、逻辑 + +标题|内容 +----|---- +类型|通用 +支持布局|responsive, fixed-height, fill, container, fixed +所需脚本| [https://c.mipcdn.com/extensions/platform/v2/m.veryhuo.com/mip-veryhuo-notfound/mip-veryhuo-notfound.js](https://c.mipcdn.com/extensions/platform/v2/m.veryhuo.com/mip-veryhuo-notfound/mip-veryhuo-notfound.js) + +## 示例 + +### 基本使用 + +```html + +``` + +## 属性 + +### url + +说明:顶部菜单按钮点击显示隐藏;点击搜索跳转。 + +必选项:是 + +类型:字符串 + +取值范围:URL + +默认值:无 diff --git a/sites/m.veryhuo.com/components/mip-veryhuo-notfound/example/index.html b/sites/m.veryhuo.com/components/mip-veryhuo-notfound/example/index.html new file mode 100644 index 000000000..c8af47a39 --- /dev/null +++ b/sites/m.veryhuo.com/components/mip-veryhuo-notfound/example/index.html @@ -0,0 +1,18 @@ + + + + + + MIP page + + + + + + + + + + diff --git a/sites/m.veryhuo.com/components/mip-veryhuo-notfound/index.less b/sites/m.veryhuo.com/components/mip-veryhuo-notfound/index.less new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/sites/m.veryhuo.com/components/mip-veryhuo-notfound/index.less @@ -0,0 +1 @@ + diff --git a/sites/m.veryhuo.com/components/mip-veryhuo-notfound/mip-veryhuo-notfound.js b/sites/m.veryhuo.com/components/mip-veryhuo-notfound/mip-veryhuo-notfound.js new file mode 100644 index 000000000..32b4ac8e9 --- /dev/null +++ b/sites/m.veryhuo.com/components/mip-veryhuo-notfound/mip-veryhuo-notfound.js @@ -0,0 +1,10 @@ +const { CustomElement } = MIP + +export default class MIPMhotComment extends CustomElement { + build () { + let goHome = this.element.querySelectorAll('.go-home')[0] + goHome.onclick = function () { + location.href = './index.html' + } + } +} diff --git a/sites/m.veryhuo.com/components/mip-veryhuo-rank/README.md b/sites/m.veryhuo.com/components/mip-veryhuo-rank/README.md new file mode 100644 index 000000000..2e0a3145b --- /dev/null +++ b/sites/m.veryhuo.com/components/mip-veryhuo-rank/README.md @@ -0,0 +1,31 @@ +# mip-veryhuo-rank + +移动端样式、逻辑 + +标题|内容 +----|---- +类型|通用 +支持布局|responsive, fixed-height, fill, container, fixed +所需脚本| [https://c.mipcdn.com/extensions/platform/v2/m.veryhuo.com/mip-veryhuo-rank/mip-veryhuo-rank.js](https://c.mipcdn.com/extensions/platform/v2/m.veryhuo.com/mip-veryhuo-rank/mip-veryhuo-rank.js) + +## 示例 + +### 基本使用 + +```html + +``` + +## 属性 + +### url + +说明:导航点击展开收起;判断机型跳转;顶部菜单按钮点击显示隐藏;下方点击加载更多,请求数据。 + +必选项:是 + +类型:字符串 + +取值范围:URL + +默认值:无 diff --git a/sites/m.veryhuo.com/components/mip-veryhuo-rank/example/index.html b/sites/m.veryhuo.com/components/mip-veryhuo-rank/example/index.html new file mode 100644 index 000000000..2052af3e4 --- /dev/null +++ b/sites/m.veryhuo.com/components/mip-veryhuo-rank/example/index.html @@ -0,0 +1,18 @@ + + + + + + MIP page + + + + + + + + + + diff --git a/sites/m.veryhuo.com/components/mip-veryhuo-rank/index.less b/sites/m.veryhuo.com/components/mip-veryhuo-rank/index.less new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/sites/m.veryhuo.com/components/mip-veryhuo-rank/index.less @@ -0,0 +1 @@ + diff --git a/sites/m.veryhuo.com/components/mip-veryhuo-rank/mip-veryhuo-rank.js b/sites/m.veryhuo.com/components/mip-veryhuo-rank/mip-veryhuo-rank.js new file mode 100644 index 000000000..74eafd91a --- /dev/null +++ b/sites/m.veryhuo.com/components/mip-veryhuo-rank/mip-veryhuo-rank.js @@ -0,0 +1,212 @@ +const { CustomElement, util } = MIP +const { css } = util + +export default class MIPMhotComment extends CustomElement { + build () { + let bnum = 0 + let nnum = 0 + let mclassifyCont = this.element.querySelectorAll('#mclassifyCont')[0] + let ztheader = this.element.querySelectorAll('.ztheader') + let oDiv = this.element.querySelectorAll('.SearchBox')[0] + let csearchDiv = this.element.querySelectorAll('.searchDiv')[0] + let sear = this.element.querySelectorAll('.searchDiv input') + let cnav = this.element.querySelectorAll('nav')[0] + let mclassify = this.element.querySelectorAll('#mclassify')[0] + let pullNav = this.element.querySelectorAll('#nav .pullNav') + let moreNav = this.element.querySelectorAll('#nav .moreNav') + let cmslass = this.element.querySelectorAll('#mclassifyCont p span') + let cul = this.element.querySelectorAll('#mclassifyCont ul') + let fixNav = this.element.querySelector('.fixNav') + let cbacktop = this.element.querySelectorAll('#Cbacktop')[0] + window.addEventListener('scroll', function () { + // 页面滚动一定高度时,显示吸顶导航盒子 + if (document.documentElement.scrollTop > 80) { + css(fixNav, {display: 'block'}) + } else { + css(fixNav, {display: 'none'}) + } + // 页面滚动一定高度时,显示回到顶部按钮 + if (document.documentElement.scrollTop > 300) { + css(cbacktop, {display: 'block'}) + } else { + css(cbacktop, {display: 'none'}) + } + }) + // 点击回到顶部按钮 + cbacktop.onclick = function () { + document.documentElement.scrollTop = 0 + } + // 分类内容 + if (ztheader.length === 0) { + // 点击搜索按钮,显示搜索框盒子,隐藏分类盒子 + oDiv.onclick = function () { + if (bnum === 0) { + css(mclassifyCont, {display: 'none'}) + css(csearchDiv, {display: 'block'}) + if (sear.length > 0) { + sear[0].focus() + } + bnum = 1 + nnum = 0 + } else { + if (nnum === 1) { + css(mclassifyCont, {display: 'none'}) + nnum = 0 + } else { + css(cnav, {height: 40}) + css(csearchDiv, {display: 'none'}) + bnum = 0 + } + } + } + // 给隐藏的分类 tab 标题添加类样式 + for (let i = 0; i < cmslass.length; i++) { + cmslass[i].onclick = function () { + let siblings = this.parentNode.childNodes + for (let i = 0; i < siblings.length; i++) { + if (siblings[i].nodeType === 1) { + siblings[i].className = '' + this.className = 'cur' + cmslass[i].index = i + } + } + // 点击隐藏的分类 tab 标题切换ul列表数据 + if (this.index === 0) { + cul[0].className = 'on' + } else { + cul[0].className = '' + } + if (this.index === 1) { + cul[1].className = 'on' + } else { + cul[1].className = '' + } + } + } + // 点击顶部分类按钮 + mclassify.onclick = function () { + if (nnum === 0) { + css(mclassifyCont, {display: 'block'}) + if (pullNav.length > 0) { + pullNav[0].classList.remove('open') + } + if (moreNav.length > 0) { + css(moreNav[0], {display: 'none'}) + } + nnum = 1 + } else { + css(mclassifyCont, {display: 'none'}) + nnum = 0 + } + } + } + // 点击排行页的 箭头,实现显示隐藏功能 + let zk = this.element.querySelector('.zk') + let sq = this.element.querySelector('.sq') + let rankA = this.element.querySelectorAll('.topnav a') + let hides = this.element.querySelectorAll('.isHide') + zk.onclick = function () { + css(rankA, {display: 'block'}) + css(zk, {display: 'none'}) + } + sq.onclick = function () { + css(hides, {display: 'none'}) + css(sq, {display: 'none'}) + css(zk, {display: 'block'}) + } + let browser1 = { + versions: (function () { + let u = navigator.userAgent + return { + trident: u.indexOf('Trident') > -1, + presto: u.indexOf('Presto') > -1, + webKit: u.indexOf('AppleWebKit') > -1, + gecko: u.indexOf('Gecko') > -1 && u.indexOf('KHTML') === -1, + mobile: !!u.match(/AppleWebKit.*Mobile/i) || !!u.match(/MIDP|SymbianOS|NOKIA|SAMSUNG|LG|NEC|TCL|Alcatel|BIRD|DBTEL|Dopod|PHILIPS|HAIER|LENOVO|MOT-|Nokia|SonyEricsson|SIE-|Amoi|ZTE/), + ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), + android: u.indexOf('Android') > -1 || u.indexOf('Linux') > -1, + iPhone: u.indexOf('iPhone') > -1 || u.indexOf('Mac') > -1, + iPad: u.indexOf('iPad') > -1, + webApp: u.indexOf('Safari') === -1 + } + })(), + language: (navigator.browserLanguage || navigator.language).toLowerCase() + } + if (location.href.indexOf('m.veryhuo.com') > -1 && browser1.versions.mobile === false && browser1.versions.ios === false && browser1.versions.android === false && browser1.versions.iPhone === false && browser1.versions.iPad === false) { + window.location = 'http://www.veryhuo.com' + } + // 机型判断 + let u = navigator.userAgent + let isIphone = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/) + let iosweb = document.getElementById('iosweb').getAttribute('value') + let classweb = document.getElementById('classweb').getAttribute('value') + let isyouxi = document.getElementById('isyouxi').getAttribute('value') + let typeid = document.getElementById('typeid').getAttribute('value') + let type = iosweb === '0' ? '2' : '3' + if (isIphone) { + if (classweb === '0') { + if (iosweb === '0') { + window.stop ? window.stop() : document.execCommand('Stop') + if (isyouxi === '1') { + window.location.href = '/apple/rank.html' + } else if (isyouxi === '2') { + window.location.href = '/apple/game.html' + } else { + window.location.href = '/apple/soft.html' + } + } + } + } else if (iosweb === '1') { + if (isyouxi === '1') { + window.location.href = '/rank.html' + } else if (isyouxi === '2') { + window.location.href = '/game.html' + } else { + window.location.href = '/soft.html' + } + } + // 点击加载更多 + let btn1 = this.element.querySelector('#btn1') + let more = this.element.querySelector('#more') + let pp = 12 + let zz = 13 + btn1.onclick = function () { + if (btn1.innerText === '加载完毕啦,么么哒~') return false + // 创建一个Request对象 + let req = new Request('https://admin.veryhuo.com/mobile/open/phb_more?os=' + type + '&type=' + isyouxi + '&p=' + pp + '&typeid=' + typeid, { + method: 'GET', + cache: 'reload' + }) + fetch(req).then(function (response) { + return response.json() + }).then(function (data) { + if (data === '') { + btn1.innerText = '加载完毕啦,么么哒~' + return false + } else { + btn1.innerText = '加载中...' + let khtml = '' + let len = data.length + for (let i = 0; i < len; i++) { + let dt = data[i] + if (dt.version === 0) { + dt.version = dt.os + } else { + dt.softrank = 5 + } + khtml = document.createElement('li') + khtml.innerHTML = '

' + zz + '' + dt.title + '' + dt.typename + '' + dt.softsize + '' + dt.version + '

下载' + zz += 1 + more.appendChild(khtml) + } + if (len < 10) { + btn1.innerText = '加载完毕啦,么么哒~' + } else { + btn1.innerText = '点击有惊喜,萌萌哒~' + } + pp = pp + 30 + } + }) + } + } +} diff --git a/sites/m.veryhuo.com/components/mip-veryhuo-special/README.md b/sites/m.veryhuo.com/components/mip-veryhuo-special/README.md new file mode 100644 index 000000000..9a55e71a8 --- /dev/null +++ b/sites/m.veryhuo.com/components/mip-veryhuo-special/README.md @@ -0,0 +1,31 @@ +# mip-veryhuo-special + +移动端样式、逻辑 + +标题|内容 +----|---- +类型|通用 +支持布局|responsive, fixed-height, fill, container, fixed +所需脚本| [https://c.mipcdn.com/extensions/platform/v2/m.veryhuo.com/mip-veryhuo-special/mip-veryhuo-special.js](https://c.mipcdn.com/extensions/platform/v2/m.veryhuo.com/mip-veryhuo-special/mip-veryhuo-special.js) + +## 示例 + +### 基本使用 + +```html + +``` + +## 属性 + +### url + +说明:点击搜索跳转;顶部菜单按钮点击显示隐藏;下方点击加载更多,请求数据。 + +必选项:是 + +类型:字符串 + +取值范围:URL + +默认值:无 diff --git a/sites/m.veryhuo.com/components/mip-veryhuo-special/example/index.html b/sites/m.veryhuo.com/components/mip-veryhuo-special/example/index.html new file mode 100644 index 000000000..39f5b5fb7 --- /dev/null +++ b/sites/m.veryhuo.com/components/mip-veryhuo-special/example/index.html @@ -0,0 +1,18 @@ + + + + + + MIP page + + + + + + + + + + diff --git a/sites/m.veryhuo.com/components/mip-veryhuo-special/index.less b/sites/m.veryhuo.com/components/mip-veryhuo-special/index.less new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/sites/m.veryhuo.com/components/mip-veryhuo-special/index.less @@ -0,0 +1 @@ + diff --git a/sites/m.veryhuo.com/components/mip-veryhuo-special/mip-veryhuo-special.js b/sites/m.veryhuo.com/components/mip-veryhuo-special/mip-veryhuo-special.js new file mode 100644 index 000000000..6e220332e --- /dev/null +++ b/sites/m.veryhuo.com/components/mip-veryhuo-special/mip-veryhuo-special.js @@ -0,0 +1,201 @@ +/** + * @file 评论模块 + * @author fl + */ +const { CustomElement, util } = MIP +const { css } = util + +export default class MIPMhotComment extends CustomElement { + build () { + let bnum = 0 + let nnum = 0 + let mclassifyCont = this.element.querySelectorAll('#mclassifyCont')[0] + let ztheader = this.element.querySelectorAll('.ztheader') + let oDiv = this.element.querySelectorAll('.SearchBox')[0] + let csearchDiv = this.element.querySelectorAll('.searchDiv')[0] + let sear = this.element.querySelectorAll('.searchDiv input') + let cnav = this.element.querySelectorAll('nav')[0] + let mclassify = this.element.querySelectorAll('#mclassify')[0] + let pullNav = this.element.querySelectorAll('#nav .pullNav') + let moreNav = this.element.querySelectorAll('#nav .moreNav') + let cmslass = this.element.querySelectorAll('#mclassifyCont p span') + let cul = this.element.querySelectorAll('#mclassifyCont ul') + let fixNav = this.element.querySelector('.fixNav') + let cbacktop = this.element.querySelectorAll('#Cbacktop')[0] + window.addEventListener('scroll', function () { + // 页面滚动一定高度时,显示吸顶导航盒子 + if (document.documentElement.scrollTop > 80) { + css(fixNav, {display: 'block'}) + } else { + css(fixNav, {display: 'none'}) + } + // 页面滚动一定高度时,显示回到顶部按钮 + if (document.documentElement.scrollTop > 300) { + css(cbacktop, {display: 'block'}) + } else { + css(cbacktop, {display: 'none'}) + } + }) + // 点击回到顶部按钮 + cbacktop.onclick = function () { + document.documentElement.scrollTop = 0 + } + if (ztheader.length === 0) { + // 点击搜索按钮,显示搜索框盒子,隐藏分类盒子 + oDiv.onclick = function () { + if (bnum === 0) { + css(mclassifyCont, {display: 'none'}) + css(csearchDiv, {display: 'block'}) + if (sear.length > 0) { + sear[0].focus() + } + bnum = 1 + nnum = 0 + } else { + if (nnum === 1) { + css(mclassifyCont, {display: 'none'}) + nnum = 0 + } else { + css(cnav, {height: 40}) + css(csearchDiv, {display: 'none'}) + bnum = 0 + } + } + } + // 给隐藏的分类 tab 标题添加类样式 + for (let i = 0; i < cmslass.length; i++) { + cmslass[i].onclick = function () { + let siblings = this.parentNode.childNodes + for (let i = 0; i < siblings.length; i++) { + if (siblings[i].nodeType === 1) { + siblings[i].className = '' + this.className = 'cur' + cmslass[i].index = i + } + } + // 点击隐藏的分类 tab 标题切换ul列表数据 + if (this.index === 0) { + cul[0].className = 'on' + } else { + cul[0].className = '' + } + if (this.index === 1) { + cul[1].className = 'on' + } else { + cul[1].className = '' + } + } + } + // 点击顶部分类按钮 + mclassify.onclick = function () { + if (nnum === 0) { + css(mclassifyCont, {display: 'block'}) + if (pullNav.length > 0) { + pullNav[0].classList.remove('open') + } + if (moreNav.length > 0) { + css(moreNav[0], {display: 'none'}) + } + nnum = 1 + } else { + css(mclassifyCont, {display: 'none'}) + nnum = 0 + } + } + } + let lis = this.element.querySelectorAll('.hqnav i') + let uls = this.element.querySelectorAll('.speContent') + for (let i = 0; i < lis.length; i++) { + lis[i].id = i + lis[i].onclick = function () { + for (let j = 0; j < lis.length; j++) { + lis[j].className = '' + uls[j].style.display = 'none' + } + this.className = 'cur' + uls[this.id].style.display = 'block' + } + } + // 点击更多按钮 + let btn1 = this.element.querySelector('#btn1') + let btn2 = this.element.querySelector('#btn2') + let specG = this.element.querySelector('#spec-game') + let specS = this.element.querySelector('#spec-soft') + let zz = 13 + let sp1 = 20 + btn1.onclick = function () { + if (btn1.innerText === '加载完毕啦,么么哒~') return false + // 创建一个Request对象 + let req = new Request('https://admin.veryhuo.com/mobile/open/spec_more?type=1&p=' + sp1, { + method: 'GET', + cache: 'reload' + }) + fetch(req).then(function (response) { + return response.json() + }).then(function (data) { + if (data === '') { + btn1.innerText = '加载完毕啦,么么哒~' + return false + } else { + btn1.innerText = '加载中...' + let khtml = '' + let len = data.length + for (let i = 0; i < len; i++) { + let dt = data[i] + console.log(dt) + if (dt.litpic === '') { + dt.litpic = '/images/nologo.png' + } + khtml = document.createElement('li') + khtml.innerHTML = '

' + dt.title + '

' + zz = zz + 1 + specG.appendChild(khtml) + } + if (len < 20) { + btn1.innerText = '加载完毕啦,么么哒~' + } else { + btn1.innerText = '点击有惊喜,萌萌哒~' + } + sp1 = sp1 + 20 + } + }) + } + let sp2 = 20 + btn2.onclick = function () { + if (btn2.innerText === '加载完毕啦,么么哒~') return false + let req = new Request('https://admin.veryhuo.com/mobile/open/spec_more?type=2&p=' + sp2, { + method: 'GET', + cache: 'reload' + }) + fetch(req).then(function (response) { + return response.json() + }).then(function (data) { + if (data === '') { + btn2.innerText = '加载完毕啦,么么哒~' + return false + } else { + btn2.innerText = '加载中...' + let shtml = '' + let len = data.length + for (let i = 0; i < len; i++) { + let dt = data[i] + console.log(dt) + if (dt.litpic === '') { + dt.litpic = '/images/nologo.png' + } + shtml = document.createElement('li') + shtml.innerHTML = '

' + dt.title + '

' + zz = zz + 1 + specS.appendChild(shtml) + } + if (len < 20) { + btn2.innerText = '加载完毕啦,么么哒~' + } else { + btn2.innerText = '点击有惊喜,萌萌哒~' + } + sp2 = sp2 + 20 + } + }) + } + } +} diff --git a/sites/m.veryhuo.com/components/mip-veryhuo-type/README.md b/sites/m.veryhuo.com/components/mip-veryhuo-type/README.md new file mode 100644 index 000000000..28abd36c3 --- /dev/null +++ b/sites/m.veryhuo.com/components/mip-veryhuo-type/README.md @@ -0,0 +1,31 @@ +# mip-veryhuo-type + +移动端样式、逻辑 + +标题|内容 +----|---- +类型|通用 +支持布局|responsive, fixed-height, fill, container, fixed +所需脚本| [https://c.mipcdn.com/extensions/platform/v2/m.veryhuo.com/mip-veryhuo-type/mip-veryhuo-type.js](https://c.mipcdn.com/extensions/platform/v2/m.veryhuo.com/mip-veryhuo-type/mip-veryhuo-type.js) + +## 示例 + +### 基本使用 + +```html + +``` + +## 属性 + +### url + +说明:判断机型跳转;顶部菜单按钮点击显示隐藏;搜索点击跳转; + +必选项:是 + +类型:字符串 + +取值范围:URL + +默认值:无 diff --git a/sites/m.veryhuo.com/components/mip-veryhuo-type/example/index.html b/sites/m.veryhuo.com/components/mip-veryhuo-type/example/index.html new file mode 100644 index 000000000..1b2407316 --- /dev/null +++ b/sites/m.veryhuo.com/components/mip-veryhuo-type/example/index.html @@ -0,0 +1,18 @@ + + + + + + MIP page + + + + + + + + + + diff --git a/sites/m.veryhuo.com/components/mip-veryhuo-type/index.less b/sites/m.veryhuo.com/components/mip-veryhuo-type/index.less new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/sites/m.veryhuo.com/components/mip-veryhuo-type/index.less @@ -0,0 +1 @@ + diff --git a/sites/m.veryhuo.com/components/mip-veryhuo-type/mip-veryhuo-type.js b/sites/m.veryhuo.com/components/mip-veryhuo-type/mip-veryhuo-type.js new file mode 100644 index 000000000..8297921f8 --- /dev/null +++ b/sites/m.veryhuo.com/components/mip-veryhuo-type/mip-veryhuo-type.js @@ -0,0 +1,175 @@ +/** + * @file 评论模块 + * @author fl + */ + +const { CustomElement, util } = MIP +const { css } = util + +export default class MIPMhotComment extends CustomElement { + build () { + let bnum = 0 + let nnum = 0 + let mclassifyCont = this.element.querySelectorAll('#mclassifyCont')[0] + let ztheader = this.element.querySelectorAll('.ztheader') + let oDiv = this.element.querySelectorAll('.SearchBox')[0] + let searBtn = this.element.querySelectorAll('.SBBtn button')[0] + let alert = this.element.querySelectorAll('#confirm')[0] + let csearchDiv = this.element.querySelectorAll('.searchDiv')[0] + let sear = this.element.querySelectorAll('.searchDiv input') + let cnav = this.element.querySelectorAll('nav')[0] + let mclassify = this.element.querySelectorAll('#mclassify')[0] + let pullNav = this.element.querySelectorAll('#nav .pullNav') + let moreNav = this.element.querySelectorAll('#nav .moreNav') + let cmslass = this.element.querySelectorAll('#mclassifyCont p span') + let cul = this.element.querySelectorAll('#mclassifyCont ul') + let fixNav = this.element.querySelector('.fixNav') + let cbacktop = this.element.querySelectorAll('#Cbacktop')[0] + let zxNav = this.element.querySelector('#zxNav') + searBtn.onclick = function () { + if (oDiv.length === 0) { + css(alert, {display: 'block'}) + } else { + css(alert, {display: 'none'}) + } + } + window.addEventListener('scroll', function () { + // 页面滚动一定高度时,显示吸顶导航盒子 + if (document.documentElement.scrollTop > 80) { + css(fixNav, {display: 'block'}) + css(zxNav, {display: 'none'}) + } else if (document.documentElement.scrollTop < 30) { + css(fixNav, {display: 'none'}) + css(zxNav, {display: 'block'}) + } + // 页面滚动一定高度时,显示回到顶部按钮 + if (document.documentElement.scrollTop > 300) { + css(cbacktop, {display: 'block'}) + } else { + css(cbacktop, {display: 'none'}) + } + }) + // 点击回到顶部按钮 + cbacktop.onclick = function () { + document.documentElement.scrollTop = 0 + } + if (ztheader.length === 0) { + // 点击搜索按钮,显示搜索框盒子,隐藏分类盒子 + oDiv.onclick = function () { + if (bnum === 0) { + css(mclassifyCont, {display: 'none'}) + css(csearchDiv, {display: 'block'}) + if (sear.length > 0) { + sear[0].focus() + } + bnum = 1 + nnum = 0 + } else { + if (nnum === 1) { + css(mclassifyCont, {display: 'none'}) + nnum = 0 + } else { + css(cnav, {height: 40}) + css(csearchDiv, {display: 'none'}) + bnum = 0 + } + } + } + // 给隐藏的分类 tab 标题添加类样式 + for (let i = 0; i < cmslass.length; i++) { + cmslass[i].onclick = function () { + let siblings = this.parentNode.childNodes + for (let i = 0; i < siblings.length; i++) { + if (siblings[i].nodeType === 1) { + siblings[i].className = '' + this.className = 'cur' + cmslass[i].index = i + } + } + // 点击隐藏的分类 tab 标题切换ul列表数据 + if (this.index === 0) { + cul[0].className = 'on' + } else { + cul[0].className = '' + } + if (this.index === 1) { + cul[1].className = 'on' + } else { + cul[1].className = '' + } + } + } + // 点击顶部分类按钮 + mclassify.onclick = function () { + if (nnum === 0) { + css(mclassifyCont, {display: 'block'}) + if (pullNav.length > 0) { + pullNav[0].classList.remove('open') + } + if (moreNav.length > 0) { + css(moreNav[0], {display: 'none'}) + } + nnum = 1 + } else { + css(mclassifyCont, {display: 'none'}) + nnum = 0 + } + } + } + let browser1 = { + versions: (function () { + let u = navigator.userAgent + return { + trident: u.indexOf('Trident') > -1, + presto: u.indexOf('Presto') > -1, + webKit: u.indexOf('AppleWebKit') > -1, + gecko: u.indexOf('Gecko') > -1 && u.indexOf('KHTML') === -1, + mobile: !!u.match(/AppleWebKit.*Mobile/i) || !!u.match(/MIDP|SymbianOS|NOKIA|SAMSUNG|LG|NEC|TCL|Alcatel|BIRD|DBTEL|Dopod|PHILIPS|HAIER|LENOVO|MOT-|Nokia|SonyEricsson|SIE-|Amoi|ZTE/), + ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), + android: u.indexOf('Android') > -1 || u.indexOf('Linux') > -1, + iPhone: u.indexOf('iPhone') > -1 || u.indexOf('Mac') > -1, + iPad: u.indexOf('iPad') > -1, + webApp: u.indexOf('Safari') === -1 + } + })(), + language: (navigator.browserLanguage || navigator.language).toLowerCase() + } + if (location.href.indexOf('m.veryhuo.com') > -1 && browser1.versions.mobile === false && browser1.versions.ios === false && browser1.versions.android === false && browser1.versions.iPhone === false && browser1.versions.iPad === false) { + window.location = 'http://www.veryhuo.com' + } + let u = navigator.userAgent + let isIphone = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/) + let iosweb = document.getElementById('iosweb').getAttribute('value') + let classweb = document.getElementById('classweb').getAttribute('value') + let isyouxi = document.getElementById('isyouxi').getAttribute('value') + if (isIphone) { + if (classweb === '1') { + if (iosweb === '0') { + let url = window.location.href + if (isyouxi === '1') { + if (url.indexOf('611') !== -1) { + window.location.href = '/list/987.html' + } + } else { + if (url.indexOf('363') !== -1) { + window.location.href = '/list/986.html' + } + } + } + } + } else { + if (classweb === '1') { + let url = window.location.href + if (isyouxi === '1') { + if (url.indexOf('987') !== -1) { + window.location.href = '/list/611.html' + } + } else { + if (url.indexOf('986') !== -1) { + window.location.href = '/list/363.html' + } + } + } + } + } +} diff --git a/sites/m.veryhuo.com/components/mip-veryhuo-zx/README.md b/sites/m.veryhuo.com/components/mip-veryhuo-zx/README.md new file mode 100644 index 000000000..f9478618f --- /dev/null +++ b/sites/m.veryhuo.com/components/mip-veryhuo-zx/README.md @@ -0,0 +1,31 @@ +# mip-veryhuo-zx + +移动端样式、逻辑 + +标题|内容 +----|---- +类型|通用 +支持布局|responsive, fixed-height, fill, container, fixed +所需脚本| [https://c.mipcdn.com/extensions/platform/v2/m.veryhuo.com/mip-veryhuo-zx/mip-veryhuo-zx.js](https://c.mipcdn.com/extensions/platform/v2/m.veryhuo.com/mip-veryhuo-zx/mip-veryhuo-zx.js) + +## 示例 + +### 基本使用 + +```html + +``` + +## 属性 + +### url + +说明:点击搜索跳转;顶部菜单按钮点击显示隐藏;下方点击加载更多,请求数据。 + +必选项:是 + +类型:字符串 + +取值范围:URL + +默认值:无 diff --git a/sites/m.veryhuo.com/components/mip-veryhuo-zx/example/index.html b/sites/m.veryhuo.com/components/mip-veryhuo-zx/example/index.html new file mode 100644 index 000000000..0a9834b26 --- /dev/null +++ b/sites/m.veryhuo.com/components/mip-veryhuo-zx/example/index.html @@ -0,0 +1,18 @@ + + + + + + MIP page + + + + + + + + + + diff --git a/sites/m.veryhuo.com/components/mip-veryhuo-zx/index.less b/sites/m.veryhuo.com/components/mip-veryhuo-zx/index.less new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/sites/m.veryhuo.com/components/mip-veryhuo-zx/index.less @@ -0,0 +1 @@ + diff --git a/sites/m.veryhuo.com/components/mip-veryhuo-zx/mip-veryhuo-zx.js b/sites/m.veryhuo.com/components/mip-veryhuo-zx/mip-veryhuo-zx.js new file mode 100644 index 000000000..5a6274316 --- /dev/null +++ b/sites/m.veryhuo.com/components/mip-veryhuo-zx/mip-veryhuo-zx.js @@ -0,0 +1,164 @@ +/** + * @file 评论模块 + * @author fl + */ +const { CustomElement, util } = MIP +const { css } = util + +export default class MIPMhotComment extends CustomElement { + build () { + let bnum = 0 + let nnum = 0 + let mclassifyCont = this.element.querySelectorAll('#mclassifyCont')[0] + let ztheader = this.element.querySelectorAll('.ztheader') + let oDiv = this.element.querySelectorAll('.SearchBox')[0] + let csearchDiv = this.element.querySelectorAll('.searchDiv')[0] + let sear = this.element.querySelectorAll('.searchDiv input') + let cnav = this.element.querySelectorAll('nav')[0] + let mclassify = this.element.querySelectorAll('#mclassify')[0] + let pullNav = this.element.querySelectorAll('#nav .pullNav') + let moreNav = this.element.querySelectorAll('#nav .moreNav') + let cmslass = this.element.querySelectorAll('#mclassifyCont p span') + let cul = this.element.querySelectorAll('#mclassifyCont ul') + let fixNav = this.element.querySelector('.fixNav') + let cbacktop = this.element.querySelectorAll('#Cbacktop')[0] + let zxNav = this.element.querySelector('#zxNav') + window.addEventListener('scroll', function () { + // 页面滚动一定高度时,显示吸顶导航盒子 + if (document.documentElement.scrollTop > 80) { + css(fixNav, {display: 'block'}) + css(zxNav, {display: 'none'}) + } else if (document.documentElement.scrollTop < 30) { + css(fixNav, {display: 'none'}) + css(zxNav, {display: 'block'}) + } + // 页面滚动一定高度时,显示回到顶部按钮 + if (document.documentElement.scrollTop > 300) { + css(cbacktop, {display: 'block'}) + } else { + css(cbacktop, {display: 'none'}) + } + }) + // 点击回到顶部按钮 + cbacktop.onclick = function () { + document.documentElement.scrollTop = 0 + } + if (ztheader.length === 0) { + // 点击搜索按钮,显示搜索框盒子,隐藏分类盒子 + oDiv.onclick = function () { + if (bnum === 0) { + css(mclassifyCont, {display: 'none'}) + css(csearchDiv, {display: 'block'}) + if (sear.length > 0) { + sear[0].focus() + } + bnum = 1 + nnum = 0 + } else { + if (nnum === 1) { + css(mclassifyCont, {display: 'none'}) + nnum = 0 + } else { + css(cnav, {height: 40}) + css(csearchDiv, {display: 'none'}) + bnum = 0 + } + } + } + // 给隐藏的分类 tab 标题添加类样式 + for (let i = 0; i < cmslass.length; i++) { + cmslass[i].onclick = function () { + let siblings = this.parentNode.childNodes + for (let i = 0; i < siblings.length; i++) { + if (siblings[i].nodeType === 1) { + siblings[i].className = '' + this.className = 'cur' + cmslass[i].index = i + } + } + // 点击隐藏的分类 tab 标题切换ul列表数据 + if (this.index === 0) { + cul[0].className = 'on' + } else { + cul[0].className = '' + } + if (this.index === 1) { + cul[1].className = 'on' + } else { + cul[1].className = '' + } + } + } + // 点击顶部分类按钮 + mclassify.onclick = function () { + if (nnum === 0) { + css(mclassifyCont, {display: 'block'}) + if (pullNav.length > 0) { + pullNav[0].classList.remove('open') + } + if (moreNav.length > 0) { + css(moreNav[0], {display: 'none'}) + } + nnum = 1 + } else { + css(mclassifyCont, {display: 'none'}) + nnum = 0 + } + } + } + let zxAs = this.element.querySelectorAll('#zxnav-tit a') + let open = this.element.querySelector('.open') + let close = this.element.querySelector('.close') + let aTit = this.element.querySelectorAll('.aTit') + open.onclick = function () { + css(zxAs, {display: 'block'}) + css(open, {display: 'none'}) + } + close.onclick = function () { + css(aTit, {display: 'none'}) + css(close, {display: 'none'}) + css(open, {display: 'block'}) + } + let btnzx = this.element.querySelector('#btnzx') + let dlist = this.element.querySelector('#dlist') + let zxTypeid = document.getElementById('zx_typeid').getAttribute('value') + let zxp1 = 10 + let zz = 13 + btnzx.onclick = function () { + if (btnzx.innerText === '加载完毕啦,么么哒~') return false + // 创建一个Request对象 + let req = new Request('https://admin.veryhuo.com/mobile/open/archives_more?p=' + zxp1 + '&typeid=' + zxTypeid, { + method: 'GET', + cache: 'reload' + }) + fetch(req).then(function (response) { + return response.json() + }).then(function (data) { + if (data === '') { + btnzx.innerText = '加载完毕啦,么么哒~' + return false + } else { + btnzx.innerText = '加载中...' + let khtml = '' + let len = data.length + for (let i = 0; i < len; i++) { + let dt = data[i] + if (dt.litpic === '') { + dt.litpic = '/images/noimg.png' + } + khtml = document.createElement('li') + khtml.innerHTML = '' + dt.title + '

' + dt.description + '

' + zz = zz + 1 + dlist.appendChild(khtml) + } + if (len < 20) { + btnzx.innerText = '加载完毕啦,么么哒~' + } else { + btnzx.innerText = '点击有惊喜,萌萌哒~' + } + zxp1 = zxp1 + 20 + } + }) + } + } +}