about.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620
  1. <template>
  2. <view class="app-page pb-24">
  3. <!-- 博主信息 -->
  4. <view class="blogger-info" :style="[calcProfileStyle]">
  5. <image class="avatar" :src="$utils.checkAvatarUrl(bloggerInfo.avatar)" mode="aspectFill"></image>
  6. <view class="profile">
  7. <view class="author mt-24 text-size-g text-weight-b">{{ bloggerInfo.nickname }}</view>
  8. <view class="desc mt-24 text-size-m">
  9. {{ bloggerInfo.description || '这个博主很懒,竟然没写介绍~' }}
  10. </view>
  11. </view>
  12. <image v-if="calcWaveUrl" :src="calcWaveUrl" mode="scaleToFill" class="gif-wave"></image>
  13. </view>
  14. <!-- 统计信息 -->
  15. <view class="statistics-wrap bg-white">
  16. <tm-more iconColor="light-blue" :open.sync="statisticsShowMore" :maxHeight="62" label=" " open-label=" ">
  17. <template>
  18. <view class="statistics flex pt-24 pb-24" :class="{ 'has-solid': statisticsShowMore }">
  19. <view class="item flex-1 text-align-center">
  20. <view class="number text-size-xl text-bg-gradient-orange-accent">
  21. <tm-flop :startVal="0" :decimals="0" :endVal="statistics.post"
  22. :duration="3000"></tm-flop>
  23. </view>
  24. <view class="mt-6 text-align-center text-size-s text-grey-darken-1">内容数量</view>
  25. </view>
  26. <view class="item flex-1 text-align-center">
  27. <view class="number text-size-xl text-bg-gradient-green-accent">
  28. <tm-flop :startVal="0" :decimals="0" :endVal="statistics.visit"
  29. :duration="3000"></tm-flop>
  30. </view>
  31. <view class="mt-6 text-size-s text-grey-darken-1">访客数量</view>
  32. </view>
  33. <view class="item flex-1 text-align-center">
  34. <view class="number text-size-xl text-bg-gradient-blue-accent">
  35. <tm-flop :startVal="0" :decimals="0" :endVal="statistics.category"
  36. :duration="3000"></tm-flop>
  37. </view>
  38. <view class="mt-6 text-align-center text-size-s text-grey-darken-1">分类总数</view>
  39. </view>
  40. </view>
  41. <view class="statistics solid-top has-solid flex pt-24 pb-24">
  42. <view class="item flex-1 text-align-center">
  43. <view class="number text-size-xl text-bg-gradient-orange-accent">
  44. <tm-flop :startVal="0" :decimals="0" :endVal="statistics.comment"
  45. :duration="3000"></tm-flop>
  46. </view>
  47. <view class="mt-6 text-align-center text-size-s text-grey-darken-1">评论数量</view>
  48. </view>
  49. <view class="item flex-1 text-align-center">
  50. <view class="number text-size-xl text-bg-gradient-blue-accent">
  51. <tm-flop :startVal="0" :decimals="0" :endVal="statistics.upvote"
  52. :duration="3000"></tm-flop>
  53. </view>
  54. <view class="mt-6 text-size-s text-grey-darken-1">点赞数量</view>
  55. </view>
  56. </view>
  57. </template>
  58. </tm-more>
  59. </view>
  60. <!-- 功能导航 -->
  61. <view class="nav-wrap ma-24 round-3">
  62. <tm-grouplist :shadow="0" :round="3" :margin="[0, 0]">
  63. <block v-for="(nav, index) in navList" :key="index">
  64. <tm-listitem v-if="nav.show" :title="nav.title" :left-icon="nav.leftIcon" show-left-icon
  65. :left-icon-color="nav.leftIconColor" :value="nav.rightText" @click="fnOnNav(nav)">
  66. <template slot="rightValue">
  67. <button class="right-value-btn" v-if="nav.openType" :open-type="nav.openType">
  68. {{ nav.rightText }}
  69. </button>
  70. <text v-else>{{ nav.rightText }}</text>
  71. </template>
  72. </tm-listitem>
  73. </block>
  74. </tm-grouplist>
  75. </view>
  76. <!-- 版权 -->
  77. <view v-if="copyrightConfig.enabled" class="copyright mt-40 text-size-xs text-align-center">
  78. <view class="">{{ copyrightConfig.content }}</view>
  79. </view>
  80. </view>
  81. </template>
  82. <script>
  83. import {
  84. checkHasAdminLogin
  85. } from '@/utils/auth.js';
  86. import CheckAppUpdate from '@/uni_modules/uni-upgrade-center-app/utils/check-update';
  87. import {
  88. CheckWxUpdate
  89. } from '@/utils/update.js';
  90. import {
  91. NeedPluginIds,
  92. NeedPlugins,
  93. checkNeedPluginAvailable
  94. } from "@/utils/plugin.js"
  95. import tmGrouplist from '@/tm-vuetify/components/tm-grouplist/tm-grouplist.vue';
  96. import tmListitem from '@/tm-vuetify/components/tm-listitem/tm-listitem.vue';
  97. import tmTranslate from '@/tm-vuetify/components/tm-translate/tm-translate.vue';
  98. import tmPoup from '@/tm-vuetify/components/tm-poup/tm-poup.vue';
  99. import tmMore from '@/tm-vuetify/components/tm-more/tm-more.vue';
  100. import tmFlop from '@/tm-vuetify/components/tm-flop/tm-flop.vue';
  101. import tmButton from '@/tm-vuetify/components/tm-button/tm-button.vue';
  102. import tmIcons from '@/tm-vuetify/components/tm-icons/tm-icons.vue';
  103. import wave from '@/components/wave/wave.vue';
  104. export default {
  105. components: {
  106. tmGrouplist,
  107. tmListitem,
  108. tmTranslate,
  109. tmPoup,
  110. tmMore,
  111. tmFlop,
  112. tmButton,
  113. tmIcons,
  114. wave
  115. },
  116. data() {
  117. return {
  118. statisticsShowMore: false,
  119. // 统计信息
  120. statistics: {
  121. post: 0, // 文章数量
  122. comment: 0, // 评论数量
  123. category: 0, // 分类数量
  124. visit: 0, // 访客数量
  125. upvote: 0 // 点赞数量
  126. },
  127. // 导航信息
  128. navList: [],
  129. miniProfileCard: {
  130. show: false
  131. }
  132. };
  133. },
  134. computed: {
  135. haloConfigs() {
  136. return this.$tm.vx.getters().getConfigs
  137. },
  138. pageConfig() {
  139. return this.haloConfigs.pageConfig.aboutConfig;
  140. },
  141. postDetailConfig() {
  142. return this.haloConfigs.basicConfig.postDetailConfig;
  143. },
  144. bloggerInfo() {
  145. return this.haloConfigs.authorConfig.blogger;
  146. },
  147. calcProfileStyle() {
  148. const _imgUrlOr = this.pageConfig.bgImageUrl;
  149. return {
  150. backgroundImage: `url(${this.$utils.checkImageUrl(_imgUrlOr)})`
  151. }
  152. },
  153. calcWaveUrl() {
  154. return this.$utils.checkImageUrl(this.pageConfig.waveImageUrl);
  155. },
  156. copyrightConfig() {
  157. return this.haloConfigs.basicConfig.copyrightConfig;
  158. },
  159. calcAuditModeEnabled() {
  160. return this.haloConfigs.auditConfig.auditModeEnabled
  161. },
  162. },
  163. watch: {
  164. haloConfigs: {
  165. handler(val) {
  166. if (!val) return;
  167. this.fnGetNavList();
  168. },
  169. deep: true,
  170. immediate: true,
  171. }
  172. },
  173. created() {
  174. this.fnGetData();
  175. },
  176. onPullDownRefresh() {
  177. this.fnGetData();
  178. },
  179. methods: {
  180. async fnGetNavList() {
  181. const systemInfo = uni.getSystemInfoSync();
  182. let _isWx = false;
  183. // #ifdef MP-WEIXIN
  184. _isWx = true;
  185. // #endif
  186. this.navList = [{
  187. key: 'data-visual',
  188. title: '数据看板',
  189. leftIcon: 'icon-chart-bar',
  190. leftIconColor: 'light-blue',
  191. rightText: '站点数据可视化',
  192. path: '/pagesA/data-visual/data-visual',
  193. isAdmin: false,
  194. type: 'page',
  195. show: await checkNeedPluginAvailable(NeedPluginIds.PluginDataStatistics)
  196. },{
  197. key: 'archives',
  198. title: this.calcAuditModeEnabled ? '内容归档' : '文章归档',
  199. leftIcon: 'halocoloricon-classify',
  200. leftIconColor: 'red',
  201. rightText: this.calcAuditModeEnabled ? '全部已归档内容' : '全部已归档文章',
  202. path: '/pagesA/archives/archives',
  203. isAdmin: false,
  204. type: 'page',
  205. show: true
  206. }, {
  207. key: 'love',
  208. title: '恋爱日记',
  209. leftIcon: 'halocoloricon-attent',
  210. leftIconColor: 'red',
  211. rightText: '博主的恋爱日记',
  212. path: '/pagesA/love/love',
  213. isAdmin: false,
  214. type: 'page',
  215. show: this.haloConfigs.loveConfig.loveEnabled
  216. }, {
  217. key: 'vote',
  218. title: '投票中心',
  219. leftIcon: 'icon-box',
  220. leftIconColor: 'red',
  221. rightText: '查看和进行投票',
  222. path: '/pagesA/votes/votes',
  223. isAdmin: false,
  224. type: 'page',
  225. show: !this.calcAuditModeEnabled
  226. }, {
  227. key: 'disclaimers',
  228. title: '友情链接',
  229. leftIcon: 'icon-lianjie',
  230. leftIconColor: 'blue',
  231. rightText: '看看博主朋友们吧',
  232. path: '/pagesA/friend-links/friend-links',
  233. isAdmin: false,
  234. type: 'page',
  235. show: true
  236. },
  237. {
  238. key: 'disclaimers',
  239. title: '免责声明',
  240. leftIcon: 'icon-map',
  241. leftIconColor: 'red',
  242. rightText: '博客内容免责声明',
  243. path: '/pagesA/disclaimers/disclaimers',
  244. isAdmin: false,
  245. type: 'page',
  246. show: this.haloConfigs.basicConfig.disclaimers.enabled
  247. },
  248. {
  249. key: 'contact-blogger',
  250. title: '联系博主',
  251. leftIcon: 'icon-paper-plane',
  252. leftIconColor: 'orange',
  253. rightText: '博主常用联系方式',
  254. path: '/pagesA/contact/contact',
  255. isAdmin: false,
  256. type: 'page',
  257. show: this.haloConfigs.authorConfig.social.enabled
  258. },
  259. {
  260. key: 'session',
  261. title: '在线客服',
  262. leftIcon: 'icon-headset-fill',
  263. leftIconColor: 'cyan',
  264. rightText: '在线客服为您答疑',
  265. path: null,
  266. isAdmin: false,
  267. type: 'page',
  268. openType: 'contact',
  269. show: _isWx
  270. },
  271. {
  272. key: 'feedback',
  273. title: '意见反馈',
  274. leftIcon: 'icon-comment-dots',
  275. leftIconColor: 'light-blue',
  276. rightText: '提交系统使用反馈',
  277. path: null,
  278. isAdmin: false,
  279. type: 'page',
  280. openType: 'feedback',
  281. show: _isWx
  282. },
  283. {
  284. key: 'about',
  285. title: '关于项目',
  286. leftIcon: 'icon-exclamation-circle',
  287. leftIconColor: 'blue',
  288. rightText: '小莫唐尼开源项目',
  289. path: '/pagesA/about/about',
  290. isAdmin: false,
  291. type: 'page',
  292. show: this.haloConfigs.basicConfig.showAboutSystem
  293. },
  294. // {
  295. // key: 'cache',
  296. // title: '清除缓存',
  297. // leftIcon: 'icon-delete',
  298. // leftIconColor: 'gray',
  299. // rightText: uni.getStorageInfoSync().currentSize + 'KB',
  300. // path: 'clear',
  301. // isAdmin: false,
  302. // type: 'poup',
  303. // show: true
  304. // },
  305. // {
  306. // key: 'update',
  307. // title: '版本更新',
  308. // leftIcon: 'icon-clouddownload',
  309. // leftIconColor: 'pink',
  310. // rightText: `当前版本 v${systemInfo.appVersion}`,
  311. // path: 'update',
  312. // isAdmin: false,
  313. // type: 'poup',
  314. // show: true
  315. // },
  316. ];
  317. },
  318. fnGetData() {
  319. this.$httpApi.v2
  320. .getBlogStatistics()
  321. .then(res => {
  322. this.statistics = res;
  323. })
  324. .catch(err => {
  325. this.$tm.toast('数据加载失败,请重试!');
  326. })
  327. .finally(() => {
  328. uni.stopPullDownRefresh();
  329. });
  330. },
  331. fnOnNav(data) {
  332. const {
  333. type,
  334. path,
  335. isAdmin,
  336. openType
  337. } = data;
  338. if (openType) {
  339. // #ifndef MP-WEIXIN
  340. return uni.$tm.toast('仅支持微信小程序打开!');
  341. // #endif
  342. // #ifdef MP-WEIXIN
  343. return;
  344. // #endif
  345. }
  346. if (!path) return;
  347. // 拦截后台管理页面(插件拦截不友好,无法阻断)
  348. if (isAdmin && !checkHasAdminLogin()) {
  349. uni.$eShowModal({
  350. title: '提示',
  351. content: '未登录超管账号或登录状态已过期,是否立即登录?',
  352. showCancel: true,
  353. cancelText: '否',
  354. cancelColor: '#999999',
  355. confirmText: '是',
  356. confirmColor: '#03a9f4'
  357. })
  358. .then(res => {
  359. uni.navigateTo({
  360. url: '/pagesB/login/login'
  361. });
  362. })
  363. .catch(err => {});
  364. return;
  365. }
  366. if (type == 'poup') {
  367. switch (path) {
  368. case 'clear':
  369. uni.$eShowModal({
  370. title: '提示',
  371. content: '清除后可能退出您当前的登录或已授权状态,是否确定清除缓存吗?',
  372. showCancel: true,
  373. cancelText: '否',
  374. cancelColor: '#999999',
  375. confirmText: '是',
  376. confirmColor: '#03a9f4'
  377. })
  378. .then(res => {
  379. uni.clearStorageSync();
  380. this.navList.find(x => x.key == 'cache').rightText =
  381. uni.getStorageInfoSync().currentSize + 'KB';
  382. })
  383. .catch(err => {});
  384. break;
  385. case 'update':
  386. // #ifdef APP-PLUS
  387. CheckAppUpdate();
  388. // #endif
  389. // #ifdef MP-WEIXIN
  390. CheckWxUpdate(true);
  391. // #endif
  392. // #ifndef APP-PLUS|| MP-WEIXIN
  393. uni.showToast({
  394. icon: 'none',
  395. title: '版本无需更新!'
  396. });
  397. // #endif
  398. break;
  399. }
  400. } else if (type == 'page') {
  401. uni.navigateTo({
  402. url: path
  403. })
  404. }
  405. },
  406. // 快捷导航页面跳转
  407. fnToNavPage(item) {
  408. // 判断是内置页面还是网页
  409. if (this.$utils.checkIsUrl(item.path)) {
  410. uni.navigateTo({
  411. url: '/pagesC/website/website?data=' +
  412. JSON.stringify({
  413. title: item.text || this.$haloConfig.title,
  414. url: encodeURIComponent(item.path)
  415. })
  416. });
  417. return;
  418. }
  419. switch (item.type) {
  420. case 'tabbar':
  421. uni.switchTab({
  422. url: item.path
  423. });
  424. break;
  425. case 'page':
  426. uni.navigateTo({
  427. url: item.path
  428. });
  429. break;
  430. }
  431. },
  432. fnOnToAdTest(path) {
  433. uni.navigateTo({
  434. url: path
  435. });
  436. }
  437. }
  438. };
  439. </script>
  440. <style scoped lang="scss">
  441. .app-page {
  442. width: 100vw;
  443. min-height: 100vh;
  444. }
  445. .blogger-info {
  446. position: relative;
  447. width: 100%;
  448. height: 600rpx;
  449. background-size: cover;
  450. background-repeat: no-repeat;
  451. &:before {
  452. content: '';
  453. width: 100%;
  454. height: 100%;
  455. position: absolute;
  456. background-color: rgba(0, 0, 0, 0.3);
  457. background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAAECAYAAACp8Z5+AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAKUlEQVQImU3IMREAIAgAwJfNkQCEsH8cijjpMf6vnXlQaIiJFx+omEBfmqIEZLe2jzcAAAAASUVORK5CYII=);
  458. z-index: 0;
  459. }
  460. .avatar {
  461. position: absolute;
  462. top: 200rpx;
  463. left: 50%;
  464. transform: translateX(-50%);
  465. width: 130rpx;
  466. height: 130rpx;
  467. border-radius: 50%;
  468. border: 6rpx solid #ffffff;
  469. }
  470. .profile {
  471. width: 100%;
  472. position: absolute;
  473. top: 340rpx;
  474. left: 0;
  475. z-index: 6;
  476. color: #fff;
  477. text-align: center;
  478. }
  479. .gif-wave {
  480. position: absolute;
  481. width: 100%;
  482. bottom: 0;
  483. left: 0;
  484. z-index: 99;
  485. mix-blend-mode: screen;
  486. height: 100rpx;
  487. }
  488. }
  489. .profile-card {
  490. position: relative;
  491. background-color: #fff;
  492. overflow: hidden;
  493. &_label {
  494. width: 120rpx;
  495. position: absolute;
  496. top: 8rpx;
  497. left: -36rpx;
  498. transform: rotateZ(-45deg);
  499. text-align: center;
  500. color: #ffffff;
  501. }
  502. .left {
  503. width: 260rpx;
  504. .avatar {
  505. width: 130rpx;
  506. height: 130rpx;
  507. border-radius: 50%;
  508. }
  509. }
  510. .right {
  511. width: 0;
  512. flex-grow: 1;
  513. .photos {
  514. &-img {
  515. width: 130rpx;
  516. height: 130rpx;
  517. }
  518. }
  519. .photos-img+.photos-img {
  520. margin-left: 12rpx;
  521. }
  522. }
  523. }
  524. .statistics-wrap {
  525. box-shadow: 0rpx 2rpx 24rpx rgba(0, 0, 0, 0.03);
  526. border-radius: 0rpx 0rpx 24rpx 24rpx;
  527. overflow: hidden;
  528. .statistics {
  529. &.has-solid {
  530. .item+.item {
  531. border-left: 2rpx solid #fafafa;
  532. }
  533. }
  534. &.solid-top {
  535. position: relative;
  536. &:before {
  537. content: '';
  538. position: absolute;
  539. top: 0;
  540. left: 36rpx;
  541. right: 36rpx;
  542. height: 2rpx;
  543. background-color: #fafafa;
  544. }
  545. }
  546. }
  547. }
  548. .quick-nav {
  549. background-color: #fff;
  550. box-sizing: border-box;
  551. box-shadow: 0rpx 2rpx 24rpx rgba(0, 0, 0, 0.03);
  552. .name {
  553. color: var(--main-text-color);
  554. }
  555. .icon {
  556. border-radius: 50%;
  557. font-size: 80rpx;
  558. }
  559. }
  560. .nav-wrap {
  561. box-shadow: 0rpx 2rpx 24rpx rgba(0, 0, 0, 0.03);
  562. background-color: #fff;
  563. }
  564. .copyright {
  565. color: #c0c4c7;
  566. }
  567. .right-value-btn {
  568. background-color: transparent;
  569. border: none;
  570. padding: 0;
  571. margin: 0;
  572. font-size: 24rpx;
  573. color: #c0c4c7;
  574. border-radius: 0;
  575. line-height: initial;
  576. &::after {
  577. border: none;
  578. border-radius: 0;
  579. transform: initial;
  580. }
  581. }
  582. </style>