myHome.vue 10 KB

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