entertainment.vue 29 KB

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