index.vue 5.7 KB

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