about.vue 16 KB

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