├── .gitignore ├── README.md ├── app.js ├── app.json ├── app.wxss ├── config.js ├── pages ├── add-comment │ ├── add-comment.js │ ├── add-comment.json │ ├── add-comment.wxml │ └── add-comment.wxss ├── blog-info │ ├── blog-info.js │ ├── blog-info.json │ ├── blog-info.wxml │ └── blog-info.wxss ├── blog │ ├── blog.js │ ├── blog.json │ ├── blog.wxml │ └── blog.wxss ├── resume │ ├── resume.js │ ├── resume.json │ ├── resume.wxml │ └── resume.wxss ├── search │ ├── search.js │ ├── search.json │ ├── search.wxml │ └── search.wxss ├── sorts-log │ ├── blog.js │ ├── blog.json │ ├── blog.wxml │ └── blog.wxss └── sorts │ ├── sorts.js │ ├── sorts.json │ ├── sorts.wxml │ └── sorts.wxss ├── project.config.json ├── project.private.config.json ├── sitemap.json ├── static ├── images │ ├── about-active.png │ ├── about.png │ ├── add.png │ ├── banner.jpg │ ├── blog-active.png │ ├── blog.png │ ├── empty.svg │ ├── logo.png │ ├── search-active.png │ ├── search.png │ ├── sort-active.png │ └── sort.png └── weui.wxss ├── template.wxml └── utils ├── api.js └── util.js /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # emlog小程序版客户端 2 | 3 | 请先安装微信小程序辅助插件,然后配置config.js 4 | 插件地址: `https://github.com/jaeheng/emlog-api` -------------------------------------------------------------------------------- /app.js: -------------------------------------------------------------------------------- 1 | //app.js 2 | import util from './utils/util.js' 3 | App({ 4 | onLaunch: function(e) { 5 | console.log('onLaunch', e); 6 | }, 7 | 8 | getSetting: function(cb) { 9 | let setting = this.globalData.setting; 10 | if (setting) { 11 | typeof cb === 'function' ? cb(setting) : setting; 12 | return true; 13 | } 14 | util.getSettings(success => { 15 | this.globalData.setting = success; 16 | typeof cb === 'function' ? cb(success) : setting; 17 | }); 18 | }, 19 | 20 | globalData: { 21 | setting: null 22 | } 23 | }) 24 | -------------------------------------------------------------------------------- /app.json: -------------------------------------------------------------------------------- 1 | { 2 | "pages": [ 3 | "pages/blog/blog", 4 | "pages/blog-info/blog-info", 5 | "pages/resume/resume", 6 | "pages/sorts/sorts", 7 | "pages/add-comment/add-comment", 8 | "pages/sorts-log/blog", 9 | "pages/search/search" 10 | ], 11 | "window": { 12 | "backgroundTextStyle": "dark", 13 | "navigationBarBackgroundColor": "#fff", 14 | "navigationBarTitleText": "博客首页", 15 | "navigationBarTextStyle": "black" 16 | }, 17 | "tabBar": { 18 | "color": "#333", 19 | "backgroundColor": "#fff", 20 | "selectedColor": "#1296db", 21 | "list": [ 22 | { 23 | "pagePath": "pages/blog/blog", 24 | "text": "博客", 25 | "iconPath": "static/images/blog.png", 26 | "selectedIconPath": "static/images/blog-active.png" 27 | }, 28 | { 29 | "pagePath": "pages/sorts/sorts", 30 | "text": "板块", 31 | "iconPath": "static/images/sort.png", 32 | "selectedIconPath": "static/images/sort-active.png" 33 | }, 34 | { 35 | "pagePath": "pages/search/search", 36 | "text": "搜索", 37 | "iconPath": "static/images/search.png", 38 | "selectedIconPath": "static/images/search-active.png" 39 | }, 40 | { 41 | "pagePath": "pages/resume/resume", 42 | "text": "关于", 43 | "iconPath": "static/images/about.png", 44 | "selectedIconPath": "static/images/about-active.png" 45 | } 46 | ] 47 | }, 48 | "networkTimeout": { 49 | "request": 10000, 50 | "downloadFile": 100000 51 | }, 52 | "debug": true, 53 | "sitemapLocation": "sitemap.json", 54 | "useExtendedLib": { 55 | "weui": true 56 | } 57 | } -------------------------------------------------------------------------------- /app.wxss: -------------------------------------------------------------------------------- 1 | /**app.wxss**/ 2 | .container { 3 | height: 100%; 4 | display: flex; 5 | flex-direction: column; 6 | justify-content: space-between; 7 | box-sizing: border-box; 8 | } 9 | .blog-view { 10 | background-color: #fff; 11 | } 12 | a { 13 | color: #378CC2; 14 | } 15 | 16 | button.red-btn { 17 | background-color: #378CC2; 18 | color: #fff; 19 | } 20 | 21 | button.red-btn:active, 22 | button.red-btn.button-hover { 23 | background-color: #137dc0; 24 | color: #fff; 25 | } 26 | 27 | button[disabled].red-btn, 28 | button[disabled].red-btn:active { 29 | background-color: #eee; 30 | color: #aaa; 31 | } 32 | /*列表*/ 33 | .zh-list { 34 | border-top: 1px solid #f3f3f3; 35 | } 36 | .zh-list-item { 37 | height: 24px; 38 | line-height: 24px; 39 | font-size: 14px; 40 | padding: 10px; 41 | border-bottom: 1rpx solid #f3f3f3; 42 | } 43 | .zh-list-item .icon { 44 | height: 16px; 45 | width: 16px; 46 | margin-right: 10px; 47 | float: left; 48 | margin-top: 3px; 49 | } 50 | .zh-list-item .icon-right { 51 | float: right; 52 | margin-top: 6px; 53 | } 54 | 55 | .zh-list-item.list-item-link:active { 56 | background-color: #f3f3f3; 57 | } 58 | 59 | /*icon*/ 60 | .icon-right { 61 | width: 12px; 62 | height: 12px; 63 | border-top: 1px solid #ccc; 64 | border-right: 1px solid #ccc; 65 | transform: rotate(45deg); 66 | } 67 | 68 | .page-title { 69 | padding: 20rpx 30rpx; 70 | font-size: 16px; 71 | line-height: 1.5; 72 | border-bottom: 1rpx solid #fafafa; 73 | } 74 | 75 | .article-item { 76 | padding: 30rpx 0rpx; 77 | margin: 0 30rpx; 78 | border-bottom: 1rpx solid #d3d3d3; 79 | } 80 | .article-item .info { 81 | overflow: hidden; 82 | } 83 | .article-item .username, 84 | .article-item .sort, 85 | .article-item .view, 86 | .article-item .time { 87 | font-size: 12px; 88 | line-height: 20px; 89 | margin-top: 5px; 90 | display: block; 91 | color: #aaa; 92 | } 93 | .article-item .view, 94 | .article-item .username, 95 | .article-item .sort { 96 | float: left; 97 | margin-right: 10px; 98 | } 99 | .article-item .time { 100 | float: right; 101 | } 102 | .article-item.with-pic { 103 | padding-right: 200rpx; 104 | position: relative; 105 | padding-bottom: 1.5em; 106 | min-height: 150rpx; 107 | } 108 | .article-item.with-pic .title { 109 | min-height: 3.5em; 110 | } 111 | .article-item.with-pic .info { 112 | position:absolute; 113 | width:100%; 114 | box-sizing:border-box; 115 | bottom:20rpx; 116 | } 117 | .article-item.with-pic .desc-img { 118 | position: absolute; 119 | right: 0; 120 | top: 20rpx; 121 | width: 180rpx; 122 | height: 145rpx; 123 | overflow: hidden; 124 | } 125 | .article-item .desc, 126 | .article-item .desc-with-pics { 127 | font-size: 14px; 128 | line-height: 1.5; 129 | color: #787878; 130 | } 131 | .article-item .desc-with-pics .desc-pics { 132 | display: flex; 133 | } 134 | .article-item .desc-with-pics .desc-img { 135 | flex: 1; 136 | padding: 20rpx 10rpx; 137 | height: 200rpx; 138 | } 139 | 140 | .article-item .title { 141 | display: block; 142 | font-size: 32rpx; 143 | margin-bottom: 10px; 144 | color:#202020; 145 | line-height: 1.5; 146 | } 147 | .article-item.article-info { 148 | background-color: transparent; 149 | } 150 | .article-item .article-item { 151 | border-left: 1px solid #666; 152 | background-color: #eee; 153 | margin: 10px 0; 154 | } 155 | .read-more { 156 | text-align: center; 157 | padding: 30rpx 0; 158 | font-size: 14px; 159 | color: #aaa; 160 | } 161 | .error { 162 | background-color:#ff0; 163 | text-align:center; 164 | padding:10px 0; 165 | color:#a00; 166 | font-size:14px; 167 | } 168 | 169 | .article-comment-item { 170 | border-bottom-color: #eee; 171 | } 172 | 173 | .article-comment-item .desc { 174 | color: #2b2b2b; 175 | } 176 | 177 | .article-comment-children { 178 | padding-left: 30rpx; 179 | } 180 | .article-comment-children .desc { 181 | margin: 0; 182 | font-size: 24rpx; 183 | } 184 | .add-comment { 185 | position: fixed; 186 | bottom: 15px; 187 | right: 15px; 188 | width: 110rpx; 189 | height: 110rpx; 190 | z-index: 999; 191 | } 192 | .add-comment:active { 193 | opacity: 0.8; 194 | } 195 | 196 | .banner { 197 | width: 100%; 198 | height: 260rpx; 199 | } -------------------------------------------------------------------------------- /config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | /** 3 | * 接口域名地址 4 | * (必须安装emlog-api插件: https://github.com/jaeheng/emlog-api) 5 | * (请求接口时会自动加上插件地址: /content/plugins/wxa/api.php?route=) 6 | */ 7 | domain: 'https://blog.phpat.com', 8 | /** 9 | * 加密字符串,配置不正确会导致发布文章提示“无权访问” 10 | */ 11 | code: '883c7b721f6c6b646596acdba7edc87b' 12 | } 13 | -------------------------------------------------------------------------------- /pages/add-comment/add-comment.js: -------------------------------------------------------------------------------- 1 | // add-comment.js 2 | import util from '../../utils/util.js' 3 | var app = getApp() 4 | 5 | Page({ 6 | 7 | /** 8 | * 页面的初始数据 9 | */ 10 | data: { 11 | gid: 0, 12 | comment: '', 13 | disabled: true, 14 | userInfo: {} 15 | }, 16 | 17 | /** 18 | * 生命周期函数--监听页面加载 19 | */ 20 | onLoad: function (options) { 21 | this.setData({ 22 | gid: options.gid 23 | }) 24 | }, 25 | 26 | onShow: function () { 27 | var that = this 28 | wx.getUserInfo({ 29 | success: function (res) { 30 | that.setData({ 31 | userInfo: res.userInfo 32 | }) 33 | } 34 | }) 35 | }, 36 | 37 | getUserinfoHandle: function (res) { 38 | console.log('res:', res) 39 | var that = this 40 | if (res.detail.errMsg === 'getUserInfo:ok') { 41 | var userInfo = res.detail.userInfo 42 | that.setData({ 43 | userInfo: userInfo 44 | }) 45 | wx.showToast({ 46 | title: '授权成功', 47 | icon: 'success' 48 | }) 49 | } else { 50 | wx.showModal({ 51 | title: '授权失败', 52 | content: '请自行在小程序设置界面授权', 53 | success: function ({ confirm, cancel }) { 54 | wx.openSetting() 55 | } 56 | }) 57 | } 58 | }, 59 | 60 | changeHandle: function (e) { 61 | console.log('input comment') 62 | var gid = this.data.gid 63 | var comment = e.detail.value 64 | console.log('gid: ' + gid) 65 | console.log('comment: ' + comment) 66 | 67 | this.setData({ 68 | comment: comment, 69 | disabled: gid === 0 || comment.length < 1 70 | }) 71 | }, 72 | 73 | addComment: function () { 74 | var gid = this.data.gid 75 | var comment = this.data.comment 76 | var poster = this.data.userInfo.nickName 77 | 78 | if (gid === 0 || comment.length < 1) { 79 | return false 80 | } else { 81 | util.addComment({ gid, comment, poster }, function (res) { 82 | wx.showToast({ 83 | title: '评论成功,可能需要管理员审核才能显示', 84 | icon: 'none', 85 | success: function () { 86 | setTimeout(() => { 87 | wx.navigateBack() 88 | }, 300); 89 | } 90 | }) 91 | }, function (msg) { 92 | wx.showToast({ 93 | title: msg, 94 | icon: 'none' 95 | }) 96 | }) 97 | } 98 | } 99 | }) -------------------------------------------------------------------------------- /pages/add-comment/add-comment.json: -------------------------------------------------------------------------------- 1 | { 2 | "navigationBarTitleText": "评论" 3 | } -------------------------------------------------------------------------------- /pages/add-comment/add-comment.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 |