homepage.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  1. <template>
  2. <view class="full-container">
  3. <uni-nav-bar id="nav-bar" status-bar="true" @clickLeft="onBack()"
  4. title="我的" color="#000000" fixed="true" :border="false">
  5. <view slot="left">
  6. <view class=" flex align-center margin-left">
  7. <image class="p-left-arrow" src="../../../static/p-left-arrow.png"></image>
  8. </view>
  9. </view>
  10. </uni-nav-bar>
  11. <!-- <view class="cu-bar ">
  12. <view class="action">
  13. </view>
  14. <view class="action">
  15. <text class="text-df text-purple" @tap="onNavUser">编辑</text>
  16. </view>
  17. </view> -->
  18. <image class="bg-image" src="../../../static/loginBg.png" mode="aspectFill"></image>
  19. <view class="card-view flex align-center " style="position: relative; margin-top: 113px;">
  20. <view class="avatar-size">
  21. <image class="avatar-img round" :src="avatarUrl"></image>
  22. </view>
  23. <view class="avatar-group text-upload">
  24. <view class="text-lg flex justify-between align-center justify-center">
  25. <text class="text-black text-bold">{{userName}}</text>
  26. <text class="text-black">达标{{days}}天</text>
  27. </view>
  28. <!-- <view class="text-xs padding-top">
  29. <text class="text-black">{{days}}</text>
  30. </view> -->
  31. <view class="text-gray padding-top">{{signature}}</view>
  32. </view>
  33. <view class="only-arrow" @tap="onNavUser"></view>
  34. </view>
  35. <view class="card-view article ">
  36. <view class="title">
  37. 最近在玩
  38. </view>
  39. <view class="cu-item shadow">
  40. <view class="cu-form-group margin-top">
  41. <view v-if="playGames.length!=0" class="grid col-3 homepage-grid-square flex-sub ">
  42. <view v-for="(item,index) in playGames" :key="index" v-if="index<6" @tap="onViewImage(item)">
  43. <image class="item-img" :src="item.gameIcon" mode="aspectFill"></image>
  44. <view class="border text-center text-cut">{{item.gameName}}</view>
  45. </view>
  46. </view>
  47. <view v-else class="text-center text-gray" :style="{width:'100%'}">去玩吧~</view>
  48. <view v-if="playGames.length!=0" class="homepage-arrow" @tap="onNavList('recently')"></view>
  49. </view>
  50. </view>
  51. </view>
  52. <view v-if="favoriteGames.length==0" class="card-view flex align-center">
  53. <view class="content flex flex-direction align-start margin-top">
  54. <view class="title">关注</view>
  55. <view class="text-grey" style="margin: 0rpx 40rpx 40rpx;">有好多好玩的视频等着你关注哦</view>
  56. </view>
  57. <view class=" margin-sm button-fav " @tap="onGoToFollow">
  58. <image style="width: 21px;height: 21px; margin-right: 12rpx;" src="../../../static/add_w.png"></image>
  59. 去关注
  60. </view>
  61. </view>
  62. <view v-else class="card-view article">
  63. <view class="title">
  64. 已关注的
  65. </view>
  66. <view class="cu-item shadow">
  67. <view class="cu-form-group margin-top">
  68. <view v-if="favoriteGames.length!=0" class="grid col-3 homepage-grid-square flex-sub ">
  69. <view class="text-center " v-for="(item,index) in favoriteGames" :key="index" v-if="index<6" @tap="onViewImage(item)">
  70. <image class="item-img" :src="item.gameIcon" mode="aspectFill"></image>
  71. <view class="border text-cut">{{item.gameName}}</view>
  72. </view>
  73. </view>
  74. <view v-else class="text-center text-gray" :style="{width:'100%'}">去关注更多的游戏吧~</view>
  75. <view v-if="favoriteGames.length!=0" class="homepage-arrow" @tap="onNavList('watchGame')"></view>
  76. </view>
  77. </view>
  78. </view>
  79. </view>
  80. </template>
  81. <script>
  82. import config from '../../../common/config.js';
  83. import reqUtil from "@/util/util-js/requstUtil.js";
  84. import {
  85. mapState
  86. } from 'vuex'
  87. export default {
  88. computed: mapState(['forcedLogin', 'hasLogin', 'userName', 'avatarUrl', 'playGames', 'favoriteGames', 'days',
  89. 'signature'
  90. ]),
  91. onLoad() {
  92. let that = this;
  93. reqUtil.requestData(config.URL.RECENTLYPLAYINGGET).then(res => {
  94. console.log('RECENTLYPLAYINGGET =====', res);
  95. if (res.code == 0) {
  96. that.$store.state.playGames = res.data.gameList;
  97. }
  98. },
  99. e => {
  100. console.log(e)
  101. });
  102. reqUtil.requestData(config.URL.FAVORITESGET).then(res => {
  103. console.log('FAVORITESADD =====', res);
  104. if (res.code == 0) {
  105. that.$store.state.favoriteGames = res.data.gameList;
  106. }
  107. },
  108. e => {
  109. console.log(e)
  110. });
  111. },
  112. methods: {
  113. onViewImage(item) {
  114. let temItem = encodeURIComponent(JSON.stringify(item));
  115. uni.navigateTo({
  116. url: "../../game-page/game-detail/game-detail?item=" + temItem
  117. })
  118. },
  119. onNavUser() {
  120. uni.navigateTo({
  121. url: '../userInfo/userInfo'
  122. });
  123. },
  124. onNavList(type) {
  125. if (type == "recently" && this.playGames.length == 0) {
  126. uni.showModal({
  127. title: "提示",
  128. content: "没有最近在玩的游戏数据"
  129. })
  130. return;
  131. } else if (type == "watchGame" && this.favoriteGames.length == 0) {
  132. uni.showModal({
  133. title: "提示",
  134. content: "没有关注的游戏数据"
  135. })
  136. return;
  137. }
  138. uni.navigateTo({
  139. url: '../../personal-page/list/list?type='+type
  140. });
  141. },
  142. onGoToFollow() {
  143. // uni.showModal({
  144. // title: "提示",
  145. // content: "功能尚未开放"
  146. // })
  147. uni.navigateTo({
  148. url: '../../game-page/game/game'
  149. });
  150. },
  151. onBack(){
  152. uni.navigateBack({
  153. delta:1
  154. })
  155. }
  156. }
  157. }
  158. </script>
  159. <style>
  160. .avatar-group {
  161. display: flex;
  162. flex-direction: column;
  163. /* justify-content: center; */
  164. /* align-items: center; */
  165. text-align: start;
  166. background-color: #FFFFFF;
  167. display: block;
  168. border-radius: 10rpx;
  169. margin: 0 54rpx 0 30rpx;
  170. width: 100%;
  171. }
  172. .avatar-size {
  173. position: relative;
  174. margin-left: 47rpx;
  175. width: 140rpx;
  176. height: 140rpx;
  177. flex-shrink: 0;
  178. }
  179. .avatar-img {
  180. position: absolute;
  181. top: 0px;
  182. left: 0;
  183. width: 140rpx;
  184. height: 140rpx;
  185. }
  186. .text-upload {
  187. font-size: 13px;
  188. color: rgba(166, 166, 166, 1);
  189. padding: 40px 35rpx 40px 0;
  190. }
  191. .homepage-grid-square {
  192. width: 250rpx;
  193. /* height: 250rpx; */
  194. align-items: start;
  195. }
  196. .homepage-grid-square image {
  197. width: 176rpx;
  198. height: 176rpx;
  199. }
  200. .homepage-arrow {
  201. position: relative;
  202. width: 35rpx;
  203. }
  204. .homepage-arrow::before {
  205. position: absolute;
  206. top: 0;
  207. right: 0upx;
  208. bottom: 0;
  209. display: block;
  210. margin: auto;
  211. width: 30upx;
  212. height: 30upx;
  213. color: #8799a3;
  214. content: "\e6a3";
  215. text-align: center;
  216. font-size: 34upx;
  217. font-family: cuIcon;
  218. line-height: 30upx
  219. }
  220. .button-fav {
  221. background-color: rgba(153, 150, 252, 255);
  222. color: #FFFFFF;
  223. border-radius: 10px;
  224. width: 184rpx;
  225. height: 90rpx;
  226. display: flex;
  227. justify-content: center;
  228. text-align: center;
  229. align-items: center;
  230. }
  231. .title {
  232. text-align: justify;
  233. /* padding: 40rpx 30rpx; */
  234. font-size: 15px;
  235. position: relative;
  236. height: 30px;
  237. line-height: 60upx;
  238. margin: 20rpx 40rpx;
  239. font-weight: 400;
  240. color: rgba(26, 26, 26, 1);
  241. }
  242. .bg-image {
  243. position: absolute;
  244. top: 0;
  245. left: 0;
  246. width: 100%;
  247. height: 159px;
  248. opacity: 1;
  249. }
  250. .border{
  251. width: 176rpx;
  252. font-size: 30rpx;
  253. color:rgba(175, 175, 175, 1);
  254. font-weight: 400;
  255. text-align: center;
  256. margin-top: 22rpx;
  257. margin-bottom: 40rpx;
  258. }
  259. .item-img{
  260. border-radius: 20rpx;
  261. /* border: 1rpx solid #EEEEEE; */
  262. box-shadow: 0px 1px 2px 0px rgba(113, 113, 219, 0.23);
  263. }
  264. </style>