index.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. <template>
  2. <view class="container">
  3. <image class="headImg" mode="aspectFill" :src="$fileUrl() + '/homeHead.jpeg'"></image>
  4. <view class="headBarrage">
  5. <l-barrage :data="barrageData" :defer="1" :loopCount="6">
  6. <template #default="{content}">
  7. <view class="bullet">{{content.text}}</view>
  8. </template>
  9. </l-barrage>
  10. </view>
  11. <view class="tabs">
  12. <view class="tab">
  13. <image :src="$fileUrl() + '/Frame3.png'" alt="">
  14. <span>全部</span>
  15. </view>
  16. <view class="tab" @click="$navigateTo('/pages/excellentValue/excellentValue')">
  17. <image :src="$fileUrl() + '/Frame4.png'" alt="">
  18. <span>超值挑战</span>
  19. </view>
  20. <view class="tab">
  21. <image :src="$fileUrl() + '/Frame2.png'" alt="">
  22. <span>拍卖专区</span>
  23. </view>
  24. <view class="tab">
  25. <image :src="$fileUrl() + '/Frame1.png'" alt="">
  26. <span>VIP福利</span>
  27. </view>
  28. </view>
  29. <view class="buttons">
  30. <view class="left">
  31. <image :src="$fileUrl() + '/button3.png'" @click="toInvite" mode="widthFix"></image>
  32. </view>
  33. <view class="right">
  34. <image :src="$fileUrl() + '/button1.png'" mode="widthFix"></image>
  35. <image :src="$fileUrl() + '/button2.png'"
  36. @click="$navigateTo('/pages/raffle/raffle')" mode="widthFix"></image>
  37. </view>
  38. </view>
  39. <view class="list-title">
  40. - 热门推荐 -
  41. </view>
  42. <view class="list">
  43. <view class="ka" v-for="(item, index) in kaList">
  44. <view class="top">
  45. <image mode="aspectFit" :src="$fileUrl() + '/ka.jpeg'"></image>
  46. </view>
  47. <view class="ka-info">
  48. <view class="ka-name">
  49. 宝可梦简中原盒拆拆乐
  50. </view>
  51. <view class="row">
  52. <uni-tag text="创意热销" inverted type="default"></uni-tag>
  53. <view class="money">
  54. ¥9.9
  55. </view>
  56. </view>
  57. </view>
  58. </view>
  59. </view>
  60. </view>
  61. </template>
  62. <script>
  63. import {
  64. messageListApi
  65. } from "@/api/common.js"
  66. export default {
  67. data() {
  68. return {
  69. kaList: 6,
  70. messageList: [],
  71. barrageData: [],
  72. barrageIndex: 0,
  73. timeOut: null,
  74. interval: null,
  75. params: {
  76. limit: 20,
  77. page: 1,
  78. },
  79. total: null,
  80. }
  81. },
  82. onLoad(query) {
  83. if (query.inviteId) {
  84. getApp().globalData.inviteId = query.inviteId;
  85. } else {
  86. const scene = decodeURIComponent(query.scene)
  87. let inviteId = scene.split("=")[1]
  88. console.log(inviteId, 'inviteId')
  89. getApp().globalData.inviteId = inviteId;
  90. }
  91. },
  92. onShow() {
  93. this.getMessage()
  94. this.interval = setInterval(() => {
  95. console.log('重复获取消息')
  96. this.barrageIndex = 0
  97. this.getMessage()
  98. // let num = this.params.page * this.params.limit
  99. // if (this.total == null || this.total > num) {
  100. // console.log('获取消息接口')
  101. // // this.params.page += 1
  102. // this.barrageIndex = 0
  103. // this.getMessage()
  104. // }
  105. }, 60000)
  106. },
  107. onHide() {
  108. clearInterval(this.interval)
  109. },
  110. methods: {
  111. getMessage() {
  112. messageListApi(this.params).then(res => {
  113. this.messageList = res.data.list
  114. this.total = res.data.total
  115. this.initBarrage()
  116. })
  117. },
  118. // 初始化弹幕
  119. initBarrage() {
  120. let _this = this
  121. // console.log(_this.barrageIndex, '_this.barrageIndex')
  122. if (_this.messageList.length > 0) {
  123. _this.timeOut = setTimeout(() => {
  124. _this.barrageData.push({
  125. text: _this.messageList[_this.barrageIndex].content
  126. })
  127. // console.log(_this.barrageData, '_this.barrageData')
  128. _this.barrageIndex += 1
  129. clearTimeout(_this.timeOut)
  130. if (_this.barrageIndex > _this.messageList.length - 1) {
  131. _this.barrageIndex = 0
  132. } else {
  133. _this.initBarrage()
  134. }
  135. }, 1000)
  136. }
  137. },
  138. // 发送弹幕
  139. sendingBarrage() {
  140. let messageList = this.messageList
  141. },
  142. toInvite() {
  143. wx.navigateTo({
  144. url: '/pages/invite/invite'
  145. })
  146. }
  147. }
  148. }
  149. </script>
  150. <style scoped lang="scss">
  151. .container {
  152. /* padding: 20px; */
  153. font-size: 14px;
  154. line-height: 24px;
  155. }
  156. .headImg {
  157. height: 180px;
  158. width: 100%;
  159. }
  160. .headBarrage {
  161. height: 180px;
  162. width: 100%;
  163. position: absolute;
  164. top: 0;
  165. }
  166. .tabs {
  167. display: flex;
  168. justify-content: space-around;
  169. margin-top: 10px;
  170. >.tab {
  171. width: 20%;
  172. display: flex;
  173. flex-direction: column;
  174. justify-content: center;
  175. align-items: center;
  176. >image {
  177. width: 40px;
  178. height: 40px;
  179. }
  180. }
  181. }
  182. .buttons {
  183. margin-top: 5px;
  184. padding: 10px;
  185. display: flex;
  186. justify-content: space-between;
  187. >.left {
  188. width: calc(50vw - 15px);
  189. height: 40vw;
  190. image {
  191. width: 100%;
  192. height: 100%;
  193. }
  194. }
  195. >.right {
  196. width: calc(50vw - 15px);
  197. height: 40vw;
  198. display: flex;
  199. flex-direction: column;
  200. justify-content: space-between;
  201. align-items: center;
  202. image {
  203. width: 100%;
  204. height: calc(50% - 5px);
  205. }
  206. }
  207. }
  208. .list-title {
  209. font-size: 16px;
  210. font-weight: 600;
  211. text-align: center;
  212. padding: 10px;
  213. }
  214. .list {
  215. display: grid;
  216. grid-template-columns: 1fr 1fr;
  217. grid-gap: 10px;
  218. padding: 10px;
  219. .ka {
  220. width: calc(50vw - 15px);
  221. box-shadow: 0px 2px 8px 2px rgba(0, 0, 0, 0.1);
  222. border-radius: 10px;
  223. // height: 60vw;
  224. .top {
  225. // height: 60vw;
  226. background: linear-gradient(180deg, #FAF1A7 0%, #FFE456 100%);
  227. text-align: center;
  228. display: flex;
  229. justify-content: center;
  230. image {
  231. width: 35vw;
  232. height: 50vw;
  233. }
  234. }
  235. .ka-info {
  236. padding: 10px;
  237. .ka-name {
  238. font-size: 15px;
  239. font-weight: 600;
  240. }
  241. .row {
  242. margin-top: 5px;
  243. display: flex;
  244. justify-content: space-between;
  245. .money {
  246. font-size: 16px;
  247. font-weight: 600;
  248. color: #FF2C43;
  249. }
  250. }
  251. }
  252. }
  253. }
  254. .bullet {
  255. height: 30px;
  256. line-height: 30px;
  257. padding: 0 10px;
  258. border-radius: 15px;
  259. background-color: rgba(0, 0, 0, 0.3);
  260. color: #fff;
  261. }
  262. </style>