heyue.vue 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080
  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. 交易方向
  61. </view>
  62. <view class="buttomBox flex">
  63. <view @click="typeIndex=1" class="buttom " :class="{action:typeIndex==1}">
  64. 上漲
  65. </view>
  66. <view @click="typeIndex=2" class="buttom " :class="{action:typeIndex==2,'bg-danger':typeIndex==2}">
  67. 下跌
  68. </view>
  69. </view>
  70. <view class="tabType flex ">
  71. <view class="tab" @click="jyType=1" :class="{action:jyType==1}">
  72. 限價委託
  73. </view>
  74. <view class="tab" @click="jyType=2" :class="{action:jyType==2}">
  75. 市價委託
  76. </view>
  77. </view>
  78. <view class="inputBox margin-b-20 flex" v-if="jyType==1">
  79. <input v-model="xzMoney" class="input" placeholder="請輸入價格" type="number">
  80. <view @click="xzMoney=listOBj[actionList].last" class="buttomZd font-color-yellow">
  81. 點擊獲取
  82. </view>
  83. </view>
  84. <view class="itemTitle margin-b-20">
  85. 交易個數
  86. </view>
  87. <view class="inputBox flex margin-b-20">
  88. <input v-model="payNum" class="input" placeholder="請輸入交易數量" 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. 槓桿倍數
  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. 止損價
  113. </view>
  114. <view class="inputBox flex">
  115. <input v-model="zsMoney" placeholder="請輸入止損價格" class="input" type="number">
  116. </view>
  117. </view>
  118. <view class="flex margin-b-20">
  119. <view class="itemTitle">
  120. 止盈價
  121. </view>
  122. <view class="inputBox flex">
  123. <input v-model="zyMoney" placeholder="請輸入止盈價格" class="input" type="number">
  124. </view>
  125. </view>
  126. <view class="flex margin-b-20">
  127. <view class="itemTitle">
  128. 保證金
  129. </view>
  130. <view class="itemTitle">
  131. {{bzjMoney}}
  132. </view>
  133. </view>
  134. <view class="flex margin-b-20">
  135. <view class="itemTitle">
  136. 可用合約餘額
  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. 手續費
  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?'做多':'做空'}}
  152. </view>
  153. </view>
  154. <view class="right-wrap">
  155. <view class="line flex">
  156. <view class="">
  157. 價格
  158. </view>
  159. <view class="">
  160. 數量
  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. 限價委託
  196. </view>
  197. <view @click="ddTypeChage(1)" class="titleType" :class="{action:ddType==1}">
  198. 持倉
  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. 全部訂單
  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. 做多
  213. </text>
  214. <text v-if="item.direction==2" class="font-color-red">
  215. 做空
  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. 撤銷
  231. </view>
  232. <view @click="closeorder(item)" v-if="ddType==1" class="usdtListButtom">
  233. 平倉
  234. </view>
  235. </view>
  236. <view class="tip ">
  237. <text v-if="item.direction==1">
  238. 委託時間:{{item.wttime}}
  239. </text>
  240. <text v-if="item.direction==2">
  241. 開倉時間:{{item.addtime}}
  242. </text>
  243. </view>
  244. <view class="flex" style="flex-wrap: wrap;">
  245. <view v-if="item.direction==1" class="tipList">
  246. <view class="nameTip">
  247. 限價
  248. </view>
  249. <view class="text">
  250. {{item.price}}
  251. </view>
  252. </view>
  253. <view v-if="item.direction==2" class="tipList">
  254. <view class="nameTip">
  255. 開倉單價
  256. </view>
  257. <view class="text">
  258. {{item.price}}
  259. </view>
  260. </view>
  261. <view class="tipList">
  262. <view class="nameTip">
  263. 保證金
  264. </view>
  265. <view class="text">
  266. {{item.bond}}
  267. </view>
  268. </view>
  269. <view class="tipList">
  270. <view class="nameTip">
  271. 交易個數
  272. </view>
  273. <view class="text">
  274. {{item.num}}
  275. </view>
  276. </view>
  277. <view class="tipList">
  278. <view class="nameTip">
  279. 槓桿倍數
  280. </view>
  281. <view class="text">
  282. {{item.ggan}}
  283. </view>
  284. </view>
  285. <template>
  286. <view class="tipList">
  287. <view class="nameTip">
  288. 止盈單價
  289. </view>
  290. <view class="text">
  291. {{item.zyprice}}
  292. </view>
  293. </view>
  294. <view class="tipList">
  295. <view class="nameTip">
  296. 止損單價
  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. 產品
  316. </view>
  317. <view class="type">
  318. 實時價格
  319. </view>
  320. <view class="type">
  321. 今日漲跌
  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: '提交中',
  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: '提示',
  516. content: '掛單成功',
  517. confirmText: '確認',
  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. this.getUser()
  562. }, 2000)
  563. },
  564. // 獲取幣種列表
  565. geLevertade() {
  566. uni.showLoading({
  567. title: '數據加載中...',
  568. mask: true
  569. });
  570. const that = this;
  571. geLevertade().then((e) => {
  572. that.spList = e.list;
  573. // 开启长连接
  574. that.onScoket()
  575. })
  576. },
  577. // 开始请求长连接
  578. onScoket() {
  579. const that = this;
  580. that.scoket = scoketNew("wss://wsaws.okx.com:8443/ws/v5/public");
  581. that.scoket.scoketOpen().then((res) => {
  582. uni.hideLoading()
  583. const requestList = that.spList.map((e) => {
  584. return {
  585. "channel": "tickers",
  586. "instId": e.coinname.toUpperCase() + "-USDT"
  587. }
  588. })
  589. that.scoket.scoketSend({
  590. "op": "subscribe",
  591. "args": requestList
  592. }).then((res) => {
  593. console.log(res, '发送成功');
  594. })
  595. that.scoket.scoketMessage((res) => {
  596. try {
  597. if (res.data) {
  598. // 判断是否已经有这个对象
  599. // console.log(res.arg.instId, 'id', that.listOBj);
  600. that.listOBj[res.arg.instId] = res.data[0];
  601. const item = that.listOBj[res.arg.instId];
  602. // 转为数字
  603. item.last = +item.last;
  604. item.sodUtc0 = +item.sodUtc0;
  605. // 保存收益情况
  606. item.bool = item.last - item.sodUtc0 > 0 ? true : false;
  607. // 算出收益率
  608. item.dcf = (+((item.last - item.sodUtc0) / item.sodUtc0 * 100).toFixed(
  609. 2)) + '%'
  610. item.name = item.instId.replace('-', '/')
  611. if(that.actionList == item.instId) {
  612. that.gmList.unshift({'pri':(item.bidPx*1).toFixed(5),'num': (item.bidSz*1).toFixed(5)})
  613. that.gmList = that.gmList.slice(0,9)
  614. that.mcList.unshift({'pri':(item.askPx*1).toFixed(5),'num': (item.askSz*1).toFixed(5)})
  615. that.mcList = that.mcList.slice(0,9)
  616. }
  617. that.listOBj = Object.assign({}, that.listOBj);
  618. console.log(that.listOBj,'that.listOBj')
  619. }
  620. } catch (e) {
  621. console.log(res, res.data, '报错');
  622. }
  623. })
  624. })
  625. },
  626. closeScoket() {
  627. this.scoket.scoketClose();
  628. },
  629. // 平倉
  630. closeorder(item) {
  631. const that = this;
  632. uni.showModal({
  633. title: '平倉',
  634. content: '是否立即平倉,確認後不可修改',
  635. confirmText: '確認',
  636. success: res => {
  637. if (res.confirm) {
  638. uni.showLoading({
  639. title: '請求中...',
  640. mask: true
  641. });
  642. closeorder({
  643. id: item.id
  644. }).then((e) => {
  645. uni.hideLoading()
  646. uni.showToast({
  647. title: '平倉成功',
  648. icon: 'success'
  649. });
  650. that.ddTypeInit()
  651. }).catch(() => {
  652. uni.hideLoading()
  653. })
  654. }
  655. },
  656. fail: () => {},
  657. complete: () => {}
  658. });
  659. },
  660. // 撤銷
  661. clearorder(item) {
  662. const that = this;
  663. uni.showModal({
  664. title: '撤銷',
  665. content: '是否立即撤銷,確認後不可修改',
  666. confirmText: '確認',
  667. success: res => {
  668. if (res.confirm) {
  669. uni.showLoading({
  670. title: '請求中...',
  671. mask: true
  672. });
  673. clearorder({
  674. id: item.id
  675. }).then((e) => {
  676. uni.hideLoading()
  677. uni.showToast({
  678. title: '撤銷成功',
  679. icon: 'success'
  680. });
  681. that.ddTypeInit()
  682. }).catch(() => {
  683. uni.hideLoading()
  684. })
  685. }
  686. },
  687. fail: () => {},
  688. complete: () => {}
  689. });
  690. },
  691. // 获取订单商品
  692. levertadeLaverorder(source) {
  693. //这里是将订单挂载到tab列表下
  694. let index = this.ddType;
  695. let navItem = this.loadData[index];
  696. let state = navItem.state;
  697. if (source === 'tabChange' && navItem.loaded === true) {
  698. //tab切换只有第一次需要加载数据
  699. return;
  700. }
  701. if (navItem.loadingType === 'loading') {
  702. //防止重复加载
  703. return;
  704. }
  705. // if (navItem.loadingType === 'noMore') {
  706. // //防止重复加载
  707. // return;
  708. // }
  709. // 修改当前对象状态为加载中
  710. navItem.loadingType = 'loading';
  711. // uni.showLoading({
  712. // title: '數據加載中',
  713. // mask: true
  714. // });
  715. levertadeLaverorder({
  716. type: state,
  717. page: navItem.page,
  718. limit: navItem.limit
  719. })
  720. .then(({
  721. list
  722. }) => {
  723. // uni.hideLoading()
  724. let arr = list.map(e => {
  725. e.direction = +e.direction;
  726. e.bond = +e.bond
  727. e.price = +e.price
  728. e.wt_price = +e.wt_price
  729. return e;
  730. });
  731. navItem.list = arr;
  732. navItem.loadingType = 'more';
  733. this.$set(navItem, 'loaded', true);
  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>