about.vue 20 KB

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