mirror of
https://github.com/ialley-workshop-open/uni-halo.git
synced 2026-07-27 04:20:43 +08:00
Compare commits
22 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9ab013562d | |||
| a8bd121deb | |||
| 476a1ec48e | |||
| 31ade9908a | |||
| 5606e8c59f | |||
| 61d3b22fdb | |||
| c05aa5253c | |||
| 0b599dcced | |||
| 623e3fa59a | |||
| 1075f588fa | |||
| c0d8cb2c3b | |||
| 9c6a054b12 | |||
| 6a05f664ba | |||
| 9c4d2242ae | |||
| eac027c116 | |||
| 3a08008192 | |||
| 7daf93d51f | |||
| 409be28deb | |||
| 97e358e41f | |||
| c17e668afe | |||
| 4611932ad8 | |||
| 452d021816 |
+262
-205
@@ -1,234 +1,291 @@
|
||||
/**
|
||||
* 所有的接口
|
||||
*/
|
||||
import {getPersonalToken} from '@/utils/token.js'
|
||||
import {
|
||||
getPersonalToken
|
||||
} from '@/utils/token.js'
|
||||
import HttpHandler from '@/common/http/request.js'
|
||||
import qs from 'qs'
|
||||
|
||||
import {getAppConfigs} from '@/config/index.js'
|
||||
import {
|
||||
getAppConfigs
|
||||
} from '@/config/index.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)
|
||||
return HttpHandler.Post(`/apis/api.halo.run/v1alpha1/indices/-/search`, params)
|
||||
},
|
||||
/**
|
||||
* 搜索文章
|
||||
* @param {Object} params 数据
|
||||
*/
|
||||
getPostListByKeyword: (params) => {
|
||||
// return HttpHandler.Get(`/apis/api.halo.run/v1alpha1/indices/post`, params)
|
||||
return HttpHandler.Post(`/apis/api.halo.run/v1alpha1/indices/-/search`, params)
|
||||
},
|
||||
|
||||
/**
|
||||
* 查询分类列表
|
||||
* @param {Object} params 查询参数
|
||||
*/
|
||||
getCategoryList: (params) => {
|
||||
const param = qs.stringify(params, {
|
||||
allowDots: true,
|
||||
encodeValuesOnly: true,
|
||||
skipNulls: true,
|
||||
encode: false,
|
||||
arrayFormat: 'repeat'
|
||||
})
|
||||
return HttpHandler.Get(`/apis/api.content.halo.run/v1alpha1/categories?${param}`, {})
|
||||
},
|
||||
/**
|
||||
* 查询分类下的文章
|
||||
* @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) => {
|
||||
const param = qs.stringify(params, {
|
||||
allowDots: true,
|
||||
encodeValuesOnly: true,
|
||||
skipNulls: true,
|
||||
encode: false,
|
||||
arrayFormat: 'repeat'
|
||||
})
|
||||
return HttpHandler.Get(`/apis/api.content.halo.run/v1alpha1/categories?${param}`, {})
|
||||
},
|
||||
/**
|
||||
* 查询分类下的文章
|
||||
* @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}/reply`, 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}/reply`, 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: {
|
||||
personalToken: getPersonalToken()
|
||||
}
|
||||
})
|
||||
},
|
||||
/**
|
||||
* 获取瞬间列表
|
||||
*/
|
||||
getMomentList: (params) => {
|
||||
return HttpHandler.Get(`/apis/moment.halo.run/v1alpha1/moments`, params, {
|
||||
custom: {
|
||||
personalToken: getPersonalToken()
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* 查询站点统计信息
|
||||
*/
|
||||
getBlogStatistics: () => {
|
||||
return HttpHandler.Get(`/apis/api.halo.run/v1alpha1/stats/-`, {})
|
||||
},
|
||||
/**
|
||||
* 获取瞬间详情
|
||||
* @param {String} name 瞬间id
|
||||
*/
|
||||
getMomentByName: (name) => {
|
||||
return HttpHandler.Get(`/apis/moment.halo.run/v1alpha1/moments/${name}`, {}, {
|
||||
custom: {
|
||||
personalToken: getPersonalToken()
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* 查询站点统计信息
|
||||
*/
|
||||
getBlogStatistics: () => {
|
||||
return HttpHandler.Get(`/apis/api.halo.run/v1alpha1/stats/-`, {})
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* 获取相册分组
|
||||
*/
|
||||
getPhotoGroupList: (params) => {
|
||||
return HttpHandler.Get(`/apis/core.halo.run/v1alpha1/photogroups`, params, {
|
||||
custom: {
|
||||
personalToken: getPersonalToken()
|
||||
}
|
||||
})
|
||||
},
|
||||
/**
|
||||
* 获取相册分组
|
||||
*/
|
||||
getPhotoGroupList: (params) => {
|
||||
return HttpHandler.Get(`/apis/core.halo.run/v1alpha1/photogroups`, params, {
|
||||
custom: {
|
||||
personalToken: getPersonalToken()
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* 根据分组获取相册
|
||||
*/
|
||||
getPhotoListByGroupName: (params) => {
|
||||
return HttpHandler.Get(`/apis/console.api.photo.halo.run/v1alpha1/photos`, params, {
|
||||
custom: {
|
||||
personalToken: getPersonalToken()
|
||||
}
|
||||
})
|
||||
},
|
||||
/**
|
||||
* 根据分组获取相册
|
||||
*/
|
||||
getPhotoListByGroupName: (params) => {
|
||||
return HttpHandler.Get(`/apis/console.api.photo.halo.run/v1alpha1/photos`, params, {
|
||||
custom: {
|
||||
personalToken: getPersonalToken()
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取友链分组
|
||||
*/
|
||||
getFriendLinkGroupList: (params) => {
|
||||
return HttpHandler.Get(`/apis/core.halo.run/v1alpha1/linkgroups`, params, {
|
||||
custom: {
|
||||
personalToken: getPersonalToken()
|
||||
}
|
||||
})
|
||||
},
|
||||
/**
|
||||
* 获取友链分组
|
||||
*/
|
||||
getFriendLinkGroupList: (params) => {
|
||||
return HttpHandler.Get(`/apis/core.halo.run/v1alpha1/linkgroups`, params, {
|
||||
custom: {
|
||||
personalToken: getPersonalToken()
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取友链
|
||||
*/
|
||||
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)
|
||||
},
|
||||
|
||||
/**
|
||||
* 限制阅读校验
|
||||
* @param restrictType
|
||||
* @param code
|
||||
* @param keyId
|
||||
* @returns {HttpPromise<any>}
|
||||
*/
|
||||
requestRestrictReadCheck: (restrictType, code, keyId) => {
|
||||
const params = {
|
||||
code: code,
|
||||
templateType: 'post',
|
||||
restrictType: restrictType,
|
||||
keyId: keyId
|
||||
}
|
||||
return HttpHandler.Post(`/apis/tools.muyin.site/v1alpha1/restrict-read/check`, params, {
|
||||
header: {
|
||||
'Authorization': getAppConfigs().pluginConfig.toolsPlugin?.Authorization,
|
||||
'Wechat-Session-Id': uni.getStorageSync('openid'),
|
||||
}
|
||||
})
|
||||
},
|
||||
/**
|
||||
* 限制阅读校验
|
||||
* @param restrictType
|
||||
* @param code
|
||||
* @param keyId
|
||||
* @returns {HttpPromise<any>}
|
||||
*/
|
||||
requestRestrictReadCheck: (restrictType, code, keyId) => {
|
||||
const params = {
|
||||
code: code,
|
||||
templateType: 'post',
|
||||
restrictType: restrictType,
|
||||
keyId: keyId
|
||||
}
|
||||
return HttpHandler.Post(`/apis/tools.muyin.site/v1alpha1/restrict-read/check`, params, {
|
||||
header: {
|
||||
'Authorization': getAppConfigs().pluginConfig.toolsPlugin?.Authorization,
|
||||
'Wechat-Session-Id': uni.getStorageSync('openid'),
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取文章验证码
|
||||
*/
|
||||
createVerificationCode: () => {
|
||||
return HttpHandler.Get(`/apis/tools.muyin.site/v1alpha1/restrict-read/create`, null, {
|
||||
header: {
|
||||
'Authorization': getAppConfigs().pluginConfig.toolsPlugin?.Authorization,
|
||||
'Wechat-Session-Id': uni.getStorageSync('openid'),
|
||||
}
|
||||
})
|
||||
},
|
||||
/**
|
||||
* 获取文章验证码
|
||||
*/
|
||||
createVerificationCode: () => {
|
||||
return HttpHandler.Get(`/apis/tools.muyin.site/v1alpha1/restrict-read/create`, null, {
|
||||
header: {
|
||||
'Authorization': getAppConfigs().pluginConfig.toolsPlugin?.Authorization,
|
||||
'Wechat-Session-Id': uni.getStorageSync('openid'),
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* 提交友情链接
|
||||
*/
|
||||
submitLink(form) {
|
||||
return HttpHandler.Post(`/apis/linksSubmit.muyin.site/v1alpha1/submit`, form, {
|
||||
header: {
|
||||
'Authorization': getAppConfigs().pluginConfig.linksSubmitPlugin?.Authorization,
|
||||
'Wechat-Session-Id': uni.getStorageSync('openid'),
|
||||
}
|
||||
})
|
||||
},
|
||||
/**
|
||||
* 获取二维码信息
|
||||
*/
|
||||
getQRCodeInfo: (key) => {
|
||||
return HttpHandler.Get(`/apis/api.uni.uhalo.pro/v1alpha1/plugins/plugin-uni-halo/getQRCodeInfo/${key}`,
|
||||
null, {})
|
||||
},
|
||||
/**
|
||||
* 获取二维码图片
|
||||
*/
|
||||
getQRCodeImg: (postId) => {
|
||||
return HttpHandler.Get(`/apis/api.uni.uhalo.pro/v1alpha1/plugins/plugin-uni-halo/getQRCodeImg/${postId}`,
|
||||
null, {})
|
||||
},
|
||||
/**
|
||||
* 点赞
|
||||
* @param {*} data ={group, plural, name}
|
||||
*/
|
||||
submitUpvote(data) {
|
||||
return HttpHandler.Post(`/apis/api.halo.run/v1alpha1/trackers/upvote`, data, {})
|
||||
}
|
||||
/**
|
||||
* 提交友情链接
|
||||
*/
|
||||
submitLink(form) {
|
||||
return HttpHandler.Post(`/apis/linksSubmit.muyin.site/v1alpha1/submit`, form, {
|
||||
header: {
|
||||
'Authorization': getAppConfigs().pluginConfig.linksSubmitPlugin?.Authorization,
|
||||
'Wechat-Session-Id': uni.getStorageSync('openid'),
|
||||
}
|
||||
})
|
||||
},
|
||||
/**
|
||||
* 获取二维码信息
|
||||
*/
|
||||
getQRCodeInfo: (key) => {
|
||||
return HttpHandler.Get(`/apis/api.uni.uhalo.pro/v1alpha1/plugins/plugin-uni-halo/getQRCodeInfo/${key}`,
|
||||
null, {})
|
||||
},
|
||||
/**
|
||||
* 获取二维码图片
|
||||
*/
|
||||
getQRCodeImg: (postId) => {
|
||||
return HttpHandler.Get(`/apis/api.uni.uhalo.pro/v1alpha1/plugins/plugin-uni-halo/getQRCodeImg/${postId}`,
|
||||
null, {})
|
||||
},
|
||||
/**
|
||||
* 点赞
|
||||
* @param {*} data ={group, plural, name}
|
||||
*/
|
||||
submitUpvote(data) {
|
||||
return HttpHandler.Post(`/apis/api.halo.run/v1alpha1/trackers/upvote`, data, {})
|
||||
},
|
||||
|
||||
}
|
||||
//----------- 投票 -----------------
|
||||
/**
|
||||
* 获取投票列表
|
||||
*/
|
||||
getVoteList: (params) => {
|
||||
return HttpHandler.Get(`/apis/api.vote.kunkunyu.com/v1alpha1/votes`, params)
|
||||
},
|
||||
/**
|
||||
* 获取投票详情
|
||||
* @param {String} name id
|
||||
*/
|
||||
getVoteDetail: (name) => {
|
||||
return HttpHandler.Get(`/apis/api.vote.kunkunyu.com/v1alpha1/votes/${name}/detail`, {})
|
||||
},
|
||||
/**
|
||||
* 获取投票用户列表
|
||||
* @param {String} name id
|
||||
*/
|
||||
getVoteUserList: (name) => {
|
||||
return HttpHandler.Get(`/apis/api.vote.kunkunyu.com/v1alpha1/votes/${name}/user-list`, {})
|
||||
},
|
||||
/**
|
||||
* 提交投票
|
||||
* @param {String} name id
|
||||
* @param {Object} { voteData:["选项ID"] } 提交的数据
|
||||
* @param {Boolean} canAnonymously 是否匿名 默认匿名
|
||||
*/
|
||||
submitVote: (name, data, canAnonymously = true) => {
|
||||
return HttpHandler.Post(`/apis/api.vote.kunkunyu.com/v1alpha1/votes/${name}/submit`, data, {
|
||||
custom: {
|
||||
personalToken: canAnonymously ? undefined : getPersonalToken()
|
||||
}
|
||||
})
|
||||
},
|
||||
/**
|
||||
* 检查是否安装启用插件
|
||||
* @param {String} name 插件id
|
||||
*/
|
||||
checkPluginAvailable: (name) => {
|
||||
return HttpHandler.Get(`/apis/api.plugin.halo.run/v1alpha1/plugins/${name}/available`, {})
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
/**
|
||||
* 功能:插件检查
|
||||
*/
|
||||
import {
|
||||
NeedPluginIds,
|
||||
NeedPlugins,
|
||||
checkNeedPluginAvailable
|
||||
} from "@/utils/plugin.js"
|
||||
|
||||
const HaloPluginAvailableMixin = {
|
||||
data() {
|
||||
return {
|
||||
NeedPluginIds,
|
||||
NeedPlugins,
|
||||
uniHaloPluginAvailableError: "",
|
||||
uniHaloPluginAvailable: true,
|
||||
uniHaloPluginPageClass: "",
|
||||
uniHaloPluginId: "", // 当前需要的插件
|
||||
uniHaloPluginInfo: "" // 当前插件信息
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
uniHaloPluginAvailable: {
|
||||
immediate: true,
|
||||
handler(val) {
|
||||
if (val) {
|
||||
this.uniHaloPluginPageClass = ""
|
||||
} else {
|
||||
this.uniHaloPluginPageClass = "box-border items-center justify-center"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
/** 设置插件ID */
|
||||
setPluginId(pluginId) {
|
||||
this.uniHaloPluginId = pluginId
|
||||
this.uniHaloPluginInfo = NeedPlugins.get(pluginId)
|
||||
},
|
||||
/** 检查插件状态 */
|
||||
async checkPluginAvailable(pluginId) {
|
||||
pluginId = pluginId ?? this.uniHaloPluginId
|
||||
if (!pluginId) return false;
|
||||
const available = await checkNeedPluginAvailable(pluginId)
|
||||
this.uniHaloPluginAvailable = available
|
||||
return available
|
||||
},
|
||||
/** 设置错误信息 */
|
||||
setPluginError(text) {
|
||||
this.uniHaloPluginAvailableError = text
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
export default HaloPluginAvailableMixin;
|
||||
@@ -172,3 +172,178 @@
|
||||
}
|
||||
|
||||
/* 文本省略样式 结束 */
|
||||
|
||||
.box-border{
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
// 定义尺寸变量(单位:rpx)
|
||||
$spacing-sizes: (
|
||||
0: 0,
|
||||
2: 4rpx,
|
||||
4: 8rpx,
|
||||
8: 16rpx,
|
||||
12: 24rpx,
|
||||
24: 48rpx,
|
||||
48: 96rpx
|
||||
);
|
||||
|
||||
// 内边距类
|
||||
@each $name, $size in $spacing-sizes {
|
||||
// 全方向内边距:p-{size}
|
||||
.uh-p-#{$name} {
|
||||
padding: $size !important;
|
||||
}
|
||||
|
||||
// 水平方向内边距:px-{size}
|
||||
.uh-px-#{$name} {
|
||||
padding-left: $size !important;
|
||||
padding-right: $size !important;
|
||||
}
|
||||
|
||||
// 垂直方向内边距:py-{size}
|
||||
.uh-py-#{$name} {
|
||||
padding-top: $size !important;
|
||||
padding-bottom: $size !important;
|
||||
}
|
||||
|
||||
// 上内边距:pt-{size}
|
||||
.uh-pt-#{$name} {
|
||||
padding-top: $size !important;
|
||||
}
|
||||
|
||||
// 右内边距:pr-{size}
|
||||
.uh-pr-#{$name} {
|
||||
padding-right: $size !important;
|
||||
}
|
||||
|
||||
// 下内边距:pb-{size}
|
||||
.uh-pb-#{$name} {
|
||||
padding-bottom: $size !important;
|
||||
}
|
||||
|
||||
// 左内边距:pl-{size}
|
||||
.uh-pl-#{$name} {
|
||||
padding-left: $size !important;
|
||||
}
|
||||
}
|
||||
|
||||
//外边距工具类
|
||||
@each $name, $size in $spacing-sizes {
|
||||
// 全方向外边距:m-{size}
|
||||
.uh-m-#{$name} {
|
||||
margin: $size !important;
|
||||
}
|
||||
|
||||
// 水平方向外边距:mx-{size}
|
||||
.uh-mx-#{$name} {
|
||||
margin-left: $size !important;
|
||||
margin-right: $size !important;
|
||||
}
|
||||
|
||||
// 垂直方向外边距:my-{size}
|
||||
.uh-my-#{$name} {
|
||||
margin-top: $size !important;
|
||||
margin-bottom: $size !important;
|
||||
}
|
||||
|
||||
// 上外边距:mt-{size}
|
||||
.uh-mt-#{$name} {
|
||||
margin-top: $size !important;
|
||||
}
|
||||
|
||||
// 右外边距:mr-{size}
|
||||
.uh-mr-#{$name} {
|
||||
margin-right: $size !important;
|
||||
}
|
||||
|
||||
// 下外边距:mb-{size}
|
||||
.uh-mb-#{$name} {
|
||||
margin-bottom: $size !important;
|
||||
}
|
||||
|
||||
// 左外边距:ml-{size}
|
||||
.uh-ml-#{$name} {
|
||||
margin-left: $size !important;
|
||||
}
|
||||
}
|
||||
|
||||
// gap 类
|
||||
@each $name, $size in $spacing-sizes {
|
||||
// 全方向gap:gap-{size}
|
||||
.uh-gap-#{$name} {
|
||||
gap: $size !important;
|
||||
}
|
||||
|
||||
// 水平方向gap:gap-x-{size}
|
||||
.uh-gap-x-#{$name} {
|
||||
column-gap: $size !important;
|
||||
}
|
||||
|
||||
// 垂直方向gap:gap-y-{size}
|
||||
.uh-gap-y-#{$name} {
|
||||
row-gap: $size !important;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
.w-full {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.h-full {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.flex {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.flex-col {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.flex-1 {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.flex-shrink-0 {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.items-center {
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.items-start {
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
.items-end {
|
||||
align-items: flex-end;
|
||||
}
|
||||
|
||||
.justify-between {
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.justify-around {
|
||||
justify-content: space-around;
|
||||
}
|
||||
|
||||
.justify-end {
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
.justify-start {
|
||||
justify-content: flex-start;
|
||||
}
|
||||
|
||||
.justify-center {
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.text-break {
|
||||
overflow-wrap: break-word;
|
||||
word-break: break-all;
|
||||
}
|
||||
@@ -0,0 +1,569 @@
|
||||
<template>
|
||||
<view class="vote-card" :class="[loading]">
|
||||
<view v-if="loading !=='success'" class="vote-error" @click="fnGetData()">
|
||||
{{loadingText}}
|
||||
</view>
|
||||
<template v-else>
|
||||
<view class="vote-card-head flex flex-col">
|
||||
<view class="flex justify-between">
|
||||
<view class="flex">
|
||||
<tm-tags color="orange" style="min-width:40rpx;" :shadow="0" rounded size="s"
|
||||
model="fill">{{ index + 1 }}</tm-tags>
|
||||
<tm-tags color="light-blue" :shadow="0" rounded size="s"
|
||||
model="fill">{{ vote.spec._uh_type }}</tm-tags>
|
||||
<tm-tags :color="vote.spec._uh_state.color" size="s" rounded :shadow="0"
|
||||
model="fill">{{vote.spec._uh_state.state}}</tm-tags>
|
||||
</view>
|
||||
<view class="flex-shrink">
|
||||
<tm-button theme="light-blue" :shadow="0" dense size="s"
|
||||
@click="handleToVoteDetail(vote)">查看投票详情</tm-button>
|
||||
</view>
|
||||
</view>
|
||||
<view class="title">
|
||||
{{ vote.spec.title }}
|
||||
</view>
|
||||
</view>
|
||||
<view class="vote-card-body">
|
||||
|
||||
<view v-if="vote.spec.remark" class="remark text-size-s">
|
||||
{{vote.spec.remark}}
|
||||
</view>
|
||||
|
||||
<template>
|
||||
<!-- 单选 -->
|
||||
<view v-if="vote.spec.type==='single'" class="single">
|
||||
<view class="w-full flex flex-col uh-gap-8">
|
||||
<template v-if="vote.spec.isVoted || vote.spec.hasEnded">
|
||||
<view v-for="(option,optionIndex) in vote.spec.options" :key="optionIndex"
|
||||
class="is-voted-item" :class="[option.checked?'selected':'']" :style="{
|
||||
'--percent': option._uh_percent + '%'
|
||||
}">
|
||||
<view class="is-voted-item-content flex w-full flex-between uh-gap-4">
|
||||
<view class="text-align-left flex-1 text-break">
|
||||
{{option.title }}
|
||||
</view>
|
||||
<view class="flex-shrink ">
|
||||
{{option._uh_percent }}%
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
<template v-else>
|
||||
<view v-for="(option,optionIndex) in vote.spec.options" :key="optionIndex"
|
||||
class="vote-select-option flex-1 w-full text-break"
|
||||
:class="[option.checked?'light-blue':'grey-lighten-3']"
|
||||
@click="handleSelectSingleOption(option)">
|
||||
{{option.title }}
|
||||
</view>
|
||||
</template>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 多选 -->
|
||||
<view v-else-if="vote.spec.type==='multiple'" class="multiple">
|
||||
<view class="w-full flex flex-col uh-gap-8">
|
||||
<template v-if="vote.spec.isVoted || vote.spec.hasEnded">
|
||||
<view v-for="(option,optionIndex) in vote.spec.options" :key="optionIndex"
|
||||
class="is-voted-item" :class="[option.checked?'selected':'']" :style="{
|
||||
'--percent': option._uh_percent + '%'
|
||||
}">
|
||||
<view class="is-voted-item-content flex w-full flex-between uh-gap-4">
|
||||
<view class="text-align-left flex-1 text-break">
|
||||
{{option.title }}
|
||||
</view>
|
||||
<view class="flex-shrink ">
|
||||
{{option._uh_percent }}%
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
<template v-else>
|
||||
<view v-for="(option,optionIndex) in vote.spec.options" :key="optionIndex"
|
||||
class="vote-select-option flex-1 w-full text-break"
|
||||
:class="[option.checked?'light-blue':'grey-lighten-3']"
|
||||
@click="handleSelectCheckboxOption(option)">
|
||||
{{option.title }}
|
||||
</view>
|
||||
</template>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- PK -->
|
||||
<view v-else-if="vote.spec.type==='pk'" class="pk">
|
||||
<view class="pk-container">
|
||||
<view class="radio-item" v-for="(option,optionIndex) in vote.spec.options"
|
||||
:key="optionIndex" :class="[optionIndex==0?'radio-left':'radio-right']"
|
||||
:style="{width:option._uh_percent + '%'}">
|
||||
<view class="option-item"
|
||||
:class="[optionIndex==0?'option-item-left':'option-item-right']">
|
||||
{{option._uh_percent }}%
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="option-foot w-full flex flex-between uh-mt-12">
|
||||
<view class="w-full flex flex-col uh-gap-8">
|
||||
<template v-if="vote.spec.isVoted || vote.spec.hasEnded">
|
||||
<view v-for="(option,optionIndex) in vote.spec.options" :key="optionIndex"
|
||||
class="is-voted-item" :class="[option.checked?'selected':'']" :style="{
|
||||
'--percent': option._uh_percent + '%'
|
||||
}">
|
||||
<view class="is-voted-item-content flex w-full flex-between uh-gap-4">
|
||||
<view class="text-align-left flex-1 text-break">
|
||||
{{option.title }}
|
||||
</view>
|
||||
<view class="flex-shrink ">
|
||||
{{option._uh_percent }}%
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
<template v-else>
|
||||
<view v-for="(option,optionIndex) in vote.spec.options" :key="optionIndex"
|
||||
class="vote-select-option flex-1 w-full text-break"
|
||||
:class="[option.checked?'light-blue':'grey-lighten-3']"
|
||||
@click="handleSelectSingleOption(option)">
|
||||
选项{{ optionIndex+1}}:{{option.title }}
|
||||
</view>
|
||||
</template>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
</view>
|
||||
<view class="vote-card-foot flex flex-between">
|
||||
<view class="left flex">
|
||||
<tm-tags v-if="vote.spec.timeLimit==='permanent'" color="grey-darken-2" rounded size="s"
|
||||
model="text">结束:永久有效 </tm-tags>
|
||||
<tm-tags v-else color="grey-darken-2" rounded size="s" model="text">
|
||||
<template
|
||||
v-if="vote.spec._state=='未开始'">开始:{{ {d: vote.spec.startDate, f: 'yyyy-MM-dd HH:mm'} | formatTime }}
|
||||
</template>
|
||||
<template v-else>结束:{{ {d: vote.spec.endDate, f: 'yyyy-MM-dd HH:mm'} | formatTime }}
|
||||
</template>
|
||||
</tm-tags>
|
||||
</view>
|
||||
|
||||
<view class="right flex flex-end">
|
||||
<tm-tags color="grey-darken-2" rounded size="s" model="text">{{ vote.stats.voteCount }}
|
||||
人已参与</tm-tags>
|
||||
<tm-tags v-if="vote.spec.isVoted" color="blue" rounded size="s" model="text">已投票</tm-tags>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view v-if="submitForm.voteData.length!==0" class="box-border uh-mt-12 w-full uh-px-2">
|
||||
<tm-button v-if="fnCalcIsVoted()" theme="white" text :block="true" class="w-full">您已参与投票</tm-button>
|
||||
<tm-button v-else-if="vote.spec._uh_state.state==='未开始'" theme="orange" text class="w-full" :height="72"
|
||||
:block="true" @click="handleSubmitTip('投票未开始')">投票未开始</tm-button>
|
||||
<tm-button v-else-if="vote.spec._uh_state.state==='已结束'" theme="red" text class="w-full" :height="72"
|
||||
:block="true" @click="handleSubmitTip('投票已结束')">投票已结束</tm-button>
|
||||
<tm-button v-else-if="!vote.spec.canAnonymously" theme="red" :shadow="0" class="w-full" :height="72"
|
||||
text :block="true" @click="handleSubmit()">不支持匿名投票</tm-button>
|
||||
<tm-button v-else-if="submitForm.voteData.length===0" theme="white" text class="w-full" :height="72"
|
||||
:block="true" @click="handleSubmitTip('请选择选项')">提交投票(请选择选项)</tm-button>
|
||||
<tm-button v-else theme="light-blue" class="w-full" :height="72" :block="true" :loading="submitLoading"
|
||||
:disabled="submitLoading" @click="handleSubmit()">提交投票</tm-button>
|
||||
</view>
|
||||
</template>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import tmButton from '@/tm-vuetify/components/tm-button/tm-button.vue';
|
||||
import tmTags from '@/tm-vuetify/components/tm-tags/tm-tags.vue';
|
||||
import {
|
||||
VOTE_TYPES,
|
||||
calcVoteState,
|
||||
calcVotePercent,
|
||||
voteCacheUtil
|
||||
} from '@/utils/vote.js'
|
||||
|
||||
export default {
|
||||
name: "ArticleVote",
|
||||
components: {
|
||||
tmButton,
|
||||
tmTags
|
||||
},
|
||||
props: {
|
||||
voteId: {
|
||||
type: String,
|
||||
default: ""
|
||||
},
|
||||
index: {
|
||||
type: Number,
|
||||
default: 0
|
||||
},
|
||||
article: {
|
||||
type: Object,
|
||||
default: () => ({})
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
loading: "loading",
|
||||
loadingText: "加载中,请稍等...",
|
||||
detail: null,
|
||||
vote: null,
|
||||
submitForm: {
|
||||
voteData: []
|
||||
},
|
||||
submitLoading: false
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.fnGetData();
|
||||
},
|
||||
methods: {
|
||||
fnGetData() {
|
||||
this.loadingText = "加载中,请稍等...";
|
||||
this.loading = "loading";
|
||||
this.$httpApi.v2
|
||||
.getVoteDetail(this.voteId)
|
||||
.then(res => {
|
||||
this.pageTitle = "投票详情" + `(${VOTE_TYPES[res.vote.spec.type]})`
|
||||
|
||||
const tempVoteRes = res;
|
||||
|
||||
tempVoteRes.vote.spec.isVoted = this.fnCalcIsVoted()
|
||||
tempVoteRes.vote.spec.disabled = this.fnCalcIsVoted()
|
||||
tempVoteRes.vote.spec._uh_state = calcVoteState(tempVoteRes.vote)
|
||||
tempVoteRes.vote.spec._uh_type = VOTE_TYPES[tempVoteRes.vote.spec.type]
|
||||
|
||||
tempVoteRes.vote.spec.options.map((option, index) => {
|
||||
option.value = option.id
|
||||
option.label = option.title
|
||||
option.isVoted = this.fnCalcIsVoted()
|
||||
option.checked = this.fnCalcIsChecked(option)
|
||||
option._uh_percent = calcVotePercent(tempVoteRes.vote, option);
|
||||
option.dataStr = JSON.stringify(option)
|
||||
|
||||
return option
|
||||
})
|
||||
|
||||
this.vote = tempVoteRes.vote
|
||||
this.detail = tempVoteRes;
|
||||
|
||||
setTimeout(() => {
|
||||
this.loading = 'success';
|
||||
}, 200);
|
||||
})
|
||||
.catch(err => {
|
||||
console.error(err);
|
||||
this.loading = 'error';
|
||||
this.loadingText = "投票内容加载失败,点击重试"
|
||||
})
|
||||
},
|
||||
|
||||
fnCalcIsVoted() {
|
||||
return voteCacheUtil.has(this.voteId)
|
||||
},
|
||||
fnCalcIsChecked(option) {
|
||||
const data = voteCacheUtil.get(this.voteId)
|
||||
if (!data) return false;
|
||||
const checked = data.selected.includes(option.id)
|
||||
return checked
|
||||
},
|
||||
formatJsonStr(jsonStr) {
|
||||
return jsonStr ? JSON.parse(jsonStr) : {}
|
||||
},
|
||||
handleSubmitTip(text) {
|
||||
uni.showToast({
|
||||
icon: "none",
|
||||
title: text
|
||||
})
|
||||
},
|
||||
handleSubmit() {
|
||||
if (!this.vote.spec.canAnonymously) {
|
||||
uni.showModal({
|
||||
icon: "none",
|
||||
title: "提示",
|
||||
content: "该投票不支持匿名,请到博主的 网站端 进行投票!",
|
||||
cancelColor: "#666666",
|
||||
cancelText: "关闭",
|
||||
confirmText: "复制地址",
|
||||
success: (res) => {
|
||||
if (res.confirm) {
|
||||
console.log("this.article", this.article)
|
||||
const articleUrl = this.$baseApiUrl + (this.article?.status?.permalink ?? "")
|
||||
this.$utils.copyText(articleUrl, "原文地址复制成功")
|
||||
}
|
||||
}
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
uni.showLoading({
|
||||
title: "正在保存..."
|
||||
})
|
||||
this.submitLoading = true
|
||||
this.$httpApi.v2
|
||||
.submitVote(this.voteId, this.submitForm, this.vote.spec.canAnonymously)
|
||||
.then(res => {
|
||||
uni.showToast({
|
||||
icon: "none",
|
||||
title: "提交成功"
|
||||
})
|
||||
|
||||
voteCacheUtil.set(this.voteId, {
|
||||
selected: [...this.submitForm.voteData],
|
||||
data: this.vote
|
||||
})
|
||||
|
||||
this.fnGetData()
|
||||
})
|
||||
.catch(err => {
|
||||
console.error(err);
|
||||
uni.showToast({
|
||||
icon: "none",
|
||||
title: "提交失败,请重试"
|
||||
})
|
||||
}).finally(() => {
|
||||
this.submitLoading = false
|
||||
})
|
||||
},
|
||||
|
||||
handleSelectSingleOption(option) {
|
||||
if (this.vote.spec._uh_state.state == '未开始') {
|
||||
this.showToast(`投票未开始`)
|
||||
return
|
||||
}
|
||||
if (this.vote.spec.hasEnded) return
|
||||
if (this.vote.spec.disabled) return
|
||||
this.vote.spec.options.map(item => {
|
||||
if (option.id == item.id) {
|
||||
item.checked = true
|
||||
} else {
|
||||
item.checked = false
|
||||
}
|
||||
})
|
||||
this.submitForm.voteData = this.vote.spec.options.filter(x => x.checked).map(item => item.id)
|
||||
},
|
||||
|
||||
handleSelectCheckboxOption(option) {
|
||||
if (this.vote.spec._uh_state.state == '未开始') {
|
||||
this.showToast(`投票未开始`)
|
||||
return
|
||||
}
|
||||
|
||||
if (this.vote.spec.hasEnded) return
|
||||
if (this.vote.spec.disabled) return
|
||||
|
||||
const checkedList = this.vote.spec.options.filter(x => x.checked && x.id != option.id)
|
||||
|
||||
if (this.vote.spec.type === 'multiple' && checkedList.length >= this.vote.spec.maxVotes) {
|
||||
this.showToast(`最多选择 ${this.vote.spec.maxVotes} 项`)
|
||||
return
|
||||
}
|
||||
|
||||
this.vote.spec.options.map(item => {
|
||||
if (option.id == item.id) {
|
||||
item.checked = !item.checked
|
||||
}
|
||||
})
|
||||
this.submitForm.voteData = this.vote.spec.options.filter(x => x.checked).map(item => item.id)
|
||||
},
|
||||
handleToVoteDetail(vote) {
|
||||
uni.navigateTo({
|
||||
url: `/pagesA/vote-detail/vote-detail?name=${vote.metadata.name}`
|
||||
});
|
||||
},
|
||||
showToast(content) {
|
||||
uni.showToast({
|
||||
icon: "none",
|
||||
title: content,
|
||||
mask: true
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.w-full {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.wp-50 {
|
||||
width: 50%;
|
||||
}
|
||||
|
||||
.vote-card {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
box-sizing: border-box;
|
||||
padding: 24rpx;
|
||||
border-radius: 12rpx;
|
||||
background-color: #ffff;
|
||||
overflow: hidden;
|
||||
margin-bottom: 12rpx;
|
||||
border: 1px solid #eee;
|
||||
|
||||
&.error {
|
||||
padding: 0;
|
||||
border-style: dashed;
|
||||
border-color: #e88080;
|
||||
color: #e88080;
|
||||
background-color: rgba(232, 128, 128, 0.075);
|
||||
}
|
||||
|
||||
&.loading {
|
||||
padding: 0;
|
||||
border-style: dashed;
|
||||
border-color: rgba(3, 174, 252, 1);
|
||||
color: rgba(3, 174, 252, 1);
|
||||
background-color: rgba(3, 174, 252, 0.075);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
.vote-error {
|
||||
padding: 50rpx 24rpx;
|
||||
font-size: 24rpx;
|
||||
border-radius: 12rpx;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.vote-card-head {
|
||||
margin-bottom: 12rpx;
|
||||
|
||||
.title {
|
||||
padding: 12rpx 0;
|
||||
font-size: 28rpx;
|
||||
font-weight: bold;
|
||||
}
|
||||
}
|
||||
|
||||
.vote-card-body {
|
||||
|
||||
.remark {
|
||||
box-sizing: border-box;
|
||||
color: rgba(0, 0, 0, 0.75);
|
||||
margin-bottom: 24rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.vote-card-foot {
|
||||
box-sizing: border-box;
|
||||
padding-top: 6px;
|
||||
margin-top: 12px;
|
||||
border-top: 2rpx solid #eee;
|
||||
|
||||
.left {}
|
||||
}
|
||||
|
||||
.is-voted-item {
|
||||
min-height: 72rpx;
|
||||
box-sizing: border-box;
|
||||
position: relative;
|
||||
border-radius: 12rpx;
|
||||
background-color: rgba(229, 229, 229, 0.75);
|
||||
font-size: 24rpx;
|
||||
overflow: hidden;
|
||||
|
||||
&::before {
|
||||
content: "";
|
||||
width: var(--percent);
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
background-color: rgba(208, 208, 208, 1);
|
||||
z-index: 0;
|
||||
border-radius: 6rpx;
|
||||
}
|
||||
|
||||
&.selected {
|
||||
background-color: rgba(3, 169, 244, 0.35);
|
||||
color: #ffffff;
|
||||
|
||||
&::before {
|
||||
background-color: rgba(3, 169, 244, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.is-voted-item-content {
|
||||
box-sizing: border-box;
|
||||
min-height: 72rpx;
|
||||
padding: 12rpx 24rpx;
|
||||
position: relative;
|
||||
z-index: 2;
|
||||
}
|
||||
|
||||
.vote-select-option {
|
||||
box-sizing: border-box;
|
||||
padding: 20rpx 24rpx;
|
||||
font-size: 24rpx;
|
||||
border-radius: 12rpx;
|
||||
transition: all 0.1s ease-in-out;
|
||||
}
|
||||
|
||||
.single {
|
||||
::v-deep {}
|
||||
}
|
||||
|
||||
.multiple {
|
||||
::v-deep {}
|
||||
}
|
||||
|
||||
.pk {
|
||||
box-sizing: border-box;
|
||||
width: 100%;
|
||||
padding: 0 12rpx;
|
||||
|
||||
::v-deep {
|
||||
|
||||
.pk-container {
|
||||
box-sizing: border-box;
|
||||
width: 100%;
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.radio-item {
|
||||
flex-grow: 1;
|
||||
min-width: 30% !important;
|
||||
max-width: 70% !important;
|
||||
}
|
||||
|
||||
.radio-left {}
|
||||
|
||||
.radio-right {}
|
||||
|
||||
.option-item {
|
||||
box-sizing: border-box;
|
||||
width: 100%;
|
||||
padding: 24rpx;
|
||||
border-radius: 12rpx;
|
||||
}
|
||||
|
||||
.option-item-left {
|
||||
background: linear-gradient(90deg, #3B82F6, #60A5FA);
|
||||
color: white;
|
||||
clip-path: polygon(0 0, calc(100% - 40rpx) 0, 100% 100%, 0 100%);
|
||||
}
|
||||
|
||||
.option-item-right {
|
||||
background: linear-gradient(90deg, #F87171, #EF4444);
|
||||
color: white;
|
||||
clip-path: polygon(0 0, 100% 0, 100% 100%, 40rpx 100%);
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.option-foot {
|
||||
width: 100%;
|
||||
margin-top: 6rpx;
|
||||
font-size: 24rpx;
|
||||
color: #666;
|
||||
|
||||
.left {
|
||||
box-sizing: border-box;
|
||||
padding-right: 24rpx;
|
||||
}
|
||||
|
||||
.right {
|
||||
box-sizing: border-box;
|
||||
padding-left: 24rpx;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,200 @@
|
||||
<template>
|
||||
<view v-if="pluginInfo" class="plugin-unavailable flex flex-col flex-center"
|
||||
:class="{border:useBorder,'decoration':useDecoration}" :style="[calcCustomStyle]">
|
||||
<!-- 图标 -->
|
||||
<image class="plugin-logo" :src="pluginInfo.logo" mode="scaleToFill"></image>
|
||||
<!-- 名称 -->
|
||||
<view class="plugin-name">
|
||||
{{ pluginInfo.name }}
|
||||
</view>
|
||||
<view class="plugin-error">
|
||||
未安装/启用插件
|
||||
</view>
|
||||
<!-- 描述 -->
|
||||
<view class="plugin-desc">
|
||||
{{ pluginInfo.desc }}
|
||||
</view>
|
||||
<view v-if="errorText" class="plugin-tip">
|
||||
{{errorText}}
|
||||
</view>
|
||||
<!-- 插件地址 -->
|
||||
<view class="plugin-url">
|
||||
插件地址:{{ pluginInfo.url }}
|
||||
</view>
|
||||
<!-- 反馈按钮/复制地址 -->
|
||||
<view class="plugin-btns w-full flex-center">
|
||||
<!-- #ifndef MP-WEIXIN -->
|
||||
<tm-button theme="light-blue" :block="true" class="w-full" :height="70" @click="copy">复制地址</tm-button>
|
||||
<!-- #endif -->
|
||||
<!-- #ifdef MP-WEIXIN -->
|
||||
<tm-button theme="light-blue" plan text :height="70" @click="copy">复制地址</tm-button>
|
||||
<tm-button theme="light-blue" open-type="contact" :height="70">提交反馈</tm-button>
|
||||
<!-- #endif -->
|
||||
</view>
|
||||
|
||||
<view class="plugin-copyright">
|
||||
提示:请确保 Halo 博客已安装相关插件
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {
|
||||
NeedPluginIds,
|
||||
NeedPlugins,
|
||||
CheckNeedPluginAvailable
|
||||
} from "@/utils/plugin.js"
|
||||
import utils from '@/utils/index.js'
|
||||
|
||||
import tmButton from '@/tm-vuetify/components/tm-button/tm-button.vue';
|
||||
|
||||
export default {
|
||||
name: "plugin-unavailable",
|
||||
components: {
|
||||
tmButton
|
||||
},
|
||||
props: {
|
||||
pluginId: {
|
||||
type: String,
|
||||
default: ""
|
||||
},
|
||||
errorText: {
|
||||
type: String,
|
||||
default: ""
|
||||
},
|
||||
useDecoration: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
},
|
||||
useBorder: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
},
|
||||
customStyle: {
|
||||
type: Object,
|
||||
default: () => ({})
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
NeedPluginIds,
|
||||
NeedPlugins,
|
||||
pluginInfo: null,
|
||||
defaultStyle: {
|
||||
width: "80vw",
|
||||
borderRadius: "24rpx"
|
||||
}
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
calcCustomStyle() {
|
||||
const style = this.customStyle ?? {}
|
||||
return {
|
||||
...this.defaultStyle,
|
||||
...style
|
||||
}
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
pluginId: {
|
||||
deep: true,
|
||||
immediate: true,
|
||||
handler(newVal, oldVal) {
|
||||
this.pluginInfo = NeedPlugins.get(newVal)
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
copy() {
|
||||
utils.copyText(this.pluginInfo.url, "插件地址已复制")
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.plugin-unavailable {
|
||||
box-sizing: border-box;
|
||||
margin: auto;
|
||||
padding: 100rpx 36rpx;
|
||||
gap: 24rpx;
|
||||
font-size: 28rpx;
|
||||
|
||||
&.border {
|
||||
// border: 2rpx solid #E2E8F0;
|
||||
border: 2rpx solid #eee;
|
||||
}
|
||||
|
||||
&.decoration {
|
||||
background-color: rgba(255, 255, 255, 0.95);
|
||||
box-shadow: 0 0 12rpx rgba(226, 232, 240, 0.35);
|
||||
backdrop-filter: blur(6rpx);
|
||||
border-top: 12rpx solid rgba(3, 169, 244, 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
.plugin-logo {
|
||||
box-sizing: border-box;
|
||||
width: 120rpx;
|
||||
height: 120rpx;
|
||||
border-radius: 24rpx;
|
||||
}
|
||||
|
||||
.plugin-name {
|
||||
box-sizing: border-box;
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
font-size: 32rpx;
|
||||
}
|
||||
|
||||
.plugin-error {
|
||||
box-sizing: border-box;
|
||||
padding: 6rpx 16rpx;
|
||||
border-radius: 36rpx;
|
||||
background-color: rgba(255, 61, 49, 0.075);
|
||||
color: rgba(255, 61, 49, 1);
|
||||
font-size: 24rpx;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.plugin-tip {
|
||||
box-sizing: border-box;
|
||||
padding: 10rpx 20rpx;
|
||||
border-radius: 12rpx;
|
||||
border: 2rpx dashed #f2c97d;
|
||||
color: #f0a020;
|
||||
font-size: 24rpx;
|
||||
}
|
||||
|
||||
.plugin-desc {
|
||||
box-sizing: border-box;
|
||||
width: 60vw;
|
||||
font-size: 24rpx;
|
||||
text-align: center;
|
||||
color: #64748b;
|
||||
}
|
||||
|
||||
.plugin-url {
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
padding: 16rpx 24rpx;
|
||||
border-radius: 12rpx;
|
||||
background-color: #F1F5F9;
|
||||
color: #666;
|
||||
font-size: 24rpx;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.plugin-btns {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.plugin-copyright {
|
||||
font-size: 20rpx;
|
||||
color: #999;
|
||||
transform: scale(0.9) translateY(20px);
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,252 @@
|
||||
<template>
|
||||
<view class="vote-card" @click="$emit('on-click',vote)">
|
||||
<view class="vote-card-head flex">
|
||||
<view class="left flex flex-center w-full">
|
||||
<view class="flex-shrink">
|
||||
<tm-tags color="light-blue" :shadow="0" rounded size="s" model="fill">{{ vote.spec._uh_type}}</tm-tags>
|
||||
</view>
|
||||
<view class="title text-overflow">
|
||||
{{ vote.spec.title }}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="vote-card-body w-full">
|
||||
<view v-if="vote.spec.remark" class="remark text-overflow-2 text-size-s">
|
||||
{{vote.spec.remark}}
|
||||
</view>
|
||||
</view>
|
||||
<view class="vote-card-foot flex flex-between">
|
||||
<view class="left flex">
|
||||
<tm-tags :color="vote.spec._uh_state.color" size="s" rounded :shadow="0"
|
||||
model="text">{{vote.spec._uh_state.state}}</tm-tags>
|
||||
|
||||
<tm-tags v-if="vote.spec.isVoted" color="blue" rounded size="s" model="text">已投票</tm-tags>
|
||||
|
||||
<tm-tags v-if="vote.spec.timeLimit==='permanent'" color="grey-darken-2" rounded size="s"
|
||||
model="text">结束时间:永久有效 </tm-tags>
|
||||
<tm-tags v-else color="grey-darken-2" rounded size="s" model="text">
|
||||
<template
|
||||
v-if="vote.spec._uh_state.state=='未开始'">开始时间:{{ {d: vote.spec.startDate, f: 'yyyy-MM-dd HH:mm'} | formatTime }}
|
||||
</template>
|
||||
<template v-else>结束时间:{{ {d: vote.spec.endDate, f: 'yyyy-MM-dd HH:mm'} | formatTime }}
|
||||
</template>
|
||||
</tm-tags>
|
||||
</view>
|
||||
|
||||
<view v-if="false" class="right flex flex-end">
|
||||
<tm-tags v-if="false" color="grey-darken-2" rounded size="s" model="text">{{ vote.stats.voteCount }}
|
||||
人已参与</tm-tags>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import tmGroupradio from '@/tm-vuetify/components/tm-groupradio/tm-groupradio.vue';
|
||||
import tmRadio from '@/tm-vuetify/components/tm-radio/tm-radio.vue';
|
||||
import tmGroupcheckbox from '@/tm-vuetify/components/tm-groupcheckbox/tm-groupcheckbox.vue';
|
||||
import tmCheckbox from '@/tm-vuetify/components/tm-checkbox/tm-checkbox.vue';
|
||||
import tmButton from '@/tm-vuetify/components/tm-button/tm-button.vue';
|
||||
import tmTags from '@/tm-vuetify/components/tm-tags/tm-tags.vue';
|
||||
|
||||
export default {
|
||||
name: "VoteCard",
|
||||
options: {
|
||||
virtualHost: true,
|
||||
styleIsolation: 'shared'
|
||||
},
|
||||
components: {
|
||||
tmGroupradio,
|
||||
tmRadio,
|
||||
tmGroupcheckbox,
|
||||
tmCheckbox,
|
||||
tmButton,
|
||||
tmTags
|
||||
},
|
||||
props: {
|
||||
vote: {
|
||||
type: Object,
|
||||
default: () => ({})
|
||||
},
|
||||
index: {
|
||||
type: Number,
|
||||
default: 0
|
||||
},
|
||||
showOptions: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.w-full {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.wp-50 {
|
||||
width: 50%;
|
||||
}
|
||||
|
||||
.vote-card {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
box-sizing: border-box;
|
||||
margin: 0 24rpx;
|
||||
padding: 24rpx;
|
||||
border-radius: 12rpx;
|
||||
background-color: #ffff;
|
||||
box-shadow: 0rpx 2rpx 12rpx rgba(0, 0, 0, 0.035);
|
||||
overflow: hidden;
|
||||
margin-bottom: 24rpx;
|
||||
// border: 1px solid #eee;
|
||||
}
|
||||
|
||||
.vote-card-head {
|
||||
margin-bottom: 12rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
|
||||
.left {
|
||||
.title {
|
||||
font-size: 28rpx;
|
||||
font-weight: bold;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.vote-card-body {
|
||||
|
||||
.remark {
|
||||
box-sizing: border-box;
|
||||
padding-top: 0;
|
||||
color: rgba(0, 0, 0, 0.75);
|
||||
margin-bottom: 12rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.vote-card-foot {
|
||||
box-sizing: border-box;
|
||||
padding-top: 6px;
|
||||
margin-top: 6px;
|
||||
border-top: 2rpx solid #F7F7F7;
|
||||
|
||||
.left {}
|
||||
}
|
||||
|
||||
|
||||
.single {
|
||||
::v-deep {
|
||||
.tm-groupradio {
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 12rpx 0;
|
||||
}
|
||||
|
||||
.tm-checkbox {
|
||||
box-sizing: border-box;
|
||||
display: block;
|
||||
padding: 0 12rpx;
|
||||
width: 50%;
|
||||
}
|
||||
|
||||
.tm-button-label {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.multiple {
|
||||
::v-deep {
|
||||
.tm-groupcheckbox {
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 12rpx 0;
|
||||
}
|
||||
|
||||
.tm-checkbox {
|
||||
box-sizing: border-box;
|
||||
display: block;
|
||||
padding: 0 12rpx;
|
||||
width: 50%;
|
||||
}
|
||||
|
||||
.tm-button-label {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.pk {
|
||||
box-sizing: border-box;
|
||||
width: 100%;
|
||||
padding: 0 12rpx;
|
||||
|
||||
::v-deep {
|
||||
.tm-groupradio {
|
||||
display: flex;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.tm-checkbox {
|
||||
flex-grow: 1;
|
||||
min-width: 30% !important;
|
||||
max-width: 70% !important;
|
||||
}
|
||||
|
||||
.radio-item {
|
||||
position: relative;
|
||||
|
||||
.selected {
|
||||
z-index: 10;
|
||||
}
|
||||
}
|
||||
|
||||
.radio-left {}
|
||||
|
||||
.radio-right {}
|
||||
|
||||
.option-item {
|
||||
width: 100%;
|
||||
padding: 12rpx 24rpx;
|
||||
border-radius: 12rpx;
|
||||
}
|
||||
|
||||
.option-item-left {
|
||||
background: linear-gradient(90deg, #3B82F6, #60A5FA);
|
||||
color: white;
|
||||
clip-path: polygon(0 0, calc(100% - 40rpx) 0, 100% 100%, 0 100%);
|
||||
}
|
||||
|
||||
.option-item-right {
|
||||
background: linear-gradient(90deg, #F87171, #EF4444);
|
||||
color: white;
|
||||
clip-path: polygon(0 0, 100% 0, 100% 100%, 40rpx 100%);
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.option-foot {
|
||||
width: 100%;
|
||||
margin-top: 6rpx;
|
||||
font-size: 24rpx;
|
||||
color: #666;
|
||||
|
||||
.left {
|
||||
box-sizing: border-box;
|
||||
padding-right: 24rpx;
|
||||
}
|
||||
|
||||
.right {
|
||||
box-sizing: border-box;
|
||||
padding-left: 24rpx;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
+28
-13
@@ -112,7 +112,7 @@
|
||||
}
|
||||
},
|
||||
"uniStatistics" : {
|
||||
"enable" : true
|
||||
"enable" : false
|
||||
}
|
||||
},
|
||||
/* 快应用特有相关 */
|
||||
@@ -126,29 +126,29 @@
|
||||
},
|
||||
"usingComponents" : true,
|
||||
"uniStatistics" : {
|
||||
"enable" : true
|
||||
"enable" : false
|
||||
}
|
||||
},
|
||||
"mp-alipay" : {
|
||||
"usingComponents" : true,
|
||||
"uniStatistics" : {
|
||||
"enable" : true
|
||||
"enable" : false
|
||||
}
|
||||
},
|
||||
"mp-baidu" : {
|
||||
"usingComponents" : true,
|
||||
"uniStatistics" : {
|
||||
"enable" : true
|
||||
"enable" : false
|
||||
}
|
||||
},
|
||||
"mp-toutiao" : {
|
||||
"usingComponents" : true,
|
||||
"uniStatistics" : {
|
||||
"enable" : true
|
||||
"enable" : false
|
||||
}
|
||||
},
|
||||
"uniStatistics" : {
|
||||
"enable" : true,
|
||||
"enable" : false,
|
||||
"version" : "2"
|
||||
},
|
||||
"vueVersion" : "2",
|
||||
@@ -174,7 +174,7 @@
|
||||
}
|
||||
},
|
||||
"uniStatistics" : {
|
||||
"enable" : true
|
||||
"enable" : false
|
||||
},
|
||||
"router" : {
|
||||
"base" : "/uni-halo/",
|
||||
@@ -190,32 +190,47 @@
|
||||
"es6" : true
|
||||
},
|
||||
"uniStatistics" : {
|
||||
"enable" : true
|
||||
"enable" : false
|
||||
}
|
||||
},
|
||||
"mp-jd" : {
|
||||
"uniStatistics" : {
|
||||
"enable" : true
|
||||
"enable" : false
|
||||
}
|
||||
},
|
||||
"mp-kuaishou" : {
|
||||
"uniStatistics" : {
|
||||
"enable" : true
|
||||
"enable" : false
|
||||
}
|
||||
},
|
||||
"mp-lark" : {
|
||||
"uniStatistics" : {
|
||||
"enable" : true
|
||||
"enable" : false
|
||||
}
|
||||
},
|
||||
"quickapp-webview-huawei" : {
|
||||
"uniStatistics" : {
|
||||
"enable" : true
|
||||
"enable" : false
|
||||
}
|
||||
},
|
||||
"quickapp-webview-union" : {
|
||||
"uniStatistics" : {
|
||||
"enable" : true
|
||||
"enable" : false
|
||||
}
|
||||
},
|
||||
"app-harmony" : {
|
||||
"uniStatistics" : {
|
||||
"enable" : false
|
||||
}
|
||||
},
|
||||
"mp-harmony" : {
|
||||
"uniStatistics" : {
|
||||
"enable" : false
|
||||
}
|
||||
},
|
||||
"mp-xhs" : {
|
||||
"uniStatistics" : {
|
||||
"enable" : false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+40
-1
@@ -266,7 +266,46 @@
|
||||
"navigationBarTitleText": "友链提交",
|
||||
"enablePullDownRefresh": false
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "moment-detail/moment-detail",
|
||||
"style": {
|
||||
"navigationBarTitleText": "瞬间详情",
|
||||
"enablePullDownRefresh": true,
|
||||
"app-plus": {
|
||||
"pullToRefresh": {
|
||||
"color": "#03a9f4",
|
||||
"style": "circle"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "votes/votes",
|
||||
"style": {
|
||||
"navigationBarTitleText": "投票列表",
|
||||
"enablePullDownRefresh": true,
|
||||
"app-plus": {
|
||||
"pullToRefresh": {
|
||||
"color": "#03a9f4",
|
||||
"style": "circle"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "vote-detail/vote-detail",
|
||||
"style": {
|
||||
"navigationBarTitleText": "投票详情",
|
||||
"enablePullDownRefresh": true,
|
||||
"app-plus": {
|
||||
"pullToRefresh": {
|
||||
"color": "#03a9f4",
|
||||
"style": "circle"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
|
||||
+126
-83
@@ -1,93 +1,136 @@
|
||||
<template>
|
||||
<view class="app-page"></view>
|
||||
<view class="app-page flex flex-center">
|
||||
<PluginUnavailable v-if="!uniHaloPluginAvailable" :pluginId="uniHaloPluginId"
|
||||
:error-text="uniHaloPluginAvailableError" :use-border="false" :use-decoration="false" />
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
const homePagePath = '/pages/tabbar/home/home'
|
||||
const startPagePath = '/pagesA/start/start'
|
||||
const articleDetailPath = '/pagesA/article-detail/article-detail';
|
||||
export default {
|
||||
computed: {
|
||||
configs() {
|
||||
return this.$tm.vx.getters().getConfigs;
|
||||
}
|
||||
},
|
||||
onLoad: function (options) {
|
||||
uni.$tm.vx.actions('config/fetchConfigs').then(async (res) => {
|
||||
if (options.scene) {
|
||||
if ('' !== options.scene) {
|
||||
const postId = await this.getPostIdByQRCode(options.scene);
|
||||
if (postId) {
|
||||
uni.redirectTo({
|
||||
url: articleDetailPath + `?name=${postId}`,
|
||||
animationType: 'slide-in-right'
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
import pluginAvailableMixin from "@/common/mixins/pluginAvailable.js"
|
||||
import PluginUnavailable from '@/components/plugin-unavailable/plugin-unavailable.vue'
|
||||
|
||||
// #ifdef MP-WEIXIN
|
||||
// uni.$tm.vx.commit('setWxShare', res.shareConfig);
|
||||
// #endif
|
||||
const homePagePath = '/pages/tabbar/home/home'
|
||||
const startPagePath = '/pagesA/start/start'
|
||||
const articleDetailPath = '/pagesA/article-detail/article-detail';
|
||||
|
||||
// 获取mockjson
|
||||
if (res.auditConfig.auditModeEnabled) {
|
||||
if (res.auditConfig.auditModeData.jsonUrl) {
|
||||
await uni.$tm.vx.actions('config/fetchMockJson')
|
||||
} else {
|
||||
const mockJson = uni.$utils.checkJsonAndParse(res.auditConfig.auditModeData.jsonData)
|
||||
if (mockJson.ok) {
|
||||
uni.$tm.vx.commit('config/setMockJson', mockJson.jsonData)
|
||||
}
|
||||
}
|
||||
}
|
||||
const _DEV_ = false
|
||||
const _DEV_TO_TYPE_ = "page"
|
||||
const _DEV_TO_PATH_ = "/pagesA/article-detail/article-detail?name=077efb85-3544-4307-b24c-537a9e53f116"
|
||||
|
||||
// 进入检查
|
||||
this.fnCheckShowStarted();
|
||||
}).catch((err) => {
|
||||
uni.switchTab({
|
||||
url: homePagePath
|
||||
});
|
||||
})
|
||||
},
|
||||
methods: {
|
||||
fnCheckShowStarted() {
|
||||
if (!this.configs.appConfig.startConfig.enabled) {
|
||||
uni.switchTab({
|
||||
url: homePagePath
|
||||
});
|
||||
return;
|
||||
}
|
||||
export default {
|
||||
mixins: [pluginAvailableMixin],
|
||||
components: {
|
||||
PluginUnavailable
|
||||
},
|
||||
computed: {
|
||||
configs() {
|
||||
return this.$tm.vx.getters().getConfigs;
|
||||
}
|
||||
},
|
||||
async onLoad(options) {
|
||||
// 检查插件
|
||||
this.setPluginId(this.NeedPluginIds.PluginUniHalo)
|
||||
this.setPluginError("阿偶,检测到当前插件没有安装或者启用,无法启动 uni-halo 哦,请联系管理员")
|
||||
if (!await this.checkPluginAvailable()) return
|
||||
|
||||
// 是否每次都显示启动页
|
||||
if (this.configs.appConfig.startConfig.alwaysShow) {
|
||||
uni.removeStorageSync('APP_HAS_STARTED')
|
||||
uni.redirectTo({
|
||||
url: startPagePath
|
||||
});
|
||||
return;
|
||||
}
|
||||
// 获取配置
|
||||
uni.$tm.vx.actions('config/fetchConfigs').then(async (res) => {
|
||||
if (options.scene) {
|
||||
if ('' !== options.scene) {
|
||||
const postId = await this.getPostIdByQRCode(options.scene);
|
||||
if (postId) {
|
||||
uni.redirectTo({
|
||||
url: articleDetailPath + `?name=${postId}`,
|
||||
animationType: 'slide-in-right'
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 只显示一次启动页
|
||||
if (uni.getStorageSync('APP_HAS_STARTED')) {
|
||||
uni.switchTab({
|
||||
url: homePagePath
|
||||
});
|
||||
} else {
|
||||
uni.redirectTo({
|
||||
url: startPagePath
|
||||
});
|
||||
}
|
||||
},
|
||||
async getPostIdByQRCode(key) {
|
||||
const response = await this.$httpApi.v2.getQRCodeInfo(key);
|
||||
if (response) {
|
||||
if (response && response.postId) {
|
||||
return response.postId;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
};
|
||||
// #ifdef MP-WEIXIN
|
||||
// uni.$tm.vx.commit('setWxShare', res.shareConfig);
|
||||
// #endif
|
||||
|
||||
// 获取mockjson
|
||||
if (res.auditConfig.auditModeEnabled) {
|
||||
if (res.auditConfig.auditModeData.jsonUrl) {
|
||||
await uni.$tm.vx.actions('config/fetchMockJson')
|
||||
} else {
|
||||
const mockJson = uni.$utils.checkJsonAndParse(res.auditConfig.auditModeData
|
||||
.jsonData)
|
||||
if (mockJson.ok) {
|
||||
uni.$tm.vx.commit('config/setMockJson', mockJson.jsonData)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 进入检查
|
||||
this.fnCheckShowStarted();
|
||||
}).catch((err) => {
|
||||
uni.switchTab({
|
||||
url: homePagePath
|
||||
});
|
||||
})
|
||||
},
|
||||
methods: {
|
||||
fnCheckShowStarted() {
|
||||
// 本地开发,快速跳转页面,发布请设置 _DEV_ = false
|
||||
if (_DEV_ && _DEV_TO_PATH_) {
|
||||
if (_DEV_TO_TYPE_ == 'tabbar') {
|
||||
uni.switchTab({
|
||||
url: _DEV_TO_PATH_
|
||||
});
|
||||
} else if (_DEV_TO_TYPE_ == 'page') {
|
||||
uni.navigateTo({
|
||||
url: _DEV_TO_PATH_
|
||||
});
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
if (!this.configs.appConfig.startConfig.enabled) {
|
||||
uni.switchTab({
|
||||
url: homePagePath
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
// 是否每次都显示启动页
|
||||
if (this.configs.appConfig.startConfig.alwaysShow) {
|
||||
uni.removeStorageSync('APP_HAS_STARTED')
|
||||
uni.redirectTo({
|
||||
url: startPagePath
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
// 只显示一次启动页
|
||||
if (uni.getStorageSync('APP_HAS_STARTED')) {
|
||||
uni.switchTab({
|
||||
url: homePagePath
|
||||
});
|
||||
} else {
|
||||
uni.redirectTo({
|
||||
url: startPagePath
|
||||
});
|
||||
}
|
||||
},
|
||||
async getPostIdByQRCode(key) {
|
||||
const response = await this.$httpApi.v2.getQRCodeInfo(key);
|
||||
if (response) {
|
||||
if (response && response.postId) {
|
||||
return response.postId;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.app-page {
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
}
|
||||
</style>
|
||||
+567
-550
File diff suppressed because it is too large
Load Diff
+376
-282
@@ -1,299 +1,393 @@
|
||||
<template>
|
||||
<view class="app-page">
|
||||
<!-- 顶部切换 -->
|
||||
<view class="e-fixed" v-if="category.list.length > 0">
|
||||
<tm-tabs color="light-blue" :shadow="0" v-model="category.activeIndex" range-key="displayName" :list="category.list"
|
||||
align="left" @change="fnOnCategoryChange"></tm-tabs>
|
||||
</view>
|
||||
<!-- 占位区域 -->
|
||||
<view v-if="category.list.length > 0" style="width: 100vw;height: 90rpx;"></view>
|
||||
<!-- 加载区域 -->
|
||||
<view v-if="loading !== 'success'" class="loading-wrap">
|
||||
<tm-skeleton model="card"></tm-skeleton>
|
||||
<tm-skeleton model="card"></tm-skeleton>
|
||||
<tm-skeleton model="card"></tm-skeleton>
|
||||
<tm-skeleton model="card"></tm-skeleton>
|
||||
</view>
|
||||
<!-- 内容区域 -->
|
||||
<view class="content" v-else>
|
||||
<view v-if="dataList.length === 0" class="content-empty">
|
||||
<!-- 空布局 -->
|
||||
<tm-empty icon="icon-shiliangzhinengduixiang-" label="博主还没有分享图片~"></tm-empty>
|
||||
</view>
|
||||
<block v-else>
|
||||
<block v-if="galleryConfig.useWaterfall">
|
||||
<!--瀑布流-->
|
||||
<tm-flowLayout-custom ref="wafll" style="width: 100%;" @click="fnOnFlowClick"></tm-flowLayout-custom>
|
||||
</block>
|
||||
<!-- 列表 -->
|
||||
<block v-else>
|
||||
<tm-translate v-for="(item, index) in dataList" :key="index"
|
||||
style="box-sizing: border-box;padding: 6rpx;width: 50%;height: 250rpx;"
|
||||
animation-name="fadeUp" :wait="calcAniWait(index)">
|
||||
<view style="border-radius: 12rpx;overflow: hidden;width: 100%;height: 250rpx;">
|
||||
<image style="width: 100%;height: 100%;" mode="aspectFill" :src="item.spec.url"
|
||||
@click="fnPreview(item)"/>
|
||||
</view>
|
||||
</tm-translate>
|
||||
</block>
|
||||
<view class="app-page" :class="[uniHaloPluginPageClass]">
|
||||
<PluginUnavailable v-if="!uniHaloPluginAvailable" :pluginId="uniHaloPluginId"
|
||||
:error-text="uniHaloPluginAvailableError" />
|
||||
<template v-else>
|
||||
<!-- 顶部切换 -->
|
||||
<view class="e-fixed" v-if="category.list.length > 0">
|
||||
<tm-tabs color="light-blue" :shadow="0" v-model="category.activeIndex" range-key="displayName"
|
||||
:list="category.list" align="left" @change="fnOnCategoryChange($event, false)"></tm-tabs>
|
||||
</view>
|
||||
<!-- 占位区域 -->
|
||||
<view v-if="category.list.length > 0" style="width: 100vw;height: 90rpx;"></view>
|
||||
<!-- 加载区域 -->
|
||||
<view v-if="loading == 'loading'" class="loading-wrap">
|
||||
<tm-skeleton model="card"></tm-skeleton>
|
||||
<tm-skeleton model="card"></tm-skeleton>
|
||||
<tm-skeleton model="card"></tm-skeleton>
|
||||
<tm-skeleton model="card"></tm-skeleton>
|
||||
</view>
|
||||
<view v-else-if="loading == 'error'" class="flex flex-col flex-center" style="width:100%;height:60vh;">
|
||||
<tm-empty icon="icon-wind-cry" label="阿偶,似乎获取数据失败了~">
|
||||
<tm-button theme="light-blue" size="m" :shadow="0" @click="fnGetData(true)">刷新试试</tm-button>
|
||||
</tm-empty>
|
||||
</view>
|
||||
<!-- 内容区域 -->
|
||||
<view v-else class="content">
|
||||
<k-touch-listen class="touch-listen-content" @touchLeft="touchLeft" @touchRight="touchRight">
|
||||
<view v-if="dataList.length === 0" class="content-empty">
|
||||
<!-- 空布局 -->
|
||||
<tm-empty icon="icon-shiliangzhinengduixiang-" label="博主还没有分享图片~"></tm-empty>
|
||||
</view>
|
||||
<block v-else>
|
||||
<block v-if="galleryConfig.useWaterfall">
|
||||
<!--瀑布流-->
|
||||
<tm-flowLayout-custom ref="wafll" style="width: 100%;"
|
||||
@click="fnOnFlowClick"></tm-flowLayout-custom>
|
||||
</block>
|
||||
<!-- 列表 -->
|
||||
<block v-else>
|
||||
<tm-translate v-for="(item, index) in dataList" :key="index"
|
||||
style="box-sizing: border-box;padding: 6rpx;width: 50%;height: 250rpx;"
|
||||
animation-name="fadeUp" :wait="calcAniWait(index)">
|
||||
<view style="border-radius: 12rpx;overflow: hidden;width: 100%;height: 250rpx;">
|
||||
<image style="width: 100%;height: 100%;" mode="aspectFill" :src="item.spec.url"
|
||||
@click="fnPreview(item)" />
|
||||
</view>
|
||||
</tm-translate>
|
||||
</block>
|
||||
|
||||
<tm-flotbutton @click="fnToTopPage" color="light-blue" size="m" icon="icon-angle-up"></tm-flotbutton>
|
||||
<view class="load-text">{{ loadMoreText }}</view>
|
||||
</block>
|
||||
<view class="load-text">{{ loadMoreText }}</view>
|
||||
</block>
|
||||
</k-touch-listen>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
</view>
|
||||
<view v-if="!calcAuditModeEnabled" class="flot-buttons">
|
||||
<tm-button v-if="loading == 'error'" @click="fnGetCategory" size="m" :fab="true" theme="light-blue"
|
||||
icon="icon-sync-alt"></tm-button>
|
||||
<tm-button @click="fnToTopPage" size="m" :fab="true" theme="light-blue"
|
||||
icon="icon-angle-up"></tm-button>
|
||||
</view>
|
||||
</template>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import tmSkeleton from '@/tm-vuetify/components/tm-skeleton/tm-skeleton.vue';
|
||||
import tmTranslate from '@/tm-vuetify/components/tm-translate/tm-translate.vue';
|
||||
import tmFlotbutton from '@/tm-vuetify/components/tm-flotbutton/tm-flotbutton.vue';
|
||||
import tmTags from '@/tm-vuetify/components/tm-tags/tm-tags.vue';
|
||||
import tmEmpty from '@/tm-vuetify/components/tm-empty/tm-empty.vue';
|
||||
import tmIcons from '@/tm-vuetify/components/tm-icons/tm-icons.vue';
|
||||
import tmImages from '@/tm-vuetify/components/tm-images/tm-images.vue';
|
||||
import tmFlowLayoutCustom from '@/tm-vuetify/components/tm-flowLayout-custom/tm-flowLayout-custom.vue';
|
||||
import tmTabs from '@/tm-vuetify/components/tm-tabs/tm-tabs.vue';
|
||||
import tmSkeleton from '@/tm-vuetify/components/tm-skeleton/tm-skeleton.vue';
|
||||
import tmTranslate from '@/tm-vuetify/components/tm-translate/tm-translate.vue';
|
||||
import tmFlotbutton from '@/tm-vuetify/components/tm-flotbutton/tm-flotbutton.vue';
|
||||
import tmTags from '@/tm-vuetify/components/tm-tags/tm-tags.vue';
|
||||
import tmEmpty from '@/tm-vuetify/components/tm-empty/tm-empty.vue';
|
||||
import tmIcons from '@/tm-vuetify/components/tm-icons/tm-icons.vue';
|
||||
import tmImages from '@/tm-vuetify/components/tm-images/tm-images.vue';
|
||||
import tmFlowLayoutCustom from '@/tm-vuetify/components/tm-flowLayout-custom/tm-flowLayout-custom.vue';
|
||||
import tmTabs from '@/tm-vuetify/components/tm-tabs/tm-tabs.vue';
|
||||
import tmButton from '@/tm-vuetify/components/tm-button/tm-button.vue';
|
||||
|
||||
export default {
|
||||
options: {
|
||||
multipleSlots: true
|
||||
},
|
||||
components: {
|
||||
tmSkeleton,
|
||||
tmTranslate,
|
||||
tmFlotbutton,
|
||||
tmTags,
|
||||
tmEmpty,
|
||||
tmIcons,
|
||||
tmImages,
|
||||
tmFlowLayoutCustom,
|
||||
tmTabs
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
isBlackTheme: false,
|
||||
loading: 'loading',
|
||||
category: {
|
||||
activeIndex: 0,
|
||||
activeValue: '',
|
||||
list: []
|
||||
},
|
||||
queryParams: {
|
||||
size: 10,
|
||||
page: 1,
|
||||
group: ""
|
||||
},
|
||||
isLoadMore: false,
|
||||
loadMoreText: '',
|
||||
hasNext: false,
|
||||
dataList: []
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
galleryConfig() {
|
||||
return this.$tm.vx.getters().getConfigs.pageConfig.galleryConfig;
|
||||
},
|
||||
haloConfigs() {
|
||||
return this.$tm.vx.getters().getConfigs;
|
||||
},
|
||||
mockJson() {
|
||||
return this.$tm.vx.getters().getMockJson;
|
||||
},
|
||||
calcAuditModeEnabled(){
|
||||
return this.haloConfigs.auditConfig.auditModeEnabled
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
galleryConfig: {
|
||||
handler(newValue, oldValue) {
|
||||
if (!newValue) return;
|
||||
this.fnSetPageTitle(newValue.pageTitle);
|
||||
this.fnGetCategory();
|
||||
},
|
||||
deep: true,
|
||||
immediate: true
|
||||
}
|
||||
},
|
||||
onPullDownRefresh() {
|
||||
this.dataList = []
|
||||
this.isLoadMore = false;
|
||||
this.queryParams.page = 1;
|
||||
this.fnGetData(true);
|
||||
},
|
||||
onReachBottom(e) {
|
||||
if (this.calcAuditModeEnabled) {
|
||||
uni.showToast({
|
||||
icon: 'none',
|
||||
title: '没有更多数据了'
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (this.hasNext) {
|
||||
this.queryParams.page += 1;
|
||||
this.isLoadMore = true;
|
||||
this.fnGetData(false);
|
||||
} else {
|
||||
uni.showToast({
|
||||
icon: 'none',
|
||||
title: '没有更多数据了'
|
||||
});
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
fnOnCategoryChange(index) {
|
||||
this.fnResetSetAniWaitIndex();
|
||||
this.queryParams.group = this.category.list[index].name;
|
||||
this.queryParams.page = 1;
|
||||
this.fnToTopPage();
|
||||
this.dataList = [];
|
||||
this.fnGetData(true);
|
||||
},
|
||||
fnGetCategory() {
|
||||
if (this.calcAuditModeEnabled) {
|
||||
this.fnGetData(true);
|
||||
return
|
||||
}
|
||||
this.$httpApi.v2.getPhotoGroupList({
|
||||
page: 1,
|
||||
size: 0
|
||||
}).then(res => {
|
||||
this.category.list = res.items.map(item => {
|
||||
return {
|
||||
name: item.metadata.name,
|
||||
displayName: item.spec.displayName
|
||||
}
|
||||
});
|
||||
if (this.category.list.length !== 0) {
|
||||
this.queryParams.group = this.category.list[0].name;
|
||||
this.fnGetData(true);
|
||||
}
|
||||
});
|
||||
},
|
||||
fnGetData(isClearWaterfall = false) {
|
||||
if (this.calcAuditModeEnabled) {
|
||||
this.dataList = this.mockJson.gallery.list.map(item => {
|
||||
return {
|
||||
metadata: {
|
||||
name: Date.now() * Math.random(),
|
||||
},
|
||||
spec: {
|
||||
url: this.$utils.checkImageUrl(item)
|
||||
}
|
||||
}
|
||||
})
|
||||
import pluginAvailable from "@/common/mixins/pluginAvailable.js"
|
||||
import PluginUnavailable from '@/components/plugin-unavailable/plugin-unavailable.vue'
|
||||
export default {
|
||||
options: {
|
||||
multipleSlots: true
|
||||
},
|
||||
mixins: [pluginAvailable],
|
||||
components: {
|
||||
tmSkeleton,
|
||||
tmTranslate,
|
||||
tmFlotbutton,
|
||||
tmTags,
|
||||
tmEmpty,
|
||||
tmIcons,
|
||||
tmImages,
|
||||
tmFlowLayoutCustom,
|
||||
tmTabs,
|
||||
tmButton,
|
||||
PluginUnavailable
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
isBlackTheme: false,
|
||||
loading: 'loading',
|
||||
category: {
|
||||
activeIndex: 0,
|
||||
activeValue: '',
|
||||
list: []
|
||||
},
|
||||
queryParams: {
|
||||
size: 10,
|
||||
page: 1,
|
||||
group: ""
|
||||
},
|
||||
isLoadMore: false,
|
||||
loadMoreText: '',
|
||||
hasNext: false,
|
||||
dataList: [],
|
||||
lock: false
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
galleryConfig() {
|
||||
return this.$tm.vx.getters().getConfigs.pageConfig.galleryConfig;
|
||||
},
|
||||
haloConfigs() {
|
||||
return this.$tm.vx.getters().getConfigs;
|
||||
},
|
||||
mockJson() {
|
||||
return this.$tm.vx.getters().getMockJson;
|
||||
},
|
||||
calcAuditModeEnabled() {
|
||||
return this.haloConfigs.auditConfig.auditModeEnabled
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
galleryConfig: {
|
||||
async handler(newValue, oldValue) {
|
||||
if (!newValue) return;
|
||||
this.fnSetPageTitle(newValue.pageTitle);
|
||||
this.fnGetCategory();
|
||||
},
|
||||
deep: true,
|
||||
immediate: true
|
||||
}
|
||||
},
|
||||
async onLoad() {
|
||||
// 检查插件
|
||||
this.setPluginId(this.NeedPluginIds.PluginPhotos)
|
||||
this.setPluginError("阿偶,检测到当前插件没有安装或者启用,无法使用图库功能哦,请联系管理员")
|
||||
await this.checkPluginAvailable()
|
||||
},
|
||||
onPullDownRefresh() {
|
||||
if (!this.uniHaloPluginAvailable) {
|
||||
uni.hideLoading();
|
||||
uni.stopPullDownRefresh();
|
||||
return
|
||||
}
|
||||
this.dataList = []
|
||||
this.isLoadMore = false;
|
||||
this.queryParams.page = 1;
|
||||
this.fnGetData(true);
|
||||
},
|
||||
onReachBottom(e) {
|
||||
if (!this.uniHaloPluginAvailable) return;
|
||||
if (this.calcAuditModeEnabled) {
|
||||
uni.showToast({
|
||||
icon: 'none',
|
||||
title: '没有更多数据了'
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
this.loading = 'success';
|
||||
if (this.hasNext) {
|
||||
this.queryParams.page += 1;
|
||||
this.isLoadMore = true;
|
||||
this.fnGetData(false);
|
||||
} else {
|
||||
uni.showToast({
|
||||
icon: 'none',
|
||||
title: '没有更多数据了'
|
||||
});
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
fnGetDataByCategory(index) {
|
||||
this.fnResetSetAniWaitIndex();
|
||||
this.queryParams.group = this.category.list[index].name;
|
||||
this.queryParams.page = 1;
|
||||
this.fnToTopPage();
|
||||
this.dataList = [];
|
||||
this.fnGetData(true);
|
||||
},
|
||||
fnOnCategoryChange(index) {
|
||||
if (this.lock) {
|
||||
// uni.showToast({
|
||||
// title: "上一个请求进行中...",
|
||||
// icon: "none"
|
||||
// })
|
||||
return;
|
||||
}
|
||||
this.fnGetDataByCategory(index)
|
||||
},
|
||||
fnGetCategory() {
|
||||
if (this.calcAuditModeEnabled) {
|
||||
this.fnGetData(true);
|
||||
return
|
||||
}
|
||||
this.$httpApi.v2.getPhotoGroupList({
|
||||
page: 1,
|
||||
size: 0
|
||||
}).then(res => {
|
||||
this.category.list = res.items.map(item => {
|
||||
return {
|
||||
name: item.metadata.name,
|
||||
displayName: item.spec.displayName,
|
||||
priority: item.spec.priority
|
||||
}
|
||||
}).sort((a, b) => a.priority - b.priority);
|
||||
|
||||
if (this.galleryConfig.useWaterfall) {
|
||||
this.$nextTick(() => {
|
||||
if (isClearWaterfall) {
|
||||
this.$refs.wafll.clear()
|
||||
}
|
||||
setTimeout(() => {
|
||||
this.$refs.wafll.pushData(this.dataList)
|
||||
}, 50)
|
||||
})
|
||||
}
|
||||
this.loadMoreText = '呜呜,没有更多数据啦~';
|
||||
uni.hideLoading();
|
||||
uni.stopPullDownRefresh();
|
||||
return;
|
||||
}
|
||||
if (this.category.list.length !== 0) {
|
||||
this.queryParams.group = this.category.list[0].name;
|
||||
this.fnGetData(true);
|
||||
}
|
||||
}).catch(e => {
|
||||
this.loading = 'error'
|
||||
this.category.list = []
|
||||
this.category.activeIndex = 0
|
||||
this.category.activeValue = ""
|
||||
});
|
||||
},
|
||||
fnGetData(isClearWaterfall = false) {
|
||||
if (this.calcAuditModeEnabled) {
|
||||
this.dataList = this.mockJson.gallery.list.map(item => {
|
||||
return {
|
||||
metadata: {
|
||||
name: Date.now() * Math.random(),
|
||||
},
|
||||
spec: {
|
||||
url: this.$utils.checkImageUrl(item)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
// 设置状态为加载中
|
||||
if (!this.isLoadMore) {
|
||||
this.loading = 'loading';
|
||||
}
|
||||
this.loadMoreText = '';
|
||||
this.$httpApi.v2
|
||||
.getPhotoListByGroupName(this.queryParams)
|
||||
.then(res => {
|
||||
this.hasNext = res.hasNext;
|
||||
this.loading = 'success';
|
||||
if (res.items.length !== 0) {
|
||||
const _list = res.items.map((item, index) => {
|
||||
item.spec.url = this.$utils.checkImageUrl(item.spec.url || item.spec.cover);
|
||||
return item;
|
||||
});
|
||||
if (this.isLoadMore) {
|
||||
this.dataList = this.dataList.concat(_list);
|
||||
} else {
|
||||
this.dataList = _list;
|
||||
}
|
||||
if (this.galleryConfig.useWaterfall) {
|
||||
this.$nextTick(() => {
|
||||
if (isClearWaterfall) {
|
||||
this.$refs.wafll.clear()
|
||||
}
|
||||
this.$refs.wafll.pushData(_list)
|
||||
})
|
||||
}
|
||||
}
|
||||
this.loadMoreText = res.hasNext ? '上拉加载更多' : '呜呜,没有更多数据啦~';
|
||||
})
|
||||
.catch(err => {
|
||||
console.error(err);
|
||||
this.loading = 'error';
|
||||
this.loadMoreText = '加载失败,请下拉刷新!';
|
||||
})
|
||||
.finally(() => {
|
||||
setTimeout(() => {
|
||||
uni.hideLoading();
|
||||
uni.stopPullDownRefresh();
|
||||
}, 500);
|
||||
});
|
||||
},
|
||||
fnOnFlowClick({item}) {
|
||||
this.fnPreview(item)
|
||||
},
|
||||
// 预览
|
||||
fnPreview(data) {
|
||||
uni.previewImage({
|
||||
current: this.dataList.findIndex(x => x.metadata.name === data.metadata.name),
|
||||
urls: this.dataList.map(x => x.spec.url),
|
||||
indicator: 'number',
|
||||
loop: true
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
this.loading = 'success';
|
||||
|
||||
if (this.galleryConfig.useWaterfall) {
|
||||
this.$nextTick(() => {
|
||||
if (isClearWaterfall) {
|
||||
this.$refs.wafll.clear()
|
||||
}
|
||||
setTimeout(() => {
|
||||
this.$refs.wafll.pushData(this.dataList)
|
||||
}, 50)
|
||||
})
|
||||
}
|
||||
this.loadMoreText = '呜呜,没有更多数据啦~';
|
||||
uni.hideLoading();
|
||||
uni.stopPullDownRefresh();
|
||||
this.lock = false;
|
||||
return;
|
||||
}
|
||||
|
||||
// 设置状态为加载中
|
||||
if (!this.isLoadMore) {
|
||||
this.loading = 'loading';
|
||||
}
|
||||
this.loadMoreText = '';
|
||||
this.$httpApi.v2
|
||||
.getPhotoListByGroupName(this.queryParams)
|
||||
.then(res => {
|
||||
this.hasNext = res.hasNext;
|
||||
this.loading = 'success';
|
||||
if (res.items.length !== 0) {
|
||||
const _list = res.items.map((item, index) => {
|
||||
item.spec.url = this.$utils.checkImageUrl(item.spec.url || item.spec.cover);
|
||||
return item;
|
||||
});
|
||||
if (this.isLoadMore) {
|
||||
this.dataList = this.dataList.concat(_list);
|
||||
} else {
|
||||
this.dataList = _list;
|
||||
}
|
||||
if (this.galleryConfig.useWaterfall) {
|
||||
this.$nextTick(() => {
|
||||
if (isClearWaterfall) {
|
||||
this.$refs.wafll.clear()
|
||||
}
|
||||
this.$refs.wafll.pushData(_list)
|
||||
})
|
||||
}
|
||||
}
|
||||
this.loadMoreText = res.hasNext ? '上拉加载更多' : '呜呜,没有更多数据啦~';
|
||||
})
|
||||
.catch(err => {
|
||||
console.error(err);
|
||||
this.loading = 'error';
|
||||
this.loadMoreText = '加载失败,请下拉刷新!';
|
||||
})
|
||||
.finally(() => {
|
||||
setTimeout(() => {
|
||||
uni.hideLoading();
|
||||
uni.stopPullDownRefresh();
|
||||
this.lock = false;
|
||||
}, 500);
|
||||
});
|
||||
},
|
||||
fnOnFlowClick({
|
||||
item
|
||||
}) {
|
||||
this.fnPreview(item)
|
||||
},
|
||||
// 预览
|
||||
fnPreview(data) {
|
||||
uni.previewImage({
|
||||
current: this.dataList.findIndex(x => x.metadata.name === data.metadata.name),
|
||||
urls: this.dataList.map(x => x.spec.url),
|
||||
indicator: 'number',
|
||||
loop: true
|
||||
});
|
||||
},
|
||||
touchLeft() {
|
||||
if (this.loading != "success") return;
|
||||
this.category.activeIndex += 1
|
||||
if (this.category.activeIndex >= this.category.list.length) {
|
||||
this.category.activeIndex = 0
|
||||
}
|
||||
this.lock = true
|
||||
this.fnGetDataByCategory(this.category.activeIndex)
|
||||
},
|
||||
touchRight() {
|
||||
if (this.loading != "success") return;
|
||||
this.category.activeIndex -= 1
|
||||
if (this.category.activeIndex < 0) {
|
||||
this.category.activeIndex = 0
|
||||
}
|
||||
this.lock = true
|
||||
this.fnGetDataByCategory(this.category.activeIndex)
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.app-page {
|
||||
width: 100vw;
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding-bottom: 24rpx;
|
||||
background-color: #fafafa;
|
||||
}
|
||||
.app-page {
|
||||
width: 100vw;
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding-bottom: 24rpx;
|
||||
background-color: #fafafa;
|
||||
}
|
||||
|
||||
.content {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
box-sizing: border-box;
|
||||
padding: 24rpx 24rpx 0;
|
||||
gap: 12rpx 0;
|
||||
.content {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
box-sizing: border-box;
|
||||
|
||||
.content-empty {
|
||||
width: 100%;
|
||||
height: 70vh;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
}
|
||||
.content-empty {
|
||||
width: 100%;
|
||||
height: 70vh;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
}
|
||||
|
||||
.loading-wrap {
|
||||
box-sizing: border-box;
|
||||
padding: 24rpx;
|
||||
}
|
||||
.touch-listen-content {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
box-sizing: border-box;
|
||||
padding: 24rpx 24rpx 0;
|
||||
gap: 12rpx 0;
|
||||
}
|
||||
|
||||
.load-text {
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
.loading-wrap {
|
||||
box-sizing: border-box;
|
||||
padding: 24rpx;
|
||||
}
|
||||
|
||||
.load-text {
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.flot-buttons {
|
||||
position: fixed;
|
||||
bottom: 100rpx;
|
||||
right: 32rpx;
|
||||
flex-direction: column;
|
||||
display: flex;
|
||||
gap: 6rpx;
|
||||
z-index: 999;
|
||||
}
|
||||
</style>
|
||||
+697
-574
File diff suppressed because it is too large
Load Diff
+385
-324
@@ -1,349 +1,410 @@
|
||||
<template>
|
||||
<view class="app-page">
|
||||
<view v-if="loading !== 'success'" class="loading-wrap">
|
||||
<tm-skeleton model="listAvatr"></tm-skeleton>
|
||||
<tm-skeleton model="listAvatr"></tm-skeleton>
|
||||
<tm-skeleton model="listAvatr"></tm-skeleton>
|
||||
</view>
|
||||
<!-- 内容区域 -->
|
||||
<view v-else class="app-page-content">
|
||||
<view v-if="dataList.length === 0" class="content-empty flex flex-center" style="min-height: 70vh;">
|
||||
<!-- 空布局 -->
|
||||
<tm-empty icon="icon-shiliangzhinengduixiang-" label="暂无数据"></tm-empty>
|
||||
</view>
|
||||
<block v-else>
|
||||
<block v-for="(moment, index) in dataList" :key="index">
|
||||
<!-- 卡片 -->
|
||||
<tm-translate v-if="moment.spec.visible==='PUBLIC'" animation-name="fadeUp" :wait="calcAniWait()">
|
||||
<view class="moment-card">
|
||||
<view class="head" style="display: flex;align-items: center;">
|
||||
<view class="avatar" style="flex-shrink: 0;">
|
||||
<image style="width: 66rpx;height: 66rpx;border-radius: 50%;"
|
||||
:src="moment.spec.user.avatar"/>
|
||||
</view>
|
||||
<view class="nickname" style="margin-left: 12rpx;">
|
||||
<view style="font-size: 30rpx;font-weight: bold;color: #333333;">
|
||||
{{ moment.spec.user.displayName }}
|
||||
</view>
|
||||
<view style="margin-top: 6rpx;font-size: 24rpx;color: #666;">
|
||||
{{ {d: moment.spec.releaseTime, f: 'yyyy年MM月dd日 星期w'} | formatTime }}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="content">
|
||||
<mp-html class="evan-markdown" lazy-load :domain="markdownConfig.domain"
|
||||
:loading-img="markdownConfig.loadingGif" :scroll-table="true" :selectable="true"
|
||||
:tag-style="markdownConfig.tagStyle" :container-style="markdownConfig.containStyle"
|
||||
:content="moment.spec.newHtml" :markdown="true" :showLineNumber="true"
|
||||
:showLanguageName="true" :copyByLongPress="true"/>
|
||||
</view>
|
||||
<view v-if="moment.images.length!==0" class="images"
|
||||
:class="['images-'+moment.images.length]">
|
||||
<view class="image-item"
|
||||
v-for="(image,mediumIndex) in moment.images"
|
||||
:key="mediumIndex">
|
||||
<image mode="aspectFill" style="width: 100%;height: 100%;border-radius: 6rpx;"
|
||||
:src="image.url"
|
||||
@click="handlePreview(mediumIndex,moment.images)"/>
|
||||
</view>
|
||||
</view>
|
||||
<view v-if="moment.audios.length!==0" class="mb-12"
|
||||
style="display: flex; flex-direction: column; gap: 12rpx 0;padding: 0 24rpx;padding-right:28rpx;">
|
||||
<audio
|
||||
v-for="(audio,index) in moment.audios"
|
||||
:controls="true"
|
||||
:key="index"
|
||||
:id="audio.url"
|
||||
:poster="bloggerInfo.avatar"
|
||||
:name="'来自' + (startConfig.title||bloggerInfo.nickname) + '的声音'"
|
||||
:author="bloggerInfo.nickname"
|
||||
:src="audio.url"></audio>
|
||||
</view>
|
||||
<view v-if="moment.videos.length!==0" class="mb-12"
|
||||
style="display: flex; flex-direction: column; gap: 12rpx 0;padding: 0 24rpx; ">
|
||||
<video
|
||||
style="width:100%;height: 400rpx;border-radius: 12rpx;"
|
||||
v-for="(video,index) in moment.videos"
|
||||
:key="index" :src="video.url"></video>
|
||||
</view>
|
||||
<view v-if="moment.spec.tags && moment.spec.tags.length!==0" class="mt-12 px-16 pb-24 flex flex-wrap">
|
||||
<tm-tags
|
||||
v-for="(tag,tagIndex) in moment.spec.tags" :key="tagIndex"
|
||||
:color="randomTagColor()" size="m" model="text">
|
||||
{{ tag }}
|
||||
</tm-tags>
|
||||
</view>
|
||||
</view>
|
||||
</tm-translate>
|
||||
</block>
|
||||
<tm-flotbutton @click="fnToTopPage" size="m" color="light-blue" icon="icon-angle-up"></tm-flotbutton>
|
||||
<view class="load-text">{{ loadMoreText }}</view>
|
||||
</block>
|
||||
</view>
|
||||
</view>
|
||||
<view class="app-page" :class="[uniHaloPluginPageClass]">
|
||||
<PluginUnavailable v-if="!uniHaloPluginAvailable" :pluginId="uniHaloPluginId"
|
||||
:error-text="uniHaloPluginAvailableError" />
|
||||
<template v-else>
|
||||
<view v-if="loading !== 'success'" class="loading-wrap">
|
||||
<tm-skeleton model="listAvatr"></tm-skeleton>
|
||||
<tm-skeleton model="listAvatr"></tm-skeleton>
|
||||
<tm-skeleton model="listAvatr"></tm-skeleton>
|
||||
</view>
|
||||
<!-- 内容区域 -->
|
||||
<view v-else class="app-page-content">
|
||||
<view v-if="dataList.length === 0" class="content-empty flex flex-center" style="min-height: 70vh;">
|
||||
<!-- 空布局 -->
|
||||
<tm-empty icon="icon-shiliangzhinengduixiang-" label="暂无数据"></tm-empty>
|
||||
</view>
|
||||
<block v-else>
|
||||
<!-- 卡片 -->
|
||||
<tm-translate v-for="(moment, index) in dataList" :key="moment.metadata.name"
|
||||
animation-name="fadeUp" :wait="calcAniWait(index)">
|
||||
<view class="moment-card">
|
||||
<view class="head" style="display: flex;align-items: center;">
|
||||
<view class="avatar" style="flex-shrink: 0;">
|
||||
<image style="width: 66rpx;height: 66rpx;border-radius: 50%;"
|
||||
:src="moment.spec.user.avatar" />
|
||||
</view>
|
||||
<view class="nickname" style="margin-left: 12rpx;">
|
||||
<view style="font-size: 30rpx;font-weight: bold;color: #333333;">
|
||||
{{ moment.spec.user.displayName }}
|
||||
</view>
|
||||
<view style="margin-top: 6rpx;font-size: 24rpx;color: #666;">
|
||||
{{ {d: moment.spec.releaseTime, f: 'yyyy年MM月dd日 星期w'} | formatTime }}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="content" @click.stop="handleToMomentDetail(moment)">
|
||||
<mp-html class="evan-markdown" lazy-load :domain="markdownConfig.domain"
|
||||
:loading-img="markdownConfig.loadingGif" :scroll-table="true" :selectable="true"
|
||||
:tag-style="markdownConfig.tagStyle" :container-style="markdownConfig.containStyle"
|
||||
:content="moment.spec.newHtml" :markdown="true" :showLineNumber="true"
|
||||
:showLanguageName="true" :copyByLongPress="true" />
|
||||
</view>
|
||||
<view v-if="moment.images && moment.images.length!==0" class="images"
|
||||
:class="['images-'+moment.images.length]">
|
||||
<view class="image-item" v-for="(image,mediumIndex) in moment.images"
|
||||
:key="mediumIndex">
|
||||
<image mode="aspectFill" style="width: 100%;height: 100%;border-radius: 6rpx;"
|
||||
:src="image.url" @click="handlePreview(mediumIndex,moment.images)" />
|
||||
</view>
|
||||
</view>
|
||||
<view v-if="moment.audios && moment.audios.length!==0" class="mb-12"
|
||||
style="display: flex; flex-direction: column; gap: 12rpx 0;padding: 0 24rpx;padding-right:28rpx;">
|
||||
<audio v-for="(audio,index) in moment.audios" :controls="true" :key="index"
|
||||
:id="audio.url" :poster="bloggerInfo.avatar"
|
||||
:name="'来自' + (startConfig.title||bloggerInfo.nickname) + '的声音'"
|
||||
:author="bloggerInfo.nickname" :src="audio.url"></audio>
|
||||
</view>
|
||||
<view v-if="moment.videos && moment.videos.length!==0" class="mb-12"
|
||||
style="display: flex; flex-direction: column; gap: 12rpx 0;padding: 0 24rpx; ">
|
||||
<video style="width:100%;height: 400rpx;border-radius: 12rpx;"
|
||||
v-for="(video,index) in moment.videos" :key="index" :src="video.url"
|
||||
:id="'video_' + video.id" :show-mute-btn="true" :controls="true"
|
||||
:show-center-play-btn="true" :enable-progress-gesture="true"
|
||||
@play="onVideoPlay(video.id)" @pause="onVideoPause(video.id)"
|
||||
@ended="onVideoEnded(video.id)"></video>
|
||||
</view>
|
||||
<view v-if="moment.spec.tags && moment.spec.tags.length!==0"
|
||||
class="mt-12 px-16 pb-24 flex flex-wrap">
|
||||
<tm-tags v-for="(tag,tagIndex) in moment.spec.tags" :key="tagIndex"
|
||||
:color="randomTagColor()" size="m" model="text">
|
||||
{{ tag }}
|
||||
</tm-tags>
|
||||
</view>
|
||||
</view>
|
||||
</tm-translate>
|
||||
<tm-flotbutton @click="fnToTopPage" :width="90" size="xs" color="light-blue" :icon-size="24"
|
||||
icon="icon-angle-up"></tm-flotbutton>
|
||||
<view class="load-text">{{ loadMoreText }}</view>
|
||||
</block>
|
||||
</view>
|
||||
</template>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import tmSkeleton from '@/tm-vuetify/components/tm-skeleton/tm-skeleton.vue';
|
||||
import tmFlotbutton from '@/tm-vuetify/components/tm-flotbutton/tm-flotbutton.vue';
|
||||
import tmTranslate from '@/tm-vuetify/components/tm-translate/tm-translate.vue';
|
||||
import tmEmpty from '@/tm-vuetify/components/tm-empty/tm-empty.vue';
|
||||
import tmTags from '@/tm-vuetify/components/tm-tags/tm-tags.vue';
|
||||
import tmSkeleton from '@/tm-vuetify/components/tm-skeleton/tm-skeleton.vue';
|
||||
import tmFlotbutton from '@/tm-vuetify/components/tm-flotbutton/tm-flotbutton.vue';
|
||||
import tmTranslate from '@/tm-vuetify/components/tm-translate/tm-translate.vue';
|
||||
import tmEmpty from '@/tm-vuetify/components/tm-empty/tm-empty.vue';
|
||||
import tmTags from '@/tm-vuetify/components/tm-tags/tm-tags.vue';
|
||||
|
||||
import MarkdownConfig from '@/common/markdown/markdown.config.js';
|
||||
import mpHtml from '@/components/mp-html/components/mp-html/mp-html.vue';
|
||||
import {getRandomNumberByRange} from "@/utils/random.js"
|
||||
import MarkdownConfig from '@/common/markdown/markdown.config.js';
|
||||
import mpHtml from '@/components/mp-html/components/mp-html/mp-html.vue';
|
||||
import {
|
||||
getRandomNumberByRange
|
||||
} from "@/utils/random.js";
|
||||
import {
|
||||
generateUUID
|
||||
} from '@/utils/uuid.js';
|
||||
|
||||
export default {
|
||||
components: {
|
||||
tmSkeleton,
|
||||
tmFlotbutton,
|
||||
tmTranslate,
|
||||
tmEmpty,
|
||||
tmTags,
|
||||
mpHtml
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
markdownConfig: MarkdownConfig,
|
||||
loading: 'loading',
|
||||
queryParams: {
|
||||
size: 10,
|
||||
page: 1
|
||||
},
|
||||
hasNext: false,
|
||||
dataList: [],
|
||||
isLoadMore: false,
|
||||
loadMoreText: '加载中...',
|
||||
tagColors: ['orange', 'green', 'red', 'blue']
|
||||
};
|
||||
},
|
||||
import pluginAvailableMixin from "@/common/mixins/pluginAvailable.js"
|
||||
import PluginUnavailable from '@/components/plugin-unavailable/plugin-unavailable.vue'
|
||||
|
||||
export default {
|
||||
mixins: [pluginAvailableMixin],
|
||||
components: {
|
||||
tmSkeleton,
|
||||
tmFlotbutton,
|
||||
tmTranslate,
|
||||
tmEmpty,
|
||||
tmTags,
|
||||
mpHtml,
|
||||
PluginUnavailable
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
markdownConfig: MarkdownConfig,
|
||||
loading: 'loading',
|
||||
queryParams: {
|
||||
size: 10,
|
||||
page: 1
|
||||
},
|
||||
hasNext: false,
|
||||
dataList: [],
|
||||
isLoadMore: false,
|
||||
loadMoreText: '加载中...',
|
||||
tagColors: ['orange', 'green', 'red', 'blue'],
|
||||
videoContexts: {},
|
||||
currentVideoId: null
|
||||
};
|
||||
},
|
||||
|
||||
computed: {
|
||||
bloggerInfo() {
|
||||
let blogger = this.$tm.vx.getters().getConfigs.authorConfig.blogger;
|
||||
blogger.avatar = this.$utils.checkAvatarUrl(blogger.avatar, true);
|
||||
return blogger;
|
||||
},
|
||||
haloConfigs() {
|
||||
return this.$tm.vx.getters().getConfigs;
|
||||
},
|
||||
mockJson() {
|
||||
return this.$tm.vx.getters().getMockJson;
|
||||
},
|
||||
calcAuditModeEnabled() {
|
||||
return this.haloConfigs.auditConfig.auditModeEnabled
|
||||
},
|
||||
calcUseTagRandomColor() {
|
||||
return this.haloConfigs.pageConfig.momentConfig.useTagRandomColor
|
||||
},
|
||||
startConfig() {
|
||||
return this.haloConfigs.appConfig.startConfig;
|
||||
},
|
||||
},
|
||||
computed: {
|
||||
bloggerInfo() {
|
||||
let blogger = this.$tm.vx.getters().getConfigs.authorConfig.blogger;
|
||||
blogger.avatar = this.$utils.checkAvatarUrl(blogger.avatar, true);
|
||||
return blogger;
|
||||
},
|
||||
haloConfigs() {
|
||||
return this.$tm.vx.getters().getConfigs;
|
||||
},
|
||||
mockJson() {
|
||||
return this.$tm.vx.getters().getMockJson;
|
||||
},
|
||||
calcAuditModeEnabled() {
|
||||
return this.haloConfigs.auditConfig.auditModeEnabled
|
||||
},
|
||||
calcUseTagRandomColor() {
|
||||
return this.haloConfigs.pageConfig.momentConfig.useTagRandomColor
|
||||
},
|
||||
startConfig() {
|
||||
return this.haloConfigs.appConfig.startConfig;
|
||||
}
|
||||
},
|
||||
async onLoad() {
|
||||
// 检查插件
|
||||
this.setPluginId(this.NeedPluginIds.PluginMoments)
|
||||
this.setPluginError("阿偶,检测到当前插件没有安装或者启用,无法使用瞬间功能哦,请联系管理员")
|
||||
if (!await this.checkPluginAvailable()) return
|
||||
|
||||
this.fnGetData();
|
||||
},
|
||||
onPullDownRefresh() {
|
||||
if (!this.uniHaloPluginAvailable) {
|
||||
uni.hideLoading();
|
||||
uni.stopPullDownRefresh();
|
||||
return
|
||||
}
|
||||
this.isLoadMore = false;
|
||||
this.queryParams.page = 0;
|
||||
this.videoContexts = {};
|
||||
this.currentVideoId = null;
|
||||
this.fnGetData();
|
||||
},
|
||||
onReachBottom(e) {
|
||||
if (!this.uniHaloPluginAvailable) return;
|
||||
if (this.calcAuditModeEnabled) {
|
||||
uni.showToast({
|
||||
icon: 'none',
|
||||
title: '没有更多数据了'
|
||||
});
|
||||
return
|
||||
}
|
||||
if (this.hasNext) {
|
||||
this.queryParams.page += 1;
|
||||
this.isLoadMore = true;
|
||||
this.fnGetData();
|
||||
} else {
|
||||
uni.showToast({
|
||||
icon: 'none',
|
||||
title: '没有更多数据了'
|
||||
});
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
fnGetData() {
|
||||
if (this.calcAuditModeEnabled) {
|
||||
this.dataList = this.mockJson.moments.list.map((item) => {
|
||||
return {
|
||||
metadata: {
|
||||
name: Date.now() * Math.random(),
|
||||
},
|
||||
spec: {
|
||||
user: {
|
||||
displayName: this.bloggerInfo.nickname,
|
||||
avatar: this.$utils.checkAvatarUrl(this.bloggerInfo.avatar),
|
||||
},
|
||||
content: {
|
||||
html: item.content
|
||||
},
|
||||
releaseTime: item.time,
|
||||
visible: "PUBLIC"
|
||||
},
|
||||
images: item.images.map((img) => {
|
||||
return {
|
||||
type: "PHOTO",
|
||||
url: this.$utils.checkThumbnailUrl(img),
|
||||
}
|
||||
}),
|
||||
videos: []
|
||||
}
|
||||
});
|
||||
this.loading = 'success';
|
||||
this.loadMoreText = '呜呜,没有更多数据啦~';
|
||||
uni.hideLoading();
|
||||
uni.stopPullDownRefresh();
|
||||
return;
|
||||
}
|
||||
uni.showLoading({
|
||||
mask: true,
|
||||
title: '加载中...'
|
||||
});
|
||||
// 设置状态为加载中
|
||||
if (!this.isLoadMore) {
|
||||
this.loading = 'loading';
|
||||
}
|
||||
this.loadMoreText = '加载中...';
|
||||
this.$httpApi.v2
|
||||
.getMomentList(this.queryParams)
|
||||
.then(res => {
|
||||
this.loading = 'success';
|
||||
this.loadMoreText = res.hasNext ? '上拉加载更多' : '呜呜,没有更多数据啦~';
|
||||
this.hasNext = res.hasNext;
|
||||
|
||||
onLoad() {
|
||||
this.fnGetData();
|
||||
},
|
||||
onPullDownRefresh() {
|
||||
this.isLoadMore = false;
|
||||
this.queryParams.page = 0;
|
||||
this.fnGetData();
|
||||
},
|
||||
const tempItems = res.items.filter(x => x.spec.visible === 'PUBLIC').map(item => {
|
||||
item.spec.user = {
|
||||
displayName: this.bloggerInfo.nickname,
|
||||
avatar: this.$utils.checkAvatarUrl(this.bloggerInfo.avatar)
|
||||
}
|
||||
item.spec.content.medium.map(medium => {
|
||||
medium.url = this.$utils.checkThumbnailUrl(medium.url, true)
|
||||
})
|
||||
|
||||
onReachBottom(e) {
|
||||
if (this.calcAuditModeEnabled) {
|
||||
uni.showToast({
|
||||
icon: 'none',
|
||||
title: '没有更多数据了'
|
||||
});
|
||||
return
|
||||
}
|
||||
if (this.hasNext) {
|
||||
this.queryParams.page += 1;
|
||||
this.isLoadMore = true;
|
||||
this.fnGetData();
|
||||
} else {
|
||||
uni.showToast({
|
||||
icon: 'none',
|
||||
title: '没有更多数据了'
|
||||
});
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
fnGetData() {
|
||||
if (this.calcAuditModeEnabled) {
|
||||
this.dataList = this.mockJson.moments.list.map((item) => {
|
||||
return {
|
||||
metadata: {
|
||||
name: Date.now() * Math.random(),
|
||||
},
|
||||
spec: {
|
||||
user: {
|
||||
displayName: this.bloggerInfo.nickname,
|
||||
avatar: this.$utils.checkAvatarUrl(this.bloggerInfo.avatar),
|
||||
},
|
||||
content: {
|
||||
html: item.content
|
||||
},
|
||||
releaseTime: item.time,
|
||||
visible: "PUBLIC"
|
||||
},
|
||||
images: item.images.map((img) => {
|
||||
return {
|
||||
type: "PHOTO",
|
||||
url: this.$utils.checkThumbnailUrl(img),
|
||||
}
|
||||
}),
|
||||
videos: []
|
||||
}
|
||||
});
|
||||
this.loading = 'success';
|
||||
this.loadMoreText = '呜呜,没有更多数据啦~';
|
||||
uni.hideLoading();
|
||||
uni.stopPullDownRefresh();
|
||||
return;
|
||||
}
|
||||
uni.showLoading({
|
||||
mask: true,
|
||||
title: '加载中...'
|
||||
});
|
||||
// 设置状态为加载中
|
||||
if (!this.isLoadMore) {
|
||||
this.loading = 'loading';
|
||||
}
|
||||
this.loadMoreText = '加载中...';
|
||||
this.$httpApi.v2
|
||||
.getMomentList(this.queryParams)
|
||||
.then(res => {
|
||||
this.loading = 'success';
|
||||
this.loadMoreText = res.hasNext ? '上拉加载更多' : '呜呜,没有更多数据啦~';
|
||||
this.hasNext = res.hasNext;
|
||||
item.spec.newHtml = this.removeTagLinksCompletely(item.spec.content.html, '')
|
||||
item['images'] = item.spec.content.medium
|
||||
.filter(x => x.type === 'PHOTO')
|
||||
|
||||
const tempItems = res.items.map(item => {
|
||||
item.spec.user = {
|
||||
displayName: this.bloggerInfo.nickname,
|
||||
avatar: this.$utils.checkAvatarUrl(this.bloggerInfo.avatar)
|
||||
}
|
||||
item.spec.content.medium.map(medium => {
|
||||
medium.url = this.$utils.checkThumbnailUrl(medium.url, true)
|
||||
})
|
||||
item['videos'] = item.spec.content.medium
|
||||
.filter(x => x.type === 'VIDEO').map(item => {
|
||||
item.id = generateUUID()
|
||||
return item;
|
||||
})
|
||||
|
||||
item.spec.newHtml = this.removeTagLinksCompletely(item.spec.content.html, '')
|
||||
item['images'] = item.spec.content.medium
|
||||
.filter(x => x.type === 'PHOTO')
|
||||
item['audios'] = item.spec.content.medium
|
||||
.filter(x => x.type === 'AUDIO')
|
||||
return item;
|
||||
})
|
||||
|
||||
item['videos'] = item.spec.content.medium
|
||||
.filter(x => x.type === 'VIDEO')
|
||||
if (this.isLoadMore) {
|
||||
this.dataList = this.dataList.concat(tempItems);
|
||||
} else {
|
||||
this.dataList = tempItems;
|
||||
}
|
||||
|
||||
item['audios'] = item.spec.content.medium
|
||||
.filter(x => x.type === 'AUDIO')
|
||||
return item;
|
||||
})
|
||||
this.$nextTick(() => {
|
||||
this.createVideoContexts(tempItems);
|
||||
})
|
||||
|
||||
if (this.isLoadMore) {
|
||||
this.dataList = this.dataList.concat(tempItems);
|
||||
} else {
|
||||
this.dataList = tempItems;
|
||||
}
|
||||
})
|
||||
.catch(err => {
|
||||
console.error(err);
|
||||
this.loading = 'error';
|
||||
this.loadMoreText = '加载失败,请下拉刷新!';
|
||||
})
|
||||
.finally(() => {
|
||||
setTimeout(() => {
|
||||
uni.hideLoading();
|
||||
uni.stopPullDownRefresh();
|
||||
}, 500);
|
||||
});
|
||||
},
|
||||
handlePreview(index, list) {
|
||||
uni.previewImage({
|
||||
current: index,
|
||||
urls: list.map(item => item.url)
|
||||
})
|
||||
},
|
||||
removeTagLinksCompletely(htmlString) {
|
||||
const regex = /<a\s+(?:[^>]*?\s+)?class=(['"])[^'"]*?\btag\b[^'"]*?\1[^>]*?>.*?<\/a>/gi;
|
||||
const newHtml = htmlString.replace(regex, '');
|
||||
return newHtml
|
||||
// .replace(/<[^>]+>\s*<\/[^>]+>/g, '')
|
||||
// .replace(/\s+/g, ' ')
|
||||
// .trim();
|
||||
},
|
||||
randomTagColor() {
|
||||
if (!this.calcUseTagRandomColor) return "blue";
|
||||
const randomIndex = getRandomNumberByRange(0, this.tagColors.length);
|
||||
return this.tagColors[randomIndex];
|
||||
}
|
||||
}
|
||||
};
|
||||
})
|
||||
.catch(err => {
|
||||
console.error(err);
|
||||
this.loading = 'error';
|
||||
this.loadMoreText = '加载失败,请下拉刷新!';
|
||||
})
|
||||
.finally(() => {
|
||||
setTimeout(() => {
|
||||
uni.hideLoading();
|
||||
uni.stopPullDownRefresh();
|
||||
}, 500);
|
||||
});
|
||||
},
|
||||
handlePreview(index, list) {
|
||||
uni.previewImage({
|
||||
current: index,
|
||||
urls: list.map(item => item.url)
|
||||
})
|
||||
},
|
||||
removeTagLinksCompletely(htmlString) {
|
||||
const regex = /<a\s+(?:[^>]*?\s+)?class=(['"])[^'"]*?\btag\b[^'"]*?\1[^>]*?>.*?<\/a>/gi;
|
||||
const newHtml = htmlString.replace(regex, '');
|
||||
return newHtml
|
||||
},
|
||||
randomTagColor() {
|
||||
if (!this.calcUseTagRandomColor) return "blue";
|
||||
const randomIndex = getRandomNumberByRange(0, this.tagColors.length);
|
||||
return this.tagColors[randomIndex];
|
||||
},
|
||||
createVideoContexts(list) {
|
||||
this.stopAllVideos()
|
||||
list.map(item => item.videos).flat().forEach(item => {
|
||||
this.videoContexts[item.id] = uni.createVideoContext(`video_${item.id}`, this);
|
||||
})
|
||||
},
|
||||
onVideoPlay(videoId) {
|
||||
this.currentVideoId = videoId;
|
||||
this.stopAllVideos(videoId)
|
||||
},
|
||||
onVideoPause(videoId) {
|
||||
if (this.currentVideoId == videoId) {
|
||||
this.currentVideoId = null;
|
||||
}
|
||||
},
|
||||
onVideoEnded(videoId) {
|
||||
this.currentVideoId = null;
|
||||
},
|
||||
stopAllVideos(excludesVideoId = null) {
|
||||
Object.keys(this.videoContexts).forEach(videoId => {
|
||||
if (!excludesVideoId || excludesVideoId != videoId) {
|
||||
const videoContext = this.videoContexts[videoId]
|
||||
videoContext?.pause();
|
||||
}
|
||||
});
|
||||
},
|
||||
handleToMomentDetail(moment) {
|
||||
if (this.calcAuditModeEnabled) return;
|
||||
uni.navigateTo({
|
||||
url: '/pagesA/moment-detail/moment-detail?name=' + moment.metadata.name,
|
||||
animationType: 'slide-in-right'
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.app-page {
|
||||
width: 100vw;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding: 24rpx 0;
|
||||
}
|
||||
.app-page {
|
||||
box-sizing: border-box;
|
||||
width: 100vw;
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding: 24rpx 0;
|
||||
}
|
||||
|
||||
.loading-wrap {
|
||||
padding: 24rpx;
|
||||
}
|
||||
.loading-wrap {
|
||||
padding: 24rpx;
|
||||
}
|
||||
|
||||
.moment-card {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
box-sizing: border-box;
|
||||
margin: 0 24rpx;
|
||||
border-radius: 12rpx;
|
||||
background-color: #ffff;
|
||||
box-shadow: 0rpx 2rpx 24rpx rgba(0, 0, 0, 0.03);
|
||||
overflow: hidden;
|
||||
margin-bottom: 24rpx;
|
||||
}
|
||||
.moment-card {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
box-sizing: border-box;
|
||||
margin: 0 24rpx;
|
||||
border-radius: 12rpx;
|
||||
background-color: #ffff;
|
||||
box-shadow: 0rpx 2rpx 24rpx rgba(0, 0, 0, 0.03);
|
||||
overflow: hidden;
|
||||
margin-bottom: 24rpx;
|
||||
}
|
||||
|
||||
.head {
|
||||
padding: 24rpx;
|
||||
padding-bottom: 0;
|
||||
}
|
||||
.head {
|
||||
padding: 24rpx;
|
||||
padding-bottom: 0;
|
||||
}
|
||||
|
||||
.images {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: flex-start;
|
||||
padding: 24rpx;
|
||||
padding-top: 0;
|
||||
.images {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: flex-start;
|
||||
padding: 24rpx;
|
||||
padding-top: 0;
|
||||
|
||||
.image-item {
|
||||
box-sizing: border-box;
|
||||
border-radius: 24rpx;
|
||||
padding: 6rpx;
|
||||
width: 33%;
|
||||
height: 200rpx
|
||||
}
|
||||
.image-item {
|
||||
box-sizing: border-box;
|
||||
border-radius: 24rpx;
|
||||
padding: 6rpx;
|
||||
width: 33%;
|
||||
height: 200rpx
|
||||
}
|
||||
|
||||
&-1 {
|
||||
> .image-item {
|
||||
width: 100%;
|
||||
height: 350rpx
|
||||
}
|
||||
}
|
||||
&-1 {
|
||||
>.image-item {
|
||||
width: 100%;
|
||||
height: 350rpx
|
||||
}
|
||||
}
|
||||
|
||||
&-2 {
|
||||
> .image-item {
|
||||
width: 50%;
|
||||
height: 250rpx
|
||||
}
|
||||
}
|
||||
}
|
||||
&-2 {
|
||||
>.image-item {
|
||||
width: 50%;
|
||||
height: 250rpx
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
::v-deep .uni-audio-default {
|
||||
width: 100%;
|
||||
border-radius: 12rpx;
|
||||
}
|
||||
|
||||
</style>
|
||||
::v-deep .uni-audio-default {
|
||||
width: 100%;
|
||||
border-radius: 12rpx;
|
||||
}
|
||||
</style>
|
||||
+1478
-1390
File diff suppressed because it is too large
Load Diff
+229
-182
@@ -1,198 +1,245 @@
|
||||
<template>
|
||||
<view class="app-page" :class="{ 'is-balck grey-darken-6': isBlackTheme }">
|
||||
<!-- 顶部切换 -->
|
||||
<view class="e-fixed shadow-1">
|
||||
<tm-search v-model="queryParams.keyword" :round="24" :shadow="0" color="light-blue"
|
||||
insert-color="light-blue" :clear="true" @input="fnOnSearch" @confirm="fnOnSearch"></tm-search>
|
||||
<tm-tabs v-if="false" color="light-blue" :shadow="0" v-model="tab.activeIndex" :list="tab.list"
|
||||
align="center" @change="fnOnTabChange"></tm-tabs>
|
||||
</view>
|
||||
<!-- 占位区域 -->
|
||||
<view style="width: 100vw;height: 100rpx;"></view>
|
||||
<!-- 加载区域 -->
|
||||
<view v-if="loading == 'loading'" class="loading-wrap pa-24">
|
||||
<tm-skeleton model="listAvatr"></tm-skeleton>
|
||||
<tm-skeleton model="listAvatr"></tm-skeleton>
|
||||
<tm-skeleton model="listAvatr"></tm-skeleton>
|
||||
<tm-skeleton model="listAvatr"></tm-skeleton>
|
||||
</view>
|
||||
<view v-else-if="loading == 'error'" class="content-empty flex flex-center">
|
||||
<tm-empty icon="icon-wind-cry" label="搜索异常"></tm-empty>
|
||||
</view>
|
||||
<!-- 内容区域 -->
|
||||
<view v-else class="content">
|
||||
<view v-if="dataList.length == 0" class="content-empty flex flex-center">
|
||||
<!-- 空布局 -->
|
||||
<tm-empty v-if="!queryParams.keyword" icon="icon-shiliangzhinengduixiang-" label="请输入关键词搜索"></tm-empty>
|
||||
<tm-empty v-else icon="icon-shiliangzhinengduixiang-"
|
||||
:label="`未搜到 ${queryParams.keyword} 相关内容`"></tm-empty>
|
||||
</view>
|
||||
<block v-else>
|
||||
<!-- 文章卡片 -->
|
||||
<tm-translate v-for="(article, index) in dataList" :key="article.metadataName" animation-name="fadeUp"
|
||||
:wait="calcAniWait(index)">
|
||||
<view class="article-card" @click="fnToArticleDetail(article)">
|
||||
<rich-text style="font-size: 32rpx;font-weight: bold;color: #333;"
|
||||
:nodes="article.title"></rich-text>
|
||||
<rich-text style="font-size: 28rpx;margin-top: 16rpx;color: #555;"
|
||||
:nodes="article.description"></rich-text>
|
||||
<text style="font-size: 24rpx;margin-top: 24rpx;color:#888">
|
||||
最近更新:{{ {d: article.updateTimestamp, f: 'yyyy年MM月dd日 HH点mm分ss秒'} | formatTime }}
|
||||
</text>
|
||||
</view>
|
||||
</tm-translate>
|
||||
<view class="app-page" :class="[uniHaloPluginPageClass]">
|
||||
<PluginUnavailable v-if="!uniHaloPluginAvailable" :pluginId="uniHaloPluginId"
|
||||
:error-text="uniHaloPluginAvailableError" />
|
||||
<template v-else>
|
||||
|
||||
<tm-flotbutton @click="fnToTopPage" size="m" color="light-blue" icon="icon-angle-up"></tm-flotbutton>
|
||||
<!-- 顶部切换 -->
|
||||
<view class="e-fixed shadow-1">
|
||||
<tm-search v-model="queryParams.keyword" :round="24" :shadow="0" color="light-blue"
|
||||
insert-color="light-blue" :clear="true" @input="fnOnSearch" @confirm="fnOnSearch"></tm-search>
|
||||
<tm-tabs v-if="false" color="light-blue" :shadow="0" v-model="tab.activeIndex" :list="tab.list"
|
||||
align="center" @change="fnOnTabChange"></tm-tabs>
|
||||
</view>
|
||||
<!-- 占位区域 -->
|
||||
<view style="width: 100vw;height: 100rpx;"></view>
|
||||
<!-- 加载区域 -->
|
||||
<view v-if="loading == 'loading'" class="loading-wrap pa-24">
|
||||
<tm-skeleton model="listAvatr"></tm-skeleton>
|
||||
<tm-skeleton model="listAvatr"></tm-skeleton>
|
||||
<tm-skeleton model="listAvatr"></tm-skeleton>
|
||||
<tm-skeleton model="listAvatr"></tm-skeleton>
|
||||
</view>
|
||||
<view v-else-if="loading == 'error'" class="content-empty flex flex-center">
|
||||
<tm-empty icon="icon-wind-cry" label="搜索异常"></tm-empty>
|
||||
</view>
|
||||
<!-- 内容区域 -->
|
||||
<view v-else class="content">
|
||||
<view v-if="dataList.length == 0" class="content-empty flex flex-center">
|
||||
<!-- 空布局 -->
|
||||
<tm-empty v-if="!queryParams.keyword" icon="icon-shiliangzhinengduixiang-"
|
||||
label="请输入关键词搜索"></tm-empty>
|
||||
<tm-empty v-else icon="icon-shiliangzhinengduixiang-"
|
||||
:label="`未搜到 ${queryParams.keyword} 相关内容`"></tm-empty>
|
||||
</view>
|
||||
<block v-else>
|
||||
<tm-translate v-for="(item, index) in dataList" :key="item.metadataName" animation-name="fadeUp"
|
||||
:wait="calcAniWait(index)">
|
||||
<view class="article-card" @click="fnToDetail(item)">
|
||||
<view class="mb-12 flex flex-start">
|
||||
<view class="flex-shrink ml--12">
|
||||
<tm-tags v-if="isArticle(item)" color="blue" size="n" model="text">文章</tm-tags>
|
||||
<tm-tags v-else color="green" size="n" model="text">瞬间</tm-tags>
|
||||
</view>
|
||||
<text class="ml-2 text-overflow text-size-n text-weight-b"
|
||||
style="color: #333;">{{ item.title }}</text>
|
||||
</view>
|
||||
<mp-html class="evan-markdown" lazy-load :domain="markdownConfig.domain"
|
||||
:loading-img="markdownConfig.loadingGif" :scroll-table="true" :selectable="true"
|
||||
:tag-style="markdownConfig.tagStyle" :content="item.description || item.content"
|
||||
:markdown="true" :showLineNumber="true" :showLanguageName="true"
|
||||
:copyByLongPress="true" />
|
||||
<view class="mt-12 flex flex-center flex-between">
|
||||
<text style="font-size: 24rpx;color:#888">
|
||||
最近更新时间:{{ {d: item.updateTimestamp, f: 'yyyy年MM月dd日 HH点mm分ss秒'} | formatTime }}
|
||||
</text>
|
||||
<!-- <tm-tags v-if="isArticle(item)" color="blue" size="n" model="text">文章</tm-tags>
|
||||
<tm-tags v-else color="green" size="n" model="text">瞬间</tm-tags> -->
|
||||
</view>
|
||||
</view>
|
||||
</tm-translate>
|
||||
|
||||
</block>
|
||||
</view>
|
||||
</view>
|
||||
<tm-flotbutton @click="fnToTopPage" size="m" color="light-blue"
|
||||
icon="icon-angle-up"></tm-flotbutton>
|
||||
|
||||
</block>
|
||||
</view>
|
||||
</template>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import tmSkeleton from '@/tm-vuetify/components/tm-skeleton/tm-skeleton.vue';
|
||||
import tmSearch from '@/tm-vuetify/components/tm-search/tm-search.vue';
|
||||
import tmTranslate from '@/tm-vuetify/components/tm-translate/tm-translate.vue';
|
||||
import tmTabs from '@/tm-vuetify/components/tm-tabs/tm-tabs.vue';
|
||||
import tmFlotbutton from '@/tm-vuetify/components/tm-flotbutton/tm-flotbutton.vue';
|
||||
import tmEmpty from '@/tm-vuetify/components/tm-empty/tm-empty.vue';
|
||||
import tmSkeleton from '@/tm-vuetify/components/tm-skeleton/tm-skeleton.vue';
|
||||
import tmSearch from '@/tm-vuetify/components/tm-search/tm-search.vue';
|
||||
import tmTranslate from '@/tm-vuetify/components/tm-translate/tm-translate.vue';
|
||||
import tmTabs from '@/tm-vuetify/components/tm-tabs/tm-tabs.vue';
|
||||
import tmFlotbutton from '@/tm-vuetify/components/tm-flotbutton/tm-flotbutton.vue';
|
||||
import tmEmpty from '@/tm-vuetify/components/tm-empty/tm-empty.vue';
|
||||
import tmTags from '@/tm-vuetify/components/tm-tags/tm-tags.vue';
|
||||
|
||||
export default {
|
||||
components: {
|
||||
tmSkeleton,
|
||||
tmSearch,
|
||||
tmTranslate,
|
||||
tmTabs,
|
||||
tmFlotbutton,
|
||||
tmEmpty
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
isBlackTheme: false,
|
||||
loading: 'loading',
|
||||
tab: {
|
||||
activeIndex: 0,
|
||||
list: ['全部', '最新文章', '热门文章', '最近更新', '最多点赞']
|
||||
},
|
||||
queryParams: {
|
||||
keyword: "",
|
||||
limit: 5,
|
||||
highlightPreTag: "<text>",
|
||||
highlightPostTag: "</text>"
|
||||
},
|
||||
cache: {
|
||||
dataList: [],
|
||||
total: 0
|
||||
},
|
||||
dataList: []
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
haloConfigs() {
|
||||
return this.$tm.vx.getters().getConfigs;
|
||||
},
|
||||
calcAuditModeEnabled() {
|
||||
return this.haloConfigs.auditConfig.auditModeEnabled
|
||||
},
|
||||
},
|
||||
onLoad() {
|
||||
this.fnSetPageTitle('内容搜索');
|
||||
},
|
||||
created() {
|
||||
if (!this.queryParams.keyword) {
|
||||
this.loading = 'success'
|
||||
} else {
|
||||
this.fnGetData();
|
||||
}
|
||||
},
|
||||
onPullDownRefresh() {
|
||||
this.fnResetSetAniWaitIndex();
|
||||
this.fnGetData();
|
||||
},
|
||||
import MarkdownConfig from '@/common/markdown/markdown.config.js';
|
||||
import mpHtml from '@/components/mp-html/components/mp-html/mp-html.vue';
|
||||
|
||||
methods: {
|
||||
fnOnTabChange(index) {
|
||||
this.fnResetSetAniWaitIndex();
|
||||
this.dataList = [];
|
||||
this.fnToTopPage();
|
||||
this.fnGetData();
|
||||
},
|
||||
fnOnSearch() {
|
||||
this.fnResetSetAniWaitIndex();
|
||||
import pluginAvailableMixin from "@/common/mixins/pluginAvailable.js"
|
||||
import PluginUnavailable from '@/components/plugin-unavailable/plugin-unavailable.vue'
|
||||
|
||||
if (!this.queryParams.keyword) {
|
||||
this.dataList = []
|
||||
} else {
|
||||
this.fnGetData();
|
||||
}
|
||||
},
|
||||
fnGetData() {
|
||||
if (this.calcAuditModeEnabled) {
|
||||
return;
|
||||
}
|
||||
// 设置状态为加载中
|
||||
this.loading = 'loading';
|
||||
this.$httpApi.v2
|
||||
.getPostListByKeyword(this.queryParams)
|
||||
.then(res => {
|
||||
this.loading = 'success';
|
||||
this.dataList = res.hits;
|
||||
})
|
||||
.catch(err => {
|
||||
console.error(err);
|
||||
this.loading = 'error';
|
||||
})
|
||||
.finally(() => {
|
||||
setTimeout(() => {
|
||||
uni.hideLoading();
|
||||
uni.stopPullDownRefresh();
|
||||
}, 800);
|
||||
});
|
||||
},
|
||||
export default {
|
||||
mixins: [pluginAvailableMixin],
|
||||
components: {
|
||||
tmSkeleton,
|
||||
tmSearch,
|
||||
tmTranslate,
|
||||
tmTabs,
|
||||
tmFlotbutton,
|
||||
tmEmpty,
|
||||
tmTags,
|
||||
mpHtml,
|
||||
PluginUnavailable
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
markdownConfig: MarkdownConfig,
|
||||
loading: 'loading',
|
||||
tab: {
|
||||
activeIndex: 0,
|
||||
list: ['全部', '最新文章', '热门文章', '最近更新', '最多点赞']
|
||||
},
|
||||
queryParams: {
|
||||
keyword: "",
|
||||
limit: 50,
|
||||
highlightPreTag: "",
|
||||
highlightPostTag: ""
|
||||
},
|
||||
cache: {
|
||||
dataList: [],
|
||||
total: 0
|
||||
},
|
||||
dataList: []
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
haloConfigs() {
|
||||
return this.$tm.vx.getters().getConfigs;
|
||||
},
|
||||
calcAuditModeEnabled() {
|
||||
return this.haloConfigs.auditConfig.auditModeEnabled
|
||||
},
|
||||
},
|
||||
async onLoad() {
|
||||
this.fnSetPageTitle('内容搜索');
|
||||
// 检查插件
|
||||
this.setPluginId(this.NeedPluginIds.PluginSearchWidget)
|
||||
this.setPluginError("阿偶,检测到当前插件没有安装或者启用,无法使用搜索功能哦,请联系管理员")
|
||||
if (!await this.checkPluginAvailable()) return
|
||||
if (!this.queryParams.keyword) {
|
||||
this.loading = 'success'
|
||||
} else {
|
||||
this.fnGetData();
|
||||
}
|
||||
},
|
||||
|
||||
//跳转文章详情
|
||||
fnToArticleDetail(article) {
|
||||
uni.navigateTo({
|
||||
url: '/pagesA/article-detail/article-detail?name=' + article.metadataName,
|
||||
animationType: 'slide-in-right'
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
onPullDownRefresh() {
|
||||
if (!this.uniHaloPluginAvailable) {
|
||||
uni.hideLoading();
|
||||
uni.stopPullDownRefresh();
|
||||
return
|
||||
}
|
||||
this.fnOnSearch()
|
||||
},
|
||||
|
||||
methods: {
|
||||
fnOnTabChange(index) {
|
||||
this.fnResetSetAniWaitIndex();
|
||||
this.dataList = [];
|
||||
this.fnToTopPage();
|
||||
this.fnGetData();
|
||||
},
|
||||
fnOnSearch() {
|
||||
this.fnResetSetAniWaitIndex();
|
||||
if (!this.queryParams.keyword) {
|
||||
this.dataList = []
|
||||
} else {
|
||||
this.fnGetData();
|
||||
}
|
||||
},
|
||||
fnGetData() {
|
||||
if (this.calcAuditModeEnabled) {
|
||||
return;
|
||||
}
|
||||
// 设置状态为加载中
|
||||
this.loading = 'loading';
|
||||
this.$httpApi.v2
|
||||
.getPostListByKeyword(this.queryParams)
|
||||
.then(res => {
|
||||
this.loading = 'success';
|
||||
this.dataList = res.hits;
|
||||
})
|
||||
.catch(err => {
|
||||
console.error(err);
|
||||
this.loading = 'error';
|
||||
})
|
||||
.finally(() => {
|
||||
setTimeout(() => {
|
||||
uni.hideLoading();
|
||||
uni.stopPullDownRefresh();
|
||||
}, 800);
|
||||
});
|
||||
},
|
||||
isArticle(item) {
|
||||
return item.type == 'post.content.halo.run'
|
||||
},
|
||||
//跳转详情
|
||||
fnToDetail(item) {
|
||||
if (this.calcAuditModeEnabled) return;
|
||||
if (this.isArticle(item)) {
|
||||
uni.navigateTo({
|
||||
url: '/pagesA/article-detail/article-detail?name=' + item.metadataName,
|
||||
animationType: 'slide-in-right'
|
||||
});
|
||||
} else {
|
||||
uni.navigateTo({
|
||||
url: '/pagesA/moment-detail/moment-detail?name=' + item.metadataName,
|
||||
animationType: 'slide-in-right'
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.app-page {
|
||||
width: 100vw;
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding-bottom: 24rpx;
|
||||
background-color: #fafafd;
|
||||
.app-page {
|
||||
width: 100vw;
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding-bottom: 24rpx;
|
||||
background-color: #fafafd;
|
||||
|
||||
&.is-balck {
|
||||
background-color: #212121;
|
||||
}
|
||||
}
|
||||
&.is-balck {
|
||||
background-color: #212121;
|
||||
}
|
||||
}
|
||||
|
||||
.content {
|
||||
padding-top: 24rpx;
|
||||
}
|
||||
.content {
|
||||
padding-top: 24rpx;
|
||||
}
|
||||
|
||||
.content-empty {
|
||||
height: 60vh;
|
||||
}
|
||||
|
||||
.article-card {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
box-sizing: border-box;
|
||||
margin: 0 24rpx;
|
||||
padding: 24rpx;
|
||||
border-radius: 12rpx;
|
||||
background-color: #ffff;
|
||||
box-shadow: 0rpx 2rpx 24rpx rgba(0, 0, 0, 0.03);
|
||||
overflow: hidden;
|
||||
margin-bottom: 24rpx;
|
||||
}
|
||||
</style>
|
||||
.content-empty {
|
||||
height: 60vh;
|
||||
}
|
||||
|
||||
.article-card {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
box-sizing: border-box;
|
||||
margin: 0 24rpx;
|
||||
padding: 24rpx;
|
||||
border-radius: 12rpx;
|
||||
background-color: #ffff;
|
||||
box-shadow: 0rpx 2rpx 24rpx rgba(0, 0, 0, 0.03);
|
||||
overflow: hidden;
|
||||
margin-bottom: 24rpx;
|
||||
}
|
||||
</style>
|
||||
@@ -1,431 +1,454 @@
|
||||
<template>
|
||||
<view class="app-page card-shadow">
|
||||
<view v-if="loading != 'success'" class="loading-wrap">
|
||||
<tm-skeleton model="listAvatr"></tm-skeleton>
|
||||
<tm-skeleton model="listAvatr"></tm-skeleton>
|
||||
<tm-skeleton model="listAvatr"></tm-skeleton>
|
||||
<tm-skeleton model="listAvatr"></tm-skeleton>
|
||||
<tm-skeleton model="listAvatr"></tm-skeleton>
|
||||
</view>
|
||||
<view v-else class="content" :class="{ 'bg-white': dataList.length !== 0 }">
|
||||
<!-- 空数据 -->
|
||||
<view v-if="dataList.length == 0" class="content-empty flex flex-center">
|
||||
<tm-empty icon="icon-shiliangzhinengduixiang-" label="啊偶,博主还没有朋友呢~"></tm-empty>
|
||||
</view>
|
||||
<view class="app-page card-shadow" :class="[uniHaloPluginPageClass]">
|
||||
<PluginUnavailable v-if="!uniHaloPluginAvailable" :pluginId="uniHaloPluginId"
|
||||
:error-text="uniHaloPluginAvailableError" />
|
||||
<template v-else>
|
||||
<view v-if="loading != 'success'" class="loading-wrap">
|
||||
<tm-skeleton model="listAvatr"></tm-skeleton>
|
||||
<tm-skeleton model="listAvatr"></tm-skeleton>
|
||||
<tm-skeleton model="listAvatr"></tm-skeleton>
|
||||
<tm-skeleton model="listAvatr"></tm-skeleton>
|
||||
<tm-skeleton model="listAvatr"></tm-skeleton>
|
||||
</view>
|
||||
<view v-else class="content" :class="{ 'bg-white': dataList.length !== 0 }">
|
||||
<!-- 空数据 -->
|
||||
<view v-if="dataList.length == 0" class="content-empty flex flex-center">
|
||||
<tm-empty icon="icon-shiliangzhinengduixiang-" label="啊偶,博主还没有朋友呢~"></tm-empty>
|
||||
</view>
|
||||
|
||||
<!-- 如果只有一个分组:使用列表的形式 dataList.length == 1 -->
|
||||
<view v-else class="flex flex-col pb-24">
|
||||
<block v-for="(link, index) in dataList" :key="index">
|
||||
<tm-translate animation-name="fadeUp" :wait="calcAniWait(index)">
|
||||
<!-- 色彩版本 -->
|
||||
<view v-if="!globalAppSettings.links.useSimple" class="info flex pt-24 pb-24 pl-12 pr-12"
|
||||
:class="{ 'border-b-1': index !== dataList.length - 1 }" @click="fnOnLinkEvent(link)">
|
||||
<view class="link-logo">
|
||||
<cache-image class="link-logo_img" radius="12rpx" :url="link.spec.logo"
|
||||
:fileMd5="link.spec.logo" mode="aspectFill"></cache-image>
|
||||
</view>
|
||||
<view class="flex flex-col pl-30 info-detail">
|
||||
<view class="link-card_name text-size-l text-weight-b text-red">
|
||||
<tm-tags style="margin-right: 12rpx;margin-left: -2rpx;"
|
||||
color="bg-gradient-light-blue-lighten" :shadow="0" size="s" model="fill">
|
||||
{{ link.spec.groupName || '暂未分组' }}
|
||||
</tm-tags>
|
||||
{{ link.spec.displayName }}
|
||||
</view>
|
||||
<view class="poup-tag mt-6" style="font-size: 28rpx;">
|
||||
站点地址:{{ link.spec.url }}
|
||||
<!-- <tm-tags color="bg-gradient-amber-accent" :shadow="0" size="s" model="fill">
|
||||
<!-- 如果只有一个分组:使用列表的形式 dataList.length == 1 -->
|
||||
<view v-else class="flex flex-col pb-24">
|
||||
<block v-for="(link, index) in dataList" :key="index">
|
||||
<tm-translate animation-name="fadeUp" :wait="calcAniWait(index)">
|
||||
<!-- 色彩版本 -->
|
||||
<view v-if="!globalAppSettings.links.useSimple" class="info flex pt-24 pb-24 pl-12 pr-12"
|
||||
:class="{ 'border-b-1': index !== dataList.length - 1 }" @click="fnOnLinkEvent(link)">
|
||||
<view class="link-logo">
|
||||
<cache-image class="link-logo_img" radius="12rpx" :url="link.spec.logo"
|
||||
:fileMd5="link.spec.logo" mode="aspectFill"></cache-image>
|
||||
</view>
|
||||
<view class="flex flex-col pl-30 info-detail">
|
||||
<view class="link-card_name text-size-l text-weight-b text-red">
|
||||
<tm-tags style="margin-right: 12rpx;margin-left: -2rpx;"
|
||||
color="bg-gradient-light-blue-lighten" :shadow="0" size="s" model="fill">
|
||||
{{ link.spec.groupName || '暂未分组' }}
|
||||
</tm-tags>
|
||||
{{ link.spec.displayName }}
|
||||
</view>
|
||||
<view class="poup-tag mt-6" style="font-size: 28rpx;">
|
||||
站点地址:{{ link.spec.url }}
|
||||
<!-- <tm-tags color="bg-gradient-amber-accent" :shadow="0" size="s" model="fill">
|
||||
URL:{{ link.spec.url }}
|
||||
</tm-tags>
|
||||
<tm-tags color=" bg-gradient-light-blue-lighten" :shadow="0" size="s" model="fill">
|
||||
{{ link.spec.groupName || '暂未分组' }}
|
||||
</tm-tags> -->
|
||||
</view>
|
||||
<view class="link-card_desc text-overflow mt-4" style="font-size: 28rpx;">
|
||||
博客简介:{{ link.spec.description || '这个博主很懒,没写简介~' }}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 简洁版本 -->
|
||||
<view v-else class="link-card flex ml-24 mr-24 pt-24 pb-24" @click="fnOnLinkEvent(link)">
|
||||
<image class="logo shadow-6" :src="link.spec.logo" mode="aspectFill"></image>
|
||||
<view class="info pl-24">
|
||||
<view class="name text-size-g">{{ link.spec.displayName }}</view>
|
||||
<view class="desc mt-12 text-size-s text-grey-darken-1">{{ link.spec.description }}
|
||||
</view>
|
||||
<view v-if="false" class="link mt-12 text-size-m text-grey-darken-1">
|
||||
<text class="iconfont icon-link mr-6 text-size-s"></text>
|
||||
{{ link.spec.url }}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</tm-translate>
|
||||
</block>
|
||||
</view>
|
||||
</view>
|
||||
<view class="link-card_desc text-overflow mt-4" style="font-size: 28rpx;">
|
||||
博客简介:{{ link.spec.description || '这个博主很懒,没写简介~' }}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 简洁版本 -->
|
||||
<view v-else class="link-card flex ml-24 mr-24 pt-24 pb-24" @click="fnOnLinkEvent(link)">
|
||||
<image class="logo shadow-6" :src="link.spec.logo" mode="aspectFill"></image>
|
||||
<view class="info pl-24">
|
||||
<view class="name text-size-g">{{ link.spec.displayName }}</view>
|
||||
<view class="desc mt-12 text-size-s text-grey-darken-1">{{ link.spec.description }}
|
||||
</view>
|
||||
<view v-if="false" class="link mt-12 text-size-m text-grey-darken-1">
|
||||
<text class="iconfont icon-link mr-6 text-size-s"></text>
|
||||
{{ link.spec.url }}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</tm-translate>
|
||||
</block>
|
||||
</view>
|
||||
|
||||
<!-- 返回顶部 -->
|
||||
<tm-flotbutton color="light-blue" @click="fnToTopPage" size="m" icon="icon-angle-up"></tm-flotbutton>
|
||||
<tm-flotbutton v-if="haloPluginConfigs.linksSubmitPlugin.enabled" :offset="[16,80]" label="申请"
|
||||
actions-pos="left" :show-text="true" color="bg-gradient-orange-accent"
|
||||
@click="toSubmitLinkPage"></tm-flotbutton>
|
||||
<!-- 详情弹窗 -->
|
||||
<tm-poup v-model="detail.show" :width="640" height="auto" position="center" :round="6">
|
||||
<view class="poup pa-36" v-if="detail.data">
|
||||
<view class="info flex">
|
||||
<view class="poup-logo bg-gradient-amber-accent pa-4 shadow-24">
|
||||
<image class="poup-logo_img" :src="$utils.checkImageUrl(detail.data.spec.logo)" mode="aspectFill"></image>
|
||||
</view>
|
||||
<view class="pl-24 info-detail">
|
||||
<view class="poup-name text-size-lg text-weight-b">{{ detail.data.spec.displayName }}</view>
|
||||
<view class="poup-tag ml--10">
|
||||
<tm-tags color="bg-gradient-light-blue-lighten" size="n" model="fill">
|
||||
{{ detail.data.spec.groupName }}
|
||||
</tm-tags>
|
||||
</view>
|
||||
<view class="poup-link text-size-m" @click="fnCopyLink(detail.data)">
|
||||
<text class="text-orange">{{ detail.data.spec.url }}</text>
|
||||
<text class="iconfont icon-copy text-size-s ml-6 text-grey"></text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 返回顶部 -->
|
||||
<tm-flotbutton color="light-blue" @click="fnToTopPage" size="m" icon="icon-angle-up"></tm-flotbutton>
|
||||
<tm-flotbutton v-if="haloPluginConfigs.linksSubmitPlugin.enabled" :offset="[16,80]" label="申请"
|
||||
actions-pos="left" :show-text="true" color="bg-gradient-orange-accent"
|
||||
@click="toSubmitLinkPage"></tm-flotbutton>
|
||||
<!-- 详情弹窗 -->
|
||||
<tm-poup v-model="detail.show" :width="640" height="auto" position="center" :round="6">
|
||||
<view class="poup pa-36" v-if="detail.data">
|
||||
<view class="info flex">
|
||||
<view class="poup-logo bg-gradient-amber-accent pa-4 shadow-24">
|
||||
<image class="poup-logo_img" :src="$utils.checkImageUrl(detail.data.spec.logo)"
|
||||
mode="aspectFill"></image>
|
||||
</view>
|
||||
<view class="pl-24 info-detail">
|
||||
<view class="poup-name text-size-lg text-weight-b">{{ detail.data.spec.displayName }}
|
||||
</view>
|
||||
<view class="poup-tag ml--10">
|
||||
<tm-tags color="bg-gradient-light-blue-lighten" size="n" model="fill">
|
||||
{{ detail.data.spec.groupName }}
|
||||
</tm-tags>
|
||||
</view>
|
||||
<view class="poup-link text-size-m" @click="fnCopyLink(detail.data)">
|
||||
<text class="text-orange">{{ detail.data.spec.url }}</text>
|
||||
<text class="iconfont icon-copy text-size-s ml-6 text-grey"></text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="poup-desc mt-20">
|
||||
博客简介:{{ detail.data.spec.description || '这个博主很懒,没写简介~' }}
|
||||
</view>
|
||||
<view class="poup-desc mt-20">
|
||||
博客简介:{{ detail.data.spec.description || '这个博主很懒,没写简介~' }}
|
||||
</view>
|
||||
|
||||
<!-- 博客预览图 -->
|
||||
<view class="mt-24">
|
||||
<tm-images :width="568" :round="2" :src="calcSiteThumbnail(detail.data.spec.url)"
|
||||
mode="aspectFill"></tm-images>
|
||||
</view>
|
||||
</view>
|
||||
</tm-poup>
|
||||
<!-- 博客预览图 -->
|
||||
<view class="mt-24">
|
||||
<tm-images :width="568" :round="2" :src="calcSiteThumbnail(detail.data.spec.url)"
|
||||
mode="aspectFill"></tm-images>
|
||||
</view>
|
||||
</view>
|
||||
</tm-poup>
|
||||
|
||||
<view class="load-text">{{ loadMoreText }}</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="load-text">{{ loadMoreText }}</view>
|
||||
</view>
|
||||
</template>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import tmSkeleton from '@/tm-vuetify/components/tm-skeleton/tm-skeleton.vue';
|
||||
import tmTranslate from '@/tm-vuetify/components/tm-translate/tm-translate.vue';
|
||||
import tmFlotbutton from '@/tm-vuetify/components/tm-flotbutton/tm-flotbutton.vue';
|
||||
import tmTags from '@/tm-vuetify/components/tm-tags/tm-tags.vue';
|
||||
import tmEmpty from '@/tm-vuetify/components/tm-empty/tm-empty.vue';
|
||||
import tmImages from '@/tm-vuetify/components/tm-images/tm-images.vue';
|
||||
import tmPoup from '@/tm-vuetify/components/tm-poup/tm-poup.vue';
|
||||
import tmSkeleton from '@/tm-vuetify/components/tm-skeleton/tm-skeleton.vue';
|
||||
import tmTranslate from '@/tm-vuetify/components/tm-translate/tm-translate.vue';
|
||||
import tmFlotbutton from '@/tm-vuetify/components/tm-flotbutton/tm-flotbutton.vue';
|
||||
import tmTags from '@/tm-vuetify/components/tm-tags/tm-tags.vue';
|
||||
import tmEmpty from '@/tm-vuetify/components/tm-empty/tm-empty.vue';
|
||||
import tmImages from '@/tm-vuetify/components/tm-images/tm-images.vue';
|
||||
import tmPoup from '@/tm-vuetify/components/tm-poup/tm-poup.vue';
|
||||
|
||||
export default {
|
||||
components: {
|
||||
tmSkeleton,
|
||||
tmTranslate,
|
||||
tmFlotbutton,
|
||||
tmTags,
|
||||
tmEmpty,
|
||||
tmImages,
|
||||
tmPoup
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
loading: 'loading',
|
||||
queryParams: {
|
||||
size: 10,
|
||||
page: 1
|
||||
},
|
||||
detail: {
|
||||
show: false,
|
||||
data: null
|
||||
},
|
||||
hasNext: false,
|
||||
isLoadMore: false,
|
||||
loadMoreText: '',
|
||||
linkGroupList: [],
|
||||
dataList: [],
|
||||
colors: [
|
||||
'#39B449',
|
||||
'#E44C41',
|
||||
'#8698A2',
|
||||
'#0080FE',
|
||||
'#1CBCB4',
|
||||
'#6638B5'
|
||||
]
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
haloConfigs() {
|
||||
return this.$tm.vx.getters().getConfigs;
|
||||
},
|
||||
haloPluginConfigs() {
|
||||
return this.$tm.vx.getters().getConfigs.pluginConfig;
|
||||
},
|
||||
calcSiteThumbnail(val) {
|
||||
return val => {
|
||||
if (!val) return '';
|
||||
if (val.charAt(val.length - 1) !== '/') {
|
||||
val = val + '/';
|
||||
}
|
||||
return 'https://image.thum.io/get/width/1000/crop/800/' + val;
|
||||
};
|
||||
},
|
||||
calcAuditModeEnabled() {
|
||||
return this.haloConfigs.auditConfig.auditModeEnabled
|
||||
},
|
||||
},
|
||||
onLoad() {
|
||||
this.fnSetPageTitle('友情链接');
|
||||
this.fnGetLinkGroupData();
|
||||
},
|
||||
onPullDownRefresh() {
|
||||
this.isLoadMore = false;
|
||||
this.queryParams.page = 1;
|
||||
this.dataList = []
|
||||
this.fnGetData();
|
||||
},
|
||||
onReachBottom(e) {
|
||||
if (this.hasNext) {
|
||||
this.queryParams.page += 1;
|
||||
this.isLoadMore = true;
|
||||
this.fnGetData();
|
||||
} else {
|
||||
uni.showToast({
|
||||
icon: 'none',
|
||||
title: '没有更多数据了'
|
||||
});
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
fnGetLinkGroupData() {
|
||||
this.$httpApi.v2
|
||||
.getFriendLinkGroupList({
|
||||
page: 1,
|
||||
size: 0
|
||||
})
|
||||
.then(res => {
|
||||
this.linkGroupList = res.items;
|
||||
this.fnGetData()
|
||||
})
|
||||
.catch(err => {
|
||||
console.error(err);
|
||||
});
|
||||
},
|
||||
findLinkGroupDisplayNameByGroupMetadataName(groupName) {
|
||||
if (this.linkGroupList.length === 0) return groupName || "未分组"
|
||||
return this.linkGroupList.find(item => item.metadata.name === groupName)?.spec?.displayName || groupName || "未分组"
|
||||
},
|
||||
fnGetData() {
|
||||
if (this.calcAuditModeEnabled) {
|
||||
return;
|
||||
}
|
||||
if (!this.isLoadMore) {
|
||||
this.loading = 'loading';
|
||||
}
|
||||
this.loadMoreText = '';
|
||||
this.$httpApi.v2
|
||||
.getFriendLinkList(this.queryParams)
|
||||
.then(res => {
|
||||
console.log('请求结果:');
|
||||
console.log(res);
|
||||
this.hasNext = res.hasNext;
|
||||
const list = res.items.map(item => {
|
||||
item.spec.logo = this.$utils.checkAvatarUrl(item.spec?.logo)
|
||||
item.spec.groupName = this.findLinkGroupDisplayNameByGroupMetadataName(item.spec?.groupName)
|
||||
return item;
|
||||
})
|
||||
this.dataList = this.dataList.concat(list);
|
||||
setTimeout(() => {
|
||||
this.loading = 'success';
|
||||
this.loadMoreText = res.hasNext ? '上拉加载更多' : '呜呜,没有更多数据啦~';
|
||||
}, 500);
|
||||
import pluginAvailableMixin from "@/common/mixins/pluginAvailable.js"
|
||||
import PluginUnavailable from '@/components/plugin-unavailable/plugin-unavailable.vue'
|
||||
|
||||
})
|
||||
.catch(err => {
|
||||
console.error(err);
|
||||
this.loading = 'error';
|
||||
this.loadMoreText = '加载失败,请下拉刷新!';
|
||||
})
|
||||
.finally(() => {
|
||||
setTimeout(() => {
|
||||
uni.hideLoading();
|
||||
uni.stopPullDownRefresh();
|
||||
}, 500);
|
||||
});
|
||||
},
|
||||
export default {
|
||||
mixins: [pluginAvailableMixin],
|
||||
components: {
|
||||
tmSkeleton,
|
||||
tmTranslate,
|
||||
tmFlotbutton,
|
||||
tmTags,
|
||||
tmEmpty,
|
||||
tmImages,
|
||||
tmPoup,
|
||||
PluginUnavailable
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
loading: 'loading',
|
||||
queryParams: {
|
||||
size: 10,
|
||||
page: 1
|
||||
},
|
||||
detail: {
|
||||
show: false,
|
||||
data: null
|
||||
},
|
||||
hasNext: false,
|
||||
isLoadMore: false,
|
||||
loadMoreText: '',
|
||||
linkGroupList: [],
|
||||
dataList: [],
|
||||
colors: [
|
||||
'#39B449',
|
||||
'#E44C41',
|
||||
'#8698A2',
|
||||
'#0080FE',
|
||||
'#1CBCB4',
|
||||
'#6638B5'
|
||||
]
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
haloConfigs() {
|
||||
return this.$tm.vx.getters().getConfigs;
|
||||
},
|
||||
haloPluginConfigs() {
|
||||
return this.$tm.vx.getters().getConfigs.pluginConfig;
|
||||
},
|
||||
calcSiteThumbnail(val) {
|
||||
return val => {
|
||||
if (!val) return '';
|
||||
if (val.charAt(val.length - 1) !== '/') {
|
||||
val = val + '/';
|
||||
}
|
||||
return 'https://image.thum.io/get/width/1000/crop/800/' + val;
|
||||
};
|
||||
},
|
||||
calcAuditModeEnabled() {
|
||||
return this.haloConfigs.auditConfig.auditModeEnabled
|
||||
},
|
||||
},
|
||||
async onLoad() {
|
||||
this.fnSetPageTitle('友情链接');
|
||||
// 检查插件
|
||||
this.setPluginId(this.NeedPluginIds.PluginLinks)
|
||||
this.setPluginError("阿偶,检测到当前插件没有安装或者启用,无法使用友情链接功能哦,请联系管理员")
|
||||
if (!await this.checkPluginAvailable()) return
|
||||
this.fnGetLinkGroupData();
|
||||
},
|
||||
onPullDownRefresh() {
|
||||
if (!this.uniHaloPluginAvailable) {
|
||||
uni.hideLoading();
|
||||
uni.stopPullDownRefresh();
|
||||
return
|
||||
}
|
||||
this.isLoadMore = false;
|
||||
this.queryParams.page = 1;
|
||||
this.dataList = []
|
||||
this.fnGetData();
|
||||
},
|
||||
onReachBottom(e) {
|
||||
if (!this.uniHaloPluginAvailable) return;
|
||||
if (this.hasNext) {
|
||||
this.queryParams.page += 1;
|
||||
this.isLoadMore = true;
|
||||
this.fnGetData();
|
||||
} else {
|
||||
uni.showToast({
|
||||
icon: 'none',
|
||||
title: '没有更多数据了'
|
||||
});
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
fnGetLinkGroupData() {
|
||||
this.$httpApi.v2
|
||||
.getFriendLinkGroupList({
|
||||
page: 1,
|
||||
size: 0
|
||||
})
|
||||
.then(res => {
|
||||
this.linkGroupList = res.items;
|
||||
this.fnGetData()
|
||||
})
|
||||
.catch(err => {
|
||||
console.error(err);
|
||||
});
|
||||
},
|
||||
findLinkGroupDisplayNameByGroupMetadataName(groupName) {
|
||||
if (this.linkGroupList.length === 0) return groupName || "未分组"
|
||||
return this.linkGroupList.find(item => item.metadata.name === groupName)?.spec?.displayName || groupName ||
|
||||
"未分组"
|
||||
},
|
||||
fnGetData() {
|
||||
if (this.calcAuditModeEnabled) {
|
||||
return;
|
||||
}
|
||||
if (!this.isLoadMore) {
|
||||
this.loading = 'loading';
|
||||
}
|
||||
this.loadMoreText = '';
|
||||
this.$httpApi.v2
|
||||
.getFriendLinkList(this.queryParams)
|
||||
.then(res => {
|
||||
console.log('请求结果:');
|
||||
console.log(res);
|
||||
this.hasNext = res.hasNext;
|
||||
const list = res.items.map(item => {
|
||||
item.spec.logo = this.$utils.checkAvatarUrl(item.spec?.logo)
|
||||
item.spec.groupName = this.findLinkGroupDisplayNameByGroupMetadataName(item.spec
|
||||
?.groupName)
|
||||
return item;
|
||||
})
|
||||
this.dataList = this.dataList.concat(list);
|
||||
setTimeout(() => {
|
||||
this.loading = 'success';
|
||||
this.loadMoreText = res.hasNext ? '上拉加载更多' : '呜呜,没有更多数据啦~';
|
||||
}, 500);
|
||||
|
||||
handleGroup(list) {
|
||||
const group = {}
|
||||
list.forEach(item => {
|
||||
if (group[item.spec.groupName]) {
|
||||
group[item.spec.groupName].children.push(item)
|
||||
} else {
|
||||
group[item.spec.groupName] = {
|
||||
title: item.spec.groupName,
|
||||
children: [item]
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
.catch(err => {
|
||||
console.error(err);
|
||||
this.loading = 'error';
|
||||
this.loadMoreText = '加载失败,请下拉刷新!';
|
||||
})
|
||||
.finally(() => {
|
||||
setTimeout(() => {
|
||||
uni.hideLoading();
|
||||
uni.stopPullDownRefresh();
|
||||
}, 500);
|
||||
});
|
||||
},
|
||||
|
||||
return Object.keys(group).map(key => {
|
||||
const {
|
||||
title,
|
||||
children = []
|
||||
} = group[key]
|
||||
return {
|
||||
title,
|
||||
children
|
||||
}
|
||||
})
|
||||
},
|
||||
fnOnLinkEvent(link) {
|
||||
this.detail.data = link;
|
||||
this.detail.show = true;
|
||||
},
|
||||
handleGroup(list) {
|
||||
const group = {}
|
||||
list.forEach(item => {
|
||||
if (group[item.spec.groupName]) {
|
||||
group[item.spec.groupName].children.push(item)
|
||||
} else {
|
||||
group[item.spec.groupName] = {
|
||||
title: item.spec.groupName,
|
||||
children: [item]
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
fnCopyLink(link) {
|
||||
uni.setClipboardData({
|
||||
data: `${link.spec.displayName}:${link.spec.url}`,
|
||||
showToast: false,
|
||||
success: () => {
|
||||
uni.showToast({
|
||||
icon: 'none',
|
||||
title: '链接复制成功!'
|
||||
});
|
||||
},
|
||||
fail: () => {
|
||||
uni.showToast({
|
||||
icon: 'none',
|
||||
title: '复制失败!'
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
toSubmitLinkPage() {
|
||||
uni.navigateTo({
|
||||
url: '/pagesA/submit-link/submit-link'
|
||||
})
|
||||
}
|
||||
}
|
||||
};
|
||||
return Object.keys(group).map(key => {
|
||||
const {
|
||||
title,
|
||||
children = []
|
||||
} = group[key]
|
||||
return {
|
||||
title,
|
||||
children
|
||||
}
|
||||
})
|
||||
},
|
||||
fnOnLinkEvent(link) {
|
||||
this.detail.data = link;
|
||||
this.detail.show = true;
|
||||
},
|
||||
|
||||
fnCopyLink(link) {
|
||||
uni.setClipboardData({
|
||||
data: `${link.spec.displayName}:${link.spec.url}`,
|
||||
showToast: false,
|
||||
success: () => {
|
||||
uni.showToast({
|
||||
icon: 'none',
|
||||
title: '链接复制成功!'
|
||||
});
|
||||
},
|
||||
fail: () => {
|
||||
uni.showToast({
|
||||
icon: 'none',
|
||||
title: '复制失败!'
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
toSubmitLinkPage() {
|
||||
uni.navigateTo({
|
||||
url: '/pagesA/submit-link/submit-link'
|
||||
})
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.app-page {
|
||||
width: 100vw;
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
background-color: #fafafd;
|
||||
}
|
||||
.app-page {
|
||||
width: 100vw;
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
background-color: #fafafd;
|
||||
}
|
||||
|
||||
.loading-wrap {
|
||||
padding: 24rpx;
|
||||
min-height: 100vh;
|
||||
}
|
||||
.loading-wrap {
|
||||
padding: 24rpx;
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
.content {
|
||||
padding: 0 24rpx;
|
||||
padding-top: 24rpx;
|
||||
.content {
|
||||
padding: 0 24rpx;
|
||||
padding-top: 24rpx;
|
||||
|
||||
.content-empty {
|
||||
height: 60vh;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
}
|
||||
.content-empty {
|
||||
height: 60vh;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
}
|
||||
|
||||
.link-card {
|
||||
border-bottom: 2rpx solid #f5f5f5;
|
||||
background-color: #ffffff;
|
||||
.link-card {
|
||||
border-bottom: 2rpx solid #f5f5f5;
|
||||
background-color: #ffffff;
|
||||
|
||||
&.one {
|
||||
border: 0;
|
||||
box-shadow: 0rpx 2rpx 24rpx 0rpx rgba(0, 0, 0, 0.03);
|
||||
&.one {
|
||||
border: 0;
|
||||
box-shadow: 0rpx 2rpx 24rpx 0rpx rgba(0, 0, 0, 0.03);
|
||||
|
||||
.logo {
|
||||
box-shadow: 0rpx 2rpx 12rpx rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
}
|
||||
.logo {
|
||||
box-shadow: 0rpx 2rpx 12rpx rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
}
|
||||
|
||||
.logo {
|
||||
// width: 126rpx;
|
||||
// height: 126rpx;
|
||||
width: 80rpx;
|
||||
height: 80rpx;
|
||||
border-radius: 12rpx;
|
||||
border: 6rpx solid #ffffff;
|
||||
box-shadow: none;
|
||||
}
|
||||
.logo {
|
||||
// width: 126rpx;
|
||||
// height: 126rpx;
|
||||
width: 80rpx;
|
||||
height: 80rpx;
|
||||
border-radius: 12rpx;
|
||||
border: 6rpx solid #ffffff;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
.info {
|
||||
width: 0;
|
||||
flex-grow: 1;
|
||||
.info {
|
||||
width: 0;
|
||||
flex-grow: 1;
|
||||
|
||||
.name {
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
color: #303133;
|
||||
font-size: 30rpx;
|
||||
font-weight: bold;
|
||||
}
|
||||
.name {
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
color: #303133;
|
||||
font-size: 30rpx;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.desc {
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
color: #303133;
|
||||
font-size: 28rpx;
|
||||
}
|
||||
}
|
||||
}
|
||||
.desc {
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
color: #303133;
|
||||
font-size: 28rpx;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.link-card_name {
|
||||
// color: #303133;
|
||||
// color: #0080fe;
|
||||
}
|
||||
.link-card_name {
|
||||
// color: #303133;
|
||||
// color: #0080fe;
|
||||
}
|
||||
|
||||
.link-card_desc {
|
||||
font-size: 24rpx;
|
||||
line-height: 1.6;
|
||||
color: #303133;
|
||||
}
|
||||
.link-card_desc {
|
||||
font-size: 24rpx;
|
||||
line-height: 1.6;
|
||||
color: #303133;
|
||||
}
|
||||
|
||||
.link-logo {
|
||||
width: 140rpx;
|
||||
height: 140rpx;
|
||||
.link-logo {
|
||||
width: 140rpx;
|
||||
height: 140rpx;
|
||||
|
||||
&_img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
}
|
||||
&_img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
.poup-logo {
|
||||
width: 140rpx;
|
||||
height: 140rpx;
|
||||
border-radius: 50%;
|
||||
.poup-logo {
|
||||
width: 140rpx;
|
||||
height: 140rpx;
|
||||
border-radius: 50%;
|
||||
|
||||
&_img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
border-radius: 50%;
|
||||
}
|
||||
}
|
||||
&_img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
border-radius: 50%;
|
||||
}
|
||||
}
|
||||
|
||||
.info-detail {
|
||||
width: 0;
|
||||
flex-grow: 1;
|
||||
justify-content: center;
|
||||
}
|
||||
.info-detail {
|
||||
width: 0;
|
||||
flex-grow: 1;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.poup-desc {
|
||||
font-size: 28rpx;
|
||||
line-height: 1.6;
|
||||
color: #555 !important;
|
||||
}
|
||||
.poup-desc {
|
||||
font-size: 28rpx;
|
||||
line-height: 1.6;
|
||||
color: #555 !important;
|
||||
}
|
||||
|
||||
.preview-site {
|
||||
width: 100%;
|
||||
height: 300rpx;
|
||||
}
|
||||
</style>
|
||||
.preview-site {
|
||||
width: 100%;
|
||||
height: 300rpx;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,357 @@
|
||||
<template>
|
||||
<view class="app-page">
|
||||
<view v-if="loading !== 'success'" class="loading-wrap">
|
||||
<tm-skeleton model="card"></tm-skeleton>
|
||||
<tm-skeleton model="card"></tm-skeleton>
|
||||
<tm-skeleton model="card"></tm-skeleton>
|
||||
</view>
|
||||
<block v-else>
|
||||
<view class="moment-card">
|
||||
<view class="card flex flex-start">
|
||||
<view class="avatar" style="flex-shrink: 0;">
|
||||
<image style="width: 80rpx;height: 80rpx;border-radius: 50%;" :src="moment.spec.user.avatar" />
|
||||
</view>
|
||||
<view class="nickname" style="margin-left: 12rpx;">
|
||||
<view style="font-size: 30rpx;font-weight: bold;color: #333333;">
|
||||
{{ moment.spec.user.displayName }}
|
||||
</view>
|
||||
<view style="margin-top: 6rpx;font-size: 24rpx;color: #666;">
|
||||
{{ {d: moment.spec.releaseTime, f: 'yyyy年MM月dd日 星期w'} | formatTime }}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view v-if="moment.spec.tags && moment.spec.tags.length!==0" class="card flex flex-wrap flex-start"
|
||||
style="padding-top:12rpx;padding-bottom:12rpx;">
|
||||
<text class="text-size-m">标签列表:</text>
|
||||
<tm-tags v-for="(tag,tagIndex) in moment.spec.tags" :key="tagIndex" :color="randomTagColor()"
|
||||
size="m" model="text">
|
||||
{{ tag }}
|
||||
</tm-tags>
|
||||
</view>
|
||||
|
||||
<view class="card" style="padding:0">
|
||||
<mp-html class="evan-markdown" lazy-load :domain="markdownConfig.domain"
|
||||
:loading-img="markdownConfig.loadingGif" :scroll-table="true" :selectable="true"
|
||||
:tag-style="markdownConfig.tagStyle" :container-style="markdownConfig.containStyle"
|
||||
:content="moment.spec.newHtml" :markdown="true" :showLineNumber="true" :showLanguageName="true"
|
||||
:copyByLongPress="true" />
|
||||
</view>
|
||||
<view v-if="moment.images && moment.images.length!==0" class="card">
|
||||
<view class="card-head text-size-m">
|
||||
图片附件:
|
||||
</view>
|
||||
<view class="images" :class="['images-'+moment.images.length]">
|
||||
<view class="image-item" v-for="(image,mediumIndex) in moment.images" :key="mediumIndex">
|
||||
<image mode="aspectFill" style="width: 100%;height: 100%;border-radius: 6rpx;"
|
||||
:src="image.url" @click="handlePreview(mediumIndex,moment.images)" />
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view v-if="moment.audios && moment.audios.length!==0" class="card">
|
||||
<view class="card-head text-size-m">
|
||||
音频附件:
|
||||
</view>
|
||||
<view
|
||||
style="display: flex; flex-direction: column; gap: 12rpx 0;padding: 0 24rpx;padding-right:28rpx;">
|
||||
<audio v-for="(audio,index) in moment.audios" :controls="true" :key="index" :id="audio.url"
|
||||
:poster="bloggerInfo.avatar"
|
||||
:name="'来自' + (startConfig.title||bloggerInfo.nickname) + '的声音'"
|
||||
:author="bloggerInfo.nickname" :src="audio.url"></audio>
|
||||
</view>
|
||||
</view>
|
||||
<view v-if="moment.videos && moment.videos.length!==0" class="card">
|
||||
<view class="card-head text-size-m">
|
||||
视频附件:
|
||||
</view>
|
||||
<view style="margin-top:24rpx;width:100%;display: flex; flex-direction: column; gap: 12rpx 0;">
|
||||
<video style="width:100%;height: 400rpx;border-radius: 12rpx;"
|
||||
v-for="(video,index) in moment.videos" :key="index" :src="video.url"
|
||||
:id="'video_' + video.id" :show-mute-btn="true" :controls="true"
|
||||
:show-center-play-btn="true" :enable-progress-gesture="true" @play="onVideoPlay(video.id)"
|
||||
@pause="onVideoPause(video.id)" @ended="onVideoEnded(video.id)"></video>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
|
||||
<!-- 返回顶部 -->
|
||||
<tm-flotbutton :width="90" :offset="[16, 80]" icon="icon-angle-up" color="bg-gradient-light-blue-accent"
|
||||
@click="fnToTopPage()"></tm-flotbutton>
|
||||
</block>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import MarkdownConfig from '@/common/markdown/markdown.config.js';
|
||||
|
||||
import tmSkeleton from '@/tm-vuetify/components/tm-skeleton/tm-skeleton.vue';
|
||||
import tmFlotbutton from '@/tm-vuetify/components/tm-flotbutton/tm-flotbutton.vue';
|
||||
import tmButton from '@/tm-vuetify/components/tm-button/tm-button.vue';
|
||||
import tmEmpty from '@/tm-vuetify/components/tm-empty/tm-empty.vue';
|
||||
import tmTags from '@/tm-vuetify/components/tm-tags/tm-tags.vue';
|
||||
|
||||
import mpHtml from '@/components/mp-html/components/mp-html/mp-html.vue';
|
||||
import {
|
||||
getAppConfigs
|
||||
} from '@/config/index.js'
|
||||
import HaloTokenConfig from "@/config/uhalo.config";
|
||||
import {
|
||||
getRandomNumberByRange
|
||||
} from "@/utils/random.js";
|
||||
import {
|
||||
generateUUID
|
||||
} from '@/utils/uuid.js';
|
||||
|
||||
export default {
|
||||
components: {
|
||||
tmSkeleton,
|
||||
tmFlotbutton,
|
||||
tmButton,
|
||||
tmEmpty,
|
||||
mpHtml,
|
||||
tmTags
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
loading: 'loading',
|
||||
markdownConfig: MarkdownConfig,
|
||||
queryParams: {
|
||||
name: null
|
||||
},
|
||||
moment: null,
|
||||
tagColors: ['orange', 'green', 'red', 'blue'],
|
||||
videoContexts: {},
|
||||
currentVideoId: null
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
haloConfigs() {
|
||||
return this.$tm.vx.getters().getConfigs;
|
||||
},
|
||||
calcUrl() {
|
||||
return url => {
|
||||
if (this.$utils.checkIsUrl(url)) {
|
||||
return url;
|
||||
}
|
||||
return getApp().globalData.baseApiUrl + url;
|
||||
};
|
||||
},
|
||||
// 获取博主信息
|
||||
bloggerInfo() {
|
||||
const blogger = this.haloConfigs.authorConfig.blogger;
|
||||
blogger.avatar = this.$utils.checkAvatarUrl(blogger.avatar, true);
|
||||
return blogger;
|
||||
},
|
||||
calcUseTagRandomColor() {
|
||||
return this.haloConfigs.pageConfig.momentConfig.useTagRandomColor;
|
||||
},
|
||||
},
|
||||
onLoad(e) {
|
||||
this.fnSetPageTitle('瞬间加载中...');
|
||||
this.queryParams.name = e.name;
|
||||
this.fnGetData();
|
||||
},
|
||||
onPullDownRefresh() {
|
||||
this.videoContexts = {};
|
||||
this.currentVideoId = null;
|
||||
this.fnGetData();
|
||||
},
|
||||
onShareAppMessage() {
|
||||
return {
|
||||
path: '/pagesA/moment-detail/moment-detail?name=' + this.moment.metadata.name,
|
||||
title: this.moment.spec.title,
|
||||
}
|
||||
},
|
||||
onShareTimeline() {
|
||||
return {
|
||||
title: this.moment.spec.title,
|
||||
query: {
|
||||
name: this.moment.metadata.name
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
fnGetData() {
|
||||
this.loading = 'loading';
|
||||
this.$httpApi.v2
|
||||
.getMomentByName(this.queryParams.name)
|
||||
.then(res => {
|
||||
console.log('获取详情', res);
|
||||
let _tempResult = res;
|
||||
this.fnSetPageTitle('瞬间详情');
|
||||
|
||||
_tempResult.spec.user = {
|
||||
displayName: this.bloggerInfo.nickname,
|
||||
avatar: this.$utils.checkAvatarUrl(this.bloggerInfo.avatar)
|
||||
}
|
||||
_tempResult.spec.content.medium.map(medium => {
|
||||
medium.url = this.$utils.checkThumbnailUrl(medium.url, true)
|
||||
})
|
||||
|
||||
_tempResult.spec.newHtml = this.removeTagLinksCompletely(_tempResult.spec.content.html, '')
|
||||
_tempResult['images'] = _tempResult.spec.content.medium
|
||||
.filter(x => x.type === 'PHOTO')
|
||||
|
||||
_tempResult['videos'] = _tempResult.spec.content.medium
|
||||
.filter(x => x.type === 'VIDEO').map(_tempResult => {
|
||||
_tempResult.id = generateUUID()
|
||||
return _tempResult;
|
||||
})
|
||||
|
||||
_tempResult['audios'] = _tempResult.spec.content.medium
|
||||
.filter(x => x.type === 'AUDIO')
|
||||
|
||||
this.moment = _tempResult;
|
||||
this.loading = 'success';
|
||||
|
||||
this.$nextTick(() => {
|
||||
this.createVideoContexts(_tempResult.videos);
|
||||
})
|
||||
})
|
||||
.catch(err => {
|
||||
console.log("错误", err)
|
||||
this.loading = 'error';
|
||||
})
|
||||
.finally(() => {
|
||||
uni.hideLoading();
|
||||
uni.stopPullDownRefresh();
|
||||
});
|
||||
},
|
||||
handlePreview(index, list) {
|
||||
uni.previewImage({
|
||||
current: index,
|
||||
urls: list.map(item => item.url)
|
||||
})
|
||||
},
|
||||
removeTagLinksCompletely(htmlString) {
|
||||
const regex = /<a\s+(?:[^>]*?\s+)?class=(['"])[^'"]*?\btag\b[^'"]*?\1[^>]*?>.*?<\/a>/gi;
|
||||
const newHtml = htmlString.replace(regex, '');
|
||||
return newHtml
|
||||
},
|
||||
randomTagColor() {
|
||||
if (!this.calcUseTagRandomColor) return "blue";
|
||||
const randomIndex = getRandomNumberByRange(0, this.tagColors.length);
|
||||
return this.tagColors[randomIndex];
|
||||
},
|
||||
createVideoContexts(videos) {
|
||||
this.stopAllVideos()
|
||||
videos.forEach(item => {
|
||||
this.videoContexts[item.id] = uni.createVideoContext(`video_${item.id}`, this);
|
||||
})
|
||||
},
|
||||
onVideoPlay(videoId) {
|
||||
this.currentVideoId = videoId;
|
||||
this.stopAllVideos(videoId)
|
||||
},
|
||||
onVideoPause(videoId) {
|
||||
if (this.currentVideoId == videoId) {
|
||||
this.currentVideoId = null;
|
||||
}
|
||||
},
|
||||
onVideoEnded(videoId) {
|
||||
this.currentVideoId = null;
|
||||
},
|
||||
stopAllVideos(excludesVideoId = null) {
|
||||
Object.keys(this.videoContexts).forEach(videoId => {
|
||||
if (!excludesVideoId || excludesVideoId != videoId) {
|
||||
const videoContext = this.videoContexts[videoId]
|
||||
videoContext?.pause();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.app-page {
|
||||
width: 100vw;
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
box-sizing: border-box;
|
||||
background-color: #fafafd;
|
||||
padding-bottom: 24rpx;
|
||||
}
|
||||
|
||||
.loading-wrap {
|
||||
padding: 0 24rpx;
|
||||
height: inherit;
|
||||
background-color: #fff;
|
||||
}
|
||||
|
||||
.moment-card {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
box-sizing: border-box;
|
||||
gap: 24rpx;
|
||||
padding: 24rpx;
|
||||
}
|
||||
|
||||
.card {
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
border-radius: 12rpx;
|
||||
background-color: #ffff;
|
||||
box-shadow: 0rpx 2rpx 24rpx rgba(0, 0, 0, 0.03);
|
||||
overflow: hidden;
|
||||
padding: 24rpx;
|
||||
|
||||
&-head {
|
||||
position: relative;
|
||||
// padding-left: 24rpx;
|
||||
margin-bottom: 6rpx;
|
||||
|
||||
&:before {
|
||||
display: none;
|
||||
box-sizing: border-box;
|
||||
content: "";
|
||||
width: 6rpx;
|
||||
height: 24rpx;
|
||||
border-radius: 24rpx;
|
||||
background: #2196F3;
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 6rpx;
|
||||
overflow: hidden;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
.images {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: flex-start;
|
||||
padding: 24rpx;
|
||||
|
||||
.image-item {
|
||||
box-sizing: border-box;
|
||||
border-radius: 24rpx;
|
||||
padding: 6rpx;
|
||||
width: 33%;
|
||||
height: 200rpx
|
||||
}
|
||||
|
||||
&-1 {
|
||||
>.image-item {
|
||||
width: 100%;
|
||||
height: 350rpx
|
||||
}
|
||||
}
|
||||
|
||||
&-2 {
|
||||
>.image-item {
|
||||
width: 50%;
|
||||
height: 250rpx
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
::v-deep .uni-audio-default {
|
||||
width: 100%;
|
||||
border-radius: 12rpx;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,729 @@
|
||||
<template>
|
||||
<view class="app-page">
|
||||
<view v-if="loading != 'success'" class="loading-wrap">
|
||||
<tm-skeleton model="listAvatr"></tm-skeleton>
|
||||
<tm-skeleton model="listAvatr"></tm-skeleton>
|
||||
<tm-skeleton model="listAvatr"></tm-skeleton>
|
||||
<tm-skeleton model="listAvatr"></tm-skeleton>
|
||||
</view>
|
||||
<block v-else>
|
||||
<view v-if="!detail" class="empty">
|
||||
<tm-empty icon="icon-shiliangzhinengduixiang-" label="未查询到数据"></tm-empty>
|
||||
</view>
|
||||
<block v-else>
|
||||
<view class="vote-card vote-info-card">
|
||||
<view class="sub-title"> 投票信息 </view>
|
||||
<view class="vote-card-body flex flex-col uh-mt-8">
|
||||
<view class="">
|
||||
投票类型:<tm-tags color="light-blue" :shadow="0" size="xs" model="fill">
|
||||
{{ vote.spec._uh_type }} </tm-tags>
|
||||
</view>
|
||||
<view class="">
|
||||
投票状态:<tm-tags :color="vote.spec._uh_state.color" size="xs" :shadow="0"
|
||||
model="fill">{{vote.spec._uh_state.state}}</tm-tags>
|
||||
</view>
|
||||
<view class="">
|
||||
投票方式:<tm-tags v-if="vote.spec.canAnonymously" color="light-blue" size="xs" :shadow="0"
|
||||
model="fill">匿名</tm-tags>
|
||||
<tm-tags v-else color="red" size="xs" :shadow="0" model="fill">不匿名</tm-tags>
|
||||
</view>
|
||||
<view class="">
|
||||
开始时间:{{ {d: vote.spec.startDate, f: 'yyyy-MM-dd HH:mm'} | formatTime }}
|
||||
</view>
|
||||
<view class="">
|
||||
<text v-if="vote.spec.timeLimit==='permanent'">
|
||||
结束时间:永久有效
|
||||
</text>
|
||||
<text v-else>
|
||||
结束时间:{{ {d: vote.spec.endDate, f: 'yyyy-MM-dd HH:mm'} | formatTime }}
|
||||
</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="vote-card">
|
||||
<view class="vote-card-head flex flex-col items-start mb-12">
|
||||
<view class="sub-title"> 投票内容 </view>
|
||||
<view class="sub-content">
|
||||
{{ vote.spec.title }}
|
||||
</view>
|
||||
<view v-if="vote.spec.remark" class="sub-remark">
|
||||
{{ vote.spec.remark }}
|
||||
</view>
|
||||
</view>
|
||||
<view class="vote-card-body uh-mt-8">
|
||||
<view class="sub-title"> 投票选项 <text v-if="vote.spec.type==='multiple'"
|
||||
class="sub-title-count">(最多选择 {{ vote.spec.maxVotes }} 项)</text> </view>
|
||||
<view v-if="vote.spec.type==='single'" class="single">
|
||||
<view class="w-full flex flex-col uh-gap-8">
|
||||
<template v-if="vote.spec.isVoted || vote.spec.hasEnded">
|
||||
<view v-for="(option,optionIndex) in vote.spec.options" :key="optionIndex"
|
||||
class="is-voted-item" :class="[option.checked?'selected':'']" :style="{
|
||||
'--percent':option._uh_percent + '%'
|
||||
}">
|
||||
<view class="is-voted-item-content flex w-full flex-between uh-gap-8">
|
||||
<view class="flex-1 text-align-left text-break">
|
||||
{{option.title }}
|
||||
</view>
|
||||
<view class="flex-shrink">
|
||||
{{option._uh_percent }}%
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
<template v-else>
|
||||
<view v-for="(option,optionIndex) in vote.spec.options" :key="optionIndex"
|
||||
class="vote-select-option flex-1 w-full text-break"
|
||||
:class="[option.checked?'light-blue':'grey-lighten-3']"
|
||||
@click="handleSelectSingleOption(option)">
|
||||
{{option.title }}
|
||||
</view>
|
||||
</template>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view v-else-if="vote.spec.type==='multiple'" class="multiple">
|
||||
<view class="w-full flex flex-col uh-gap-8">
|
||||
<template v-if="vote.spec.isVoted || vote.spec.hasEnded">
|
||||
<view v-for="(option,optionIndex) in vote.spec.options" :key="optionIndex"
|
||||
class="is-voted-item" :class="[option.checked?'selected':'']" :style="{
|
||||
'--percent':option._uh_percent + '%'
|
||||
}">
|
||||
<view class="is-voted-item-content flex w-full flex-between uh-gap-8">
|
||||
<view class="flex-1 text-align-left text-break">
|
||||
{{option.title }}
|
||||
</view>
|
||||
<view class="flex-shrink">
|
||||
{{option._uh_percent }}%
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
<template v-else>
|
||||
<view v-for="(option,optionIndex) in vote.spec.options" :key="optionIndex"
|
||||
class="vote-select-option flex-1 w-full text-break"
|
||||
:class="[option.checked?'light-blue':'grey-lighten-3']"
|
||||
@click="handleSelectCheckboxOption(option)">
|
||||
{{option.title }}
|
||||
</view>
|
||||
</template>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view v-else-if="vote.spec.type==='pk'" class="pk">
|
||||
<view class="pk-container">
|
||||
<view class="radio-item" v-for="(option,optionIndex) in vote.spec.options"
|
||||
:key="optionIndex" :class="[optionIndex==0?'radio-left':'radio-right']"
|
||||
:style="{width: option._uh_percent + '%'}">
|
||||
<view class="option-item"
|
||||
:class="[optionIndex==0?'option-item-left':'option-item-right']">
|
||||
{{option._uh_percent }}%
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="option-foot w-full flex flex-col uh-gap-8">
|
||||
<template v-if="vote.spec.isVoted || vote.spec.hasEnded">
|
||||
<view v-for="(option,optionIndex) in vote.spec.options" :key="optionIndex"
|
||||
class="is-voted-item" :class="[option.checked?'selected':'']" :style="{
|
||||
'--percent': option._uh_percent + '%'
|
||||
}">
|
||||
<view class="is-voted-item-content flex w-full flex-between uh-gap-8">
|
||||
<view class="flex-1 text-align-left text-break">
|
||||
选项{{ optionIndex+1}}:{{option.title }}
|
||||
</view>
|
||||
<view class="flex-shrink">
|
||||
{{option._uh_percent }}%
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
<template v-else>
|
||||
<view v-for="(option,optionIndex) in vote.spec.options" :key="optionIndex"
|
||||
class="vote-select-option flex-1 w-full text-break"
|
||||
:class="[option.checked?'light-blue':'grey-lighten-3']"
|
||||
@click="handleSelectSingleOption(option)">
|
||||
选项{{ optionIndex+1}}:{{option.title }}
|
||||
</view>
|
||||
</template>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="vote-card">
|
||||
<view class="vote-card-body">
|
||||
<view class="sub-title"> 投票统计 </view>
|
||||
<view class="">
|
||||
<tm-tags color="grey-darken-4" size="s" model="text">{{ vote.stats.voteCount }}
|
||||
人已参与</tm-tags>
|
||||
<!-- <tm-tags v-if="vote.spec.isVoted" color="blue" rounded size="s" model="text">已投票</tm-tags> -->
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 暂时不做,目前没有意义 -->
|
||||
<!-- <view v-if="vote.spec.canSeeVoters" class="vote-card">
|
||||
<view class="vote-card-body">
|
||||
<view class="sub-title"> 投票用户 </view>
|
||||
<view class="">
|
||||
|
||||
</view>
|
||||
</view>
|
||||
</view> -->
|
||||
|
||||
<view class="vote-submit flex w-full flex-center" :style="{
|
||||
paddingBottom:safeAreaBottom + 'rpx'
|
||||
}">
|
||||
<tm-button v-if="fnCalcIsVoted()" theme="white" text :block="true" class="w-full">您已参与投票</tm-button>
|
||||
<tm-button v-else-if="vote.spec._uh_state.state==='未开始'" theme="orange" text class="w-full"
|
||||
:block="true" @click="handleSubmitTip('投票未开始')">投票未开始</tm-button>
|
||||
<tm-button v-else-if="vote.spec._uh_state.state==='已结束'" theme="red" text class="w-full"
|
||||
:block="true" @click="handleSubmitTip('投票已结束')">投票已结束</tm-button>
|
||||
<tm-button v-else-if="!vote.spec.canAnonymously" theme="red" :shadow="0" class="w-full" text
|
||||
:block="true" @click="handleSubmit()">不支持匿名投票</tm-button>
|
||||
<tm-button v-else-if="submitForm.voteData.length===0" theme="white" text class="w-full"
|
||||
:block="true" @click="handleSubmitTip('请选择选项')">提交投票(请选择选项)</tm-button>
|
||||
<tm-button v-else theme="light-blue" class="w-full" :block="true" :loading="submitLoading"
|
||||
:disabled="submitLoading" @click="handleSubmit()">提交投票</tm-button>
|
||||
</view>
|
||||
</block>
|
||||
</block>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import tmSkeleton from '@/tm-vuetify/components/tm-skeleton/tm-skeleton.vue';
|
||||
import tmEmpty from '@/tm-vuetify/components/tm-empty/tm-empty.vue';
|
||||
import tmButton from '@/tm-vuetify/components/tm-button/tm-button.vue';
|
||||
import tmTags from '@/tm-vuetify/components/tm-tags/tm-tags.vue';
|
||||
|
||||
import {
|
||||
VOTE_TYPES,
|
||||
calcVoteState,
|
||||
calcVotePercent,
|
||||
voteCacheUtil
|
||||
} from '@/utils/vote.js'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
tmSkeleton,
|
||||
tmEmpty,
|
||||
tmButton,
|
||||
tmTags,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
safeAreaBottom: 24,
|
||||
loading: 'loading',
|
||||
submitLoading: false,
|
||||
pageTitle: '加载中...',
|
||||
|
||||
name: '',
|
||||
detail: null,
|
||||
vote: null,
|
||||
submitForm: {
|
||||
voteData: []
|
||||
}
|
||||
};
|
||||
},
|
||||
|
||||
onLoad(e) {
|
||||
this.name = e.name;
|
||||
this.fnGetData();
|
||||
// this.fnGetVoteUserList();
|
||||
// #ifndef H5
|
||||
const systemInfo = uni.getSystemInfoSync();
|
||||
this.safeAreaBottom = systemInfo.safeAreaInsets.bottom + 12;
|
||||
// #endif
|
||||
},
|
||||
onPullDownRefresh() {
|
||||
this.fnGetData();
|
||||
// this.fnGetVoteUserList();
|
||||
},
|
||||
onShareAppMessage() {
|
||||
return {
|
||||
path: '/pagesA/vote-detail/vote-detail?name=' + this.name,
|
||||
title: this.vote?.spec?.title ?? "来投个票吧",
|
||||
imageUrl: ""
|
||||
}
|
||||
},
|
||||
onShareTimeline() {
|
||||
return {
|
||||
title: this.vote?.spec?.title ?? "来投个票吧",
|
||||
query: {
|
||||
name: this.name
|
||||
},
|
||||
imageUrl: ""
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
fnGetData() {
|
||||
// 设置状态为加载中
|
||||
this.loading = 'loading';
|
||||
this.pageTitle = "加载中..."
|
||||
this.$httpApi.v2
|
||||
.getVoteDetail(this.name)
|
||||
.then(res => {
|
||||
this.pageTitle = "投票详情" + `(${VOTE_TYPES[res.vote.spec.type]})`
|
||||
|
||||
const tempVoteRes = res;
|
||||
|
||||
tempVoteRes.vote.spec.isVoted = this.fnCalcIsVoted()
|
||||
tempVoteRes.vote.spec.disabled = this.fnCalcIsVoted()
|
||||
tempVoteRes.vote.spec._uh_state = calcVoteState(tempVoteRes.vote)
|
||||
tempVoteRes.vote.spec._uh_type = VOTE_TYPES[tempVoteRes.vote.spec.type]
|
||||
|
||||
tempVoteRes.vote.spec.options.map((option, index) => {
|
||||
option.value = option.id
|
||||
option.label = option.title
|
||||
option.isVoted = this.fnCalcIsVoted()
|
||||
option.checked = this.fnCalcIsChecked(option)
|
||||
option._uh_percent = calcVotePercent(tempVoteRes.vote, option);
|
||||
|
||||
option.dataStr = JSON.stringify(option)
|
||||
|
||||
return option
|
||||
})
|
||||
|
||||
this.vote = tempVoteRes.vote
|
||||
this.detail = tempVoteRes;
|
||||
|
||||
setTimeout(() => {
|
||||
this.loading = 'success';
|
||||
}, 200);
|
||||
})
|
||||
.catch(err => {
|
||||
console.error(err);
|
||||
this.loading = 'error';
|
||||
this.pageTitle = "加载失败,请重试..."
|
||||
})
|
||||
.finally(() => {
|
||||
setTimeout(() => {
|
||||
uni.hideLoading();
|
||||
uni.stopPullDownRefresh();
|
||||
this.fnSetPageTitle(this.pageTitle);
|
||||
}, 200);
|
||||
});
|
||||
},
|
||||
fnGetVoteUserList() {
|
||||
this.$httpApi.v2
|
||||
.getVoteUserList(this.name)
|
||||
.then(res => {
|
||||
console.log("查询投票用户列表")
|
||||
})
|
||||
.catch(err => {
|
||||
console.log("err")
|
||||
})
|
||||
},
|
||||
fnCalcIsVoted() {
|
||||
return voteCacheUtil.has(this.name)
|
||||
},
|
||||
|
||||
fnCalcIsChecked(option) {
|
||||
const data = voteCacheUtil.get(this.name)
|
||||
if (!data) return false;
|
||||
const checked = data.selected.includes(option.id)
|
||||
return checked
|
||||
},
|
||||
onOptionRadioChange(e) {
|
||||
this.submitForm.voteData = e.map(item => this.vote.spec.options[item.index]?.id);
|
||||
},
|
||||
onOptionCheckboxChange(e) {
|
||||
this.submitForm.voteData = e.map(item => this.vote.spec.options[item.index]?.id);
|
||||
},
|
||||
onOptionPkChange(e) {
|
||||
this.submitForm.voteData = e.map(item => this.vote.spec.options[item.index]?.id);
|
||||
},
|
||||
formatJsonStr(jsonStr) {
|
||||
return jsonStr ? JSON.parse(jsonStr) : {}
|
||||
},
|
||||
handleSubmitTip(text) {
|
||||
this.showToast(text)
|
||||
},
|
||||
handleSubmit() {
|
||||
if (!this.vote.spec.canAnonymously) {
|
||||
uni.showModal({
|
||||
icon: "none",
|
||||
title: "提示",
|
||||
content: "该投票不支持匿名,请到博主的 网站端 进行投票!",
|
||||
cancelColor: "#666666",
|
||||
cancelText: "关闭",
|
||||
confirmText: "复制地址",
|
||||
success: (res) => {
|
||||
if (res.confirm) {
|
||||
this.$utils.copyText(this.$baseApiUrl, "复制成功")
|
||||
}
|
||||
}
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
this.submitLoading = true
|
||||
uni.showLoading({
|
||||
title: "正在保存..."
|
||||
})
|
||||
|
||||
this.$httpApi.v2
|
||||
.submitVote(this.name, this.submitForm, this.vote.spec.canAnonymously)
|
||||
.then(res => {
|
||||
|
||||
this.showToast("提交成功")
|
||||
voteCacheUtil.set(this.name, {
|
||||
selected: [...this.submitForm.voteData],
|
||||
data: this.vote
|
||||
})
|
||||
|
||||
setTimeout(() => {
|
||||
uni.startPullDownRefresh()
|
||||
this.submitLoading = false
|
||||
}, 1500);
|
||||
})
|
||||
.catch(err => {
|
||||
console.error(err);
|
||||
this.showToast("提交失败,请重试")
|
||||
this.submitLoading = false
|
||||
})
|
||||
},
|
||||
|
||||
handleSelectSingleOption(option) {
|
||||
if (this.vote.spec._uh_state.state == '未开始') {
|
||||
this.showToast(`投票未开始`)
|
||||
return
|
||||
}
|
||||
if (this.vote.spec.hasEnded) return
|
||||
if (this.vote.spec.disabled) return
|
||||
this.vote.spec.options.map(item => {
|
||||
if (option.id == item.id) {
|
||||
item.checked = true
|
||||
} else {
|
||||
item.checked = false
|
||||
}
|
||||
})
|
||||
|
||||
this.submitForm.voteData = this.vote.spec.options.filter(x => x.checked).map(item => item.id)
|
||||
},
|
||||
|
||||
handleSelectCheckboxOption(option) {
|
||||
if (this.vote.spec._uh_state.state == '未开始') {
|
||||
this.showToast(`投票未开始`)
|
||||
return
|
||||
}
|
||||
if (this.vote.spec.hasEnded) return
|
||||
if (this.vote.spec.disabled) return
|
||||
|
||||
const checkedList = this.vote.spec.options.filter(x => x.checked && x.id != option.id)
|
||||
|
||||
if (this.vote.spec.type === 'multiple' && checkedList.length >= this.vote.spec.maxVotes) {
|
||||
this.showToast(`最多选择 ${this.vote.spec.maxVotes} 项`)
|
||||
return
|
||||
}
|
||||
|
||||
this.vote.spec.options.map(item => {
|
||||
if (option.id == item.id) {
|
||||
item.checked = !item.checked
|
||||
}
|
||||
})
|
||||
|
||||
this.submitForm.voteData = this.vote.spec.options.filter(x => x.checked).map(item => item.id)
|
||||
},
|
||||
showToast(content) {
|
||||
uni.showToast({
|
||||
icon: "none",
|
||||
title: content,
|
||||
mask: true
|
||||
})
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.app-page {
|
||||
box-sizing: border-box;
|
||||
width: 100vw;
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding: 24rpx 0;
|
||||
padding-bottom: 160rpx;
|
||||
background-color: #fafafd;
|
||||
}
|
||||
|
||||
.loading-wrap {
|
||||
padding: 0 24rpx;
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
.empty {
|
||||
height: 60vh;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.w-full {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.wp-50 {
|
||||
width: 50%;
|
||||
}
|
||||
|
||||
.vote-card {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
box-sizing: border-box;
|
||||
margin: 0 24rpx;
|
||||
padding: 24rpx;
|
||||
border-radius: 12rpx;
|
||||
background-color: #ffff;
|
||||
box-shadow: 0rpx 2rpx 24rpx rgba(0, 0, 0, 0.03);
|
||||
overflow: hidden;
|
||||
margin-bottom: 24rpx;
|
||||
}
|
||||
|
||||
.vote-info-card {
|
||||
.vote-card-body {
|
||||
font-size: 28rpx;
|
||||
gap: 12rpx 0;
|
||||
background: #F3F4F6;
|
||||
color: #3F3F3F;
|
||||
padding: 24rpx;
|
||||
border-radius: 12rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.vote-card-head {
|
||||
margin-bottom: 12rpx;
|
||||
display: flex;
|
||||
align-items: flex-satrt;
|
||||
justify-content: space-between;
|
||||
|
||||
.left {
|
||||
.title {
|
||||
font-size: 28rpx;
|
||||
font-weight: bold;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.vote-card-body {
|
||||
|
||||
.remark {
|
||||
box-sizing: border-box;
|
||||
padding: 12rpx 6rpx;
|
||||
padding-top: 0;
|
||||
color: rgba(0, 0, 0, 0.75);
|
||||
}
|
||||
}
|
||||
|
||||
.vote-card-foot {
|
||||
box-sizing: border-box;
|
||||
margin-top: 12px;
|
||||
padding-top: 6px;
|
||||
border-top: 2rpx solid #eee;
|
||||
}
|
||||
|
||||
.is-voted-item {
|
||||
min-height: 72rpx;
|
||||
box-sizing: border-box;
|
||||
position: relative;
|
||||
border-radius: 12rpx;
|
||||
background-color: rgba(229, 229, 229, 0.75);
|
||||
font-size: 24rpx;
|
||||
overflow: hidden;
|
||||
|
||||
&::before {
|
||||
content: "";
|
||||
width: var(--percent);
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
background-color: rgba(208, 208, 208, 1);
|
||||
z-index: 0;
|
||||
border-radius: 6rpx;
|
||||
}
|
||||
|
||||
&.selected {
|
||||
background-color: rgba(3, 169, 244, 0.35);
|
||||
color: #ffffff;
|
||||
|
||||
&::before {
|
||||
background-color: rgba(3, 169, 244, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.is-voted-item-content {
|
||||
box-sizing: border-box;
|
||||
min-height: 72rpx;
|
||||
padding: 12rpx 24rpx;
|
||||
position: relative;
|
||||
z-index: 2;
|
||||
}
|
||||
|
||||
.vote-select-option {
|
||||
box-sizing: border-box;
|
||||
padding: 20rpx 24rpx;
|
||||
font-size: 24rpx;
|
||||
border-radius: 12rpx;
|
||||
transition: all 0.1s ease-in-out;
|
||||
}
|
||||
|
||||
|
||||
::v-deep {
|
||||
.tm-button-label {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
.single {
|
||||
::v-deep {}
|
||||
}
|
||||
|
||||
.multiple {
|
||||
::v-deep {}
|
||||
}
|
||||
|
||||
.pk {
|
||||
box-sizing: border-box;
|
||||
width: 100%;
|
||||
|
||||
::v-deep {
|
||||
|
||||
.pk-container {
|
||||
box-sizing: border-box;
|
||||
width: 100%;
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.radio-item {
|
||||
flex-grow: 1;
|
||||
min-width: 30% !important;
|
||||
max-width: 70% !important;
|
||||
}
|
||||
|
||||
.radio-left {}
|
||||
|
||||
.radio-right {}
|
||||
|
||||
.option-item {
|
||||
box-sizing: border-box;
|
||||
width: 100%;
|
||||
padding: 24rpx;
|
||||
border-radius: 12rpx;
|
||||
}
|
||||
|
||||
.option-item-left {
|
||||
background: linear-gradient(90deg, #3B82F6, #60A5FA);
|
||||
color: white;
|
||||
clip-path: polygon(0 0, calc(100% - 40rpx) 0, 100% 100%, 0 100%);
|
||||
}
|
||||
|
||||
.option-item-right {
|
||||
background: linear-gradient(90deg, #F87171, #EF4444);
|
||||
color: white;
|
||||
clip-path: polygon(0 0, 100% 0, 100% 100%, 40rpx 100%);
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.option-foot {
|
||||
margin-top: 24rpx;
|
||||
width: 100%;
|
||||
font-size: 24rpx;
|
||||
color: #666;
|
||||
|
||||
.tm-groupradio {
|
||||
display: flex;
|
||||
gap: 12rpx;
|
||||
}
|
||||
|
||||
.tm-checkbox {
|
||||
// width: 100%;
|
||||
max-width: initial !important;
|
||||
}
|
||||
|
||||
.tm-button {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.left {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.right {
|
||||
box-sizing: border-box;
|
||||
|
||||
.flex-start.fulled {
|
||||
justify-content: flex-end;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.sub-content {
|
||||
margin-bottom: 12rpx;
|
||||
padding: 12rpx 0;
|
||||
font-weight: bold;
|
||||
color: #2B2F33;
|
||||
font-size: 30rpx;
|
||||
}
|
||||
|
||||
.sub-remark {
|
||||
margin-bottom: 36rpx;
|
||||
padding-top: 12rpx;
|
||||
color: #3F3F3F;
|
||||
font-size: 28rpx;
|
||||
}
|
||||
|
||||
.sub-title {
|
||||
box-sizing: border-box;
|
||||
position: relative;
|
||||
margin-bottom: 12rpx;
|
||||
padding-left: 24rpx;
|
||||
// font-weight: bold;
|
||||
font-size: 30rpx;
|
||||
|
||||
&:before {
|
||||
content: "";
|
||||
width: 8rpx;
|
||||
height: 28rpx;
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 6rpx;
|
||||
background: #03A9F4;
|
||||
border-radius: 6rpx;
|
||||
}
|
||||
|
||||
.sub-title-count {
|
||||
font-size: 24rpx;
|
||||
font-weight: normal;
|
||||
}
|
||||
}
|
||||
|
||||
.vote-submit {
|
||||
box-sizing: border-box;
|
||||
padding: 24rpx 36rpx;
|
||||
position: fixed;
|
||||
left: 0;
|
||||
width: 100vw;
|
||||
bottom: 0;
|
||||
background-color: rgba(255, 255, 255, 0.98);
|
||||
box-shadow: 0rpx 2rpx 24rpx rgba(0, 0, 0, 0.03);
|
||||
border-top: 2rpx solid #eee;
|
||||
z-index: 99;
|
||||
|
||||
::v-deep {
|
||||
.tm-button {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.tm-button-btn {
|
||||
margin: 0;
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,409 @@
|
||||
<template>
|
||||
<view class="app-page" :class="[uniHaloPluginPageClass]">
|
||||
<PluginUnavailable v-if="!uniHaloPluginAvailable" :pluginId="uniHaloPluginId"
|
||||
:error-text="uniHaloPluginAvailableError" />
|
||||
<template v-else>
|
||||
<!-- 顶部切换 -->
|
||||
<view class="e-fixed filter-box">
|
||||
<tm-search v-model="queryParams.keyword" :round="24" :shadow="0" color="light-blue"
|
||||
insert-color="light-blue" :clear="true" @input="fnOnSearch" @confirm="fnOnSearch"></tm-search>
|
||||
<tm-dropDownMenu :shadow="0" color="light-blue" active-color="light-blue"
|
||||
:default-selected="filterOption.selected" :list="filterOption.list"
|
||||
@confirm="fnOnFilterConfirm"></tm-dropDownMenu>
|
||||
</view>
|
||||
<!-- 占位区域 -->
|
||||
<view style="width: 100vw;height: 180rpx;"></view>
|
||||
<!-- 加载区域 -->
|
||||
<view v-if="loading == 'loading'" class="loading-wrap pa-24">
|
||||
<tm-skeleton model="listAvatr"></tm-skeleton>
|
||||
<tm-skeleton model="listAvatr"></tm-skeleton>
|
||||
<tm-skeleton model="listAvatr"></tm-skeleton>
|
||||
<tm-skeleton model="listAvatr"></tm-skeleton>
|
||||
</view>
|
||||
<view v-else-if="loading == 'error'" class="content-empty flex flex-center">
|
||||
<tm-empty icon="icon-wind-cry" label="加载异常"></tm-empty>
|
||||
</view>
|
||||
<!-- 内容区域 -->
|
||||
<view v-else class="content">
|
||||
<view v-if="dataList.length == 0" class="content-empty flex flex-center">
|
||||
<tm-empty icon="icon-shiliangzhinengduixiang-" label="暂无数据"></tm-empty>
|
||||
</view>
|
||||
<block v-else>
|
||||
<tm-translate v-for="(item, index) in dataList" :key="item.metadata.name" animation-name="fadeUp"
|
||||
:wait="calcAniWait(index)">
|
||||
<VoteCard :vote="item" :index="index" @on-click="fnToDetail"></VoteCard>
|
||||
</tm-translate>
|
||||
<view class="load-text">{{ loadMoreText }}</view>
|
||||
<tm-flotbutton @click="fnToTopPage" size="m" color="light-blue"
|
||||
icon="icon-angle-up"></tm-flotbutton>
|
||||
|
||||
</block>
|
||||
</view>
|
||||
</template>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import tmSkeleton from '@/tm-vuetify/components/tm-skeleton/tm-skeleton.vue';
|
||||
import tmSearch from '@/tm-vuetify/components/tm-search/tm-search.vue';
|
||||
import tmTranslate from '@/tm-vuetify/components/tm-translate/tm-translate.vue';
|
||||
import tmTabs from '@/tm-vuetify/components/tm-tabs/tm-tabs.vue';
|
||||
import tmFlotbutton from '@/tm-vuetify/components/tm-flotbutton/tm-flotbutton.vue';
|
||||
import tmEmpty from '@/tm-vuetify/components/tm-empty/tm-empty.vue';
|
||||
import tmTags from '@/tm-vuetify/components/tm-tags/tm-tags.vue';
|
||||
import tmDropDownMenu from '@/tm-vuetify/components/tm-dropDownMenu/tm-dropDownMenu.vue';
|
||||
|
||||
import VoteCard from '@/components/vote-card/vote-card.vue'
|
||||
|
||||
import {
|
||||
VOTE_TYPES,
|
||||
calcVoteState,
|
||||
voteCacheUtil
|
||||
} from '@/utils/vote.js'
|
||||
import pluginAvailableMixin from "@/common/mixins/pluginAvailable.js"
|
||||
import PluginUnavailable from '@/components/plugin-unavailable/plugin-unavailable.vue'
|
||||
|
||||
export default {
|
||||
options: {
|
||||
styleIsolation: 'shared'
|
||||
},
|
||||
mixins: [pluginAvailableMixin],
|
||||
components: {
|
||||
tmSkeleton,
|
||||
tmSearch,
|
||||
tmTranslate,
|
||||
tmTabs,
|
||||
tmFlotbutton,
|
||||
tmEmpty,
|
||||
tmTags,
|
||||
tmDropDownMenu,
|
||||
VoteCard,
|
||||
PluginUnavailable
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
loading: 'loading',
|
||||
hasNext: false,
|
||||
isLoadMore: false,
|
||||
loadMoreText: '加载中...',
|
||||
filterOption: {
|
||||
selected: [],
|
||||
list: [{
|
||||
title: '类型',
|
||||
children: [{
|
||||
title: "",
|
||||
model: "list",
|
||||
name: "type",
|
||||
children: [{
|
||||
title: "全部",
|
||||
id: undefined
|
||||
},
|
||||
{
|
||||
title: "单选",
|
||||
id: 'single'
|
||||
},
|
||||
{
|
||||
title: "多选",
|
||||
id: 'multiple'
|
||||
},
|
||||
{
|
||||
title: "双选PK",
|
||||
id: 'pk'
|
||||
}
|
||||
]
|
||||
}]
|
||||
}, {
|
||||
title: '状态',
|
||||
children: [{
|
||||
title: "",
|
||||
model: "list",
|
||||
name: "hasEnded",
|
||||
children: [{
|
||||
title: "全部",
|
||||
id: undefined
|
||||
},
|
||||
{
|
||||
title: "进行中",
|
||||
id: false
|
||||
},
|
||||
{
|
||||
title: "已结束",
|
||||
id: true
|
||||
}
|
||||
]
|
||||
}]
|
||||
}, {
|
||||
title: '排序',
|
||||
children: [{
|
||||
title: "",
|
||||
model: "list",
|
||||
name: "sort",
|
||||
children: [{
|
||||
title: "默认排序",
|
||||
id: undefined
|
||||
},
|
||||
{
|
||||
title: "较近创建",
|
||||
id: 'metadata.creationTimestamp,desc'
|
||||
},
|
||||
{
|
||||
title: "较早创建",
|
||||
id: 'metadata.creationTimestamp,asc'
|
||||
}
|
||||
]
|
||||
}]
|
||||
}, {
|
||||
title: '是否已投',
|
||||
children: [{
|
||||
title: "",
|
||||
model: "list",
|
||||
name: "isVoted",
|
||||
children: [{
|
||||
title: "全部",
|
||||
id: undefined
|
||||
},
|
||||
{
|
||||
title: "未投票",
|
||||
id: false
|
||||
},
|
||||
{
|
||||
title: "已投票",
|
||||
id: true
|
||||
}
|
||||
]
|
||||
}]
|
||||
}]
|
||||
},
|
||||
filterIsVoted: undefined,
|
||||
queryParams: {
|
||||
keyword: "",
|
||||
page: 1,
|
||||
size: 10,
|
||||
sort: undefined,
|
||||
type: undefined,
|
||||
hasEnded: undefined
|
||||
},
|
||||
dataList: []
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
haloConfigs() {
|
||||
return this.$tm.vx.getters().getConfigs;
|
||||
},
|
||||
calcAuditModeEnabled() {
|
||||
return this.haloConfigs.auditConfig.auditModeEnabled
|
||||
},
|
||||
},
|
||||
async onLoad() {
|
||||
this.fnSetPageTitle('投票列表');
|
||||
// 检查插件
|
||||
this.setPluginId(this.NeedPluginIds.PluginVote)
|
||||
this.setPluginError("阿偶,检测到当前插件没有安装或者启用,无法使用投票功能哦,请联系管理员")
|
||||
if (!await this.checkPluginAvailable()) return
|
||||
this.fnGetData();
|
||||
},
|
||||
onPullDownRefresh() {
|
||||
if (!this.uniHaloPluginAvailable) {
|
||||
uni.hideLoading();
|
||||
uni.stopPullDownRefresh();
|
||||
return
|
||||
}
|
||||
this.fnResetSetAniWaitIndex();
|
||||
this.isLoadMore = false;
|
||||
this.queryParams.page = 0;
|
||||
this.fnGetData();
|
||||
},
|
||||
onReachBottom(e) {
|
||||
if (!this.uniHaloPluginAvailable) return;
|
||||
if (this.calcAuditModeEnabled) {
|
||||
uni.showToast({
|
||||
icon: 'none',
|
||||
title: '没有更多数据了'
|
||||
});
|
||||
return
|
||||
}
|
||||
if (this.hasNext) {
|
||||
this.queryParams.page += 1;
|
||||
this.isLoadMore = true;
|
||||
this.fnGetData();
|
||||
} else {
|
||||
uni.showToast({
|
||||
icon: 'none',
|
||||
title: '没有更多数据了'
|
||||
});
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
fnOnSearch() {
|
||||
this.fnResetSetAniWaitIndex();
|
||||
this.fnToTopPage();
|
||||
this.fnGetData();
|
||||
},
|
||||
fnGetData() {
|
||||
if (this.calcAuditModeEnabled) {
|
||||
return;
|
||||
}
|
||||
uni.showLoading({
|
||||
mask: true,
|
||||
title: '加载中...'
|
||||
});
|
||||
// 设置状态为加载中
|
||||
if (!this.isLoadMore) {
|
||||
this.loading = 'loading';
|
||||
}
|
||||
this.loadMoreText = '加载中...';
|
||||
this.$httpApi.v2
|
||||
.getVoteList(this.queryParams)
|
||||
.then(res => {
|
||||
this.loading = 'success';
|
||||
this.loadMoreText = res.hasNext ? '上拉加载更多' : '呜呜,没有更多数据啦~';
|
||||
this.hasNext = res.hasNext;
|
||||
|
||||
const tempItems = res.items.map(item => {
|
||||
item.spec.disabled = true
|
||||
item.spec.isVoted = this.fnCalcIsVoted(item.metadata.name)
|
||||
item.spec._uh_state = calcVoteState(item)
|
||||
item.spec._uh_type = VOTE_TYPES[item.spec.type]
|
||||
item.spec.options.map((option, index) => {
|
||||
|
||||
option.checked = this.fnCalcIsChecked(item.metadata.name, option)
|
||||
option.value = option.id
|
||||
option.label = option.title
|
||||
|
||||
// 计算当前的选择占比
|
||||
if (item.spec.type === 'single') {
|
||||
option.percent = this.fnCalcPercent(option, item.stats);
|
||||
} else if (item.spec.type === 'multiple') {
|
||||
option.percent = this.fnCalcPercent(option, item.stats);
|
||||
} else if (item.spec.type === 'pk') {
|
||||
option.percent = this.fnCalcPercent(option, item.stats);
|
||||
}
|
||||
|
||||
return option
|
||||
})
|
||||
|
||||
return item;
|
||||
})
|
||||
|
||||
if (this.isLoadMore) {
|
||||
this.dataList = this.dataList.concat(tempItems);
|
||||
} else {
|
||||
this.dataList = tempItems;
|
||||
}
|
||||
|
||||
this.dataList = this.dataList.sort((a, b) => {
|
||||
return a.spec.isVoted - b.spec.isVoted
|
||||
})
|
||||
|
||||
if (this.filterIsVoted != undefined) {
|
||||
this.dataList = this.dataList.filter(x => x.spec.isVoted == this.filterIsVoted)
|
||||
}
|
||||
})
|
||||
.catch(err => {
|
||||
console.error(err);
|
||||
this.loading = 'error';
|
||||
this.loadMoreText = '加载失败,请下拉刷新!';
|
||||
})
|
||||
.finally(() => {
|
||||
setTimeout(() => {
|
||||
uni.hideLoading();
|
||||
uni.stopPullDownRefresh();
|
||||
}, 100);
|
||||
});
|
||||
},
|
||||
|
||||
fnCalcPercent(voteOption, stats) {
|
||||
if (!stats?.voteDataList) return 0;
|
||||
const option = stats.voteDataList.find(x => x.id == voteOption.id)
|
||||
if (!option) return 0;
|
||||
const percent = (option.voteCount / stats.voteCount) * 100
|
||||
return Math.round(percent)
|
||||
},
|
||||
|
||||
fnCalcIsVoted(name) {
|
||||
return voteCacheUtil.has(name)
|
||||
},
|
||||
fnCalcIsChecked(name, option) {
|
||||
const data = voteCacheUtil.get(name)
|
||||
if (!data) return false;
|
||||
const checked = data.selected.includes(option.id)
|
||||
return checked
|
||||
},
|
||||
|
||||
//跳转详情
|
||||
fnToDetail(item) {
|
||||
if (this.calcAuditModeEnabled) return;
|
||||
uni.navigateTo({
|
||||
url: '/pagesA/vote-detail/vote-detail?name=' + item.metadata.name,
|
||||
animationType: 'slide-in-right'
|
||||
});
|
||||
},
|
||||
fnOnFilterConfirm(e) {
|
||||
// 类型
|
||||
const type = e.find(x => x.name == 'type')
|
||||
if (type.children.length == 0) {
|
||||
this.queryParams.type = undefined
|
||||
} else {
|
||||
this.queryParams.type = type.children[0]?.id
|
||||
}
|
||||
|
||||
// 状态
|
||||
const hasEnded = e.find(x => x.name == 'hasEnded')
|
||||
if (hasEnded.children.length == 0) {
|
||||
this.queryParams.hasEnded = undefined
|
||||
} else {
|
||||
this.queryParams.hasEnded = hasEnded.children[0]?.id
|
||||
}
|
||||
|
||||
// 排序
|
||||
const sort = e.find(x => x.name == 'sort')
|
||||
if (sort.children.length == 0) {
|
||||
this.queryParams.sort = undefined
|
||||
} else {
|
||||
this.queryParams.sort = sort.children[0]?.id
|
||||
}
|
||||
|
||||
// 是否已经投
|
||||
const isVoted = e.find(x => x.name == 'isVoted')
|
||||
if (isVoted.children.length == 0) {
|
||||
this.filterIsVoted = undefined
|
||||
} else {
|
||||
this.filterIsVoted = isVoted.children[0]?.id
|
||||
}
|
||||
|
||||
this.queryParams.page = 0;
|
||||
this.isLoadMore = false;
|
||||
this.fnResetSetAniWaitIndex();
|
||||
this.fnToTopPage();
|
||||
this.fnGetData();
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.app-page {
|
||||
width: 100vw;
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding-bottom: 24rpx;
|
||||
background-color: #fafafd;
|
||||
|
||||
&.is-balck {
|
||||
background-color: #212121;
|
||||
}
|
||||
}
|
||||
|
||||
.filter-box {
|
||||
box-shadow: 0rpx 0rpx 12rpx rgba(0, 0, 0, 0.035);
|
||||
}
|
||||
|
||||
.content {
|
||||
padding-top: 24rpx;
|
||||
}
|
||||
|
||||
.content-empty {
|
||||
height: 60vh;
|
||||
}
|
||||
</style>
|
||||
@@ -2,7 +2,7 @@
|
||||
<view @click="onclick" class=" tm-checkbox " :class="[dense?'':'pa-20',inline?'d-inline-block':'']">
|
||||
<view class=" flex-start">
|
||||
|
||||
<slot name="default" :checkData="{label:label,checked:changValue}" :on="onclick">
|
||||
<slot name="default" :checkData="{label:label,checked:changValue,extendData}" :on="onclick">
|
||||
<view :style="{width: sizes.wk,height: sizes.wk}" class="tm-checkbox-boey relative d-inline-block"
|
||||
:class="[black?'bk':'','flex-shrink mr-10',
|
||||
changValue?'ani':'',
|
||||
@@ -51,6 +51,10 @@
|
||||
*/
|
||||
import tmIcons from "@/tm-vuetify/components/tm-icons/tm-icons.vue"
|
||||
export default {
|
||||
options: {
|
||||
virtualHost: true,
|
||||
styleIsolation: 'shared'
|
||||
},
|
||||
components:{tmIcons},
|
||||
name: 'tm-checkbox',
|
||||
model: {
|
||||
@@ -117,6 +121,10 @@
|
||||
fllowTheme:{
|
||||
type:Boolean|String,
|
||||
default:true
|
||||
},
|
||||
extendData:{
|
||||
type:Object,
|
||||
default:()=>({})
|
||||
}
|
||||
},
|
||||
data() {
|
||||
|
||||
@@ -100,8 +100,6 @@ export default {
|
||||
},
|
||||
//向列表添加数据
|
||||
pushData(list) {
|
||||
console.log('添加图片数据----------',list)
|
||||
|
||||
let prIdx_i = this.list2.length;
|
||||
if (!Array.isArray(list) || typeof list == 'undefined') {
|
||||
return false;
|
||||
@@ -122,8 +120,6 @@ export default {
|
||||
return this.dataList;
|
||||
},
|
||||
async loadimg(event, isLoad, index) {
|
||||
console.log('图片加载事件----------',event)
|
||||
|
||||
this.isLoading = true;
|
||||
let ps = this.list2[index];
|
||||
ps.isLoad = true;
|
||||
|
||||
@@ -17,6 +17,10 @@
|
||||
*
|
||||
*/
|
||||
export default {
|
||||
options: {
|
||||
virtualHost: true,
|
||||
styleIsolation: 'shared'
|
||||
},
|
||||
name:'tm-groupcheckbox',
|
||||
props:{
|
||||
// 最大选择数量
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<view @click="onclick" class=" tm-checkbox " :class="[dense?'':'pa-20',inline?'d-inline-block ':'fulled']">
|
||||
<view class="flex-start fulled">
|
||||
|
||||
<slot name="default" :checkData="{label:label,checked:changValue}" :on="onclick">
|
||||
<slot name="default" :checkData="{label:label,checked:changValue,extendData}" :on="onclick">
|
||||
<view :style="{width: sizes.wk,height: sizes.wk}" class="tm-checkbox-boey relative d-inline-block"
|
||||
:class="[black?'bk':'','flex-shrink mr-10 ',
|
||||
changValue?'ani':'',
|
||||
@@ -119,8 +119,11 @@
|
||||
fllowTheme:{
|
||||
type:Boolean|String,
|
||||
default:true
|
||||
}
|
||||
|
||||
},
|
||||
extendData:{
|
||||
type:Object,
|
||||
default:()=>({})
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
## 1.0.2(2023-09-14)
|
||||
更新使用文档:
|
||||
引入本插件 然后使用,手动滑稽,教程简单吗?
|
||||
<k-touch-listen @touchUp="touchUp" @touchDown="touchDown" @touchLeft="touchLeft" @touchRight="touchRight">
|
||||
<view>
|
||||
//您需要监听的区域的代码
|
||||
</view>
|
||||
</k-touch-listen>
|
||||
## 1.0.1(2023-09-14)
|
||||
更新使用文档:
|
||||
引入本插件 然后使用,手动滑稽,教程简单吗?
|
||||
<k-touch-listen @touchUp="touchUp" @touchDown="touchDown" @touchLeft="touchLeft" @touchRight="touchRight">
|
||||
<view>
|
||||
//您需要监听的区域的代码
|
||||
</view>
|
||||
</k-touch-listen>
|
||||
## 1.0.0(2023-09-14)
|
||||
首次提交
|
||||
@@ -0,0 +1,113 @@
|
||||
<template>
|
||||
<view class="touch-box" @touchstart="touchStart" @touchmove="touchMove" @touchend="touchEnd">
|
||||
<slot></slot>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'k-touch-listen',
|
||||
data() {
|
||||
return {
|
||||
touchStartX: 0, // 触摸时的原点
|
||||
touchStartY: 0, // 触摸时的原点
|
||||
time: 0, // 时间记录,用于滑动时且时间小于1s则执行左右滑动
|
||||
interval: '', // 记录/清理时间记录
|
||||
touchMoveX: 0, // x轴方向移动的距离
|
||||
touchMoveY: 0, // y轴方向移动的距离
|
||||
touchMoveTag: false // 定义滑动状态
|
||||
}
|
||||
},
|
||||
props: {
|
||||
direction: {
|
||||
type: String,
|
||||
default: 'all'
|
||||
},
|
||||
distance: {
|
||||
type: [String, Number],
|
||||
default: 30
|
||||
}
|
||||
},
|
||||
emits: ['touchUp', 'touchDown', 'touchLeft', 'touchRight'],
|
||||
methods: {
|
||||
// 触摸开始事件
|
||||
touchStart(e) {
|
||||
this.touchStartX = e.touches[0].pageX // 获取触摸时的原点
|
||||
this.touchStartY = e.touches[0].pageY // 获取触摸时的原点
|
||||
// 使用js计时器记录时间
|
||||
this.interval = setInterval(() => {
|
||||
this.time++
|
||||
}, 100)
|
||||
},
|
||||
// 触摸移动事件
|
||||
touchMove(e) {
|
||||
this.touchMoveTag = true
|
||||
this.touchMoveX = e.touches[0].pageX
|
||||
this.touchMoveY = e.touches[0].pageY
|
||||
},
|
||||
ressetData() {
|
||||
this.touchStartX = 0 // 触摸时的原点
|
||||
this.touchStartY = 0 // 触摸时的原点
|
||||
this.time = 0 // 时间记录,用于滑动时且时间小于1s则执行左右滑动
|
||||
this.interval = '' // 记录/清理时间记录
|
||||
this.touchMoveX = 0 // x轴方向移动的距离
|
||||
this.touchMoveY = 0 // y轴方向移动的距离
|
||||
this.touchMoveTag = false // 定义滑动状态
|
||||
},
|
||||
// 触摸结束事件
|
||||
touchEnd(e) {
|
||||
let moveX = this.touchMoveX - this.touchStartX
|
||||
let moveY = this.touchMoveY - this.touchStartY
|
||||
if (Math.sign(moveX) == -1) {
|
||||
moveX *= -1
|
||||
}
|
||||
if (Math.sign(moveY) == -1) {
|
||||
moveY *= -1
|
||||
}
|
||||
if (2 * moveX <= moveY && this.touchMoveTag) {
|
||||
// 上下
|
||||
if (this.direction != 'all' && this.direction != 'vertical') return
|
||||
// 向上滑动
|
||||
if (
|
||||
this.touchMoveY - this.touchStartY <= -this.distance &&
|
||||
this.time < 10
|
||||
) {
|
||||
this.$emit('touchUp')
|
||||
}
|
||||
// 向下滑动
|
||||
if (
|
||||
this.touchMoveY - this.touchStartY >= this.distance &&
|
||||
this.time < 10
|
||||
) {
|
||||
this.$emit('touchDown')
|
||||
}
|
||||
} else if (moveX > 2 * moveY && this.touchMoveTag) {
|
||||
// 左右
|
||||
if (this.direction != 'all' && this.direction != 'horizontal') return
|
||||
// 向左滑动
|
||||
if (
|
||||
this.touchMoveX - this.touchStartX <= -this.distance &&
|
||||
this.time < 10
|
||||
) {
|
||||
this.$emit('touchLeft')
|
||||
}
|
||||
// 向右滑动
|
||||
if (
|
||||
this.touchMoveX - this.touchStartX >= this.distance &&
|
||||
this.time < 10
|
||||
) {
|
||||
this.$emit('touchRight')
|
||||
}
|
||||
}
|
||||
clearInterval(this.interval) // 清除setInterval
|
||||
this.ressetData()
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style scoped>
|
||||
.touch-box {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,85 @@
|
||||
{
|
||||
"id": "k-touch-listen",
|
||||
"displayName": "k-touch-listen 手势监听 全面兼容小程序、vue2、vue3等多端",
|
||||
"version": "1.0.2",
|
||||
"description": "用于监听用户滑动手势,左滑右滑,上滑下滑等一系列手势监听",
|
||||
"keywords": [
|
||||
"touch",
|
||||
"手势",
|
||||
"手势监听",
|
||||
"手势监听",
|
||||
"vue3"
|
||||
],
|
||||
"repository": "",
|
||||
"engines": {
|
||||
"HBuilderX": "^3.7.6"
|
||||
},
|
||||
"dcloudext": {
|
||||
"type": "component-vue",
|
||||
"sale": {
|
||||
"regular": {
|
||||
"price": "0.00"
|
||||
},
|
||||
"sourcecode": {
|
||||
"price": "0.00"
|
||||
}
|
||||
},
|
||||
"contact": {
|
||||
"qq": ""
|
||||
},
|
||||
"declaration": {
|
||||
"ads": "无",
|
||||
"data": "插件不采集任何数据",
|
||||
"permissions": "无"
|
||||
},
|
||||
"npmurl": ""
|
||||
},
|
||||
"uni_modules": {
|
||||
"dependencies": [],
|
||||
"encrypt": [],
|
||||
"platforms": {
|
||||
"cloud": {
|
||||
"tcb": "y",
|
||||
"aliyun": "y"
|
||||
},
|
||||
"client": {
|
||||
"Vue": {
|
||||
"vue2": "y",
|
||||
"vue3": "y"
|
||||
},
|
||||
"App": {
|
||||
"app-vue": "y",
|
||||
"app-nvue": "y"
|
||||
},
|
||||
"H5-mobile": {
|
||||
"Safari": "y",
|
||||
"Android Browser": "y",
|
||||
"微信浏览器(Android)": "y",
|
||||
"QQ浏览器(Android)": "y"
|
||||
},
|
||||
"H5-pc": {
|
||||
"Chrome": "y",
|
||||
"IE": "y",
|
||||
"Edge": "y",
|
||||
"Firefox": "y",
|
||||
"Safari": "y"
|
||||
},
|
||||
"小程序": {
|
||||
"微信": "y",
|
||||
"阿里": "y",
|
||||
"百度": "y",
|
||||
"字节跳动": "y",
|
||||
"QQ": "y",
|
||||
"钉钉": "u",
|
||||
"快手": "u",
|
||||
"飞书": "u",
|
||||
"京东": "u"
|
||||
},
|
||||
"快应用": {
|
||||
"华为": "u",
|
||||
"联盟": "u"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
import utils from '@/utils/index.js'
|
||||
import v2Apis from "@/api/v2/all.api.js"
|
||||
|
||||
export const NeedPluginIds = Object.freeze({
|
||||
PluginUniHalo: "plugin-uni-halo",
|
||||
PluginPhotos: "PluginPhotos",
|
||||
PluginLinks: "PluginLinks",
|
||||
PluginMoments: "PluginMoments",
|
||||
PluginSearchWidget: "PluginSearchWidget",
|
||||
PluginCommentWidget: "PluginCommentWidget",
|
||||
PluginVote: "vote",
|
||||
})
|
||||
|
||||
export const NeedPlugins = new Map([
|
||||
[
|
||||
NeedPluginIds.PluginUniHalo, {
|
||||
id: "plugin-uni-halo",
|
||||
name: "UniHalo配置",
|
||||
desc: "uni-halo 核心插件,未安装和启用的情况下,将无法使用 uni-halo,请检查是否已安装和启用",
|
||||
logo: utils.checkUrl("/plugins/plugin-uni-halo/assets/logo.png"),
|
||||
url: "https://www.halo.run/store/apps/app-ryemX"
|
||||
}
|
||||
],
|
||||
[
|
||||
NeedPluginIds.PluginPhotos, {
|
||||
id: "PluginPhotos",
|
||||
name: "图库管理",
|
||||
desc: "图库功能模块所需要的插件",
|
||||
logo: utils.checkUrl("/plugins/PluginPhotos/assets/logo.svg"),
|
||||
url: "https://www.halo.run/store/apps/app-BmQJW"
|
||||
}
|
||||
],
|
||||
[
|
||||
NeedPluginIds.PluginLinks, {
|
||||
id: "PluginLinks",
|
||||
name: "链接管理",
|
||||
desc: "链接管理模块,用于网站友情链接功能模块",
|
||||
logo: utils.checkUrl("/plugins/PluginLinks/assets/logo.svg"),
|
||||
url: "https://www.halo.run/store/apps/app-hfbQg"
|
||||
}
|
||||
],
|
||||
[
|
||||
NeedPluginIds.PluginMoments, {
|
||||
id: "PluginMoments",
|
||||
name: "瞬间",
|
||||
desc: "提供一个轻量级的内容图文、视频、音频等内容展示",
|
||||
logo: utils.checkUrl("/plugins/PluginMoments/assets/logo.svg"),
|
||||
url: "https://www.halo.run/store/apps/app-SnwWD"
|
||||
}
|
||||
],
|
||||
[
|
||||
NeedPluginIds.PluginSearchWidget, {
|
||||
id: "PluginSearchWidget",
|
||||
name: "搜索组件",
|
||||
desc: "为应用提供统一的搜索组件",
|
||||
logo: utils.checkUrl("/plugins/PluginSearchWidget/assets/logo.svg"),
|
||||
url: "https://www.halo.run/store/apps/app-DlacW"
|
||||
}
|
||||
],
|
||||
[
|
||||
NeedPluginIds.PluginCommentWidget, {
|
||||
id: "PluginCommentWidget",
|
||||
name: "评论组件",
|
||||
desc: "为用户前台提供完整的评论解决方案",
|
||||
logo: utils.checkUrl("/plugins/PluginCommentWidget/assets/logo.svg"),
|
||||
url: "https://www.halo.run/store/apps/app-YXyaD"
|
||||
}
|
||||
],
|
||||
[
|
||||
NeedPluginIds.PluginVote, {
|
||||
id: "vote",
|
||||
name: "投票管理",
|
||||
desc: "投票模块所需要的插件,用于展示投票和提交投票",
|
||||
logo: utils.checkUrl("/plugins/vote/assets/logo.png"),
|
||||
url: "https://www.halo.run/store/apps/app-veyvzyhv"
|
||||
}
|
||||
]
|
||||
])
|
||||
|
||||
/**
|
||||
* 检查插件是否启用、安装
|
||||
* @param {String} pluginId 插件id
|
||||
* @return {Boolean} true = 安装、启用 false= 未安装启用
|
||||
*/
|
||||
export const checkNeedPluginAvailable = (pluginId) => {
|
||||
return new Promise(async (resolve) => {
|
||||
try {
|
||||
const available = await v2Apis.checkPluginAvailable(pluginId)
|
||||
resolve(available)
|
||||
} catch (err) {
|
||||
resolve(false)
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
|
||||
/**
|
||||
* 生成指定长度的uuid
|
||||
* @param {number} = 长度
|
||||
*/
|
||||
export function generateUUID(length = 36) {
|
||||
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
||||
let result = '';
|
||||
|
||||
const validLength = Math.max(1, Math.floor(Number(length)) || 36);
|
||||
for (let i = 0; i < validLength; i++) {
|
||||
result += characters.charAt(Math.floor(Math.random() * characters.length));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
const UnihaloVoteUid = "unihalo_vote_uid"
|
||||
|
||||
export const voteCacheUtil = {
|
||||
getAll() {
|
||||
const data = uni.getStorageSync(UnihaloVoteUid)
|
||||
if (!data) {
|
||||
return null
|
||||
}
|
||||
return JSON.parse(data)
|
||||
},
|
||||
get(name) {
|
||||
const data = this.getAll()
|
||||
if (!data) {
|
||||
return null
|
||||
}
|
||||
return data[name]
|
||||
},
|
||||
has(name) {
|
||||
const data = this.getAll()
|
||||
if (!data) return false
|
||||
return data[name] != undefined
|
||||
},
|
||||
set(name, value) {
|
||||
let data = this.getAll()
|
||||
if (!data) {
|
||||
data = {
|
||||
[name]: value
|
||||
}
|
||||
} else {
|
||||
data[name] = value
|
||||
}
|
||||
uni.setStorageSync(UnihaloVoteUid, JSON.stringify(data))
|
||||
}
|
||||
}
|
||||
|
||||
export const VOTE_TYPES = {
|
||||
"pk": "双选PK",
|
||||
"multiple": "多选",
|
||||
"single": "单选"
|
||||
}
|
||||
|
||||
export const VOTE_STATES = {
|
||||
"未开始": {
|
||||
state: "未开始",
|
||||
color: "orange"
|
||||
},
|
||||
"进行中": {
|
||||
state: "进行中",
|
||||
color: "green"
|
||||
},
|
||||
"已结束": {
|
||||
state: "已结束",
|
||||
color: "red"
|
||||
},
|
||||
}
|
||||
|
||||
export const calcVoteState = (vote) => {
|
||||
if (vote.spec.timeLimit !== 'custom') {
|
||||
return vote.spec.hasEnded ? VOTE_STATES["已结束"] : VOTE_STATES["进行中"]
|
||||
}
|
||||
|
||||
const nowTime = new Date().getTime()
|
||||
const startTime = new Date(vote.spec.startDate).getTime()
|
||||
const endTime = new Date(vote.spec.endDate).getTime()
|
||||
|
||||
if (nowTime < startTime) {
|
||||
return VOTE_STATES["未开始"]
|
||||
}
|
||||
if (nowTime < endTime) {
|
||||
return VOTE_STATES["进行中"]
|
||||
}
|
||||
return vote.spec.hasEnded ? VOTE_STATES["已结束"] : VOTE_STATES["进行中"]
|
||||
}
|
||||
|
||||
export const calcVotePercent = (vote, voteOption) => {
|
||||
if (!vote || !voteOption) return 0
|
||||
const votedDataList = vote?.stats?.voteDataList || []
|
||||
if (votedDataList.length == 0) return 0
|
||||
const voteCount = vote?.stats?.voteCount || 0
|
||||
if (voteCount == 0) return 0
|
||||
|
||||
const _voteOption = votedDataList.find(x => x.id == voteOption.id)
|
||||
if (!_voteOption) return 0;
|
||||
const percent = (_voteOption.voteCount / voteCount) * 100
|
||||
return Math.round(percent)
|
||||
}
|
||||
Reference in New Issue
Block a user