entertainment.vue 29 KB

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