heyue.vue 23 KB

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