entertainment.vue 26 KB

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