Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

更新下载提示、评论提示 #845

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions sites/pc0359.cn/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
UTF-8
# This file is for unifying the coding style for different editors and IDEs
# editorconfig.org
root = true
[*]
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[*.{js,styl,html,json,vue}]
indent_size = 2
indent_style = space
[*.md]
trim_trailing_whitespace = false
2 changes: 2 additions & 0 deletions sites/pc0359.cn/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist
node_modules
39 changes: 39 additions & 0 deletions sites/pc0359.cn/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"parser": "vue-eslint-parser",
"parserOptions": {
"ecmaVersion": 8,
"sourceType": "module",
"allowImportExportEverywhere": false
},
"extends": [
"standard",
"plugin:vue/recommended"
],
"plugins": [
"jsdoc"
],
"globals": {
"MIP": true
},
"env": {
"browser": true
},
"rules": {
"jsdoc/check-param-names": 1,
"jsdoc/check-tag-names": 1,
"jsdoc/check-types": 1,
"jsdoc/newline-after-description": 1,
"jsdoc/no-undefined-types": 1,
"jsdoc/require-description-complete-sentence": 0,
"jsdoc/require-example": 0,
"jsdoc/require-hyphen-before-param-description": 0,
"jsdoc/require-param": 1,
"jsdoc/require-param-description": 1,
"jsdoc/require-param-name": 1,
"jsdoc/require-param-type": 1,
"jsdoc/require-returns-description": 1,
"jsdoc/require-returns-type": 1,
"jsdoc/valid-types": 1,
"no-var": 2
}
}
8 changes: 8 additions & 0 deletions sites/pc0359.cn/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
node_modules/
dist/
.idea/
*.log
Thumbs.db
.DS_Store
*.swp
*.gz
Empty file added sites/pc0359.cn/common/.gitkeep
Empty file.
48 changes: 48 additions & 0 deletions sites/pc0359.cn/components/mip-cyb-comment/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# mip-cyb-comment
标题|移动端评论块
----|----
类型|通用
支持布局|
所需脚本| [https://c.mipcdn.com/extensions/platform/v2/pc0359.cn/mip-cyb-comment/mip-cyb-comment.js](https://c.mipcdn.com/extensions/platform/v2/pc0359.cn/mip-cyb-comment/mip-cyb-comment.js)

## 说明

显示评论列表,分页,回复,支持评论

## 示例

```
<mip-cyb-comment id="{$id}" cid="{$cid}" url="https://www.xxx.com"></mip-cyb-comment>
```

## 属性

### id

**说明**:本页面ID

**必选项**:是

**单位**:字符串

**默认值**:无

### cid

**说明**:本页面分类ID

**必选项**:是

**单位**:字符串

**默认值**:无

### url

**说明**:本站点网址

**必选项**:是

**单位**:字符串

**默认值**:无
55 changes: 55 additions & 0 deletions sites/pc0359.cn/components/mip-cyb-comment/example/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<!DOCTYPE html>
<html mip>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1,user-scalable=no">
<title>评论块</title>
<link rel="canonical" href="对应的原页面地址">
<link rel="stylesheet" href="https://c.mipcdn.com/static/v2/mip.css">
<style mip-custom>
/* 自定义样式 */
</style>
</head>
<body>
<div>
<mip-cyb-comment id="" cid="" url="">
<div class="plbox ins">
<mip-form method="POST" fetch-url="/e/pl/doaction.php">
<input hidden name="nomember" type="text" id="nomember" value="1" />
<input hidden name="repid" type="text" id="repid" value="0" />
<input hidden name="id" type="text" id="id" value="24628" />
<input hidden name="classid" type="text" id="classid" value="279" />
<input hidden name="enews" type="text" id="enews" value="AddPlajax" />
<ul>
<li><textarea validatetarget="saytext" name="saytext" id="saytext" placeholder="请填写评论内容" class="textarea" required></textarea></li>
<li class="sbtn"><button type="submit" id="submit">立即发布</button> <span id="cancel" class="button">取消</span></li>
</ul>
<div class="erro" target="saytext">请填写评论内容</div>
<div submitting>
<template type="mip-mustache">
<p>正在提交申请,请耐心等待</p>
</template>
</div>
<div class="mip-example-submit-results" submit-success>
<template type="mip-mustache">
<p>{{message}}</p>
</template>
</div>
<div submit-error>
<template type="mip-mustache">
Sorry, 请求发生了一点错误
</template>
</div>
</mip-form>
</div>
<div class="plbtn">我要跟帖 </div>

<div class="comment_2 f14">所有评论 共 <span class="c1 plnum" id="plnum">0</span> 条</div>
<div id="comment-list" class="comment-list"></div>
<div id="comment-more"><input type="button" value="更多评论" class="button"></div>
</mip-cyb-comment>
</div>
<script src="https://c.mipcdn.com/static/v2/mip.js"></script>
<script src="/mip-cyb-comment/mip-cyb-comment.js"></script>
</body>
</html>
2 changes: 2 additions & 0 deletions sites/pc0359.cn/components/mip-cyb-comment/index.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
mip-cyb-comment {
}
131 changes: 131 additions & 0 deletions sites/pc0359.cn/components/mip-cyb-comment/mip-cyb-comment.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
const { CustomElement, util } = MIP
const { jsonParse, dom, css } = util
export default class MIPCybComment extends CustomElement {
data () {
return {
id: this.element.getAttribute('id'),
cid: this.element.getAttribute('cid'),
url: this.element.getAttribute('url'),
hasReply: this.element.getAttribute('hasReply')
}
}
build () {
let ele = this.element
// let morepl = ele.querySelectorAll('#comment-more')
let plbox = ele.querySelectorAll('.plbox')[0]
let plbtn = ele.querySelectorAll('.plbtn')[0]
let cancel = ele.querySelectorAll('#cancel')[0]
// 更多评论
ele.querySelectorAll('#comment-more input')[0].onclick = () => {
this.readComment()
}
// 读取评论
this.readComment()
// 显示评论
plbtn.onclick = () => {
css(plbtn, { display: 'none' })
css(plbox, { display: 'block' })
}
// 取消评论
cancel.onclick = () => {
css(plbox, { display: 'none' })
css(plbtn, { display: 'block' })
document.getElementById('repid').value = '0'
}
}

/*
*读取评论
*/
readComment () {
// let _this = this
let ul = document.getElementById('comment-list')
let morepl = this.element.querySelectorAll('#comment-more')
let oli = ul.getElementsByTagName('dl')
let p = Math.floor(oli.length / 5 + 1)
fetch(`${this.data().url}/e/extend/comments/?classid=${this.data().cid}&id=${this.data().id}&page=${p}`, {
method: 'GET'
}).then((responseText) => {
return responseText.text()
}).then((responseRes) => {
let html = ''
let data = jsonParse(responseRes)
if (p >= data.pagenum) {
morepl[0].innerHTML = '<p>没有更多评论了!</p>'
}
document.getElementById('plnum').innerText = data.num
if (data.num === 0) {
morepl[0].innerHTML = '<p class="nodp">还没有发布过评价</p>'
}
for (let i = 0; i < data.list.length; i++) {
let list = data.list[i]
html += '<dl><dt><span>' + list.saytime + '</span><b>' + list.plusername + '</b>[' + list.sayip + ']</dt><dd>' + list.saytext + '</dd><dd class="rep"><p><em><a href="javascript:;" data-id="' + list.id + '" class="up">支持</a> <i id="pldigg' + list.id + '1">' + list.zcnum + '</i></em><a href="javascript:;" class="huifu" data-id="' + list.id + '">回复</a></p></dd></dl>'
}
oli.length === 0 ? ul.innerHTML = html : ul.innerHTML = ul.innerHTML + html
this.pldigg()
this.reply()
})
}

/*
*赞评论
*/
pldigg () {
let _this = this
let ctrl = document.getElementsByClassName('up')
for (let i = 0; i < ctrl.length; i++) {
ctrl[i].onclick = function () {
let id = this.getAttribute('data-id')
let pid = document.getElementById('pldigg' + id + '1')
let num = Number(pid.innerText)
fetch(`${_this.data().url}/e/extend/comments/?enews=DoForPlajax&plid=${id}&id=${_this.data().id}&classid=${_this.data().cid}&dopl=1&doajax=1`, {
method: 'GET'
}).then((responseText) => {
return responseText.text()
}).then((responseRes) => {
let data = jsonParse(responseRes)
if (data.status === 1) {
pid.innerText = num + 1
} else {
_this.cAlert(data.msg)
}
})
}
}
}

/*
*回复评论
*/
reply () {
let _this = this
let ctrl = document.getElementsByClassName('huifu')
let repid = document.getElementById('repid')
let plbox = _this.element.querySelectorAll('.plbox')[0]
let plbtn = _this.element.querySelectorAll('.plbtn')[0]
for (let i = 0; i < ctrl.length; i++) {
ctrl[i].onclick = function () {
let id = this.getAttribute('data-id')
repid.value = id
css(plbtn, { display: 'none' })
css(plbox, { display: 'block' })
document.getElementById('saytext').focus()
}
}
}

/* 提示
*/
cAlert (msg) {
if (document.getElementById('alert_tips')) {
document.getElementById('alert_tips').parentNode.removeChild(document.getElementById('alert_tips'))
}
let cTips = dom.create(`<mip-fixed type="top" id="alert_tips" class="animated fadeIn">${msg}</mip-fixed>`)
document.body.appendChild(cTips)
setTimeout(() => {
if (document.getElementById('alert_tips')) {
document.getElementById('alert_tips').parentNode.removeChild(document.getElementById('alert_tips'))
}
}, 3000)
}
}
21 changes: 21 additions & 0 deletions sites/pc0359.cn/components/mip-cyb-downinfo/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# mip-cyb-downinfo

标题|下载页面所需逻辑
----|----
类型|
支持布局|
所需脚本| [https://c.mipcdn.com/extensions/platform/v2/pc0359.cn/mip-cyb-downinfo/mip-cyb-downinfo.js](https://c.mipcdn.com/extensions/platform/v2/pc0359.cn/mip-cyb-downinfo/mip-cyb-downinfo.js)

## 说明

用于下载地址,判断系统平台。

## 示例

<mip-cyb-downinfo></mip-cyb-downinfo>

```
<mip-cyb-downinfo><ul id="soft-download"> <li id="down-android"><a href="#" rel="nofollow" class="downonclick" data-id="">立即下载</a></li></ul></mip-cyb-downinfo>
```

## 属性
20 changes: 20 additions & 0 deletions sites/pc0359.cn/components/mip-cyb-downinfo/example/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!DOCTYPE html>
<html mip>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1,user-scalable=no">
<title>MIP page</title>
<link rel="canonical" href="对应的原页面地址">
<link rel="stylesheet" href="https://c.mipcdn.com/static/v2/mip.css">
<style mip-custom>
/* 自定义样式 */
</style>
</head>
<body>
<div>
<mip-cyb-downinfo><ul id="soft-download"> <li id="down-android"><a href="#" rel="nofollow" class="downonclick" data-id="">立即下载</a></li></ul></mip-cyb-downinfo>
</div>
<script src="https://c.mipcdn.com/static/v2/mip.js"></script>
<script src="/mip-cyb-downinfo/mip-cyb-downinfo.js"></script>
</body>
</html>
6 changes: 6 additions & 0 deletions sites/pc0359.cn/components/mip-cyb-downinfo/index.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
mip-cyb-downinfo {
.wrapper {
margin: 0 auto;
text-align: center;
}
}
37 changes: 37 additions & 0 deletions sites/pc0359.cn/components/mip-cyb-downinfo/mip-cyb-downinfo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
const { CustomElement, util } = MIP
const { platform } = util
export default class MIPCybDowninfo extends CustomElement {
build () {
let ele = this.element
// let android = platform.isAndroid()
let ios = platform.isIOS()
let down = ele.querySelectorAll('#soft-download')
let dandroid = ele.querySelectorAll('#down-android')
let dofficial = ele.querySelectorAll('#down-official')
let dappstore = ele.querySelectorAll('#down-appstore')
let dnormal = ele.querySelectorAll('#down-normal')
ele.querySelectorAll('#soft-download').innerHTML = '<li id="noDownload" class="officials">此软件不提供苹果版下载</li>'
if (ios) {
if (dandroid.length) {
down[0].removeChild(dandroid[0])
}
if (dofficial.length) {
down[0].removeChild(dofficial[0])
}
if (dappstore.length === 0) {
down[0].innerHTML = '<li id="noDownload" class="officials">此软件不提供苹果版下载</li>'
}
} else {
if (dappstore.length) {
down[0].removeChild(dappstore[0])
}
if (dandroid.length === 0) {
down[0].innerHTML = '<li id="noDownload" class="officials">此软件不提供安卓版下载</li>'
}
}
if (dnormal.length) {
down[0].removeChild(dnormal[0])
down[0].innerHTML = '<li id="noDownload" class="tips official">抱歉!此软件暂不提供手机版下载。</li>'
}
}
}
Loading