entertainment.vue 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239
  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.c}}
  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. const balance = Number(res.data.back.USDT.money.money);
  474. this.userWallet = balance.toFixed(2);
  475. // this.userWallet = +res.data.back.USDT.money.money
  476. })
  477. },
  478. // 开始倒计时
  479. async opTiem() {
  480. const that = this;
  481. try {
  482. // 判斷是否有游戲信息并且有正在進行中游戏
  483. if (that.history.base.id && that.history.next) {
  484. // console.log(that.history.base.id, that.history.next,
  485. // 'that.history.base.id && that.history.next');
  486. that.time.t = setInterval(() => {
  487. that.getOutTime();
  488. }, 1000)
  489. }
  490. } catch (e) {
  491. console.log(e, '定时');
  492. }
  493. },
  494. // 获取倒计时时间
  495. getOutTime() {
  496. const that = this;
  497. const da = (new Date()).getTime();
  498. const timenum = that.history.next.open_time * 1000 - da;
  499. // console.log(timenum, that.history.next.open_time, da, '计算');
  500. if (timenum > 0) {
  501. that.time.H = Math.floor(timenum / 1000 / 60 / 60);
  502. that.time.S = Math.floor(timenum / 1000 % 60)
  503. that.time.M = Math.floor(timenum / 1000 / 60 % 60);
  504. }
  505. if (that.time.H == 0 && that.time.M == 0 && that.time.S == 0) {
  506. console.log('归0');
  507. clearInterval(that.time.t);
  508. // 延时调用防止数据重复加载
  509. setTimeout(() => {
  510. that.getGame(that.history.base.id)
  511. that.getGameKline();
  512. }, 2000)
  513. }
  514. },
  515. // 游戏tab切换
  516. changeTab(item, ind) {
  517. const that = this;
  518. if (ind != this.actionIndex) {
  519. that.actionIndex = ind;
  520. // 清理倒计时
  521. that.initData();
  522. // 重新加载数据
  523. that.gameDataInit(item.id);
  524. }
  525. },
  526. // 初始化
  527. async gameInit() {
  528. // 获取游戏列表
  529. await this.getGameList();
  530. // 加载游戏数据
  531. this.gameDataInit(this.history.base.id || this.gameList[0].id)
  532. },
  533. // 加载游戏列表
  534. getGameList() {
  535. return getGameList().then((res) => {
  536. this.gameList = res.data.list;
  537. // console.log('1111111111',this.gameList);
  538. })
  539. },
  540. // 重新加载基础游戏信息
  541. async gameDataInit(id, reload = true) {
  542. // 获取基础信息
  543. await this.getGame(id);
  544. //获取K线
  545. this.getGameKline(reload);
  546. // 获取游戏压住记录
  547. this.gameBetList();
  548. },
  549. // 获取游戏压住记录
  550. gameBetList() {
  551. const that = this;
  552. const lineNum = that.history.base.decimal;
  553. const list = that.betList.list;
  554. // return list;
  555. console.log('11111', list);
  556. gameBetList({
  557. page: 1,
  558. limit: 10,
  559. id: that.history.base.id,
  560. }).then(({
  561. data
  562. }) => {
  563. that.betList.list = data.bet_log.map((res) => {
  564. res.num = Number(res.num);
  565. res.get = Number(res.get);
  566. res.sexy = +(res.get - res.num).toFixed(2);
  567. if (res.room.result_info) {
  568. const obj = res.room.result_info
  569. obj.c = Number(obj.c).toFixed(lineNum)
  570. obj.o = Number(obj.o).toFixed(lineNum)
  571. obj.h = Number(obj.h).toFixed(lineNum)
  572. obj.l = Number(obj.l).toFixed(lineNum)
  573. }
  574. return res
  575. });
  576. })
  577. return list;
  578. },
  579. // 获取游戏K线信息
  580. getGameKline(reload = true) {
  581. const that = this;
  582. const lineNum = this.history.base.decimal;
  583. gameKline({
  584. page: 1,
  585. limit: 60
  586. }, that.history.base.id).then((res) => {
  587. that.KlineList = res.data.list[0];
  588. let list = res.data.list.reverse();
  589. // x轴记录
  590. let xarr = [];
  591. // 打点数据
  592. let linearr = [];
  593. for (let i = 0; i < list.length; i++) {
  594. const ll = list[i];
  595. const time = new Date(+ll.ts);
  596. const addar = [+(+ll.o).toFixed(lineNum), +(+ll.c).toFixed(lineNum), +(+ll.l).toFixed(
  597. lineNum), +(+ll.h)
  598. .toFixed(lineNum)
  599. ];
  600. xarr.push(`${time.getHours()}:${time.getMinutes()}`)
  601. linearr.push(addar)
  602. }
  603. that.$nextTick(() => {
  604. // 判断是否要重载数据
  605. that.initKline({
  606. xarr,
  607. linearr
  608. }, reload)
  609. })
  610. })
  611. },
  612. // 获取当前项目信息
  613. getGame(id) {
  614. const that = this;
  615. return getGame({
  616. page: that.history.page,
  617. limit: that.history.limit
  618. }, id).then(({
  619. data
  620. }) => {
  621. that.history.list = data.list || [];
  622. that.history.base = data.game || {};
  623. that.history.next = data.next_game || '';
  624. that.history.now = data.now_game || '';
  625. // 是否不存在启动中的活动并判断防止重复调用创建倒计时
  626. // 判断是否不存在游戏,并且没有倒计时对象,且在当前页面
  627. if (that.loadPage && !that.history.next && !that.getNextTimeObj) {
  628. that.getNextTimeObj = setInterval(() => {
  629. that.getGame(id)
  630. }, 1000)
  631. return
  632. }
  633. if (that.history.next && that.getNextTimeObj) {
  634. clearInterval(that.getNextTimeObj);
  635. // 清空倒计时对象
  636. that.getNextTimeObj = '';
  637. }
  638. // 判断是否有活动并且正在进行中
  639. if (that.history.next && !that.getNextTimeObj) {
  640. that.opTiem();
  641. }
  642. })
  643. },
  644. // 均值计算
  645. calculateMA(dayCount, data) {
  646. var result = [];
  647. for (var i = 0, len = data.linearr.length; i < len; i++) {
  648. if (i < dayCount) {
  649. result.push('-');
  650. continue;
  651. }
  652. var sum = 0;
  653. for (var j = 0; j < dayCount; j++) {
  654. sum += data.linearr[i - j][1];
  655. }
  656. result.push(+(sum / dayCount).toFixed(5));
  657. }
  658. return result;
  659. },
  660. // 重载K线
  661. async initKline(data, reload = true) {
  662. const that = this;
  663. try {
  664. const chart = await this.$refs.chart.init(echarts);
  665. if (reload) {
  666. const upColor = '#00da3c';
  667. const downColor = '#ec0000';
  668. chart.setOption(
  669. (this.option = {
  670. animation: false,
  671. legend: {
  672. top: 10,
  673. left: 10,
  674. data: ['MA5', 'MA10', 'MA20'],
  675. textStyle: {
  676. color: '#999999'
  677. }
  678. },
  679. tooltip: {
  680. trigger: 'axis',
  681. axisPointer: {
  682. type: 'cross'
  683. },
  684. borderWidth: 1,
  685. borderColor: '#ccc',
  686. padding: 10,
  687. textStyle: {
  688. color: '#000'
  689. },
  690. position: function(pos, params, el, elRect, size) {
  691. const obj = {
  692. top: 10
  693. };
  694. obj[['left', 'right'][+(pos[0] < size.viewSize[0] / 2)]] = 40;
  695. return obj;
  696. }
  697. },
  698. dataZoom: [{
  699. type: 'inside',
  700. xAxisIndex: 0,
  701. start: 50,
  702. end: 100
  703. }],
  704. grid: [{
  705. left: 10,
  706. right: 55,
  707. bottom: 20,
  708. top: 45
  709. }],
  710. xAxis: [{
  711. type: 'category',
  712. data: data.xarr,
  713. axisLine: {
  714. onZero: false
  715. },
  716. splitLine: {
  717. show: false
  718. },
  719. min: 'dataMin',
  720. max: 'dataMax',
  721. axisPointer: {
  722. z: 100
  723. }
  724. }],
  725. yAxis: [{
  726. scale: true,
  727. splitNumber: 4,
  728. position: 'right',
  729. axisTick: {
  730. show: false
  731. },
  732. splitLine: {
  733. show: false,
  734. lineStyle: {
  735. color: '#e3e3e3'
  736. }
  737. },
  738. axisLabel: {
  739. inside: false,
  740. formatter: '{value}\n',
  741. color: '#999999'
  742. }
  743. }],
  744. series: [{
  745. name: that.history.base.token + '-USDT',
  746. type: 'candlestick',
  747. data: data.linearr,
  748. itemStyle: {
  749. color: upColor,
  750. color0: downColor,
  751. borderColor: undefined,
  752. borderColor0: undefined
  753. }
  754. },
  755. {
  756. name: "MA5",
  757. smooth: true,
  758. type: 'line',
  759. data: that.calculateMA(5, data),
  760. showSymbol: false,
  761. lineStyle: {
  762. width: 1
  763. }
  764. },
  765. {
  766. name: "MA10",
  767. smooth: true,
  768. type: 'line',
  769. data: that.calculateMA(10, data),
  770. showSymbol: false,
  771. lineStyle: {
  772. width: 1
  773. }
  774. },
  775. {
  776. name: "MA20",
  777. smooth: true,
  778. type: 'line',
  779. data: that.calculateMA(20, data),
  780. showSymbol: false,
  781. lineStyle: {
  782. width: 1
  783. }
  784. },
  785. ]
  786. }),
  787. true
  788. )
  789. } else {
  790. chart.setOption({
  791. xAxis: [{
  792. type: 'category',
  793. data: data.xarr,
  794. }],
  795. series: [{
  796. name: that.history.base.token + '-USDT',
  797. data: data.linearr,
  798. },
  799. {
  800. name: "MA5",
  801. data: that.calculateMA(5, data),
  802. },
  803. {
  804. name: "MA10",
  805. data: that.calculateMA(10, data),
  806. },
  807. {
  808. name: "MA20",
  809. data: that.calculateMA(20, data),
  810. },
  811. ]
  812. })
  813. }
  814. } catch (e) {
  815. console.log(e, 'cuowu');
  816. //TODO handle the exception
  817. }
  818. },
  819. // 页面跳转
  820. nav(url) {
  821. console.log('tz');
  822. if (!this.hasLogin) {
  823. uni.showModal({
  824. title: this.$t('enter.c4'),
  825. content: this.$t('enter.b5'),
  826. success: (e) => {
  827. // 判断是否点击确认按钮
  828. if (e.confirm) {
  829. // 保存当前页面地址
  830. saveUrl()
  831. // 跳转页面
  832. interceptor()
  833. }
  834. }
  835. })
  836. return
  837. }
  838. uni.navigateTo({
  839. url,
  840. fail(err) {
  841. console.log(err);
  842. }
  843. });
  844. },
  845. },
  846. };
  847. </script>
  848. <style lang="scss">
  849. .all {
  850. width: 750rpx;
  851. /* height: 2500rpx; */
  852. height: 100%;
  853. padding-top: var(--status-bar-height);
  854. padding-bottom: 30rpx;
  855. }
  856. .tab {
  857. padding: 30rpx 20rpx;
  858. margin: 0 30rpx;
  859. background-color: #191A1F;
  860. border-radius: 20px;
  861. .tab-item {
  862. color: #FFF;
  863. font-size: $font-lg;
  864. padding: 0 20rpx;
  865. padding-bottom: 10rpx;
  866. &.action {
  867. color: #F5A944;
  868. border-bottom: 1px solid #F5A944;
  869. }
  870. }
  871. .top {
  872. height: 530rpx;
  873. width: 100%;
  874. }
  875. }
  876. .center {
  877. padding: 30rpx;
  878. line-height: 1;
  879. align-items: flex-start;
  880. .le,
  881. .ri {
  882. width: 50%;
  883. }
  884. .le {
  885. .tit {
  886. font-weight: bold;
  887. .ti1 {
  888. font-size: 26rpx;
  889. color: #ffffff;
  890. }
  891. .ti2 {
  892. font-size: 22rpx;
  893. padding-left: 10rpx;
  894. color: #999999;
  895. }
  896. }
  897. .he {
  898. padding-top: 40rpx;
  899. .numbox {
  900. flex-wrap: wrap;
  901. .he1 {
  902. background: #fdaf41;
  903. border-radius: 10rpx;
  904. margin-bottom: 40rpx;
  905. margin-right: 20rpx;
  906. width: 84rpx;
  907. height: 84rpx;
  908. justify-content: center;
  909. .wen {
  910. font-size: 30rpx;
  911. font-weight: bold;
  912. color: #000000;
  913. }
  914. }
  915. }
  916. }
  917. .yi {
  918. color: #ffffff;
  919. font-size: $font-base;
  920. .img {
  921. width: 41rpx;
  922. height: 42rpx;
  923. }
  924. .wz {
  925. font-weight: bold;
  926. }
  927. }
  928. .shu {
  929. padding-top: 10rpx;
  930. font-size: 51rpx;
  931. font-weight: bold;
  932. color: #fdb242;
  933. }
  934. }
  935. .ri {
  936. .ti {
  937. font-size: 26rpx;
  938. font-weight: bold;
  939. .t1 {
  940. color: #ffffff;
  941. }
  942. .t2 {
  943. color: #fdaf41;
  944. }
  945. }
  946. .dh {
  947. width: 100%;
  948. padding: 20rpx 30rpx;
  949. margin-top: 30rpx;
  950. background: #efefef;
  951. border-radius: 10rpx;
  952. .te {
  953. font-size: 44rpx;
  954. font-weight: 800;
  955. color: #000000;
  956. }
  957. }
  958. .btn {
  959. padding-top: 30rpx;
  960. .bt {
  961. padding-bottom: 10rpx;
  962. .btnItem {
  963. width: 49%;
  964. height: 70rpx;
  965. line-height: 70rpx;
  966. text-align: center;
  967. .imag {
  968. width: 32rpx;
  969. height: 20rpx;
  970. }
  971. .xia {
  972. font-size: 28rpx;
  973. font-weight: 800;
  974. color: #ffffff;
  975. }
  976. }
  977. .btnle {
  978. border-radius: 50rpx 0 0 50rpx;
  979. background-color: #df5660;
  980. }
  981. .btnri {
  982. border-radius: 0 50rpx 50rpx 0;
  983. background-color: #5bb786;
  984. }
  985. }
  986. }
  987. .db {
  988. justify-content: flex-end;
  989. padding-top: 30rpx;
  990. .jl {
  991. font-size: $font-lg + 4rpx;
  992. font-weight: 400;
  993. color: #999999;
  994. }
  995. .sj {
  996. width: 40rpx;
  997. height: 40rpx;
  998. background: #bfbfbf;
  999. border-radius: 3rpx;
  1000. text-align: center;
  1001. line-height: 40rpx;
  1002. margin-left: 10rpx;
  1003. }
  1004. }
  1005. }
  1006. }
  1007. .kb {
  1008. width: 750rpx;
  1009. height: 20rpx;
  1010. background-color: #191a1f;
  1011. }
  1012. .last {
  1013. padding: 30rpx;
  1014. line-height: 1;
  1015. font-size: 24rpx;
  1016. font-weight: 800;
  1017. color: #fff;
  1018. .lb {
  1019. width: 14rpx;
  1020. height: 20rpx;
  1021. margin-left: 10rpx;
  1022. }
  1023. }
  1024. .bg {
  1025. padding: 0 30rpx;
  1026. background-color: #000000;
  1027. color: #fff;
  1028. text-align: center;
  1029. font-size: 28rpx;
  1030. padding-bottom: 30rpx;
  1031. .biaotou {
  1032. font-weight: 800;
  1033. padding-bottom: 10rpx;
  1034. }
  1035. .biwe {
  1036. width: 25%;
  1037. .zz {
  1038. width: 22rpx;
  1039. height: 14rpx;
  1040. margin-left: 8rpx;
  1041. }
  1042. .nametip {
  1043. font-size: 18rpx;
  1044. color: #999999;
  1045. padding-left: 8rpx;
  1046. &.green {
  1047. color: #5bb786;
  1048. }
  1049. &.red {
  1050. color: #df5660;
  1051. }
  1052. }
  1053. }
  1054. .biwe:nth-child(1) {
  1055. flex-shrink: 0;
  1056. text-align: left;
  1057. align-items: flex-end;
  1058. }
  1059. .biwe:nth-child(4) {
  1060. flex-shrink: 0;
  1061. width: 200rpx;
  1062. }
  1063. .list {
  1064. font-weight: bold;
  1065. padding: 20rpx 0;
  1066. border-bottom: 1px solid rgba(43, 42, 38, 0.52);
  1067. }
  1068. .list-buttom {
  1069. width: 100rpx;
  1070. border-radius: 30rpx;
  1071. font-size: 16rpx;
  1072. padding: 10rpx 0;
  1073. &.success {
  1074. background: $color-green;
  1075. }
  1076. &.red {
  1077. background: $color-yellow;
  1078. }
  1079. &.primary {
  1080. background: #01ebf6;
  1081. color: #000000;
  1082. }
  1083. }
  1084. }
  1085. .chz {
  1086. background: #191a1f;
  1087. border-radius: 20rpx;
  1088. margin: 0 30rpx;
  1089. color: #ffffff;
  1090. font-weight: bold;
  1091. padding: 20rpx 30rpx;
  1092. .yue {
  1093. font-size: 28rpx;
  1094. }
  1095. .yes {
  1096. color: #fdaf41;
  1097. }
  1098. .quc {
  1099. font-size: 26rpx;
  1100. font-weight: 500;
  1101. color: #ffffff;
  1102. }
  1103. .choz {
  1104. width: 22rpx;
  1105. height: 14rpx;
  1106. }
  1107. }
  1108. .alert-detail {
  1109. background-color: #FFF;
  1110. border-radius: 10rpx;
  1111. width: 600rpx;
  1112. .red {
  1113. color: #df5660;
  1114. }
  1115. .green {
  1116. color: $color-green;
  1117. }
  1118. .flex {
  1119. padding: 10rpx 0;
  1120. }
  1121. }
  1122. .lisT {
  1123. font-size: $font-lg;
  1124. font-weight: bold;
  1125. &.red {
  1126. color: #df5660;
  1127. }
  1128. &.green {
  1129. color: $color-green;
  1130. }
  1131. }
  1132. .lis {
  1133. .liss {
  1134. border-radius: 5rpx;
  1135. padding: 10rpx 20rpx;
  1136. font-size: 22rpx;
  1137. font-weight: 500;
  1138. color: #FFF;
  1139. &.red {
  1140. background: $color-yellow;
  1141. }
  1142. &.green {
  1143. background: $color-green;
  1144. }
  1145. &.primary {
  1146. background: #01ebf6;
  1147. }
  1148. }
  1149. }
  1150. </style>