bbjy.vue 24 KB

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