entertainment.vue 27 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237
  1. <template>
  2. <view class="all">
  3. <view class="padding-t-30"></view>
  4. <view class="tab">
  5. <view class="flex-start">
  6. <view class="tab-item " @click="changeTab(item,ind)" :class="{action:actionIndex==ind}"
  7. v-for="(item,ind) in gameList">
  8. {{item.name}}
  9. </view>
  10. </view>
  11. <l-echart class="top" ref="chart"></l-echart>
  12. </view>
  13. <view class="center flex">
  14. <!-- 左 -->
  15. <view class="le">
  16. <view class="tit flex-start">
  17. <view class="ti1">{{$t('enter.u1')}}</view>
  18. <view class="ti2">({{$t('enter.u2')}} {{history.base.max_bet*1}}U)</view>
  19. </view>
  20. <view class="he">
  21. <view class="numbox flex-start">
  22. <view class="he1 flex" @click="upOnBtnData.value=it" v-for="it in arMoneyList">
  23. <view class="wen">{{it}}</view>
  24. </view>
  25. </view>
  26. </view>
  27. <view class="yi flex-start">
  28. <!-- <image class="img" src="../../static/icon/le.png" mode=""></image> -->
  29. <view class="wz padding-l-10">{{history.base.token}}</view>
  30. <view class="qx padding-l-10" v-if="history.next.id">{{history.next.no}}</view>
  31. </view>
  32. <view class="shu">
  33. {{KlineList.c*1}}
  34. </view>
  35. </view>
  36. <!--右 -->
  37. <view class="ri">
  38. <view class="ti flex-center">
  39. <view class="t1">{{$t('enter.u3')}}</view>
  40. <view class="t2 padding-l-10">{{history.base.timebar}}</view>
  41. </view>
  42. <view class="dh">
  43. <input class="input" :placeholder="'USDT'+$t('enter.a9')" type="number" v-model="upOnBtnData.value">
  44. </view>
  45. <view class="btn">
  46. <view class="bt flex">
  47. <view class="btnItem btnle" @click="onPayBet(2)">
  48. <image class="imag" src="../../static/icon/xia.png" mode=""></image>
  49. <text class="xia">{{$t('enter.u4')}}</text>
  50. </view>
  51. <view class="btnItem btnri" @click="onPayBet(1)">
  52. <image class="imag" src="../../static/icon/shang.png" mode=""></image>
  53. <text class="xia">{{$t('enter.u6')}}</text>
  54. </view>
  55. </view>
  56. <view class="bt flex">
  57. <view class="btnItem btnle" @click="onPayBet(3)">
  58. <view class="xia">{{$t('enter.u5')}}</view>
  59. </view>
  60. <view class="btnItem btnri" @click="onPayBet(4)">
  61. <view class="xia">{{$t('enter.u7')}}</view>
  62. </view>
  63. </view>
  64. </view>
  65. <view class="db flex">
  66. <view class="jl">{{$t('enter.u8')}}</view>
  67. <view class="sj">
  68. <text v-if="time.H<10">0</text>
  69. {{time.H}}
  70. </view>
  71. <view class="sj">
  72. <text v-if="time.M<10">0</text>
  73. {{time.M}}
  74. </view>
  75. <view class="sj">
  76. <text v-if="time.S<10">0</text>
  77. {{time.S}}
  78. </view>
  79. </view>
  80. </view>
  81. </view>
  82. <view class="kb"></view>
  83. <view class="last">
  84. <view class="flex">
  85. <text>{{$t('enter.u9')}}</text>
  86. <view class="flex" @click="nav(`/pages/game/history?id=${history.base.id}`)">
  87. <text>{{$t('enter.u10')}}</text>
  88. <image class="lb" src="../../static/icon/jt.png" mode="scaleToFill"></image>
  89. </view>
  90. </view>
  91. </view>
  92. <view class="bg">
  93. <view class="biaotou flex">
  94. <view class="biwe">{{$t('enter.u11')}}</view>
  95. <view class="biwe">{{$t('enter.u12')}}</view>
  96. <view class="biwe">{{$t('enter.u13')}}</view>
  97. <view class="biwe">{{$t('enter.u14')}}</view>
  98. </view>
  99. <view class="list flex" v-for="(item,ind) in betList.list" :key="ind">
  100. <view class="biwe flex-start">
  101. <view class="tr">{{history.base.token}}</view>
  102. <view class="nametip">{{history.base.timebar}}</view>
  103. <image v-if="item.bet==1" class="zz" src="../../static/icon/shang.png" mode="scaleToFill"></image>
  104. <image v-if="item.bet==2" class="zz" src="../../static/icon/xia.png" mode="scaleToFill"></image>
  105. <view v-if="item.bet==3" class="nametip red">{{$t('enter.u5')}}</view>
  106. <view v-if="item.bet==4" class="nametip green">{{$t('enter.u7')}}</view>
  107. </view>
  108. <view class="biwe">{{item.num*1}}</view>
  109. <view class="biwe">{{item.sexy}}</view>
  110. <view class="biwe flex-center">
  111. <view v-if="item.status==0" class="list-buttom primary margin-r-10">
  112. {{$t('enter.a4')}}
  113. </view>
  114. <view class="list-buttom red" v-if="item.result==1">
  115. {{$t('enter.a5')}}
  116. </view>
  117. <view class="list-buttom success" v-if="item.result===0">
  118. {{$t('enter.a6')}}
  119. </view>
  120. <view @click="alertDetailOpen(item)" class="list-buttom primary margin-l-10"
  121. v-if="item.result===0||item.result==1">
  122. {{$t('enter.u18')}}
  123. </view>
  124. </view>
  125. </view>
  126. </view>
  127. <view class="chz flex" @click="nav('/pages/user/money/recharge')">
  128. <view>
  129. <view class="yue padding-b-10">{{$t('enter.u15')}}</view>
  130. <view class="yes">{{userWallet}}U</view>
  131. </view>
  132. <view class="flex-start">
  133. <view class="quc">{{$t('enter.u16')}}</view>
  134. <image class="choz" src="../../static/icon/jt.png" mode="scaleToFill"></image>
  135. </view>
  136. </view>
  137. <uni-popup type="bottom" ref="popup" :mask-click="false" @maskClick='colsePayPassword'>
  138. <inputPassword @commit='KeyInfo'></inputPassword>
  139. </uni-popup>
  140. <uni-popup type="center" ref="popupDetail">
  141. <view class="alert-detail" v-if="alertDetail.room">
  142. <view class="padding-c-30 padding-t-30 padding-b-30" v-if="alertDetail.room.result_info">
  143. <!-- <view class="padding-c-30 padding-t-30 padding-b-30"> -->
  144. <view class="flex">
  145. <view class="type">
  146. {{$t('set.a7')}}{{alertDetail.room.no}}{{$t('set.a8')}}
  147. </view>
  148. <view class="num">
  149. <view class="lis" v-if="alertDetail.result === 1">
  150. <view class="liss green">{{$t('enter.a5')}}</view>
  151. </view>
  152. <view class="lis" v-if="alertDetail.result === 0">
  153. <view class="liss red">{{$t('enter.a6')}}</view>
  154. </view>
  155. <view class="lis" v-if="alertDetail.status === 0">
  156. <view class="liss primary">{{$t('enter.a4')}}</view>
  157. </view>
  158. </view>
  159. </view>
  160. <!-- <view class="flex">
  161. <view class="type">
  162. {{$t('gameList.a5')}}
  163. </view>
  164. <view class="num" v-if="alertDetail.result_info.ts">
  165. {{getTime(alertDetail.result_info.ts)}}
  166. </view>
  167. </view> -->
  168. <view class="flex">
  169. <view class="type">
  170. {{$t('gameList.a2')}}
  171. </view>
  172. <view class="num">
  173. {{alertDetail.room.game.timebar}}
  174. </view>
  175. </view>
  176. <view class="flex">
  177. <view class="type">
  178. {{$t('gameList.a4')}}
  179. </view>
  180. <view class="num">
  181. <!-- {{alertDetail.result_info.c}} -->
  182. {{alertDetail.num}}U
  183. </view>
  184. </view>
  185. <view class="flex">
  186. <view class="type">
  187. {{$t('gameList.a7')}}
  188. </view>
  189. <view class="num flex-start">
  190. <!-- {{alertDetail.result_info.l}} -->
  191. <view class="green" v-if="alertDetail.bet==1">{{ $t("enter.u6") }}</view>
  192. <view class="red" v-if="alertDetail.bet==2">{{ $t("enter.u4") }}</view>
  193. <view class="green" v-if="alertDetail.bet==3">{{ $t("enter.u5") }}</view>
  194. <view class="red" v-if="alertDetail.bet==4">{{ $t("enter.u7") }}</view>
  195. </view>
  196. </view>
  197. <view class="flex">
  198. <view class="type">
  199. {{$t('gameList.a10')}}
  200. </view>
  201. <view class="num">
  202. {{alertDetail.room.result_info.o}}
  203. </view>
  204. </view>
  205. <view class="flex">
  206. <view class="type">
  207. {{$t('gameList.a5')}}
  208. </view>
  209. <view class="num" v-if="alertDetail.room.open_time">
  210. <!-- {{alertDetail.result_info.h}} -->
  211. {{alertDetail.room.open_time}}
  212. </view>
  213. </view>
  214. <view class="flex">
  215. <view class="type">
  216. {{$t('gameList.a9')}}
  217. </view>
  218. <view class="num flex-start">
  219. <template v-for="it in alertDetail.room.arr " v-if="it.value==1">
  220. <view class="green" v-if="it.type==1">{{ $t("enter.u6") }}</view>
  221. <view class="green" v-if="it.type==3">{{ $t("enter.u5") }}</view>
  222. <view class="red" v-if="it.type==2">{{ $t("enter.u4") }}</view>
  223. <view class="red" v-if="it.type==4">{{ $t("enter.u7") }}</view>
  224. </template>
  225. </view>
  226. </view>
  227. <view class="flex">
  228. <view class="type">
  229. {{$t('gameList.a8')}}
  230. </view>
  231. <view class="num">
  232. <!-- {{alertDetail.result_info.h}} -->
  233. {{alertDetail.get}}
  234. </view>
  235. </view>
  236. </view>
  237. <button class="button" type="default" @click="$refs.popupDetail.close()"><text
  238. class="button-text">{{$t("safe.d7")}}</text></button>
  239. </view>
  240. </uni-popup>
  241. <taber tab='entertainment' v-if="!upOnBtnData.show"></taber>
  242. </view>
  243. </view>
  244. </template>
  245. <script>
  246. import * as echarts from '@/uni_modules/lime-echart/static/echarts.min'
  247. import {
  248. getGame,
  249. gameKline,
  250. getGameList,
  251. gameWallet,
  252. gameBetList,
  253. gameBetIn
  254. } from "@/api/game.js";
  255. import {
  256. mapState,
  257. mapMutations
  258. } from 'vuex';
  259. import {
  260. saveUrl,
  261. interceptor
  262. } from '@/utils/loginUtils.js';
  263. import taber from "@/components/footer/footer.vue";
  264. import {
  265. getTime
  266. } from '@/utils/rocessor.js';
  267. import inputPassword from "@/components/input-password/input-password.vue";
  268. export default {
  269. components: {
  270. taber,
  271. inputPassword
  272. },
  273. computed: {
  274. ...mapState("user", ["hasLogin"]),
  275. },
  276. data() {
  277. return {
  278. arMoneyList: [
  279. 1, 5, 10, 20, 50, 100
  280. ],
  281. actionIndex: 0,
  282. // 当前游戏列表
  283. gameList: [],
  284. // 游戏信息
  285. history: {
  286. list: [], //游戏进行记录
  287. page: 1,
  288. limit: 10,
  289. // 基础数据
  290. base: {},
  291. next: "",
  292. now: {}
  293. },
  294. time: {
  295. H: 0,
  296. M: 0,
  297. S: 0,
  298. // 保存倒计时对象
  299. t: ''
  300. },
  301. // 游戏押注记录
  302. betList: {
  303. list: [], //游戏进行记录
  304. page: 1,
  305. limit: 5,
  306. },
  307. userWallet: 0,
  308. // 当前最新K线数据
  309. KlineList: {
  310. c: ''
  311. },
  312. upOnBtnData: {
  313. // 是否显示底部导航栏
  314. show: false,
  315. type: '',
  316. // 当前输入的密码
  317. passwordArr: '',
  318. value: '',
  319. },
  320. // 弹窗数据像晴
  321. alertDetail: {},
  322. // 保存获取下次游戏对象
  323. getNextTimeObj: '',
  324. // 判断是否当前页面中
  325. loadPage: false,
  326. };
  327. },
  328. onShow() {
  329. this.loadPage = true;
  330. if (!this.hasLogin) {
  331. uni.showModal({
  332. title: this.$t('enter.c4'),
  333. content: this.$t('enter.b5'),
  334. success: (e) => {
  335. // 判断是否点击确认按钮
  336. if (e.confirm) {
  337. // 保存当前页面地址
  338. saveUrl()
  339. // 跳转页面
  340. interceptor()
  341. }
  342. }
  343. })
  344. return
  345. }
  346. this.getUserWallet();
  347. this.gameInit();
  348. this.gameBetList()
  349. },
  350. // 关闭循环
  351. onHide() {
  352. this.loadPage = false;
  353. console.log('隐藏');
  354. // 倒计时清理
  355. this.initData();
  356. },
  357. methods: {
  358. getTime,
  359. // 弹窗详情
  360. alertDetailOpen(item) {
  361. this.alertDetail = item;
  362. console.log(this.alertDetail);
  363. const res = this.alertDetail.room;
  364. if (res.result_info) {
  365. res.result_info.c = Number(res.result_info.c).toFixed(res.game.decimal)
  366. }
  367. if (res.result) {
  368. let arr = [];
  369. const ar = res.result.split(",")
  370. for (let i = 0; i < ar.length; i++) {
  371. const s = ar[i].split(':');
  372. arr.push({
  373. type: s[0],
  374. value: s[1]
  375. })
  376. }
  377. res.arr = arr;
  378. }
  379. res.open_time = getTime(res.open_time);
  380. this.$refs.popupDetail.open();
  381. },
  382. // 倒计时清理
  383. initData() {
  384. const that = this
  385. // 关闭倒计时
  386. clearInterval(that.getNextTimeObj);
  387. clearInterval(that.time.t);
  388. // 清空倒计时对象
  389. that.getNextTimeObj = '';
  390. that.time = {
  391. H: 0,
  392. M: 0,
  393. S: 0,
  394. t: ''
  395. };
  396. },
  397. // 点击触发支付事件
  398. onPayBet(type) {
  399. if (!this.upOnBtnData.value) {
  400. uni.showToast({
  401. title: this.$t('enter.a9'),
  402. icon: "error"
  403. })
  404. return
  405. }
  406. if (!this.history.next) {
  407. uni.showModal({
  408. title: this.$t('enter.c4'),
  409. content: this.$t('enter.a3'),
  410. showCancel: false,
  411. });
  412. return
  413. }
  414. this.upOnBtnData.type = type;
  415. this.openPayPassword();
  416. },
  417. // 打开支付弹窗
  418. openPayPassword() {
  419. this.upOnBtnData.show = true;
  420. this.$refs.popup.open();
  421. },
  422. // 关闭支付弹窗
  423. colsePayPassword() {
  424. this.upOnBtnData.show = false;
  425. this.$refs.popup.close();
  426. },
  427. // 密码输入完成后调用下注
  428. KeyInfo(val) {
  429. const that = this;
  430. that.upOnBtnData.passwordArr = val;
  431. that.colsePayPassword();
  432. const typeList = [that.$t('enter.u6'), that.$t('enter.u4'), that.$t('enter.u5'), that.$t('enter.u7')];
  433. uni.showModal({
  434. title: that.$t('enter.c4'),
  435. content: `${that.$t('enter.a8')}${that.upOnBtnData.value}USDT${that.$t('enter.a10')}${typeList[that.upOnBtnData.type-1]}`,
  436. success: res => {
  437. if (res.confirm) {
  438. that.gameBetIn();
  439. }
  440. },
  441. });
  442. },
  443. // 参与压住
  444. gameBetIn(type) {
  445. const that = this;
  446. const upData = {
  447. id: that.history.next.id,
  448. bet: that.upOnBtnData.type,
  449. num: that.upOnBtnData.value,
  450. trade_password: that.upOnBtnData.passwordArr
  451. };
  452. uni.showLoading({
  453. mask: true
  454. })
  455. that.upOnBtnData.value = '';
  456. gameBetIn(upData).then((res) => {
  457. uni.hideLoading()
  458. uni.showToast({
  459. title: res.msg
  460. });
  461. that.gameBetList();
  462. that.getUserWallet();
  463. }).catch((res) => {
  464. uni.hideLoading();
  465. uni.showToast({
  466. title: res.msg
  467. });
  468. })
  469. },
  470. // 获取用户余额信息
  471. getUserWallet() {
  472. gameWallet().then((res) => {
  473. this.userWallet = +res.data.back.USDT.money.money
  474. })
  475. },
  476. // 开始倒计时
  477. async opTiem() {
  478. const that = this;
  479. try {
  480. // 判斷是否有游戲信息并且有正在進行中游戏
  481. if (that.history.base.id && that.history.next) {
  482. // console.log(that.history.base.id, that.history.next,
  483. // 'that.history.base.id && that.history.next');
  484. that.time.t = setInterval(() => {
  485. that.getOutTime();
  486. }, 1000)
  487. }
  488. } catch (e) {
  489. console.log(e, '定时');
  490. }
  491. },
  492. // 获取倒计时时间
  493. getOutTime() {
  494. const that = this;
  495. const da = (new Date()).getTime();
  496. const timenum = that.history.next.open_time * 1000 - da;
  497. // console.log(timenum, that.history.next.open_time, da, '计算');
  498. if (timenum > 0) {
  499. that.time.H = Math.floor(timenum / 1000 / 60 / 60);
  500. that.time.S = Math.floor(timenum / 1000 % 60)
  501. that.time.M = Math.floor(timenum / 1000 / 60 % 60);
  502. }
  503. if (that.time.H == 0 && that.time.M == 0 && that.time.S == 0) {
  504. console.log('归0');
  505. clearInterval(that.time.t);
  506. // 延时调用防止数据重复加载
  507. setTimeout(() => {
  508. that.getGame(that.history.base.id)
  509. that.getGameKline();
  510. }, 2000)
  511. }
  512. },
  513. // 游戏tab切换
  514. changeTab(item, ind) {
  515. const that = this;
  516. if (ind != this.actionIndex) {
  517. that.actionIndex = ind;
  518. // 清理倒计时
  519. that.initData();
  520. // 重新加载数据
  521. that.gameDataInit(item.id);
  522. }
  523. },
  524. // 初始化
  525. async gameInit() {
  526. // 获取游戏列表
  527. await this.getGameList();
  528. // 加载游戏数据
  529. this.gameDataInit(this.history.base.id || this.gameList[0].id)
  530. },
  531. // 加载游戏列表
  532. getGameList() {
  533. return getGameList().then((res) => {
  534. this.gameList = res.data.list;
  535. // console.log('1111111111',this.gameList);
  536. })
  537. },
  538. // 重新加载基础游戏信息
  539. async gameDataInit(id, reload = true) {
  540. // 获取基础信息
  541. await this.getGame(id);
  542. //获取K线
  543. this.getGameKline(reload);
  544. // 获取游戏压住记录
  545. this.gameBetList();
  546. },
  547. // 获取游戏压住记录
  548. gameBetList() {
  549. const that = this;
  550. const lineNum = that.history.base.decimal;
  551. const list = that.betList.list;
  552. // return list;
  553. console.log('11111', list);
  554. gameBetList({
  555. page: 1,
  556. limit: 10,
  557. id: that.history.base.id,
  558. }).then(({
  559. data
  560. }) => {
  561. that.betList.list = data.bet_log.map((res) => {
  562. res.num = Number(res.num);
  563. res.get = Number(res.get);
  564. res.sexy = +(res.get - res.num).toFixed(2);
  565. if (res.room.result_info) {
  566. const obj = res.room.result_info
  567. obj.c = Number(obj.c).toFixed(lineNum)
  568. obj.o = Number(obj.o).toFixed(lineNum)
  569. obj.h = Number(obj.h).toFixed(lineNum)
  570. obj.l = Number(obj.l).toFixed(lineNum)
  571. }
  572. return res
  573. });
  574. })
  575. return list;
  576. },
  577. // 获取游戏K线信息
  578. getGameKline(reload = true) {
  579. const that = this;
  580. const lineNum = this.history.base.decimal;
  581. gameKline({
  582. page: 1,
  583. limit: 60
  584. }, that.history.base.id).then((res) => {
  585. that.KlineList = res.data.list[0];
  586. let list = res.data.list.reverse();
  587. // x轴记录
  588. let xarr = [];
  589. // 打点数据
  590. let linearr = [];
  591. for (let i = 0; i < list.length; i++) {
  592. const ll = list[i];
  593. const time = new Date(+ll.ts);
  594. const addar = [+(+ll.o).toFixed(lineNum), +(+ll.c).toFixed(lineNum), +(+ll.l).toFixed(
  595. lineNum), +(+ll.h)
  596. .toFixed(lineNum)
  597. ];
  598. xarr.push(`${time.getHours()}:${time.getMinutes()}`)
  599. linearr.push(addar)
  600. }
  601. that.$nextTick(() => {
  602. // 判断是否要重载数据
  603. that.initKline({
  604. xarr,
  605. linearr
  606. }, reload)
  607. })
  608. })
  609. },
  610. // 获取当前项目信息
  611. getGame(id) {
  612. const that = this;
  613. return getGame({
  614. page: that.history.page,
  615. limit: that.history.limit
  616. }, id).then(({
  617. data
  618. }) => {
  619. that.history.list = data.list || [];
  620. that.history.base = data.game || {};
  621. that.history.next = data.next_game || '';
  622. that.history.now = data.now_game || '';
  623. // 是否不存在启动中的活动并判断防止重复调用创建倒计时
  624. // 判断是否不存在游戏,并且没有倒计时对象,且在当前页面
  625. if (that.loadPage && !that.history.next && !that.getNextTimeObj) {
  626. that.getNextTimeObj = setInterval(() => {
  627. that.getGame(id)
  628. }, 1000)
  629. return
  630. }
  631. if (that.history.next && that.getNextTimeObj) {
  632. clearInterval(that.getNextTimeObj);
  633. // 清空倒计时对象
  634. that.getNextTimeObj = '';
  635. }
  636. // 判断是否有活动并且正在进行中
  637. if (that.history.next && !that.getNextTimeObj) {
  638. that.opTiem();
  639. }
  640. })
  641. },
  642. // 均值计算
  643. calculateMA(dayCount, data) {
  644. var result = [];
  645. for (var i = 0, len = data.linearr.length; i < len; i++) {
  646. if (i < dayCount) {
  647. result.push('-');
  648. continue;
  649. }
  650. var sum = 0;
  651. for (var j = 0; j < dayCount; j++) {
  652. sum += data.linearr[i - j][1];
  653. }
  654. result.push(+(sum / dayCount).toFixed(5));
  655. }
  656. return result;
  657. },
  658. // 重载K线
  659. async initKline(data, reload = true) {
  660. const that = this;
  661. try {
  662. const chart = await this.$refs.chart.init(echarts);
  663. if (reload) {
  664. const upColor = '#00da3c';
  665. const downColor = '#ec0000';
  666. chart.setOption(
  667. (this.option = {
  668. animation: false,
  669. legend: {
  670. top: 10,
  671. left: 10,
  672. data: ['MA5', 'MA10', 'MA20'],
  673. textStyle: {
  674. color: '#999999'
  675. }
  676. },
  677. tooltip: {
  678. trigger: 'axis',
  679. axisPointer: {
  680. type: 'cross'
  681. },
  682. borderWidth: 1,
  683. borderColor: '#ccc',
  684. padding: 10,
  685. textStyle: {
  686. color: '#000'
  687. },
  688. position: function(pos, params, el, elRect, size) {
  689. const obj = {
  690. top: 10
  691. };
  692. obj[['left', 'right'][+(pos[0] < size.viewSize[0] / 2)]] = 40;
  693. return obj;
  694. }
  695. },
  696. dataZoom: [{
  697. type: 'inside',
  698. xAxisIndex: 0,
  699. start: 50,
  700. end: 100
  701. }],
  702. grid: [{
  703. left: 10,
  704. right: 55,
  705. bottom: 20,
  706. top: 45
  707. }],
  708. xAxis: [{
  709. type: 'category',
  710. data: data.xarr,
  711. axisLine: {
  712. onZero: false
  713. },
  714. splitLine: {
  715. show: false
  716. },
  717. min: 'dataMin',
  718. max: 'dataMax',
  719. axisPointer: {
  720. z: 100
  721. }
  722. }],
  723. yAxis: [{
  724. scale: true,
  725. splitNumber: 4,
  726. position: 'right',
  727. axisTick: {
  728. show: false
  729. },
  730. splitLine: {
  731. show: false,
  732. lineStyle: {
  733. color: '#e3e3e3'
  734. }
  735. },
  736. axisLabel: {
  737. inside: false,
  738. formatter: '{value}\n',
  739. color: '#999999'
  740. }
  741. }],
  742. series: [{
  743. name: that.history.base.token + '-USDT',
  744. type: 'candlestick',
  745. data: data.linearr,
  746. itemStyle: {
  747. color: upColor,
  748. color0: downColor,
  749. borderColor: undefined,
  750. borderColor0: undefined
  751. }
  752. },
  753. {
  754. name: "MA5",
  755. smooth: true,
  756. type: 'line',
  757. data: that.calculateMA(5, data),
  758. showSymbol: false,
  759. lineStyle: {
  760. width: 1
  761. }
  762. },
  763. {
  764. name: "MA10",
  765. smooth: true,
  766. type: 'line',
  767. data: that.calculateMA(10, data),
  768. showSymbol: false,
  769. lineStyle: {
  770. width: 1
  771. }
  772. },
  773. {
  774. name: "MA20",
  775. smooth: true,
  776. type: 'line',
  777. data: that.calculateMA(20, data),
  778. showSymbol: false,
  779. lineStyle: {
  780. width: 1
  781. }
  782. },
  783. ]
  784. }),
  785. true
  786. )
  787. } else {
  788. chart.setOption({
  789. xAxis: [{
  790. type: 'category',
  791. data: data.xarr,
  792. }],
  793. series: [{
  794. name: that.history.base.token + '-USDT',
  795. data: data.linearr,
  796. },
  797. {
  798. name: "MA5",
  799. data: that.calculateMA(5, data),
  800. },
  801. {
  802. name: "MA10",
  803. data: that.calculateMA(10, data),
  804. },
  805. {
  806. name: "MA20",
  807. data: that.calculateMA(20, data),
  808. },
  809. ]
  810. })
  811. }
  812. } catch (e) {
  813. console.log(e, 'cuowu');
  814. //TODO handle the exception
  815. }
  816. },
  817. // 页面跳转
  818. nav(url) {
  819. console.log('tz');
  820. if (!this.hasLogin) {
  821. uni.showModal({
  822. title: this.$t('enter.c4'),
  823. content: this.$t('enter.b5'),
  824. success: (e) => {
  825. // 判断是否点击确认按钮
  826. if (e.confirm) {
  827. // 保存当前页面地址
  828. saveUrl()
  829. // 跳转页面
  830. interceptor()
  831. }
  832. }
  833. })
  834. return
  835. }
  836. uni.navigateTo({
  837. url,
  838. fail(err) {
  839. console.log(err);
  840. }
  841. });
  842. },
  843. },
  844. };
  845. </script>
  846. <style lang="scss">
  847. .all {
  848. width: 750rpx;
  849. /* height: 2500rpx; */
  850. height: 100%;
  851. padding-top: var(--status-bar-height);
  852. padding-bottom: 30rpx;
  853. }
  854. .tab {
  855. padding: 30rpx 20rpx;
  856. margin: 0 30rpx;
  857. background-color: #191A1F;
  858. border-radius: 20px;
  859. .tab-item {
  860. color: #FFF;
  861. font-size: $font-lg;
  862. padding: 0 20rpx;
  863. padding-bottom: 10rpx;
  864. &.action {
  865. color: #F5A944;
  866. border-bottom: 1px solid #F5A944;
  867. }
  868. }
  869. .top {
  870. height: 530rpx;
  871. width: 100%;
  872. }
  873. }
  874. .center {
  875. padding: 30rpx;
  876. line-height: 1;
  877. align-items: flex-start;
  878. .le,
  879. .ri {
  880. width: 50%;
  881. }
  882. .le {
  883. .tit {
  884. font-weight: bold;
  885. .ti1 {
  886. font-size: 26rpx;
  887. color: #ffffff;
  888. }
  889. .ti2 {
  890. font-size: 22rpx;
  891. padding-left: 10rpx;
  892. color: #999999;
  893. }
  894. }
  895. .he {
  896. padding-top: 40rpx;
  897. .numbox {
  898. flex-wrap: wrap;
  899. .he1 {
  900. background: #fdaf41;
  901. border-radius: 10rpx;
  902. margin-bottom: 40rpx;
  903. margin-right: 20rpx;
  904. width: 84rpx;
  905. height: 84rpx;
  906. justify-content: center;
  907. .wen {
  908. font-size: 30rpx;
  909. font-weight: bold;
  910. color: #000000;
  911. }
  912. }
  913. }
  914. }
  915. .yi {
  916. color: #ffffff;
  917. font-size: $font-base;
  918. .img {
  919. width: 41rpx;
  920. height: 42rpx;
  921. }
  922. .wz {
  923. font-weight: bold;
  924. }
  925. }
  926. .shu {
  927. padding-top: 10rpx;
  928. font-size: 51rpx;
  929. font-weight: bold;
  930. color: #fdb242;
  931. }
  932. }
  933. .ri {
  934. .ti {
  935. font-size: 26rpx;
  936. font-weight: bold;
  937. .t1 {
  938. color: #ffffff;
  939. }
  940. .t2 {
  941. color: #fdaf41;
  942. }
  943. }
  944. .dh {
  945. width: 100%;
  946. padding: 20rpx 30rpx;
  947. margin-top: 30rpx;
  948. background: #efefef;
  949. border-radius: 10rpx;
  950. .te {
  951. font-size: 44rpx;
  952. font-weight: 800;
  953. color: #000000;
  954. }
  955. }
  956. .btn {
  957. padding-top: 30rpx;
  958. .bt {
  959. padding-bottom: 10rpx;
  960. .btnItem {
  961. width: 49%;
  962. height: 70rpx;
  963. line-height: 70rpx;
  964. text-align: center;
  965. .imag {
  966. width: 32rpx;
  967. height: 20rpx;
  968. }
  969. .xia {
  970. font-size: 28rpx;
  971. font-weight: 800;
  972. color: #ffffff;
  973. }
  974. }
  975. .btnle {
  976. border-radius: 50rpx 0 0 50rpx;
  977. background-color: #df5660;
  978. }
  979. .btnri {
  980. border-radius: 0 50rpx 50rpx 0;
  981. background-color: #5bb786;
  982. }
  983. }
  984. }
  985. .db {
  986. justify-content: flex-end;
  987. padding-top: 30rpx;
  988. .jl {
  989. font-size: $font-lg + 4rpx;
  990. font-weight: 400;
  991. color: #999999;
  992. }
  993. .sj {
  994. width: 40rpx;
  995. height: 40rpx;
  996. background: #bfbfbf;
  997. border-radius: 3rpx;
  998. text-align: center;
  999. line-height: 40rpx;
  1000. margin-left: 10rpx;
  1001. }
  1002. }
  1003. }
  1004. }
  1005. .kb {
  1006. width: 750rpx;
  1007. height: 20rpx;
  1008. background-color: #191a1f;
  1009. }
  1010. .last {
  1011. padding: 30rpx;
  1012. line-height: 1;
  1013. font-size: 24rpx;
  1014. font-weight: 800;
  1015. color: #fff;
  1016. .lb {
  1017. width: 14rpx;
  1018. height: 20rpx;
  1019. margin-left: 10rpx;
  1020. }
  1021. }
  1022. .bg {
  1023. padding: 0 30rpx;
  1024. background-color: #000000;
  1025. color: #fff;
  1026. text-align: center;
  1027. font-size: 28rpx;
  1028. padding-bottom: 30rpx;
  1029. .biaotou {
  1030. font-weight: 800;
  1031. padding-bottom: 10rpx;
  1032. }
  1033. .biwe {
  1034. width: 25%;
  1035. .zz {
  1036. width: 22rpx;
  1037. height: 14rpx;
  1038. margin-left: 8rpx;
  1039. }
  1040. .nametip {
  1041. font-size: 18rpx;
  1042. color: #999999;
  1043. padding-left: 8rpx;
  1044. &.green {
  1045. color: #5bb786;
  1046. }
  1047. &.red {
  1048. color: #df5660;
  1049. }
  1050. }
  1051. }
  1052. .biwe:nth-child(1) {
  1053. flex-shrink: 0;
  1054. text-align: left;
  1055. align-items: flex-end;
  1056. }
  1057. .biwe:nth-child(4) {
  1058. flex-shrink: 0;
  1059. width: 200rpx;
  1060. }
  1061. .list {
  1062. font-weight: bold;
  1063. padding: 20rpx 0;
  1064. border-bottom: 1px solid rgba(43, 42, 38, 0.52);
  1065. }
  1066. .list-buttom {
  1067. width: 100rpx;
  1068. border-radius: 30rpx;
  1069. font-size: 16rpx;
  1070. padding: 10rpx 0;
  1071. &.success {
  1072. background: $color-green;
  1073. }
  1074. &.red {
  1075. background: $color-yellow;
  1076. }
  1077. &.primary {
  1078. background: #01ebf6;
  1079. color: #000000;
  1080. }
  1081. }
  1082. }
  1083. .chz {
  1084. background: #191a1f;
  1085. border-radius: 20rpx;
  1086. margin: 0 30rpx;
  1087. color: #ffffff;
  1088. font-weight: bold;
  1089. padding: 20rpx 30rpx;
  1090. .yue {
  1091. font-size: 28rpx;
  1092. }
  1093. .yes {
  1094. color: #fdaf41;
  1095. }
  1096. .quc {
  1097. font-size: 26rpx;
  1098. font-weight: 500;
  1099. color: #ffffff;
  1100. }
  1101. .choz {
  1102. width: 22rpx;
  1103. height: 14rpx;
  1104. }
  1105. }
  1106. .alert-detail {
  1107. background-color: #FFF;
  1108. border-radius: 10rpx;
  1109. width: 600rpx;
  1110. .red {
  1111. color: #df5660;
  1112. }
  1113. .green {
  1114. color: $color-green;
  1115. }
  1116. .flex {
  1117. padding: 10rpx 0;
  1118. }
  1119. }
  1120. .lisT {
  1121. font-size: $font-lg;
  1122. font-weight: bold;
  1123. &.red {
  1124. color: #df5660;
  1125. }
  1126. &.green {
  1127. color: $color-green;
  1128. }
  1129. }
  1130. .lis {
  1131. .liss {
  1132. border-radius: 5rpx;
  1133. padding: 10rpx 20rpx;
  1134. font-size: 22rpx;
  1135. font-weight: 500;
  1136. color: #FFF;
  1137. &.red {
  1138. background: $color-yellow;
  1139. }
  1140. &.green {
  1141. background: $color-green;
  1142. }
  1143. &.primary {
  1144. background: #01ebf6;
  1145. }
  1146. }
  1147. }
  1148. </style>