list.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. <template>
  2. <view>
  3. <uni-nav-bar id="nav-bar" status-bar="true" @clickLeft="onBack()" :title="title" color="#000000" fixed="true" :border="false">
  4. <view slot="left">
  5. <view class=" flex align-center margin-left">
  6. <image class="p-left-arrow" src="../../../static/p-left-arrow.png"></image>
  7. </view>
  8. </view>
  9. </uni-nav-bar>
  10. <view class="card-view game-item" v-for="(item,index) in list" :key="index">
  11. <!-- <view class="only-arrow"> -->
  12. <view class="content" @tap="onNavTo(item)">
  13. <image :src="item.gameIcon" class="png" ></image>
  14. <text class="text-black text-bold ">{{item.gameName}}</text>
  15. <view class="only-arrow"></view>
  16. </view>
  17. <!-- </view> -->
  18. </view>
  19. <view v-if="bDontUpdate" class="text-16px text-gray text-center margin">- 没有更多数据 -</view>
  20. </view>
  21. </template>
  22. <script>
  23. import reqUtil from "@/util/util-js/requstUtil.js"
  24. import config from "@/common/config.js"
  25. export default {
  26. data() {
  27. return {
  28. list: [],
  29. title: "最近在玩",
  30. type:'',
  31. page:1,
  32. size:10,
  33. bDontUpdate:false,
  34. }
  35. },
  36. onLoad(option) {
  37. let that = this;
  38. if (option&&option.type) {
  39. that.type = option.type;
  40. that.onGetData();
  41. }
  42. },
  43. methods: {
  44. onNavTo(item) {
  45. let temItem = encodeURIComponent(JSON.stringify(item));
  46. uni.navigateTo({
  47. url: "../../game-page/game-detail/game-detail?item=" + temItem
  48. })
  49. },
  50. onBack() {
  51. uni.navigateBack({
  52. delta: 1
  53. })
  54. },
  55. onReachBottom(){
  56. if(this.bDontUpdate) return;
  57. this.page++;
  58. this.onGetData();
  59. },
  60. onGetData(){
  61. let that = this;
  62. uni.showToast({
  63. title:'',
  64. icon:'loading',
  65. mask:true,
  66. duration:10000
  67. })
  68. if (that.type == 'recently') {
  69. that.title = "最近在玩";
  70. reqUtil.requestData(config.URL.RECENTLYPLAYINGGET,{
  71. page:that.page,
  72. size:that.size
  73. }).then(res => {
  74. console.log('RECENTLYPLAYINGGET =====', res);
  75. if (res.code == 0) {
  76. if(res.data.gameList.length < that.size){
  77. that.bDontUpdate = true;
  78. }
  79. that.list = that.list.concat(res.data.gameList);
  80. }
  81. uni.hideToast();
  82. },
  83. e => {
  84. uni.hideToast();
  85. console.log(e)
  86. });
  87. } else if (that.type == 'watchGame') {
  88. that.title = "关注的游戏";
  89. reqUtil.requestData(config.URL.FAVORITESGET,{
  90. page:that.page,
  91. size:that.size
  92. }).then(res => {
  93. console.log('FAVORITESADD =====', res);
  94. if (res.code == 0) {
  95. if(res.data.gameList.length < that.size){
  96. that.bDontUpdate = true;
  97. }
  98. that.list = that.list.concat(res.data.gameList);
  99. }
  100. uni.hideToast();
  101. },
  102. e => {
  103. uni.hideToast();
  104. console.log(e)
  105. });
  106. }
  107. }
  108. }
  109. }
  110. </script>
  111. <style>
  112. .content {
  113. display: flex;
  114. flex-direction: row;
  115. align-items: center;
  116. height: 98px;
  117. }
  118. .content image {
  119. width: 71px;
  120. height: 71px;
  121. margin-left: 40rpx;
  122. margin-right: 40rpx;
  123. border-radius: 12px;
  124. }
  125. .game-item {
  126. position: relative;
  127. background-color: #FFFFFF;
  128. border-radius: 10px;
  129. }
  130. </style>