123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- //模板
- export const TemplateJsCode={
- ListJsCode:`
- var ret = []
- document.querySelectorAll("{{.ListItemCss}}").forEach((v, i) => {
- let item = {}
- if ("{{.ListLinkCss}}" != "") {
- let link = v.querySelector("{{.ListLinkCss}}")
- if (link) {
- var href = link.href
- if (!href.startsWith("http")) href = window.location.origin + "/" + href
- let title = link.getAttribute("title") || link.innerText
- item = { "title": title, "href": href, "no": i }
- } else {
- item = { "no": i }
- }
- }
- if ("{{.ListPubtimeCss}}" != "") {
- let pubtime = v.querySelector("{{.ListPubtimeCss}}")
- if (pubtime) {
- item["pubtime"] = pubtime.innerText
- }
- }
- ret.push(item)
- })
- ret
- `,
- ContentJsCode:`
- //执行JS代码
- var ret = {}
- var tmp = null
- if ("{{.TitleCss}}" != "") {//标题
- tmp = document.querySelector("{{.TitleCss}}")
- if (tmp) ret["title"] = tmp.getAttribute("title") || tmp.innerText
- }
- if ("{{.PublishUnitCss}}" != "") {//采购单位
- tmp = document.querySelector("{{.PublishUnitCss}}")
- if (tmp) ret["publishUnit"] = tmp.getAttribute("title") || tmp.innerText
- }
- if ("{{.PublishTimeCss}}" != "") {//发布时间
- tmp = document.querySelector("{{.PublishTimeCss}}")
- if (tmp) ret["publishTime"] = tmp.getAttribute("title") || tmp.innerText
- }
- if ("{{.ContentCss}}" != "") {//正文内容
- tmp = document.querySelector("{{.ContentCss}}")
- if (tmp) {
- ret["content"] = tmp.innerText
- ret["contentHtml"] = tmp.innerHTML
- }
- }
- if("{{.AttachCss}}"!=""){//附件
- tmp = document.querySelectorAll("{{.AttachCss}} a")
- let attach=[]
- if(tmp){
- tmp.forEach((v,i)=>{
- attach.push([v.getAttribute("title")||v.innerText,v.href])
- })
- }
- ret["attachLinks"]=attach
- }
- ret
- `,
- AttachJsCode:`
- //附件下载以及提交
-
- `,
- ListTurnPageJsCode: `
- //列表页翻页代码
- `
- }
|