BBeng.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415
  1. <template>
  2. <view>
  3. <view class="today-recommend">
  4. <view id="topUI">
  5. <!-- 搜索框 -->
  6. <view id="searchBG">
  7. <!-- <view id="searchTip">搜索关键词</view> -->
  8. <input id="searchInput" confirm-type="search" placeholder="搜索关键词" />
  9. <!-- <view id="searchIcon"></view> -->
  10. <image id="searchIcon" src="../../static/bbeng/searchIcon.png"></image>
  11. </view>
  12. <view id="gameClassify">
  13. <!-- 横向选项卡 -->
  14. <wuc-tab :tab-list="data_category" :tabCur.sync="TabCur" @change="tabChange"></wuc-tab>
  15. </view>
  16. <view id="topLine"></view>
  17. <view id="classifyTop">
  18. <view id="classifyTitle">{{classifyTitleStr}}</view>
  19. <view style="display: flex;" @click="clickBluetooth">
  20. <image id="iconBluetooth" :src='blueToothInfoArr[currentBlueToothInfo].src'></image>
  21. <view id="tipBluetooth" :style="{'color':blueToothInfoArr[currentBlueToothInfo].color}">{{blueToothInfoArr[currentBlueToothInfo].text}}</view>
  22. </view>
  23. </view>
  24. </view>
  25. <!-- 游戏列表 -->
  26. <view class="items" v-for="(item,index) in aTodayRecArr" :key="index" @click="clickTodayRecItem(index)">
  27. <view class="content">
  28. <view class="pic">
  29. <image mode="scaleToFill" :src='item.gameIcon'></image>
  30. </view>
  31. <view class="detail">
  32. <text class="title">{{item.gameName}}</text>
  33. <!-- <text class="intro">{{item.gameDescription}}</text> -->
  34. <view class="intro">{{item.gameDescription}}</view>
  35. </view>
  36. <view class="left-arrow">
  37. <image mode="scaleToFill" src="../../static/home/LeftArrow.png"></image>
  38. </view>
  39. </view>
  40. <view class="buttom-box">
  41. <button class="play-btn">开始玩</button>
  42. </view>
  43. </view>
  44. </view>
  45. </view>
  46. </template>
  47. <script>
  48. import WucTab from '@/components/wuc-tab/wuc-tab.vue';
  49. export default {
  50. data() {
  51. return {
  52. aTodayRecArr: [{
  53. "gameName": "音咚",
  54. "gameDescription": "二次元音乐与数码的战斗,戴上你的拳击套击碎音符迸发出来的能量吧",
  55. "gameIcon": "gameIcon/2020-07-26/d1e5292c910f4ca6b767c3400815cec3-eee492f7e18d97a82c2e4ffc98fa95b.png",
  56. "gamePicture": "pictures/2020-07-26/5885c40179ca4f68869a3b60ad082eac-loading.jpg",
  57. "gameUrl": "http://110.43.54.43/t8/",
  58. "createTime": "2020-07-01"
  59. }],
  60. TabCur: 0,
  61. classifyTitleStr: '推荐',
  62. //分类列表
  63. data_category: [{
  64. "categoryId": 1,
  65. "categoryName": "全部",
  66. "categoryType": 0
  67. }],
  68. currentBlueToothInfo: 0,
  69. blueToothInfoArr: [{
  70. src: '../../static/bbeng/iconBluetooth.png',
  71. text: '蓝牙未连接',
  72. color: '#B3B3B3'
  73. },
  74. {
  75. src: '../../static/bbeng/iconBluetoothBlue.png',
  76. text: '蓝牙已连接',
  77. color: '#00A1FF'
  78. },
  79. ],
  80. }
  81. },
  82. onLoad() {
  83. //默认展示第一个分类
  84. this.tabChange(0);
  85. console.log("哔蹦onload");
  86. //请求游戏分类
  87. this.getCategory(this.callbackCategory);
  88. },
  89. components: {
  90. WucTab,
  91. },
  92. methods: {
  93. clickTodayRecItem: function(index) {
  94. // console.log(index);
  95. getApp().globalData.gid = getApp().globalData.gameList[7 + index].id;
  96. this.goToGame();
  97. },
  98. //切换分类
  99. tabChange(index) {
  100. this.TabCur = index;
  101. this.classifyTitleStr = this.data_category[index].categoryName;
  102. // console.log("切换分类",this.data_category);
  103. let categoryType = this.data_category[index].categoryType;
  104. //根据分类获取游戏列表
  105. this.getGameListByCategory(categoryType, 1, 100, this.callbackGameListByCategory);
  106. },
  107. clickBluetooth() {
  108. let newIndex = (this.currentBlueToothInfo + 1) % 2;
  109. this.currentBlueToothInfo = newIndex;
  110. // console.log("新的索引", this.currentBlueToothInfo);
  111. },
  112. //请求游戏分类
  113. getCategory(callback) {
  114. let url = 'https://www.9527fun.cn/api_dev/td/game_category'
  115. // let data_category = this.data_category;
  116. uni.request({
  117. url: url,
  118. method: 'GET',
  119. success: (res) => {
  120. // console.log("分类 ", res);
  121. callback(res.data.data);
  122. },
  123. fail: (res) => {
  124. console.log("fail:====" + res)
  125. // return callback('fail');
  126. }
  127. })
  128. },
  129. //请求游戏分类回调
  130. callbackCategory(res) {
  131. this.data_category = res;
  132. // console.log("分类啦啦啦", this.data_category);
  133. //根据分类获取游戏列表
  134. this.getGameListByCategory(res[0].categoryType, 1, 100, this.callbackGameListByCategory);
  135. },
  136. //根据分类获取游戏列表
  137. getGameListByCategory(categoryType, page, size, callback) {
  138. let url = 'https://www.9527fun.cn/api_dev/td/games_by_category?categoryType=' + categoryType + '&page=' + page +
  139. '&size=' + size;
  140. // let data_category = this.data_category;
  141. uni.request({
  142. url: url,
  143. method: 'GET',
  144. success: (res) => {
  145. // console.log("根据分类获取游戏列表 ", res);
  146. callback(res.data.data);
  147. },
  148. fail: (res) => {
  149. console.log("fail:====" + res)
  150. // return callback('fail');
  151. }
  152. })
  153. },
  154. //根据分类获取游戏列表回调
  155. callbackGameListByCategory(res) {
  156. // this.data_category = res;
  157. // console.log("分类啦啦啦", this.data_category);
  158. // console.log("根据分类获取游戏列表 ", res);
  159. this.aTodayRecArr = res.List;
  160. },
  161. }
  162. }
  163. </script>
  164. <style>
  165. #topUI {
  166. display: flex;
  167. flex-direction: column;
  168. }
  169. #searchBG {
  170. width: 330px;
  171. height: 37px;
  172. background: #EFEFEF;
  173. border-radius: 19px;
  174. display: flex;
  175. flex-direction: row;
  176. align-items: center;
  177. }
  178. #searchInput {
  179. margin-left: 20px;
  180. width: 100%;
  181. }
  182. #searchIcon {
  183. width: 22px;
  184. height: 18px;
  185. /* background: #B3B3B3; */
  186. /* background-image: url(../../static/bbeng/searchIcon.png); */
  187. margin-right: 20px;
  188. margin-left: 10px;
  189. }
  190. #topLine {
  191. width: 317px;
  192. height: 1px;
  193. background: #EBEBEB;
  194. margin-top: 10px;
  195. }
  196. #classifyTop {
  197. display: flex;
  198. /* flex-direction: row; */
  199. margin-top: 20px;
  200. width: 100%;
  201. align-items: center;
  202. /* border: 1px solid blue; */
  203. justify-content: space-between;
  204. }
  205. #classifyTitle {
  206. width: 68px;
  207. height: 24px;
  208. font-size: 17px;
  209. font-family: PingFang-SC-Heavy, PingFang-SC;
  210. font-weight: 800;
  211. color: #414141;
  212. line-height: 24px;
  213. /* border: 1px solid blue; */
  214. }
  215. #iconBluetooth {
  216. width: 20px;
  217. height: 20px;
  218. margin-right: 7px;
  219. /* margin-left: 10px; */
  220. /* border: 1px solid blue; */
  221. }
  222. #tipBluetooth {
  223. width: 70px;
  224. height: 20px;
  225. font-size: 14px;
  226. font-family: PingFangSC-Medium, PingFang SC;
  227. font-weight: 500;
  228. color: #B3B3B3;
  229. line-height: 20px;
  230. /* margin-right: 10px; */
  231. /* border: 1px solid blue; */
  232. }
  233. .today-recommend {
  234. width: 100%;
  235. margin-top: 50rpx;
  236. display: flex;
  237. flex-direction: column;
  238. align-items: center;
  239. justify-content: center;
  240. /* border:1rpx solid red; */
  241. }
  242. .today-recommend .title {
  243. width: 90%;
  244. /* height:62rpx; */
  245. display: flex;
  246. flex-direction: row;
  247. align-items: center;
  248. justify-content: space-between;
  249. /* border:1px solid red; */
  250. }
  251. .today-recommend .title .today {
  252. /* color: #BBBBBB; */
  253. font-size: 40rpx;
  254. font-weight: 700;
  255. }
  256. .today-recommend .title .more {
  257. display: flex;
  258. flex-direction: row;
  259. align-items: center;
  260. justify-content: space-between;
  261. /* border:1px solid blue; */
  262. }
  263. .today-recommend .title .more text {
  264. color: #BBBBBB;
  265. font-size: 20rpx;
  266. font-weight: 700;
  267. /* border:1px solid red; */
  268. }
  269. .today-recommend .title .more .left-arrow {
  270. width: 20rpx;
  271. height: 20rpx;
  272. /* border:1px solid red; */
  273. }
  274. .today-recommend .items {
  275. width: 90%;
  276. height: 250rpx;
  277. margin-top: 50rpx;
  278. display: flex;
  279. flex-direction: column;
  280. align-items: center;
  281. justify-content: flex-start;
  282. border: 1rpx solid #E5E5E5;
  283. border-top: #007AFF;
  284. border-left: #4CD964;
  285. border-right: #007AFF;
  286. }
  287. .today-recommend .items .content {
  288. width: 100%;
  289. display: flex;
  290. flex-direction: row;
  291. /* border:1px solid blue; */
  292. }
  293. .today-recommend .items .content .pic {
  294. margin: 10rpx;
  295. /* border:1px solid red; */
  296. }
  297. .today-recommend .items .content .pic image {
  298. width: 160rpx;
  299. height: 160rpx;
  300. /* border:1px solid red; */
  301. }
  302. .today-recommend .items .content .detail {
  303. margin-right: 10rpx;
  304. margin-top: 10rpx;
  305. /* border:1px solid red; */
  306. }
  307. .today-recommend .items .content .detail .title {
  308. font-size: 35rpx;
  309. font-weight: 700;
  310. }
  311. .today-recommend .items .content .detail .intro {
  312. color: #BBBBBB;
  313. font-size: 25rpx;
  314. text-align: left;
  315. font-weight: 400;
  316. /* border:1px solid red; */
  317. }
  318. .intro {
  319. /* border: 1px solid red; */
  320. /* margin-right: 200px; */
  321. width: 220px;
  322. height: 70px;
  323. margin-top: 5px;
  324. }
  325. .today-recommend .items .content .left-arrow {
  326. /* width:20rpx;
  327. height:20rpx; */
  328. margin-right: 30rpx;
  329. display: flex;
  330. align-items: center;
  331. /* justify-content: center; */
  332. /* border:1px solid red; */
  333. }
  334. /* .content {
  335. border: 1px solid red;
  336. }
  337. .left-arrow {
  338. border: 1px solid red;
  339. }
  340. */
  341. .today-recommend .items .content .left-arrow image {
  342. width: 20rpx;
  343. height: 20rpx;
  344. /* border:1px solid red; */
  345. }
  346. .today-recommend .items .buttom-box {
  347. width: 100%;
  348. height: 62rpx;
  349. /* border:1px solid red; */
  350. }
  351. .today-recommend .items .buttom-box button {
  352. width: 140rpx;
  353. height: 62rpx;
  354. background: linear-gradient(180deg, #00C0FF 0%, #008CFF 100%);
  355. border-radius: 6px;
  356. font-size: 12px;
  357. color: #FFFFFF;
  358. margin-right: 30rpx;
  359. margin-top: -20rpx;
  360. display: flex;
  361. justify-content: center;
  362. align-items: center;
  363. /* border:1px solid red; */
  364. }
  365. </style>