myHome.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430
  1. <template>
  2. <view class="container">
  3. <!-- 页面标题 -->
  4. <view class="title" :style="{ height: customBarH * 2 + 'rpx', top: statusBarH * 2 + 'rpx' }" v-if="!headerType">个人主页</view>
  5. <view class="title_icon" :style="{ height: customBarH * 2 + 'rpx', top: statusBarH * 2 + 'rpx' }" v-if="!headerType" @click="handleBack">
  6. <img src="../../static/index/left.png" />
  7. </view>
  8. <view class="title" :style="{ height: customBarH * 2 + 'rpx', paddingTop: statusBarH * 2 + 'rpx', backgroundColor: '#fff', color: '#000' }" v-if="headerType">
  9. 个人主页
  10. </view>
  11. <view class="title_icon" :style="{ height: customBarH * 2 + 'rpx', top: statusBarH * 2 + 'rpx' }" v-if="headerType" @click="handleBack">
  12. <img src="../../static/index/left2.png" />
  13. </view>
  14. <!-- 顶部用户信息区域 -->
  15. <view class="header">
  16. <img src="https://chtech.ncjti.edu.cn/hotelReservation/image/18.png" />
  17. <!-- 头像区域 -->
  18. <img class="img" mode="aspectFill" :src="userInfo.headPhoto || '../../static/my/portrait.png'" />
  19. <!-- 姓名区域 -->
  20. <view class="name">{{ userInfo.user_name }}</view>
  21. <!-- 用户id区域 -->
  22. <view class="number">ID:{{ userInfo.id }}</view>
  23. <!-- 简介区域 -->
  24. <view class="desc" v-if="!showInput" @click="showInput = true">点击这里,填写简介</view>
  25. <view class="desc_input" v-else>
  26. <input type="text" auto-focus placeholder-style="color:#ccc" placeholder="请输入简介" @blur="handleBlur" @confirm="handleClickDesc" />
  27. </view>
  28. <!-- 粉丝 关注 获赞 区域 -->
  29. <view class="info">
  30. <!-- 粉丝区域 -->
  31. <view class="info_box">
  32. <view class="box_num">17</view>
  33. <view class="box_key">粉丝</view>
  34. </view>
  35. <!-- 关注区域 -->
  36. <view class="info_box">
  37. <view class="box_num">18</view>
  38. <view class="box_key">关注</view>
  39. </view>
  40. <!-- 获赞区域 -->
  41. <view class="info_box">
  42. <view class="box_num">12</view>
  43. <view class="box_key">获赞</view>
  44. </view>
  45. </view>
  46. </view>
  47. <!-- 内容区域 -->
  48. <view class="body">
  49. <!-- 分段器区域 -->
  50. <view class="control">
  51. <uni-segmented-control :current="current" :values="items" style-type="text" active-color="#096562" @clickItem="onClickItem" />
  52. </view>
  53. <!-- 推文列表区域 -->
  54. <view class="list">
  55. <!-- 每一个推文区域 -->
  56. <view class="item_box" v-for="item in list" :key="item.id">
  57. <!-- 视频推文 -->
  58. <view class="box_video" v-if="item.type === 'video'">
  59. <video :src="item.url"></video>
  60. </view>
  61. <!-- 图片推文 -->
  62. <view class="box_image" v-if="item.type === 'image'">
  63. <view class="image_box" v-for="(ele, index) in item.url" :key="index">
  64. <img mode="acpectFill" :src="ele" />
  65. </view>
  66. </view>
  67. <!-- 标题区域 -->
  68. <view class="box_title">{{ item.title }}</view>
  69. <view class="box_info">
  70. <view class="info_time">{{ item.time }}</view>
  71. <view class="info_town">{{ item.town }}</view>
  72. <img class="img" src="../../static/index/upvote.png" />
  73. <view class="info_like">{{ item.like }}</view>
  74. <img class="img2" src="../../static/index/comment.png" />
  75. <view class="info_comment">{{ item.comment }}</view>
  76. <!-- 审核中印章区域 -->
  77. <img v-if="current === 1" class="box_audit" src="../../static/index/audit.png" />
  78. <!-- 已驳回印章区域 -->
  79. <img v-if="current === 2" class="box_rejected" src="../../static/index/rejected.png" />
  80. </view>
  81. </view>
  82. </view>
  83. </view>
  84. </view>
  85. </template>
  86. <script>
  87. export default {
  88. data() {
  89. return {
  90. // 用户信息
  91. userInfo: {},
  92. // 状态栏高度
  93. statusBarH: 0,
  94. // 胶囊按钮栏高度
  95. customBarH: 0,
  96. // 顶部页面标题栏显示隐藏控制
  97. headerType: false,
  98. // 简介输入框显示隐藏控制
  99. showInput: false,
  100. current: 0,
  101. items: ['全部推文', '审核中', '驳回'],
  102. list: [
  103. {
  104. id: 1,
  105. title: '靖安最美的景色,绝对值得来',
  106. time: '09-20',
  107. town: '双溪镇',
  108. like: 99,
  109. comment: 24,
  110. type: 'image',
  111. url: [
  112. 'https://chtech.ncjti.edu.cn/hotelReservation/fileload/download/1933617026前台.jpg',
  113. 'https://chtech.ncjti.edu.cn/hotelReservation/fileload/download/1933617026前台.jpg',
  114. 'https://chtech.ncjti.edu.cn/hotelReservation/fileload/download/1933617026前台.jpg',
  115. 'https://chtech.ncjti.edu.cn/hotelReservation/fileload/download/1933617026前台.jpg',
  116. 'https://chtech.ncjti.edu.cn/hotelReservation/fileload/download/1933617026前台.jpg',
  117. 'https://chtech.ncjti.edu.cn/hotelReservation/fileload/download/1933617026前台.jpg'
  118. ]
  119. },
  120. {
  121. id: 2,
  122. title: '靖安最美的景色,绝对值得来',
  123. time: '09-20',
  124. town: '双溪镇',
  125. like: 66,
  126. comment: 26,
  127. type: 'video',
  128. url: 'https://jinganminsu-1320402385.cos.ap-nanjing.myqcloud.com/static//20230927113127_ytGv5IurFspj2d102676797c75b76ac4d13238401c8f.mp4'
  129. },
  130. {
  131. id: 3,
  132. title: '靖安最美的景色,绝对值得来',
  133. time: '09-20',
  134. town: '双溪镇',
  135. like: 66,
  136. comment: 26,
  137. type: 'video',
  138. url: 'https://jinganminsu-1320402385.cos.ap-nanjing.myqcloud.com/static//20230927113127_ytGv5IurFspj2d102676797c75b76ac4d13238401c8f.mp4'
  139. },
  140. {
  141. id: 4,
  142. title: '靖安最美的景色,绝对值得来',
  143. time: '09-20',
  144. town: '双溪镇',
  145. like: 99,
  146. comment: 24,
  147. type: 'image',
  148. url: ['https://chtech.ncjti.edu.cn/hotelReservation/fileload/download/1933617026前台.jpg']
  149. }
  150. ]
  151. }
  152. },
  153. created() {
  154. // 获取系统信息
  155. uni.getSystemInfo({
  156. success: (e) => {
  157. // 获取状态栏高度
  158. this.statusBarH = e.statusBarHeight + 10
  159. // // 获取菜单按钮栏高度
  160. let custom = uni.getMenuButtonBoundingClientRect()
  161. this.customBarH = custom.height + 10
  162. }
  163. })
  164. },
  165. onPageScroll(e) {
  166. if (e.scrollTop > 50) {
  167. this.headerType = true
  168. } else {
  169. this.headerType = false
  170. }
  171. },
  172. onShow() {
  173. this.userInfo = uni.getStorageSync('userInfo')
  174. },
  175. methods: {
  176. handleBack() {
  177. uni.navigateBack(1)
  178. },
  179. handleClickDesc(e) {
  180. console.log(e.detail)
  181. this.showInput = false
  182. },
  183. handleBlur() {
  184. this.showInput = false
  185. },
  186. onClickItem(e) {
  187. this.current = e.currentIndex
  188. }
  189. }
  190. }
  191. </script>
  192. <style lang="scss" scoped>
  193. .container {
  194. position: relative;
  195. min-height: 100vh;
  196. .title {
  197. z-index: 999;
  198. position: fixed;
  199. top: 0;
  200. left: 0;
  201. right: 0;
  202. font-size: 28rpx;
  203. color: #fff;
  204. text-align: center;
  205. }
  206. .title_icon {
  207. z-index: 999;
  208. position: fixed;
  209. top: 0;
  210. left: 10rpx;
  211. right: 0;
  212. img {
  213. width: 47rpx;
  214. height: 47rpx;
  215. }
  216. }
  217. .header {
  218. position: relative;
  219. height: 510rpx;
  220. color: #fff;
  221. overflow: hidden;
  222. img {
  223. width: 100%;
  224. height: 100%;
  225. }
  226. .img {
  227. position: absolute;
  228. top: 190rpx;
  229. left: 32rpx;
  230. width: 140rpx;
  231. height: 140rpx;
  232. border-radius: 50%;
  233. }
  234. .name {
  235. position: absolute;
  236. top: 200rpx;
  237. left: 202rpx;
  238. font-size: 40rpx;
  239. font-weight: bold;
  240. }
  241. .number {
  242. position: absolute;
  243. top: 265rpx;
  244. left: 202rpx;
  245. font-size: 24rpx;
  246. opacity: 0.5;
  247. }
  248. .desc {
  249. position: absolute;
  250. top: 350rpx;
  251. left: 32rpx;
  252. font-size: 28rpx;
  253. color: #fff;
  254. }
  255. .desc_input {
  256. position: absolute;
  257. top: 350rpx;
  258. left: 32rpx;
  259. width: 300rpx;
  260. height: 40rpx;
  261. line-height: 40rpx;
  262. font-size: 28rpx;
  263. border-radius: 15rpx;
  264. border: 1rpx solid #fff;
  265. input {
  266. box-sizing: border-box;
  267. padding: 0 10rpx;
  268. width: 100%;
  269. height: 100%;
  270. }
  271. }
  272. .info {
  273. position: absolute;
  274. top: 410rpx;
  275. left: 0rpx;
  276. display: flex;
  277. font-size: 28rpx;
  278. color: #fff;
  279. .info_box {
  280. display: flex;
  281. flex-direction: column;
  282. align-items: center;
  283. padding: 0 20rpx 0 35rpx;
  284. .box_num {
  285. }
  286. .box_key {
  287. }
  288. }
  289. }
  290. }
  291. .body {
  292. position: absolute;
  293. top: 510rpx;
  294. box-sizing: border-box;
  295. width: 100%;
  296. min-height: calc(100vh - 510rpx);
  297. border-radius: 20rpx 20rpx 0 0;
  298. background-color: #f7f7f7;
  299. .control {
  300. padding: 0 100rpx;
  301. height: 95rpx;
  302. background-color: #fff;
  303. }
  304. .list {
  305. padding: 20rpx 30rpx;
  306. .item_box {
  307. margin-bottom: 22rpx;
  308. padding-bottom: 30rpx;
  309. width: 690rpx;
  310. border-radius: 12rpx;
  311. border-bottom: 1rpx solid #e6e6e6;
  312. background-color: #fff;
  313. .box_video {
  314. height: 335rpx;
  315. border-radius: 12rpx;
  316. background-color: skyblue;
  317. video {
  318. width: 100%;
  319. height: 100%;
  320. }
  321. }
  322. .box_image {
  323. display: grid;
  324. grid-template-columns: repeat(3, 1fr);
  325. grid-auto-rows: auto;
  326. gap: 20rpx;
  327. .image_box {
  328. width: 216rpx;
  329. height: 126rpx;
  330. img {
  331. width: 100%;
  332. height: 100%;
  333. border-radius: 12rpx;
  334. }
  335. }
  336. }
  337. .box_title {
  338. padding: 10rpx 25rpx;
  339. font-size: 28rpx;
  340. font-weight: bold;
  341. }
  342. .box_info {
  343. position: relative;
  344. display: flex;
  345. align-items: center;
  346. padding-left: 25rpx;
  347. color: #999999;
  348. font-size: 24rpx;
  349. .info_time {
  350. }
  351. .info_town {
  352. margin-left: 15rpx;
  353. }
  354. .img {
  355. margin-left: auto;
  356. width: 28rpx;
  357. height: 28rpx;
  358. }
  359. .info_like {
  360. margin-left: 10rpx;
  361. }
  362. .img2 {
  363. margin-left: 15rpx;
  364. width: 25rpx;
  365. height: 25rpx;
  366. }
  367. .info_comment {
  368. margin: 0 10rpx;
  369. }
  370. .box_audit {
  371. position: absolute;
  372. top: -45rpx;
  373. left: 410rpx;
  374. width: 100rpx;
  375. height: 100rpx;
  376. }
  377. .box_rejected {
  378. position: absolute;
  379. top: -45rpx;
  380. left: 410rpx;
  381. width: 100rpx;
  382. height: 100rpx;
  383. }
  384. }
  385. }
  386. }
  387. }
  388. }
  389. </style>