heyue.vue 24 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081
  1. <template>
  2. <view class="content">
  3. <!-- #ifdef APP-PLUS -->
  4. <view class="vheight"></view>
  5. <!-- #endif -->
  6. <view class="usdtTitle flex">
  7. <view class="left flex">
  8. <image @click="alertShow=true" class="img margin-r-10" src="../../static/icon/hy02.png" mode="widthFix">
  9. </image>
  10. <view class="margin-r-10">
  11. {{listOBj[actionList].name}}
  12. </view>
  13. <view :class="{'font-color-green':listOBj[actionList].bool,'font-color-red':!listOBj[actionList].bool}">
  14. {{listOBj[actionList].dcf}}
  15. </view>
  16. </view>
  17. <view class="right">
  18. <image class="img" src="../../static/icon/hy01.png" mode="widthFix"></image>
  19. </view>
  20. </view>
  21. <view class="box flex padding-t-20 padding-b-30">
  22. <view class="item" style="width: 65%;">
  23. <!-- <view class="itemName flex">
  24. <view class="itemMinName">
  25. 当前價格
  26. </view>
  27. <view class="itemMinName">
  28. 開盤價
  29. </view>
  30. <view class="itemMinName">
  31. 最高價
  32. </view>
  33. <view class="itemMinName">
  34. 最低價
  35. </view>
  36. <view class="itemMinName">
  37. 成交數量
  38. </view>
  39. </view>
  40. <view class="itemList">
  41. <view class="list flex font-color-green">
  42. <view class="li top">
  43. {{listOBj[actionList].last}}
  44. </view>
  45. <view class="li top">
  46. {{listOBj[actionList].sodUtc0}}
  47. </view>
  48. <view class="li top">
  49. {{listOBj[actionList].high24h}}
  50. </view>
  51. <view class="li top">
  52. {{listOBj[actionList].low24h}}
  53. </view>
  54. <view class="li top">
  55. {{listOBj[actionList].volCcy24h|actionMoney}}
  56. </view>
  57. </view>
  58. </view> -->
  59. <view class="itemTitle margin-b-20">
  60. {{$t('hy.jyfx')}}
  61. </view>
  62. <view class="buttomBox flex">
  63. <view @click="typeIndex=1" class="buttom " :class="{action:typeIndex==1}">
  64. {{$t('hy.sz')}}
  65. </view>
  66. <view @click="typeIndex=2" class="buttom " :class="{action:typeIndex==2,'bg-danger':typeIndex==2}">
  67. {{$t('hy.xd')}}
  68. </view>
  69. </view>
  70. <view class="tabType flex ">
  71. <view class="tab" @click="jyType=1" :class="{action:jyType==1}">
  72. {{$t('hy.xjwt')}}
  73. </view>
  74. <view class="tab" @click="jyType=2" :class="{action:jyType==2}">
  75. {{$t('hy.sjwt')}}
  76. </view>
  77. </view>
  78. <view class="inputBox margin-b-20 flex" v-if="jyType==1">
  79. <input v-model="xzMoney" class="input" :placeholder="$t('hy.jg')" type="number">
  80. <view @click="xzMoney=listOBj[actionList].last" class="buttomZd font-color-yellow">
  81. {{$t('hy.djhq')}}
  82. </view>
  83. </view>
  84. <view class="itemTitle margin-b-20">
  85. {{$t('hy.jygs')}}
  86. </view>
  87. <view class="inputBox flex margin-b-20">
  88. <input v-model="payNum" class="input" :placeholder="$t('hy.jygs')" type="number">
  89. <view class="rightInputBox flex">
  90. <image @click="payNum>0?payNum--:false" class="img" src="../../static/icon/hy04.png"
  91. mode="scaleToFill"></image>
  92. <view class="jg">
  93. </view>
  94. <image @click="payNum++" class="img" src="../../static/icon/hy03.png" mode="scaleToFill">
  95. </image>
  96. </view>
  97. </view>
  98. <view class="itemTitle margin-b-20">
  99. {{$t('hy.ggbs')}}
  100. </view>
  101. <view class="itemLeftList flex margin-b-20">
  102. <view class="ll" @click="changeGG(ind,ls)" :class="{action:ind==ggIndex}"
  103. v-for="(ls,ind) in ggList">
  104. {{ls.num}}
  105. </view>
  106. </view>
  107. <view class="inputBox flex margin-b-20">
  108. <input v-model="ggBs" class="input" placeholder="請輸入槓桿倍率" type="number">
  109. </view>
  110. <view class="flex margin-b-20">
  111. <view class="itemTitle">
  112. {{$t('hy.zsj')}}
  113. </view>
  114. <view class="inputBox flex">
  115. <input v-model="zsMoney" :placeholder="$t('hy.zsj')" class="input" type="number">
  116. </view>
  117. </view>
  118. <view class="flex margin-b-20">
  119. <view class="itemTitle">
  120. {{$t('hy.zyj')}}
  121. </view>
  122. <view class="inputBox flex">
  123. <input v-model="zyMoney" placeholder="$t('hy.zyj')" class="input" type="number">
  124. </view>
  125. </view>
  126. <view class="flex margin-b-20">
  127. <view class="itemTitle">
  128. {{$t('hy.bzj')}}
  129. </view>
  130. <view class="itemTitle">
  131. {{bzjMoney}}
  132. </view>
  133. </view>
  134. <view class="flex margin-b-20">
  135. <view class="itemTitle">
  136. {{$t('hy.kyhyye')}}
  137. </view>
  138. <view class="itemTitle">
  139. {{userInfo.money}}
  140. </view>
  141. </view>
  142. <view class="flex margin-b-20">
  143. <view class="itemTitle">
  144. {{$t('hy.sxf')}}
  145. </view>
  146. <view class="itemTitle">
  147. {{sxfMoney}}
  148. </view>
  149. </view>
  150. <view class="buttomSubmit" :class="{'bg-success':typeIndex==1,'bg-danger':typeIndex==2}" @click="UpOrderHandle()">
  151. {{typeIndex==1?$t('hy.zd'):$t('hy.zk')}}
  152. </view>
  153. </view>
  154. <view class="right-wrap">
  155. <view class="line flex">
  156. <view class="">
  157. {{$t('hy.jg')}}
  158. </view>
  159. <view class="">
  160. {{$t('hy.sl')}}
  161. </view>
  162. </view>
  163. <!-- 買入 -->
  164. <view class="" style="height: 400rpx;">
  165. <view class="line flex" v-for="item in gmList" style="color: #0ecb81;">
  166. <view class="">
  167. {{item.pri}}
  168. </view>
  169. <view class="">
  170. {{item.num}}
  171. </view>
  172. </view>
  173. </view>
  174. <!-- 當前價格 -->
  175. <view class="new-price">
  176. {{listOBj[actionList].last}}
  177. </view>
  178. <!-- 賣出 -->
  179. <view class="" style="height: 400rpx;">
  180. <view class="line flex" v-for="item in mcList" style="color: #f7465c;">
  181. <view class="">
  182. {{item.pri}}
  183. </view>
  184. <view class="">
  185. {{item.num}}
  186. </view>
  187. </view>
  188. </view>
  189. </view>
  190. </view>
  191. <view class="box margin-t-30 padding-t-30 padding-b-30">
  192. <view class="flex listTitleBox">
  193. <view class="leftBottom flex">
  194. <view @click="ddTypeChage(0)" class="titleType margin-r-30" :class="{action:ddType==0}">
  195. {{$t('hy.xjwt')}}
  196. </view>
  197. <view @click="ddTypeChage(1)" class="titleType" :class="{action:ddType==1}">
  198. {{$t('hy.zc')}}
  199. </view>
  200. </view>
  201. <view class="rightBottom flex" @click="navto('/pages/heyue/tradlist')">
  202. <image class="img" src="../../static/icon/hy02.png" mode="widthFix"></image>
  203. <view class="more">
  204. {{$t('hy.qbdd')}}
  205. </view>
  206. </view>
  207. </view>
  208. <view v-for="(item,ind) in loadData[ddType].list" class="usdtList padding-t-30 padding-b-30">
  209. <view class="flex">
  210. <view class="name">
  211. <text v-if="item.direction==1" class="font-color-green">
  212. {{$t('hy.zd')}}
  213. </text>
  214. <text v-if="item.direction==2" class="font-color-red">
  215. {{$t('hy.zk')}}
  216. </text>
  217. <text>
  218. {{item.symbol}}
  219. </text>
  220. <text v-if="ddType==1 && item.direction==2"
  221. :class="{'font-color-green':+((item.price - listOBj[item.symbol.replace('/','-')].last)*item.num)>=0,'font-color-red':+((item.price - listOBj[item.symbol.replace('/','-')].last)*item.num)<0}">
  222. <!-- {{+item.profit}} -->{{ ((item.price - listOBj[item.symbol.replace('/','-')].last)*item.num).toFixed(2)|| ''}}
  223. </text>
  224. <text v-if="ddType==1 && item.direction==1"
  225. :class="{'font-color-green':+(( listOBj[item.symbol.replace('/','-')].last- item.price )*item.num)>=0,'font-color-red':+(( listOBj[item.symbol.replace('/','-')].last- item.price )*item.num)<0}">
  226. <!-- {{+item.profit}} -->{{ (( listOBj[item.symbol.replace('/','-')].last- item.price )*item.num).toFixed(2) || ''}}
  227. </text>
  228. </view>
  229. <view @click="clearorder(item)" v-if="ddType==0" class="usdtListButtom">
  230. {{$t('hy.cx')}}
  231. </view>
  232. <view @click="closeorder(item)" v-if="ddType==1" class="usdtListButtom">
  233. {{$t('hy.pc')}}
  234. </view>
  235. </view>
  236. <view class="tip ">
  237. <text v-if="item.direction==1">
  238. {{$t('hy.wtsj')}}:{{item.wttime}}
  239. </text>
  240. <text v-if="item.direction==2">
  241. {{$t('hy.kcsj')}}:{{item.addtime}}
  242. </text>
  243. </view>
  244. <view class="flex" style="flex-wrap: wrap;">
  245. <view v-if="ddType==0" class="tipList">
  246. <view class="nameTip">
  247. {{$t('hy.wtjg')}}
  248. </view>
  249. <view class="text">
  250. {{item.wt_price}}
  251. </view>
  252. </view>
  253. <view v-if="ddType==1" class="tipList">
  254. <view class="nameTip">
  255. {{$t('hy.kcdj')}}
  256. </view>
  257. <view class="text">
  258. {{item.price}}
  259. </view>
  260. </view>
  261. <view class="tipList">
  262. <view class="nameTip">
  263. {{$t('hy.bzj')}}
  264. </view>
  265. <view class="text">
  266. {{item.bond}}
  267. </view>
  268. </view>
  269. <view class="tipList">
  270. <view class="nameTip">
  271. {{$t('hy.jygs')}}
  272. </view>
  273. <view class="text">
  274. {{item.num}}
  275. </view>
  276. </view>
  277. <view class="tipList">
  278. <view class="nameTip">
  279. {{$t('hy.ggbs')}}
  280. </view>
  281. <view class="text">
  282. {{item.ggan}}
  283. </view>
  284. </view>
  285. <template>
  286. <view class="tipList">
  287. <view class="nameTip">
  288. {{$t('hy.zydj')}}
  289. </view>
  290. <view class="text">
  291. {{item.zyprice}}
  292. </view>
  293. </view>
  294. <view class="tipList">
  295. <view class="nameTip">
  296. {{$t('hy.zkdj')}}
  297. </view>
  298. <view class="text">
  299. {{item.zsprice}}
  300. </view>
  301. </view>
  302. </template>
  303. </view>
  304. </view>
  305. </view>
  306. <view class="alertBox" v-show="alertShow">
  307. <!-- #ifdef APP-PLUS -->
  308. <view class="vheight"></view>
  309. <!-- #endif -->
  310. <view class="reback">
  311. <image src="../../static/icon/reback.png" mode="" @click="alertShow = false"></image>
  312. </view>
  313. <view class="list flex">
  314. <view class="type">
  315. {{$t('hy.cp')}}
  316. </view>
  317. <view class="type">
  318. {{$t('hy.ssjg')}}
  319. </view>
  320. <view class="type">
  321. {{$t('hy.jrdz')}}
  322. </view>
  323. </view>
  324. <view class="itemlist flex" @click="changeData(ls)" v-for="ls in listOBj" v-if="ls.name != 'BCH/USDT'">
  325. <view class="type name">
  326. {{ls.name}}
  327. </view>
  328. <view class="type money" :class="{'font-color-green':ls.bool,'font-color-red':!ls.bool}">
  329. {{ls.last}}
  330. </view>
  331. <view class="type bfb" :class="{'font-color-green':ls.bool,'font-color-red':!ls.bool}">
  332. {{ls.dcf}}
  333. </view>
  334. </view>
  335. <view class="itemlist flex" @click="changeData(ls)" v-for="ls in listOBj" v-if="ls.name == 'BCH/USDT'">
  336. <view class="type name">
  337. {{ls.name}}
  338. </view>
  339. <view class="type money" :class="{'font-color-green':ls.bool,'font-color-red':!ls.bool}">
  340. {{ls.last}}
  341. </view>
  342. <view class="type bfb" :class="{'font-color-green':ls.bool,'font-color-red':!ls.bool}">
  343. {{ls.dcf}}
  344. </view>
  345. </view>
  346. </view>
  347. </view>
  348. </template>
  349. <script>
  350. import {
  351. mapState,
  352. mapMutations
  353. } from 'vuex';
  354. import {
  355. levertadeLaverorder,
  356. closeorder,
  357. clearorder,
  358. UpOrderHandle,
  359. bond
  360. } from '@/api/heyue.js';
  361. import {
  362. scoketNew,
  363. scoketOpen
  364. } from '@/utils/socket.js';
  365. import {
  366. geLevertade
  367. } from '@/api/index.js';
  368. import { getUser} from '@/api/login.js'
  369. export default {
  370. data() {
  371. return {
  372. // 是否显示弹窗
  373. alertShow: false,
  374. //保存幣種類型
  375. spList: [],
  376. // 右侧允许的最长长度
  377. listLength: 20,
  378. // 当前选中的对象数据列表
  379. // actionList: 'BCH-USDT',
  380. actionList: 'BTC-USDT',
  381. // 價格列表
  382. listOBj: {
  383. "BCH-USDT": {},
  384. "BTC-USDT": {}
  385. },
  386. // 当前选中的杠杆倍数
  387. ggIndex: 0,
  388. ggList: [{
  389. num: 5
  390. }, {
  391. num: 10
  392. }, {
  393. num: 20
  394. }, {
  395. num: 50
  396. }, {
  397. num: 100
  398. }],
  399. //当前选中的交易类别
  400. typeIndex: 1,
  401. // 交易类型
  402. jyType: 1,
  403. //交易数量
  404. payNum: 0,
  405. // 杠杆倍数
  406. ggBs: 0,
  407. // 限价委托价格
  408. xzMoney: 0,
  409. // 止损价格
  410. zsMoney: 0,
  411. // 止盈价格
  412. zyMoney: 0,
  413. // 保證金
  414. bzjMoney: 0,
  415. // 手續費
  416. sxfMoney: 0,
  417. ddType: 1, //1委托订单2持仓订单3成交订单
  418. loadData: [{
  419. state: 1,
  420. text: '限价委托',
  421. loadingType: 'more',
  422. list: [],
  423. page: 1, //当前页数
  424. limit: 10 //每次信息条数
  425. },
  426. {
  427. state: 2,
  428. text: '持仓',
  429. loadingType: 'more',
  430. list: [],
  431. page: 1, //当前页数
  432. limit: 10 //每次信息条数
  433. }
  434. ],
  435. setTimeoutObj: '',
  436. // 是否提交做多請求
  437. upDataLoding: false,
  438. gmList: [],
  439. mcList: [],
  440. gmobj: {},
  441. mcobj: {}
  442. }
  443. },
  444. watch: {
  445. ggBs(newValue, oldValue) {
  446. this.ggBs = newValue;
  447. this.bond();
  448. },
  449. payNum(newValue, oldValue) {
  450. this.payNum = newValue;
  451. this.bond();
  452. }
  453. },
  454. filters: {
  455. actionMoney: function(value) {
  456. let num = 0;
  457. if (+value > 10000000) {
  458. num = (+(value / 10000000).toFixed(2)) + '千萬'
  459. } else if (+value > 10000) {
  460. num = (+(value / 10000).toFixed(2)) + '萬'
  461. }
  462. return num;
  463. }
  464. },
  465. onLoad() {
  466. // 初始化保存BCH对象
  467. this.levertadeLaverorder();
  468. },
  469. onShow: function() {
  470. this.geLevertade()
  471. this.initListData()
  472. },
  473. onHide() {
  474. this.closeScoket()
  475. clearInterval(this.setTimeoutObj)
  476. },
  477. onReachBottom() {
  478. this.levertadeLaverorder();
  479. },
  480. onReady() {
  481. console.log(this.userInfo);
  482. },
  483. computed: {
  484. ...mapState('user', ['userInfo'])
  485. },
  486. methods: {
  487. ...mapMutations('user',['login','setUserInfo']),
  488. // 提交訂單
  489. UpOrderHandle() {
  490. const that = this;
  491. if (this.upDataLoding) {
  492. return
  493. }
  494. uni.showLoading({
  495. title: that.$t('hy.tjz'),
  496. mask: true
  497. });
  498. this.upDataLoding = true;
  499. that.bond().then(() => {
  500. UpOrderHandle({
  501. direction: that.typeIndex,
  502. type: that.jyType,
  503. symbol: that.listOBj[that.actionList].name,
  504. mprice: that.jyType == 2 ? that.listOBj[that.actionList].last : that.xzMoney,
  505. ggan: that.ggBs,
  506. num: that.payNum,
  507. upbondmoney: that.bzjMoney,
  508. fee: that.sxfMoney,
  509. zyprice: that.zyMoney,
  510. zsprice: that.zsMoney,
  511. }).then((e) => {
  512. uni.hideLoading()
  513. that.upDataLoding = false;
  514. uni.showModal({
  515. title: that.$t('hy.ts'),
  516. content: that.jyType == 1?that.$t('hy.gdcg'):that.$t('hy.jycg'),
  517. confirmText: that.$t('hy.qr'),
  518. showCancel: false,
  519. });
  520. obj.levertadeLaverorder();
  521. }).catch(() => {
  522. uni.hideLoading()
  523. that.upDataLoding = false;
  524. })
  525. }).catch(() => {
  526. uni.hideLoading()
  527. that.upDataLoding = false;
  528. })
  529. },
  530. // 修改当前选中的数据对象
  531. changeData(item) {
  532. console.log(item, 'qh');
  533. this.actionList = item.instId;
  534. this.gmList = []
  535. this.mcList = []
  536. this.alertShow = false;
  537. },
  538. // 獲取保證金
  539. bond() {
  540. const taht = this
  541. return new Promise((resolve, rejact) => {
  542. bond({
  543. name: taht.actionList.split('-')[0],
  544. 'num': taht.payNum,
  545. 'gann': taht.ggBs
  546. }).then((e) => {
  547. taht.sxfMoney = e.data.fee
  548. taht.bzjMoney = e.data.bong ? e.data.bong : 0
  549. console.log(e)
  550. resolve()
  551. }).catch(() => {
  552. rejact()
  553. console.log(e)
  554. })
  555. })
  556. },
  557. //循環獲取數據
  558. initListData() {
  559. this.setTimeoutObj = setInterval(() => {
  560. this.levertadeLaverorder();
  561. }, 2000)
  562. },
  563. // 獲取幣種列表
  564. geLevertade() {
  565. uni.showLoading({
  566. title: this.$t('hy.sjjzz') + '...',
  567. mask: true
  568. });
  569. const that = this;
  570. geLevertade().then((e) => {
  571. that.spList = e.list;
  572. // 开启长连接
  573. that.onScoket()
  574. })
  575. },
  576. // 开始请求长连接
  577. onScoket() {
  578. const that = this;
  579. that.scoket = scoketNew("wss://wsaws.okx.com:8443/ws/v5/public");
  580. that.scoket.scoketOpen().then((res) => {
  581. uni.hideLoading()
  582. const requestList = that.spList.map((e) => {
  583. return {
  584. "channel": "tickers",
  585. "instId": e.coinname.toUpperCase() + "-USDT"
  586. }
  587. })
  588. that.scoket.scoketSend({
  589. "op": "subscribe",
  590. "args": requestList
  591. }).then((res) => {
  592. console.log(res, '发送成功');
  593. })
  594. that.scoket.scoketMessage((res) => {
  595. try {
  596. if (res.data) {
  597. // 判断是否已经有这个对象
  598. // console.log(res.arg.instId, 'id', that.listOBj);
  599. that.listOBj[res.arg.instId] = res.data[0];
  600. const item = that.listOBj[res.arg.instId];
  601. // 转为数字
  602. item.last = +item.last;
  603. item.sodUtc0 = +item.sodUtc0;
  604. // 保存收益情况
  605. item.bool = item.last - item.sodUtc0 > 0 ? true : false;
  606. // 算出收益率
  607. item.dcf = (+((item.last - item.sodUtc0) / item.sodUtc0 * 100).toFixed(
  608. 2)) + '%'
  609. item.name = item.instId.replace('-', '/')
  610. if(that.actionList == item.instId) {
  611. that.gmList.unshift({'pri':(item.bidPx*1).toFixed(5),'num': (item.bidSz*1).toFixed(5)})
  612. that.gmList = that.gmList.slice(0,9)
  613. that.mcList.unshift({'pri':(item.askPx*1).toFixed(5),'num': (item.askSz*1).toFixed(5)})
  614. that.mcList = that.mcList.slice(0,9)
  615. }
  616. that.listOBj = Object.assign({}, that.listOBj);
  617. console.log(that.listOBj,'that.listOBj')
  618. }
  619. } catch (e) {
  620. console.log(res, res.data, '报错');
  621. }
  622. })
  623. })
  624. },
  625. closeScoket() {
  626. this.scoket.scoketClose();
  627. },
  628. // 平倉
  629. closeorder(item) {
  630. const that = this;
  631. uni.showModal({
  632. title: that.$t('hy.pc'),
  633. content: that.$t('hy.ljpc'),
  634. confirmText: that.$t('hy.qr'),
  635. success: res => {
  636. if (res.confirm) {
  637. uni.showLoading({
  638. title: that.$t('hy.qqz') + '...',
  639. mask: true
  640. });
  641. closeorder({
  642. id: item.id
  643. }).then((e) => {
  644. uni.hideLoading()
  645. uni.showToast({
  646. title: that.$t('hy.pccg'),
  647. icon: 'success'
  648. });
  649. that.ddTypeInit()
  650. }).catch(() => {
  651. uni.hideLoading()
  652. })
  653. }
  654. },
  655. fail: () => {},
  656. complete: () => {}
  657. });
  658. },
  659. // 撤銷
  660. clearorder(item) {
  661. const that = this;
  662. uni.showModal({
  663. title: that.$t('hy.cx'),
  664. content: that.$t('hy.ljcx'),
  665. confirmText: that.$t('hy.qr'),
  666. success: res => {
  667. if (res.confirm) {
  668. uni.showLoading({
  669. title: that.$t('hy.qqz') +'...',
  670. mask: true
  671. });
  672. clearorder({
  673. id: item.id
  674. }).then((e) => {
  675. uni.hideLoading()
  676. uni.showToast({
  677. title: that.$t('hy.cxcg'),
  678. icon: 'success'
  679. });
  680. that.ddTypeInit()
  681. }).catch(() => {
  682. uni.hideLoading()
  683. })
  684. }
  685. },
  686. fail: () => {},
  687. complete: () => {}
  688. });
  689. },
  690. // 获取订单商品
  691. levertadeLaverorder(source) {
  692. //这里是将订单挂载到tab列表下
  693. let index = this.ddType;
  694. let navItem = this.loadData[index];
  695. let state = navItem.state;
  696. if (source === 'tabChange' && navItem.loaded === true) {
  697. //tab切换只有第一次需要加载数据
  698. return;
  699. }
  700. if (navItem.loadingType === 'loading') {
  701. //防止重复加载
  702. return;
  703. }
  704. // if (navItem.loadingType === 'noMore') {
  705. // //防止重复加载
  706. // return;
  707. // }
  708. // 修改当前对象状态为加载中
  709. navItem.loadingType = 'loading';
  710. // uni.showLoading({
  711. // title: '數據加載中',
  712. // mask: true
  713. // });
  714. levertadeLaverorder({
  715. type: state,
  716. page: navItem.page,
  717. limit: navItem.limit
  718. })
  719. .then(({
  720. list
  721. }) => {
  722. // uni.hideLoading()
  723. let arr = list.map(e => {
  724. e.direction = +e.direction;
  725. e.bond = +e.bond
  726. e.price = +e.price
  727. e.wt_price = +e.wt_price
  728. return e;
  729. });
  730. navItem.list = arr;
  731. navItem.loadingType = 'more';
  732. this.$set(navItem, 'loaded', true);
  733. this.getUser()
  734. })
  735. .catch(e => {
  736. // uni.hideLoading()
  737. console.log(e);
  738. });
  739. },
  740. // 修改杠杆倍数
  741. changeGG(ind, item) {
  742. this.ggBs = item.num
  743. this.ggIndex = ind
  744. },
  745. // 列表切换
  746. ddTypeChage(ind) {
  747. this.ddType = ind;
  748. this.levertadeLaverorder('tabChange');
  749. },
  750. // 初始化重新加載
  751. ddTypeInit() {
  752. // 初始化數據
  753. let item = this.loadData[this.ddType];
  754. item.loadingType = 'more';
  755. item.list = [];
  756. item.page = 1;
  757. item.limit = 10;
  758. item.loaded = false;
  759. this.levertadeLaverorder();
  760. },
  761. navto(url) {
  762. uni.navigateTo({
  763. url,
  764. fail() {
  765. uni.switchTab({
  766. url
  767. })
  768. }
  769. })
  770. },
  771. getUser() {
  772. getUser().then(re => {
  773. this.setUserInfo(re.data)
  774. })
  775. }
  776. }
  777. }
  778. </script>
  779. <style lang="scss">
  780. .usdtTitle,
  781. .box {
  782. padding: 0 20rpx;
  783. width: 750rpx;
  784. background-color: #FFFFFF;
  785. }
  786. .usdtTitle {
  787. border-bottom: 1px solid $border-color-light;
  788. line-height: 1;
  789. .left {
  790. font-size: 32rpx;
  791. font-weight: bold;
  792. .img {
  793. width: 36rpx;
  794. }
  795. }
  796. .right {
  797. .img {
  798. width: 48rpx;
  799. }
  800. }
  801. }
  802. .box {
  803. line-height: 1;
  804. align-items: flex-start;
  805. .itemTitle {
  806. font-weight: bold;
  807. font-size: $font-sm;
  808. }
  809. .item {
  810. // flex-grow: 1;
  811. // width: 50%;
  812. flex-shrink: 0;
  813. }
  814. .buttomBox {
  815. font-size: $font-sm;
  816. .buttom {
  817. width: 350rpx;
  818. padding: 20rpx 0;
  819. text-align: center;
  820. border-radius: 10rpx;
  821. background-color: #F5F5F5;
  822. &.action {
  823. color: #FFFFFF;
  824. background-color: $color-green;
  825. }
  826. }
  827. }
  828. .tabType {
  829. justify-content: space-around;
  830. .tab {
  831. padding-top: 30rpx;
  832. padding-bottom: 20rpx;
  833. color: #545D6F;
  834. font-size: $font-sm;
  835. font-weight: bold;
  836. &.action {
  837. color: $uni-color-warning;
  838. }
  839. }
  840. }
  841. .inputBox {
  842. height: 60rpx;
  843. border-radius: 10rpx;
  844. padding: 0 20rpx;
  845. display: flex;
  846. align-items: center;
  847. border: 1px solid $border-color-light;
  848. .buttomZd {
  849. font-size: $font-sm;
  850. }
  851. .input {
  852. font-size: $font-sm;
  853. flex-grow: 1;
  854. }
  855. .rightInputBox {
  856. .jg {
  857. border: 1px solid $border-color-light;
  858. height: 50rpx;
  859. margin: 0 30rpx;
  860. }
  861. .img {
  862. width: 28rpx;
  863. height: 28rpx;
  864. }
  865. }
  866. }
  867. .itemLeftList {
  868. justify-content: space-around;
  869. .ll {
  870. border: 1px solid $border-color-light;
  871. width: 74rpx;
  872. height: 54rpx;
  873. line-height: 54rpx;
  874. text-align: center;
  875. font-size: $font-sm;
  876. font-weight: bold;
  877. &.action {
  878. background-color: #F5F5F5;
  879. }
  880. }
  881. }
  882. .buttomSubmit {
  883. color: #FFFFFF;
  884. height: 64rpx;
  885. line-height: 64rpx;
  886. text-align: center;
  887. font-size: $font-sm;
  888. border-radius: 10rpx;
  889. }
  890. .itemName {
  891. .itemMinName {
  892. width: 20%;
  893. font-size: 22rpx;
  894. color: #5D6677;
  895. }
  896. }
  897. .itemList {
  898. .list {
  899. font-size: 20rpx;
  900. padding: 10rpx 0;
  901. .li {
  902. width: 20%;
  903. }
  904. }
  905. .llMax {
  906. padding: 30rpx 0;
  907. font-weight: bold;
  908. font-size: $font-lg;
  909. }
  910. }
  911. .listTitleBox {
  912. border-bottom: 1px solid $border-color-light;
  913. align-items: flex-start;
  914. .leftBottom {
  915. flex-shrink: 0;
  916. font-size: $font-lg;
  917. font-weight: bold;
  918. .action {
  919. border-bottom: 2px solid $uni-color-warning;
  920. }
  921. .titleType {
  922. padding-bottom: 20rpx;
  923. }
  924. }
  925. .rightBottom {
  926. font-size: $font-base;
  927. color: #707A8A;
  928. flex-shrink: 0;
  929. .img {
  930. width: 36rpx;
  931. }
  932. }
  933. }
  934. .usdtList {
  935. color: #707A8A;
  936. border-bottom: 1px solid $border-color-light;
  937. .name {
  938. font-size: $font-lg;
  939. font-weight: bold;
  940. }
  941. .usdtListButtom {
  942. font-size: $font-base;
  943. background-color: #F5F5F5;
  944. color: $uni-color-warning;
  945. border-radius: 10rpx;
  946. padding: 10rpx 20rpx;
  947. }
  948. .tip {
  949. padding-top: 10rpx;
  950. padding-bottom: 10rpx;
  951. font-size: $font-base;
  952. }
  953. .tipList {
  954. font-size: $font-sm;
  955. text-align: center;
  956. width: 33%;
  957. padding-top: 20rpx;
  958. .nameTip {
  959. padding-bottom: 20rpx;
  960. }
  961. }
  962. }
  963. }
  964. .alertBox {
  965. position: fixed;
  966. top: 0;
  967. left: 0;
  968. right: 0;
  969. bottom: 0;
  970. background-color: #FFFFFF;
  971. text-align: center;
  972. color: #707A8A;
  973. .reback {
  974. width: 100%;
  975. display: flex;
  976. justify-content: flex-start;
  977. padding-left: 10rpx;
  978. padding-top: 10rpx;
  979. image {
  980. width: 50rpx;
  981. height: 50rpx;
  982. }
  983. }
  984. .type {
  985. width: 30%;
  986. flex-grow: 1;
  987. }
  988. .itemlist {
  989. padding-top: 20rpx;
  990. .name {
  991. padding-left: 20rpx;
  992. text-align: left;
  993. }
  994. }
  995. .list {
  996. padding: 30rpx 0;
  997. border-bottom: 1px solid $border-color-light;
  998. .type {
  999. font-size: $font-lg;
  1000. font-weight: bold;
  1001. }
  1002. }
  1003. }
  1004. .right-wrap {
  1005. flex-grow: 1;
  1006. padding: 0 10rpx;
  1007. font-size: 24rpx;
  1008. color: #707A8A;
  1009. .line {
  1010. view {
  1011. padding: 10rpx 0;
  1012. }
  1013. }
  1014. }
  1015. .new-price {
  1016. font-size: 36rpx;
  1017. color: #0ecb81;
  1018. padding: 20rpx;
  1019. }
  1020. .vheight {
  1021. height: var(--status-bar-height);
  1022. }
  1023. </style>