From 9e8d6c86a76761f695eb900310108cb009b67e91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=8D=E8=A0=A2=E4=BC=9A=E6=AD=BB=E7=9A=84=E6=9F=90?= =?UTF-8?q?=E7=BF=A0?= Date: Sun, 23 Feb 2020 00:25:52 +0800 Subject: [PATCH] :bug: fixed bugs in share and prepare for release --- UniTypecho/components/articledetail.vue | 4 +- UniTypecho/components/commentdetail.vue | 24 +++--- UniTypecho/components/commentsender/app.vue | 4 +- UniTypecho/components/commentsender/h5.vue | 4 +- UniTypecho/components/commentsender/qq.vue | 4 +- .../components/commentsender/toutiao.vue | 4 +- UniTypecho/components/commentsender/wx.vue | 68 ++++++++--------- UniTypecho/pages/about/about.vue | 4 +- UniTypecho/pages/index/index.vue | 23 +++--- UniTypecho/pages/post/post.vue | 15 +++- UniTypecho/utils/api.js | 4 +- UniTypecho/utils/login.js | 6 +- UniTypecho/utils/net.js | 74 +++++++++---------- 13 files changed, 123 insertions(+), 115 deletions(-) diff --git a/UniTypecho/components/articledetail.vue b/UniTypecho/components/articledetail.vue index 872276e..b85d819 100644 --- a/UniTypecho/components/articledetail.vue +++ b/UniTypecho/components/articledetail.vue @@ -81,9 +81,7 @@ that.title = item.title; that.thumb = item.thumb.type == 'self' ? item.thumb.url : null; that.link = item.link; - console.log(that.donateQrURL) - console.log(that.showDonate) - if (!Util.isNull(that.donateQrURL) && that.showDonate == true) + if (!Util.isNull(that.donateQrURL) && that.showDonate == true) that.isShowDonate = true; that.$emit('getInfo', { "title": item.title, diff --git a/UniTypecho/components/commentdetail.vue b/UniTypecho/components/commentdetail.vue index 236ac01..ad2c134 100644 --- a/UniTypecho/components/commentdetail.vue +++ b/UniTypecho/components/commentdetail.vue @@ -64,7 +64,7 @@ }, watch: { cid: function(cid) { - if(this.isPage) this.getdetails(cid); + if (this.isPage) this.getdetails(cid); }, refresh: function() { this.getdetails(this.cid); @@ -81,7 +81,7 @@ }, methods: { getdetails(cid) { - if(Util.isNull(cid)) return; + if (Util.isNull(cid)) return; let that = this; Net.request({ url: API.getLikedNum(cid), @@ -93,12 +93,12 @@ success: function(res) { let datas = res.data.data; let avatarList = []; - for(let i in datas){ + for (let i in datas) { let avatarUrl = datas[i]['avatarUrl']; avatarList.push(avatarUrl); } let leftAvatars = that.likeNum - avatarList.length - for(let i = 0; i < leftAvatars; i++){ + for (let i = 0; i < leftAvatars; i++) { avatarList.push("https://i.loli.net/2020/02/21/suCXpZ4rxQFeMDn.jpg"); }; avatarList.reverse(); @@ -132,7 +132,7 @@ navigate(href, e) { let re = new RegExp("^https:\/\/" + cfg.getdomain + "\/archives\/([0-9]*)\/?"); let str = href.match(re); - if(!Util.isNull(str)) { + if (!Util.isNull(str)) { uni.navigateTo({ url: '/pages/post/post?cid=' + str[1] }); @@ -142,16 +142,15 @@ window.open(href); // #endif // #ifdef APP-PLUS - plus.runtime.openURL(href, function(res) { - }); + plus.runtime.openURL(href, function(res) {}); // #endif // #ifdef MP uni.setClipboardData({ data: href, - success: function(){ + success: function() { uni.showToast({ - title: '链接已复制', - duration: 2000 + title: '链接已复制', + duration: 2000 }); } }); @@ -164,11 +163,12 @@ .cu-bar .action:first-child { margin-left: 0; } + .cu-avatar-group { white-space: nowrap; } - + .cu-list .cu-item .content { word-break: break-all; - } + } diff --git a/UniTypecho/components/commentsender/app.vue b/UniTypecho/components/commentsender/app.vue index 719aa65..1bdc2cd 100644 --- a/UniTypecho/components/commentsender/app.vue +++ b/UniTypecho/components/commentsender/app.vue @@ -199,12 +199,12 @@ 0, ), success: function(res) { - if(res.data.data.status == "waiting"){ + if (res.data.data.status == "waiting") { uni.showToast({ title: "请等待审核", duration: 2000 }); - }else if(res.data.data.status == "approved"){ + } else if (res.data.data.status == "approved") { uni.showToast({ title: "评论成功", duration: 2000 diff --git a/UniTypecho/components/commentsender/h5.vue b/UniTypecho/components/commentsender/h5.vue index 55b3937..9b24b36 100644 --- a/UniTypecho/components/commentsender/h5.vue +++ b/UniTypecho/components/commentsender/h5.vue @@ -200,12 +200,12 @@ 0, ), success: function(res) { - if(res.data.data.status == "waiting"){ + if (res.data.data.status == "waiting") { uni.showToast({ title: "请等待审核", duration: 2000 }); - }else if(res.data.data.status == "approved"){ + } else if (res.data.data.status == "approved") { uni.showToast({ title: "评论成功", duration: 2000 diff --git a/UniTypecho/components/commentsender/qq.vue b/UniTypecho/components/commentsender/qq.vue index f3c3e48..faab34c 100644 --- a/UniTypecho/components/commentsender/qq.vue +++ b/UniTypecho/components/commentsender/qq.vue @@ -147,12 +147,12 @@ getApp().globalData.userInfo.avatarUrl, ), success: function(res) { - if(res.data.data.status == "waiting"){ + if (res.data.data.status == "waiting") { uni.showToast({ title: "请等待审核", duration: 2000 }); - }else if(res.data.data.status == "approved"){ + } else if (res.data.data.status == "approved") { uni.showToast({ title: "评论成功", duration: 2000 diff --git a/UniTypecho/components/commentsender/toutiao.vue b/UniTypecho/components/commentsender/toutiao.vue index f3c3e48..faab34c 100644 --- a/UniTypecho/components/commentsender/toutiao.vue +++ b/UniTypecho/components/commentsender/toutiao.vue @@ -147,12 +147,12 @@ getApp().globalData.userInfo.avatarUrl, ), success: function(res) { - if(res.data.data.status == "waiting"){ + if (res.data.data.status == "waiting") { uni.showToast({ title: "请等待审核", duration: 2000 }); - }else if(res.data.data.status == "approved"){ + } else if (res.data.data.status == "approved") { uni.showToast({ title: "评论成功", duration: 2000 diff --git a/UniTypecho/components/commentsender/wx.vue b/UniTypecho/components/commentsender/wx.vue index 63bcfe6..7b4a7b6 100644 --- a/UniTypecho/components/commentsender/wx.vue +++ b/UniTypecho/components/commentsender/wx.vue @@ -106,12 +106,12 @@ } }) }, - getPoster(){ + getPoster() { uni.showLoading({ - title: "加载中", - mask: false + title: "加载中", + mask: false }); - if(!this.isPage) { + if (!this.isPage) { this.qrUrl = API.getPosterUrl('/page/index/index?cid=' + this.cid); } else this.qrUrl = API.getPosterUrl('/pages/index/index'); this.imgUrl = Util.isNull(this.thumb) ? "https://api.isoyu.com/bing_images.php" : this.thumb; @@ -123,19 +123,19 @@ this.modalName = "DialogModal2" this.posterURL = res.tempFilePath; }, - savePoster(){ + savePoster() { let that = this; uni.authorize({ - scope: 'scope.writePhotosAlbum', - success() { - uni.saveImageToPhotosAlbum({ - filePath: that.posterURL, - success: function () { - that.loadDialogModal2 = false; - that.modalName = ""; - } - }); - } + scope: 'scope.writePhotosAlbum', + success() { + uni.saveImageToPhotosAlbum({ + filePath: that.posterURL, + success: function() { + that.loadDialogModal2 = false; + that.modalName = ""; + } + }); + } }) }, hidePoster() { @@ -212,12 +212,12 @@ getApp().globalData.userInfo.avatarUrl, ), success: function(res) { - if(res.data.data.status == "waiting"){ + if (res.data.data.status == "waiting") { uni.showToast({ title: "请等待审核", duration: 2000 }); - }else if(res.data.data.status == "approved"){ + } else if (res.data.data.status == "approved") { uni.showToast({ title: "评论成功", duration: 2000 @@ -226,24 +226,24 @@ console.log('success'); that.$emit('onRefreshComments'); that.value = "" - if(Util.isNull(getApp().globalData.templateIds)) return; + if (Util.isNull(getApp().globalData.templateIds)) return; uni.requestSubscribeMessage({ - tmplIds: getApp().globalData.templateIds, - success (res) { - console.log(res); - Net.request({ - showLoading: false, - url: API.subscribe(getApp().globalData.userInfo.openid), - success: function(res) {} - }); - uni.showToast({ - title: "订阅成功", - duration: 2000 - }); - }, - fail (e) { - console.log(e); - } + tmplIds: getApp().globalData.templateIds, + success(res) { + console.log(res); + Net.request({ + showLoading: false, + url: API.subscribe(getApp().globalData.userInfo.openid), + success: function(res) {} + }); + uni.showToast({ + title: "订阅成功", + duration: 2000 + }); + }, + fail(e) { + console.log(e); + } }) } }); diff --git a/UniTypecho/pages/about/about.vue b/UniTypecho/pages/about/about.vue index c82f052..8ecc0a5 100644 --- a/UniTypecho/pages/about/about.vue +++ b/UniTypecho/pages/about/about.vue @@ -6,11 +6,11 @@ - + - + diff --git a/UniTypecho/pages/index/index.vue b/UniTypecho/pages/index/index.vue index ba6e56e..7536dfa 100644 --- a/UniTypecho/pages/index/index.vue +++ b/UniTypecho/pages/index/index.vue @@ -47,10 +47,9 @@ success: function(res) { getApp().globalData.userInfo = res.userInfo; Login.login({ - success: function() { - } + success: function() {} }); - + } }); // #endif @@ -65,8 +64,8 @@ getApp().globalData.showComments = showComments; getApp().globalData.showShare = showShare; getApp().globalData.showDonate = showDonate; - if(!Util.isNull(templateIds)) getApp().globalData.templateIds = templateIds; - if(!Util.isNull(option.cid)){ + if (!Util.isNull(templateIds)) getApp().globalData.templateIds = templateIds; + if (!Util.isNull(option.cid)) { that.cid = option.cid; uni.navigateTo({ url: '../post/post?cid=' + option.cid @@ -75,13 +74,17 @@ } }); }, - // #ifdef MP-QQ - onShareAppMessage: function () { - qq.showShareMenu({ + onShareAppMessage: function() { + // #ifdef MP-QQ + qq.showShareMenu({ showShareItems: ['qq', 'qzone', 'wechatFriends', 'wechatMoment'] - }) + }); + // #endif + return { + title: '来看看这个博客小程序!', + path: '/pages/index/index?' + } } - // #endif } diff --git a/UniTypecho/pages/post/post.vue b/UniTypecho/pages/post/post.vue index eabe5d3..125acbe 100644 --- a/UniTypecho/pages/post/post.vue +++ b/UniTypecho/pages/post/post.vue @@ -53,7 +53,7 @@ getInfo(e) { this.title = e.title; this.thumb = e.thumb; - if(!this.isPage) { + if (!this.isPage) { uni.setNavigationBarTitle({ title: e.title }); @@ -63,10 +63,17 @@ this.refreshComments = !this.refreshComments; } }, - onShareAppMessage: function () { - qq.showShareMenu({ + onShareAppMessage: function() { + // #ifdef MP-QQ + qq.showShareMenu({ showShareItems: ['qq', 'qzone', 'wechatFriends', 'wechatMoment'] - }) + }); + // #endif + return { + title: this.title, + path: '/pages/index/index?cid=' + this.cid, + imageUrl: this.thumb + } } } diff --git a/UniTypecho/utils/api.js b/UniTypecho/utils/api.js index c4047c5..4ec870d 100644 --- a/UniTypecho/utils/api.js +++ b/UniTypecho/utils/api.js @@ -154,7 +154,7 @@ module.exports = { }, //#endif //#ifndef MP - postComment: function(cid, name, mail, website, text, parent){ + postComment: function(cid, name, mail, website, text, parent) { return this.appendAPISEC( API_URL + "postcomment?cid=" + cid + "&name=" + name + "&mail=" + mail + "&text=" + text + "&parent=" + parent + "&website=" + website + "&type=app" @@ -162,7 +162,7 @@ module.exports = { } //#endif // #ifdef MP-WEIXIN - subscribe: function(openid){ + subscribe: function(openid) { return this.appendAPISEC( API_URL + "subscribe?openid=" + openid ); diff --git a/UniTypecho/utils/login.js b/UniTypecho/utils/login.js index d17a947..d7ee3dd 100644 --- a/UniTypecho/utils/login.js +++ b/UniTypecho/utils/login.js @@ -4,13 +4,13 @@ import Util from './util.js'; function login(handler) { uni.showLoading({ - title: "加载中", - mask: false + title: "加载中", + mask: false }); uni.login({ provider: 'weixin', success: function(res) { - if(Util.isNull(getApp().globalData.userInfo)) { + if (Util.isNull(getApp().globalData.userInfo)) { uni.hideLoading(); return; } diff --git a/UniTypecho/utils/net.js b/UniTypecho/utils/net.js index 111bb82..a450899 100644 --- a/UniTypecho/utils/net.js +++ b/UniTypecho/utils/net.js @@ -1,45 +1,45 @@ var requestHandler = { - url: "", - data: {}, - method: "", - success: function(res) {}, - fail: function() {}, - complete: function() {} + url: "", + data: {}, + method: "", + success: function(res) {}, + fail: function() {}, + complete: function() {} }; function request(requestHandler) { - var data = requestHandler.data; - var url = requestHandler.url; - var method = requestHandler.method; - var showloading = requestHandler.showloading; - if (showloading != false) { - uni.showLoading({ - title: "加载中", - mask: false - }); - } - uni.request({ - url: url, - data: data, - method: method, - success: function(res) { - uni.hideLoading(); - requestHandler.success(res); - }, - fail: function() { - uni.hideLoading(); - uni.showToast({ - title: "网络错误请刷新", - icon: "none", - // image: "../resources/error1.png", - duration: 2000 - }); - requestHandler.fail(); - }, - complete: function() {} - }); + var data = requestHandler.data; + var url = requestHandler.url; + var method = requestHandler.method; + var showloading = requestHandler.showloading; + if (showloading != false) { + uni.showLoading({ + title: "加载中", + mask: false + }); + } + uni.request({ + url: url, + data: data, + method: method, + success: function(res) { + uni.hideLoading(); + requestHandler.success(res); + }, + fail: function() { + uni.hideLoading(); + uni.showToast({ + title: "网络错误请刷新", + icon: "none", + // image: "../resources/error1.png", + duration: 2000 + }); + requestHandler.fail(); + }, + complete: function() {} + }); } module.exports = { - request: request + request: request };