heyue.vue 24 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064
  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. <view class="list flex">
  308. <view class="type">
  309. 產品
  310. </view>
  311. <view class="type">
  312. 實時價格
  313. </view>
  314. <view class="type">
  315. 营收
  316. </view>
  317. </view>
  318. <view class="itemlist flex" @click="changeData(ls)" v-for="ls in listOBj" v-if="ls.name != 'BCH/USDT'">
  319. <view class="type name">
  320. {{ls.name}}
  321. </view>
  322. <view class="type money" :class="{'font-color-green':ls.bool,'font-color-red':!ls.bool}">
  323. {{ls.last}}
  324. </view>
  325. <view class="type bfb" :class="{'font-color-green':ls.bool,'font-color-red':!ls.bool}">
  326. {{ls.dcf}}
  327. </view>
  328. </view>
  329. <view class="itemlist flex" @click="changeData(ls)" v-for="ls in listOBj" v-if="ls.name == 'BCH/USDT'">
  330. <view class="type name">
  331. {{ls.name}}
  332. </view>
  333. <view class="type money" :class="{'font-color-green':ls.bool,'font-color-red':!ls.bool}">
  334. {{ls.last}}
  335. </view>
  336. <view class="type bfb" :class="{'font-color-green':ls.bool,'font-color-red':!ls.bool}">
  337. {{ls.dcf}}
  338. </view>
  339. </view>
  340. </view>
  341. </view>
  342. </template>
  343. <script>
  344. import {
  345. mapState,
  346. mapMutations
  347. } from 'vuex';
  348. import {
  349. levertadeLaverorder,
  350. closeorder,
  351. clearorder,
  352. UpOrderHandle,
  353. bond
  354. } from '@/api/heyue.js';
  355. import {
  356. scoketNew,
  357. scoketOpen
  358. } from '@/utils/socket.js';
  359. import {
  360. geLevertade
  361. } from '@/api/index.js';
  362. import { getUser} from '@/api/login.js'
  363. export default {
  364. data() {
  365. return {
  366. // 是否显示弹窗
  367. alertShow: false,
  368. //保存幣種類型
  369. spList: [],
  370. // 右侧允许的最长长度
  371. listLength: 20,
  372. // 当前选中的对象数据列表
  373. // actionList: 'BCH-USDT',
  374. actionList: 'BTC-USDT',
  375. // 價格列表
  376. listOBj: {
  377. "BCH-USDT": {},
  378. "BTC-USDT": {}
  379. },
  380. // 当前选中的杠杆倍数
  381. ggIndex: 0,
  382. ggList: [{
  383. num: 5
  384. }, {
  385. num: 10
  386. }, {
  387. num: 20
  388. }, {
  389. num: 50
  390. }, {
  391. num: 100
  392. }],
  393. //当前选中的交易类别
  394. typeIndex: 1,
  395. // 交易类型
  396. jyType: 1,
  397. //交易数量
  398. payNum: 0,
  399. // 杠杆倍数
  400. ggBs: 0,
  401. // 限价委托价格
  402. xzMoney: 0,
  403. // 止损价格
  404. zsMoney: 0,
  405. // 止盈价格
  406. zyMoney: 0,
  407. // 保證金
  408. bzjMoney: 0,
  409. // 手續費
  410. sxfMoney: 0,
  411. ddType: 1, //1委托订单2持仓订单3成交订单
  412. loadData: [{
  413. state: 1,
  414. text: '限价委托',
  415. loadingType: 'more',
  416. list: [],
  417. page: 1, //当前页数
  418. limit: 10 //每次信息条数
  419. },
  420. {
  421. state: 2,
  422. text: '持仓',
  423. loadingType: 'more',
  424. list: [],
  425. page: 1, //当前页数
  426. limit: 10 //每次信息条数
  427. }
  428. ],
  429. setTimeoutObj: '',
  430. // 是否提交做多請求
  431. upDataLoding: false,
  432. gmList: [],
  433. mcList: [],
  434. gmobj: {},
  435. mcobj: {}
  436. }
  437. },
  438. watch: {
  439. ggBs(newValue, oldValue) {
  440. this.ggBs = newValue;
  441. this.bond();
  442. },
  443. payNum(newValue, oldValue) {
  444. this.payNum = newValue;
  445. this.bond();
  446. }
  447. },
  448. filters: {
  449. actionMoney: function(value) {
  450. let num = 0;
  451. if (+value > 10000000) {
  452. num = (+(value / 10000000).toFixed(2)) + '千萬'
  453. } else if (+value > 10000) {
  454. num = (+(value / 10000).toFixed(2)) + '萬'
  455. }
  456. return num;
  457. }
  458. },
  459. onLoad() {
  460. // 初始化保存BCH对象
  461. this.levertadeLaverorder();
  462. },
  463. onShow: function() {
  464. this.geLevertade()
  465. this.initListData()
  466. },
  467. onHide() {
  468. this.closeScoket()
  469. clearInterval(this.setTimeoutObj)
  470. },
  471. onReachBottom() {
  472. this.levertadeLaverorder();
  473. },
  474. onReady() {
  475. console.log(this.userInfo);
  476. },
  477. computed: {
  478. ...mapState('user', ['userInfo'])
  479. },
  480. methods: {
  481. ...mapMutations('user',['login','setUserInfo']),
  482. // 提交訂單
  483. UpOrderHandle() {
  484. const that = this;
  485. if (this.upDataLoding) {
  486. return
  487. }
  488. uni.showLoading({
  489. title: '提交中',
  490. mask: true
  491. });
  492. this.upDataLoding = true;
  493. that.bond().then(() => {
  494. UpOrderHandle({
  495. direction: that.typeIndex,
  496. type: that.jyType,
  497. symbol: that.listOBj[that.actionList].name,
  498. mprice: that.jyType == 2 ? that.listOBj[that.actionList].last : that.xzMoney,
  499. ggan: that.ggBs,
  500. num: that.payNum,
  501. upbondmoney: that.bzjMoney,
  502. fee: that.sxfMoney,
  503. zyprice: that.zyMoney,
  504. zsprice: that.zsMoney,
  505. }).then((e) => {
  506. uni.hideLoading()
  507. that.upDataLoding = false;
  508. uni.showModal({
  509. title: '提示',
  510. content: '掛單成功',
  511. confirmText: '確認',
  512. showCancel: false,
  513. });
  514. obj.levertadeLaverorder();
  515. }).catch(() => {
  516. uni.hideLoading()
  517. that.upDataLoding = false;
  518. })
  519. }).catch(() => {
  520. uni.hideLoading()
  521. that.upDataLoding = false;
  522. })
  523. },
  524. // 修改当前选中的数据对象
  525. changeData(item) {
  526. console.log(item, 'qh');
  527. this.actionList = item.instId;
  528. this.gmList = []
  529. this.mcList = []
  530. this.alertShow = false;
  531. },
  532. // 獲取保證金
  533. bond() {
  534. const taht = this
  535. return new Promise((resolve, rejact) => {
  536. bond({
  537. name: taht.actionList.split('-')[0],
  538. 'num': taht.payNum,
  539. 'gann': taht.ggBs
  540. }).then((e) => {
  541. taht.sxfMoney = e.data.fee
  542. taht.bzjMoney = e.data.bong ? e.data.bong : 0
  543. console.log(e)
  544. resolve()
  545. }).catch(() => {
  546. rejact()
  547. console.log(e)
  548. })
  549. })
  550. },
  551. //循環獲取數據
  552. initListData() {
  553. this.setTimeoutObj = setInterval(() => {
  554. this.levertadeLaverorder();
  555. this.getUser()
  556. }, 2000)
  557. },
  558. // 獲取幣種列表
  559. geLevertade() {
  560. uni.showLoading({
  561. title: '數據加載中...',
  562. mask: true
  563. });
  564. const that = this;
  565. geLevertade().then((e) => {
  566. that.spList = e.list;
  567. // 开启长连接
  568. that.onScoket()
  569. })
  570. },
  571. // 开始请求长连接
  572. onScoket() {
  573. const that = this;
  574. that.scoket = scoketNew("wss://wsaws.okx.com:8443/ws/v5/public");
  575. that.scoket.scoketOpen().then((res) => {
  576. uni.hideLoading()
  577. const requestList = that.spList.map((e) => {
  578. return {
  579. "channel": "tickers",
  580. "instId": e.coinname.toUpperCase() + "-USDT"
  581. }
  582. })
  583. that.scoket.scoketSend({
  584. "op": "subscribe",
  585. "args": requestList
  586. }).then((res) => {
  587. console.log(res, '发送成功');
  588. })
  589. that.scoket.scoketMessage((res) => {
  590. try {
  591. if (res.data) {
  592. // 判断是否已经有这个对象
  593. // console.log(res.arg.instId, 'id', that.listOBj);
  594. that.listOBj[res.arg.instId] = res.data[0];
  595. const item = that.listOBj[res.arg.instId];
  596. // 转为数字
  597. item.last = +item.last;
  598. item.sodUtc0 = +item.sodUtc0;
  599. // 保存收益情况
  600. item.bool = item.last - item.sodUtc0 > 0 ? true : false;
  601. // 算出收益率
  602. item.dcf = (+((item.last - item.sodUtc0) / item.sodUtc0 * 100).toFixed(
  603. 2)) + '%'
  604. item.name = item.instId.replace('-', '/')
  605. if(that.actionList == item.instId) {
  606. that.gmList.unshift({'pri':(item.bidPx*1).toFixed(5),'num': (item.bidSz*1).toFixed(5)})
  607. that.gmList = that.gmList.slice(0,9)
  608. that.mcList.unshift({'pri':(item.askPx*1).toFixed(5),'num': (item.askSz*1).toFixed(5)})
  609. that.mcList = that.mcList.slice(0,9)
  610. }
  611. that.listOBj = Object.assign({}, that.listOBj);
  612. console.log(that.listOBj,'that.listOBj')
  613. }
  614. } catch (e) {
  615. console.log(res, res.data, '报错');
  616. }
  617. })
  618. })
  619. },
  620. closeScoket() {
  621. this.scoket.scoketClose();
  622. },
  623. // 平倉
  624. closeorder(item) {
  625. const that = this;
  626. uni.showModal({
  627. title: '平倉',
  628. content: '是否立即平倉,確認後不可修改',
  629. confirmText: '確認',
  630. success: res => {
  631. if (res.confirm) {
  632. uni.showLoading({
  633. title: '請求中...',
  634. mask: true
  635. });
  636. closeorder({
  637. id: item.id
  638. }).then((e) => {
  639. uni.hideLoading()
  640. uni.showToast({
  641. title: '平倉成功',
  642. icon: 'success'
  643. });
  644. that.ddTypeInit()
  645. }).catch(() => {
  646. uni.hideLoading()
  647. })
  648. }
  649. },
  650. fail: () => {},
  651. complete: () => {}
  652. });
  653. },
  654. // 撤銷
  655. clearorder(item) {
  656. const that = this;
  657. uni.showModal({
  658. title: '撤銷',
  659. content: '是否立即撤銷,確認後不可修改',
  660. confirmText: '確認',
  661. success: res => {
  662. if (res.confirm) {
  663. uni.showLoading({
  664. title: '請求中...',
  665. mask: true
  666. });
  667. clearorder({
  668. id: item.id
  669. }).then((e) => {
  670. uni.hideLoading()
  671. uni.showToast({
  672. title: '撤銷成功',
  673. icon: 'success'
  674. });
  675. that.ddTypeInit()
  676. }).catch(() => {
  677. uni.hideLoading()
  678. })
  679. }
  680. },
  681. fail: () => {},
  682. complete: () => {}
  683. });
  684. },
  685. // 获取订单商品
  686. levertadeLaverorder(source) {
  687. //这里是将订单挂载到tab列表下
  688. let index = this.ddType;
  689. let navItem = this.loadData[index];
  690. let state = navItem.state;
  691. if (source === 'tabChange' && navItem.loaded === true) {
  692. //tab切换只有第一次需要加载数据
  693. return;
  694. }
  695. if (navItem.loadingType === 'loading') {
  696. //防止重复加载
  697. return;
  698. }
  699. // if (navItem.loadingType === 'noMore') {
  700. // //防止重复加载
  701. // return;
  702. // }
  703. // 修改当前对象状态为加载中
  704. navItem.loadingType = 'loading';
  705. // uni.showLoading({
  706. // title: '數據加載中',
  707. // mask: true
  708. // });
  709. levertadeLaverorder({
  710. type: state,
  711. page: navItem.page,
  712. limit: navItem.limit
  713. })
  714. .then(({
  715. list
  716. }) => {
  717. // uni.hideLoading()
  718. let arr = list.map(e => {
  719. e.direction = +e.direction;
  720. e.bond = +e.bond
  721. e.price = +e.price
  722. e.wt_price = +e.wt_price
  723. return e;
  724. });
  725. navItem.list = arr;
  726. navItem.loadingType = 'more';
  727. this.$set(navItem, 'loaded', true);
  728. })
  729. .catch(e => {
  730. // uni.hideLoading()
  731. console.log(e);
  732. });
  733. },
  734. // 修改杠杆倍数
  735. changeGG(ind, item) {
  736. this.ggBs = item.num
  737. this.ggIndex = ind
  738. },
  739. // 列表切换
  740. ddTypeChage(ind) {
  741. this.ddType = ind;
  742. this.levertadeLaverorder('tabChange');
  743. },
  744. // 初始化重新加載
  745. ddTypeInit() {
  746. // 初始化數據
  747. let item = this.loadData[this.ddType];
  748. item.loadingType = 'more';
  749. item.list = [];
  750. item.page = 1;
  751. item.limit = 10;
  752. item.loaded = false;
  753. this.levertadeLaverorder();
  754. },
  755. navto(url) {
  756. uni.navigateTo({
  757. url,
  758. fail() {
  759. uni.switchTab({
  760. url
  761. })
  762. }
  763. })
  764. },
  765. getUser() {
  766. getUser().then(re => {
  767. this.setUserInfo(re.data)
  768. })
  769. }
  770. }
  771. }
  772. </script>
  773. <style lang="scss">
  774. .usdtTitle,
  775. .box {
  776. padding: 0 20rpx;
  777. width: 750rpx;
  778. background-color: #FFFFFF;
  779. }
  780. .usdtTitle {
  781. border-bottom: 1px solid $border-color-light;
  782. line-height: 1;
  783. .left {
  784. font-size: 32rpx;
  785. font-weight: bold;
  786. .img {
  787. width: 36rpx;
  788. }
  789. }
  790. .right {
  791. .img {
  792. width: 48rpx;
  793. }
  794. }
  795. }
  796. .box {
  797. line-height: 1;
  798. align-items: flex-start;
  799. .itemTitle {
  800. font-weight: bold;
  801. font-size: $font-sm;
  802. }
  803. .item {
  804. // flex-grow: 1;
  805. // width: 50%;
  806. flex-shrink: 0;
  807. }
  808. .buttomBox {
  809. font-size: $font-sm;
  810. .buttom {
  811. width: 350rpx;
  812. padding: 20rpx 0;
  813. text-align: center;
  814. border-radius: 10rpx;
  815. background-color: #F5F5F5;
  816. &.action {
  817. color: #FFFFFF;
  818. background-color: $color-green;
  819. }
  820. }
  821. }
  822. .tabType {
  823. justify-content: space-around;
  824. .tab {
  825. padding-top: 30rpx;
  826. padding-bottom: 20rpx;
  827. color: #545D6F;
  828. font-size: $font-sm;
  829. font-weight: bold;
  830. &.action {
  831. color: $uni-color-warning;
  832. }
  833. }
  834. }
  835. .inputBox {
  836. height: 60rpx;
  837. border-radius: 10rpx;
  838. padding: 0 20rpx;
  839. display: flex;
  840. align-items: center;
  841. border: 1px solid $border-color-light;
  842. .buttomZd {
  843. font-size: $font-sm;
  844. }
  845. .input {
  846. font-size: $font-sm;
  847. flex-grow: 1;
  848. }
  849. .rightInputBox {
  850. .jg {
  851. border: 1px solid $border-color-light;
  852. height: 50rpx;
  853. margin: 0 30rpx;
  854. }
  855. .img {
  856. width: 28rpx;
  857. height: 28rpx;
  858. }
  859. }
  860. }
  861. .itemLeftList {
  862. justify-content: space-around;
  863. .ll {
  864. border: 1px solid $border-color-light;
  865. width: 74rpx;
  866. height: 54rpx;
  867. line-height: 54rpx;
  868. text-align: center;
  869. font-size: $font-sm;
  870. font-weight: bold;
  871. &.action {
  872. background-color: #F5F5F5;
  873. }
  874. }
  875. }
  876. .buttomSubmit {
  877. color: #FFFFFF;
  878. height: 64rpx;
  879. line-height: 64rpx;
  880. text-align: center;
  881. font-size: $font-sm;
  882. border-radius: 10rpx;
  883. }
  884. .itemName {
  885. .itemMinName {
  886. width: 20%;
  887. font-size: 22rpx;
  888. color: #5D6677;
  889. }
  890. }
  891. .itemList {
  892. .list {
  893. font-size: 20rpx;
  894. padding: 10rpx 0;
  895. .li {
  896. width: 20%;
  897. }
  898. }
  899. .llMax {
  900. padding: 30rpx 0;
  901. font-weight: bold;
  902. font-size: $font-lg;
  903. }
  904. }
  905. .listTitleBox {
  906. border-bottom: 1px solid $border-color-light;
  907. align-items: flex-start;
  908. .leftBottom {
  909. flex-shrink: 0;
  910. font-size: $font-lg;
  911. font-weight: bold;
  912. .action {
  913. border-bottom: 2px solid $uni-color-warning;
  914. }
  915. .titleType {
  916. padding-bottom: 20rpx;
  917. }
  918. }
  919. .rightBottom {
  920. font-size: $font-base;
  921. color: #707A8A;
  922. flex-shrink: 0;
  923. .img {
  924. width: 36rpx;
  925. }
  926. }
  927. }
  928. .usdtList {
  929. color: #707A8A;
  930. border-bottom: 1px solid $border-color-light;
  931. .name {
  932. font-size: $font-lg;
  933. font-weight: bold;
  934. }
  935. .usdtListButtom {
  936. font-size: $font-base;
  937. background-color: #F5F5F5;
  938. color: $uni-color-warning;
  939. border-radius: 10rpx;
  940. padding: 10rpx 20rpx;
  941. }
  942. .tip {
  943. padding-top: 10rpx;
  944. padding-bottom: 10rpx;
  945. font-size: $font-base;
  946. }
  947. .tipList {
  948. font-size: $font-sm;
  949. text-align: center;
  950. width: 33%;
  951. padding-top: 20rpx;
  952. .nameTip {
  953. padding-bottom: 20rpx;
  954. }
  955. }
  956. }
  957. }
  958. .alertBox {
  959. position: fixed;
  960. top: 0;
  961. left: 0;
  962. right: 0;
  963. bottom: 0;
  964. background-color: #FFFFFF;
  965. text-align: center;
  966. color: #707A8A;
  967. .type {
  968. width: 30%;
  969. flex-grow: 1;
  970. }
  971. .itemlist {
  972. padding-top: 20rpx;
  973. .name {
  974. padding-left: 20rpx;
  975. text-align: left;
  976. }
  977. }
  978. .list {
  979. padding: 30rpx 0;
  980. border-bottom: 1px solid $border-color-light;
  981. .type {
  982. font-size: $font-lg;
  983. font-weight: bold;
  984. }
  985. }
  986. }
  987. .right-wrap {
  988. flex-grow: 1;
  989. padding: 0 10rpx;
  990. font-size: 24rpx;
  991. color: #707A8A;
  992. .line {
  993. view {
  994. padding: 10rpx 0;
  995. }
  996. }
  997. }
  998. .new-price {
  999. font-size: 36rpx;
  1000. color: #0ecb81;
  1001. padding: 20rpx;
  1002. }
  1003. .vheight {
  1004. height: var(--status-bar-height);
  1005. }
  1006. </style>