├── LICENSE ├── README.md ├── app.js ├── app.json ├── app.wxss ├── colorui.wxss ├── component ├── cu-custom.js ├── cu-custom.json ├── custom.js ├── custom.json ├── custom.wxml └── custom.wxss ├── highlight ├── prism.js └── prism.wxss ├── icon.wxss ├── images ├── logo.png └── tabbar │ ├── about.png │ ├── about_cur.png │ ├── basics.png │ ├── basics_cur.png │ ├── component.png │ ├── component_cur.png │ ├── plugin.png │ └── plugin_cur.png ├── pages ├── about │ ├── about.js │ ├── about.json │ ├── about.wxml │ ├── about.wxss │ ├── issue.js │ ├── issue.json │ ├── issue.wxml │ ├── issue.wxss │ ├── thank.js │ ├── thank.json │ ├── thank.wxml │ └── thank.wxss ├── index │ ├── list.js │ ├── list.json │ ├── list.wxml │ ├── list.wxss │ ├── more.js │ ├── more.json │ ├── more.wxml │ ├── more.wxss │ ├── reply.js │ ├── reply.json │ ├── reply.wxml │ ├── reply.wxss │ └── router.js ├── login │ ├── login.js │ ├── login.json │ ├── login.wxml │ └── login.wxss └── temp │ ├── collection.js │ ├── collection.json │ ├── collection.wxml │ ├── collection.wxss │ ├── comment.js │ ├── comment.json │ ├── comment.wxml │ ├── comment.wxss │ ├── flash.js │ ├── flash.json │ ├── flash.wxml │ ├── flash.wxss │ ├── index.js │ ├── index.json │ ├── index.wxml │ ├── index.wxss │ ├── like.js │ ├── like.json │ ├── like.wxml │ ├── like.wxss │ ├── notice.js │ ├── notice.json │ ├── notice.wxml │ └── notice.wxss ├── project.config.json ├── scan.jpg ├── sitemap.json ├── utils ├── md5.js ├── router.js ├── timeago.js └── util.js └── wxParse ├── emojis ├── 00.gif ├── 01.gif ├── 02.gif ├── 03.gif ├── 04.gif ├── 05.gif ├── 06.gif ├── 07.gif ├── 08.gif ├── 09.gif ├── 10.gif ├── 100.gif ├── 101.gif ├── 102.gif ├── 103.gif ├── 104.gif ├── 105.gif ├── 106.gif ├── 107.gif ├── 108.gif ├── 109.gif ├── 11.gif ├── 110.gif ├── 111.gif ├── 112.gif ├── 113.gif ├── 114.gif ├── 115.gif ├── 116.gif ├── 117.gif ├── 118.gif ├── 119.gif ├── 12.gif ├── 120.gif ├── 121.gif ├── 122.gif ├── 123.gif ├── 124.gif ├── 125.gif ├── 126.gif ├── 127.gif ├── 128.gif ├── 129.gif ├── 13.gif ├── 130.gif ├── 131.gif ├── 132.gif ├── 133.gif ├── 134.gif ├── 14.gif ├── 15.gif ├── 16.gif ├── 17.gif ├── 18.gif ├── 19.gif ├── 20.gif ├── 21.gif ├── 22.gif ├── 23.gif ├── 24.gif ├── 25.gif ├── 26.gif ├── 27.gif ├── 28.gif ├── 29.gif ├── 30.gif ├── 31.gif ├── 32.gif ├── 33.gif ├── 34.gif ├── 35.gif ├── 36.gif ├── 37.gif ├── 38.gif ├── 39.gif ├── 40.gif ├── 41.gif ├── 42.gif ├── 43.gif ├── 44.gif ├── 45.gif ├── 46.gif ├── 47.gif ├── 48.gif ├── 49.gif ├── 50.gif ├── 51.gif ├── 52.gif ├── 53.gif ├── 54.gif ├── 55.gif ├── 56.gif ├── 57.gif ├── 58.gif ├── 59.gif ├── 60.gif ├── 61.gif ├── 62.gif ├── 63.gif ├── 64.gif ├── 65.gif ├── 66.gif ├── 67.gif ├── 68.gif ├── 69.gif ├── 70.gif ├── 71.gif ├── 72.gif ├── 73.gif ├── 74.gif ├── 75.gif ├── 76.gif ├── 77.gif ├── 78.gif ├── 79.gif ├── 80.gif ├── 81.gif ├── 82.gif ├── 83.gif ├── 84.gif ├── 85.gif ├── 86.gif ├── 87.gif ├── 88.gif ├── 89.gif ├── 90.gif ├── 91.gif ├── 92.gif ├── 93.gif ├── 94.gif ├── 95.gif ├── 96.gif ├── 97.gif ├── 98.gif └── 99.gif ├── highlight.js ├── html2json.js ├── htmlparser.js ├── showdown.js ├── wxDiscode.js ├── wxParse.js ├── wxParse.wxml └── wxParse.wxss /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Jarry 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 微信小程序 2 | 3 | ## 介绍 4 | 5 | 这是一款后台为 `python-flask` 的博客微信小程序。使用了 `ColorUI` 组件库。 6 | 7 | 可以实现 `代码高亮` `点赞` `收藏` `评论` `回复` `接收通知` 等功能。 8 | 9 | 微信搜索 : `jarry007` 进行体验。 10 | 11 | 或者扫码体验: 12 | 13 | 14 | 15 | --- 16 | 17 | ## 版本 18 | 19 | - ### v1.1 (05/17) 20 | 21 | - 修复个人界面点击获取头像按钮无法显示头像BUG 22 | - 解决分享之后打开页面路径不对的问题 23 | - 修复下拉后无法自动收回的问题 24 | - 在一些操作事件中加入短震动(iphone7及以上,部分安卓) 25 | - 反馈内容直接发送到作者邮箱 26 | - 点击评论的任意位置即可跳转至回复界面 27 | - 文章页面双击导航栏回到顶部 28 | 29 | - ### v1.2 (05/21) 30 | 31 | - 修复代码段无法换行问题 32 | - 修复反馈内容无图情况下无法发送的问题 33 | - 评论后延时触底 34 | - 解决消息提醒错误的问题 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /app.js: -------------------------------------------------------------------------------- 1 | //app.js 2 | var time = require('utils/util.js') 3 | App({ 4 | onLaunch: function() { 5 | wx.getSystemInfo({ 6 | success: e => { 7 | this.globalData.StatusBar = e.statusBarHeight; 8 | let custom = wx.getMenuButtonBoundingClientRect(); 9 | this.globalData.Custom = custom; 10 | this.globalData.CustomBar = custom.bottom + custom.top - e.statusBarHeight; 11 | } 12 | }) 13 | }, 14 | globalData: { 15 | userInfo: null, 16 | url: 'http://localhost:5000/', 17 | new_: '', 18 | StatusBar: '', 19 | Custom: '', 20 | CustomBar: '', 21 | routerConfig:{ 22 | tokenName:'Authorization', 23 | tokenValue:'', 24 | url:'http://localhost:5000/' 25 | } 26 | 27 | } 28 | }) -------------------------------------------------------------------------------- /app.json: -------------------------------------------------------------------------------- 1 | { 2 | "pages": [ 3 | "pages/index/list", 4 | "pages/index/more", 5 | "pages/temp/index", 6 | "pages/temp/flash", 7 | "pages/temp/like", 8 | "pages/login/login", 9 | "pages/temp/comment", 10 | "pages/temp/collection", 11 | "pages/temp/notice", 12 | "pages/about/about", 13 | "pages/about/thank", 14 | "pages/index/reply", 15 | "pages/about/issue", 16 | "component/custom" 17 | 18 | ], 19 | "window": { 20 | "backgroundTextStyle": "light", 21 | "navigationBarBackgroundColor": "#fff", 22 | "navigationBarTitleText": "ColorUI", 23 | "navigationStyle": "custom", 24 | "navigationBarTextStyle": "white" 25 | }, 26 | 27 | "tabBar": { 28 | "color": "#aaa", 29 | "selectedColor": "#39b54a", 30 | "borderStyle": "black", 31 | "backgroundColor": "#ffffff", 32 | "list": [ 33 | { 34 | "pagePath": "pages/index/list", 35 | "iconPath": "/images/tabbar/component.png", 36 | "selectedIconPath": "/images/tabbar/component_cur.png", 37 | "text": "文章" 38 | }, 39 | { 40 | "pagePath": "pages/temp/index", 41 | "iconPath": "/images/tabbar/about.png", 42 | "selectedIconPath": "/images/tabbar/about_cur.png", 43 | "text": "我的" 44 | } 45 | ] 46 | }, 47 | "usingComponents": { 48 | "cu-custom": "/component/custom" 49 | }, 50 | "sitemapLocation": "sitemap.json" 51 | } -------------------------------------------------------------------------------- /app.wxss: -------------------------------------------------------------------------------- 1 | @import "icon.wxss"; 2 | @import "colorui.wxss"; 3 | 4 | .nav-list { 5 | display: flex; 6 | flex-wrap: wrap; 7 | padding: 0px 40rpx 0px; 8 | justify-content: space-between; 9 | } 10 | 11 | .nav-li { 12 | padding: 30rpx; 13 | border-radius: 12rpx; 14 | width: 45%; 15 | margin: 0 2.5% 40rpx; 16 | background-image: url(https://image.weilanwl.com/color2.0/cardBg.png); 17 | background-size: cover; 18 | background-position: center; 19 | position: relative; 20 | z-index: 1; 21 | } 22 | 23 | .nav-li::after { 24 | content: ""; 25 | position: absolute; 26 | z-index: -1; 27 | background-color: inherit; 28 | width: 100%; 29 | height: 100%; 30 | left: 0; 31 | bottom: -10%; 32 | border-radius: 10rpx; 33 | opacity: 0.2; 34 | transform: scale(0.9, 0.9); 35 | } 36 | 37 | .nav-li.cur { 38 | color: #fff; 39 | background: rgb(94, 185, 94); 40 | box-shadow: 4rpx 4rpx 6rpx rgba(94, 185, 94, 0.4); 41 | } 42 | 43 | .nav-title { 44 | font-size: 32rpx; 45 | font-weight: 300; 46 | } 47 | 48 | .nav-title::first-letter { 49 | font-size: 40rpx; 50 | margin-right: 4rpx; 51 | } 52 | 53 | .nav-name { 54 | font-size: 28rpx; 55 | text-transform: Capitalize; 56 | margin-top: 20rpx; 57 | position: relative; 58 | } 59 | 60 | .nav-name::before { 61 | content: ""; 62 | position: absolute; 63 | display: block; 64 | width: 40rpx; 65 | height: 6rpx; 66 | background: #fff; 67 | bottom: 0; 68 | right: 0; 69 | opacity: 0.5; 70 | } 71 | 72 | .nav-name::after { 73 | content: ""; 74 | position: absolute; 75 | display: block; 76 | width: 100rpx; 77 | height: 1px; 78 | background: #fff; 79 | bottom: 0; 80 | right: 40rpx; 81 | opacity: 0.3; 82 | } 83 | 84 | .nav-name::first-letter { 85 | font-weight: bold; 86 | font-size: 36rpx; 87 | margin-right: 1px; 88 | } 89 | 90 | .nav-li text { 91 | position: absolute; 92 | right: 30rpx; 93 | top: 30rpx; 94 | font-size: 52rpx; 95 | width: 60rpx; 96 | height: 60rpx; 97 | text-align: center; 98 | line-height: 60rpx; 99 | } 100 | 101 | .text-light { 102 | font-weight: 300; 103 | } 104 | 105 | @keyframes show { 106 | 0% { 107 | transform: translateY(-50px); 108 | } 109 | 110 | 60% { 111 | transform: translateY(40rpx); 112 | } 113 | 114 | 100% { 115 | transform: translateY(0px); 116 | } 117 | } 118 | 119 | @-webkit-keyframes show { 120 | 0% { 121 | transform: translateY(-50px); 122 | } 123 | 124 | 60% { 125 | transform: translateY(40rpx); 126 | } 127 | 128 | 100% { 129 | transform: translateY(0px); 130 | } 131 | } 132 | -------------------------------------------------------------------------------- /component/cu-custom.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jarry007/wxBlog/0c170f6b46751976b273f8bd94524451e9b0df47/component/cu-custom.js -------------------------------------------------------------------------------- /component/cu-custom.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jarry007/wxBlog/0c170f6b46751976b273f8bd94524451e9b0df47/component/cu-custom.json -------------------------------------------------------------------------------- /component/custom.js: -------------------------------------------------------------------------------- 1 | const app = getApp(); 2 | Component({ 3 | /** 4 | * 组件的一些选项 5 | */ 6 | options: { 7 | addGlobalClass: true, 8 | multipleSlots: true 9 | }, 10 | /** 11 | * 组件的对外属性 12 | */ 13 | properties: { 14 | bgColor: { 15 | type: String, 16 | default: '' 17 | }, 18 | isCustom: { 19 | type: [Boolean, String], 20 | default: false 21 | }, 22 | isBack: { 23 | type: [Boolean, String], 24 | default: false 25 | }, 26 | bgImage: { 27 | type: String, 28 | default: '' 29 | }, 30 | }, 31 | /** 32 | * 组件的初始数据 33 | */ 34 | attached() { 35 | // console.log(app.sysCallBack) 36 | // if (app.globalData.barInfo.Custom){ 37 | // this.setData({ 38 | // StatusBar: app.globalData.barInfo.StatusBar, 39 | // CustomBar: app.globalData.barInfo.CustomBar, 40 | // Custom: app.globalData.barInfo.Custom 41 | // }) 42 | // }else{ 43 | // console.log('callbackkkkkk') 44 | // app.sysCallBack = e=>{ 45 | // console.log('e',e) 46 | // this.setData({ 47 | // StatusBar: e.statusBarHeight, 48 | // CustomBar: custom.bottom + custom.top - e.statusBarHeight, 49 | // Custom: custom 50 | // }) 51 | // } 52 | // } 53 | 54 | wx.getSystemInfo({ 55 | 56 | success: e => { 57 | let custom = wx.getMenuButtonBoundingClientRect(); 58 | 59 | // this.globalData.barInfo.StatusBar = e.statusBarHeight; 60 | 61 | // this.globalData.barInfo.Custom = custom; 62 | // this.globalData.barInfo.CustomBar = custom.bottom + custom.top - e.statusBarHeight; 63 | 64 | 65 | this.setData({ 66 | StatusBar: e.statusBarHeight, 67 | Custom: custom, 68 | CustomBar: custom.bottom + custom.top - e.statusBarHeight 69 | }) 70 | 71 | } 72 | }) 73 | }, 74 | data: { 75 | StatusBar: '', 76 | CustomBar: '', 77 | Custom: '' 78 | }, 79 | /** 80 | * 组件的方法列表 81 | */ 82 | methods: { 83 | BackPage() { 84 | wx.navigateBack({ 85 | delta: 1 86 | }); 87 | }, 88 | toHome() { 89 | wx.reLaunch({ 90 | url: '/pages/index/index', 91 | }) 92 | } 93 | } 94 | }) -------------------------------------------------------------------------------- /component/custom.json: -------------------------------------------------------------------------------- 1 | { 2 | "component": true, 3 | "usingComponents": {} 4 | } -------------------------------------------------------------------------------- /component/custom.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /component/custom.wxss: -------------------------------------------------------------------------------- 1 | /* component/custom.wxss */ -------------------------------------------------------------------------------- /highlight/prism.js: -------------------------------------------------------------------------------- 1 | 2 | var _self="undefined"!=typeof window?window:"undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope?self:{},Prism=function(g){var c=/\blang(?:uage)?-([\w-]+)\b/i,a=0,C={manual:g.Prism&&g.Prism.manual,disableWorkerMessageHandler:g.Prism&&g.Prism.disableWorkerMessageHandler,util:{encode:function(e){return e instanceof M?new M(e.type,C.util.encode(e.content),e.alias):Array.isArray(e)?e.map(C.util.encode):e.replace(/&/g,"&").replace(/e.length)return;if(!(k instanceof M)){if(f&&y!=a.length-1){if(c.lastIndex=v,!(x=c.exec(e)))break;for(var b=x.index+(h?x[1].length:0),w=x.index+x[0].length,A=y,P=v,O=a.length;A"+t.content+""},!g.document)return g.addEventListener&&(C.disableWorkerMessageHandler||g.addEventListener("message",function(e){var a=JSON.parse(e.data),t=a.language,n=a.code,r=a.immediateClose;g.postMessage(C.highlight(n,C.languages[t],t)),r&&g.close()},!1)),C;var e=document.currentScript||[].slice.call(document.getElementsByTagName("script")).pop();return e&&(C.filename=e.src,C.manual||e.hasAttribute("data-manual")||("loading"!==document.readyState?window.requestAnimationFrame?window.requestAnimationFrame(C.highlightAll):window.setTimeout(C.highlightAll,16):document.addEventListener("DOMContentLoaded",C.highlightAll))),C}(_self);"undefined"!=typeof module&&module.exports&&(module.exports=Prism),"undefined"!=typeof global&&(global.Prism=Prism); 3 | Prism.languages.markup={comment://,prolog:/<\?[\s\S]+?\?>/,doctype://i,cdata://i,tag:{pattern:/<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/i,greedy:!0,inside:{tag:{pattern:/^<\/?[^\s>\/]+/i,inside:{punctuation:/^<\/?/,namespace:/^[^\s>\/:]+:/}},"attr-value":{pattern:/=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/i,inside:{punctuation:[/^=/,{pattern:/^(\s*)["']|["']$/,lookbehind:!0}]}},punctuation:/\/?>/,"attr-name":{pattern:/[^\s>\/]+/,inside:{namespace:/^[^\s>\/:]+:/}}}},entity:/&#?[\da-z]{1,8};/i},Prism.languages.markup.tag.inside["attr-value"].inside.entity=Prism.languages.markup.entity,Prism.hooks.add("wrap",function(a){"entity"===a.type&&(a.attributes.title=a.content.replace(/&/,"&"))}),Object.defineProperty(Prism.languages.markup.tag,"addInlined",{value:function(a,e){var s={};s["language-"+e]={pattern:/(^$)/i,lookbehind:!0,inside:Prism.languages[e]},s.cdata=/^$/i;var n={"included-cdata":{pattern://i,inside:s}};n["language-"+e]={pattern:/[\s\S]+/,inside:Prism.languages[e]};var i={};i[a]={pattern:RegExp("(<__[\\s\\S]*?>)(?:\\s*|[\\s\\S])*?(?=<\\/__>)".replace(/__/g,a),"i"),lookbehind:!0,greedy:!0,inside:n},Prism.languages.insertBefore("markup","cdata",i)}}),Prism.languages.xml=Prism.languages.extend("markup",{}),Prism.languages.html=Prism.languages.markup,Prism.languages.mathml=Prism.languages.markup,Prism.languages.svg=Prism.languages.markup; 4 | !function(s){var e=/("|')(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/;s.languages.css={comment:/\/\*[\s\S]*?\*\//,atrule:{pattern:/@[\w-]+?[\s\S]*?(?:;|(?=\s*\{))/i,inside:{rule:/@[\w-]+/}},url:RegExp("url\\((?:"+e.source+"|.*?)\\)","i"),selector:RegExp("[^{}\\s](?:[^{};\"']|"+e.source+")*?(?=\\s*\\{)"),string:{pattern:e,greedy:!0},property:/[-_a-z\xA0-\uFFFF][-\w\xA0-\uFFFF]*(?=\s*:)/i,important:/!important\b/i,function:/[-a-z0-9]+(?=\()/i,punctuation:/[(){};:,]/},s.languages.css.atrule.inside.rest=s.languages.css;var a=s.languages.markup;a&&(a.tag.addInlined("style","css"),s.languages.insertBefore("inside","attr-value",{"style-attr":{pattern:/\s*style=("|')(?:\\[\s\S]|(?!\1)[^\\])*\1/i,inside:{"attr-name":{pattern:/^\s*style/i,inside:a.tag.inside},punctuation:/^\s*=\s*['"]|['"]\s*$/,"attr-value":{pattern:/.+/i,inside:s.languages.css}},alias:"language-css"}},a.tag))}(Prism); 5 | Prism.languages.clike={comment:[{pattern:/(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,lookbehind:!0},{pattern:/(^|[^\\:])\/\/.*/,lookbehind:!0,greedy:!0}],string:{pattern:/(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,greedy:!0},"class-name":{pattern:/((?:\b(?:class|interface|extends|implements|trait|instanceof|new)\s+)|(?:catch\s+\())[\w.\\]+/i,lookbehind:!0,inside:{punctuation:/[.\\]/}},keyword:/\b(?:if|else|while|do|for|return|in|instanceof|function|new|try|throw|catch|finally|null|break|continue)\b/,boolean:/\b(?:true|false)\b/,function:/\w+(?=\()/,number:/\b0x[\da-f]+\b|(?:\b\d+\.?\d*|\B\.\d+)(?:e[+-]?\d+)?/i,operator:/--?|\+\+?|!=?=?|<=?|>=?|==?=?|&&?|\|\|?|\?|\*|\/|~|\^|%/,punctuation:/[{}[\];(),.:]/}; 6 | Prism.languages.javascript=Prism.languages.extend("clike",{"class-name":[Prism.languages.clike["class-name"],{pattern:/(^|[^$\w\xA0-\uFFFF])[_$A-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\.(?:prototype|constructor))/,lookbehind:!0}],keyword:[{pattern:/((?:^|})\s*)(?:catch|finally)\b/,lookbehind:!0},{pattern:/(^|[^.])\b(?:as|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,lookbehind:!0}],number:/\b(?:(?:0[xX][\dA-Fa-f]+|0[bB][01]+|0[oO][0-7]+)n?|\d+n|NaN|Infinity)\b|(?:\b\d+\.?\d*|\B\.\d+)(?:[Ee][+-]?\d+)?/,function:/[_$a-zA-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,operator:/-[-=]?|\+[+=]?|!=?=?|<>?>?=?|=(?:==?|>)?|&[&=]?|\|[|=]?|\*\*?=?|\/=?|~|\^=?|%=?|\?|\.{3}/}),Prism.languages.javascript["class-name"][0].pattern=/(\b(?:class|interface|extends|implements|instanceof|new)\s+)[\w.\\]+/,Prism.languages.insertBefore("javascript","keyword",{regex:{pattern:/((?:^|[^$\w\xA0-\uFFFF."'\])\s])\s*)\/(\[(?:[^\]\\\r\n]|\\.)*]|\\.|[^/\\\[\r\n])+\/[gimyu]{0,5}(?=\s*($|[\r\n,.;})\]]))/,lookbehind:!0,greedy:!0},"function-variable":{pattern:/[_$a-zA-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|[_$a-zA-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*)\s*=>))/,alias:"function"},parameter:[{pattern:/(function(?:\s+[_$A-Za-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*)?\s*\(\s*)(?!\s)(?:[^()]|\([^()]*\))+?(?=\s*\))/,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/[_$a-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\s*=>)/i,inside:Prism.languages.javascript},{pattern:/(\(\s*)(?!\s)(?:[^()]|\([^()]*\))+?(?=\s*\)\s*=>)/,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:[_$A-Za-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*\s*)\(\s*)(?!\s)(?:[^()]|\([^()]*\))+?(?=\s*\)\s*\{)/,lookbehind:!0,inside:Prism.languages.javascript}],constant:/\b[A-Z](?:[A-Z_]|\dx?)*\b/}),Prism.languages.insertBefore("javascript","string",{"template-string":{pattern:/`(?:\\[\s\S]|\${[^}]+}|[^\\`])*`/,greedy:!0,inside:{interpolation:{pattern:/\${[^}]+}/,inside:{"interpolation-punctuation":{pattern:/^\${|}$/,alias:"punctuation"},rest:Prism.languages.javascript}},string:/[\s\S]+/}}}),Prism.languages.markup&&Prism.languages.markup.tag.addInlined("script","javascript"),Prism.languages.js=Prism.languages.javascript; 7 | Prism.languages.c=Prism.languages.extend("clike",{"class-name":{pattern:/(\b(?:enum|struct)\s+)\w+/,lookbehind:!0},keyword:/\b(?:_Alignas|_Alignof|_Atomic|_Bool|_Complex|_Generic|_Imaginary|_Noreturn|_Static_assert|_Thread_local|asm|typeof|inline|auto|break|case|char|const|continue|default|do|double|else|enum|extern|float|for|goto|if|int|long|register|return|short|signed|sizeof|static|struct|switch|typedef|union|unsigned|void|volatile|while)\b/,operator:/>>=?|<<=?|->|([-+&|:])\1|[?:~]|[-+*/%&|^!=<>]=?/,number:/(?:\b0x(?:[\da-f]+\.?[\da-f]*|\.[\da-f]+)(?:p[+-]?\d+)?|(?:\b\d+\.?\d*|\B\.\d+)(?:e[+-]?\d+)?)[ful]*/i}),Prism.languages.insertBefore("c","string",{macro:{pattern:/(^\s*)#\s*[a-z]+(?:[^\r\n\\]|\\(?:\r\n|[\s\S]))*/im,lookbehind:!0,alias:"property",inside:{string:{pattern:/(#\s*include\s*)(?:<.+?>|("|')(?:\\?.)+?\2)/,lookbehind:!0},directive:{pattern:/(#\s*)\b(?:define|defined|elif|else|endif|error|ifdef|ifndef|if|import|include|line|pragma|undef|using)\b/,lookbehind:!0,alias:"keyword"}}},constant:/\b(?:__FILE__|__LINE__|__DATE__|__TIME__|__TIMESTAMP__|__func__|EOF|NULL|SEEK_CUR|SEEK_END|SEEK_SET|stdin|stdout|stderr)\b/}),delete Prism.languages.c.boolean; 8 | !function(e){var t=/\b(?:abstract|continue|for|new|switch|assert|default|goto|package|synchronized|boolean|do|if|private|this|break|double|implements|protected|throw|byte|else|import|public|throws|case|enum|instanceof|return|transient|catch|extends|int|short|try|char|final|interface|static|void|class|finally|long|strictfp|volatile|const|float|native|super|while|var|null|exports|module|open|opens|provides|requires|to|transitive|uses|with)\b/,a=/\b[A-Z](?:\w*[a-z]\w*)?\b/;e.languages.java=e.languages.extend("clike",{"class-name":[a,/\b[A-Z]\w*(?=\s+\w+\s*[;,=())])/],keyword:t,function:[e.languages.clike.function,{pattern:/(\:\:)[a-z_]\w*/,lookbehind:!0}],number:/\b0b[01][01_]*L?\b|\b0x[\da-f_]*\.?[\da-f_p+-]+\b|(?:\b\d[\d_]*\.?[\d_]*|\B\.\d[\d_]*)(?:e[+-]?\d[\d_]*)?[dfl]?/i,operator:{pattern:/(^|[^.])(?:<<=?|>>>?=?|->|([-+&|])\2|[?:~]|[-+*/%&|^!=<>]=?)/m,lookbehind:!0}}),e.languages.insertBefore("java","class-name",{annotation:{alias:"punctuation",pattern:/(^|[^.])@\w+/,lookbehind:!0},namespace:{pattern:/(\b(?:exports|import(?:\s+static)?|module|open|opens|package|provides|requires|to|transitive|uses|with)\s+)[a-z]\w*(\.[a-z]\w*)+/,lookbehind:!0,inside:{punctuation:/\./}},generics:{pattern:/<(?:[\w\s,.&?]|<(?:[\w\s,.&?]|<(?:[\w\s,.&?]|<[\w\s,.&?]*>)*>)*>)*>/,inside:{"class-name":a,keyword:t,punctuation:/[<>(),.:]/,operator:/[?&|]/}}})}(Prism); 9 | Prism.languages.python={comment:{pattern:/(^|[^\\])#.*/,lookbehind:!0},"string-interpolation":{pattern:/(?:f|rf|fr)(?:("""|''')[\s\S]+?\1|("|')(?:\\.|(?!\2)[^\\\r\n])*\2)/i,greedy:!0,inside:{interpolation:{pattern:/((?:^|[^{])(?:{{)*){(?!{)(?:[^{}]|{(?!{)(?:[^{}]|{(?!{)(?:[^{}])+})+})+}/,lookbehind:!0,inside:{"format-spec":{pattern:/(:)[^:(){}]+(?=}$)/,lookbehind:!0},"conversion-option":{pattern:/![sra](?=[:}]$)/,alias:"punctuation"},rest:null}},string:/[\s\S]+/}},"triple-quoted-string":{pattern:/(?:[rub]|rb|br)?("""|''')[\s\S]+?\1/i,greedy:!0,alias:"string"},string:{pattern:/(?:[rub]|rb|br)?("|')(?:\\.|(?!\1)[^\\\r\n])*\1/i,greedy:!0},function:{pattern:/((?:^|\s)def[ \t]+)[a-zA-Z_]\w*(?=\s*\()/g,lookbehind:!0},"class-name":{pattern:/(\bclass\s+)\w+/i,lookbehind:!0},decorator:{pattern:/(^\s*)@\w+(?:\.\w+)*/i,lookbehind:!0,alias:["annotation","punctuation"],inside:{punctuation:/\./}},keyword:/\b(?:and|as|assert|async|await|break|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|nonlocal|not|or|pass|print|raise|return|try|while|with|yield)\b/,builtin:/\b(?:__import__|abs|all|any|apply|ascii|basestring|bin|bool|buffer|bytearray|bytes|callable|chr|classmethod|cmp|coerce|compile|complex|delattr|dict|dir|divmod|enumerate|eval|execfile|file|filter|float|format|frozenset|getattr|globals|hasattr|hash|help|hex|id|input|int|intern|isinstance|issubclass|iter|len|list|locals|long|map|max|memoryview|min|next|object|oct|open|ord|pow|property|range|raw_input|reduce|reload|repr|reversed|round|set|setattr|slice|sorted|staticmethod|str|sum|super|tuple|type|unichr|unicode|vars|xrange|zip)\b/,boolean:/\b(?:True|False|None)\b/,number:/(?:\b(?=\d)|\B(?=\.))(?:0[bo])?(?:(?:\d|0x[\da-f])[\da-f]*\.?\d*|\.\d+)(?:e[+-]?\d+)?j?\b/i,operator:/[-+%=]=?|!=|\*\*?=?|\/\/?=?|<[<=>]?|>[=>]?|[&|^~]/,punctuation:/[{}[\];(),.:]/},Prism.languages.python["string-interpolation"].inside.interpolation.inside.rest=Prism.languages.python,Prism.languages.py=Prism.languages.python; 10 | -------------------------------------------------------------------------------- /highlight/prism.wxss: -------------------------------------------------------------------------------- 1 | /* PrismJS 1.16.0 2 | https://prismjs.com/download.html#themes=prism&languages=markup+css+clike+javascript+c+java+python */ 3 | /** 4 | * prism.js default theme for JavaScript, CSS and HTML 5 | * Based on dabblet (http://dabblet.com) 6 | * @author Lea Verou 7 | */ 8 | 9 | code[class*="language-"], 10 | .wxParse-pre { 11 | color: black; 12 | background: none; 13 | text-shadow: 0 1px white; 14 | font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace; 15 | font-size: 1em; 16 | text-align: left; 17 | white-space: pre; 18 | word-spacing: normal; 19 | word-break: normal; 20 | word-wrap: normal; 21 | line-height: 1.5; 22 | 23 | -moz-tab-size: 4; 24 | -o-tab-size: 4; 25 | tab-size: 4; 26 | 27 | -webkit-hyphens: none; 28 | -moz-hyphens: none; 29 | -ms-hyphens: none; 30 | hyphens: none; 31 | } 32 | 33 | .wxParse-pre::-moz-selection, .wxParse-pre::-moz-selection, 34 | code[class*="language-"]::-moz-selection, code[class*="language-"] ::-moz-selection { 35 | text-shadow: none; 36 | background: #080d13; 37 | } 38 | 39 | .wxParse-pre::selection, .wxParse-pre ::selection, 40 | code[class*="language-"]::selection, code[class*="language-"] ::selection { 41 | text-shadow: none; 42 | background: #040608; 43 | } 44 | 45 | @media print { 46 | code[class*="language-"], 47 | pre[class*="language-"] { 48 | text-shadow: none; 49 | } 50 | } 51 | 52 | /* Code blocks */ 53 | .wxParse-pre { 54 | padding: 1em; 55 | margin: .5em 0; 56 | overflow: auto; 57 | border-radius: 10rpx; 58 | } 59 | 60 | :not(pre) > code[class*="language-"], 61 | .wxParse-pre { 62 | background: #f7f7f7; 63 | border: 1rpx solid rgb(209, 208, 208); 64 | border-radius: 10rpx; 65 | } 66 | /* Inline code */ 67 | :not(pre) > code[class*="language-"] { 68 | padding: .1em; 69 | border-radius: .3em; 70 | white-space: normal; 71 | } 72 | 73 | .token.comment, 74 | .token.prolog, 75 | .token.doctype, 76 | .token.cdata { 77 | color: slategray; 78 | } 79 | 80 | .token.punctuation { 81 | color: #999; 82 | } 83 | 84 | .namespace { 85 | opacity: .7; 86 | } 87 | 88 | .token.property, 89 | .token.tag, 90 | .token.boolean, 91 | .token.number, 92 | .token.constant, 93 | .token.symbol, 94 | .token.deleted { 95 | color: #905; 96 | } 97 | 98 | .token.selector, 99 | .token.attr-name, 100 | .token.string, 101 | .token.char, 102 | .token.builtin, 103 | .token.inserted { 104 | color: #690; 105 | } 106 | 107 | .token.operator, 108 | .token.entity, 109 | .token.url, 110 | .language-css .token.string, 111 | .style .token.string { 112 | color: #9a6e3a; 113 | background: hsla(0, 0%, 100%, .5); 114 | } 115 | 116 | .token.atrule, 117 | .token.attr-value, 118 | .token.keyword { 119 | color: #07a; 120 | } 121 | 122 | .token.function, 123 | .token.class-name { 124 | color: #DD4A68; 125 | } 126 | 127 | .token.regex, 128 | .token.important, 129 | .token.variable { 130 | color: #e90; 131 | } 132 | 133 | .token.important, 134 | .token.bold { 135 | font-weight: bold; 136 | } 137 | .token.italic { 138 | font-style: italic; 139 | } 140 | 141 | .token.entity { 142 | cursor: help; 143 | } 144 | 145 | -------------------------------------------------------------------------------- /images/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jarry007/wxBlog/0c170f6b46751976b273f8bd94524451e9b0df47/images/logo.png -------------------------------------------------------------------------------- /images/tabbar/about.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jarry007/wxBlog/0c170f6b46751976b273f8bd94524451e9b0df47/images/tabbar/about.png -------------------------------------------------------------------------------- /images/tabbar/about_cur.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jarry007/wxBlog/0c170f6b46751976b273f8bd94524451e9b0df47/images/tabbar/about_cur.png -------------------------------------------------------------------------------- /images/tabbar/basics.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jarry007/wxBlog/0c170f6b46751976b273f8bd94524451e9b0df47/images/tabbar/basics.png -------------------------------------------------------------------------------- /images/tabbar/basics_cur.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jarry007/wxBlog/0c170f6b46751976b273f8bd94524451e9b0df47/images/tabbar/basics_cur.png -------------------------------------------------------------------------------- /images/tabbar/component.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jarry007/wxBlog/0c170f6b46751976b273f8bd94524451e9b0df47/images/tabbar/component.png -------------------------------------------------------------------------------- /images/tabbar/component_cur.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jarry007/wxBlog/0c170f6b46751976b273f8bd94524451e9b0df47/images/tabbar/component_cur.png -------------------------------------------------------------------------------- /images/tabbar/plugin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jarry007/wxBlog/0c170f6b46751976b273f8bd94524451e9b0df47/images/tabbar/plugin.png -------------------------------------------------------------------------------- /images/tabbar/plugin_cur.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jarry007/wxBlog/0c170f6b46751976b273f8bd94524451e9b0df47/images/tabbar/plugin_cur.png -------------------------------------------------------------------------------- /pages/about/about.js: -------------------------------------------------------------------------------- 1 | const app = getApp(); 2 | Page({ 3 | data: { 4 | StatusBar: app.globalData.StatusBar, 5 | CustomBar: app.globalData.CustomBar, 6 | ColorList: app.globalData.ColorList, 7 | }, 8 | onLoad: function () { }, 9 | pageBack() { 10 | wx.navigateBack({ 11 | delta: 1 12 | }); 13 | } 14 | }); -------------------------------------------------------------------------------- /pages/about/about.json: -------------------------------------------------------------------------------- 1 | { 2 | "usingComponents": {} 3 | } -------------------------------------------------------------------------------- /pages/about/about.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 返回 4 | 5 | 6 | 更多功能 7 | 8 | 目前web端和小程序端还不能实现账号同步,您可以访问 'blogai.cn' 使用完整版的博客,web端可以支持博客文章的撰写,用户的关注等。 9 | 如果您觉得不错,请移步github给作者点个赞吧。谢谢! 10 | 更多功能敬请期待! 11 | ---2019/5/6--- 12 | 13 | 14 | -------------------------------------------------------------------------------- /pages/about/about.wxss: -------------------------------------------------------------------------------- 1 | /* pages/about/about.wxss */ -------------------------------------------------------------------------------- /pages/about/issue.js: -------------------------------------------------------------------------------- 1 | const app = getApp() 2 | const accountInfo = wx.getAccountInfoSync() 3 | var router = require('../index/router.js'); 4 | Page({ 5 | 6 | 7 | data: { 8 | StatusBar: app.globalData.StatusBar, 9 | CustomBar: app.globalData.CustomBar, 10 | ColorList: app.globalData.ColorList, 11 | imgList:[] 12 | }, 13 | onLoad: function (options) { 14 | 15 | }, 16 | 17 | onReady: function () { 18 | 19 | }, 20 | issue(e){ 21 | wx.vibrateShort({}) 22 | let iss = e.detail.value.issue, 23 | imgs = this.data.imgList; 24 | if (iss){ 25 | wx.showToast({ 26 | title: '反馈成功', 27 | icon:'success' 28 | }) 29 | if(this.data.imgList.length>0){ 30 | wx.uploadFile({ 31 | url: 'https://blogai.cn/mp/send_mail' , 32 | header:{ 33 | appid: String(accountInfo.miniProgram.appId) 34 | }, 35 | metohd: 'POST', 36 | filePath: String(imgs[0]), 37 | name: 'imgs', 38 | formData:{ 39 | iss:JSON.stringify(iss) 40 | }, 41 | success:res=>{ 42 | console.log(res) 43 | } 44 | })}else{ 45 | wx.request({ 46 | url: 'https://blogai.cn/mp/send_mail', 47 | header: { 48 | appid: String(accountInfo.miniProgram.appId) 49 | }, 50 | metohd: 'POST', 51 | data:{ 52 | iss: JSON.stringify(iss) 53 | }, 54 | success:res=>{ 55 | console.log(res) 56 | } 57 | }) 58 | } 59 | }else{ 60 | wx.showToast({ 61 | title: '不能为空', 62 | icon:'none' 63 | }) 64 | } 65 | }, 66 | choose(e){ 67 | wx.vibrateShort({}) 68 | // let imgCount = 3-this.data.imgList.length 69 | wx.chooseImage({ 70 | count: 1, 71 | sizeType: ['original', 'compressed'], 72 | sourceType: ['album'], 73 | success: res=> { 74 | if (this.data.imgList.length != 0) { 75 | this.setData({ 76 | imgList: this.data.imgList.concat(res.tempFilePaths) 77 | }) 78 | } else { 79 | this.setData({ 80 | imgList: res.tempFilePaths 81 | }) 82 | } 83 | } 84 | }) 85 | }, 86 | ViewImage(e) { 87 | wx.previewImage({ 88 | urls: this.data.imgList, 89 | current: e.currentTarget.dataset.url 90 | }); 91 | }, 92 | closeimg(e){ 93 | 94 | this.setData({ 95 | imgList: [] 96 | }) 97 | } 98 | }) -------------------------------------------------------------------------------- /pages/about/issue.json: -------------------------------------------------------------------------------- 1 | { 2 | "usingComponents": {} 3 | } -------------------------------------------------------------------------------- /pages/about/issue.wxml: -------------------------------------------------------------------------------- 1 | 返回反馈 2 | 3 | 4 | 5 |
6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 |
-------------------------------------------------------------------------------- /pages/about/issue.wxss: -------------------------------------------------------------------------------- 1 | /* pages/about/issue.wxss */ -------------------------------------------------------------------------------- /pages/about/thank.js: -------------------------------------------------------------------------------- 1 | const app = getApp(); 2 | Page({ 3 | data: { 4 | StatusBar: app.globalData.StatusBar, 5 | CustomBar: app.globalData.CustomBar, 6 | ColorList: app.globalData.ColorList, 7 | }, 8 | 9 | }) -------------------------------------------------------------------------------- /pages/about/thank.json: -------------------------------------------------------------------------------- 1 | { 2 | "usingComponents": {} 3 | } -------------------------------------------------------------------------------- /pages/about/thank.wxml: -------------------------------------------------------------------------------- 1 | 返回 2 | 3 | 4 | 特别感谢 5 | "ALL-in",取这个名字是希望对待任何事情都要全力以赴,不留遗憾。 6 | 该项目是我的博客(blogai.cn)的微信小程序版本,后台使用的是python的flask框架。匆忙之中赶出来的,作为一个新手,存在很多不足。如果您在使用中遇到了任何问题,欢迎反馈。 7 | 另外该小程序的开发使用到了很多优秀的开源组件和插件,特在此表示感谢 8 | 9 | - ColorUI 组件库 10 | - wxParse 11 | - Prism 12 | - 日出一点一 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /pages/about/thank.wxss: -------------------------------------------------------------------------------- 1 | /* pages/about/thank.wxss */ -------------------------------------------------------------------------------- /pages/index/list.js: -------------------------------------------------------------------------------- 1 | // pages/index/list.js 2 | const app = getApp() 3 | const { 4 | Router 5 | } = require('../../utils/router.js'); 6 | var time = require('../../utils/util.js') 7 | var router = require('../index/router.js'); 8 | Page({ 9 | data: { 10 | posts: '', 11 | cardCur: 0, 12 | news: '', 13 | page: 1, 14 | StatusBar: app.globalData.StatusBar, 15 | CustomBar: app.globalData.CustomBar, 16 | first_tap: '', 17 | pageNum:1, 18 | canScroll:true, 19 | list:[], 20 | hiddenLoading:false 21 | }, 22 | onLoad: function (options) { 23 | wx.vibrateShort({}) 24 | this.getNew() 25 | this.getList() 26 | // router.route_request('mp/new').catch(res => { 27 | // let news = res.news; 28 | // for (var i = 0; i < news.length; i++) { 29 | // news[i]['time'] = time.formatTime(new Date(news[i]['time'].replace('GMT', ''))) 30 | // } 31 | // this.setData({ 32 | // news: news 33 | // }) 34 | // }) 35 | 36 | }, 37 | getNew() { 38 | Router.get('mp/new').then(res => { 39 | this.setData({ 40 | news: res.data 41 | }) 42 | }) 43 | }, 44 | getList(e) { 45 | if (e === 'refresh') { 46 | this.data.pageNum = 1 47 | } else { 48 | if (!this.data.canScroll) return 49 | } 50 | const parmas = { 51 | pageNum: this.data.pageNum 52 | } 53 | Router.get('get-list', parmas).then(res => { 54 | console.log('列表', res) 55 | if(e==='refresh'){ 56 | this.setData({ 57 | list: res.data, 58 | status: false, 59 | hiddenLoading:true 60 | }) 61 | }else{ 62 | this.data.list = this.data.list.concat(res.data) 63 | this.setData({ 64 | list: this.data.list, 65 | hiddenLoading:true 66 | }) 67 | } 68 | this.data.pageNum++ 69 | 70 | this.setData({ 71 | canScroll: res.data.length === 10 72 | }) 73 | }) 74 | }, 75 | // onReady: function () { 76 | 77 | // let info = { 78 | // page: this.data.page 79 | // } 80 | // router.route_request('mp/posts', info).catch(res => { 81 | 82 | // let post_ = res.posts 83 | // for (var i = 0; i < post_.length; i++) { 84 | // post_[i]['time'] = time.formatTime(new Date(post_[i]['time'].replace('GMT', ''))) 85 | // } 86 | // this.setData({ 87 | // posts: post_ 88 | // }) 89 | // }) 90 | 91 | // }, 92 | more: function (event) { 93 | let postId = event.currentTarget.dataset.id 94 | wx.navigateTo({ 95 | url: 'more?id=' + postId, 96 | }) 97 | }, 98 | onShow: function () { 99 | 100 | 101 | 102 | }, 103 | cardSwiper(e) { 104 | this.setData({ 105 | cardCur: e.detail.current 106 | }) 107 | }, 108 | 109 | 110 | 111 | 112 | onReachBottom: function () { 113 | wx.vibrateShort({}) 114 | wx.showLoading({ 115 | title: '数据加载中...', 116 | icon: 'loading', 117 | duration: 1000 118 | }) 119 | let page = this.data.page + 1, 120 | posts = this.data.posts, 121 | info = { 122 | page: page 123 | } 124 | console.log('page' + page) 125 | router.route_request('mp/posts', info).catch(res => { 126 | let news = res.posts 127 | for (var i = 0; i < news.length; i++) { 128 | news[i]['time'] = time.formatTime(new Date(news[i]['time'].replace('GMT', ''))) 129 | } 130 | this.setData({ 131 | posts: posts.concat(news) 132 | }) 133 | }) 134 | this.setData({ 135 | page: page 136 | }) 137 | 138 | 139 | }, 140 | onPullDownRefresh() { 141 | wx.vibrateShort({}) 142 | wx.showNavigationBarLoading() 143 | console.log('到顶了') 144 | wx.showLoading({ 145 | title: '刷新中...', 146 | icon: 'loading', 147 | duration: 1500 148 | }) 149 | let info = { 150 | page: 1 151 | } 152 | router.route_request('mp/posts', info).catch(res => { 153 | let news = res.posts 154 | for (var i = 0; i < news.length; i++) { 155 | news[i]['time'] = time.formatTime(new Date(news[i]['time'].replace('GMT', ''))) 156 | } 157 | this.setData({ 158 | posts: news, 159 | page: 1 160 | }) 161 | }) 162 | wx.stopPullDownRefresh(); 163 | 164 | }, 165 | totop(e) { 166 | let first = e.timeStamp 167 | if (first - this.data.first_tap < 300) { 168 | wx.pageScrollTo({ 169 | scrollTop: 0, 170 | duration: 1000 171 | }) 172 | } 173 | this.setData({ 174 | first_tap: first 175 | }) 176 | 177 | } 178 | }) -------------------------------------------------------------------------------- /pages/index/list.json: -------------------------------------------------------------------------------- 1 | { 2 | "usingComponents": {}, 3 | "enablePullDownRefresh": true 4 | } -------------------------------------------------------------------------------- /pages/index/list.wxml: -------------------------------------------------------------------------------- 1 | 主页 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | {{new_.tittle}} 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | {{item.tittle}} 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | {{item.link_.username}} 32 | 33 | {{item.time}} 34 | 35 | {{item.view_count}} 36 | {{item.like_count}} 37 | {{item.comment}} 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /pages/index/list.wxss: -------------------------------------------------------------------------------- 1 | /* pages/index/list.wxss */ 2 | 3 | .page{ 4 | background-image:url(https://image.weilanwl.com/gif/loading-white.gif); 5 | background-size:contain; 6 | background-repeat:no-repeat; 7 | background-position: 50% 50%; 8 | 9 | } 10 | .loading{ 11 | background-image:url(https://image.weilanwl.com/gif/loading-white.gif); 12 | background-size:contain; 13 | background-repeat:no-repeat; 14 | background-position: 50% 50%; 15 | height: 50vh; 16 | } 17 | 18 | .bg-black{ 19 | background: rgba(17, 17, 17, 0.3); 20 | border-radius: 10rpx; 21 | } 22 | 23 | -------------------------------------------------------------------------------- /pages/index/more.js: -------------------------------------------------------------------------------- 1 | var WxParse = require('../../wxParse/wxParse.js'); 2 | var router = require('../index/router.js'); 3 | var time_ = require('../../utils/util.js'); 4 | var md_ = require('../../utils/md5.js'); 5 | var timeago = require('../../utils/timeago.js') 6 | const app = getApp() 7 | Page({ 8 | 9 | data: { 10 | post: '', 11 | StatusBar: app.globalData.StatusBar, 12 | CustomBar: app.globalData.CustomBar, 13 | liked: false, 14 | like_count: '', 15 | comment_count: '', 16 | view_count: '', 17 | comments: '', 18 | isZan: '', 19 | collection: false, 20 | iscollec: false, 21 | imgUrl: '' 22 | 23 | }, 24 | 25 | onLoad: function(options) { 26 | let num = options.id, 27 | info = { 28 | num: num 29 | } 30 | // console.log(num) 31 | router.route_request('mp/refresh', info).catch(res => { 32 | 33 | let posts = res; 34 | // console.log(posts) 35 | posts['time'] = time_.formatTime(new Date(posts['time'].replace('GMT', ''))) 36 | this.get_data(posts) 37 | let collec = wx.getStorageSync('collection'); 38 | if (collec) { 39 | for (let i = 0; i < collec.length; i++) { 40 | if (collec[i].id == posts.id) { 41 | this.setData({ 42 | iscollec: true 43 | }) 44 | } 45 | } 46 | } 47 | let parse = this.data.post.body_html; 48 | WxParse.wxParse('wxshow', 'html', parse, this, 20); 49 | if(posts['img']){ 50 | var bgImg = "https://blogai.cn/static/" + posts['img'] 51 | }else{ 52 | var bgImg = 'https://blogai.cn/static/uploads/82f6bfa51778a0c55d42a334321cabf1/20190906180648_94.png' 53 | } 54 | if (posts['post.link_.avatar']) { 55 | var avaImg = "https://blogai.cn/static/" + posts['img'] 56 | } else { 57 | var avaImg = 'https://blogai.cn/static/uploads/82f6bfa51778a0c55d42a334321cabf1/20190906180648_94.png' 58 | } 59 | 60 | // 61 | wx.getImageInfo({ 62 | src: bgImg, 63 | success: res_ => { 64 | this.setData({ 65 | imgeInfo: res_ 66 | }) 67 | } 68 | }) 69 | 70 | wx.getImageInfo({ 71 | src: avaImg, 72 | success: res_ => { 73 | this.setData({ 74 | avatarInfo: res_ 75 | }) 76 | } 77 | }) 78 | }) 79 | 80 | const sysInfo = wx.getSystemInfoSync(); 81 | const screenWidth = sysInfo.screenWidth; 82 | const screenHeight = sysInfo.screenHeight; 83 | this.setData({ 84 | cWidth: screenWidth - 20, 85 | cHeight: screenHeight - 200 86 | }) 87 | 88 | 89 | 90 | 91 | }, 92 | like(e) { 93 | // like_.like() 94 | wx.vibrateShort({ 95 | 96 | }) 97 | let stroage = wx.getStorageSync('final_data'); 98 | if (stroage) { 99 | let like_count = this.data.like_count, 100 | liked = this.data.liked, 101 | num = this.data.post.id, 102 | info = { 103 | openId: stroage.openId, 104 | num: num 105 | }; 106 | router.route_request('mp/like', info).catch(res => { 107 | // console.log({ 108 | // 'res': res 109 | // }) 110 | }) 111 | if (!liked) { 112 | liked = true, 113 | like_count++; 114 | wx.showToast({ 115 | title: '点赞成功', 116 | icon: 'success', 117 | duration: 2000 118 | }) 119 | } else { 120 | liked = false, 121 | like_count--; 122 | wx.showToast({ 123 | title: '取消成功', 124 | icon: 'success', 125 | duration: 2000 126 | }) 127 | } 128 | this.setData({ 129 | liked: liked, 130 | like_count: like_count 131 | }) 132 | 133 | } else { 134 | wx.navigateTo({ 135 | url: '../login/login', 136 | }) 137 | } 138 | 139 | 140 | }, 141 | comment(e) { 142 | wx.vibrateShort({ 143 | 144 | }) 145 | if (e.detail.value.comment) { 146 | let stroage = wx.getStorageSync('final_data') 147 | // console.log(stroage) 148 | if (stroage) { 149 | let num = this.data.post['id'], 150 | wx_comment = e.detail.value.comment, 151 | info = { 152 | openId: stroage.openId, 153 | wx_comment: wx_comment, 154 | num: num 155 | }; 156 | var wx_uid = md_.md5(stroage['openId']); 157 | router.route_request('mp/comment', info).catch(res => { 158 | var comments = res.new_comment.comments 159 | for (var j = 0; j < comments.length; j++) { 160 | comments[j]['time'] = timeago.transDate(comments[j]['time'].replace('GMT', '')) 161 | for (var k = 0; k < comments[j].liker.length; k++) { 162 | if (comments[j].liker[k].user_id == wx_uid) { 163 | comments[j].liked = 'isLike' 164 | } 165 | } 166 | } 167 | this.setData({ 168 | comments: comments, 169 | comment_count: this.data.comment_count + 1 170 | }) 171 | }) 172 | wx.showToast({ 173 | title: '评论成功', 174 | duration: 1500 175 | }) 176 | setTimeout(() => { 177 | this.tobottom() 178 | }, 1500) 179 | 180 | 181 | 182 | } else { 183 | wx.navigateTo({ 184 | url: '../login/login', 185 | }) 186 | } 187 | } else { 188 | wx.showToast({ 189 | title: '输入不能为空', 190 | icon: 'none' 191 | }) 192 | } 193 | }, 194 | get_data(posts) { 195 | let view_count = posts['view_count'], 196 | comments = posts.new_comment.comments, 197 | like = posts.likes, 198 | stroage = wx.getStorageSync('final_data'); 199 | 200 | if (stroage) { 201 | var wx_uid = md_.md5(stroage['openId']); 202 | 203 | for (var i = 0; i < like.length; i++) { 204 | like[i]['time'] = timeago.transDate(like[i]['time'].replace('GMT', '')) 205 | if (like[i].user_id == wx_uid) { 206 | var liked = true 207 | } 208 | } 209 | 210 | for (var j = 0; j < comments.length; j++) { 211 | comments[j]['time'] = timeago.transDate(comments[j]['time'].replace('GMT', '')) 212 | for (var k = 0; k < comments[j].liker.length; k++) { 213 | 214 | if (comments[j].liker[k].user_id == wx_uid) { 215 | comments[j].liked = 'isLike' 216 | } 217 | } 218 | } 219 | } else { 220 | var liked = false 221 | } 222 | 223 | view_count++; 224 | this.setData({ 225 | post: posts, 226 | like_count: posts['like_count'], 227 | comment_count: posts['comment'], 228 | view_count: view_count, 229 | comments: comments, 230 | liked: liked 231 | }) 232 | 233 | }, 234 | onPullDownRefresh() { 235 | wx.vibrateShort({}) 236 | wx.showNavigationBarLoading() 237 | wx.showLoading({ 238 | title: '更新中...', 239 | icon: 'loading', 240 | duration: 1500 241 | }) 242 | let info = { 243 | num: this.data.post.id 244 | } 245 | router.route_request('mp/refresh', info).catch(res => { 246 | let posts = res; 247 | posts['time'] = time_.formatTime(new Date(posts['time'].replace('GMT', ''))) 248 | this.get_data(posts) 249 | }) 250 | wx.stopPullDownRefresh(); 251 | }, 252 | zan: function(e) { 253 | wx.vibrateShort({}) 254 | let stroage = wx.getStorageSync('final_data'), 255 | num = e.currentTarget.dataset.id; 256 | var index = e.currentTarget.dataset.index; 257 | if (stroage) { 258 | let info = { 259 | openId: stroage.openId, 260 | num: num 261 | }; 262 | // console.log('num' + num) 263 | router.route_request('mp/like_comment', info).catch(res => { 264 | res.time = timeago.transDate(res['time'].replace('GMT', '')) 265 | let comments = this.data.comments; 266 | let liker = comments[index]; 267 | let status = liker.liked ? '' : 'isLike' 268 | res.liked = status 269 | comments[index] = res 270 | this.setData({ 271 | comments: comments 272 | }) 273 | 274 | }) 275 | 276 | 277 | } else { 278 | wx.navigateTo({ 279 | url: '../login/login', 280 | }) 281 | } 282 | 283 | 284 | 285 | }, 286 | tobottom() { 287 | wx.createSelectorQuery().select('#b_comment').boundingClientRect(function(rect) { 288 | // 使页面滚动到底部 289 | wx.pageScrollTo({ 290 | scrollTop: rect.bottom 291 | }) 292 | }).exec() 293 | }, 294 | reply(e) { 295 | let comment_id = e.currentTarget.dataset.id, 296 | index = e.currentTarget.dataset.index; 297 | wx.setStorageSync('comment', this.data.comments[index]) 298 | wx.navigateTo({ 299 | url: 'reply?id=' + comment_id, 300 | }) 301 | 302 | }, 303 | poster() { 304 | 305 | }, 306 | 307 | share() { 308 | 309 | wx.showLoading({ 310 | title: '生成中....', 311 | }) 312 | let that = this 313 | const ctx = wx.createCanvasContext('poster', this) 314 | const fs = wx.getFileSystemManager(); 315 | const filePath = `${wx.env.USER_DATA_PATH}/interim`; 316 | router.route_request('mp/get_code').catch(res => { 317 | console.log(res.access_token) 318 | wx.request({ 319 | method: 'POST', 320 | url: `https://api.weixin.qq.com/wxa/getwxacode?access_token=${res.access_token}`, 321 | data: { 322 | path: '/pages/index/more?id=' + this.data.post.id 323 | }, 324 | responseType: 'arraybuffer', 325 | success: res_ => { 326 | console.log(res_) 327 | // let imgUrl = wx.arrayBufferToBase64(res_.data) 328 | // console.log(imgUrl) 329 | // this.setData({ 330 | // imgUrl: imgUrl 331 | // }) 332 | fs.writeFile({ 333 | filePath: filePath, 334 | data: res_.data, 335 | encoding: 'utf-8', 336 | success() { 337 | console.log('d', filePath) 338 | wx.getImageInfo({ 339 | src: filePath, 340 | success: img => { 341 | 342 | that.setData({ 343 | imgUrl: img.path 344 | }) 345 | 346 | let img_w = that.data.imgeInfo.width, 347 | img_h = that.data.imgeInfo.height, 348 | scale = img_w / img_h; 349 | if (scale > 1) { 350 | var width = that.data.cWidth, 351 | height = width / scale 352 | } else { 353 | var height = that.data.cHeight, 354 | width = scale * height 355 | } 356 | ctx.beginPath() 357 | ctx.setFillStyle('#5e00ff') 358 | ctx.rect(0, 0, that.data.cWidth, that.data.cHeight) 359 | ctx.fill() 360 | 361 | ctx.drawImage(that.data.imgeInfo.path, 0, 0, width, height) 362 | 363 | ctx.draw() 364 | that.setData({ 365 | show: true 366 | }) 367 | 368 | } 369 | }) 370 | 371 | }, 372 | fail() { 373 | return (new Error('ERROR_WRITE')); 374 | }, 375 | }); 376 | } 377 | }) 378 | }) 379 | 380 | console.log('dd') 381 | 382 | 383 | 384 | }, 385 | onShareAppMessage: function(res) { 386 | if (res.from == 'button') { 387 | // 来自页面内转发按钮 388 | // console.log(res.target) 389 | } 390 | return { 391 | title: this.data.post.tittle, 392 | path: '/pages/index/more?id=' + this.data.post.id, 393 | success: res => { 394 | // console.log('成功') 395 | }, 396 | fail: err => { 397 | // console.log('失败') 398 | } 399 | } 400 | 401 | }, 402 | collection(e) { 403 | wx.vibrateShort({ 404 | 405 | }) 406 | let colloced = this.data.iscollec; 407 | let post = [this.data.post], 408 | collec = wx.getStorageSync('collection'); 409 | if (!colloced) { 410 | 411 | if (collec) { 412 | var collec_post = collec.concat(post) 413 | wx.setStorageSync('collection', collec_post) 414 | } else { 415 | var collec_post = post; 416 | wx.setStorageSync('collection', collec_post) 417 | } 418 | this.setData({ 419 | iscollec: true 420 | }) 421 | } else { 422 | 423 | for (let i = 0; i < collec.length; i++) { 424 | let num = this.data.post.id 425 | if (collec[i].id == num) { 426 | collec.splice(i, 1) 427 | 428 | } 429 | wx.setStorageSync('collection', collec) 430 | 431 | } 432 | // console.log(collec) 433 | this.setData({ 434 | iscollec: false 435 | }) 436 | } 437 | 438 | } 439 | }) -------------------------------------------------------------------------------- /pages/index/more.json: -------------------------------------------------------------------------------- 1 | { 2 | "usingComponents": {}, 3 | "enablePullDownRefresh": true 4 | } -------------------------------------------------------------------------------- /pages/index/more.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 返回 6 | {{post.tittle}} 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | {{post.tittle}} 15 | 16 | {{post.link_.username}} 17 | {{post.time}} 18 | {{view_count}} 19 | {{like_count}} 20 | {{post.comment}} 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 |