contact.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. <template>
  2. <view class="app-page flex flex-col felx-center bg-white">
  3. <!-- 信息 -->
  4. <view class="profile flex flex-col flex-center pa-36">
  5. <view class="avatar">
  6. <image class="avatar-img" :src="bloggerInfo.avatar" mode="aspectFill"></image>
  7. </view>
  8. <view class="nickname mt-24 text-weight-b text-size-g">{{ bloggerInfo.nickname }}</view>
  9. <view class="desc mt-24 text-size-m text-grey-darken-3">
  10. {{ bloggerInfo.description || '这个博主很懒,竟然没写介绍~' }}
  11. </view>
  12. <!-- 联系图标 -->
  13. <view class="mt-24 contact-icons">
  14. <!-- 放全部:似乎显得有点拥挤 -->
  15. <!-- <block v-for="(item, index) in result" :key="index"><text v-if="item.value" class="halocoloricon" :class="[item.icon, { 'ml-12': index != 0 }]"></text></block> -->
  16. <!-- 考虑放几个常用的就行 -->
  17. <text class="halocoloricon halocoloricon-qq"></text>
  18. <!-- #ifndef MP-QQ -->
  19. <text class="ml-12 halocoloricon halocoloricon-wechat"></text>
  20. <!-- #endif -->
  21. <text class="ml-12 halocoloricon halocoloricon-GitHub"></text>
  22. <text class="ml-12 halocoloricon halocoloricon-gitee"></text>
  23. <text class="ml-12 halocoloricon halocoloricon-ic_email_round"></text>
  24. </view>
  25. </view>
  26. <!-- 社交联系方式列表 -->
  27. <view class="contact ma-50 mt-0 pt-12">
  28. <block v-if="calcIsNotEmpty">
  29. <block v-for="(item, index) in result" :key="index">
  30. <view v-if="item.value" class="item mt-24 flex" @click="fnOnClick(item)">
  31. <view class="left">
  32. <text class="icon halocoloricon" :class="[item.icon]"></text>
  33. <text class="name">{{ item.name }}</text>
  34. </view>
  35. <view class="right flex-1">{{ item.value }}</view>
  36. </view>
  37. </block>
  38. </block>
  39. <view v-else class="mt-12 pt-12">
  40. <tm-empty icon="icon-shiliangzhinengduixiang-" label="暂无联系方式"/>
  41. </view>
  42. </view>
  43. </view>
  44. </template>
  45. <script>
  46. import tmSkeleton from '@/tm-vuetify/components/tm-skeleton/tm-skeleton.vue';
  47. import tmButton from '@/tm-vuetify/components/tm-button/tm-button.vue';
  48. import tmEmpty from '@/tm-vuetify/components/tm-empty/tm-empty.vue';
  49. export default {
  50. components: {
  51. tmSkeleton,
  52. tmButton,
  53. tmEmpty
  54. },
  55. data() {
  56. return {
  57. loading: 'loading',
  58. queryParams: {
  59. size: 10,
  60. page: 0
  61. },
  62. result: [
  63. {
  64. key: 'qq',
  65. icon: 'halocoloricon-qq',
  66. name: '企鹅号',
  67. value: ''
  68. },
  69. {
  70. key: 'wechat',
  71. icon: 'halocoloricon-wechat',
  72. name: '微信号',
  73. value: ''
  74. },
  75. {
  76. key: 'github',
  77. icon: 'halocoloricon-GitHub',
  78. name: 'Github',
  79. value: ''
  80. },
  81. {
  82. key: 'gitee',
  83. icon: 'halocoloricon-gitee',
  84. name: 'Gitee',
  85. value: ''
  86. },
  87. {
  88. key: 'bilibili',
  89. icon: 'halocoloricon-bilibili',
  90. name: 'Bilibili',
  91. value: ''
  92. },
  93. {
  94. key: 'csdn',
  95. icon: 'halocoloricon-csdn1',
  96. name: 'CSDN',
  97. value: ''
  98. },
  99. {
  100. key: 'blog',
  101. icon: 'halocoloricon-url-monitor',
  102. name: '博客地址',
  103. value: ''
  104. },
  105. {
  106. key: 'juejin',
  107. icon: 'halocoloricon-juejin',
  108. name: '掘金地址',
  109. value: ''
  110. },
  111. {
  112. key: 'weibo',
  113. icon: 'halocoloricon-social-weibo',
  114. name: '微博地址',
  115. value: ''
  116. },
  117. {
  118. key: 'email',
  119. icon: 'halocoloricon-ic_email_round',
  120. name: '邮箱地址',
  121. value: ''
  122. }
  123. ]
  124. };
  125. },
  126. computed: {
  127. authorConfig() {
  128. return this.$tm.vx.getters().getConfigs.authorConfig;
  129. },
  130. bloggerInfo() {
  131. let blogger = this.authorConfig.blogger;
  132. blogger.avatar = this.$utils.checkAvatarUrl(blogger.avatar, true);
  133. return blogger;
  134. },
  135. socialConfig() {
  136. return this.authorConfig.social;
  137. },
  138. calcIsNotEmpty() {
  139. return this.result.some((item) => item.value !== "");
  140. }
  141. },
  142. watch: {
  143. socialConfig: {
  144. handler(newVal) {
  145. if (!newVal) return;
  146. this.fnGetData();
  147. },
  148. deep: true,
  149. immediate: true
  150. }
  151. },
  152. onLoad() {
  153. this.fnSetPageTitle('联系博主');
  154. },
  155. methods: {
  156. fnGetData() {
  157. for (let key in this.socialConfig) {
  158. if (key === 'enabled') {
  159. continue;
  160. }
  161. this.result.find(x => x.key === key).value = this.socialConfig[key];
  162. }
  163. },
  164. fnOnClick(item) {
  165. this.$utils.copyText(item.value, item.name + ' 已复制!');
  166. // if (this.globalAppSettings.contact.isLinkCopy && this.$utils.checkIsUrl(item.value)) {
  167. // uni.navigateTo({
  168. // url: '/pagesC/website/website?data=' +
  169. // JSON.stringify({
  170. // title: item.name,
  171. // url: item.value
  172. // })
  173. // });
  174. // } else {
  175. // this.$utils.copyText(item.value, item.name + ' 已复制!');
  176. // }
  177. }
  178. }
  179. };
  180. </script>
  181. <style lang="scss" scoped>
  182. .app-page {
  183. width: 100vw;
  184. min-height: 100vh;
  185. box-sizing: border-box;
  186. padding-top: 160rpx;
  187. }
  188. .profile {
  189. .avatar {
  190. width: 170rpx;
  191. height: 170rpx;
  192. position: relative;
  193. box-sizing: border-box;
  194. border-radius: 50%;
  195. border: 6rpx solid #fff;
  196. box-shadow: 0rpx 2rpx 24rpx rgba(0, 0, 0, 0.07);
  197. overflow: hidden;
  198. &-img {
  199. width: 100%;
  200. height: 100%;
  201. }
  202. }
  203. .nickname {
  204. font-size: 38rpx;
  205. }
  206. }
  207. .contact-icons {
  208. .halocoloricon {
  209. font-size: 42rpx;
  210. }
  211. }
  212. .contact {
  213. box-sizing: border-box;
  214. border-top: 2rpx solid #f2f2f2;
  215. .item {
  216. box-sizing: border-box;
  217. border-radius: 12rpx;
  218. background-color: #fafafa;
  219. // background-color: rgba(0, 0, 0, 0.05);
  220. // padding-bottom: 12rpx;
  221. // border-bottom: 2rpx solid #eee;
  222. padding: 16rpx;
  223. .left {
  224. position: relative;
  225. width: 140rpx;
  226. display: flex;
  227. align-items: center;
  228. box-sizing: border-box;
  229. // background-color: rgba(0, 0, 0, 0.03);
  230. border-radius: 12rpx 0 0 12rpx;
  231. &::after {
  232. display: none;
  233. content: ':';
  234. position: absolute;
  235. right: 18rpx;
  236. top: 50%;
  237. transform: translateY(-50%);
  238. font-size: 24rpx;
  239. color: #666;
  240. }
  241. .icon {
  242. font-size: 24rpx;
  243. }
  244. .name {
  245. margin-left: 10rpx;
  246. color: #555;
  247. font-size: 24rpx;
  248. }
  249. }
  250. .right {
  251. width: 0;
  252. display: flex;
  253. align-items: center;
  254. flex-wrap: wrap;
  255. box-sizing: border-box;
  256. word-wrap: break-word;
  257. word-break: break-all;
  258. font-size: 24rpx;
  259. box-sizing: border-box;
  260. padding-left: 12rpx;
  261. }
  262. }
  263. }
  264. </style>