mirror of
https://github.com/ialley-workshop-open/uni-halo.git
synced 2025-05-19 10:00:13 +09:00
update: 优化代码格式
This commit is contained in:
parent
f9fce7d0ed
commit
9721932c34
@ -4,169 +4,170 @@
|
||||
import HaloTokenConfig from '@/config/token.config.js'
|
||||
import HttpHandler from '@/common/http/request.js'
|
||||
import {
|
||||
getCache
|
||||
getCache
|
||||
} from '@/utils/storage.js'
|
||||
|
||||
export default {
|
||||
/**
|
||||
* 获取文章列表
|
||||
* @param {Object} params 参数
|
||||
*/
|
||||
getPostList: (params) => {
|
||||
return HttpHandler.Get(`/apis/api.content.halo.run/v1alpha1/posts`, params)
|
||||
},
|
||||
/**
|
||||
* 获取文章列表
|
||||
* @param {Object} params 参数
|
||||
*/
|
||||
getPostList: (params) => {
|
||||
return HttpHandler.Get(`/apis/api.content.halo.run/v1alpha1/posts`, params)
|
||||
},
|
||||
|
||||
/**
|
||||
* 根据名称获取文章
|
||||
* @param {String} name 分类名称
|
||||
*/
|
||||
getPostByName: (name) => {
|
||||
return HttpHandler.Get(`/apis/api.content.halo.run/v1alpha1/posts/${name}`, {}, {
|
||||
header: {
|
||||
'Wechat-Session-Id': uni.getStorageSync('openid'),
|
||||
}
|
||||
})
|
||||
},
|
||||
/**
|
||||
* 根据名称获取文章
|
||||
* @param {String} name 分类名称
|
||||
*/
|
||||
getPostByName: (name) => {
|
||||
return HttpHandler.Get(`/apis/api.content.halo.run/v1alpha1/posts/${name}`, {}, {
|
||||
header: {
|
||||
'Wechat-Session-Id': uni.getStorageSync('openid'),
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* 搜索文章
|
||||
* @param {Object} params 数据
|
||||
*/
|
||||
getPostListByKeyword: (params) => {
|
||||
return HttpHandler.Get(`/apis/api.halo.run/v1alpha1/indices/post`, params)
|
||||
},
|
||||
/**
|
||||
* 搜索文章
|
||||
* @param {Object} params 数据
|
||||
*/
|
||||
getPostListByKeyword: (params) => {
|
||||
return HttpHandler.Get(`/apis/api.halo.run/v1alpha1/indices/post`, params)
|
||||
},
|
||||
|
||||
/**
|
||||
* 查询分类列表
|
||||
* @param {Object} params 查询参数
|
||||
*/
|
||||
getCategoryList: (params) => {
|
||||
return HttpHandler.Get('/apis/api.content.halo.run/v1alpha1/categories', params)
|
||||
},
|
||||
/**
|
||||
* 查询分类下的文章
|
||||
* @param {String} name 分类名称
|
||||
* @param {Object} params 查询参数
|
||||
*/
|
||||
getCategoryPostList: (name, params) => {
|
||||
return HttpHandler.Get(`/apis/api.content.halo.run/v1alpha1/categories/${name}/posts`, params)
|
||||
},
|
||||
/**
|
||||
* 查询分类列表
|
||||
* @param {Object} params 查询参数
|
||||
*/
|
||||
getCategoryList: (params) => {
|
||||
return HttpHandler.Get('/apis/api.content.halo.run/v1alpha1/categories', params)
|
||||
},
|
||||
/**
|
||||
* 查询分类下的文章
|
||||
* @param {String} name 分类名称
|
||||
* @param {Object} params 查询参数
|
||||
*/
|
||||
getCategoryPostList: (name, params) => {
|
||||
return HttpHandler.Get(`/apis/api.content.halo.run/v1alpha1/categories/${name}/posts`, params)
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* 获取评论列表接口(列表数据)
|
||||
* @param {Object} params 查询参数
|
||||
*/
|
||||
getPostCommentList: (params) => {
|
||||
return HttpHandler.Get(`/apis/api.halo.run/v1alpha1/comments`, params)
|
||||
},
|
||||
/**
|
||||
* 获取评论列表接口(列表数据)
|
||||
* @param {Object} params 查询参数
|
||||
*/
|
||||
getPostCommentList: (params) => {
|
||||
return HttpHandler.Get(`/apis/api.halo.run/v1alpha1/comments`, params)
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取回复列表
|
||||
* @param {String} commentName 名称
|
||||
* @param {Object} params 查询参数
|
||||
*/
|
||||
getPostCommentReplyList: (commentName, params) => {
|
||||
return HttpHandler.Get(`/apis/api.halo.run/v1alpha1/comments/${commentName}/reply`, params)
|
||||
},
|
||||
/**
|
||||
* 获取回复列表
|
||||
* @param {String} commentName 名称
|
||||
* @param {Object} params 查询参数
|
||||
*/
|
||||
getPostCommentReplyList: (commentName, params) => {
|
||||
return HttpHandler.Get(`/apis/api.halo.run/v1alpha1/comments/${commentName}/reply`, params)
|
||||
},
|
||||
|
||||
// 提交评论
|
||||
addPostComment: (data) => {
|
||||
return HttpHandler.Post(`/apis/api.halo.run/v1alpha1/comments`, data)
|
||||
},
|
||||
// 提交回复
|
||||
addPostCommentReply: (commentName, data) => {
|
||||
return HttpHandler.Post(`/apis/api.halo.run/v1alpha1/comments/${commentName}/replay`, data)
|
||||
},
|
||||
// 提交评论
|
||||
addPostComment: (data) => {
|
||||
return HttpHandler.Post(`/apis/api.halo.run/v1alpha1/comments`, data)
|
||||
},
|
||||
// 提交回复
|
||||
addPostCommentReply: (commentName, data) => {
|
||||
return HttpHandler.Post(`/apis/api.halo.run/v1alpha1/comments/${commentName}/replay`, data)
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取标签列表
|
||||
* @param {Object} params 查询参数
|
||||
*/
|
||||
getTagList: (params) => {
|
||||
return HttpHandler.Get(`/apis/api.content.halo.run/v1alpha1/tags`, params)
|
||||
},
|
||||
/**
|
||||
* 获取标签列表
|
||||
* @param {Object} params 查询参数
|
||||
*/
|
||||
getTagList: (params) => {
|
||||
return HttpHandler.Get(`/apis/api.content.halo.run/v1alpha1/tags`, params)
|
||||
},
|
||||
|
||||
/**
|
||||
* 根据标签获取文章列表
|
||||
* @param {String} tagName 参数
|
||||
* @param {Object} params 查询参数
|
||||
*/
|
||||
getPostByTagName: (tagName, params) => {
|
||||
return HttpHandler.Get(`/apis/api.content.halo.run/v1alpha1/tags/${tagName}/posts`, params)
|
||||
},
|
||||
/**
|
||||
* 根据标签获取文章列表
|
||||
* @param {String} tagName 参数
|
||||
* @param {Object} params 查询参数
|
||||
*/
|
||||
getPostByTagName: (tagName, params) => {
|
||||
return HttpHandler.Get(`/apis/api.content.halo.run/v1alpha1/tags/${tagName}/posts`, params)
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取瞬间列表
|
||||
*/
|
||||
getMomentList: (params) => {
|
||||
return HttpHandler.Get(`/apis/moment.halo.run/v1alpha1/moments`, params, {
|
||||
custom: {
|
||||
systemToken: HaloTokenConfig.systemToken
|
||||
}
|
||||
})
|
||||
},
|
||||
/**
|
||||
* 获取瞬间列表
|
||||
*/
|
||||
getMomentList: (params) => {
|
||||
return HttpHandler.Get(`/apis/moment.halo.run/v1alpha1/moments`, params, {
|
||||
custom: {
|
||||
systemToken: HaloTokenConfig.systemToken
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* 查询站点统计信息
|
||||
*/
|
||||
getBlogStatistics: () => {
|
||||
return HttpHandler.Get(`/apis/api.halo.run/v1alpha1/stats/-`, {})
|
||||
},
|
||||
/**
|
||||
* 查询站点统计信息
|
||||
*/
|
||||
getBlogStatistics: () => {
|
||||
return HttpHandler.Get(`/apis/api.halo.run/v1alpha1/stats/-`, {})
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* 获取相册分组
|
||||
*/
|
||||
getPhotoGroupList: (params) => {
|
||||
return HttpHandler.Get(`/apis/core.halo.run/v1alpha1/photogroups`, params, {
|
||||
custom: {
|
||||
systemToken: HaloTokenConfig.systemToken
|
||||
}
|
||||
})
|
||||
},
|
||||
/**
|
||||
* 获取相册分组
|
||||
*/
|
||||
getPhotoGroupList: (params) => {
|
||||
return HttpHandler.Get(`/apis/core.halo.run/v1alpha1/photogroups`, params, {
|
||||
custom: {
|
||||
systemToken: HaloTokenConfig.systemToken
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* 根据分组获取相册
|
||||
*/
|
||||
getPhotoListByGroupName: (params) => {
|
||||
return HttpHandler.Get(`/apis/console.api.photo.halo.run/v1alpha1/photos`, params, {
|
||||
custom: {
|
||||
systemToken: HaloTokenConfig.systemToken
|
||||
}
|
||||
})
|
||||
},
|
||||
/**
|
||||
* 根据分组获取相册
|
||||
*/
|
||||
getPhotoListByGroupName: (params) => {
|
||||
return HttpHandler.Get(`/apis/console.api.photo.halo.run/v1alpha1/photos`, params, {
|
||||
custom: {
|
||||
systemToken: HaloTokenConfig.systemToken
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* 获取友链
|
||||
*/
|
||||
getFriendLinkList: (params) => {
|
||||
return HttpHandler.Get(`/apis/api.plugin.halo.run/v1alpha1/plugins/PluginLinks/links`, params)
|
||||
},
|
||||
/**
|
||||
* 获取友链
|
||||
*/
|
||||
getFriendLinkList: (params) => {
|
||||
return HttpHandler.Get(`/apis/api.plugin.halo.run/v1alpha1/plugins/PluginLinks/links`, params)
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* 校验文章访问密码
|
||||
*/
|
||||
checkPostVerifyCode: (verifyCode, postId) => {
|
||||
return HttpHandler.Get(`/tools/verificationCode/check?code=${verifyCode}`, null, {
|
||||
header: {
|
||||
'Authorization': 'Tools工具箱插件设置的认证token',
|
||||
'Wechat-Session-Id': uni.getStorageSync('openid'),
|
||||
'Post-Id': postId
|
||||
}
|
||||
})
|
||||
},
|
||||
/**
|
||||
* 校验文章访问密码
|
||||
*/
|
||||
checkPostVerifyCode: (verifyCode, postId) => {
|
||||
return HttpHandler.Get(`/tools/verificationCode/check?code=${verifyCode}`, null, {
|
||||
header: {
|
||||
'Authorization': 'Tools工具箱插件设置的认证token',
|
||||
'Wechat-Session-Id': uni.getStorageSync('openid'),
|
||||
'Post-Id': postId
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取文章验证码
|
||||
*/
|
||||
getPostVerifyCode: () => {
|
||||
return HttpHandler.Get(`/tools/verificationCode/create`, null, {
|
||||
header: {
|
||||
'Authorization': 'Tools工具箱插件设置的认证token'
|
||||
}
|
||||
})
|
||||
},
|
||||
}
|
||||
/**
|
||||
* 获取文章验证码
|
||||
*/
|
||||
getPostVerifyCode: () => {
|
||||
return HttpHandler.Get(`/tools/verificationCode/create`, null, {
|
||||
header: {
|
||||
'Authorization': 'Tools工具箱插件设置的认证token'
|
||||
}
|
||||
})
|
||||
},
|
||||
}
|
||||
|
1243
pages.json
1243
pages.json
File diff suppressed because it is too large
Load Diff
@ -1,142 +1,144 @@
|
||||
<template>
|
||||
<tm-fullView>
|
||||
<tm-sheet :shadow="24">
|
||||
<tm-alerts label="观看视频即可获取注册码" close></tm-alerts>
|
||||
<tm-divider color="red" model="dashed" :text="codeDataShow?'请复制下方注册码':'请点击“获取注册码”'"></tm-divider>
|
||||
<view class="ma-20" v-show="!codeDataShow">
|
||||
<tm-button theme="bg-gradient-orange-accent" :round="24" block @click="openVideoAd">获取注册码</tm-button>
|
||||
</view>
|
||||
<view class="ma-20" v-show="codeDataShow">
|
||||
<tm-coupon :hdata="codeData" color="orange" @click="fnCopyCode"></tm-coupon>
|
||||
</view>
|
||||
</tm-sheet>
|
||||
<!-- <tm-sheet :shadow="24">
|
||||
<tm-images @load="loadimg" src="https://picsum.photos/300?id=7"></tm-images>
|
||||
</tm-sheet> -->
|
||||
</tm-fullView>
|
||||
<tm-fullView>
|
||||
<tm-sheet :shadow="24">
|
||||
<tm-alerts label="观看视频即可获取注册码" close></tm-alerts>
|
||||
<tm-divider color="red" model="dashed" :text="codeDataShow?'请复制下方注册码':'请点击“获取注册码”'"></tm-divider>
|
||||
<view class="ma-20" v-show="!codeDataShow">
|
||||
<tm-button theme="bg-gradient-orange-accent" :round="24" block @click="openVideoAd">获取注册码</tm-button>
|
||||
</view>
|
||||
<view class="ma-20" v-show="codeDataShow">
|
||||
<tm-coupon :hdata="codeData" color="orange" @click="fnCopyCode"></tm-coupon>
|
||||
</view>
|
||||
</tm-sheet>
|
||||
<!-- <tm-sheet :shadow="24">
|
||||
<tm-images @load="loadimg" src="https://picsum.photos/300?id=7"></tm-images>
|
||||
</tm-sheet> -->
|
||||
</tm-fullView>
|
||||
|
||||
</template>
|
||||
|
||||
<script>
|
||||
let videoAd = null;
|
||||
import tmFullView from "@/tm-vuetify/components/tm-fullView/tm-fullView.vue"
|
||||
import tmMenubars from "@/tm-vuetify/components/tm-menubars/tm-menubars.vue"
|
||||
import tmSheet from "@/tm-vuetify/components/tm-sheet/tm-sheet.vue"
|
||||
import tmAlerts from "@/tm-vuetify/components/tm-alerts/tm-alerts.vue"
|
||||
import tmDivider from "@/tm-vuetify/components/tm-divider/tm-divider.vue"
|
||||
import tmCoupon from '@/tm-vuetify/components/tm-coupon/tm-coupon.vue'
|
||||
import tmButton from "@/tm-vuetify/components/tm-button/tm-button.vue"
|
||||
import tmImages from "@/tm-vuetify/components/tm-images/tm-images.vue"
|
||||
export default {
|
||||
components: {
|
||||
tmFullView,
|
||||
tmMenubars,
|
||||
tmSheet,
|
||||
tmAlerts,
|
||||
tmDivider,
|
||||
tmCoupon,
|
||||
tmButton,
|
||||
tmImages
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
adUnitId: '',
|
||||
codeDataShow: false,
|
||||
codeData: {
|
||||
// img: 'https://lywq.muyin.site/logo.png',
|
||||
title: "请获取",
|
||||
btnText: '复制',
|
||||
time: '有效期5分钟',
|
||||
sale: '',
|
||||
saleLable: '注册码',
|
||||
saleSplit: ''
|
||||
}
|
||||
}
|
||||
},
|
||||
onLoad(options) {
|
||||
// #ifdef MP-WEIXIN
|
||||
wx.hideShareMenu();
|
||||
this.adLoad();
|
||||
// #endif
|
||||
uni.onCopyUrl((result) => {
|
||||
setTimeout(() => {
|
||||
uni.setClipboardData({
|
||||
data: "禁止复制哦",
|
||||
})
|
||||
}, 1000);
|
||||
})
|
||||
},
|
||||
methods: {
|
||||
adLoad() {
|
||||
if (wx.createRewardedVideoAd) {
|
||||
videoAd = wx.createRewardedVideoAd({
|
||||
adUnitId: haloAdConfig.rewardedVideoAd //你的广告key
|
||||
})
|
||||
videoAd.onError(err => {})
|
||||
videoAd.onClose((status) => {
|
||||
if (status && status.isEnded || status === undefined) {
|
||||
//这里写广告播放完成后的事件
|
||||
this.getRegistrationCode();
|
||||
} else {
|
||||
// 广告播放未完成
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
openVideoAd: function() {
|
||||
if (videoAd && haloAdConfig.rewardedVideoAd != '') {
|
||||
videoAd.show().catch(err => {
|
||||
// 失败重试
|
||||
console.log("广告拉取失败")
|
||||
videoAd.load().then(() => videoAd.show())
|
||||
})
|
||||
} else {
|
||||
this.getRegistrationCode();
|
||||
}
|
||||
},
|
||||
getRegistrationCode() {
|
||||
uni.showLoading({
|
||||
title: '正在获取...'
|
||||
});
|
||||
this.$httpApi.v2.getPostVerifyCode()
|
||||
.then(res => {
|
||||
if (res.code === 200) {
|
||||
uni.$tm.toast('获取成功!');
|
||||
this.codeData.title = res.data;
|
||||
this.codeDataShow = true;
|
||||
} else {
|
||||
uni.$tm.toast('操作失败,请重试!');
|
||||
}
|
||||
})
|
||||
.catch(err => {
|
||||
uni.$tm.toast(err.message);
|
||||
});
|
||||
},
|
||||
fnCopyCode() {
|
||||
uni.setClipboardData({
|
||||
data: this.codeData.title,
|
||||
showToast: false,
|
||||
success: () => {
|
||||
uni.showToast({
|
||||
icon: 'none',
|
||||
title: '复制成功!'
|
||||
});
|
||||
setTimeout(() => {
|
||||
uni.navigateBack()
|
||||
}, 500);
|
||||
},
|
||||
fail: () => {
|
||||
uni.showToast({
|
||||
icon: 'none',
|
||||
title: '复制失败!'
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
let videoAd = null;
|
||||
import tmFullView from "@/tm-vuetify/components/tm-fullView/tm-fullView.vue"
|
||||
import tmMenubars from "@/tm-vuetify/components/tm-menubars/tm-menubars.vue"
|
||||
import tmSheet from "@/tm-vuetify/components/tm-sheet/tm-sheet.vue"
|
||||
import tmAlerts from "@/tm-vuetify/components/tm-alerts/tm-alerts.vue"
|
||||
import tmDivider from "@/tm-vuetify/components/tm-divider/tm-divider.vue"
|
||||
import tmCoupon from '@/tm-vuetify/components/tm-coupon/tm-coupon.vue'
|
||||
import tmButton from "@/tm-vuetify/components/tm-button/tm-button.vue"
|
||||
import tmImages from "@/tm-vuetify/components/tm-images/tm-images.vue"
|
||||
|
||||
export default {
|
||||
components: {
|
||||
tmFullView,
|
||||
tmMenubars,
|
||||
tmSheet,
|
||||
tmAlerts,
|
||||
tmDivider,
|
||||
tmCoupon,
|
||||
tmButton,
|
||||
tmImages
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
adUnitId: '',
|
||||
codeDataShow: false,
|
||||
codeData: {
|
||||
// img: 'https://lywq.muyin.site/logo.png',
|
||||
title: "请获取",
|
||||
btnText: '复制',
|
||||
time: '有效期5分钟',
|
||||
sale: '',
|
||||
saleLable: '注册码',
|
||||
saleSplit: ''
|
||||
}
|
||||
}
|
||||
},
|
||||
onLoad(options) {
|
||||
// #ifdef MP-WEIXIN
|
||||
wx.hideShareMenu();
|
||||
this.adLoad();
|
||||
// #endif
|
||||
uni.onCopyUrl((result) => {
|
||||
setTimeout(() => {
|
||||
uni.setClipboardData({
|
||||
data: "禁止复制哦",
|
||||
})
|
||||
}, 1000);
|
||||
})
|
||||
},
|
||||
methods: {
|
||||
adLoad() {
|
||||
if (wx.createRewardedVideoAd) {
|
||||
videoAd = wx.createRewardedVideoAd({
|
||||
adUnitId: haloAdConfig.rewardedVideoAd //你的广告key
|
||||
})
|
||||
videoAd.onError(err => {
|
||||
})
|
||||
videoAd.onClose((status) => {
|
||||
if (status && status.isEnded || status === undefined) {
|
||||
//这里写广告播放完成后的事件
|
||||
this.getRegistrationCode();
|
||||
} else {
|
||||
// 广告播放未完成
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
openVideoAd: function () {
|
||||
if (videoAd && haloAdConfig.rewardedVideoAd != '') {
|
||||
videoAd.show().catch(err => {
|
||||
// 失败重试
|
||||
console.log("广告拉取失败")
|
||||
videoAd.load().then(() => videoAd.show())
|
||||
})
|
||||
} else {
|
||||
this.getRegistrationCode();
|
||||
}
|
||||
},
|
||||
getRegistrationCode() {
|
||||
uni.showLoading({
|
||||
title: '正在获取...'
|
||||
});
|
||||
this.$httpApi.v2.getPostVerifyCode()
|
||||
.then(res => {
|
||||
if (res.code === 200) {
|
||||
uni.$tm.toast('获取成功!');
|
||||
this.codeData.title = res.data;
|
||||
this.codeDataShow = true;
|
||||
} else {
|
||||
uni.$tm.toast('操作失败,请重试!');
|
||||
}
|
||||
})
|
||||
.catch(err => {
|
||||
uni.$tm.toast(err.message);
|
||||
});
|
||||
},
|
||||
fnCopyCode() {
|
||||
uni.setClipboardData({
|
||||
data: this.codeData.title,
|
||||
showToast: false,
|
||||
success: () => {
|
||||
uni.showToast({
|
||||
icon: 'none',
|
||||
title: '复制成功!'
|
||||
});
|
||||
setTimeout(() => {
|
||||
uni.navigateBack()
|
||||
}, 500);
|
||||
},
|
||||
fail: () => {
|
||||
uni.showToast({
|
||||
icon: 'none',
|
||||
title: '复制失败!'
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
||||
</style>
|
||||
</style>
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user