添加微信登录

This commit is contained in:
yi-ge 2020-07-21 23:47:38 +08:00
parent ca2ec55a72
commit dd78f3af82

View File

@ -51,8 +51,9 @@
span.reply(@click="check(i.comment_ID, 2)" v-else-if="visitorInfo.manage") 设为垃圾评论
p(v-if="!comments.length", style="color: #cecece; text-align: center; margin-top: 40px") 暂无内容
.comment-default-commit
.login(v-if="!visitorToken", @click="login")
img(src="https://cdn.wyr.me/imgs/GitHub-Login.png")
.login(v-if="!visitorToken")
img(class="login-img", src="https://cdn.wyr.me/imgs/GitHub-Login.png", @click="login('github')", style="margin-left: -140px;")
img(class="login-img", src="https://cdn.wyr.me/visitor-files/2020-07-21/1595344271134Weixin-Login.png", @click="login('weixin')")
#editor
.comment-toolbar
.comment-no-userinfo(v-if="!visitorToken") 尚未登陆
@ -64,7 +65,8 @@
.comment-btn(@click="commentCommit('editor')") 发布
.comment-reply-commit(id="comment-reply-commit", v-show="replyID")
.login(v-show="!visitorToken", @click="login")
img(src="https://cdn.wyr.me/imgs/GitHub-Login.png")
img(class="login-img", src="https://cdn.wyr.me/imgs/GitHub-Login.png", @click="login('github')", style="margin-left: -140px;")
img(class="login-img", src="https://cdn.wyr.me/visitor-files/2020-07-21/1595344271134Weixin-Login.png", @click="login('weixin')")
#editor-reply
.comment-toolbar
.comment-no-userinfo(v-if="!visitorToken") 尚未登陆
@ -595,8 +597,65 @@ export default {
window.localStorage.removeItem('visitorToken')
this.visitorToken = null
},
login () {
window.open('https://github.com/login/oauth/authorize?client_id=ce1673a37333e47e482d&redirect_uri=https://www.wyr.me/auth', 'Github授权', 'scrollbars=yes,resizable=yes,status=no,location=yes,toolbar=no,menubar=no,width=800,height=600,left=0,top=0')
getCode (uuid, last) {
// $.ajax({
// type: "GET",
// url: "https://weixin.openapi.site/check?uuid=" + uuid + (last ? '&last=' + last : ''),
// dataType: "json",
// cache: !1,
// timeout: 6e4,
// success: function (data) {
// if (data.status === 405) {
// $('#code').text('code = ' + data.result.code)
// } else if (data.status === 404) {
// $('#code').text(data.msg.title + ', ' + data.msg.content)
// getCode(uuid, data.result.wxErrCode)
// } else if (data.status === 403) {
// $('#code').text(data.msg.title + ', ' + data.msg.content)
// getCode(uuid, data.result.wxErrCode)
// } else if (data.status === 500) {
// getUUID()
// } else {
// setTimeout(function () {
// getCode(uuid)
// }, 2000)
// }
// },
// error: function () {
// setTimeout(function () {
// getCode(uuid)
// }, 2000)
// }
// })
},
async login (type) {
if (type === 'github') {
window.open('https://github.com/login/oauth/authorize?client_id=ce1673a37333e47e482d&redirect_uri=https://www.wyr.me/auth', 'Github授权', 'scrollbars=yes,resizable=yes,status=no,location=yes,toolbar=no,menubar=no,width=800,height=600,left=0,top=0')
} else if (type === 'weixin') {
const { data } = await this.$axios.get('https://weixin.openapi.site/img?appid=wx2d1d6aa2f86768d7&redirect_uri=https://wyr.me')
if (data.status === 1) {
const uuid = data.result.wxUUID
// $('#qrcode').attr('src', data.result.imgData)
// getCode(uuid)
console.log(uuid)
} else {
this.$toasted.show('获取微信登录所需参数错误,请暂时换用其它登录方式或重试。', {
position: 'top-center',
duration: 5000
})
}
this.$toasted.show('敬请期待请先使用Github登录', {
position: 'top-center',
duration: 5000
})
} else {
this.$toasted.show('敬请期待', {
position: 'top-center',
duration: 5000
})
}
},
setCommentMap () {
const comments = this.comments
@ -879,7 +938,12 @@ export default {
user-select none
img
margin-top 70px
margin 70px 20px 0 20px
z-index 100
position absolute
.login-img:hover
filter contrast(50%)
.login:hover
background-color #fff