├── .gitattributes ├── LICENSE ├── qTravel ├── app.js ├── app.json ├── app.qss ├── images │ ├── cate.png │ ├── detail │ │ ├── bottom_bar_back.png │ │ ├── bottom_bar_comment.png │ │ ├── bottom_bar_share.png │ │ ├── collect.png │ │ ├── collected.png │ │ ├── collects.png │ │ ├── messageListNodata.png │ │ ├── quan_like.png │ │ ├── quan_liked.png │ │ ├── share_icon1.svg │ │ ├── share_icon2.svg │ │ ├── voice.gif │ │ └── voice.png │ ├── ic_huoban.png │ ├── ic_huoban_on.png │ ├── ic_index.png │ ├── ic_index_on.png │ ├── ic_user.png │ ├── ic_user_on.png │ ├── lanmu@2x.png │ └── messageListNodata.png ├── pages │ ├── category │ │ ├── category.js │ │ ├── category.json │ │ ├── category.qml │ │ └── category.qss │ ├── detail │ │ ├── detail.js │ │ ├── detail.json │ │ ├── detail.qml │ │ └── detail.qss │ ├── index │ │ ├── index.js │ │ ├── index.json │ │ ├── index.qml │ │ └── index.qss │ ├── list │ │ ├── list.js │ │ ├── list.json │ │ ├── list.qml │ │ └── list.qss │ ├── logs │ │ ├── logs.js │ │ ├── logs.json │ │ ├── logs.qml │ │ └── logs.qss │ └── mine │ │ ├── mine.js │ │ ├── mine.json │ │ ├── mine.qml │ │ ├── mine.qss │ │ ├── mypost.js │ │ ├── mypost.json │ │ ├── mypost.qml │ │ └── mypost.qss ├── project.config.json ├── sitemap.json ├── utils │ ├── api.js │ ├── auth.js │ ├── base.js │ └── util.js └── wxParse │ ├── html2json.js │ ├── htmlparser.js │ ├── icon.wxss │ ├── showdown.js │ ├── wxDiscode.js │ ├── wxParse.js │ ├── wxParse.wxml │ └── wxParse.wxss ├── readme.md ├── screenshot ├── 20190722154321.jpg ├── 20190722154328.jpg ├── 20190722154336.jpg ├── 20190722154348.jpg ├── 20190722154355.jpg ├── 20190722154402.jpg └── 20190723104521.jpg └── weTravel ├── app.js ├── app.json ├── app.wxss ├── images ├── cate.png ├── detail │ ├── bottom_bar_back.png │ ├── bottom_bar_comment.png │ ├── bottom_bar_share.png │ ├── collect.png │ ├── collected.png │ ├── collects.png │ ├── messageListNodata.png │ ├── quan_like.png │ ├── quan_liked.png │ ├── share_icon1.svg │ ├── share_icon2.svg │ ├── voice.gif │ └── voice.png ├── ic_huoban.png ├── ic_huoban_on.png ├── ic_index.png ├── ic_index_on.png ├── ic_user.png ├── ic_user_on.png ├── lanmu@2x.png └── messageListNodata.png ├── pages ├── category │ ├── category.js │ ├── category.json │ ├── category.wxml │ └── category.wxss ├── detail │ ├── detail.js │ ├── detail.json │ ├── detail.wxml │ └── detail.wxss ├── index │ ├── index.js │ ├── index.json │ ├── index.wxml │ └── index.wxss ├── list │ ├── list.js │ ├── list.json │ ├── list.wxml │ └── list.wxss ├── logs │ ├── logs.js │ ├── logs.json │ ├── logs.wxml │ └── logs.wxss └── mine │ ├── mine.js │ ├── mine.json │ ├── mine.wxml │ ├── mine.wxss │ ├── mypost.js │ ├── mypost.json │ ├── mypost.wxml │ └── mypost.wxss ├── project.config.json ├── sitemap.json ├── utils ├── api.js ├── auth.js ├── base.js └── util.js └── wxParse ├── html2json.js ├── htmlparser.js ├── icon.wxss ├── showdown.js ├── wxDiscode.js ├── wxParse.js ├── wxParse.wxml └── wxParse.wxss /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /qTravel/app.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Author : 丸子团队(波波、Chi、ONLINE.信) 3 | * Github 地址: https://github.com/dchijack/Travel-Mini-Program 4 | * GiTee 地址: https://gitee.com/izol/Travel-Mini-Program 5 | */ 6 | //app.js 7 | const API = require('/utils/base') 8 | 9 | App({ 10 | 11 | onLaunch: function () { 12 | API.login(); 13 | // 获取系统状态栏信息 14 | wx.getSystemInfo({ 15 | success: e => { 16 | this.globalData.StatusBar = e.statusBarHeight; 17 | this.globalData.CustomBar = e.platform == 'android' ? e.statusBarHeight + 50 : e.statusBarHeight + 45; 18 | } 19 | }) 20 | }, 21 | 22 | onShow: function () { 23 | this.globalData.user = API.getUser(); 24 | this.globalData.skin = wx.getStorageSync('skin') ? wx.getStorageSync('skin') : 'bg-gray'; 25 | this.globalData.color = wx.getStorageSync('color') ? wx.getStorageSync('color') : 'gray'; 26 | }, 27 | 28 | globalData: { 29 | user: '', 30 | skin: '', 31 | color: '', 32 | StatusBar: '', 33 | CustomBar: '' 34 | } 35 | 36 | }) -------------------------------------------------------------------------------- /qTravel/app.json: -------------------------------------------------------------------------------- 1 | { 2 | "pages": [ 3 | "pages/index/index", 4 | "pages/detail/detail", 5 | "pages/list/list", 6 | "pages/logs/logs", 7 | "pages/category/category", 8 | "pages/mine/mine", 9 | "pages/mine/mypost" 10 | ], 11 | "window": { 12 | "backgroundTextStyle": "light", 13 | "navigationBarBackgroundColor": "#fff", 14 | "navigationBarTitleText": "丸子社区", 15 | "navigationBarTextStyle": "black" 16 | }, 17 | "tabBar": { 18 | "color": "#AAAAAA", 19 | "selectedColor": "#262626", 20 | "borderStyle": "black", 21 | "backgroundColor": "#fff", 22 | "list": [ 23 | { 24 | "text": "首页", 25 | "pagePath": "pages/index/index", 26 | "iconPath": "images/ic_index.png", 27 | "selectedIconPath": "images/ic_index_on.png" 28 | }, 29 | { 30 | "text": "栏目", 31 | "pagePath": "pages/category/category", 32 | "iconPath": "images/ic_huoban.png", 33 | "selectedIconPath": "images/ic_huoban_on.png" 34 | }, 35 | { 36 | "text": "我的", 37 | "pagePath": "pages/mine/mine", 38 | "iconPath": "images/ic_user.png", 39 | "selectedIconPath": "images/ic_user_on.png" 40 | } 41 | ] 42 | }, 43 | "sitemapLocation": "sitemap.json" 44 | } -------------------------------------------------------------------------------- /qTravel/app.qss: -------------------------------------------------------------------------------- 1 | button::after { 2 | border-radius: 0; 3 | border: none; 4 | } -------------------------------------------------------------------------------- /qTravel/images/cate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/webzol/Travel-Mini-Program/792602f4047fc9b9f811e287e1d1859089506fb3/qTravel/images/cate.png -------------------------------------------------------------------------------- /qTravel/images/detail/bottom_bar_back.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/webzol/Travel-Mini-Program/792602f4047fc9b9f811e287e1d1859089506fb3/qTravel/images/detail/bottom_bar_back.png -------------------------------------------------------------------------------- /qTravel/images/detail/bottom_bar_comment.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/webzol/Travel-Mini-Program/792602f4047fc9b9f811e287e1d1859089506fb3/qTravel/images/detail/bottom_bar_comment.png -------------------------------------------------------------------------------- /qTravel/images/detail/bottom_bar_share.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/webzol/Travel-Mini-Program/792602f4047fc9b9f811e287e1d1859089506fb3/qTravel/images/detail/bottom_bar_share.png -------------------------------------------------------------------------------- /qTravel/images/detail/collect.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/webzol/Travel-Mini-Program/792602f4047fc9b9f811e287e1d1859089506fb3/qTravel/images/detail/collect.png -------------------------------------------------------------------------------- /qTravel/images/detail/collected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/webzol/Travel-Mini-Program/792602f4047fc9b9f811e287e1d1859089506fb3/qTravel/images/detail/collected.png -------------------------------------------------------------------------------- /qTravel/images/detail/collects.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/webzol/Travel-Mini-Program/792602f4047fc9b9f811e287e1d1859089506fb3/qTravel/images/detail/collects.png -------------------------------------------------------------------------------- /qTravel/images/detail/messageListNodata.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/webzol/Travel-Mini-Program/792602f4047fc9b9f811e287e1d1859089506fb3/qTravel/images/detail/messageListNodata.png -------------------------------------------------------------------------------- /qTravel/images/detail/quan_like.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/webzol/Travel-Mini-Program/792602f4047fc9b9f811e287e1d1859089506fb3/qTravel/images/detail/quan_like.png -------------------------------------------------------------------------------- /qTravel/images/detail/quan_liked.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/webzol/Travel-Mini-Program/792602f4047fc9b9f811e287e1d1859089506fb3/qTravel/images/detail/quan_liked.png -------------------------------------------------------------------------------- /qTravel/images/detail/share_icon1.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 分享海报-下载 5 | Created with Sketch. 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /qTravel/images/detail/share_icon2.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 分享海报-给朋友 5 | Created with Sketch. 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /qTravel/images/detail/voice.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/webzol/Travel-Mini-Program/792602f4047fc9b9f811e287e1d1859089506fb3/qTravel/images/detail/voice.gif -------------------------------------------------------------------------------- /qTravel/images/detail/voice.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/webzol/Travel-Mini-Program/792602f4047fc9b9f811e287e1d1859089506fb3/qTravel/images/detail/voice.png -------------------------------------------------------------------------------- /qTravel/images/ic_huoban.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/webzol/Travel-Mini-Program/792602f4047fc9b9f811e287e1d1859089506fb3/qTravel/images/ic_huoban.png -------------------------------------------------------------------------------- /qTravel/images/ic_huoban_on.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/webzol/Travel-Mini-Program/792602f4047fc9b9f811e287e1d1859089506fb3/qTravel/images/ic_huoban_on.png -------------------------------------------------------------------------------- /qTravel/images/ic_index.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/webzol/Travel-Mini-Program/792602f4047fc9b9f811e287e1d1859089506fb3/qTravel/images/ic_index.png -------------------------------------------------------------------------------- /qTravel/images/ic_index_on.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/webzol/Travel-Mini-Program/792602f4047fc9b9f811e287e1d1859089506fb3/qTravel/images/ic_index_on.png -------------------------------------------------------------------------------- /qTravel/images/ic_user.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/webzol/Travel-Mini-Program/792602f4047fc9b9f811e287e1d1859089506fb3/qTravel/images/ic_user.png -------------------------------------------------------------------------------- /qTravel/images/ic_user_on.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/webzol/Travel-Mini-Program/792602f4047fc9b9f811e287e1d1859089506fb3/qTravel/images/ic_user_on.png -------------------------------------------------------------------------------- /qTravel/images/lanmu@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/webzol/Travel-Mini-Program/792602f4047fc9b9f811e287e1d1859089506fb3/qTravel/images/lanmu@2x.png -------------------------------------------------------------------------------- /qTravel/images/messageListNodata.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/webzol/Travel-Mini-Program/792602f4047fc9b9f811e287e1d1859089506fb3/qTravel/images/messageListNodata.png -------------------------------------------------------------------------------- /qTravel/pages/category/category.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Author : 丸子团队(波波、Chi、ONLINE.信) 3 | * Github 地址: https://github.com/dchijack/Travel-Mini-Program 4 | * GiTee 地址: https://gitee.com/izol/Travel-Mini-Program 5 | */ 6 | // pages/category/category.js 7 | const API = require('../../utils/api') 8 | 9 | 10 | Page({ 11 | 12 | /** 13 | * 页面的初始数据 14 | */ 15 | data: { 16 | 17 | }, 18 | 19 | /** 20 | * 生命周期函数--监听页面加载 21 | */ 22 | onLoad: function (options) { 23 | this.getCategories(); 24 | }, 25 | getCategories: function () { 26 | API.getCategories().then(res => { 27 | this.setData({ 28 | category: res 29 | }) 30 | }) 31 | }, 32 | 33 | goClassByid: function (e) { 34 | let id = e.currentTarget.id; 35 | wx.navigateTo({ 36 | url: '/pages/list/list?id=' + id, 37 | }) 38 | }, 39 | /** 40 | * 生命周期函数--监听页面初次渲染完成 41 | */ 42 | onReady: function () { 43 | 44 | }, 45 | 46 | /** 47 | * 生命周期函数--监听页面显示 48 | */ 49 | onShow: function () { 50 | 51 | }, 52 | 53 | /** 54 | * 生命周期函数--监听页面隐藏 55 | */ 56 | onHide: function () { 57 | 58 | }, 59 | 60 | /** 61 | * 生命周期函数--监听页面卸载 62 | */ 63 | onUnload: function () { 64 | 65 | }, 66 | 67 | /** 68 | * 页面相关事件处理函数--监听用户下拉动作 69 | */ 70 | onPullDownRefresh: function () { 71 | 72 | }, 73 | 74 | /** 75 | * 页面上拉触底事件的处理函数 76 | */ 77 | onReachBottom: function () { 78 | 79 | }, 80 | 81 | /** 82 | * 用户点击右上角分享 83 | */ 84 | onShareAppMessage: function () { 85 | 86 | } 87 | }) -------------------------------------------------------------------------------- /qTravel/pages/category/category.json: -------------------------------------------------------------------------------- 1 | { 2 | "enablePullDownRefresh": true, 3 | "navigationBarTitleText": "分类栏目", 4 | "usingComponents": {} 5 | } -------------------------------------------------------------------------------- /qTravel/pages/category/category.qml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | {{item.name}} 10 | 11 | {{item.description}} 12 | 13 | 14 | 15 | 了解更多 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /qTravel/pages/category/category.qss: -------------------------------------------------------------------------------- 1 | .is-flex { 2 | display: flex; 3 | } 4 | 5 | .center-xs { 6 | justify-content: center; 7 | text-align: center; 8 | } 9 | 10 | .end-xs { 11 | justify-content: flex-end; 12 | text-align: end; 13 | } 14 | 15 | .section { 16 | padding: 40rpx; 17 | padding-bottom: 48rpx; 18 | } 19 | 20 | .direction-vert { 21 | flex-direction: column; 22 | } 23 | 24 | .section-features { 25 | padding-bottom: 14px; 26 | } 27 | 28 | .section-features .feature-list { 29 | width: 100%; 30 | max-width: 750rpx; 31 | } 32 | 33 | .section-features .feature-list .feature-card { 34 | padding-bottom: 40rpx; 35 | position: relative; 36 | font-weight: 300; 37 | font-size: 18px; 38 | flex: 1 0 auto; 39 | } 40 | 41 | .middle-xs { 42 | align-items: center; 43 | } 44 | 45 | .section-features .feature-list .feature-card .card-cover { 46 | width: 100%; 47 | padding-top: 380rpx; 48 | max-width: 100%; 49 | background-size: cover; 50 | background-color: #f6f7f7; 51 | } 52 | 53 | .section-features .feature-list .feature-card { 54 | width: 100%; 55 | } 56 | 57 | .section-features .feature-list .feature-card .card-main { 58 | background-color: #f6f7f7; 59 | } 60 | 61 | .section-features .feature-list .feature-card .card-main { 62 | position: relative; 63 | padding: 0; 64 | padding-top: 280rpx; 65 | -webkit-transform: translate3d(0, 0, 0) !important; 66 | transform: translate3d(0, 0, 0) !important; 67 | text-align: left; 68 | } 69 | 70 | .section-features .feature-list .feature-card .card-main .card-top { 71 | padding: 30rpx 29rpx; 72 | position: absolute; 73 | top: 0; 74 | } 75 | 76 | .section-features .feature-list .feature-card .card-title { 77 | font-size: 38rpx; 78 | line-height: 44rpx; 79 | font-weight: 400; 80 | padding-top:20rpx; 81 | margin-bottom: 29.5rpx; 82 | } 83 | 84 | .section-features .feature-list .feature-card .card-content text { 85 | margin: 0; 86 | margin-bottom: 10px; 87 | font-size: 26rpx; 88 | } 89 | 90 | .section-features .feature-list .feature-card .card-main .card-actions { 91 | bottom: 0; 92 | right: 0; 93 | margin-right: 0; 94 | padding: 30rpx 29rpx; 95 | position: absolute; 96 | } 97 | 98 | .section-features .feature-list .feature-card .img-icon { 99 | width: 35rpx; 100 | height: 35rpx; 101 | margin-left: 15rpx; 102 | background-repeat: no-repeat; 103 | background-position: center; 104 | } 105 | 106 | .section-features .feature-list .feature-card .action-item { 107 | font-size: 30rpx; 108 | 109 | } 110 | -------------------------------------------------------------------------------- /qTravel/pages/detail/detail.json: -------------------------------------------------------------------------------- 1 | { 2 | "enablePullDownRefresh": true, 3 | "usingComponents": {} 4 | } -------------------------------------------------------------------------------- /qTravel/pages/index/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Author : 丸子团队(波波、Chi、ONLINE.信) 3 | * Github 地址: https://github.com/dchijack/Travel-Mini-Program 4 | * GiTee 地址: https://gitee.com/izol/Travel-Mini-Program 5 | */ 6 | const API = require('../../utils/api') 7 | 8 | Page({ 9 | 10 | /** 11 | * 页面的初始数据 12 | */ 13 | data: { 14 | posts: [], 15 | page:1, 16 | indicatorDots: !1, 17 | autoplay: !0, 18 | interval: 3e3, 19 | currentSwiper: 0, 20 | navBarHeight: wx.getSystemInfoSync().statusBarHeight, 21 | placeHolder: '输入你想知道的内容...', 22 | autoFocus: false, 23 | inputEnable: true, 24 | }, 25 | 26 | /** 27 | * 生命周期函数--监听页面加载 28 | */ 29 | onLoad: function(options) { 30 | let that=this; 31 | wx.getSystemInfo({ 32 | success: function (a) { 33 | that.setData({ 34 | isIphoneX: a.model.match(/iPhone X/gi) 35 | }); 36 | } 37 | }); 38 | this.getStickyPosts(); 39 | this.getPostList(); 40 | this.getCategories(); 41 | this.getSiteInfo(); 42 | }, 43 | 44 | getSiteInfo: function() { 45 | 46 | API.getSiteInfo().then(res => { 47 | this.setData({ 48 | siteInfo: res 49 | }) 50 | }) 51 | }, 52 | 53 | onInput: function(e) { 54 | this.setData({ 55 | searchKey: e.detail.value 56 | }) 57 | }, 58 | 59 | currentChange: function(e) { 60 | this.setData({ 61 | currentSwiper: e.detail.current 62 | }); 63 | }, 64 | 65 | getCategories: function() { 66 | API.getCategories().then(res => { 67 | this.setData({ 68 | category: res 69 | }) 70 | }) 71 | }, 72 | getStickyPosts: function() { 73 | API.getStickyPosts().then(res => { 74 | this.setData({ 75 | stickyPost: res 76 | }) 77 | }) 78 | }, 79 | goClassfication:function(){ 80 | wx.switchTab({ 81 | url: '/pages/category/category', 82 | }) 83 | }, 84 | 85 | getPostList: function(args) { 86 | API.getPostsList(args).then(res => { 87 | let args = {} 88 | if (res.length < 10) { 89 | this.setData({ 90 | isLastPage: true, 91 | loadtext: '到底啦', 92 | showloadmore: false 93 | }) 94 | } 95 | if (this.data.isPull) { 96 | args.posts = [].concat(this.data.posts, res) 97 | args.page = this.data.page + 1 98 | } else if (this.data.isBottom) { 99 | args.posts = [].concat(this.data.posts, res) 100 | args.page = this.data.page + 1 101 | } else { 102 | args.posts = [].concat(this.data.posts, res) 103 | args.page = this.data.page + 1 104 | } 105 | this.setData(args) 106 | }) 107 | 108 | }, 109 | 110 | goClassByid: function (e) { 111 | let id = e.currentTarget.id; 112 | wx.navigateTo({ 113 | url: '/pages/list/list?id=' + id, 114 | }) 115 | }, 116 | 117 | goArticleDetail: function(e) { 118 | let id = e.currentTarget.id; 119 | wx.navigateTo({ 120 | url: '/pages/detail/detail?id=' + id, 121 | }) 122 | }, 123 | 124 | onConfirm:function(e){ 125 | console.log(e); 126 | let s=e.detail.value; 127 | wx.navigateTo({ 128 | url: '/pages/list/list?s='+s, 129 | }) 130 | }, 131 | 132 | /** 133 | * 生命周期函数--监听页面初次渲染完成 134 | */ 135 | onReady: function() { 136 | 137 | }, 138 | 139 | /** 140 | * 生命周期函数--监听页面显示 141 | */ 142 | onShow: function() { 143 | 144 | }, 145 | 146 | /** 147 | * 生命周期函数--监听页面隐藏 148 | */ 149 | onHide: function() { 150 | 151 | }, 152 | 153 | /** 154 | * 生命周期函数--监听页面卸载 155 | */ 156 | onUnload: function() { 157 | 158 | }, 159 | 160 | onClear:function(){ 161 | this.setData({ 162 | searchKey:'', 163 | }) 164 | }, 165 | 166 | /** 167 | * 页面相关事件处理函数--监听用户下拉动作 168 | */ 169 | onPullDownRefresh: function() { 170 | this.setData({ 171 | posts:[], 172 | page:1, 173 | }) 174 | this.getPostList({ 175 | page: this.data.page 176 | }); 177 | wx.stopPullDownRefresh(); 178 | }, 179 | 180 | /** 181 | * 页面上拉触底事件的处理函数 182 | */ 183 | onReachBottom: function() { 184 | if (!this.data.isLastPage) { 185 | this.getPostList({ 186 | page:this.data.page 187 | }); 188 | } 189 | }, 190 | 191 | /** 192 | * 用户点击右上角分享 193 | */ 194 | onShareAppMessage: function() { 195 | let that=this; 196 | return { 197 | title:that.data.siteInfo.name , 198 | path: '/pages/index/index' 199 | } 200 | 201 | } 202 | }) -------------------------------------------------------------------------------- /qTravel/pages/index/index.json: -------------------------------------------------------------------------------- 1 | { 2 | "enablePullDownRefresh": true, 3 | "navigationStyle": "custom", 4 | "navigationBarTextStyle": "white", 5 | "usingComponents": {} 6 | } -------------------------------------------------------------------------------- /qTravel/pages/index/index.qml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 19 | 20 | 21 | 为你精选 22 | 23 | 24 |
{{item.name}}
25 | 26 |
27 |
28 | 29 | 30 | 31 | 32 | 33 | 34 | {{item.category[0].name}} 35 | 36 | 37 | {{item.title.rendered}} 38 | {{item.excerpt.rendered}} 39 | 40 | 41 | 已经到底啦~ 42 | 努力加载中... 43 |
44 |
45 |
-------------------------------------------------------------------------------- /qTravel/pages/list/list.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Author : 丸子团队(波波、Chi、ONLINE.信) 3 | * Github 地址: https://github.com/dchijack/Travel-Mini-Program 4 | * GiTee 地址: https://gitee.com/izol/Travel-Mini-Program 5 | */ 6 | // pages/list/list.js 7 | const API = require('../../utils/api') 8 | 9 | Page({ 10 | 11 | /** 12 | * 页面的初始数据 13 | */ 14 | data: { 15 | posts: [], 16 | page: 1, 17 | isLoadAll: false, 18 | }, 19 | 20 | /** 21 | * 生命周期函数--监听页面加载 22 | */ 23 | onLoad: function(options) { 24 | let id = options.id; 25 | this.setData({ 26 | options: options, 27 | }) 28 | if (options.id) { 29 | this.getPostList({ 30 | categories: id, 31 | page: this.data.page 32 | }); 33 | this.getCategoryByID(options.id); 34 | } 35 | if (options.s) { 36 | this.getPostList({ 37 | search: options.s, 38 | page: this.data.page 39 | }); 40 | this.setData({ 41 | category: '关键词“' + options.s + '”的结果' 42 | }) 43 | } 44 | 45 | }, 46 | 47 | /** 48 | * 生命周期函数--监听页面初次渲染完成 49 | */ 50 | onReady: function() { 51 | 52 | }, 53 | 54 | getCategoryByID: function(id) { 55 | API.getCategoryByID(id).then(res => { 56 | this.setData({ 57 | category: res.name 58 | }) 59 | }) 60 | 61 | }, 62 | 63 | goArticleDetail: function(e) { 64 | let id = e.currentTarget.id; 65 | wx.navigateTo({ 66 | url: '/pages/detail/detail?id=' + id, 67 | }) 68 | }, 69 | 70 | getPostList: function(args) { 71 | API.getPostsList(args).then(res => { 72 | let args = {} 73 | if (res.length < 10) { 74 | this.setData({ 75 | isLastPage: true, 76 | loadtext: '到底啦', 77 | showloadmore: false 78 | }) 79 | } 80 | if (this.data.isPull) { 81 | args.posts = [].concat(this.data.posts, res) 82 | args.page = this.data.page + 1 83 | } else if (this.data.isBottom) { 84 | args.posts = [].concat(this.data.posts, res) 85 | args.page = this.data.page + 1 86 | } else { 87 | args.posts = [].concat(this.data.posts, res) 88 | args.page = this.data.page + 1 89 | args.isLoadAll = true 90 | } 91 | this.setData(args) 92 | }) 93 | }, 94 | 95 | 96 | /** 97 | * 生命周期函数--监听页面显示 98 | */ 99 | onShow: function() { 100 | 101 | }, 102 | 103 | /** 104 | * 生命周期函数--监听页面隐藏 105 | */ 106 | onHide: function() { 107 | 108 | }, 109 | 110 | /** 111 | * 生命周期函数--监听页面卸载 112 | */ 113 | onUnload: function() { 114 | 115 | }, 116 | 117 | /** 118 | * 页面相关事件处理函数--监听用户下拉动作 119 | */ 120 | onPullDownRefresh: function() { 121 | this.setData({ 122 | posts:[], 123 | page:1, 124 | }) 125 | if (this.data.options.id) { 126 | this.getPostList({ 127 | categories: this.data.options.id, 128 | page: this.data.page 129 | }); 130 | } 131 | if (this.data.options.s) { 132 | this.getPostList({ 133 | search: this.data.options.s, 134 | page: this.data.page 135 | }); 136 | } 137 | wx.stopPullDownRefresh(); 138 | 139 | }, 140 | 141 | /** 142 | * 页面上拉触底事件的处理函数 143 | */ 144 | onReachBottom: function() { 145 | if (!this.data.isLastPage) { 146 | if (this.data.options.id) { 147 | this.getPostList({ 148 | categories: this.data.options.id, 149 | page: this.data.page 150 | }); 151 | } 152 | if (this.data.options.s) { 153 | this.getPostList({ 154 | search: this.data.options.s, 155 | page: this.data.page 156 | }); 157 | } 158 | } 159 | }, 160 | 161 | /** 162 | * 用户点击右上角分享 163 | */ 164 | onShareAppMessage: function() { 165 | 166 | } 167 | }) -------------------------------------------------------------------------------- /qTravel/pages/list/list.json: -------------------------------------------------------------------------------- 1 | { 2 | "enablePullDownRefresh": true, 3 | "usingComponents": {} 4 | } -------------------------------------------------------------------------------- /qTravel/pages/list/list.qml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | {{category}} 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | {{item.category[0].name}} 14 | 15 | 16 | {{item.title.rendered}} 17 | {{item.excerpt.rendered}} 18 | 19 | 20 | 暂无内容 21 | 22 | 23 | 24 | 已经到底啦~ 25 | 努力加载中... 26 | 27 | 28 | -------------------------------------------------------------------------------- /qTravel/pages/list/list.qss: -------------------------------------------------------------------------------- 1 | 2 | .page.iphone-x { 3 | padding-bottom: 20rpx; 4 | } 5 | 6 | .banner { 7 | position: relative; 8 | width: 100vw; 9 | height: 540rpx; 10 | z-index: 0; 11 | } 12 | 13 | .banner-bg { 14 | position: absolute; 15 | width: 100vw; 16 | bottom: 0; 17 | left: 0; 18 | } 19 | 20 | .banner::after { 21 | content: ""; 22 | display: block; 23 | height: 80rpx; 24 | width: 100vw; 25 | position: absolute; 26 | left: 0; 27 | bottom: 0; 28 | background-image: linear-gradient(180deg,rgba(255,255,255,0.00) 0%,#F9F9F9 100%); 29 | pointer-events: none; 30 | z-index: -1; 31 | } 32 | 33 | .banner-info { 34 | position: absolute; 35 | left: 0; 36 | right: 0; 37 | margin: 0 40rpx; 38 | } 39 | 40 | .banner-title { 41 | font-weight: bold; 42 | font-size: 58rpx; 43 | color: #000; 44 | line-height: 68rpx; 45 | } 46 | 47 | .banner-title_text { 48 | display: inline-block; 49 | vertical-align: middle; 50 | } 51 | 52 | .banner-avatar { 53 | position: relative; 54 | vertical-align: middle; 55 | float: right; 56 | } 57 | 58 | .avatar { 59 | width: 72rpx; 60 | height: 72rpx; 61 | border: 5rpx solid #fff; 62 | border-radius: 50%; 63 | background-size: cover; 64 | } 65 | 66 | .default-avatar { 67 | width: 72rpx; 68 | height: 72rpx; 69 | border: 5rpx solid #fff; 70 | border-radius: 50%; 71 | background-image: url(https://cloud-minapp-16269.cloud.ifanrusercontent.com/default-avator.jpg); 72 | background-size: cover; 73 | } 74 | 75 | .unread-message { 76 | display: block; 77 | position: absolute; 78 | right: 0; 79 | top: 0; 80 | pointer-events: none; 81 | } 82 | 83 | .banner-brief { 84 | font-size: 28rpx; 85 | color: #121212; 86 | line-height: 40rpx; 87 | margin-top: 20rpx; 88 | letter-spacing: 4rpx; 89 | } 90 | 91 | .ifanr-search { 92 | position: absolute; 93 | bottom: -20rpx; 94 | left: 40rpx; 95 | right: 40rpx; 96 | border-radius: 44rpx; 97 | box-shadow: 0 4rpx 20rpx 2rpx #FBEBD4; 98 | } 99 | 100 | 101 | .index { 102 | padding: 20rpx 36rpx; 103 | } 104 | 105 | .top_text { 106 | width: 100%; 107 | text-align: center; 108 | color: #AAA; 109 | font-size: 24rpx; 110 | } 111 | 112 | page::-webkit-scrollbar { 113 | display: none; 114 | } 115 | 116 | .slide_box { 117 | width: 678rpx; 118 | height: 280rpx; 119 | margin: 0 auto; 120 | box-shadow: 0rpx 2rpx 14rpx 0rpx rgba(38,38,38,0.1); 121 | } 122 | 123 | .slide_image { 124 | width: 678rpx; 125 | height: 280rpx; 126 | border-radius: 4rpx; 127 | } 128 | 129 | .dots { 130 | display: flex; 131 | flex-direction: row; 132 | justify-content: center; 133 | margin-top: 20rpx; 134 | } 135 | 136 | .dot { 137 | width: 20rpx; 138 | height: 4rpx; 139 | background: rgba(221,221,221,1); 140 | margin-right: 20rpx; 141 | } 142 | 143 | .active { 144 | width: 60rpx; 145 | height: 4rpx; 146 | background: rgba(38,38,38,1); 147 | } 148 | 149 | .category { 150 | padding: 30rpx 10rpx; 151 | } 152 | 153 | .index_label { 154 | position: relative; 155 | } 156 | 157 | .index_label_title { 158 | font-size: 48rpx; 159 | color: #262626; 160 | position: absolute; 161 | top: 0; 162 | left: 0; 163 | z-index: 1; 164 | } 165 | 166 | .index_label_bg { 167 | width: 160rpx; 168 | height: 12rpx; 169 | background: linear-gradient(270deg,rgba(249,228,135,0) 0%,rgba(241,197,79,1) 100%); 170 | border-radius: 11rpx; 171 | position: absolute; 172 | top: 48rpx; 173 | left: 0; 174 | } 175 | 176 | .index_label_more { 177 | position: absolute; 178 | right: 0; 179 | top: -14rpx; 180 | color: #888888; 181 | font-size: 28rpx; 182 | line-height: 48rpx; 183 | display: flex; 184 | flex-direction: row; 185 | align-items: center; 186 | } 187 | 188 | .index_comment_box { 189 | margin: 120rpx 30rpx 0 0; 190 | width: 100%; 191 | display: flex; 192 | flex-direction: row; 193 | flex-wrap: nowrap; 194 | overflow-x: scroll; 195 | -webkit-overflow-scrolling: touch; 196 | } 197 | 198 | .index_comment { 199 | background: rgba(246,247,249,1); 200 | border-radius: 4rpx; 201 | padding: 70rpx 40rpx 100rpx 40rpx; 202 | } 203 | 204 | .index_comment_hb { 205 | display: flex; 206 | flex-direction: row; 207 | } 208 | 209 | .index_comment_avatar { 210 | width: 70rpx; 211 | height: 70rpx; 212 | border-radius: 50%; 213 | background: #888888; 214 | } 215 | 216 | .index_comment_hb_name { 217 | color: #888888; 218 | font-size: 24rpx; 219 | line-height: 37rpx; 220 | } 221 | 222 | .index_comment_hb_title { 223 | color: #262626; 224 | font-size: 24rpx; 225 | line-height: 24rpx; 226 | margin-left: 6rpx; 227 | width: 220rpx; 228 | overflow: hidden; 229 | text-overflow: ellipsis; 230 | white-space: nowrap; 231 | } 232 | 233 | .index_comment_content { 234 | color: #262626; 235 | font-size: 32rpx; 236 | height: 240rpx; 237 | width: 340rpx; 238 | display: inline-block; 239 | margin-top: 50rpx; 240 | white-space: normal; 241 | display: -webkit-box; 242 | -webkit-box-orient: vertical; 243 | -webkit-line-clamp: 5; 244 | overflow: hidden; 245 | } 246 | 247 | .margin_right_30 { 248 | margin-right: 30rpx; 249 | } 250 | 251 | .margin_right_0 { 252 | margin-right: 0; 253 | } 254 | 255 | .index_article_cover { 256 | width: 678rpx; 257 | height: 380rpx; 258 | border-radius: 4rpx; 259 | } 260 | 261 | .index_article { 262 | margin-top: 80rpx; 263 | } 264 | 265 | .index_article_title { 266 | font-size: 36rpx; 267 | font-weight: 400; 268 | color: rgba(38,38,38,1); 269 | line-height: 50rpx; 270 | margin-top: 30rpx; 271 | width: 678rpx; 272 | overflow: hidden; 273 | text-overflow: ellipsis; 274 | white-space: nowrap; 275 | } 276 | 277 | .index_article_desc { 278 | color: #888888; 279 | font-size: 28rpx; 280 | margin-bottom: 70rpx; 281 | overflow: hidden; 282 | margin-top: 16rpx; 283 | text-overflow: ellipsis; 284 | display: -webkit-box; 285 | -webkit-line-clamp: 2; 286 | -webkit-box-orient: vertical; 287 | word-wrap: break-word; 288 | } 289 | 290 | .index_article_during { 291 | position: absolute; 292 | top: 326rpx; 293 | left: 16rpx; 294 | z-index: 1; 295 | width: 120rpx; 296 | height: 40rpx; 297 | background: rgba(38,38,38,1); 298 | border-radius: 4rpx; 299 | opacity: 0.9; 300 | text-align: center; 301 | line-height: 32rpx; 302 | } 303 | 304 | .index_article_during text { 305 | font-size: 22rpx; 306 | color: #fff; 307 | margin-left: 8rpx; 308 | } 309 | 310 | .last_text { 311 | width: 100%; 312 | text-align: center; 313 | color: #AAA; 314 | font-size: 24rpx; 315 | margin: 90rpx 0 30rpx; 316 | } 317 | 318 | .dialog .t1 { 319 | color: #262626; 320 | font-size: 36rpx; 321 | width: 100%; 322 | text-align: center; 323 | margin: 70rpx auto 50rpx; 324 | } 325 | 326 | .dialog .t2 { 327 | color: #888; 328 | font-size: 32rpx; 329 | width: 100%; 330 | text-align: center; 331 | } 332 | 333 | .dialog .t3 { 334 | width: 500rpx; 335 | height: 174rpx; 336 | border-top-left-radius: 0; 337 | border-top-right-radius: 0; 338 | } 339 | 340 | .dialog .t4 { 341 | display: flex; 342 | flex-direction: row; 343 | justify-content: space-around; 344 | padding: 0 30rpx; 345 | } 346 | 347 | .dialog .t4 .cancel { 348 | width: 240rpx; 349 | height: 70rpx; 350 | background: #fff; 351 | border: 1rpx solid #F1C54F; 352 | color: #F1C54F; 353 | text-align: center; 354 | line-height: 70rpx; 355 | } 356 | 357 | .dialog .t4 .go_set { 358 | width: 240rpx; 359 | height: 70rpx; 360 | background: rgba(241,197,79,1); 361 | color: #fff; 362 | text-align: center; 363 | line-height: 70rpx; 364 | } 365 | 366 | .ifanr-search { 367 | display: flex; 368 | flex-flow: row; 369 | background: #FFFFFF; 370 | box-shadow: 0 6rpx 8rpx 0 #F5F5F5; 371 | border-radius: 44rpx; 372 | height: 88rpx; 373 | justify-content: center; 374 | align-items: center; 375 | padding: 24rpx; 376 | box-sizing: border-box; 377 | } 378 | 379 | .search-icon { 380 | flex-grow: 0; 381 | flex-shrink: 0; 382 | width: 40rpx; 383 | height: 40rpx; 384 | background-image: url("https://cloud-minapp-16269.cloud.ifanrusercontent.com/product-search.svg"); 385 | background-size: contain; 386 | } 387 | 388 | .search-input { 389 | flex-grow: 1; 390 | flex-shrink: 1; 391 | overflow: hidden; 392 | text-overflow: ellipsis; 393 | white-space: nowrap; 394 | margin-left: 20rpx; 395 | font-size: 26rpx; 396 | color: #A8A8A8; 397 | } 398 | 399 | input.search-input { 400 | color: #222222; 401 | } 402 | 403 | search-input-placeholder { 404 | color: #A8A8A8; 405 | } 406 | 407 | .close-btn { 408 | width: 36rpx; 409 | height: 36rpx; 410 | margin-left: 24rpx; 411 | border-radius: 50%; 412 | opacity: 0.4; 413 | } -------------------------------------------------------------------------------- /qTravel/pages/logs/logs.js: -------------------------------------------------------------------------------- 1 | //logs.js 2 | const util = require('../../utils/util.js') 3 | 4 | Page({ 5 | data: { 6 | logs: [] 7 | }, 8 | onLoad: function () { 9 | this.setData({ 10 | logs: (wx.getStorageSync('logs') || []).map(log => { 11 | return util.formatTime(new Date(log)) 12 | }) 13 | }) 14 | } 15 | }) 16 | -------------------------------------------------------------------------------- /qTravel/pages/logs/logs.json: -------------------------------------------------------------------------------- 1 | { 2 | "navigationBarTitleText": "查看启动日志", 3 | "usingComponents": {} 4 | } -------------------------------------------------------------------------------- /qTravel/pages/logs/logs.qml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | {{index + 1}}. {{log}} 5 | 6 | 7 | -------------------------------------------------------------------------------- /qTravel/pages/logs/logs.qss: -------------------------------------------------------------------------------- 1 | .log-list { 2 | display: flex; 3 | flex-direction: column; 4 | padding: 40rpx; 5 | } 6 | .log-item { 7 | margin: 10rpx; 8 | } 9 | -------------------------------------------------------------------------------- /qTravel/pages/mine/mine.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Author : 丸子团队(波波、Chi、ONLINE.信) 3 | * Github 地址: https://github.com/dchijack/Travel-Mini-Program 4 | * GiTee 地址: https://gitee.com/izol/Travel-Mini-Program 5 | */ 6 | // pages/mine/mine.js 7 | const API = require('../../utils/api') 8 | const app = getApp() 9 | Page({ 10 | 11 | /** 12 | * 页面的初始数据 13 | */ 14 | data: { 15 | 16 | }, 17 | 18 | /** 19 | * 生命周期函数--监听页面加载 20 | */ 21 | onLoad: function(options) { 22 | this.getSiteInfo(); 23 | }, 24 | 25 | /** 26 | * 生命周期函数--监听页面初次渲染完成 27 | */ 28 | onReady: function() { 29 | 30 | }, 31 | 32 | 33 | getSiteInfo: function () { 34 | 35 | API.getSiteInfo().then(res => { 36 | this.setData({ 37 | siteInfo: res 38 | }) 39 | }) 40 | }, 41 | 42 | 43 | getUserInfoFun: function (e) { 44 | console.log(e); 45 | if (e.detail.errMsg == "getUserInfo:ok") { 46 | this.getProfile(); 47 | wx.setStorageSync('user', e.detail) 48 | this.setData({ 49 | user: true, 50 | }) 51 | } 52 | else { 53 | return 54 | } 55 | 56 | 57 | }, 58 | 59 | mineHandler:function(e){ 60 | let url=e.currentTarget.dataset.url; 61 | wx.navigateTo({ 62 | url: url, 63 | }) 64 | }, 65 | 66 | getProfile: function (e) { 67 | console.log(e); 68 | API.getProfile().then(res => { 69 | console.log(res) 70 | this.setData({ 71 | user: res 72 | }) 73 | }) 74 | .catch(err => { 75 | console.log(err) 76 | wx.hideLoading() 77 | }) 78 | }, 79 | 80 | /** 81 | * 生命周期函数--监听页面显示 82 | */ 83 | onShow: function() { 84 | let user = app.globalData.user 85 | if (!user) { 86 | user = ''; 87 | } 88 | this.setData({ 89 | user: user, 90 | }) 91 | }, 92 | 93 | clear:function(){ 94 | 95 | wx.clearStorageSync(); 96 | wx.showToast({ 97 | title: '清除完毕', 98 | }) 99 | wx.switchTab({ 100 | url: '/pages/mine/mine', 101 | }) 102 | 103 | }, 104 | 105 | /** 106 | * 生命周期函数--监听页面隐藏 107 | */ 108 | onHide: function() { 109 | 110 | }, 111 | 112 | /** 113 | * 生命周期函数--监听页面卸载 114 | */ 115 | onUnload: function() { 116 | 117 | }, 118 | 119 | /** 120 | * 页面相关事件处理函数--监听用户下拉动作 121 | */ 122 | onPullDownRefresh: function() { 123 | 124 | }, 125 | 126 | /** 127 | * 页面上拉触底事件的处理函数 128 | */ 129 | onReachBottom: function() { 130 | 131 | }, 132 | 133 | /** 134 | * 用户点击右上角分享 135 | */ 136 | onShareAppMessage: function() { 137 | 138 | } 139 | }) -------------------------------------------------------------------------------- /qTravel/pages/mine/mine.json: -------------------------------------------------------------------------------- 1 | { 2 | "usingComponents": {} 3 | } -------------------------------------------------------------------------------- /qTravel/pages/mine/mine.qml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | {{user.nickName}} 8 | {{siteInfo.description}} 9 | 10 | 11 | 12 | 13 | 14 | 点击登录 15 | 使用微信登录 16 | 17 | 18 | 19 | 20 | 21 | 我的点赞 22 | 23 | 24 | {{unreadMessageCount}} 25 | 26 | 27 | 28 | 29 | 我的评论 30 | 31 | 32 | 33 | 34 | 35 | 36 | 我的收藏 37 | 38 | 39 | 40 | 41 | 42 | 43 | 问题反馈 44 | 45 | 46 | 47 | 48 | 49 | 50 | 清除缓存 51 | 52 | 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /qTravel/pages/mine/mine.qss: -------------------------------------------------------------------------------- 1 | .user-container { 2 | background-color: #F5F7F9; 3 | overflow: hidden; 4 | box-sizing: border-box; 5 | padding-bottom: 68rpx; 6 | } 7 | 8 | .user-information { 9 | display: flex; 10 | padding: 48rpx 24rpx; 11 | margin: 24rpx 24rpx 0; 12 | background-color: #fff; 13 | border-radius: 16rpx; 14 | } 15 | 16 | .user-information_img { 17 | position: relative; 18 | width: 140rpx; 19 | height: 140rpx; 20 | border-radius: 50%; 21 | border: 4rpx solid #fff; 22 | overflow: hidden; 23 | background-size: cover; 24 | background-position: center; 25 | margin-right: 32rpx; 26 | overflow: hidden; 27 | } 28 | 29 | .nickname { 30 | flex: 1; 31 | display: inline-flex; 32 | flex-direction: column; 33 | justify-content: center; 34 | } 35 | 36 | .user-information_nickname { 37 | font-size: 44rpx; 38 | font-weight: bold; 39 | line-height: 60rpx; 40 | color: #121212; 41 | } 42 | 43 | .user-information_introduction { 44 | font-size: 28rpx; 45 | line-height: 40rpx; 46 | color: #7D7D7D; 47 | margin-top: 10rpx; 48 | opacity: .8; 49 | } 50 | 51 | .user-items { 52 | padding: 24rpx 40rpx; 53 | margin: 24rpx; 54 | border-radius: 16rpx; 55 | background-color: #fff; 56 | } 57 | 58 | .user-item { 59 | position: relative; 60 | height: 120rpx; 61 | line-height: 120rpx; 62 | font-size: 36rpx; 63 | color: #3A3A3A; 64 | border-bottom: 1rpx solid #E8E8E8; 65 | } 66 | 67 | .user-item:last-child { 68 | border-bottom: none; 69 | } 70 | 71 | .user-item_text { 72 | position: relative; 73 | z-index: 10; 74 | pointer-events: none; 75 | } 76 | 77 | .user-item_icon { 78 | position: relative; 79 | z-index: 10; 80 | float: right; 81 | vertical-align: middle; 82 | width: 60rpx; 83 | height: 100%; 84 | display: flex; 85 | flex-direction: column; 86 | justify-content: center; 87 | pointer-events: none; 88 | } 89 | 90 | .user-item_switch { 91 | float: right; 92 | transform: scale(0.8,.8); 93 | margin-right: -20rpx; 94 | } 95 | 96 | .user-item_icon_img { 97 | width: 100%; 98 | height: 60rpx; 99 | } 100 | 101 | .user-item_icon_sup { 102 | position: absolute; 103 | right: -1rpx; 104 | top: 24rpx; 105 | width: 32rpx; 106 | height: 32rpx; 107 | background: #F13B03; 108 | border: 2rpx solid #FFFFFF; 109 | border-radius: 50%; 110 | font-weight: bold; 111 | font-size: 24rpx; 112 | color: #FFFFFF; 113 | line-height: 32rpx; 114 | text-align: center; 115 | } 116 | 117 | .user-welfare { 118 | position: relative; 119 | margin: 54rpx 24rpx; 120 | height: 196rpx; 121 | } 122 | 123 | .user-welfare_img { 124 | width: 100%; 125 | height: 100%; 126 | } 127 | 128 | .my-login { 129 | width: 100%; 130 | height: 100%; 131 | position: absolute; 132 | top: 0; 133 | left: 0; 134 | background: none; 135 | } 136 | 137 | .my-login::after { 138 | border: none; 139 | } 140 | 141 | .auth-btn { 142 | position: absolute; 143 | width: 100%; 144 | height: 100%; 145 | top: 0; 146 | left: 0; 147 | right: 0; 148 | bottom: 0; 149 | background: transparent; 150 | padding: 0; 151 | text-align: left; 152 | line-height: 120rpx; 153 | color: #3A3A3A; 154 | } 155 | 156 | .auth-btn:after { 157 | border: none; 158 | } 159 | 160 | .separator { 161 | width: 100%; 162 | height: 24rpx; 163 | } -------------------------------------------------------------------------------- /qTravel/pages/mine/mypost.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Author : 丸子团队(波波、Chi、ONLINE.信) 3 | * Github 地址: https://github.com/dchijack/Travel-Mini-Program 4 | * GiTee 地址: https://gitee.com/izol/Travel-Mini-Program 5 | */ 6 | // pages/mine/mypost.js 7 | const API = require('../../utils/api') 8 | const app = getApp() 9 | Page({ 10 | 11 | /** 12 | * 页面的初始数据 13 | */ 14 | data: { 15 | posts:[], 16 | page: 1, 17 | }, 18 | 19 | /** 20 | * 生命周期函数--监听页面加载 21 | */ 22 | onLoad: function(options) { 23 | if (options.id == 3) { 24 | this.setData({ 25 | category: '我的收藏' 26 | }) 27 | this.getFavPosts(); 28 | } else if (options.id == 1) { 29 | this.setData({ 30 | category: '我的点赞' 31 | }) 32 | this.getLikePosts(); 33 | } else if (options.id == 2) { 34 | this.setData({ 35 | category: '我的评论' 36 | }) 37 | this.getCommentsPosts(); 38 | } 39 | }, 40 | 41 | getFavPosts: function(args) { 42 | API.getFavPosts(args).then(res => { 43 | let args = {} 44 | if (res.length < 10) { 45 | this.setData({ 46 | isLastPage: true, 47 | loadtext: '到底啦', 48 | showloadmore: false 49 | }) 50 | } 51 | if (this.data.isPull) { 52 | args.posts = [].concat(this.data.posts, res) 53 | args.page = this.data.page + 1 54 | } else if (this.data.isBottom) { 55 | args.posts = [].concat(this.data.posts, res) 56 | args.page = this.data.page + 1 57 | } else { 58 | args.posts = [].concat(this.data.posts, res) 59 | args.page = this.data.page + 1 60 | } 61 | this.setData(args) 62 | }) 63 | 64 | }, 65 | getCommentsPosts: function(args) { 66 | API.getCommentsPosts(args).then(res => { 67 | let args = {} 68 | if (res.length < 10) { 69 | this.setData({ 70 | isLastPage: true, 71 | loadtext: '到底啦', 72 | showloadmore: false 73 | }) 74 | } 75 | if (this.data.isPull) { 76 | args.posts = [].concat(this.data.posts, res) 77 | args.page = this.data.page + 1 78 | } else if (this.data.isBottom) { 79 | args.posts = [].concat(this.data.posts, res) 80 | args.page = this.data.page + 1 81 | } else { 82 | args.posts = [].concat(this.data.posts, res) 83 | args.page = this.data.page + 1 84 | } 85 | this.setData(args) 86 | }) 87 | 88 | }, 89 | getLikePosts: function(args) { 90 | API.getLikePosts(args).then(res => { 91 | let args = {} 92 | if (res.length < 10) { 93 | this.setData({ 94 | isLastPage: true, 95 | loadtext: '到底啦', 96 | showloadmore: false 97 | }) 98 | } 99 | if (this.data.isPull) { 100 | args.posts = [].concat(this.data.posts, res) 101 | args.page = this.data.page + 1 102 | } else if (this.data.isBottom) { 103 | args.posts = [].concat(this.data.posts, res) 104 | args.page = this.data.page + 1 105 | } else { 106 | args.posts = [].concat(this.data.posts, res) 107 | args.page = this.data.page + 1 108 | } 109 | this.setData(args) 110 | }) 111 | 112 | }, 113 | 114 | goArticleDetail: function (e) { 115 | let id = e.currentTarget.id; 116 | wx.navigateTo({ 117 | url: '/pages/detail/detail?id=' + id, 118 | }) 119 | }, 120 | /** 121 | * 生命周期函数--监听页面初次渲染完成 122 | */ 123 | onReady: function() { 124 | 125 | }, 126 | 127 | /** 128 | * 生命周期函数--监听页面显示 129 | */ 130 | onShow: function() { 131 | 132 | }, 133 | 134 | /** 135 | * 生命周期函数--监听页面隐藏 136 | */ 137 | onHide: function() { 138 | 139 | }, 140 | 141 | /** 142 | * 生命周期函数--监听页面卸载 143 | */ 144 | onUnload: function() { 145 | 146 | }, 147 | 148 | /** 149 | * 页面相关事件处理函数--监听用户下拉动作 150 | */ 151 | onPullDownRefresh: function() { 152 | 153 | }, 154 | 155 | /** 156 | * 页面上拉触底事件的处理函数 157 | */ 158 | onReachBottom: function() { 159 | 160 | }, 161 | 162 | /** 163 | * 用户点击右上角分享 164 | */ 165 | onShareAppMessage: function() { 166 | 167 | } 168 | }) -------------------------------------------------------------------------------- /qTravel/pages/mine/mypost.json: -------------------------------------------------------------------------------- 1 | { 2 | "usingComponents": {} 3 | } -------------------------------------------------------------------------------- /qTravel/pages/mine/mypost.qml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | {{category}} 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | {{item.category[0].name}} 14 | 15 | 16 | {{item.title.rendered}} 17 | {{item.excerpt.rendered}} 18 | 19 | 20 | 暂无内容 21 | 22 | 23 | 24 | 已经到底啦~ 25 | 努力加载中... 26 | 27 | 28 | -------------------------------------------------------------------------------- /qTravel/pages/mine/mypost.qss: -------------------------------------------------------------------------------- 1 | 2 | .page.iphone-x { 3 | padding-bottom: 20rpx; 4 | } 5 | 6 | .banner { 7 | position: relative; 8 | width: 100vw; 9 | height: 540rpx; 10 | z-index: 0; 11 | } 12 | 13 | .banner-bg { 14 | position: absolute; 15 | width: 100vw; 16 | bottom: 0; 17 | left: 0; 18 | } 19 | 20 | .banner::after { 21 | content: ""; 22 | display: block; 23 | height: 80rpx; 24 | width: 100vw; 25 | position: absolute; 26 | left: 0; 27 | bottom: 0; 28 | background-image: linear-gradient(180deg,rgba(255,255,255,0.00) 0%,#F9F9F9 100%); 29 | pointer-events: none; 30 | z-index: -1; 31 | } 32 | 33 | .banner-info { 34 | position: absolute; 35 | left: 0; 36 | right: 0; 37 | margin: 0 40rpx; 38 | } 39 | 40 | .banner-title { 41 | font-weight: bold; 42 | font-size: 58rpx; 43 | color: #000; 44 | line-height: 68rpx; 45 | } 46 | 47 | .banner-title_text { 48 | display: inline-block; 49 | vertical-align: middle; 50 | } 51 | 52 | .banner-avatar { 53 | position: relative; 54 | vertical-align: middle; 55 | float: right; 56 | } 57 | 58 | .avatar { 59 | width: 72rpx; 60 | height: 72rpx; 61 | border: 5rpx solid #fff; 62 | border-radius: 50%; 63 | background-size: cover; 64 | } 65 | 66 | .default-avatar { 67 | width: 72rpx; 68 | height: 72rpx; 69 | border: 5rpx solid #fff; 70 | border-radius: 50%; 71 | background-image: url(https://cloud-minapp-16269.cloud.ifanrusercontent.com/default-avator.jpg); 72 | background-size: cover; 73 | } 74 | 75 | .unread-message { 76 | display: block; 77 | position: absolute; 78 | right: 0; 79 | top: 0; 80 | pointer-events: none; 81 | } 82 | 83 | .banner-brief { 84 | font-size: 28rpx; 85 | color: #121212; 86 | line-height: 40rpx; 87 | margin-top: 20rpx; 88 | letter-spacing: 4rpx; 89 | } 90 | 91 | .ifanr-search { 92 | position: absolute; 93 | bottom: -20rpx; 94 | left: 40rpx; 95 | right: 40rpx; 96 | border-radius: 44rpx; 97 | box-shadow: 0 4rpx 20rpx 2rpx #FBEBD4; 98 | } 99 | 100 | 101 | .index { 102 | padding: 20rpx 36rpx; 103 | } 104 | 105 | .top_text { 106 | width: 100%; 107 | text-align: center; 108 | color: #AAA; 109 | font-size: 24rpx; 110 | } 111 | 112 | page::-webkit-scrollbar { 113 | display: none; 114 | } 115 | 116 | .slide_box { 117 | width: 678rpx; 118 | height: 280rpx; 119 | margin: 0 auto; 120 | box-shadow: 0rpx 2rpx 14rpx 0rpx rgba(38,38,38,0.1); 121 | } 122 | 123 | .slide_image { 124 | width: 678rpx; 125 | height: 280rpx; 126 | border-radius: 4rpx; 127 | } 128 | 129 | .dots { 130 | display: flex; 131 | flex-direction: row; 132 | justify-content: center; 133 | margin-top: 20rpx; 134 | } 135 | 136 | .dot { 137 | width: 20rpx; 138 | height: 4rpx; 139 | background: rgba(221,221,221,1); 140 | margin-right: 20rpx; 141 | } 142 | 143 | .active { 144 | width: 60rpx; 145 | height: 4rpx; 146 | background: rgba(38,38,38,1); 147 | } 148 | 149 | .category { 150 | padding: 30rpx 10rpx; 151 | } 152 | 153 | .index_label { 154 | position: relative; 155 | } 156 | 157 | .index_label_title { 158 | font-size: 48rpx; 159 | color: #262626; 160 | position: absolute; 161 | top: 0; 162 | left: 0; 163 | z-index: 1; 164 | } 165 | 166 | .index_label_bg { 167 | width: 160rpx; 168 | height: 12rpx; 169 | background: linear-gradient(270deg,rgba(249,228,135,0) 0%,rgba(241,197,79,1) 100%); 170 | border-radius: 11rpx; 171 | position: absolute; 172 | top: 48rpx; 173 | left: 0; 174 | } 175 | 176 | .index_label_more { 177 | position: absolute; 178 | right: 0; 179 | top: -14rpx; 180 | color: #888888; 181 | font-size: 28rpx; 182 | line-height: 48rpx; 183 | display: flex; 184 | flex-direction: row; 185 | align-items: center; 186 | } 187 | 188 | .index_comment_box { 189 | margin: 120rpx 30rpx 0 0; 190 | width: 100%; 191 | display: flex; 192 | flex-direction: row; 193 | flex-wrap: nowrap; 194 | overflow-x: scroll; 195 | -webkit-overflow-scrolling: touch; 196 | } 197 | 198 | .index_comment { 199 | background: rgba(246,247,249,1); 200 | border-radius: 4rpx; 201 | padding: 70rpx 40rpx 100rpx 40rpx; 202 | } 203 | 204 | .index_comment_hb { 205 | display: flex; 206 | flex-direction: row; 207 | } 208 | 209 | .index_comment_avatar { 210 | width: 70rpx; 211 | height: 70rpx; 212 | border-radius: 50%; 213 | background: #888888; 214 | } 215 | 216 | .index_comment_hb_name { 217 | color: #888888; 218 | font-size: 24rpx; 219 | line-height: 37rpx; 220 | } 221 | 222 | .index_comment_hb_title { 223 | color: #262626; 224 | font-size: 24rpx; 225 | line-height: 24rpx; 226 | margin-left: 6rpx; 227 | width: 220rpx; 228 | overflow: hidden; 229 | text-overflow: ellipsis; 230 | white-space: nowrap; 231 | } 232 | 233 | .index_comment_content { 234 | color: #262626; 235 | font-size: 32rpx; 236 | height: 240rpx; 237 | width: 340rpx; 238 | display: inline-block; 239 | margin-top: 50rpx; 240 | white-space: normal; 241 | display: -webkit-box; 242 | -webkit-box-orient: vertical; 243 | -webkit-line-clamp: 5; 244 | overflow: hidden; 245 | } 246 | 247 | .margin_right_30 { 248 | margin-right: 30rpx; 249 | } 250 | 251 | .margin_right_0 { 252 | margin-right: 0; 253 | } 254 | 255 | .index_video_cover { 256 | width: 678rpx; 257 | height: 380rpx; 258 | border-radius: 4rpx; 259 | } 260 | 261 | .index_video { 262 | margin-top: 80rpx; 263 | } 264 | 265 | .index_video_title { 266 | font-size: 36rpx; 267 | font-weight: 400; 268 | color: rgba(38,38,38,1); 269 | line-height: 50rpx; 270 | margin-top: 30rpx; 271 | width: 678rpx; 272 | overflow: hidden; 273 | text-overflow: ellipsis; 274 | white-space: nowrap; 275 | } 276 | 277 | .index_video_desc { 278 | color: #888888; 279 | font-size: 28rpx; 280 | margin-bottom: 70rpx; 281 | overflow: hidden; 282 | margin-top: 16rpx; 283 | text-overflow: ellipsis; 284 | display: -webkit-box; 285 | -webkit-line-clamp: 2; 286 | -webkit-box-orient: vertical; 287 | word-wrap: break-word; 288 | } 289 | 290 | .index_video_during { 291 | position: absolute; 292 | top: 326rpx; 293 | left: 16rpx; 294 | z-index: 1; 295 | width: 120rpx; 296 | height: 40rpx; 297 | background: rgba(38,38,38,1); 298 | border-radius: 4rpx; 299 | opacity: 0.9; 300 | text-align: center; 301 | line-height: 32rpx; 302 | } 303 | 304 | .index_video_during text { 305 | font-size: 22rpx; 306 | color: #fff; 307 | margin-left: 8rpx; 308 | } 309 | 310 | .last_text { 311 | width: 100%; 312 | text-align: center; 313 | color: #AAA; 314 | font-size: 24rpx; 315 | margin: 90rpx 0 30rpx; 316 | } 317 | 318 | .dialog .t1 { 319 | color: #262626; 320 | font-size: 36rpx; 321 | width: 100%; 322 | text-align: center; 323 | margin: 70rpx auto 50rpx; 324 | } 325 | 326 | .dialog .t2 { 327 | color: #888; 328 | font-size: 32rpx; 329 | width: 100%; 330 | text-align: center; 331 | } 332 | 333 | .dialog .t3 { 334 | width: 500rpx; 335 | height: 174rpx; 336 | border-top-left-radius: 0; 337 | border-top-right-radius: 0; 338 | } 339 | 340 | .dialog .t4 { 341 | display: flex; 342 | flex-direction: row; 343 | justify-content: space-around; 344 | padding: 0 30rpx; 345 | } 346 | 347 | .dialog .t4 .cancel { 348 | width: 240rpx; 349 | height: 70rpx; 350 | background: #fff; 351 | border: 1rpx solid #F1C54F; 352 | color: #F1C54F; 353 | text-align: center; 354 | line-height: 70rpx; 355 | } 356 | 357 | .dialog .t4 .go_set { 358 | width: 240rpx; 359 | height: 70rpx; 360 | background: rgba(241,197,79,1); 361 | color: #fff; 362 | text-align: center; 363 | line-height: 70rpx; 364 | } 365 | 366 | .ifanr-search { 367 | display: flex; 368 | flex-flow: row; 369 | background: #FFFFFF; 370 | box-shadow: 0 6rpx 8rpx 0 #F5F5F5; 371 | border-radius: 44rpx; 372 | height: 88rpx; 373 | justify-content: center; 374 | align-items: center; 375 | padding: 24rpx; 376 | box-sizing: border-box; 377 | } 378 | 379 | .search-icon { 380 | flex-grow: 0; 381 | flex-shrink: 0; 382 | width: 40rpx; 383 | height: 40rpx; 384 | background-image: url("https://cloud-minapp-16269.cloud.ifanrusercontent.com/product-search.svg"); 385 | background-size: contain; 386 | } 387 | 388 | .search-input { 389 | flex-grow: 1; 390 | flex-shrink: 1; 391 | overflow: hidden; 392 | text-overflow: ellipsis; 393 | white-space: nowrap; 394 | margin-left: 20rpx; 395 | font-size: 26rpx; 396 | color: #A8A8A8; 397 | } 398 | 399 | input.search-input { 400 | color: #222222; 401 | } 402 | 403 | search-input-placeholder { 404 | color: #A8A8A8; 405 | } 406 | 407 | .close-btn { 408 | width: 36rpx; 409 | height: 36rpx; 410 | margin-left: 24rpx; 411 | border-radius: 50%; 412 | opacity: 0.4; 413 | }/* pages/mine/mypost.wxss */ -------------------------------------------------------------------------------- /qTravel/project.config.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "项目配置文件", 3 | "packOptions": { 4 | "ignore": [] 5 | }, 6 | "setting": { 7 | "urlCheck": false, 8 | "es6": true, 9 | "postcss": false, 10 | "minified": false, 11 | "newFeature": true, 12 | "autoAudits": false, 13 | "checkInvalidKey": true, 14 | "remoteDebugLogEnable": false, 15 | "sourcemapDisabled": true, 16 | "useAlphaLib": true, 17 | "nodeModules": true, 18 | "uglifyFileName": true 19 | }, 20 | "compileType": "miniprogram", 21 | "libVersion": "2.7.7", 22 | "appid": "wxe61b785946958cc7", 23 | "projectname": "wTravel", 24 | "debugOptions": { 25 | "hidedInDevtools": [] 26 | }, 27 | "isGameTourist": false, 28 | "simulatorType": "wechat", 29 | "simulatorPluginLibVersion": {}, 30 | "qqappid": "1109677042", 31 | "scripts": { 32 | "beforeCompile": "", 33 | "beforePreview": "", 34 | "beforeUpload": "" 35 | }, 36 | "condition": { 37 | "search": { 38 | "current": -1, 39 | "list": [] 40 | }, 41 | "conversation": { 42 | "current": -1, 43 | "list": [] 44 | }, 45 | "game": { 46 | "currentL": -1, 47 | "list": [] 48 | }, 49 | "miniprogram": { 50 | "current": -1, 51 | "list": [] 52 | } 53 | } 54 | } -------------------------------------------------------------------------------- /qTravel/sitemap.json: -------------------------------------------------------------------------------- 1 | { 2 | "desc": "关于本文件的更多信息,请参考文档 https://developers.weixin.qq.com/miniprogram/dev/framework/sitemap.html", 3 | "rules": [{ 4 | "action": "allow", 5 | "page": "*" 6 | }] 7 | } -------------------------------------------------------------------------------- /qTravel/utils/api.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Author : 丸子团队(波波、Chi、ONLINE.信) 3 | * Github 地址: https://github.com/dchijack/Travel-Mini-Program 4 | * GiTee 地址: https://gitee.com/izol/Travel-Mini-Program 5 | */ 6 | 7 | const API = require('./base') 8 | 9 | /** 10 | * 获取站点信息 11 | * @param {object} args 参数,默认为空 12 | * @return {promise} 13 | */ 14 | const getSiteInfo = function(data) { 15 | return API.get('/wp-json/mp/v1/setting', data); 16 | } 17 | 18 | /** 19 | * 获取置顶文章 20 | * @param {object} args 参数,默认为空 21 | * @return {promise} 22 | */ 23 | const getStickyPosts = function(data) { 24 | return API.get('/wp-json/mp/v1/posts/sticky', data); 25 | } 26 | 27 | /** 28 | * 获取文章列表 29 | * @param {object} args 参数,默认为空 30 | * 参数可以访问: http://v2.wp-api.org/ 了解相关参数 31 | * @return {promise} 32 | */ 33 | const getPostsList = function(data) { 34 | return API.get('/wp-json/wp/v2/posts', data, { token:true }); 35 | } 36 | 37 | /** 38 | * 获取文章详情 39 | * @param {int} id 文章id 40 | * @return {promise} 41 | */ 42 | const getPostsbyID = function(id){ 43 | return API.get('/wp-json/wp/v2/posts/'+id, {}, { token:true }); 44 | } 45 | 46 | /** 47 | * 获取页面列表 48 | * @param {object} args 参数,默认为空 49 | * 参数可以访问: http://v2.wp-api.org/ 了解相关参数 50 | * @return {promise} 51 | */ 52 | const getPagesList = function(data){ 53 | return API.get('/wp-json/wp/v2/pages', data); 54 | } 55 | 56 | /** 57 | * 获取页面详情 58 | * @param {int} id 页面id 59 | * @return {promise} 60 | */ 61 | const getPageByID = function(id){ 62 | return API.get('/wp-json/wp/v2/pages/'+id); 63 | } 64 | 65 | /** 66 | * 获取所有分类列表 67 | * @param {object} args 参数 68 | * 参数可以访问: http://v2.wp-api.org/ 了解相关参数 69 | * @return {promise} 70 | */ 71 | const getCategories = function(data){ 72 | return API.get('/wp-json/wp/v2/categories?orderby=id&order=asc', data); 73 | } 74 | 75 | /** 76 | * 获取指定分类 77 | * @param {int} id 分类ID 78 | * @return {promise} 79 | */ 80 | const getCategoryByID = function(id){ 81 | return API.get('/wp-json/wp/v2/categories/'+id); 82 | } 83 | 84 | /** 85 | * 获取所有标签列表 86 | * @param {object} args 参数 87 | * 参数可以访问: http://v2.wp-api.org/ 了解相关参数 88 | * @return {promise} 89 | */ 90 | const getTags = function(data){ 91 | return API.get('/wp-json/wp/v2/tags?orderby=id&order=asc', data); 92 | } 93 | 94 | /** 95 | * 获取指定标签 96 | * @param {int} id 标签ID 97 | * @return {promise} 98 | */ 99 | const getTagByID = function(id){ 100 | return API.get('/wp-json/wp/v2/tags/'+id); 101 | } 102 | 103 | /** 104 | * 获取随机文章列表 105 | * @param {object} args 参数,默认为空 106 | * @return {promise} 107 | */ 108 | const getRandPosts = function(data){ 109 | return API.get('/wp-json/mp/v1/posts/rand', data); 110 | } 111 | 112 | /** 113 | * 获取相关文章列表 114 | * @param {object} data 参数 115 | * @return {promise} 116 | */ 117 | const getRelatePosts = function(data){ 118 | return API.get('/wp-json/mp/v1/posts/relate', data); 119 | } 120 | 121 | /** 122 | * 获取热门文章列表 123 | * @param {object} args 参数,默认为空 124 | * @return {promise} 125 | */ 126 | const getMostViewsPosts = function(data){ 127 | return API.get('/wp-json/mp/v1/posts/most?meta=views', data); 128 | } 129 | 130 | /** 131 | * 获取热门收藏文章列表 132 | * @param {object} args 参数 133 | * @return {promise} 134 | */ 135 | const getMostFavPosts = function(data){ 136 | return API.get('/wp-json/mp/v2/posts/most?meta=favs', data); 137 | } 138 | 139 | /** 140 | * 获取热门点赞文章列表 141 | * @param {object} args 参数 142 | * @return {promise} 143 | */ 144 | const getMostLikePosts = function(data){ 145 | return API.get('/wp-json/mp/v2/posts/most?meta=likes', data); 146 | } 147 | 148 | /** 149 | * 获取热评文章列表 150 | * @param {object} args 参数,默认为空 151 | * @return {promise} 152 | */ 153 | const getMostCommentPosts = function(data){ 154 | return API.get('/wp-json/mp/v2/posts/most?meta=comments', data); 155 | } 156 | 157 | /** 158 | * 获取近期评论文章 159 | * @param {object} args 参数,默认为空 160 | * @return {promise} 161 | */ 162 | const getRecentCommentPosts = function(data){ 163 | return API.get('/wp-json/mp/v1/posts/comment', data); 164 | } 165 | 166 | /** 167 | * 文章评论列表 168 | * @param {object} args 参数,默认为空 169 | * @return {promise} 170 | */ 171 | const getComments = function(data) { 172 | return API.get('/wp-json/mp/v1/comments', data); 173 | } 174 | 175 | /** 176 | * 获取用户信息 177 | * @param {object} args 参数 178 | * @return {promise} 179 | */ 180 | const getProfile = function() { 181 | return API.getUserInfo(); 182 | } 183 | 184 | /** 185 | * 注销用户登录 186 | * @param {object} args 参数 187 | * @return {promise} 188 | */ 189 | const Loginout = function() { 190 | return API.logout(); 191 | } 192 | 193 | /** 194 | * 收藏文章 195 | * @param {object} args 参数,POST 文章id 196 | * TOKEN 参数为 true ,需要用户授权使用 197 | * @return {promise} 198 | */ 199 | const fav = function(data) { 200 | return API.post('/wp-json/mp/v1/comments?type=fav', data, { token:true }); 201 | } 202 | 203 | /** 204 | * 点赞文章 205 | * @param {object} args 参数,POST 文章id 206 | * TOKEN 参数为 true ,需要用户授权使用 207 | * @return {promise} 208 | */ 209 | const like = function(data) { 210 | return API.post('/wp-json/mp/v1/comments?type=like', data, { token:true }); 211 | } 212 | 213 | /** 214 | * 我的收藏文章列表 215 | * @param {object} args 参数 216 | * TOKEN 参数为 true ,需要用户授权使用 217 | * @return {promise} 218 | */ 219 | const getFavPosts = function(data) { 220 | return API.get('/wp-json/mp/v1/posts/comment?type=fav', data, { token:true }); 221 | } 222 | 223 | /** 224 | * 我的点赞文章列表 225 | * @param {object} args 参数 226 | * TOKEN 参数为 true ,需要用户授权使用 227 | * @return {promise} 228 | */ 229 | const getLikePosts = function(data) { 230 | return API.get('/wp-json/mp/v1/posts/comment?type=like', data, { token:true }); 231 | } 232 | 233 | /** 234 | * 我的评论文章列表 235 | * @param {object} args 参数 236 | * TOKEN 参数为 true ,需要用户授权使用 237 | * @return {promise} 238 | */ 239 | const getCommentsPosts = function(data) { 240 | return API.get('/wp-json/mp/v1/posts/comment?type=comment', data, { token:true }); 241 | } 242 | 243 | /** 244 | * 发表评论 245 | * @param {object} args 参数, POST 评论内容及文章id 246 | * TOKEN 参数为 true ,需要用户授权使用 247 | * @return {promise} 248 | */ 249 | const addComment = function(data) { 250 | return API.post('/wp-json/mp/v1/comments?type=comment', data, { token:true }); 251 | } 252 | 253 | /** 254 | * 投票表态 255 | * @param {object} args 参数, POST 文章 ID 及选项 ID 256 | * TOKEN 参数为 true ,需要用户授权使用 257 | * @return {promise} 258 | */ 259 | const votePosts = function(data) { 260 | return API.post('/wp-json/mp/v1/vote', data, { token:true }); 261 | } 262 | 263 | /** 264 | * 获取二维码 265 | * @param {object} args 参数 266 | * @return {promise} 267 | */ 268 | const getCodeImg = function(data) { 269 | return API.post('/wp-json/mp/v1/qrcode', data, { token: false }); 270 | } 271 | 272 | /** 273 | * 导航数据 274 | */ 275 | const getMenuSetting = function(data) { 276 | return API.get('/wp-json/mp/v1/menu', data); 277 | } 278 | 279 | /** 280 | * 首页广告数据 281 | */ 282 | const indexAdsense = function(data) { 283 | return API.get('/wp-json/mp/v1/advert?type=index', data); 284 | } 285 | 286 | /** 287 | * 列表广告数据 288 | */ 289 | const listAdsense = function(data) { 290 | return API.get('/wp-json/mp/v1/advert?type=list', data); 291 | } 292 | 293 | /** 294 | * 详情广告数据 295 | */ 296 | const detailAdsense = function(data) { 297 | return API.get('/wp-json/mp/v1/advert?type=detail', data); 298 | } 299 | 300 | /** 301 | * 页面广告数据 302 | */ 303 | const pageAdsense = function(data) { 304 | return API.get('/wp-json/mp/v1/advert?type=page', data); 305 | } 306 | 307 | API.getSiteInfo = getSiteInfo 308 | API.getStickyPosts = getStickyPosts 309 | API.getPostsList = getPostsList 310 | API.getPostsbyID = getPostsbyID 311 | API.getPagesList = getPagesList 312 | API.getPageByID = getPageByID 313 | API.getCategories = getCategories 314 | API.getCategoryByID = getCategoryByID 315 | API.getTags = getTags 316 | API.getTagByID = getTagByID 317 | API.getRandPosts = getRandPosts 318 | API.getRelatePosts = getRelatePosts 319 | API.getMostViewsPosts = getMostViewsPosts 320 | API.getMostFavPosts = getMostFavPosts 321 | API.getMostLikePosts = getMostLikePosts 322 | API.getMostCommentPosts = getMostCommentPosts 323 | API.getRecentCommentPosts = getRecentCommentPosts 324 | API.getComments = getComments 325 | API.getProfile = API.guard(getProfile) 326 | API.fav = API.guard(fav) 327 | API.getFavPosts = API.guard(getFavPosts) 328 | API.like = API.guard(like) 329 | API.getLikePosts = API.guard(getLikePosts) 330 | API.getCommentsPosts = API.guard(getCommentsPosts) 331 | API.addComment = API.guard(addComment) 332 | API.votePosts = API.guard(votePosts) 333 | API.getCodeImg = getCodeImg 334 | API.Loginout = Loginout 335 | API.getMenuSetting = getMenuSetting 336 | API.indexAdsense = indexAdsense 337 | API.listAdsense = listAdsense 338 | API.detailAdsense = detailAdsense 339 | API.pageAdsense = pageAdsense 340 | 341 | module.exports = API -------------------------------------------------------------------------------- /qTravel/utils/auth.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Author : 丸子团队(波波、Chi、ONLINE.信) 3 | * Github 地址: https://github.com/dchijack/Travel-Mini-Program 4 | * GiTee 地址: https://gitee.com/izol/Travel-Mini-Program 5 | */ 6 | 7 | const Auth = {} 8 | 9 | /** 10 | * 获取当前登陆用户的openid 11 | * @return {string} 12 | */ 13 | Auth.openid = function() { 14 | const user = Auth.user() 15 | if (user && user.openid) { 16 | return user.openid 17 | } else { 18 | return '' 19 | } 20 | } 21 | 22 | /** 23 | * 获取当前登陆用户信息 24 | * @return {object} 25 | */ 26 | Auth.user = function() { 27 | return wx.getStorageSync('user'); 28 | } 29 | 30 | /** 31 | * 获取token 32 | * @return {string} 33 | */ 34 | Auth.token = function() { 35 | return wx.getStorageSync('token'); 36 | } 37 | 38 | /** 39 | * 判断token还是否在有效期内 40 | * @return {boolean} 41 | */ 42 | Auth.check = function() { 43 | let user = Auth.user() 44 | let token = Auth.token() 45 | if (user && Date.now() < wx.getStorageSync('expired_in') && token) { 46 | console.log('access_token过期时间:', (wx.getStorageSync('expired_in') - Date.now()) / 1000, '秒'); 47 | return true; 48 | } else { 49 | return false; 50 | } 51 | } 52 | 53 | /** 54 | * 登录 55 | * @return {Promise} 登录信息 56 | */ 57 | Auth.login = function() { 58 | return new Promise(function(resolve, reject) { 59 | wx.login({ 60 | success: function(res) { 61 | //console.log('wx.login.code', res.code); 62 | resolve(res); 63 | }, 64 | 65 | fail: function(err) { 66 | reject(err); 67 | } 68 | }); 69 | }); 70 | } 71 | 72 | /** 73 | * 通过 wx.login 获取code 74 | * @return code 75 | */ 76 | Auth.code = function(){ 77 | return new Promise(function(resolve, reject) { 78 | wx.login({ 79 | success: function(res){ 80 | resolve(res.code); 81 | }, 82 | 83 | fail: function(err) { 84 | reject(err); 85 | } 86 | }); 87 | }); 88 | } 89 | 90 | /** 91 | * 注销 92 | * @return {boolean} 93 | */ 94 | Auth.logout = function() { 95 | wx.removeStorageSync('user') 96 | wx.removeStorageSync('token') 97 | wx.removeStorageSync('expired_in') 98 | return true 99 | } 100 | 101 | /** 102 | * 获取授权登录加密数据 103 | */ 104 | Auth.getUserInfo = function(){ 105 | return new Promise(function(resolve, reject) { 106 | Auth.code().then(data => { 107 | let args = {} 108 | args.code = data; 109 | wx.getUserInfo({ 110 | success: function (res) { 111 | //console.log(res); 112 | args.iv = encodeURIComponent(res.iv); 113 | args.encryptedData = encodeURIComponent(res.encryptedData); 114 | resolve(args); 115 | }, 116 | fail: function (err) { 117 | reject(err); 118 | } 119 | }); 120 | }) 121 | }); 122 | } 123 | 124 | module.exports = Auth -------------------------------------------------------------------------------- /qTravel/utils/base.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Author : 丸子团队(波波、Chi、ONLINE.信) 3 | * Github 地址: https://github.com/dchijack/Travel-Mini-Program 4 | * GiTee 地址: https://gitee.com/izol/Travel-Mini-Program 5 | */ 6 | 7 | const API_HOST = 'https://cxcat.com' // 更换为你的网站域名, 需要有 https 协议 8 | const Auth = require('./auth') 9 | 10 | const API = {} 11 | 12 | API.getHost = function(){ 13 | return API_HOST; 14 | } 15 | 16 | API.request = function(url, method = "GET", data={}, args = { token: true, isPull: false }) { 17 | 18 | return new Promise(function(resolve, reject) { 19 | 20 | wx.showNavigationBarLoading() 21 | 22 | url = API_HOST + url; 23 | 24 | if (args.token) { 25 | const token = API.token(); 26 | if(token) { 27 | if(url.indexOf("?")>0) { 28 | url = url + '&access_token=' + token; 29 | } else { 30 | url = url + '?access_token=' + token; 31 | } 32 | } else { 33 | console.warn('[提示]','部分数据需要授权,检测出当前访问用户未授权登录小程序'); 34 | } 35 | } 36 | //console.log(url) 37 | //console.log(data) 38 | wx.request({ 39 | url: url, 40 | data: data, 41 | method: method, 42 | success: function(res) { 43 | console.log(res); 44 | if(res.statusCode == 200) { 45 | resolve(res.data); 46 | } else if(res.data.code === "rest_post_invalid_page_number") { 47 | wx.showToast({ 48 | title: '没有更多内容', 49 | mask: false, 50 | duration: 1000 51 | }); 52 | } else { 53 | wx.showToast({ 54 | title: "请求数据失败", 55 | duration: 1500 56 | }); 57 | console.log(res.data.message); 58 | reject(res.data); 59 | } 60 | wx.hideNavigationBarLoading() 61 | }, 62 | fail: function(err) { 63 | wx.hideNavigationBarLoading(); 64 | console.log(err); 65 | reject(err); 66 | } 67 | }) 68 | }); 69 | 70 | } 71 | 72 | API.get = function(url, data={}, args = { token: false }) { 73 | return API.request(url, "GET", data, args); 74 | } 75 | 76 | API.post = function(url, data, args = { token: true }) { 77 | return API.request(url, "POST", data, args); 78 | } 79 | 80 | API.getUser = function(){ 81 | if(Auth.check()){ 82 | return Auth.user(); 83 | }else{ 84 | return false; 85 | } 86 | 87 | } 88 | 89 | API.login = function() { 90 | return new Promise(function(resolve, reject) { 91 | if(Auth.check()){ 92 | resolve(Auth.user()); 93 | }else{ 94 | Auth.login().then(data=>{ 95 | API.post('/wp-json/mp/v1/user/openid', data, { token: false }).then(res => { 96 | API.storageUser(res); 97 | //console.log(res); 98 | resolve(res); 99 | }, err => { 100 | reject(err); 101 | }); 102 | }).catch( err =>{ 103 | reject(err); 104 | }) 105 | } 106 | }); 107 | } 108 | 109 | API.logout = function() { 110 | let logout = Auth.logout(); 111 | if(logout) { 112 | getApp().globalData.user = ''; 113 | } else { 114 | wx.showToast({ 115 | title: '注销失败!', 116 | icon: 'warn', 117 | duration: 1000, 118 | }) 119 | } 120 | } 121 | 122 | API.getUserInfo = function() { 123 | return new Promise(function(resolve, reject) { 124 | Auth.getUserInfo().then(data=>{ 125 | API.post('/wp-json/mp/v1/tencent/login', data, { token: false }).then(res => { 126 | API.storageUser(res); 127 | console.log(res); 128 | resolve(res.user); 129 | }, err => { 130 | reject(err); 131 | }); 132 | }) 133 | .catch( err =>{ 134 | //console.log(err); 135 | reject(err); 136 | }) 137 | }); 138 | } 139 | 140 | API.token = function() { 141 | let token = Auth.token(); 142 | let datetime = Date.now(); 143 | if(token && datetime < wx.getStorageSync('expired_in')) { 144 | return token; 145 | } else { 146 | return false; 147 | } 148 | } 149 | 150 | API.storageUser = function(res) { 151 | getApp().globalData.user = res.user; 152 | wx.setStorageSync('user', res.user); 153 | wx.setStorageSync('openid', res.openid); 154 | if(res.access_token){ 155 | wx.setStorageSync('token', res.access_token); 156 | wx.setStorageSync('expired_in', Date.now() + parseInt(res.expired_in, 10) * 100000 - 60000); 157 | } 158 | } 159 | 160 | /** 161 | * 需要授权的接口调用 162 | * @param {Function} fn 163 | * @return {Promise} 164 | */ 165 | API.guard = function(fn) { 166 | const self = this 167 | return function() { 168 | if(API.getUser()) { 169 | return fn.apply(self, arguments) 170 | } else { 171 | return API.getUserInfo().then(res => { 172 | console.log('登录成功', res); 173 | return fn.apply(self, arguments) 174 | }, err => { 175 | console.log('登录失败', err); 176 | return err 177 | }) 178 | } 179 | } 180 | } 181 | 182 | module.exports = API -------------------------------------------------------------------------------- /qTravel/utils/util.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Author : 丸子团队(波波、Chi、ONLINE.信) 3 | * Github 地址: https://github.com/dchijack/Travel-Mini-Program 4 | * GiTee 地址: https://gitee.com/izol/Travel-Mini-Program 5 | */ 6 | 7 | const formatTime = date => { 8 | const year = date.getFullYear() 9 | const month = date.getMonth() + 1 10 | const day = date.getDate() 11 | const hour = date.getHours() 12 | const minute = date.getMinutes() 13 | const second = date.getSeconds() 14 | 15 | return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':') 16 | } 17 | 18 | const formatNumber = n => { 19 | n = n.toString() 20 | return n[1] ? n : '0' + n 21 | } 22 | 23 | module.exports = { 24 | formatTime: formatTime 25 | } 26 | -------------------------------------------------------------------------------- /qTravel/wxParse/htmlparser.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * htmlParser改造自: https://github.com/blowsie/Pure-JavaScript-HTML5-Parser 4 | * 5 | * author: Di (微信小程序开发工程师) 6 | * organization: WeAppDev(微信小程序开发论坛)(http://weappdev.com) 7 | * 垂直微信小程序开发交流社区 8 | * 9 | * github地址: https://github.com/icindy/wxParse 10 | * 11 | * for: 微信小程序富文本解析 12 | * detail : http://weappdev.com/t/wxparse-alpha0-1-html-markdown/184 13 | */ 14 | // Regular Expressions for parsing tags and attributes 15 | var startTag = /^<([-A-Za-z0-9_]+)((?:\s+[a-zA-Z_:][-a-zA-Z0-9_:.]*(?:\s*=\s*(?:(?:"[^"]*")|(?:'[^']*')|[^>\s]+))?)*)\s*(\/?)>/, 16 | endTag = /^<\/([-A-Za-z0-9_]+)[^>]*>/, 17 | attr = /([a-zA-Z_:][-a-zA-Z0-9_:.]*)(?:\s*=\s*(?:(?:"((?:\\.|[^"])*)")|(?:'((?:\\.|[^'])*)')|([^>\s]+)))?/g; 18 | 19 | // Empty Elements - HTML 5 20 | var empty = makeMap("area,base,basefont,br,col,frame,hr,img,input,link,meta,param,embed,command,keygen,source,track,wbr"); 21 | 22 | // Block Elements - HTML 5 23 | var block = makeMap("a,address,code,article,applet,aside,audio,blockquote,button,canvas,center,dd,del,dir,div,dl,dt,fieldset,figcaption,figure,footer,form,frameset,h1,h2,h3,h4,h5,h6,header,hgroup,hr,iframe,ins,isindex,li,map,menu,noframes,noscript,object,ol,output,p,pre,section,script,table,tbody,td,tfoot,th,thead,tr,ul,video"); 24 | 25 | // Inline Elements - HTML 5 26 | var inline = makeMap("abbr,acronym,applet,b,basefont,bdo,big,br,button,cite,del,dfn,em,font,i,iframe,img,input,ins,kbd,label,map,object,q,s,samp,script,select,small,span,strike,strong,sub,sup,textarea,tt,u,var"); 27 | 28 | // Elements that you can, intentionally, leave open 29 | // (and which close themselves) 30 | var closeSelf = makeMap("colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr"); 31 | 32 | // Attributes that have their values filled in disabled="disabled" 33 | var fillAttrs = makeMap("checked,compact,declare,defer,disabled,ismap,multiple,nohref,noresize,noshade,nowrap,readonly,selected"); 34 | 35 | // Special Elements (can contain anything) 36 | var special = makeMap("wxxxcode-style,script,style,view,scroll-view,block"); 37 | 38 | function HTMLParser(html, handler) { 39 | var index, chars, match, stack = [], last = html; 40 | stack.last = function () { 41 | return this[this.length - 1]; 42 | }; 43 | 44 | while (html) { 45 | chars = true; 46 | 47 | // Make sure we're not in a script or style element 48 | if (!stack.last() || !special[stack.last()]) { 49 | 50 | // Comment 51 | if (html.indexOf(""); 53 | 54 | if (index >= 0) { 55 | if (handler.comment) 56 | handler.comment(html.substring(4, index)); 57 | html = html.substring(index + 3); 58 | chars = false; 59 | } 60 | 61 | // end tag 62 | } else if (html.indexOf("]*>"), function (all, text) { 100 | text = text.replace(/|/g, "$1$2"); 101 | if (handler.chars) 102 | handler.chars(text); 103 | 104 | return ""; 105 | }); 106 | 107 | 108 | parseEndTag("", stack.last()); 109 | } 110 | 111 | if (html == last) 112 | throw "Parse Error: " + html; 113 | last = html; 114 | } 115 | 116 | // Clean up any remaining tags 117 | parseEndTag(); 118 | 119 | function parseStartTag(tag, tagName, rest, unary) { 120 | tagName = tagName.toLowerCase(); 121 | 122 | if (block[tagName]) { 123 | while (stack.last() && inline[stack.last()]) { 124 | parseEndTag("", stack.last()); 125 | } 126 | } 127 | 128 | if (closeSelf[tagName] && stack.last() == tagName) { 129 | parseEndTag("", tagName); 130 | } 131 | 132 | unary = empty[tagName] || !!unary; 133 | 134 | if (!unary) 135 | stack.push(tagName); 136 | 137 | if (handler.start) { 138 | var attrs = []; 139 | 140 | rest.replace(attr, function (match, name) { 141 | var value = arguments[2] ? arguments[2] : 142 | arguments[3] ? arguments[3] : 143 | arguments[4] ? arguments[4] : 144 | fillAttrs[name] ? name : ""; 145 | 146 | attrs.push({ 147 | name: name, 148 | value: value, 149 | escaped: value.replace(/(^|[^\\])"/g, '$1\\\"') //" 150 | }); 151 | }); 152 | 153 | if (handler.start) { 154 | handler.start(tagName, attrs, unary); 155 | } 156 | 157 | } 158 | } 159 | 160 | function parseEndTag(tag, tagName) { 161 | // If no tag name is provided, clean shop 162 | if (!tagName) 163 | var pos = 0; 164 | 165 | // Find the closest opened tag of the same type 166 | else { 167 | tagName = tagName.toLowerCase(); 168 | for (var pos = stack.length - 1; pos >= 0; pos--) 169 | if (stack[pos] == tagName) 170 | break; 171 | } 172 | if (pos >= 0) { 173 | // Close all the open elements, up the stack 174 | for (var i = stack.length - 1; i >= pos; i--) 175 | if (handler.end) 176 | handler.end(stack[i]); 177 | 178 | // Remove the open elements from the stack 179 | stack.length = pos; 180 | } 181 | } 182 | }; 183 | 184 | 185 | function makeMap(str) { 186 | var obj = {}, items = str.split(","); 187 | for (var i = 0; i < items.length; i++) 188 | obj[items[i]] = true; 189 | return obj; 190 | } 191 | 192 | module.exports = HTMLParser; 193 | -------------------------------------------------------------------------------- /qTravel/wxParse/wxDiscode.js: -------------------------------------------------------------------------------- 1 | // HTML 支持的数学符号 2 | function strNumDiscode(str){ 3 | str = str.replace(/∀/g, '∀'); 4 | str = str.replace(/∂/g, '∂'); 5 | str = str.replace(/&exists;/g, '∃'); 6 | str = str.replace(/∅/g, '∅'); 7 | str = str.replace(/∇/g, '∇'); 8 | str = str.replace(/∈/g, '∈'); 9 | str = str.replace(/∉/g, '∉'); 10 | str = str.replace(/∋/g, '∋'); 11 | str = str.replace(/∏/g, '∏'); 12 | str = str.replace(/∑/g, '∑'); 13 | str = str.replace(/−/g, '−'); 14 | str = str.replace(/∗/g, '∗'); 15 | str = str.replace(/√/g, '√'); 16 | str = str.replace(/∝/g, '∝'); 17 | str = str.replace(/∞/g, '∞'); 18 | str = str.replace(/∠/g, '∠'); 19 | str = str.replace(/∧/g, '∧'); 20 | str = str.replace(/∨/g, '∨'); 21 | str = str.replace(/∩/g, '∩'); 22 | str = str.replace(/∩/g, '∪'); 23 | str = str.replace(/∫/g, '∫'); 24 | str = str.replace(/∴/g, '∴'); 25 | str = str.replace(/∼/g, '∼'); 26 | str = str.replace(/≅/g, '≅'); 27 | str = str.replace(/≈/g, '≈'); 28 | str = str.replace(/≠/g, '≠'); 29 | str = str.replace(/≤/g, '≤'); 30 | str = str.replace(/≥/g, '≥'); 31 | str = str.replace(/⊂/g, '⊂'); 32 | str = str.replace(/⊃/g, '⊃'); 33 | str = str.replace(/⊄/g, '⊄'); 34 | str = str.replace(/⊆/g, '⊆'); 35 | str = str.replace(/⊇/g, '⊇'); 36 | str = str.replace(/⊕/g, '⊕'); 37 | str = str.replace(/⊗/g, '⊗'); 38 | str = str.replace(/⊥/g, '⊥'); 39 | str = str.replace(/⋅/g, '⋅'); 40 | return str; 41 | } 42 | 43 | //HTML 支持的希腊字母 44 | function strGreeceDiscode(str){ 45 | str = str.replace(/Α/g, 'Α'); 46 | str = str.replace(/Β/g, 'Β'); 47 | str = str.replace(/Γ/g, 'Γ'); 48 | str = str.replace(/Δ/g, 'Δ'); 49 | str = str.replace(/Ε/g, 'Ε'); 50 | str = str.replace(/Ζ/g, 'Ζ'); 51 | str = str.replace(/Η/g, 'Η'); 52 | str = str.replace(/Θ/g, 'Θ'); 53 | str = str.replace(/Ι/g, 'Ι'); 54 | str = str.replace(/Κ/g, 'Κ'); 55 | str = str.replace(/Λ/g, 'Λ'); 56 | str = str.replace(/Μ/g, 'Μ'); 57 | str = str.replace(/Ν/g, 'Ν'); 58 | str = str.replace(/Ξ/g, 'Ν'); 59 | str = str.replace(/Ο/g, 'Ο'); 60 | str = str.replace(/Π/g, 'Π'); 61 | str = str.replace(/Ρ/g, 'Ρ'); 62 | str = str.replace(/Σ/g, 'Σ'); 63 | str = str.replace(/Τ/g, 'Τ'); 64 | str = str.replace(/Υ/g, 'Υ'); 65 | str = str.replace(/Φ/g, 'Φ'); 66 | str = str.replace(/Χ/g, 'Χ'); 67 | str = str.replace(/Ψ/g, 'Ψ'); 68 | str = str.replace(/Ω/g, 'Ω'); 69 | 70 | str = str.replace(/α/g, 'α'); 71 | str = str.replace(/β/g, 'β'); 72 | str = str.replace(/γ/g, 'γ'); 73 | str = str.replace(/δ/g, 'δ'); 74 | str = str.replace(/ε/g, 'ε'); 75 | str = str.replace(/ζ/g, 'ζ'); 76 | str = str.replace(/η/g, 'η'); 77 | str = str.replace(/θ/g, 'θ'); 78 | str = str.replace(/ι/g, 'ι'); 79 | str = str.replace(/κ/g, 'κ'); 80 | str = str.replace(/λ/g, 'λ'); 81 | str = str.replace(/μ/g, 'μ'); 82 | str = str.replace(/ν/g, 'ν'); 83 | str = str.replace(/ξ/g, 'ξ'); 84 | str = str.replace(/ο/g, 'ο'); 85 | str = str.replace(/π/g, 'π'); 86 | str = str.replace(/ρ/g, 'ρ'); 87 | str = str.replace(/ς/g, 'ς'); 88 | str = str.replace(/σ/g, 'σ'); 89 | str = str.replace(/τ/g, 'τ'); 90 | str = str.replace(/υ/g, 'υ'); 91 | str = str.replace(/φ/g, 'φ'); 92 | str = str.replace(/χ/g, 'χ'); 93 | str = str.replace(/ψ/g, 'ψ'); 94 | str = str.replace(/ω/g, 'ω'); 95 | str = str.replace(/ϑ/g, 'ϑ'); 96 | str = str.replace(/ϒ/g, 'ϒ'); 97 | str = str.replace(/ϖ/g, 'ϖ'); 98 | str = str.replace(/·/g, '·'); 99 | return str; 100 | } 101 | 102 | // 103 | 104 | function strcharacterDiscode(str){ 105 | // 加入常用解析 106 | str = str.replace(/ /g, ' '); 107 | str = str.replace(/"/g, "'"); 108 | str = str.replace(/&/g, '&'); 109 | // str = str.replace(/</g, '‹'); 110 | // str = str.replace(/>/g, '›'); 111 | 112 | str = str.replace(/</g, '<'); 113 | str = str.replace(/>/g, '>'); 114 | str = str.replace(/•/g, '•'); 115 | str = str.replace(/&/g, '&'); 116 | str = str.replace(/”/g, '"'); 117 | str = str.replace(/‘/g, '\''); 118 | str = str.replace(/’/g, '\''); 119 | str = str.replace(/'/g, '\''); 120 | str = str.replace(/…/g, '...'); 121 | str = str.replace(/“/g, '"'); 122 | str = str.replace(/&/g, '&'); 123 | str = str.replace(/–/g, '-'); 124 | str = str.replace(/—/g, '--'); 125 | 126 | 127 | 128 | return str; 129 | } 130 | 131 | // HTML 支持的其他实体 132 | function strOtherDiscode(str){ 133 | str = str.replace(/Œ/g, 'Œ'); 134 | str = str.replace(/œ/g, 'œ'); 135 | str = str.replace(/Š/g, 'Š'); 136 | str = str.replace(/š/g, 'š'); 137 | str = str.replace(/Ÿ/g, 'Ÿ'); 138 | str = str.replace(/ƒ/g, 'ƒ'); 139 | str = str.replace(/ˆ/g, 'ˆ'); 140 | str = str.replace(/˜/g, '˜'); 141 | str = str.replace(/ /g, ''); 142 | str = str.replace(/ /g, ''); 143 | str = str.replace(/ /g, ''); 144 | str = str.replace(/‌/g, ''); 145 | str = str.replace(/‍/g, ''); 146 | str = str.replace(/‎/g, ''); 147 | str = str.replace(/‏/g, ''); 148 | str = str.replace(/–/g, '–'); 149 | str = str.replace(/—/g, '—'); 150 | str = str.replace(/‘/g, '‘'); 151 | str = str.replace(/’/g, '’'); 152 | str = str.replace(/‚/g, '‚'); 153 | str = str.replace(/“/g, '“'); 154 | str = str.replace(/”/g, '”'); 155 | str = str.replace(/„/g, '„'); 156 | str = str.replace(/†/g, '†'); 157 | str = str.replace(/‡/g, '‡'); 158 | str = str.replace(/•/g, '•'); 159 | str = str.replace(/…/g, '…'); 160 | str = str.replace(/‰/g, '‰'); 161 | str = str.replace(/′/g, '′'); 162 | str = str.replace(/″/g, '″'); 163 | str = str.replace(/‹/g, '‹'); 164 | str = str.replace(/›/g, '›'); 165 | str = str.replace(/‾/g, '‾'); 166 | str = str.replace(/€/g, '€'); 167 | str = str.replace(/™/g, '™'); 168 | 169 | str = str.replace(/←/g, '←'); 170 | str = str.replace(/↑/g, '↑'); 171 | str = str.replace(/→/g, '→'); 172 | str = str.replace(/↓/g, '↓'); 173 | str = str.replace(/↔/g, '↔'); 174 | str = str.replace(/↵/g, '↵'); 175 | str = str.replace(/⌈/g, '⌈'); 176 | str = str.replace(/⌉/g, '⌉'); 177 | 178 | str = str.replace(/⌊/g, '⌊'); 179 | str = str.replace(/⌋/g, '⌋'); 180 | str = str.replace(/◊/g, '◊'); 181 | str = str.replace(/♠/g, '♠'); 182 | str = str.replace(/♣/g, '♣'); 183 | str = str.replace(/♥/g, '♥'); 184 | 185 | str = str.replace(/♦/g, '♦'); 186 | str = str.replace(/'/g, '\''); 187 | return str; 188 | } 189 | 190 | function strMoreDiscode(str){ 191 | str = str.replace(/\r\n/g,""); 192 | str = str.replace(/\n/g,""); 193 | 194 | //str = str.replace(/code/g,"wxxxcode-style"); 195 | return str; 196 | } 197 | 198 | function strDiscode(str){ 199 | str = strNumDiscode(str); 200 | str = strGreeceDiscode(str); 201 | str = strcharacterDiscode(str); 202 | str = strOtherDiscode(str); 203 | //str = strMoreDiscode(str); 204 | return str; 205 | } 206 | function urlToHttpUrl(url,rep){ 207 | 208 | var patt1 = new RegExp("^//"); 209 | var result = patt1.test(url); 210 | if(result){ 211 | url = rep+":"+url; 212 | } 213 | return url; 214 | } 215 | 216 | module.exports = { 217 | strDiscode:strDiscode, 218 | urlToHttpUrl:urlToHttpUrl 219 | } -------------------------------------------------------------------------------- /qTravel/wxParse/wxParse.js: -------------------------------------------------------------------------------- 1 | /** 2 | * author: Di (微信小程序开发工程师) 3 | * organization: WeAppDev(微信小程序开发论坛)(http://weappdev.com) 4 | * 垂直微信小程序开发交流社区 5 | * 6 | * github地址: https://github.com/icindy/wxParse 7 | * 8 | * for: 微信小程序富文本解析 9 | * detail : http://weappdev.com/t/wxparse-alpha0-1-html-markdown/184 10 | */ 11 | 12 | /** 13 | * utils函数引入 14 | **/ 15 | import showdown from './showdown.js'; 16 | import HtmlToJson from './html2json.js'; 17 | /** 18 | * 配置及公有属性 19 | **/ 20 | var realWindowWidth = 0; 21 | var realWindowHeight = 0; 22 | wx.getSystemInfo({ 23 | success: function (res) { 24 | realWindowWidth = res.windowWidth 25 | realWindowHeight = res.windowHeight 26 | } 27 | }) 28 | /** 29 | * 主函数入口区 30 | **/ 31 | function wxParse(bindName = 'wxParseData', type='html', data='
数据不能为空
', target,imagePadding) { 32 | var that = target; 33 | var transData = {};//存放转化后的数据 34 | if (type == 'html') { 35 | transData = HtmlToJson.html2json(data, bindName); 36 | // console.log(JSON.stringify(transData, ' ', ' ')); 37 | } else if (type == 'md' || type == 'markdown') { 38 | var converter = new showdown.Converter(); 39 | var html = converter.makeHtml(data); 40 | transData = HtmlToJson.html2json(html, bindName); 41 | // console.log(JSON.stringify(transData, ' ', ' ')); 42 | } 43 | transData.view = {}; 44 | transData.view.imagePadding = 0; 45 | if(typeof(imagePadding) != 'undefined'){ 46 | transData.view.imagePadding = imagePadding 47 | } 48 | var bindData = {}; 49 | bindData[bindName] = transData; 50 | that.setData(bindData) 51 | that.wxParseImgLoad = wxParseImgLoad; 52 | that.wxParseImgTap = wxParseImgTap; 53 | } 54 | // 图片点击事件 55 | function wxParseImgTap(e) { 56 | var that = this; 57 | var nowImgUrl = e.target.dataset.src; 58 | var tagFrom = e.target.dataset.from; 59 | if (typeof (tagFrom) != 'undefined' && tagFrom.length > 0) { 60 | wx.previewImage({ 61 | current: nowImgUrl, // 当前显示图片的http链接 62 | urls: that.data[tagFrom].imageUrls // 需要预览的图片http链接列表 63 | }) 64 | } 65 | } 66 | 67 | /** 68 | * 图片视觉宽高计算函数区 69 | **/ 70 | function wxParseImgLoad(e) { 71 | var that = this; 72 | var tagFrom = e.target.dataset.from; 73 | var idx = e.target.dataset.idx; 74 | if (typeof (tagFrom) != 'undefined' && tagFrom.length > 0) { 75 | calMoreImageInfo(e, idx, that, tagFrom) 76 | } 77 | } 78 | // 假循环获取计算图片视觉最佳宽高 79 | function calMoreImageInfo(e, idx, that, bindName) { 80 | var temData = that.data[bindName]; 81 | if (!temData || temData.images.length == 0) { 82 | return; 83 | } 84 | var temImages = temData.images; 85 | //因为无法获取view宽度 需要自定义padding进行计算,稍后处理 86 | var recal = wxAutoImageCal(e.detail.width, e.detail.height,that,bindName); 87 | // temImages[idx].width = recal.imageWidth; 88 | // temImages[idx].height = recal.imageheight; 89 | // temData.images = temImages; 90 | // var bindData = {}; 91 | // bindData[bindName] = temData; 92 | // that.setData(bindData); 93 | var index = temImages[idx].index 94 | var key = `${bindName}` 95 | for (var i of index.split('.')) key+=`.nodes[${i}]` 96 | var keyW = key + '.width' 97 | var keyH = key + '.height' 98 | that.setData({ 99 | [keyW]: recal.imageWidth, 100 | [keyH]: recal.imageheight, 101 | }) 102 | } 103 | 104 | // 计算视觉优先的图片宽高 105 | function wxAutoImageCal(originalWidth, originalHeight,that,bindName) { 106 | //获取图片的原始长宽 107 | var windowWidth = 0, windowHeight = 0; 108 | var autoWidth = 0, autoHeight = 0; 109 | var results = {}; 110 | var padding = that.data[bindName].view.imagePadding; 111 | windowWidth = realWindowWidth-2*padding; 112 | windowHeight = realWindowHeight; 113 | //判断按照那种方式进行缩放 114 | // console.log("windowWidth" + windowWidth); 115 | if (originalWidth > windowWidth) {//在图片width大于手机屏幕width时候 116 | autoWidth = windowWidth; 117 | // console.log("autoWidth" + autoWidth); 118 | autoHeight = (autoWidth * originalHeight) / originalWidth; 119 | // console.log("autoHeight" + autoHeight); 120 | results.imageWidth = autoWidth; 121 | results.imageheight = autoHeight; 122 | } else {//否则展示原来的数据 123 | results.imageWidth = originalWidth; 124 | results.imageheight = originalHeight; 125 | } 126 | return results; 127 | } 128 | 129 | function wxParseTemArray(temArrayName,bindNameReg,total,that){ 130 | var array = []; 131 | var temData = that.data; 132 | var obj = null; 133 | for(var i = 0; i < total; i++){ 134 | var simArr = temData[bindNameReg+i].nodes; 135 | array.push(simArr); 136 | } 137 | 138 | temArrayName = temArrayName || 'wxParseTemArray'; 139 | obj = JSON.parse('{"'+ temArrayName +'":""}'); 140 | obj[temArrayName] = array; 141 | that.setData(obj); 142 | } 143 | 144 | /** 145 | * 配置emojis 146 | * 147 | */ 148 | 149 | /* function emojisInit(reg='',baseSrc="/wxParse/emojis/",emojis){ 150 | HtmlToJson.emojisInit(reg,baseSrc,emojis); 151 | } */ 152 | 153 | module.exports = { 154 | wxParse: wxParse, 155 | wxParseTemArray:wxParseTemArray, 156 | //emojisInit:emojisInit 157 | } 158 | 159 | 160 | -------------------------------------------------------------------------------- /qTravel/wxParse/wxParse.wxss: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * author: Di (微信小程序开发工程师) 4 | * organization: WeAppDev(微信小程序开发论坛)(http://weappdev.com) 5 | * 垂直微信小程序开发交流社区 6 | * 7 | * github地址: https://github.com/icindy/wxParse 8 | * 9 | * for: 微信小程序富文本解析 10 | * detail : http://weappdev.com/t/wxparse-alpha0-1-html-markdown/184 11 | */ 12 | 13 | .wxParse{ 14 | margin: 0 5px; 15 | font-family: Helvetica,sans-serif; 16 | font-size: 28rpx; 17 | color: #666; 18 | line-height: 1.8; 19 | } 20 | view{ 21 | word-break:break-all; 22 | } 23 | .wxParse-inline{ 24 | display: inline; 25 | margin: 0; 26 | padding: 0; 27 | } 28 | /*//标题 */ 29 | .wxParse-div{margin: 0;padding: 0;} 30 | .wxParse-h1{ font-size:2em; margin: .67em 0 } 31 | .wxParse-h2{ font-size:1.5em; margin: .75em 0 } 32 | .wxParse-h3{ font-size:1.17em; margin: .83em 0 } 33 | .wxParse-h4{ margin: 1.12em 0} 34 | .wxParse-h5 { font-size:.83em; margin: 1.5em 0 } 35 | .wxParse-h6{ font-size:.75em; margin: 1.67em 0 } 36 | 37 | .wxParse-h1 { 38 | font-size: 18px; 39 | font-weight: 400; 40 | margin-bottom: .9em; 41 | } 42 | .wxParse-h2 { 43 | font-size: 16px; 44 | font-weight: 400; 45 | margin-bottom: .34em; 46 | } 47 | .wxParse-h3 { 48 | font-weight: 400; 49 | font-size: 15px; 50 | margin-bottom: .34em; 51 | } 52 | .wxParse-h4 { 53 | font-weight: 400; 54 | font-size: 14px; 55 | margin-bottom: .24em; 56 | } 57 | .wxParse-h5 { 58 | font-weight: 400; 59 | font-size: 13px; 60 | margin-bottom: .14em; 61 | } 62 | .wxParse-h6 { 63 | font-weight: 400; 64 | font-size: 12px; 65 | margin-bottom: .04em; 66 | } 67 | 68 | .wxParse-h1, .wxParse-h2, .wxParse-h3, .wxParse-h4, .wxParse-h5, .wxParse-h6, .wxParse-b, .wxParse-strong { font-weight: bolder } 69 | 70 | .wxParse-i,.wxParse-cite,.wxParse-em,.wxParse-var,.wxParse-address{font-style:italic} 71 | .wxParse-pre,.wxParse-tt,.wxParse-code,.wxParse-kbd,.wxParse-samp{font-family:monospace} 72 | .wxParse-pre{white-space:pre} 73 | .wxParse-big{font-size:1.17em} 74 | .wxParse-small,.wxParse-sub,.wxParse-sup{font-size:.83em} 75 | .wxParse-sub{vertical-align:sub} 76 | .wxParse-sup{vertical-align:super} 77 | .wxParse-s,.wxParse-strike,.wxParse-del{text-decoration:line-through} 78 | /*wxparse-自定义个性化的css样式*/ 79 | /*增加video的css样式*/ 80 | .wxParse-strong,.wxParse-s{display: inline} 81 | .wxParse-a{ 82 | color: deepskyblue; 83 | word-break:break-all; 84 | overflow:auto; 85 | } 86 | 87 | .wxParse-video{ 88 | text-align: center; 89 | margin: 10px 0; 90 | } 91 | 92 | .wxParse-video-video{ 93 | width:100%; 94 | } 95 | 96 | .wxParse-img{ 97 | /*background-color: #efefef;*/ 98 | overflow: hidden; 99 | } 100 | 101 | .wxParse-blockquote { 102 | margin: 0; 103 | padding:10px 0 10px 5px; 104 | font-family:Courier, Calibri,"宋体"; 105 | background:#f5f5f5; 106 | border-left: 3px solid #dbdbdb; 107 | } 108 | 109 | .wxParse-code,.wxParse-wxxxcode-style{ 110 | display: inline; 111 | background:#f5f5f5; 112 | } 113 | .wxParse-ul{ 114 | margin: 20rpx 10rpx; 115 | } 116 | 117 | .wxParse-li,.wxParse-li-inner{ 118 | display: flex; 119 | align-items: baseline; 120 | margin: 10rpx 0; 121 | } 122 | .wxParse-li-text{ 123 | 124 | align-items: center; 125 | line-height: 20px; 126 | } 127 | 128 | .wxParse-li-circle{ 129 | display: inline-flex; 130 | width: 5px; 131 | height: 5px; 132 | background-color: #333; 133 | margin-right: 5px; 134 | } 135 | 136 | .wxParse-li-square{ 137 | display: inline-flex; 138 | width: 10rpx; 139 | height: 10rpx; 140 | background-color: #333; 141 | margin-right: 5px; 142 | } 143 | .wxParse-li-ring{ 144 | display: inline-flex; 145 | width: 10rpx; 146 | height: 10rpx; 147 | border: 2rpx solid #333; 148 | border-radius: 50%; 149 | background-color: #fff; 150 | margin-right: 5px; 151 | } 152 | 153 | /*.wxParse-table{ 154 | width: 100%; 155 | height: 400px; 156 | } 157 | .wxParse-thead,.wxParse-tfoot,.wxParse-tr{ 158 | display: flex; 159 | flex-direction: row; 160 | } 161 | .wxParse-th,.wxParse-td{ 162 | display: flex; 163 | width: 580px; 164 | overflow: auto; 165 | }*/ 166 | 167 | .wxParse-u { 168 | text-decoration: underline; 169 | } 170 | .wxParse-hide{ 171 | display: none; 172 | } 173 | .WxEmojiView{ 174 | align-items: center; 175 | } 176 | .wxEmoji{ 177 | width: 16px; 178 | height:16px; 179 | } 180 | .wxParse-tr{ 181 | display: flex; 182 | border-right:1px solid #e0e0e0; 183 | border-bottom:1px solid #e0e0e0; 184 | border-top:1px solid #e0e0e0; 185 | } 186 | .wxParse-th, 187 | .wxParse-td{ 188 | flex:1; 189 | padding:5px; 190 | font-size:28rpx; 191 | border-left:1px solid #e0e0e0; 192 | word-break: break-all; 193 | } 194 | .wxParse-td:last{ 195 | border-top:1px solid #e0e0e0; 196 | } 197 | .wxParse-th{ 198 | background:#f0f0f0; 199 | border-top:1px solid #e0e0e0; 200 | } 201 | .wxParse-del{ 202 | display: inline; 203 | } 204 | .wxParse-figure { 205 | overflow: hidden; 206 | } 207 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # WordPress Travel Mini Program 2 | 3 | > 标签:旅游、笔记、博客 4 | 5 | 基于 WordPress Mini Program API 插件创建的 WordPress 小程序之 Travel 主题,包括微信小程序及 QQ 小程序。虽然说是旅游类型,但是同样也适用于日记类型小程序,博客类型小程序。 6 | 7 | # WordPress Mini Program API 插件 8 | 9 | 由 丸子小程序团队 基于 WordPress REST 创建小程序应用 API 数据接口。免费开源,实现 WordPress 连接小程序应用数据。插件地址:[点击这里访问](https://github.com/dchijack/wp-mini-program) 10 | 11 | # WordPress Travel Mini Program 说明 12 | 13 | 1. 两个文件夹分别为微信小程序前端及 QQ 小程序前端 14 | 2. weTravel 为微信小程序前端,qTravel 为 QQ 小程序前端,插件支持两个小程序前端 15 | 16 | ## 安装指南 17 | 18 | 1. 点击 Clone or download 下拉选择 Download ZIP 或者[点击这里](https://github.com/dchijack/Travel-Mini-Program/releases)下载源码包 19 | 20 | 2. 解压压缩包后, 打开 weTravel / qTravel 文件夹 utils 目录下的 base.js 21 | 22 | 3. 修改 base.js 里的 **const API_HOST = '你的域名'** // 注意,域名需要填写协议,比如 https://cxcat.com 23 | 24 | 4. 登录微信公众号小程序后台 - 开发 - 服务器配置 ,把你的域名加入 request 域名 25 | 26 | 5. 登录网站后台, 在仪表盘下方的小程序设置里,填写上对应的 AppID 和 AppScret 27 | 28 | 6. 然后使用微信开发者工具导入 weTravel 目录进行开发调试, 使用 QQ 小程序开发者工具导入 qTravel 目录进行开发调试 29 | 30 | ## 预览截图 31 | 32 | ![小程序截图](https://github.com/dchijack/Travel-Mini-Program/blob/master/screenshot/20190722154321.jpg) 33 | 34 | ![小程序截图](https://github.com/dchijack/Travel-Mini-Program/blob/master/screenshot/20190722154328.jpg) 35 | 36 | ![小程序截图](https://github.com/dchijack/Travel-Mini-Program/blob/master/screenshot/20190722154336.jpg) 37 | 38 | ![小程序截图](https://github.com/dchijack/Travel-Mini-Program/blob/master/screenshot/20190722154402.jpg) 39 | 40 | ![小程序截图](https://github.com/dchijack/Travel-Mini-Program/blob/master/screenshot/20190722154355.jpg) 41 | 42 | ![小程序截图](https://github.com/dchijack/Travel-Mini-Program/blob/master/screenshot/20190722154348.jpg) 43 | 44 | ## 预览体验 45 | 46 | 关注微信公众号 WordPressTalk ,点击菜单 小程序集合 - 丸子旅游 47 | 48 | ![微信公众号二维码](https://github.com/dchijack/WP-REST-API/blob/master/qrcode.jpg) 49 | 50 | ## 讨论交流群 51 | 52 | 由于讨论交流群已经满了 100 人, 无法扫描二维码加入,可以扫描下方二维码添加好友,由群主拉入群。添加好友时,请注明:开源 53 | 54 | ![二维码](https://github.com/dchijack/Travel-Mini-Program/blob/master/screenshot/20190723104521.jpg) -------------------------------------------------------------------------------- /screenshot/20190722154321.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/webzol/Travel-Mini-Program/792602f4047fc9b9f811e287e1d1859089506fb3/screenshot/20190722154321.jpg -------------------------------------------------------------------------------- /screenshot/20190722154328.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/webzol/Travel-Mini-Program/792602f4047fc9b9f811e287e1d1859089506fb3/screenshot/20190722154328.jpg -------------------------------------------------------------------------------- /screenshot/20190722154336.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/webzol/Travel-Mini-Program/792602f4047fc9b9f811e287e1d1859089506fb3/screenshot/20190722154336.jpg -------------------------------------------------------------------------------- /screenshot/20190722154348.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/webzol/Travel-Mini-Program/792602f4047fc9b9f811e287e1d1859089506fb3/screenshot/20190722154348.jpg -------------------------------------------------------------------------------- /screenshot/20190722154355.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/webzol/Travel-Mini-Program/792602f4047fc9b9f811e287e1d1859089506fb3/screenshot/20190722154355.jpg -------------------------------------------------------------------------------- /screenshot/20190722154402.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/webzol/Travel-Mini-Program/792602f4047fc9b9f811e287e1d1859089506fb3/screenshot/20190722154402.jpg -------------------------------------------------------------------------------- /screenshot/20190723104521.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/webzol/Travel-Mini-Program/792602f4047fc9b9f811e287e1d1859089506fb3/screenshot/20190723104521.jpg -------------------------------------------------------------------------------- /weTravel/app.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Author : 丸子团队(波波、Chi、ONLINE.信) 3 | * Github 地址: https://github.com/dchijack/Travel-Mini-Program 4 | * GiTee 地址: https://gitee.com/izol/Travel-Mini-Program 5 | */ 6 | //app.js 7 | const API = require('/utils/base') 8 | 9 | App({ 10 | 11 | onLaunch: function () { 12 | API.login(); 13 | // 获取系统状态栏信息 14 | wx.getSystemInfo({ 15 | success: e => { 16 | this.globalData.StatusBar = e.statusBarHeight; 17 | this.globalData.CustomBar = e.platform == 'android' ? e.statusBarHeight + 50 : e.statusBarHeight + 45; 18 | } 19 | }) 20 | }, 21 | 22 | onShow: function () { 23 | this.globalData.user = API.getUser(); 24 | }, 25 | 26 | globalData: { 27 | user: '', 28 | skin: '', 29 | color: '', 30 | StatusBar: '', 31 | CustomBar: '' 32 | } 33 | 34 | }) -------------------------------------------------------------------------------- /weTravel/app.json: -------------------------------------------------------------------------------- 1 | { 2 | "pages": [ 3 | "pages/index/index", 4 | "pages/detail/detail", 5 | "pages/list/list", 6 | "pages/logs/logs", 7 | "pages/category/category", 8 | "pages/mine/mine", 9 | "pages/mine/mypost" 10 | ], 11 | "window": { 12 | "backgroundTextStyle": "light", 13 | "navigationBarBackgroundColor": "#fff", 14 | "navigationBarTitleText": "丸子社区", 15 | "navigationBarTextStyle": "black" 16 | }, 17 | "tabBar": { 18 | "color": "#AAAAAA", 19 | "selectedColor": "#262626", 20 | "borderStyle": "black", 21 | "backgroundColor": "#fff", 22 | "list": [ 23 | { 24 | "text": "首页", 25 | "pagePath": "pages/index/index", 26 | "iconPath": "images/ic_index.png", 27 | "selectedIconPath": "images/ic_index_on.png" 28 | }, 29 | { 30 | "text": "栏目", 31 | "pagePath": "pages/category/category", 32 | "iconPath": "images/ic_huoban.png", 33 | "selectedIconPath": "images/ic_huoban_on.png" 34 | }, 35 | { 36 | "text": "我的", 37 | "pagePath": "pages/mine/mine", 38 | "iconPath": "images/ic_user.png", 39 | "selectedIconPath": "images/ic_user_on.png" 40 | } 41 | ] 42 | }, 43 | "sitemapLocation": "sitemap.json" 44 | } -------------------------------------------------------------------------------- /weTravel/app.wxss: -------------------------------------------------------------------------------- 1 | button::after { 2 | border-radius: 0; 3 | border: none; 4 | } -------------------------------------------------------------------------------- /weTravel/images/cate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/webzol/Travel-Mini-Program/792602f4047fc9b9f811e287e1d1859089506fb3/weTravel/images/cate.png -------------------------------------------------------------------------------- /weTravel/images/detail/bottom_bar_back.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/webzol/Travel-Mini-Program/792602f4047fc9b9f811e287e1d1859089506fb3/weTravel/images/detail/bottom_bar_back.png -------------------------------------------------------------------------------- /weTravel/images/detail/bottom_bar_comment.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/webzol/Travel-Mini-Program/792602f4047fc9b9f811e287e1d1859089506fb3/weTravel/images/detail/bottom_bar_comment.png -------------------------------------------------------------------------------- /weTravel/images/detail/bottom_bar_share.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/webzol/Travel-Mini-Program/792602f4047fc9b9f811e287e1d1859089506fb3/weTravel/images/detail/bottom_bar_share.png -------------------------------------------------------------------------------- /weTravel/images/detail/collect.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/webzol/Travel-Mini-Program/792602f4047fc9b9f811e287e1d1859089506fb3/weTravel/images/detail/collect.png -------------------------------------------------------------------------------- /weTravel/images/detail/collected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/webzol/Travel-Mini-Program/792602f4047fc9b9f811e287e1d1859089506fb3/weTravel/images/detail/collected.png -------------------------------------------------------------------------------- /weTravel/images/detail/collects.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/webzol/Travel-Mini-Program/792602f4047fc9b9f811e287e1d1859089506fb3/weTravel/images/detail/collects.png -------------------------------------------------------------------------------- /weTravel/images/detail/messageListNodata.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/webzol/Travel-Mini-Program/792602f4047fc9b9f811e287e1d1859089506fb3/weTravel/images/detail/messageListNodata.png -------------------------------------------------------------------------------- /weTravel/images/detail/quan_like.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/webzol/Travel-Mini-Program/792602f4047fc9b9f811e287e1d1859089506fb3/weTravel/images/detail/quan_like.png -------------------------------------------------------------------------------- /weTravel/images/detail/quan_liked.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/webzol/Travel-Mini-Program/792602f4047fc9b9f811e287e1d1859089506fb3/weTravel/images/detail/quan_liked.png -------------------------------------------------------------------------------- /weTravel/images/detail/share_icon1.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 分享海报-下载 5 | Created with Sketch. 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /weTravel/images/detail/share_icon2.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 分享海报-给朋友 5 | Created with Sketch. 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /weTravel/images/detail/voice.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/webzol/Travel-Mini-Program/792602f4047fc9b9f811e287e1d1859089506fb3/weTravel/images/detail/voice.gif -------------------------------------------------------------------------------- /weTravel/images/detail/voice.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/webzol/Travel-Mini-Program/792602f4047fc9b9f811e287e1d1859089506fb3/weTravel/images/detail/voice.png -------------------------------------------------------------------------------- /weTravel/images/ic_huoban.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/webzol/Travel-Mini-Program/792602f4047fc9b9f811e287e1d1859089506fb3/weTravel/images/ic_huoban.png -------------------------------------------------------------------------------- /weTravel/images/ic_huoban_on.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/webzol/Travel-Mini-Program/792602f4047fc9b9f811e287e1d1859089506fb3/weTravel/images/ic_huoban_on.png -------------------------------------------------------------------------------- /weTravel/images/ic_index.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/webzol/Travel-Mini-Program/792602f4047fc9b9f811e287e1d1859089506fb3/weTravel/images/ic_index.png -------------------------------------------------------------------------------- /weTravel/images/ic_index_on.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/webzol/Travel-Mini-Program/792602f4047fc9b9f811e287e1d1859089506fb3/weTravel/images/ic_index_on.png -------------------------------------------------------------------------------- /weTravel/images/ic_user.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/webzol/Travel-Mini-Program/792602f4047fc9b9f811e287e1d1859089506fb3/weTravel/images/ic_user.png -------------------------------------------------------------------------------- /weTravel/images/ic_user_on.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/webzol/Travel-Mini-Program/792602f4047fc9b9f811e287e1d1859089506fb3/weTravel/images/ic_user_on.png -------------------------------------------------------------------------------- /weTravel/images/lanmu@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/webzol/Travel-Mini-Program/792602f4047fc9b9f811e287e1d1859089506fb3/weTravel/images/lanmu@2x.png -------------------------------------------------------------------------------- /weTravel/images/messageListNodata.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/webzol/Travel-Mini-Program/792602f4047fc9b9f811e287e1d1859089506fb3/weTravel/images/messageListNodata.png -------------------------------------------------------------------------------- /weTravel/pages/category/category.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Author : 丸子团队(波波、Chi、ONLINE.信) 3 | * Github 地址: https://github.com/dchijack/Travel-Mini-Program 4 | * GiTee 地址: https://gitee.com/izol/Travel-Mini-Program 5 | */ 6 | // pages/category/category.js 7 | const API = require('../../utils/api') 8 | 9 | 10 | Page({ 11 | 12 | /** 13 | * 页面的初始数据 14 | */ 15 | data: { 16 | 17 | }, 18 | 19 | /** 20 | * 生命周期函数--监听页面加载 21 | */ 22 | onLoad: function (options) { 23 | this.getCategories(); 24 | }, 25 | getCategories: function () { 26 | API.getCategories().then(res => { 27 | this.setData({ 28 | category: res 29 | }) 30 | }) 31 | }, 32 | 33 | goClassByid: function (e) { 34 | let id = e.currentTarget.id; 35 | wx.navigateTo({ 36 | url: '/pages/list/list?id=' + id, 37 | }) 38 | }, 39 | /** 40 | * 生命周期函数--监听页面初次渲染完成 41 | */ 42 | onReady: function () { 43 | 44 | }, 45 | 46 | /** 47 | * 生命周期函数--监听页面显示 48 | */ 49 | onShow: function () { 50 | 51 | }, 52 | 53 | /** 54 | * 生命周期函数--监听页面隐藏 55 | */ 56 | onHide: function () { 57 | 58 | }, 59 | 60 | /** 61 | * 生命周期函数--监听页面卸载 62 | */ 63 | onUnload: function () { 64 | 65 | }, 66 | 67 | /** 68 | * 页面相关事件处理函数--监听用户下拉动作 69 | */ 70 | onPullDownRefresh: function () { 71 | 72 | }, 73 | 74 | /** 75 | * 页面上拉触底事件的处理函数 76 | */ 77 | onReachBottom: function () { 78 | 79 | }, 80 | 81 | /** 82 | * 用户点击右上角分享 83 | */ 84 | onShareAppMessage: function () { 85 | 86 | } 87 | }) -------------------------------------------------------------------------------- /weTravel/pages/category/category.json: -------------------------------------------------------------------------------- 1 | { 2 | "enablePullDownRefresh": true, 3 | "navigationBarTitleText": "分类栏目", 4 | "usingComponents": {} 5 | } -------------------------------------------------------------------------------- /weTravel/pages/category/category.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | {{item.name}} 10 | 11 | {{item.description}} 12 | 13 | 14 | 15 | 了解更多 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /weTravel/pages/category/category.wxss: -------------------------------------------------------------------------------- 1 | .is-flex { 2 | display: flex; 3 | } 4 | 5 | .center-xs { 6 | justify-content: center; 7 | text-align: center; 8 | } 9 | 10 | .end-xs { 11 | justify-content: flex-end; 12 | text-align: end; 13 | } 14 | 15 | .section { 16 | padding: 40rpx; 17 | padding-bottom: 48rpx; 18 | } 19 | 20 | .direction-vert { 21 | flex-direction: column; 22 | } 23 | 24 | .section-features { 25 | padding-bottom: 14px; 26 | } 27 | 28 | .section-features .feature-list { 29 | width: 100%; 30 | max-width: 750rpx; 31 | } 32 | 33 | .section-features .feature-list .feature-card { 34 | padding-bottom: 40rpx; 35 | position: relative; 36 | font-weight: 300; 37 | font-size: 18px; 38 | flex: 1 0 auto; 39 | } 40 | 41 | .middle-xs { 42 | align-items: center; 43 | } 44 | 45 | .section-features .feature-list .feature-card .card-cover { 46 | width: 100%; 47 | padding-top: 380rpx; 48 | max-width: 100%; 49 | background-size: cover; 50 | background-color: #f6f7f7; 51 | } 52 | 53 | .section-features .feature-list .feature-card { 54 | width: 100%; 55 | } 56 | 57 | .section-features .feature-list .feature-card .card-main { 58 | background-color: #f6f7f7; 59 | } 60 | 61 | .section-features .feature-list .feature-card .card-main { 62 | position: relative; 63 | padding: 0; 64 | padding-top: 280rpx; 65 | -webkit-transform: translate3d(0, 0, 0) !important; 66 | transform: translate3d(0, 0, 0) !important; 67 | text-align: left; 68 | } 69 | 70 | .section-features .feature-list .feature-card .card-main .card-top { 71 | padding: 30rpx 29rpx; 72 | position: absolute; 73 | top: 0; 74 | } 75 | 76 | .section-features .feature-list .feature-card .card-title { 77 | font-size: 38rpx; 78 | line-height: 44rpx; 79 | font-weight: 400; 80 | padding-top:20rpx; 81 | margin-bottom: 29.5rpx; 82 | } 83 | 84 | .section-features .feature-list .feature-card .card-content text { 85 | margin: 0; 86 | margin-bottom: 10px; 87 | font-size: 26rpx; 88 | } 89 | 90 | .section-features .feature-list .feature-card .card-main .card-actions { 91 | bottom: 0; 92 | right: 0; 93 | margin-right: 0; 94 | padding: 30rpx 29rpx; 95 | position: absolute; 96 | } 97 | 98 | .section-features .feature-list .feature-card .img-icon { 99 | width: 35rpx; 100 | height: 35rpx; 101 | margin-left: 15rpx; 102 | background-repeat: no-repeat; 103 | background-position: center; 104 | } 105 | 106 | .section-features .feature-list .feature-card .action-item { 107 | font-size: 30rpx; 108 | 109 | } 110 | -------------------------------------------------------------------------------- /weTravel/pages/detail/detail.json: -------------------------------------------------------------------------------- 1 | { 2 | "enablePullDownRefresh": true, 3 | "usingComponents": {} 4 | } -------------------------------------------------------------------------------- /weTravel/pages/index/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Author : 丸子团队(波波、Chi、ONLINE.信) 3 | * Github 地址: https://github.com/dchijack/Travel-Mini-Program 4 | * GiTee 地址: https://gitee.com/izol/Travel-Mini-Program 5 | */ 6 | 7 | const API = require('../../utils/api') 8 | 9 | Page({ 10 | 11 | /** 12 | * 页面的初始数据 13 | */ 14 | data: { 15 | posts: [], 16 | page:1, 17 | indicatorDots: !1, 18 | autoplay: !0, 19 | interval: 3e3, 20 | currentSwiper: 0, 21 | navBarHeight: wx.getSystemInfoSync().statusBarHeight, 22 | placeHolder: '输入你想知道的内容...', 23 | autoFocus: false, 24 | inputEnable: true, 25 | }, 26 | 27 | /** 28 | * 生命周期函数--监听页面加载 29 | */ 30 | onLoad: function(options) { 31 | let that=this; 32 | wx.getSystemInfo({ 33 | success: function (a) { 34 | that.setData({ 35 | isIphoneX: a.model.match(/iPhone X/gi) 36 | }); 37 | } 38 | }); 39 | this.getStickyPosts(); 40 | this.getPostList(); 41 | this.getCategories(); 42 | this.getSiteInfo(); 43 | }, 44 | 45 | getSiteInfo: function() { 46 | 47 | API.getSiteInfo().then(res => { 48 | this.setData({ 49 | siteInfo: res 50 | }) 51 | }) 52 | }, 53 | 54 | onInput: function(e) { 55 | this.setData({ 56 | searchKey: e.detail.value 57 | }) 58 | }, 59 | 60 | currentChange: function(e) { 61 | this.setData({ 62 | currentSwiper: e.detail.current 63 | }); 64 | }, 65 | 66 | getCategories: function() { 67 | API.getCategories().then(res => { 68 | this.setData({ 69 | category: res 70 | }) 71 | }) 72 | }, 73 | getStickyPosts: function() { 74 | API.getStickyPosts().then(res => { 75 | this.setData({ 76 | stickyPost: res 77 | }) 78 | }) 79 | }, 80 | goClassfication:function(){ 81 | wx.switchTab({ 82 | url: '/pages/category/category', 83 | }) 84 | }, 85 | 86 | getPostList: function(args) { 87 | API.getPostsList(args).then(res => { 88 | let args = {} 89 | if (res.length < 10) { 90 | this.setData({ 91 | isLastPage: true, 92 | loadtext: '到底啦', 93 | showloadmore: false 94 | }) 95 | } 96 | if (this.data.isPull) { 97 | args.posts = [].concat(this.data.posts, res) 98 | args.page = this.data.page + 1 99 | } else if (this.data.isBottom) { 100 | args.posts = [].concat(this.data.posts, res) 101 | args.page = this.data.page + 1 102 | } else { 103 | args.posts = [].concat(this.data.posts, res) 104 | args.page = this.data.page + 1 105 | } 106 | this.setData(args) 107 | }) 108 | 109 | }, 110 | 111 | goClassByid: function (e) { 112 | let id = e.currentTarget.id; 113 | wx.navigateTo({ 114 | url: '/pages/list/list?id=' + id, 115 | }) 116 | }, 117 | 118 | goArticleDetail: function(e) { 119 | let id = e.currentTarget.id; 120 | wx.navigateTo({ 121 | url: '/pages/detail/detail?id=' + id, 122 | }) 123 | }, 124 | 125 | onConfirm:function(e){ 126 | console.log(e); 127 | let s=e.detail.value; 128 | wx.navigateTo({ 129 | url: '/pages/list/list?s='+s, 130 | }) 131 | }, 132 | 133 | /** 134 | * 生命周期函数--监听页面初次渲染完成 135 | */ 136 | onReady: function() { 137 | 138 | }, 139 | 140 | /** 141 | * 生命周期函数--监听页面显示 142 | */ 143 | onShow: function() { 144 | 145 | }, 146 | 147 | /** 148 | * 生命周期函数--监听页面隐藏 149 | */ 150 | onHide: function() { 151 | 152 | }, 153 | 154 | /** 155 | * 生命周期函数--监听页面卸载 156 | */ 157 | onUnload: function() { 158 | 159 | }, 160 | 161 | onClear:function(){ 162 | this.setData({ 163 | searchKey:'', 164 | }) 165 | }, 166 | 167 | /** 168 | * 页面相关事件处理函数--监听用户下拉动作 169 | */ 170 | onPullDownRefresh: function() { 171 | this.setData({ 172 | posts:[], 173 | page:1, 174 | }) 175 | this.getPostList({ 176 | page: this.data.page 177 | }); 178 | wx.stopPullDownRefresh(); 179 | }, 180 | 181 | /** 182 | * 页面上拉触底事件的处理函数 183 | */ 184 | onReachBottom: function() { 185 | if (!this.data.isLastPage) { 186 | this.getPostList({ 187 | page:this.data.page 188 | }); 189 | } 190 | }, 191 | 192 | /** 193 | * 用户点击右上角分享 194 | */ 195 | onShareAppMessage: function() { 196 | let that=this; 197 | return { 198 | title:that.data.siteInfo.name , 199 | path: '/pages/index/index' 200 | } 201 | 202 | } 203 | }) -------------------------------------------------------------------------------- /weTravel/pages/index/index.json: -------------------------------------------------------------------------------- 1 | { 2 | "enablePullDownRefresh": true, 3 | "navigationStyle": "custom", 4 | "navigationBarTextStyle": "white", 5 | "usingComponents": {} 6 | } -------------------------------------------------------------------------------- /weTravel/pages/index/index.wxml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 19 | 20 | 21 | 为你精选 22 | 23 | 24 |
{{item.name}}
25 | 26 |
27 |
28 | 29 | 30 | 31 | 32 | 33 | 34 | {{item.category[0].name}} 35 | 36 | 37 | {{item.title.rendered}} 38 | {{item.excerpt.rendered}} 39 | 40 | 41 | 已经到底啦~ 42 | 努力加载中... 43 |
44 |
45 |
-------------------------------------------------------------------------------- /weTravel/pages/list/list.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Author : 丸子团队(波波、Chi、ONLINE.信) 3 | * Github 地址: https://github.com/dchijack/Travel-Mini-Program 4 | * GiTee 地址: https://gitee.com/izol/Travel-Mini-Program 5 | */ 6 | // pages/list/list.js 7 | const API = require('../../utils/api') 8 | 9 | Page({ 10 | 11 | /** 12 | * 页面的初始数据 13 | */ 14 | data: { 15 | posts: [], 16 | page: 1, 17 | isLoadAll: false, 18 | }, 19 | 20 | /** 21 | * 生命周期函数--监听页面加载 22 | */ 23 | onLoad: function(options) { 24 | let id = options.id; 25 | this.setData({ 26 | options: options, 27 | }) 28 | if (options.id) { 29 | this.getPostList({ 30 | categories: id, 31 | page: this.data.page 32 | }); 33 | this.getCategoryByID(options.id); 34 | } 35 | if (options.s) { 36 | this.getPostList({ 37 | search: options.s, 38 | page: this.data.page 39 | }); 40 | this.setData({ 41 | category: '关键词“' + options.s + '”的结果' 42 | }) 43 | } 44 | 45 | }, 46 | 47 | /** 48 | * 生命周期函数--监听页面初次渲染完成 49 | */ 50 | onReady: function() { 51 | 52 | }, 53 | 54 | getCategoryByID: function(id) { 55 | API.getCategoryByID(id).then(res => { 56 | this.setData({ 57 | category: res.name 58 | }) 59 | }) 60 | 61 | }, 62 | 63 | goArticleDetail: function(e) { 64 | let id = e.currentTarget.id; 65 | wx.navigateTo({ 66 | url: '/pages/detail/detail?id=' + id, 67 | }) 68 | }, 69 | 70 | getPostList: function(args) { 71 | API.getPostsList(args).then(res => { 72 | let args = {} 73 | if (res.length < 10) { 74 | this.setData({ 75 | isLastPage: true, 76 | loadtext: '到底啦', 77 | showloadmore: false 78 | }) 79 | } 80 | if (this.data.isPull) { 81 | args.posts = [].concat(this.data.posts, res) 82 | args.page = this.data.page + 1 83 | } else if (this.data.isBottom) { 84 | args.posts = [].concat(this.data.posts, res) 85 | args.page = this.data.page + 1 86 | } else { 87 | args.posts = [].concat(this.data.posts, res) 88 | args.page = this.data.page + 1 89 | args.isLoadAll = true 90 | } 91 | this.setData(args) 92 | }) 93 | }, 94 | 95 | 96 | /** 97 | * 生命周期函数--监听页面显示 98 | */ 99 | onShow: function() { 100 | 101 | }, 102 | 103 | /** 104 | * 生命周期函数--监听页面隐藏 105 | */ 106 | onHide: function() { 107 | 108 | }, 109 | 110 | /** 111 | * 生命周期函数--监听页面卸载 112 | */ 113 | onUnload: function() { 114 | 115 | }, 116 | 117 | /** 118 | * 页面相关事件处理函数--监听用户下拉动作 119 | */ 120 | onPullDownRefresh: function() { 121 | this.setData({ 122 | posts:[], 123 | page:1, 124 | }) 125 | if (this.data.options.id) { 126 | this.getPostList({ 127 | categories: this.data.options.id, 128 | page: this.data.page 129 | }); 130 | } 131 | if (this.data.options.s) { 132 | this.getPostList({ 133 | search: this.data.options.s, 134 | page: this.data.page 135 | }); 136 | } 137 | wx.stopPullDownRefresh(); 138 | 139 | }, 140 | 141 | /** 142 | * 页面上拉触底事件的处理函数 143 | */ 144 | onReachBottom: function() { 145 | if (!this.data.isLastPage) { 146 | if (this.data.options.id) { 147 | this.getPostList({ 148 | categories: this.data.options.id, 149 | page: this.data.page 150 | }); 151 | } 152 | if (this.data.options.s) { 153 | this.getPostList({ 154 | search: this.data.options.s, 155 | page: this.data.page 156 | }); 157 | } 158 | } 159 | }, 160 | 161 | /** 162 | * 用户点击右上角分享 163 | */ 164 | onShareAppMessage: function() { 165 | 166 | } 167 | }) -------------------------------------------------------------------------------- /weTravel/pages/list/list.json: -------------------------------------------------------------------------------- 1 | { 2 | "enablePullDownRefresh": true, 3 | "usingComponents": {} 4 | } -------------------------------------------------------------------------------- /weTravel/pages/list/list.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | {{category}} 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | {{item.category[0].name}} 14 | 15 | 16 | {{item.title.rendered}} 17 | {{item.excerpt.rendered}} 18 | 19 | 20 | 暂无内容 21 | 22 | 23 | 24 | 已经到底啦~ 25 | 努力加载中... 26 | 27 | 28 | -------------------------------------------------------------------------------- /weTravel/pages/list/list.wxss: -------------------------------------------------------------------------------- 1 | 2 | .page.iphone-x { 3 | padding-bottom: 20rpx; 4 | } 5 | 6 | .banner { 7 | position: relative; 8 | width: 100vw; 9 | height: 540rpx; 10 | z-index: 0; 11 | } 12 | 13 | .banner-bg { 14 | position: absolute; 15 | width: 100vw; 16 | bottom: 0; 17 | left: 0; 18 | } 19 | 20 | .banner::after { 21 | content: ""; 22 | display: block; 23 | height: 80rpx; 24 | width: 100vw; 25 | position: absolute; 26 | left: 0; 27 | bottom: 0; 28 | background-image: linear-gradient(180deg,rgba(255,255,255,0.00) 0%,#F9F9F9 100%); 29 | pointer-events: none; 30 | z-index: -1; 31 | } 32 | 33 | .banner-info { 34 | position: absolute; 35 | left: 0; 36 | right: 0; 37 | margin: 0 40rpx; 38 | } 39 | 40 | .banner-title { 41 | font-weight: bold; 42 | font-size: 58rpx; 43 | color: #000; 44 | line-height: 68rpx; 45 | } 46 | 47 | .banner-title_text { 48 | display: inline-block; 49 | vertical-align: middle; 50 | } 51 | 52 | .banner-avatar { 53 | position: relative; 54 | vertical-align: middle; 55 | float: right; 56 | } 57 | 58 | .avatar { 59 | width: 72rpx; 60 | height: 72rpx; 61 | border: 5rpx solid #fff; 62 | border-radius: 50%; 63 | background-size: cover; 64 | } 65 | 66 | .default-avatar { 67 | width: 72rpx; 68 | height: 72rpx; 69 | border: 5rpx solid #fff; 70 | border-radius: 50%; 71 | background-image: url(https://cloud-minapp-16269.cloud.ifanrusercontent.com/default-avator.jpg); 72 | background-size: cover; 73 | } 74 | 75 | .unread-message { 76 | display: block; 77 | position: absolute; 78 | right: 0; 79 | top: 0; 80 | pointer-events: none; 81 | } 82 | 83 | .banner-brief { 84 | font-size: 28rpx; 85 | color: #121212; 86 | line-height: 40rpx; 87 | margin-top: 20rpx; 88 | letter-spacing: 4rpx; 89 | } 90 | 91 | .ifanr-search { 92 | position: absolute; 93 | bottom: -20rpx; 94 | left: 40rpx; 95 | right: 40rpx; 96 | border-radius: 44rpx; 97 | box-shadow: 0 4rpx 20rpx 2rpx #FBEBD4; 98 | } 99 | 100 | 101 | .index { 102 | padding: 20rpx 36rpx; 103 | } 104 | 105 | .top_text { 106 | width: 100%; 107 | text-align: center; 108 | color: #AAA; 109 | font-size: 24rpx; 110 | } 111 | 112 | page::-webkit-scrollbar { 113 | display: none; 114 | } 115 | 116 | .slide_box { 117 | width: 678rpx; 118 | height: 280rpx; 119 | margin: 0 auto; 120 | box-shadow: 0rpx 2rpx 14rpx 0rpx rgba(38,38,38,0.1); 121 | } 122 | 123 | .slide_image { 124 | width: 678rpx; 125 | height: 280rpx; 126 | border-radius: 4rpx; 127 | } 128 | 129 | .dots { 130 | display: flex; 131 | flex-direction: row; 132 | justify-content: center; 133 | margin-top: 20rpx; 134 | } 135 | 136 | .dot { 137 | width: 20rpx; 138 | height: 4rpx; 139 | background: rgba(221,221,221,1); 140 | margin-right: 20rpx; 141 | } 142 | 143 | .active { 144 | width: 60rpx; 145 | height: 4rpx; 146 | background: rgba(38,38,38,1); 147 | } 148 | 149 | .category { 150 | padding: 30rpx 10rpx; 151 | } 152 | 153 | .index_label { 154 | position: relative; 155 | } 156 | 157 | .index_label_title { 158 | font-size: 48rpx; 159 | color: #262626; 160 | position: absolute; 161 | top: 0; 162 | left: 0; 163 | z-index: 1; 164 | } 165 | 166 | .index_label_bg { 167 | width: 160rpx; 168 | height: 12rpx; 169 | background: linear-gradient(270deg,rgba(249,228,135,0) 0%,rgba(241,197,79,1) 100%); 170 | border-radius: 11rpx; 171 | position: absolute; 172 | top: 48rpx; 173 | left: 0; 174 | } 175 | 176 | .index_label_more { 177 | position: absolute; 178 | right: 0; 179 | top: -14rpx; 180 | color: #888888; 181 | font-size: 28rpx; 182 | line-height: 48rpx; 183 | display: flex; 184 | flex-direction: row; 185 | align-items: center; 186 | } 187 | 188 | .index_comment_box { 189 | margin: 120rpx 30rpx 0 0; 190 | width: 100%; 191 | display: flex; 192 | flex-direction: row; 193 | flex-wrap: nowrap; 194 | overflow-x: scroll; 195 | -webkit-overflow-scrolling: touch; 196 | } 197 | 198 | .index_comment { 199 | background: rgba(246,247,249,1); 200 | border-radius: 4rpx; 201 | padding: 70rpx 40rpx 100rpx 40rpx; 202 | } 203 | 204 | .index_comment_hb { 205 | display: flex; 206 | flex-direction: row; 207 | } 208 | 209 | .index_comment_avatar { 210 | width: 70rpx; 211 | height: 70rpx; 212 | border-radius: 50%; 213 | background: #888888; 214 | } 215 | 216 | .index_comment_hb_name { 217 | color: #888888; 218 | font-size: 24rpx; 219 | line-height: 37rpx; 220 | } 221 | 222 | .index_comment_hb_title { 223 | color: #262626; 224 | font-size: 24rpx; 225 | line-height: 24rpx; 226 | margin-left: 6rpx; 227 | width: 220rpx; 228 | overflow: hidden; 229 | text-overflow: ellipsis; 230 | white-space: nowrap; 231 | } 232 | 233 | .index_comment_content { 234 | color: #262626; 235 | font-size: 32rpx; 236 | height: 240rpx; 237 | width: 340rpx; 238 | display: inline-block; 239 | margin-top: 50rpx; 240 | white-space: normal; 241 | display: -webkit-box; 242 | -webkit-box-orient: vertical; 243 | -webkit-line-clamp: 5; 244 | overflow: hidden; 245 | } 246 | 247 | .margin_right_30 { 248 | margin-right: 30rpx; 249 | } 250 | 251 | .margin_right_0 { 252 | margin-right: 0; 253 | } 254 | 255 | .index_article_cover { 256 | width: 678rpx; 257 | height: 380rpx; 258 | border-radius: 4rpx; 259 | } 260 | 261 | .index_article { 262 | margin-top: 80rpx; 263 | } 264 | 265 | .index_article_title { 266 | font-size: 36rpx; 267 | font-weight: 400; 268 | color: rgba(38,38,38,1); 269 | line-height: 50rpx; 270 | margin-top: 30rpx; 271 | width: 678rpx; 272 | overflow: hidden; 273 | text-overflow: ellipsis; 274 | white-space: nowrap; 275 | } 276 | 277 | .index_article_desc { 278 | color: #888888; 279 | font-size: 28rpx; 280 | margin-bottom: 70rpx; 281 | overflow: hidden; 282 | margin-top: 16rpx; 283 | text-overflow: ellipsis; 284 | display: -webkit-box; 285 | -webkit-line-clamp: 2; 286 | -webkit-box-orient: vertical; 287 | word-wrap: break-word; 288 | } 289 | 290 | .index_article_during { 291 | position: absolute; 292 | top: 326rpx; 293 | left: 16rpx; 294 | z-index: 1; 295 | width: 120rpx; 296 | height: 40rpx; 297 | background: rgba(38,38,38,1); 298 | border-radius: 4rpx; 299 | opacity: 0.9; 300 | text-align: center; 301 | line-height: 32rpx; 302 | } 303 | 304 | .index_article_during text { 305 | font-size: 22rpx; 306 | color: #fff; 307 | margin-left: 8rpx; 308 | } 309 | 310 | .last_text { 311 | width: 100%; 312 | text-align: center; 313 | color: #AAA; 314 | font-size: 24rpx; 315 | margin: 90rpx 0 30rpx; 316 | } 317 | 318 | .dialog .t1 { 319 | color: #262626; 320 | font-size: 36rpx; 321 | width: 100%; 322 | text-align: center; 323 | margin: 70rpx auto 50rpx; 324 | } 325 | 326 | .dialog .t2 { 327 | color: #888; 328 | font-size: 32rpx; 329 | width: 100%; 330 | text-align: center; 331 | } 332 | 333 | .dialog .t3 { 334 | width: 500rpx; 335 | height: 174rpx; 336 | border-top-left-radius: 0; 337 | border-top-right-radius: 0; 338 | } 339 | 340 | .dialog .t4 { 341 | display: flex; 342 | flex-direction: row; 343 | justify-content: space-around; 344 | padding: 0 30rpx; 345 | } 346 | 347 | .dialog .t4 .cancel { 348 | width: 240rpx; 349 | height: 70rpx; 350 | background: #fff; 351 | border: 1rpx solid #F1C54F; 352 | color: #F1C54F; 353 | text-align: center; 354 | line-height: 70rpx; 355 | } 356 | 357 | .dialog .t4 .go_set { 358 | width: 240rpx; 359 | height: 70rpx; 360 | background: rgba(241,197,79,1); 361 | color: #fff; 362 | text-align: center; 363 | line-height: 70rpx; 364 | } 365 | 366 | .ifanr-search { 367 | display: flex; 368 | flex-flow: row; 369 | background: #FFFFFF; 370 | box-shadow: 0 6rpx 8rpx 0 #F5F5F5; 371 | border-radius: 44rpx; 372 | height: 88rpx; 373 | justify-content: center; 374 | align-items: center; 375 | padding: 24rpx; 376 | box-sizing: border-box; 377 | } 378 | 379 | .search-icon { 380 | flex-grow: 0; 381 | flex-shrink: 0; 382 | width: 40rpx; 383 | height: 40rpx; 384 | background-image: url("https://cloud-minapp-16269.cloud.ifanrusercontent.com/product-search.svg"); 385 | background-size: contain; 386 | } 387 | 388 | .search-input { 389 | flex-grow: 1; 390 | flex-shrink: 1; 391 | overflow: hidden; 392 | text-overflow: ellipsis; 393 | white-space: nowrap; 394 | margin-left: 20rpx; 395 | font-size: 26rpx; 396 | color: #A8A8A8; 397 | } 398 | 399 | input.search-input { 400 | color: #222222; 401 | } 402 | 403 | search-input-placeholder { 404 | color: #A8A8A8; 405 | } 406 | 407 | .close-btn { 408 | width: 36rpx; 409 | height: 36rpx; 410 | margin-left: 24rpx; 411 | border-radius: 50%; 412 | opacity: 0.4; 413 | } -------------------------------------------------------------------------------- /weTravel/pages/logs/logs.js: -------------------------------------------------------------------------------- 1 | //logs.js 2 | const util = require('../../utils/util.js') 3 | 4 | Page({ 5 | data: { 6 | logs: [] 7 | }, 8 | onLoad: function () { 9 | this.setData({ 10 | logs: (wx.getStorageSync('logs') || []).map(log => { 11 | return util.formatTime(new Date(log)) 12 | }) 13 | }) 14 | } 15 | }) 16 | -------------------------------------------------------------------------------- /weTravel/pages/logs/logs.json: -------------------------------------------------------------------------------- 1 | { 2 | "navigationBarTitleText": "查看启动日志", 3 | "usingComponents": {} 4 | } -------------------------------------------------------------------------------- /weTravel/pages/logs/logs.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | {{index + 1}}. {{log}} 5 | 6 | 7 | -------------------------------------------------------------------------------- /weTravel/pages/logs/logs.wxss: -------------------------------------------------------------------------------- 1 | .log-list { 2 | display: flex; 3 | flex-direction: column; 4 | padding: 40rpx; 5 | } 6 | .log-item { 7 | margin: 10rpx; 8 | } 9 | -------------------------------------------------------------------------------- /weTravel/pages/mine/mine.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Author : 丸子团队(波波、Chi、ONLINE.信) 3 | * Github 地址: https://github.com/dchijack/Travel-Mini-Program 4 | * GiTee 地址: https://gitee.com/izol/Travel-Mini-Program 5 | */ 6 | // pages/mine/mine.js 7 | const API = require('../../utils/api') 8 | const app = getApp() 9 | Page({ 10 | 11 | /** 12 | * 页面的初始数据 13 | */ 14 | data: { 15 | 16 | }, 17 | 18 | /** 19 | * 生命周期函数--监听页面加载 20 | */ 21 | onLoad: function(options) { 22 | this.getSiteInfo(); 23 | }, 24 | 25 | /** 26 | * 生命周期函数--监听页面初次渲染完成 27 | */ 28 | onReady: function() { 29 | 30 | }, 31 | 32 | 33 | getSiteInfo: function () { 34 | 35 | API.getSiteInfo().then(res => { 36 | this.setData({ 37 | siteInfo: res 38 | }) 39 | }) 40 | }, 41 | 42 | 43 | getUserInfoFun: function (e) { 44 | console.log(e); 45 | if (e.detail.errMsg == "getUserInfo:ok") { 46 | this.getProfile(); 47 | wx.setStorageSync('user', e.detail) 48 | this.setData({ 49 | user: true, 50 | }) 51 | } 52 | else { 53 | return 54 | } 55 | 56 | 57 | }, 58 | 59 | mineHandler:function(e){ 60 | let url=e.currentTarget.dataset.url; 61 | wx.navigateTo({ 62 | url: url, 63 | }) 64 | }, 65 | 66 | getProfile: function (e) { 67 | console.log(e); 68 | API.getProfile().then(res => { 69 | console.log(res) 70 | this.setData({ 71 | user: res 72 | }) 73 | }) 74 | .catch(err => { 75 | console.log(err) 76 | wx.hideLoading() 77 | }) 78 | }, 79 | 80 | /** 81 | * 生命周期函数--监听页面显示 82 | */ 83 | onShow: function() { 84 | let user = app.globalData.user 85 | if (!user) { 86 | user = ''; 87 | } 88 | this.setData({ 89 | user: user, 90 | }) 91 | }, 92 | 93 | clear:function(){ 94 | 95 | wx.clearStorageSync(); 96 | wx.showToast({ 97 | title: '清除完毕', 98 | }) 99 | wx.switchTab({ 100 | url: '/pages/mine/mine', 101 | }) 102 | 103 | }, 104 | 105 | /** 106 | * 生命周期函数--监听页面隐藏 107 | */ 108 | onHide: function() { 109 | 110 | }, 111 | 112 | /** 113 | * 生命周期函数--监听页面卸载 114 | */ 115 | onUnload: function() { 116 | 117 | }, 118 | 119 | /** 120 | * 页面相关事件处理函数--监听用户下拉动作 121 | */ 122 | onPullDownRefresh: function() { 123 | 124 | }, 125 | 126 | /** 127 | * 页面上拉触底事件的处理函数 128 | */ 129 | onReachBottom: function() { 130 | 131 | }, 132 | 133 | /** 134 | * 用户点击右上角分享 135 | */ 136 | onShareAppMessage: function() { 137 | 138 | } 139 | }) -------------------------------------------------------------------------------- /weTravel/pages/mine/mine.json: -------------------------------------------------------------------------------- 1 | { 2 | "usingComponents": {} 3 | } -------------------------------------------------------------------------------- /weTravel/pages/mine/mine.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | {{user.nickName}} 8 | {{siteInfo.description}} 9 | 10 | 11 | 12 | 13 | 14 | 点击登录 15 | 使用微信登录 16 | 17 | 18 | 19 | 20 | 21 | 我的点赞 22 | 23 | 24 | {{unreadMessageCount}} 25 | 26 | 27 | 28 | 29 | 我的评论 30 | 31 | 32 | 33 | 34 | 35 | 36 | 我的收藏 37 | 38 | 39 | 40 | 41 | 42 | 43 | 问题反馈 44 | 45 | 46 | 47 | 48 | 49 | 50 | 清除缓存 51 | 52 | 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /weTravel/pages/mine/mine.wxss: -------------------------------------------------------------------------------- 1 | .user-container { 2 | background-color: #F5F7F9; 3 | overflow: hidden; 4 | box-sizing: border-box; 5 | padding-bottom: 68rpx; 6 | } 7 | 8 | .user-information { 9 | display: flex; 10 | padding: 48rpx 24rpx; 11 | margin: 24rpx 24rpx 0; 12 | background-color: #fff; 13 | border-radius: 16rpx; 14 | } 15 | 16 | .user-information_img { 17 | position: relative; 18 | width: 140rpx; 19 | height: 140rpx; 20 | border-radius: 50%; 21 | border: 4rpx solid #fff; 22 | overflow: hidden; 23 | background-size: cover; 24 | background-position: center; 25 | margin-right: 32rpx; 26 | overflow: hidden; 27 | } 28 | 29 | .nickname { 30 | flex: 1; 31 | display: inline-flex; 32 | flex-direction: column; 33 | justify-content: center; 34 | } 35 | 36 | .user-information_nickname { 37 | font-size: 44rpx; 38 | font-weight: bold; 39 | line-height: 60rpx; 40 | color: #121212; 41 | } 42 | 43 | .user-information_introduction { 44 | font-size: 28rpx; 45 | line-height: 40rpx; 46 | color: #7D7D7D; 47 | margin-top: 10rpx; 48 | opacity: .8; 49 | } 50 | 51 | .user-items { 52 | padding: 24rpx 40rpx; 53 | margin: 24rpx; 54 | border-radius: 16rpx; 55 | background-color: #fff; 56 | } 57 | 58 | .user-item { 59 | position: relative; 60 | height: 120rpx; 61 | line-height: 120rpx; 62 | font-size: 36rpx; 63 | color: #3A3A3A; 64 | border-bottom: 1rpx solid #E8E8E8; 65 | } 66 | 67 | .user-item:last-child { 68 | border-bottom: none; 69 | } 70 | 71 | .user-item_text { 72 | position: relative; 73 | z-index: 10; 74 | pointer-events: none; 75 | } 76 | 77 | .user-item_icon { 78 | position: relative; 79 | z-index: 10; 80 | float: right; 81 | vertical-align: middle; 82 | width: 60rpx; 83 | height: 100%; 84 | display: flex; 85 | flex-direction: column; 86 | justify-content: center; 87 | pointer-events: none; 88 | } 89 | 90 | .user-item_switch { 91 | float: right; 92 | transform: scale(0.8,.8); 93 | margin-right: -20rpx; 94 | } 95 | 96 | .user-item_icon_img { 97 | width: 100%; 98 | height: 60rpx; 99 | } 100 | 101 | .user-item_icon_sup { 102 | position: absolute; 103 | right: -1rpx; 104 | top: 24rpx; 105 | width: 32rpx; 106 | height: 32rpx; 107 | background: #F13B03; 108 | border: 2rpx solid #FFFFFF; 109 | border-radius: 50%; 110 | font-weight: bold; 111 | font-size: 24rpx; 112 | color: #FFFFFF; 113 | line-height: 32rpx; 114 | text-align: center; 115 | } 116 | 117 | .user-welfare { 118 | position: relative; 119 | margin: 54rpx 24rpx; 120 | height: 196rpx; 121 | } 122 | 123 | .user-welfare_img { 124 | width: 100%; 125 | height: 100%; 126 | } 127 | 128 | .my-login { 129 | width: 100%; 130 | height: 100%; 131 | position: absolute; 132 | top: 0; 133 | left: 0; 134 | background: none; 135 | } 136 | 137 | .my-login::after { 138 | border: none; 139 | } 140 | 141 | .auth-btn { 142 | position: absolute; 143 | width: 100%; 144 | height: 100%; 145 | top: 0; 146 | left: 0; 147 | right: 0; 148 | bottom: 0; 149 | background: transparent; 150 | padding: 0; 151 | text-align: left; 152 | line-height: 120rpx; 153 | color: #3A3A3A; 154 | } 155 | 156 | .auth-btn:after { 157 | border: none; 158 | } 159 | 160 | .separator { 161 | width: 100%; 162 | height: 24rpx; 163 | } -------------------------------------------------------------------------------- /weTravel/pages/mine/mypost.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Author : 丸子团队(波波、Chi、ONLINE.信) 3 | * Github 地址: https://github.com/dchijack/Travel-Mini-Program 4 | * GiTee 地址: https://gitee.com/izol/Travel-Mini-Program 5 | */ 6 | // pages/mine/mypost.js 7 | const API = require('../../utils/api') 8 | const app = getApp() 9 | Page({ 10 | 11 | /** 12 | * 页面的初始数据 13 | */ 14 | data: { 15 | posts:[], 16 | page: 1, 17 | }, 18 | 19 | /** 20 | * 生命周期函数--监听页面加载 21 | */ 22 | onLoad: function(options) { 23 | if (options.id == 3) { 24 | this.setData({ 25 | category: '我的收藏' 26 | }) 27 | this.getFavPosts(); 28 | } else if (options.id == 1) { 29 | this.setData({ 30 | category: '我的点赞' 31 | }) 32 | this.getLikePosts(); 33 | } else if (options.id == 2) { 34 | this.setData({ 35 | category: '我的评论' 36 | }) 37 | this.getCommentsPosts(); 38 | } 39 | }, 40 | 41 | getFavPosts: function(args) { 42 | API.getFavPosts(args).then(res => { 43 | let args = {} 44 | if (res.length < 10) { 45 | this.setData({ 46 | isLastPage: true, 47 | loadtext: '到底啦', 48 | showloadmore: false 49 | }) 50 | } 51 | if (this.data.isPull) { 52 | args.posts = [].concat(this.data.posts, res) 53 | args.page = this.data.page + 1 54 | } else if (this.data.isBottom) { 55 | args.posts = [].concat(this.data.posts, res) 56 | args.page = this.data.page + 1 57 | } else { 58 | args.posts = [].concat(this.data.posts, res) 59 | args.page = this.data.page + 1 60 | } 61 | this.setData(args) 62 | }) 63 | 64 | }, 65 | getCommentsPosts: function(args) { 66 | API.getCommentsPosts(args).then(res => { 67 | let args = {} 68 | if (res.length < 10) { 69 | this.setData({ 70 | isLastPage: true, 71 | loadtext: '到底啦', 72 | showloadmore: false 73 | }) 74 | } 75 | if (this.data.isPull) { 76 | args.posts = [].concat(this.data.posts, res) 77 | args.page = this.data.page + 1 78 | } else if (this.data.isBottom) { 79 | args.posts = [].concat(this.data.posts, res) 80 | args.page = this.data.page + 1 81 | } else { 82 | args.posts = [].concat(this.data.posts, res) 83 | args.page = this.data.page + 1 84 | } 85 | this.setData(args) 86 | }) 87 | 88 | }, 89 | getLikePosts: function(args) { 90 | API.getLikePosts(args).then(res => { 91 | let args = {} 92 | if (res.length < 10) { 93 | this.setData({ 94 | isLastPage: true, 95 | loadtext: '到底啦', 96 | showloadmore: false 97 | }) 98 | } 99 | if (this.data.isPull) { 100 | args.posts = [].concat(this.data.posts, res) 101 | args.page = this.data.page + 1 102 | } else if (this.data.isBottom) { 103 | args.posts = [].concat(this.data.posts, res) 104 | args.page = this.data.page + 1 105 | } else { 106 | args.posts = [].concat(this.data.posts, res) 107 | args.page = this.data.page + 1 108 | } 109 | this.setData(args) 110 | }) 111 | 112 | }, 113 | 114 | goArticleDetail: function (e) { 115 | let id = e.currentTarget.id; 116 | wx.navigateTo({ 117 | url: '/pages/detail/detail?id=' + id, 118 | }) 119 | }, 120 | /** 121 | * 生命周期函数--监听页面初次渲染完成 122 | */ 123 | onReady: function() { 124 | 125 | }, 126 | 127 | /** 128 | * 生命周期函数--监听页面显示 129 | */ 130 | onShow: function() { 131 | 132 | }, 133 | 134 | /** 135 | * 生命周期函数--监听页面隐藏 136 | */ 137 | onHide: function() { 138 | 139 | }, 140 | 141 | /** 142 | * 生命周期函数--监听页面卸载 143 | */ 144 | onUnload: function() { 145 | 146 | }, 147 | 148 | /** 149 | * 页面相关事件处理函数--监听用户下拉动作 150 | */ 151 | onPullDownRefresh: function() { 152 | 153 | }, 154 | 155 | /** 156 | * 页面上拉触底事件的处理函数 157 | */ 158 | onReachBottom: function() { 159 | 160 | }, 161 | 162 | /** 163 | * 用户点击右上角分享 164 | */ 165 | onShareAppMessage: function() { 166 | 167 | } 168 | }) -------------------------------------------------------------------------------- /weTravel/pages/mine/mypost.json: -------------------------------------------------------------------------------- 1 | { 2 | "usingComponents": {} 3 | } -------------------------------------------------------------------------------- /weTravel/pages/mine/mypost.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | {{category}} 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | {{item.category[0].name}} 14 | 15 | 16 | {{item.title.rendered}} 17 | {{item.excerpt.rendered}} 18 | 19 | 20 | 暂无内容 21 | 22 | 23 | 24 | 已经到底啦~ 25 | 努力加载中... 26 | 27 | 28 | -------------------------------------------------------------------------------- /weTravel/pages/mine/mypost.wxss: -------------------------------------------------------------------------------- 1 | 2 | .page.iphone-x { 3 | padding-bottom: 20rpx; 4 | } 5 | 6 | .banner { 7 | position: relative; 8 | width: 100vw; 9 | height: 540rpx; 10 | z-index: 0; 11 | } 12 | 13 | .banner-bg { 14 | position: absolute; 15 | width: 100vw; 16 | bottom: 0; 17 | left: 0; 18 | } 19 | 20 | .banner::after { 21 | content: ""; 22 | display: block; 23 | height: 80rpx; 24 | width: 100vw; 25 | position: absolute; 26 | left: 0; 27 | bottom: 0; 28 | background-image: linear-gradient(180deg,rgba(255,255,255,0.00) 0%,#F9F9F9 100%); 29 | pointer-events: none; 30 | z-index: -1; 31 | } 32 | 33 | .banner-info { 34 | position: absolute; 35 | left: 0; 36 | right: 0; 37 | margin: 0 40rpx; 38 | } 39 | 40 | .banner-title { 41 | font-weight: bold; 42 | font-size: 58rpx; 43 | color: #000; 44 | line-height: 68rpx; 45 | } 46 | 47 | .banner-title_text { 48 | display: inline-block; 49 | vertical-align: middle; 50 | } 51 | 52 | .banner-avatar { 53 | position: relative; 54 | vertical-align: middle; 55 | float: right; 56 | } 57 | 58 | .avatar { 59 | width: 72rpx; 60 | height: 72rpx; 61 | border: 5rpx solid #fff; 62 | border-radius: 50%; 63 | background-size: cover; 64 | } 65 | 66 | .default-avatar { 67 | width: 72rpx; 68 | height: 72rpx; 69 | border: 5rpx solid #fff; 70 | border-radius: 50%; 71 | background-image: url(https://cloud-minapp-16269.cloud.ifanrusercontent.com/default-avator.jpg); 72 | background-size: cover; 73 | } 74 | 75 | .unread-message { 76 | display: block; 77 | position: absolute; 78 | right: 0; 79 | top: 0; 80 | pointer-events: none; 81 | } 82 | 83 | .banner-brief { 84 | font-size: 28rpx; 85 | color: #121212; 86 | line-height: 40rpx; 87 | margin-top: 20rpx; 88 | letter-spacing: 4rpx; 89 | } 90 | 91 | .ifanr-search { 92 | position: absolute; 93 | bottom: -20rpx; 94 | left: 40rpx; 95 | right: 40rpx; 96 | border-radius: 44rpx; 97 | box-shadow: 0 4rpx 20rpx 2rpx #FBEBD4; 98 | } 99 | 100 | 101 | .index { 102 | padding: 20rpx 36rpx; 103 | } 104 | 105 | .top_text { 106 | width: 100%; 107 | text-align: center; 108 | color: #AAA; 109 | font-size: 24rpx; 110 | } 111 | 112 | page::-webkit-scrollbar { 113 | display: none; 114 | } 115 | 116 | .slide_box { 117 | width: 678rpx; 118 | height: 280rpx; 119 | margin: 0 auto; 120 | box-shadow: 0rpx 2rpx 14rpx 0rpx rgba(38,38,38,0.1); 121 | } 122 | 123 | .slide_image { 124 | width: 678rpx; 125 | height: 280rpx; 126 | border-radius: 4rpx; 127 | } 128 | 129 | .dots { 130 | display: flex; 131 | flex-direction: row; 132 | justify-content: center; 133 | margin-top: 20rpx; 134 | } 135 | 136 | .dot { 137 | width: 20rpx; 138 | height: 4rpx; 139 | background: rgba(221,221,221,1); 140 | margin-right: 20rpx; 141 | } 142 | 143 | .active { 144 | width: 60rpx; 145 | height: 4rpx; 146 | background: rgba(38,38,38,1); 147 | } 148 | 149 | .category { 150 | padding: 30rpx 10rpx; 151 | } 152 | 153 | .index_label { 154 | position: relative; 155 | } 156 | 157 | .index_label_title { 158 | font-size: 48rpx; 159 | color: #262626; 160 | position: absolute; 161 | top: 0; 162 | left: 0; 163 | z-index: 1; 164 | } 165 | 166 | .index_label_bg { 167 | width: 160rpx; 168 | height: 12rpx; 169 | background: linear-gradient(270deg,rgba(249,228,135,0) 0%,rgba(241,197,79,1) 100%); 170 | border-radius: 11rpx; 171 | position: absolute; 172 | top: 48rpx; 173 | left: 0; 174 | } 175 | 176 | .index_label_more { 177 | position: absolute; 178 | right: 0; 179 | top: -14rpx; 180 | color: #888888; 181 | font-size: 28rpx; 182 | line-height: 48rpx; 183 | display: flex; 184 | flex-direction: row; 185 | align-items: center; 186 | } 187 | 188 | .index_comment_box { 189 | margin: 120rpx 30rpx 0 0; 190 | width: 100%; 191 | display: flex; 192 | flex-direction: row; 193 | flex-wrap: nowrap; 194 | overflow-x: scroll; 195 | -webkit-overflow-scrolling: touch; 196 | } 197 | 198 | .index_comment { 199 | background: rgba(246,247,249,1); 200 | border-radius: 4rpx; 201 | padding: 70rpx 40rpx 100rpx 40rpx; 202 | } 203 | 204 | .index_comment_hb { 205 | display: flex; 206 | flex-direction: row; 207 | } 208 | 209 | .index_comment_avatar { 210 | width: 70rpx; 211 | height: 70rpx; 212 | border-radius: 50%; 213 | background: #888888; 214 | } 215 | 216 | .index_comment_hb_name { 217 | color: #888888; 218 | font-size: 24rpx; 219 | line-height: 37rpx; 220 | } 221 | 222 | .index_comment_hb_title { 223 | color: #262626; 224 | font-size: 24rpx; 225 | line-height: 24rpx; 226 | margin-left: 6rpx; 227 | width: 220rpx; 228 | overflow: hidden; 229 | text-overflow: ellipsis; 230 | white-space: nowrap; 231 | } 232 | 233 | .index_comment_content { 234 | color: #262626; 235 | font-size: 32rpx; 236 | height: 240rpx; 237 | width: 340rpx; 238 | display: inline-block; 239 | margin-top: 50rpx; 240 | white-space: normal; 241 | display: -webkit-box; 242 | -webkit-box-orient: vertical; 243 | -webkit-line-clamp: 5; 244 | overflow: hidden; 245 | } 246 | 247 | .margin_right_30 { 248 | margin-right: 30rpx; 249 | } 250 | 251 | .margin_right_0 { 252 | margin-right: 0; 253 | } 254 | 255 | .index_video_cover { 256 | width: 678rpx; 257 | height: 380rpx; 258 | border-radius: 4rpx; 259 | } 260 | 261 | .index_video { 262 | margin-top: 80rpx; 263 | } 264 | 265 | .index_video_title { 266 | font-size: 36rpx; 267 | font-weight: 400; 268 | color: rgba(38,38,38,1); 269 | line-height: 50rpx; 270 | margin-top: 30rpx; 271 | width: 678rpx; 272 | overflow: hidden; 273 | text-overflow: ellipsis; 274 | white-space: nowrap; 275 | } 276 | 277 | .index_video_desc { 278 | color: #888888; 279 | font-size: 28rpx; 280 | margin-bottom: 70rpx; 281 | overflow: hidden; 282 | margin-top: 16rpx; 283 | text-overflow: ellipsis; 284 | display: -webkit-box; 285 | -webkit-line-clamp: 2; 286 | -webkit-box-orient: vertical; 287 | word-wrap: break-word; 288 | } 289 | 290 | .index_video_during { 291 | position: absolute; 292 | top: 326rpx; 293 | left: 16rpx; 294 | z-index: 1; 295 | width: 120rpx; 296 | height: 40rpx; 297 | background: rgba(38,38,38,1); 298 | border-radius: 4rpx; 299 | opacity: 0.9; 300 | text-align: center; 301 | line-height: 32rpx; 302 | } 303 | 304 | .index_video_during text { 305 | font-size: 22rpx; 306 | color: #fff; 307 | margin-left: 8rpx; 308 | } 309 | 310 | .last_text { 311 | width: 100%; 312 | text-align: center; 313 | color: #AAA; 314 | font-size: 24rpx; 315 | margin: 90rpx 0 30rpx; 316 | } 317 | 318 | .dialog .t1 { 319 | color: #262626; 320 | font-size: 36rpx; 321 | width: 100%; 322 | text-align: center; 323 | margin: 70rpx auto 50rpx; 324 | } 325 | 326 | .dialog .t2 { 327 | color: #888; 328 | font-size: 32rpx; 329 | width: 100%; 330 | text-align: center; 331 | } 332 | 333 | .dialog .t3 { 334 | width: 500rpx; 335 | height: 174rpx; 336 | border-top-left-radius: 0; 337 | border-top-right-radius: 0; 338 | } 339 | 340 | .dialog .t4 { 341 | display: flex; 342 | flex-direction: row; 343 | justify-content: space-around; 344 | padding: 0 30rpx; 345 | } 346 | 347 | .dialog .t4 .cancel { 348 | width: 240rpx; 349 | height: 70rpx; 350 | background: #fff; 351 | border: 1rpx solid #F1C54F; 352 | color: #F1C54F; 353 | text-align: center; 354 | line-height: 70rpx; 355 | } 356 | 357 | .dialog .t4 .go_set { 358 | width: 240rpx; 359 | height: 70rpx; 360 | background: rgba(241,197,79,1); 361 | color: #fff; 362 | text-align: center; 363 | line-height: 70rpx; 364 | } 365 | 366 | .ifanr-search { 367 | display: flex; 368 | flex-flow: row; 369 | background: #FFFFFF; 370 | box-shadow: 0 6rpx 8rpx 0 #F5F5F5; 371 | border-radius: 44rpx; 372 | height: 88rpx; 373 | justify-content: center; 374 | align-items: center; 375 | padding: 24rpx; 376 | box-sizing: border-box; 377 | } 378 | 379 | .search-icon { 380 | flex-grow: 0; 381 | flex-shrink: 0; 382 | width: 40rpx; 383 | height: 40rpx; 384 | background-image: url("https://cloud-minapp-16269.cloud.ifanrusercontent.com/product-search.svg"); 385 | background-size: contain; 386 | } 387 | 388 | .search-input { 389 | flex-grow: 1; 390 | flex-shrink: 1; 391 | overflow: hidden; 392 | text-overflow: ellipsis; 393 | white-space: nowrap; 394 | margin-left: 20rpx; 395 | font-size: 26rpx; 396 | color: #A8A8A8; 397 | } 398 | 399 | input.search-input { 400 | color: #222222; 401 | } 402 | 403 | search-input-placeholder { 404 | color: #A8A8A8; 405 | } 406 | 407 | .close-btn { 408 | width: 36rpx; 409 | height: 36rpx; 410 | margin-left: 24rpx; 411 | border-radius: 50%; 412 | opacity: 0.4; 413 | }/* pages/mine/mypost.wxss */ -------------------------------------------------------------------------------- /weTravel/project.config.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "项目配置文件", 3 | "packOptions": { 4 | "ignore": [] 5 | }, 6 | "setting": { 7 | "urlCheck": true, 8 | "es6": true, 9 | "postcss": false, 10 | "minified": false, 11 | "newFeature": true, 12 | "autoAudits": false, 13 | "checkInvalidKey": true 14 | }, 15 | "compileType": "miniprogram", 16 | "libVersion": "2.7.7", 17 | "appid": "wxe61b785946958cc7", 18 | "projectname": "wTravel", 19 | "debugOptions": { 20 | "hidedInDevtools": [] 21 | }, 22 | "isGameTourist": false, 23 | "simulatorType": "wechat", 24 | "simulatorPluginLibVersion": {}, 25 | "condition": { 26 | "search": { 27 | "current": -1, 28 | "list": [] 29 | }, 30 | "conversation": { 31 | "current": -1, 32 | "list": [] 33 | }, 34 | "game": { 35 | "currentL": -1, 36 | "list": [] 37 | }, 38 | "miniprogram": { 39 | "current": -1, 40 | "list": [] 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /weTravel/sitemap.json: -------------------------------------------------------------------------------- 1 | { 2 | "desc": "关于本文件的更多信息,请参考文档 https://developers.weixin.qq.com/miniprogram/dev/framework/sitemap.html", 3 | "rules": [{ 4 | "action": "allow", 5 | "page": "*" 6 | }] 7 | } -------------------------------------------------------------------------------- /weTravel/utils/api.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Author : 丸子团队(波波、Chi、ONLINE.信) 3 | * Github 地址: https://github.com/dchijack/Travel-Mini-Program 4 | * GiTee 地址: https://gitee.com/izol/Travel-Mini-Program 5 | */ 6 | 7 | const API = require('./base') 8 | 9 | /** 10 | * 获取站点信息 11 | * @param {object} args 参数,默认为空 12 | * @return {promise} 13 | */ 14 | const getSiteInfo = function(data) { 15 | return API.get('/wp-json/mp/v1/setting', data); 16 | } 17 | 18 | /** 19 | * 获取置顶文章 20 | * @param {object} args 参数,默认为空 21 | * @return {promise} 22 | */ 23 | const getStickyPosts = function(data) { 24 | return API.get('/wp-json/mp/v1/posts/sticky', data); 25 | } 26 | 27 | /** 28 | * 获取文章列表 29 | * @param {object} args 参数,默认为空 30 | * 参数可以访问: http://v2.wp-api.org/ 了解相关参数 31 | * @return {promise} 32 | */ 33 | const getPostsList = function(data) { 34 | return API.get('/wp-json/wp/v2/posts', data, { token:true }); 35 | } 36 | 37 | /** 38 | * 获取文章详情 39 | * @param {int} id 文章id 40 | * @return {promise} 41 | */ 42 | const getPostsbyID = function(id){ 43 | return API.get('/wp-json/wp/v2/posts/'+id, {}, { token:true }); 44 | } 45 | 46 | /** 47 | * 获取页面列表 48 | * @param {object} args 参数,默认为空 49 | * 参数可以访问: http://v2.wp-api.org/ 了解相关参数 50 | * @return {promise} 51 | */ 52 | const getPagesList = function(data){ 53 | return API.get('/wp-json/wp/v2/pages', data); 54 | } 55 | 56 | /** 57 | * 获取页面详情 58 | * @param {int} id 页面id 59 | * @return {promise} 60 | */ 61 | const getPageByID = function(id){ 62 | return API.get('/wp-json/wp/v2/pages/'+id); 63 | } 64 | 65 | /** 66 | * 获取所有分类列表 67 | * @param {object} args 参数 68 | * 参数可以访问: http://v2.wp-api.org/ 了解相关参数 69 | * @return {promise} 70 | */ 71 | const getCategories = function(data){ 72 | return API.get('/wp-json/wp/v2/categories?orderby=id&order=asc', data); 73 | } 74 | 75 | /** 76 | * 获取指定分类 77 | * @param {int} id 分类ID 78 | * @return {promise} 79 | */ 80 | const getCategoryByID = function(id){ 81 | return API.get('/wp-json/wp/v2/categories/'+id); 82 | } 83 | 84 | /** 85 | * 获取所有标签列表 86 | * @param {object} args 参数 87 | * 参数可以访问: http://v2.wp-api.org/ 了解相关参数 88 | * @return {promise} 89 | */ 90 | const getTags = function(data){ 91 | return API.get('/wp-json/wp/v2/tags?orderby=id&order=asc', data); 92 | } 93 | 94 | /** 95 | * 获取指定标签 96 | * @param {int} id 标签ID 97 | * @return {promise} 98 | */ 99 | const getTagByID = function(id){ 100 | return API.get('/wp-json/wp/v2/tags/'+id); 101 | } 102 | 103 | /** 104 | * 获取随机文章列表 105 | * @param {object} args 参数,默认为空 106 | * @return {promise} 107 | */ 108 | const getRandPosts = function(data){ 109 | return API.get('/wp-json/mp/v1/posts/rand', data); 110 | } 111 | 112 | /** 113 | * 获取相关文章列表 114 | * @param {object} data 参数 115 | * @return {promise} 116 | */ 117 | const getRelatePosts = function(data){ 118 | return API.get('/wp-json/mp/v1/posts/relate', data); 119 | } 120 | 121 | /** 122 | * 获取热门文章列表 123 | * @param {object} args 参数,默认为空 124 | * @return {promise} 125 | */ 126 | const getMostViewsPosts = function(data){ 127 | return API.get('/wp-json/mp/v1/posts/most?meta=views', data); 128 | } 129 | 130 | /** 131 | * 获取热门收藏文章列表 132 | * @param {object} args 参数 133 | * @return {promise} 134 | */ 135 | const getMostFavPosts = function(data){ 136 | return API.get('/wp-json/mp/v2/posts/most?meta=favs', data); 137 | } 138 | 139 | /** 140 | * 获取热门点赞文章列表 141 | * @param {object} args 参数 142 | * @return {promise} 143 | */ 144 | const getMostLikePosts = function(data){ 145 | return API.get('/wp-json/mp/v2/posts/most?meta=likes', data); 146 | } 147 | 148 | /** 149 | * 获取热评文章列表 150 | * @param {object} args 参数,默认为空 151 | * @return {promise} 152 | */ 153 | const getMostCommentPosts = function(data){ 154 | return API.get('/wp-json/mp/v2/posts/most?meta=comments', data); 155 | } 156 | 157 | /** 158 | * 获取近期评论文章 159 | * @param {object} args 参数,默认为空 160 | * @return {promise} 161 | */ 162 | const getRecentCommentPosts = function(data){ 163 | return API.get('/wp-json/mp/v1/posts/comment', data); 164 | } 165 | 166 | /** 167 | * 文章评论列表 168 | * @param {object} args 参数,默认为空 169 | * @return {promise} 170 | */ 171 | const getComments = function(data) { 172 | return API.get('/wp-json/mp/v1/comments', data); 173 | } 174 | 175 | /** 176 | * 获取用户信息 177 | * @param {object} args 参数 178 | * @return {promise} 179 | */ 180 | const getProfile = function() { 181 | return API.getUserInfo(); 182 | } 183 | 184 | /** 185 | * 注销用户登录 186 | * @param {object} args 参数 187 | * @return {promise} 188 | */ 189 | const Loginout = function() { 190 | return API.logout(); 191 | } 192 | 193 | /** 194 | * 收藏文章 195 | * @param {object} args 参数,POST 文章id 196 | * TOKEN 参数为 true ,需要用户授权使用 197 | * @return {promise} 198 | */ 199 | const fav = function(data) { 200 | return API.post('/wp-json/mp/v1/comments?type=fav', data, { token:true }); 201 | } 202 | 203 | /** 204 | * 点赞文章 205 | * @param {object} args 参数,POST 文章id 206 | * TOKEN 参数为 true ,需要用户授权使用 207 | * @return {promise} 208 | */ 209 | const like = function(data) { 210 | return API.post('/wp-json/mp/v1/comments?type=like', data, { token:true }); 211 | } 212 | 213 | /** 214 | * 我的收藏文章列表 215 | * @param {object} args 参数 216 | * TOKEN 参数为 true ,需要用户授权使用 217 | * @return {promise} 218 | */ 219 | const getFavPosts = function(data) { 220 | return API.get('/wp-json/mp/v1/posts/comment?type=fav', data, { token:true }); 221 | } 222 | 223 | /** 224 | * 我的点赞文章列表 225 | * @param {object} args 参数 226 | * TOKEN 参数为 true ,需要用户授权使用 227 | * @return {promise} 228 | */ 229 | const getLikePosts = function(data) { 230 | return API.get('/wp-json/mp/v1/posts/comment?type=like', data, { token:true }); 231 | } 232 | 233 | /** 234 | * 我的评论文章列表 235 | * @param {object} args 参数 236 | * TOKEN 参数为 true ,需要用户授权使用 237 | * @return {promise} 238 | */ 239 | const getCommentsPosts = function(data) { 240 | return API.get('/wp-json/mp/v1/posts/comment?type=comment', data, { token:true }); 241 | } 242 | 243 | /** 244 | * 发表评论 245 | * @param {object} args 参数, POST 评论内容及文章id 246 | * TOKEN 参数为 true ,需要用户授权使用 247 | * @return {promise} 248 | */ 249 | const addComment = function(data) { 250 | return API.post('/wp-json/mp/v1/comments?type=comment', data, { token:true }); 251 | } 252 | 253 | /** 254 | * 投票表态 255 | * @param {object} args 参数, POST 文章 ID 及选项 ID 256 | * TOKEN 参数为 true ,需要用户授权使用 257 | * @return {promise} 258 | */ 259 | const votePosts = function(data) { 260 | return API.post('/wp-json/mp/v1/vote', data, { token:true }); 261 | } 262 | 263 | /** 264 | * 获取二维码 265 | * @param {object} args 参数 266 | * @return {promise} 267 | */ 268 | const getCodeImg = function(data) { 269 | return API.post('/wp-json/mp/v1/qrcode', data, { token: false }); 270 | } 271 | 272 | /** 273 | * 导航数据 274 | */ 275 | const getMenuSetting = function(data) { 276 | return API.get('/wp-json/mp/v1/menu', data); 277 | } 278 | 279 | /** 280 | * 首页广告数据 281 | */ 282 | const indexAdsense = function(data) { 283 | return API.get('/wp-json/mp/v1/advert?type=index', data); 284 | } 285 | 286 | /** 287 | * 列表广告数据 288 | */ 289 | const listAdsense = function(data) { 290 | return API.get('/wp-json/mp/v1/advert?type=list', data); 291 | } 292 | 293 | /** 294 | * 详情广告数据 295 | */ 296 | const detailAdsense = function(data) { 297 | return API.get('/wp-json/mp/v1/advert?type=detail', data); 298 | } 299 | 300 | /** 301 | * 页面广告数据 302 | */ 303 | const pageAdsense = function(data) { 304 | return API.get('/wp-json/mp/v1/advert?type=page', data); 305 | } 306 | 307 | API.getSiteInfo = getSiteInfo 308 | API.getStickyPosts = getStickyPosts 309 | API.getPostsList = getPostsList 310 | API.getPostsbyID = getPostsbyID 311 | API.getPagesList = getPagesList 312 | API.getPageByID = getPageByID 313 | API.getCategories = getCategories 314 | API.getCategoryByID = getCategoryByID 315 | API.getTags = getTags 316 | API.getTagByID = getTagByID 317 | API.getRandPosts = getRandPosts 318 | API.getRelatePosts = getRelatePosts 319 | API.getMostViewsPosts = getMostViewsPosts 320 | API.getMostFavPosts = getMostFavPosts 321 | API.getMostLikePosts = getMostLikePosts 322 | API.getMostCommentPosts = getMostCommentPosts 323 | API.getRecentCommentPosts = getRecentCommentPosts 324 | API.getComments = getComments 325 | API.getProfile = API.guard(getProfile) 326 | API.fav = API.guard(fav) 327 | API.getFavPosts = API.guard(getFavPosts) 328 | API.like = API.guard(like) 329 | API.getLikePosts = API.guard(getLikePosts) 330 | API.getCommentsPosts = API.guard(getCommentsPosts) 331 | API.addComment = API.guard(addComment) 332 | API.votePosts = API.guard(votePosts) 333 | API.getCodeImg = getCodeImg 334 | API.Loginout = Loginout 335 | API.getMenuSetting = getMenuSetting 336 | API.indexAdsense = indexAdsense 337 | API.listAdsense = listAdsense 338 | API.detailAdsense = detailAdsense 339 | API.pageAdsense = pageAdsense 340 | 341 | module.exports = API -------------------------------------------------------------------------------- /weTravel/utils/auth.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Author : 丸子团队(波波、Chi、ONLINE.信) 3 | * Github 地址: https://github.com/dchijack/Travel-Mini-Program 4 | * GiTee 地址: https://gitee.com/izol/Travel-Mini-Program 5 | */ 6 | 7 | const Auth = {} 8 | 9 | /** 10 | * 获取当前登陆用户的openid 11 | * @return {string} 12 | */ 13 | Auth.openid = function() { 14 | const user = Auth.user() 15 | if (user && user.openid) { 16 | return user.openid 17 | } else { 18 | return '' 19 | } 20 | } 21 | 22 | /** 23 | * 获取当前登陆用户信息 24 | * @return {object} 25 | */ 26 | Auth.user = function() { 27 | return wx.getStorageSync('user'); 28 | } 29 | 30 | /** 31 | * 获取token 32 | * @return {string} 33 | */ 34 | Auth.token = function() { 35 | return wx.getStorageSync('token'); 36 | } 37 | 38 | /** 39 | * 判断token还是否在有效期内 40 | * @return {boolean} 41 | */ 42 | Auth.check = function() { 43 | let user = Auth.user() 44 | let token = Auth.token() 45 | if (user && Date.now() < wx.getStorageSync('expired_in') && token) { 46 | console.log('access_token过期时间:', (wx.getStorageSync('expired_in') - Date.now()) / 1000, '秒'); 47 | return true; 48 | } else { 49 | return false; 50 | } 51 | } 52 | 53 | /** 54 | * 登录 55 | * @return {Promise} 登录信息 56 | */ 57 | Auth.login = function() { 58 | return new Promise(function(resolve, reject) { 59 | wx.login({ 60 | success: function(res) { 61 | //console.log('wx.login.code', res.code); 62 | resolve(res); 63 | }, 64 | 65 | fail: function(err) { 66 | reject(err); 67 | } 68 | }); 69 | }); 70 | } 71 | 72 | /** 73 | * 通过 wx.login 获取code 74 | * @return code 75 | */ 76 | Auth.code = function(){ 77 | return new Promise(function(resolve, reject) { 78 | wx.login({ 79 | success: function(res){ 80 | resolve(res.code); 81 | }, 82 | 83 | fail: function(err) { 84 | reject(err); 85 | } 86 | }); 87 | }); 88 | } 89 | 90 | /** 91 | * 注销 92 | * @return {boolean} 93 | */ 94 | Auth.logout = function() { 95 | wx.removeStorageSync('user') 96 | wx.removeStorageSync('token') 97 | wx.removeStorageSync('expired_in') 98 | return true 99 | } 100 | 101 | /** 102 | * 获取授权登录加密数据 103 | */ 104 | Auth.getUserInfo = function(){ 105 | return new Promise(function(resolve, reject) { 106 | Auth.code().then(data => { 107 | let args = {} 108 | args.code = data; 109 | wx.getUserInfo({ 110 | success: function (res) { 111 | //console.log(res); 112 | args.iv = encodeURIComponent(res.iv); 113 | args.encryptedData = encodeURIComponent(res.encryptedData); 114 | resolve(args); 115 | }, 116 | fail: function (err) { 117 | reject(err); 118 | } 119 | }); 120 | }) 121 | }); 122 | } 123 | 124 | module.exports = Auth -------------------------------------------------------------------------------- /weTravel/utils/base.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Author : 丸子团队(波波、Chi、ONLINE.信) 3 | * Github 地址: https://github.com/dchijack/Travel-Mini-Program 4 | * GiTee 地址: https://gitee.com/izol/Travel-Mini-Program 5 | */ 6 | 7 | const API_HOST = 'https://cxcat.com' // 更换为你的网站域名, 需要有 https 协议 8 | const Auth = require('./auth') 9 | 10 | const API = {} 11 | 12 | API.getHost = function(){ 13 | return API_HOST; 14 | } 15 | 16 | API.request = function(url, method = "GET", data={}, args = { token: true, isPull: false }) { 17 | 18 | return new Promise(function(resolve, reject) { 19 | 20 | wx.showNavigationBarLoading() 21 | 22 | url = API_HOST + url; 23 | 24 | if (args.token) { 25 | const token = API.token(); 26 | if(token) { 27 | if(url.indexOf("?")>0) { 28 | url = url + '&access_token=' + token; 29 | } else { 30 | url = url + '?access_token=' + token; 31 | } 32 | } else { 33 | console.warn('[提示]','部分数据需要授权,检测出当前访问用户未授权登录小程序'); 34 | } 35 | } 36 | //console.log(url) 37 | //console.log(data) 38 | wx.request({ 39 | url: url, 40 | data: data, 41 | method: method, 42 | success: function(res) { 43 | console.log(res); 44 | if(res.statusCode == 200) { 45 | resolve(res.data); 46 | } else if(res.data.code === "rest_post_invalid_page_number") { 47 | wx.showToast({ 48 | title: '没有更多内容', 49 | mask: false, 50 | duration: 1000 51 | }); 52 | } else { 53 | wx.showToast({ 54 | title: "请求数据失败", 55 | duration: 1500 56 | }); 57 | console.log(res.data.message); 58 | reject(res.data); 59 | } 60 | wx.hideNavigationBarLoading() 61 | }, 62 | fail: function(err) { 63 | wx.hideNavigationBarLoading(); 64 | console.log(err); 65 | reject(err); 66 | } 67 | }) 68 | }); 69 | 70 | } 71 | 72 | API.get = function(url, data={}, args = { token: false }) { 73 | return API.request(url, "GET", data, args); 74 | } 75 | 76 | API.post = function(url, data, args = { token: true }) { 77 | return API.request(url, "POST", data, args); 78 | } 79 | 80 | API.getUser = function(){ 81 | if(Auth.check()){ 82 | return Auth.user(); 83 | }else{ 84 | return false; 85 | } 86 | 87 | } 88 | 89 | API.login = function() { 90 | return new Promise(function(resolve, reject) { 91 | if(Auth.check()){ 92 | resolve(Auth.user()); 93 | }else{ 94 | Auth.login().then(data=>{ 95 | API.post('/wp-json/mp/v1/user/openid', data, { token: false }).then(res => { 96 | API.storageUser(res); 97 | //console.log(res); 98 | resolve(res); 99 | }, err => { 100 | reject(err); 101 | }); 102 | }).catch( err =>{ 103 | reject(err); 104 | }) 105 | } 106 | }); 107 | } 108 | 109 | API.logout = function() { 110 | let logout = Auth.logout(); 111 | if(logout) { 112 | getApp().globalData.user = ''; 113 | } else { 114 | wx.showToast({ 115 | title: '注销失败!', 116 | icon: 'warn', 117 | duration: 1000, 118 | }) 119 | } 120 | } 121 | 122 | API.getUserInfo = function() { 123 | return new Promise(function(resolve, reject) { 124 | Auth.getUserInfo().then(data=>{ 125 | API.post('/wp-json/mp/v1/user/login', data, { token: false }).then(res => { 126 | API.storageUser(res); 127 | console.log(res); 128 | resolve(res.user); 129 | }, err => { 130 | reject(err); 131 | }); 132 | }) 133 | .catch( err =>{ 134 | //console.log(err); 135 | reject(err); 136 | }) 137 | }); 138 | } 139 | 140 | API.token = function() { 141 | let token = Auth.token(); 142 | let datetime = Date.now(); 143 | if(token && datetime < wx.getStorageSync('expired_in')) { 144 | return token; 145 | } else { 146 | return false; 147 | } 148 | } 149 | 150 | API.storageUser = function(res) { 151 | getApp().globalData.user = res.user; 152 | wx.setStorageSync('user', res.user); 153 | wx.setStorageSync('openid', res.openid); 154 | if(res.access_token){ 155 | wx.setStorageSync('token', res.access_token); 156 | wx.setStorageSync('expired_in', Date.now() + parseInt(res.expired_in, 10) * 100000 - 60000); 157 | } 158 | } 159 | 160 | /** 161 | * 需要授权的接口调用 162 | * @param {Function} fn 163 | * @return {Promise} 164 | */ 165 | API.guard = function(fn) { 166 | const self = this 167 | return function() { 168 | if(API.getUser()) { 169 | return fn.apply(self, arguments) 170 | } else { 171 | return API.getUserInfo().then(res => { 172 | console.log('登录成功', res); 173 | return fn.apply(self, arguments) 174 | }, err => { 175 | console.log('登录失败', err); 176 | return err 177 | }) 178 | } 179 | } 180 | } 181 | 182 | module.exports = API -------------------------------------------------------------------------------- /weTravel/utils/util.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Author : 丸子团队(波波、Chi、ONLINE.信) 3 | * Github 地址: https://github.com/dchijack/Travel-Mini-Program 4 | * GiTee 地址: https://gitee.com/izol/Travel-Mini-Program 5 | */ 6 | 7 | const formatTime = date => { 8 | const year = date.getFullYear() 9 | const month = date.getMonth() + 1 10 | const day = date.getDate() 11 | const hour = date.getHours() 12 | const minute = date.getMinutes() 13 | const second = date.getSeconds() 14 | 15 | return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':') 16 | } 17 | 18 | const formatNumber = n => { 19 | n = n.toString() 20 | return n[1] ? n : '0' + n 21 | } 22 | 23 | module.exports = { 24 | formatTime: formatTime 25 | } 26 | -------------------------------------------------------------------------------- /weTravel/wxParse/htmlparser.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * htmlParser改造自: https://github.com/blowsie/Pure-JavaScript-HTML5-Parser 4 | * 5 | * author: Di (微信小程序开发工程师) 6 | * organization: WeAppDev(微信小程序开发论坛)(http://weappdev.com) 7 | * 垂直微信小程序开发交流社区 8 | * 9 | * github地址: https://github.com/icindy/wxParse 10 | * 11 | * for: 微信小程序富文本解析 12 | * detail : http://weappdev.com/t/wxparse-alpha0-1-html-markdown/184 13 | */ 14 | // Regular Expressions for parsing tags and attributes 15 | var startTag = /^<([-A-Za-z0-9_]+)((?:\s+[a-zA-Z_:][-a-zA-Z0-9_:.]*(?:\s*=\s*(?:(?:"[^"]*")|(?:'[^']*')|[^>\s]+))?)*)\s*(\/?)>/, 16 | endTag = /^<\/([-A-Za-z0-9_]+)[^>]*>/, 17 | attr = /([a-zA-Z_:][-a-zA-Z0-9_:.]*)(?:\s*=\s*(?:(?:"((?:\\.|[^"])*)")|(?:'((?:\\.|[^'])*)')|([^>\s]+)))?/g; 18 | 19 | // Empty Elements - HTML 5 20 | var empty = makeMap("area,base,basefont,br,col,frame,hr,img,input,link,meta,param,embed,command,keygen,source,track,wbr"); 21 | 22 | // Block Elements - HTML 5 23 | var block = makeMap("a,address,code,article,applet,aside,audio,blockquote,button,canvas,center,dd,del,dir,div,dl,dt,fieldset,figcaption,figure,footer,form,frameset,h1,h2,h3,h4,h5,h6,header,hgroup,hr,iframe,ins,isindex,li,map,menu,noframes,noscript,object,ol,output,p,pre,section,script,table,tbody,td,tfoot,th,thead,tr,ul,video"); 24 | 25 | // Inline Elements - HTML 5 26 | var inline = makeMap("abbr,acronym,applet,b,basefont,bdo,big,br,button,cite,del,dfn,em,font,i,iframe,img,input,ins,kbd,label,map,object,q,s,samp,script,select,small,span,strike,strong,sub,sup,textarea,tt,u,var"); 27 | 28 | // Elements that you can, intentionally, leave open 29 | // (and which close themselves) 30 | var closeSelf = makeMap("colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr"); 31 | 32 | // Attributes that have their values filled in disabled="disabled" 33 | var fillAttrs = makeMap("checked,compact,declare,defer,disabled,ismap,multiple,nohref,noresize,noshade,nowrap,readonly,selected"); 34 | 35 | // Special Elements (can contain anything) 36 | var special = makeMap("wxxxcode-style,script,style,view,scroll-view,block"); 37 | 38 | function HTMLParser(html, handler) { 39 | var index, chars, match, stack = [], last = html; 40 | stack.last = function () { 41 | return this[this.length - 1]; 42 | }; 43 | 44 | while (html) { 45 | chars = true; 46 | 47 | // Make sure we're not in a script or style element 48 | if (!stack.last() || !special[stack.last()]) { 49 | 50 | // Comment 51 | if (html.indexOf(""); 53 | 54 | if (index >= 0) { 55 | if (handler.comment) 56 | handler.comment(html.substring(4, index)); 57 | html = html.substring(index + 3); 58 | chars = false; 59 | } 60 | 61 | // end tag 62 | } else if (html.indexOf("]*>"), function (all, text) { 100 | text = text.replace(/|/g, "$1$2"); 101 | if (handler.chars) 102 | handler.chars(text); 103 | 104 | return ""; 105 | }); 106 | 107 | 108 | parseEndTag("", stack.last()); 109 | } 110 | 111 | if (html == last) 112 | throw "Parse Error: " + html; 113 | last = html; 114 | } 115 | 116 | // Clean up any remaining tags 117 | parseEndTag(); 118 | 119 | function parseStartTag(tag, tagName, rest, unary) { 120 | tagName = tagName.toLowerCase(); 121 | 122 | if (block[tagName]) { 123 | while (stack.last() && inline[stack.last()]) { 124 | parseEndTag("", stack.last()); 125 | } 126 | } 127 | 128 | if (closeSelf[tagName] && stack.last() == tagName) { 129 | parseEndTag("", tagName); 130 | } 131 | 132 | unary = empty[tagName] || !!unary; 133 | 134 | if (!unary) 135 | stack.push(tagName); 136 | 137 | if (handler.start) { 138 | var attrs = []; 139 | 140 | rest.replace(attr, function (match, name) { 141 | var value = arguments[2] ? arguments[2] : 142 | arguments[3] ? arguments[3] : 143 | arguments[4] ? arguments[4] : 144 | fillAttrs[name] ? name : ""; 145 | 146 | attrs.push({ 147 | name: name, 148 | value: value, 149 | escaped: value.replace(/(^|[^\\])"/g, '$1\\\"') //" 150 | }); 151 | }); 152 | 153 | if (handler.start) { 154 | handler.start(tagName, attrs, unary); 155 | } 156 | 157 | } 158 | } 159 | 160 | function parseEndTag(tag, tagName) { 161 | // If no tag name is provided, clean shop 162 | if (!tagName) 163 | var pos = 0; 164 | 165 | // Find the closest opened tag of the same type 166 | else { 167 | tagName = tagName.toLowerCase(); 168 | for (var pos = stack.length - 1; pos >= 0; pos--) 169 | if (stack[pos] == tagName) 170 | break; 171 | } 172 | if (pos >= 0) { 173 | // Close all the open elements, up the stack 174 | for (var i = stack.length - 1; i >= pos; i--) 175 | if (handler.end) 176 | handler.end(stack[i]); 177 | 178 | // Remove the open elements from the stack 179 | stack.length = pos; 180 | } 181 | } 182 | }; 183 | 184 | 185 | function makeMap(str) { 186 | var obj = {}, items = str.split(","); 187 | for (var i = 0; i < items.length; i++) 188 | obj[items[i]] = true; 189 | return obj; 190 | } 191 | 192 | module.exports = HTMLParser; 193 | -------------------------------------------------------------------------------- /weTravel/wxParse/wxDiscode.js: -------------------------------------------------------------------------------- 1 | // HTML 支持的数学符号 2 | function strNumDiscode(str){ 3 | str = str.replace(/∀/g, '∀'); 4 | str = str.replace(/∂/g, '∂'); 5 | str = str.replace(/&exists;/g, '∃'); 6 | str = str.replace(/∅/g, '∅'); 7 | str = str.replace(/∇/g, '∇'); 8 | str = str.replace(/∈/g, '∈'); 9 | str = str.replace(/∉/g, '∉'); 10 | str = str.replace(/∋/g, '∋'); 11 | str = str.replace(/∏/g, '∏'); 12 | str = str.replace(/∑/g, '∑'); 13 | str = str.replace(/−/g, '−'); 14 | str = str.replace(/∗/g, '∗'); 15 | str = str.replace(/√/g, '√'); 16 | str = str.replace(/∝/g, '∝'); 17 | str = str.replace(/∞/g, '∞'); 18 | str = str.replace(/∠/g, '∠'); 19 | str = str.replace(/∧/g, '∧'); 20 | str = str.replace(/∨/g, '∨'); 21 | str = str.replace(/∩/g, '∩'); 22 | str = str.replace(/∩/g, '∪'); 23 | str = str.replace(/∫/g, '∫'); 24 | str = str.replace(/∴/g, '∴'); 25 | str = str.replace(/∼/g, '∼'); 26 | str = str.replace(/≅/g, '≅'); 27 | str = str.replace(/≈/g, '≈'); 28 | str = str.replace(/≠/g, '≠'); 29 | str = str.replace(/≤/g, '≤'); 30 | str = str.replace(/≥/g, '≥'); 31 | str = str.replace(/⊂/g, '⊂'); 32 | str = str.replace(/⊃/g, '⊃'); 33 | str = str.replace(/⊄/g, '⊄'); 34 | str = str.replace(/⊆/g, '⊆'); 35 | str = str.replace(/⊇/g, '⊇'); 36 | str = str.replace(/⊕/g, '⊕'); 37 | str = str.replace(/⊗/g, '⊗'); 38 | str = str.replace(/⊥/g, '⊥'); 39 | str = str.replace(/⋅/g, '⋅'); 40 | return str; 41 | } 42 | 43 | //HTML 支持的希腊字母 44 | function strGreeceDiscode(str){ 45 | str = str.replace(/Α/g, 'Α'); 46 | str = str.replace(/Β/g, 'Β'); 47 | str = str.replace(/Γ/g, 'Γ'); 48 | str = str.replace(/Δ/g, 'Δ'); 49 | str = str.replace(/Ε/g, 'Ε'); 50 | str = str.replace(/Ζ/g, 'Ζ'); 51 | str = str.replace(/Η/g, 'Η'); 52 | str = str.replace(/Θ/g, 'Θ'); 53 | str = str.replace(/Ι/g, 'Ι'); 54 | str = str.replace(/Κ/g, 'Κ'); 55 | str = str.replace(/Λ/g, 'Λ'); 56 | str = str.replace(/Μ/g, 'Μ'); 57 | str = str.replace(/Ν/g, 'Ν'); 58 | str = str.replace(/Ξ/g, 'Ν'); 59 | str = str.replace(/Ο/g, 'Ο'); 60 | str = str.replace(/Π/g, 'Π'); 61 | str = str.replace(/Ρ/g, 'Ρ'); 62 | str = str.replace(/Σ/g, 'Σ'); 63 | str = str.replace(/Τ/g, 'Τ'); 64 | str = str.replace(/Υ/g, 'Υ'); 65 | str = str.replace(/Φ/g, 'Φ'); 66 | str = str.replace(/Χ/g, 'Χ'); 67 | str = str.replace(/Ψ/g, 'Ψ'); 68 | str = str.replace(/Ω/g, 'Ω'); 69 | 70 | str = str.replace(/α/g, 'α'); 71 | str = str.replace(/β/g, 'β'); 72 | str = str.replace(/γ/g, 'γ'); 73 | str = str.replace(/δ/g, 'δ'); 74 | str = str.replace(/ε/g, 'ε'); 75 | str = str.replace(/ζ/g, 'ζ'); 76 | str = str.replace(/η/g, 'η'); 77 | str = str.replace(/θ/g, 'θ'); 78 | str = str.replace(/ι/g, 'ι'); 79 | str = str.replace(/κ/g, 'κ'); 80 | str = str.replace(/λ/g, 'λ'); 81 | str = str.replace(/μ/g, 'μ'); 82 | str = str.replace(/ν/g, 'ν'); 83 | str = str.replace(/ξ/g, 'ξ'); 84 | str = str.replace(/ο/g, 'ο'); 85 | str = str.replace(/π/g, 'π'); 86 | str = str.replace(/ρ/g, 'ρ'); 87 | str = str.replace(/ς/g, 'ς'); 88 | str = str.replace(/σ/g, 'σ'); 89 | str = str.replace(/τ/g, 'τ'); 90 | str = str.replace(/υ/g, 'υ'); 91 | str = str.replace(/φ/g, 'φ'); 92 | str = str.replace(/χ/g, 'χ'); 93 | str = str.replace(/ψ/g, 'ψ'); 94 | str = str.replace(/ω/g, 'ω'); 95 | str = str.replace(/ϑ/g, 'ϑ'); 96 | str = str.replace(/ϒ/g, 'ϒ'); 97 | str = str.replace(/ϖ/g, 'ϖ'); 98 | str = str.replace(/·/g, '·'); 99 | return str; 100 | } 101 | 102 | // 103 | 104 | function strcharacterDiscode(str){ 105 | // 加入常用解析 106 | str = str.replace(/ /g, ' '); 107 | str = str.replace(/"/g, "'"); 108 | str = str.replace(/&/g, '&'); 109 | // str = str.replace(/</g, '‹'); 110 | // str = str.replace(/>/g, '›'); 111 | 112 | str = str.replace(/</g, '<'); 113 | str = str.replace(/>/g, '>'); 114 | str = str.replace(/•/g, '•'); 115 | str = str.replace(/&/g, '&'); 116 | str = str.replace(/”/g, '"'); 117 | str = str.replace(/‘/g, '\''); 118 | str = str.replace(/’/g, '\''); 119 | str = str.replace(/'/g, '\''); 120 | str = str.replace(/…/g, '...'); 121 | str = str.replace(/“/g, '"'); 122 | str = str.replace(/&/g, '&'); 123 | str = str.replace(/–/g, '-'); 124 | str = str.replace(/—/g, '--'); 125 | 126 | 127 | 128 | return str; 129 | } 130 | 131 | // HTML 支持的其他实体 132 | function strOtherDiscode(str){ 133 | str = str.replace(/Œ/g, 'Œ'); 134 | str = str.replace(/œ/g, 'œ'); 135 | str = str.replace(/Š/g, 'Š'); 136 | str = str.replace(/š/g, 'š'); 137 | str = str.replace(/Ÿ/g, 'Ÿ'); 138 | str = str.replace(/ƒ/g, 'ƒ'); 139 | str = str.replace(/ˆ/g, 'ˆ'); 140 | str = str.replace(/˜/g, '˜'); 141 | str = str.replace(/ /g, ''); 142 | str = str.replace(/ /g, ''); 143 | str = str.replace(/ /g, ''); 144 | str = str.replace(/‌/g, ''); 145 | str = str.replace(/‍/g, ''); 146 | str = str.replace(/‎/g, ''); 147 | str = str.replace(/‏/g, ''); 148 | str = str.replace(/–/g, '–'); 149 | str = str.replace(/—/g, '—'); 150 | str = str.replace(/‘/g, '‘'); 151 | str = str.replace(/’/g, '’'); 152 | str = str.replace(/‚/g, '‚'); 153 | str = str.replace(/“/g, '“'); 154 | str = str.replace(/”/g, '”'); 155 | str = str.replace(/„/g, '„'); 156 | str = str.replace(/†/g, '†'); 157 | str = str.replace(/‡/g, '‡'); 158 | str = str.replace(/•/g, '•'); 159 | str = str.replace(/…/g, '…'); 160 | str = str.replace(/‰/g, '‰'); 161 | str = str.replace(/′/g, '′'); 162 | str = str.replace(/″/g, '″'); 163 | str = str.replace(/‹/g, '‹'); 164 | str = str.replace(/›/g, '›'); 165 | str = str.replace(/‾/g, '‾'); 166 | str = str.replace(/€/g, '€'); 167 | str = str.replace(/™/g, '™'); 168 | 169 | str = str.replace(/←/g, '←'); 170 | str = str.replace(/↑/g, '↑'); 171 | str = str.replace(/→/g, '→'); 172 | str = str.replace(/↓/g, '↓'); 173 | str = str.replace(/↔/g, '↔'); 174 | str = str.replace(/↵/g, '↵'); 175 | str = str.replace(/⌈/g, '⌈'); 176 | str = str.replace(/⌉/g, '⌉'); 177 | 178 | str = str.replace(/⌊/g, '⌊'); 179 | str = str.replace(/⌋/g, '⌋'); 180 | str = str.replace(/◊/g, '◊'); 181 | str = str.replace(/♠/g, '♠'); 182 | str = str.replace(/♣/g, '♣'); 183 | str = str.replace(/♥/g, '♥'); 184 | 185 | str = str.replace(/♦/g, '♦'); 186 | str = str.replace(/'/g, '\''); 187 | return str; 188 | } 189 | 190 | function strMoreDiscode(str){ 191 | str = str.replace(/\r\n/g,""); 192 | str = str.replace(/\n/g,""); 193 | 194 | //str = str.replace(/code/g,"wxxxcode-style"); 195 | return str; 196 | } 197 | 198 | function strDiscode(str){ 199 | str = strNumDiscode(str); 200 | str = strGreeceDiscode(str); 201 | str = strcharacterDiscode(str); 202 | str = strOtherDiscode(str); 203 | //str = strMoreDiscode(str); 204 | return str; 205 | } 206 | function urlToHttpUrl(url,rep){ 207 | 208 | var patt1 = new RegExp("^//"); 209 | var result = patt1.test(url); 210 | if(result){ 211 | url = rep+":"+url; 212 | } 213 | return url; 214 | } 215 | 216 | module.exports = { 217 | strDiscode:strDiscode, 218 | urlToHttpUrl:urlToHttpUrl 219 | } -------------------------------------------------------------------------------- /weTravel/wxParse/wxParse.js: -------------------------------------------------------------------------------- 1 | /** 2 | * author: Di (微信小程序开发工程师) 3 | * organization: WeAppDev(微信小程序开发论坛)(http://weappdev.com) 4 | * 垂直微信小程序开发交流社区 5 | * 6 | * github地址: https://github.com/icindy/wxParse 7 | * 8 | * for: 微信小程序富文本解析 9 | * detail : http://weappdev.com/t/wxparse-alpha0-1-html-markdown/184 10 | */ 11 | 12 | /** 13 | * utils函数引入 14 | **/ 15 | import showdown from './showdown.js'; 16 | import HtmlToJson from './html2json.js'; 17 | /** 18 | * 配置及公有属性 19 | **/ 20 | var realWindowWidth = 0; 21 | var realWindowHeight = 0; 22 | wx.getSystemInfo({ 23 | success: function (res) { 24 | realWindowWidth = res.windowWidth 25 | realWindowHeight = res.windowHeight 26 | } 27 | }) 28 | /** 29 | * 主函数入口区 30 | **/ 31 | function wxParse(bindName = 'wxParseData', type='html', data='
数据不能为空
', target,imagePadding) { 32 | var that = target; 33 | var transData = {};//存放转化后的数据 34 | if (type == 'html') { 35 | transData = HtmlToJson.html2json(data, bindName); 36 | // console.log(JSON.stringify(transData, ' ', ' ')); 37 | } else if (type == 'md' || type == 'markdown') { 38 | var converter = new showdown.Converter(); 39 | var html = converter.makeHtml(data); 40 | transData = HtmlToJson.html2json(html, bindName); 41 | // console.log(JSON.stringify(transData, ' ', ' ')); 42 | } 43 | transData.view = {}; 44 | transData.view.imagePadding = 0; 45 | if(typeof(imagePadding) != 'undefined'){ 46 | transData.view.imagePadding = imagePadding 47 | } 48 | var bindData = {}; 49 | bindData[bindName] = transData; 50 | that.setData(bindData) 51 | that.wxParseImgLoad = wxParseImgLoad; 52 | that.wxParseImgTap = wxParseImgTap; 53 | } 54 | // 图片点击事件 55 | function wxParseImgTap(e) { 56 | var that = this; 57 | var nowImgUrl = e.target.dataset.src; 58 | var tagFrom = e.target.dataset.from; 59 | if (typeof (tagFrom) != 'undefined' && tagFrom.length > 0) { 60 | wx.previewImage({ 61 | current: nowImgUrl, // 当前显示图片的http链接 62 | urls: that.data[tagFrom].imageUrls // 需要预览的图片http链接列表 63 | }) 64 | } 65 | } 66 | 67 | /** 68 | * 图片视觉宽高计算函数区 69 | **/ 70 | function wxParseImgLoad(e) { 71 | var that = this; 72 | var tagFrom = e.target.dataset.from; 73 | var idx = e.target.dataset.idx; 74 | if (typeof (tagFrom) != 'undefined' && tagFrom.length > 0) { 75 | calMoreImageInfo(e, idx, that, tagFrom) 76 | } 77 | } 78 | // 假循环获取计算图片视觉最佳宽高 79 | function calMoreImageInfo(e, idx, that, bindName) { 80 | var temData = that.data[bindName]; 81 | if (!temData || temData.images.length == 0) { 82 | return; 83 | } 84 | var temImages = temData.images; 85 | //因为无法获取view宽度 需要自定义padding进行计算,稍后处理 86 | var recal = wxAutoImageCal(e.detail.width, e.detail.height,that,bindName); 87 | // temImages[idx].width = recal.imageWidth; 88 | // temImages[idx].height = recal.imageheight; 89 | // temData.images = temImages; 90 | // var bindData = {}; 91 | // bindData[bindName] = temData; 92 | // that.setData(bindData); 93 | var index = temImages[idx].index 94 | var key = `${bindName}` 95 | for (var i of index.split('.')) key+=`.nodes[${i}]` 96 | var keyW = key + '.width' 97 | var keyH = key + '.height' 98 | that.setData({ 99 | [keyW]: recal.imageWidth, 100 | [keyH]: recal.imageheight, 101 | }) 102 | } 103 | 104 | // 计算视觉优先的图片宽高 105 | function wxAutoImageCal(originalWidth, originalHeight,that,bindName) { 106 | //获取图片的原始长宽 107 | var windowWidth = 0, windowHeight = 0; 108 | var autoWidth = 0, autoHeight = 0; 109 | var results = {}; 110 | var padding = that.data[bindName].view.imagePadding; 111 | windowWidth = realWindowWidth-2*padding; 112 | windowHeight = realWindowHeight; 113 | //判断按照那种方式进行缩放 114 | // console.log("windowWidth" + windowWidth); 115 | if (originalWidth > windowWidth) {//在图片width大于手机屏幕width时候 116 | autoWidth = windowWidth; 117 | // console.log("autoWidth" + autoWidth); 118 | autoHeight = (autoWidth * originalHeight) / originalWidth; 119 | // console.log("autoHeight" + autoHeight); 120 | results.imageWidth = autoWidth; 121 | results.imageheight = autoHeight; 122 | } else {//否则展示原来的数据 123 | results.imageWidth = originalWidth; 124 | results.imageheight = originalHeight; 125 | } 126 | return results; 127 | } 128 | 129 | function wxParseTemArray(temArrayName,bindNameReg,total,that){ 130 | var array = []; 131 | var temData = that.data; 132 | var obj = null; 133 | for(var i = 0; i < total; i++){ 134 | var simArr = temData[bindNameReg+i].nodes; 135 | array.push(simArr); 136 | } 137 | 138 | temArrayName = temArrayName || 'wxParseTemArray'; 139 | obj = JSON.parse('{"'+ temArrayName +'":""}'); 140 | obj[temArrayName] = array; 141 | that.setData(obj); 142 | } 143 | 144 | /** 145 | * 配置emojis 146 | * 147 | */ 148 | 149 | /* function emojisInit(reg='',baseSrc="/wxParse/emojis/",emojis){ 150 | HtmlToJson.emojisInit(reg,baseSrc,emojis); 151 | } */ 152 | 153 | module.exports = { 154 | wxParse: wxParse, 155 | wxParseTemArray:wxParseTemArray, 156 | //emojisInit:emojisInit 157 | } 158 | 159 | 160 | -------------------------------------------------------------------------------- /weTravel/wxParse/wxParse.wxss: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * author: Di (微信小程序开发工程师) 4 | * organization: WeAppDev(微信小程序开发论坛)(http://weappdev.com) 5 | * 垂直微信小程序开发交流社区 6 | * 7 | * github地址: https://github.com/icindy/wxParse 8 | * 9 | * for: 微信小程序富文本解析 10 | * detail : http://weappdev.com/t/wxparse-alpha0-1-html-markdown/184 11 | */ 12 | 13 | .wxParse{ 14 | margin: 0 5px; 15 | font-family: Helvetica,sans-serif; 16 | font-size: 28rpx; 17 | color: #666; 18 | line-height: 1.8; 19 | } 20 | view{ 21 | word-break:break-all; 22 | } 23 | .wxParse-inline{ 24 | display: inline; 25 | margin: 0; 26 | padding: 0; 27 | } 28 | /*//标题 */ 29 | .wxParse-div{margin: 0;padding: 0;} 30 | .wxParse-h1{ font-size:2em; margin: .67em 0 } 31 | .wxParse-h2{ font-size:1.5em; margin: .75em 0 } 32 | .wxParse-h3{ font-size:1.17em; margin: .83em 0 } 33 | .wxParse-h4{ margin: 1.12em 0} 34 | .wxParse-h5 { font-size:.83em; margin: 1.5em 0 } 35 | .wxParse-h6{ font-size:.75em; margin: 1.67em 0 } 36 | 37 | .wxParse-h1 { 38 | font-size: 18px; 39 | font-weight: 400; 40 | margin-bottom: .9em; 41 | } 42 | .wxParse-h2 { 43 | font-size: 16px; 44 | font-weight: 400; 45 | margin-bottom: .34em; 46 | } 47 | .wxParse-h3 { 48 | font-weight: 400; 49 | font-size: 15px; 50 | margin-bottom: .34em; 51 | } 52 | .wxParse-h4 { 53 | font-weight: 400; 54 | font-size: 14px; 55 | margin-bottom: .24em; 56 | } 57 | .wxParse-h5 { 58 | font-weight: 400; 59 | font-size: 13px; 60 | margin-bottom: .14em; 61 | } 62 | .wxParse-h6 { 63 | font-weight: 400; 64 | font-size: 12px; 65 | margin-bottom: .04em; 66 | } 67 | 68 | .wxParse-h1, .wxParse-h2, .wxParse-h3, .wxParse-h4, .wxParse-h5, .wxParse-h6, .wxParse-b, .wxParse-strong { font-weight: bolder } 69 | 70 | .wxParse-i,.wxParse-cite,.wxParse-em,.wxParse-var,.wxParse-address{font-style:italic} 71 | .wxParse-pre,.wxParse-tt,.wxParse-code,.wxParse-kbd,.wxParse-samp{font-family:monospace} 72 | .wxParse-pre{white-space:pre} 73 | .wxParse-big{font-size:1.17em} 74 | .wxParse-small,.wxParse-sub,.wxParse-sup{font-size:.83em} 75 | .wxParse-sub{vertical-align:sub} 76 | .wxParse-sup{vertical-align:super} 77 | .wxParse-s,.wxParse-strike,.wxParse-del{text-decoration:line-through} 78 | /*wxparse-自定义个性化的css样式*/ 79 | /*增加video的css样式*/ 80 | .wxParse-strong,.wxParse-s{display: inline} 81 | .wxParse-a{ 82 | color: deepskyblue; 83 | word-break:break-all; 84 | overflow:auto; 85 | } 86 | 87 | .wxParse-video{ 88 | text-align: center; 89 | margin: 10px 0; 90 | } 91 | 92 | .wxParse-video-video{ 93 | width:100%; 94 | } 95 | 96 | .wxParse-img{ 97 | /*background-color: #efefef;*/ 98 | overflow: hidden; 99 | } 100 | 101 | .wxParse-blockquote { 102 | margin: 0; 103 | padding:10px 0 10px 5px; 104 | font-family:Courier, Calibri,"宋体"; 105 | background:#f5f5f5; 106 | border-left: 3px solid #dbdbdb; 107 | } 108 | 109 | .wxParse-code,.wxParse-wxxxcode-style{ 110 | display: inline; 111 | background:#f5f5f5; 112 | } 113 | .wxParse-ul{ 114 | margin: 20rpx 10rpx; 115 | } 116 | 117 | .wxParse-li,.wxParse-li-inner{ 118 | display: flex; 119 | align-items: baseline; 120 | margin: 10rpx 0; 121 | } 122 | .wxParse-li-text{ 123 | 124 | align-items: center; 125 | line-height: 20px; 126 | } 127 | 128 | .wxParse-li-circle{ 129 | display: inline-flex; 130 | width: 5px; 131 | height: 5px; 132 | background-color: #333; 133 | margin-right: 5px; 134 | } 135 | 136 | .wxParse-li-square{ 137 | display: inline-flex; 138 | width: 10rpx; 139 | height: 10rpx; 140 | background-color: #333; 141 | margin-right: 5px; 142 | } 143 | .wxParse-li-ring{ 144 | display: inline-flex; 145 | width: 10rpx; 146 | height: 10rpx; 147 | border: 2rpx solid #333; 148 | border-radius: 50%; 149 | background-color: #fff; 150 | margin-right: 5px; 151 | } 152 | 153 | /*.wxParse-table{ 154 | width: 100%; 155 | height: 400px; 156 | } 157 | .wxParse-thead,.wxParse-tfoot,.wxParse-tr{ 158 | display: flex; 159 | flex-direction: row; 160 | } 161 | .wxParse-th,.wxParse-td{ 162 | display: flex; 163 | width: 580px; 164 | overflow: auto; 165 | }*/ 166 | 167 | .wxParse-u { 168 | text-decoration: underline; 169 | } 170 | .wxParse-hide{ 171 | display: none; 172 | } 173 | .WxEmojiView{ 174 | align-items: center; 175 | } 176 | .wxEmoji{ 177 | width: 16px; 178 | height:16px; 179 | } 180 | .wxParse-tr{ 181 | display: flex; 182 | border-right:1px solid #e0e0e0; 183 | border-bottom:1px solid #e0e0e0; 184 | border-top:1px solid #e0e0e0; 185 | } 186 | .wxParse-th, 187 | .wxParse-td{ 188 | flex:1; 189 | padding:5px; 190 | font-size:28rpx; 191 | border-left:1px solid #e0e0e0; 192 | word-break: break-all; 193 | } 194 | .wxParse-td:last{ 195 | border-top:1px solid #e0e0e0; 196 | } 197 | .wxParse-th{ 198 | background:#f0f0f0; 199 | border-top:1px solid #e0e0e0; 200 | } 201 | .wxParse-del{ 202 | display: inline; 203 | } 204 | .wxParse-figure { 205 | overflow: hidden; 206 | } 207 | --------------------------------------------------------------------------------