heyue.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672
  1. <template>
  2. <view class="content">
  3. <view class="usdtTitle flex">
  4. <view class="left flex">
  5. <image class="img margin-r-10" src="../../static/icon/hy02.png" mode="widthFix"></image>
  6. <view class="margin-r-10">
  7. BTC/USDT
  8. </view>
  9. <view class="font-color-green">
  10. 10086
  11. </view>
  12. </view>
  13. <view class="right">
  14. <image class="img" src="../../static/icon/hy01.png" mode="widthFix"></image>
  15. </view>
  16. </view>
  17. <view class="box flex padding-t-20 padding-b-30">
  18. <view class="item">
  19. <view class="itemTitle margin-b-20">
  20. 交易方向
  21. </view>
  22. <view class="buttomBox flex">
  23. <view @click="typeIndex=1" class="buttom " :class="{action:typeIndex==1}">
  24. 上漲
  25. </view>
  26. <view @click="typeIndex=2" class="buttom " :class="{action:typeIndex==2,'bg-danger':typeIndex==2}">
  27. 下跌
  28. </view>
  29. </view>
  30. <view class="tabType flex ">
  31. <view class="tab" @click="jyType=1" :class="{action:jyType==1}">
  32. 限價委託
  33. </view>
  34. <view class="tab" @click="jyType=2" :class="{action:jyType==2}">
  35. 市價委託
  36. </view>
  37. </view>
  38. <view class="inputBox margin-b-20" v-if="jyType==1">
  39. <input v-model="xzMoney" class="input" placeholder="請輸入價格" type="number">
  40. </view>
  41. <view class="itemTitle margin-b-20">
  42. 交易個數
  43. </view>
  44. <view class="inputBox flex margin-b-20">
  45. <input v-model="payNum" class="input" placeholder="請輸入交易數量" type="number">
  46. <view class="rightInputBox flex">
  47. <image @click="payNum>0?payNum--:false" class="img" src="../../static/icon/hy04.png"
  48. mode="scaleToFill"></image>
  49. <view class="jg">
  50. </view>
  51. <image @click="payNum++" class="img" src="../../static/icon/hy03.png" mode="scaleToFill">
  52. </image>
  53. </view>
  54. </view>
  55. <view class="itemTitle margin-b-20">
  56. 槓桿倍數
  57. </view>
  58. <view class="itemLeftList flex margin-b-20">
  59. <view class="ll" @click="changeGG(ind,ls)" :class="{action:ind==ggIndex}"
  60. v-for="(ls,ind) in ggList">
  61. {{ls.num}}
  62. </view>
  63. </view>
  64. <view class="inputBox flex margin-b-20">
  65. <input v-model="ggBs" class="input" placeholder="請輸入槓桿倍率" type="number">
  66. </view>
  67. <view class="flex margin-b-20">
  68. <view class="itemTitle">
  69. 止損價
  70. </view>
  71. <view class="inputBox flex">
  72. <input v-model="zsMoney" placeholder="請輸入止損價格" class="input" type="number">
  73. </view>
  74. </view>
  75. <view class="flex margin-b-20">
  76. <view class="itemTitle">
  77. 止盈價
  78. </view>
  79. <view class="inputBox flex">
  80. <input v-model="zyMoney" placeholder="請輸入止盈價格" class="input" type="number">
  81. </view>
  82. </view>
  83. <view class="flex margin-b-20">
  84. <view class="itemTitle">
  85. 保證金
  86. </view>
  87. <view class="itemTitle">
  88. 0
  89. </view>
  90. </view>
  91. <view class="flex margin-b-20">
  92. <view class="itemTitle">
  93. 可用合約餘額
  94. </view>
  95. <view class="itemTitle">
  96. 0
  97. </view>
  98. </view>
  99. <view class="flex margin-b-20">
  100. <view class="itemTitle">
  101. 手續費
  102. </view>
  103. <view class="itemTitle">
  104. 0
  105. </view>
  106. </view>
  107. <view class="buttomSubmit" :class="{'bg-success':typeIndex==1,'bg-danger':typeIndex==2}">
  108. {{typeIndex==1?'做多':'做空'}}
  109. </view>
  110. </view>
  111. <view class="item padding-l-20">
  112. <view class="itemName flex">
  113. <view class="itemMinName">
  114. 價格
  115. </view>
  116. <view class="itemMinName">
  117. 數量
  118. </view>
  119. </view>
  120. <view class="itemList">
  121. <view class="list flex font-color-green">
  122. <view class="li top">
  123. 166666
  124. </view>
  125. <view class="li top">
  126. 0000.00
  127. </view>
  128. </view>
  129. <view class="llMax font-color-green">
  130. 10086
  131. </view>
  132. <view class="list flex font-color-red">
  133. <view class="li bottom">
  134. 166666
  135. </view>
  136. <view class="li bottom">
  137. 0000.00
  138. </view>
  139. </view>
  140. </view>
  141. </view>
  142. </view>
  143. <view class="box margin-t-30 padding-t-30 padding-b-30">
  144. <view class="flex listTitleBox">
  145. <view class="leftBottom flex">
  146. <view @click="ddTypeChage(0)" class="titleType margin-r-30" :class="{action:ddType==0}">
  147. 限價委託
  148. </view>
  149. <view @click="ddTypeChage(1)" class="titleType" :class="{action:ddType==1}">
  150. 持倉
  151. </view>
  152. </view>
  153. <view class="rightBottom flex">
  154. <image class="img" src="../../static/icon/hy02.png" mode="widthFix"></image>
  155. <view class="more">
  156. 全部訂單
  157. </view>
  158. </view>
  159. </view>
  160. <view v-for="(item,ind) in loadData[ddType].list" class="usdtList padding-t-30 padding-b-30">
  161. <view class="flex">
  162. <view class="name">
  163. <text v-if="item.direction==1" class="font-color-green">
  164. 做多
  165. </text>
  166. <text v-if="item.direction==2" class="font-color-red">
  167. 做空
  168. </text>
  169. <text>
  170. BTC/USDT
  171. </text>
  172. <text v-if="ddType==1"
  173. :class="{'font-color-green':item.direction==1,'font-color-red':item.direction==2}">
  174. 0.00
  175. </text>
  176. </view>
  177. <view @click="clearorder(item)" v-if="ddType==0" class="usdtListButtom">
  178. 撤銷
  179. </view>
  180. <view @click="closeorder(item)" v-if="ddType==1" class="usdtListButtom">
  181. 一鍵平倉
  182. </view>
  183. </view>
  184. <view class="tip ">
  185. <text v-if="item.direction==1">
  186. 委託時間:{{item.wttime}}
  187. </text>
  188. <text v-if="item.direction==2">
  189. 開倉時間:{{item.addtime}}
  190. </text>
  191. </view>
  192. <view class="flex">
  193. <view v-if="item.direction==1" class="tipList">
  194. <view class="nameTip">
  195. 限價
  196. </view>
  197. <view class="text">
  198. {{item.wt_price}}
  199. </view>
  200. </view>
  201. <view v-if="item.direction==2" class="tipList">
  202. <view class="nameTip">
  203. 開倉單價
  204. </view>
  205. <view class="text">
  206. {{item.price}}
  207. </view>
  208. </view>
  209. <view class="tipList">
  210. <view class="nameTip">
  211. 保證金
  212. </view>
  213. <view class="text">
  214. {{item.bond}}
  215. </view>
  216. </view>
  217. <view class="tipList">
  218. <view class="nameTip">
  219. 交易個數
  220. </view>
  221. <view class="text">
  222. {{item.num}}
  223. </view>
  224. </view>
  225. <view class="tipList">
  226. <view class="nameTip">
  227. 槓桿倍數
  228. </view>
  229. <view class="text">
  230. {{item.ggan}}
  231. </view>
  232. </view>
  233. </view>
  234. </view>
  235. </view>
  236. </view>
  237. </template>
  238. <script>
  239. import {
  240. levertadeLaverorder,
  241. closeorder,
  242. clearorder
  243. } from '@/api/heyue.js';
  244. export default {
  245. data() {
  246. return {
  247. //保存幣種類型
  248. moneytypeList:[],
  249. // 当前选中的杠杆倍数
  250. ggIndex: 0,
  251. ggList: [{
  252. num: 5
  253. }, {
  254. num: 10
  255. }, {
  256. num: 20
  257. }, {
  258. num: 50
  259. }, {
  260. num: 100
  261. }],
  262. //当前选中的交易类别
  263. typeIndex: 1,
  264. // 交易类型
  265. jyType: 1,
  266. //交易数量
  267. payNum: 0,
  268. // 杠杆倍数
  269. ggBs: 0,
  270. // 限价委托价格
  271. xzMoney: 0,
  272. // 止损价格
  273. zsMoney: 0,
  274. // 止盈价格
  275. zyMoney: 0,
  276. ddType: 1, //1委托订单2持仓订单3成交订单
  277. loadData: [{
  278. state: 1,
  279. text: '限价委托',
  280. loadingType: 'more',
  281. list: [],
  282. page: 1, //当前页数
  283. limit: 10 //每次信息条数
  284. },
  285. {
  286. state: 2,
  287. text: '持仓',
  288. loadingType: 'more',
  289. list: [],
  290. page: 1, //当前页数
  291. limit: 10 //每次信息条数
  292. }
  293. ]
  294. }
  295. },
  296. onLoad() {
  297. this.levertadeLaverorder();
  298. },
  299. onShow() {
  300. },
  301. onReachBottom() {
  302. this.levertadeLaverorder();
  303. },
  304. onReady() {
  305. },
  306. methods: {
  307. // 平倉
  308. closeorder(item) {
  309. const that = this;
  310. uni.showModal({
  311. title: '平倉',
  312. content: '是否立即平倉,確認後不可修改',
  313. success: res => {
  314. if (res.confirm) {
  315. uni.showLoading({
  316. title: '請求中...',
  317. mask: true
  318. });
  319. closeorder({
  320. id: item.id
  321. }).then((e) => {
  322. uni.hideLoading()
  323. uni.showToast({
  324. title: '平倉成功',
  325. icon: 'success'
  326. });
  327. that.ddTypeInit()
  328. }).catch(() => {
  329. uni.hideLoading()
  330. })
  331. }
  332. },
  333. fail: () => {},
  334. complete: () => {}
  335. });
  336. },
  337. // 撤銷
  338. clearorder(item) {
  339. const that = this;
  340. uni.showModal({
  341. title: '撤銷',
  342. content: '是否立即撤銷,確認後不可修改',
  343. success: res => {
  344. if (res.confirm) {
  345. uni.showLoading({
  346. title: '請求中...',
  347. mask: true
  348. });
  349. clearorder({
  350. id: item.id
  351. }).then((e) => {
  352. uni.hideLoading()
  353. uni.showToast({
  354. title: '撤銷成功',
  355. icon: 'success'
  356. });
  357. that.ddTypeInit()
  358. }).catch(() => {
  359. uni.hideLoading()
  360. })
  361. }
  362. },
  363. fail: () => {},
  364. complete: () => {}
  365. });
  366. },
  367. // 获取订单商品
  368. levertadeLaverorder(source) {
  369. //这里是将订单挂载到tab列表下
  370. let index = this.ddType;
  371. let navItem = this.loadData[index];
  372. let state = navItem.state;
  373. if (source === 'tabChange' && navItem.loaded === true) {
  374. //tab切换只有第一次需要加载数据
  375. return;
  376. }
  377. if (navItem.loadingType === 'loading') {
  378. //防止重复加载
  379. return;
  380. }
  381. if (navItem.loadingType === 'noMore') {
  382. //防止重复加载
  383. return;
  384. }
  385. // 修改当前对象状态为加载中
  386. navItem.loadingType = 'loading';
  387. uni.showLoading({
  388. title: '數據加載中',
  389. mask: true
  390. });
  391. levertadeLaverorder({
  392. type: state,
  393. page: navItem.page,
  394. limit: navItem.limit
  395. })
  396. .then(({
  397. list
  398. }) => {
  399. uni.hideLoading()
  400. let arr = list.map(e => {
  401. e.direction = +e.direction;
  402. e.bond = +e.bond
  403. e.price = +e.price
  404. e.wt_price = +e.wt_price
  405. return e;
  406. });
  407. navItem.list = navItem.list.concat(arr);
  408. navItem.page++;
  409. if (navItem.limit == list.length) {
  410. //判断是否还有数据, 有改为 more, 没有改为noMore
  411. navItem.loadingType = 'more';
  412. return;
  413. } else {
  414. //判断是否还有数据, 有改为 more, 没有改为noMore
  415. navItem.loadingType = 'noMore';
  416. }
  417. this.$set(navItem, 'loaded', true);
  418. })
  419. .catch(e => {
  420. uni.hideLoading()
  421. console.log(e);
  422. });
  423. },
  424. // 修改杠杆倍数
  425. changeGG(ind, item) {
  426. this.ggBs = item.num
  427. this.ggIndex = ind
  428. },
  429. // 列表切换
  430. ddTypeChage(ind) {
  431. this.ddType = ind;
  432. this.levertadeLaverorder('tabChange');
  433. },
  434. // 初始化重新加載
  435. ddTypeInit() {
  436. // 初始化數據
  437. let item = this.loadData[this.ddType];
  438. item.loadingType = 'more';
  439. item.list = [];
  440. item.page = 1;
  441. item.limit = 10;
  442. item.loaded = false;
  443. this.levertadeLaverorder();
  444. }
  445. }
  446. }
  447. </script>
  448. <style lang="scss">
  449. .usdtTitle,
  450. .box {
  451. padding: 0 20rpx;
  452. width: 750rpx;
  453. background-color: #FFFFFF;
  454. }
  455. .usdtTitle {
  456. border-bottom: 1px solid $border-color-light;
  457. line-height: 1;
  458. .left {
  459. font-size: 32rpx;
  460. font-weight: bold;
  461. .img {
  462. width: 36rpx;
  463. }
  464. }
  465. .right {
  466. .img {
  467. width: 48rpx;
  468. }
  469. }
  470. }
  471. .box {
  472. line-height: 1;
  473. align-items: flex-start;
  474. .itemTitle {
  475. font-weight: bold;
  476. font-size: $font-sm;
  477. }
  478. .item {
  479. flex-grow: 1;
  480. flex-shrink: 0;
  481. }
  482. .buttomBox {
  483. font-size: $font-sm;
  484. .buttom {
  485. width: 200rpx;
  486. padding: 20rpx 0;
  487. text-align: center;
  488. border-radius: 10rpx;
  489. background-color: #F5F5F5;
  490. &.action {
  491. color: #FFFFFF;
  492. background-color: $color-green;
  493. }
  494. }
  495. }
  496. .tabType {
  497. justify-content: space-around;
  498. .tab {
  499. padding-top: 30rpx;
  500. padding-bottom: 20rpx;
  501. color: #545D6F;
  502. font-size: $font-sm;
  503. font-weight: bold;
  504. &.action {
  505. color: $uni-color-warning;
  506. }
  507. }
  508. }
  509. .inputBox {
  510. height: 60rpx;
  511. border-radius: 10rpx;
  512. padding: 0 20rpx;
  513. display: flex;
  514. align-items: center;
  515. border: 1px solid $border-color-light;
  516. .input {
  517. font-size: $font-sm;
  518. flex-grow: 1;
  519. }
  520. .rightInputBox {
  521. .jg {
  522. border: 1px solid $border-color-light;
  523. height: 50rpx;
  524. margin: 0 30rpx;
  525. }
  526. .img {
  527. width: 28rpx;
  528. height: 28rpx;
  529. }
  530. }
  531. }
  532. .itemLeftList {
  533. justify-content: space-around;
  534. .ll {
  535. border: 1px solid $border-color-light;
  536. width: 74rpx;
  537. height: 54rpx;
  538. line-height: 54rpx;
  539. text-align: center;
  540. font-size: $font-sm;
  541. font-weight: bold;
  542. &.action {
  543. background-color: #F5F5F5;
  544. }
  545. }
  546. }
  547. .buttomSubmit {
  548. color: #FFFFFF;
  549. height: 64rpx;
  550. line-height: 64rpx;
  551. text-align: center;
  552. font-size: $font-sm;
  553. border-radius: 10rpx;
  554. }
  555. .itemName {
  556. padding-bottom: 20rpx;
  557. .itemMinName {
  558. font-size: 22rpx;
  559. color: #5D6677;
  560. }
  561. }
  562. .itemList {
  563. .list {
  564. font-size: 20rpx;
  565. padding: 10rpx 0;
  566. }
  567. .llMax {
  568. padding: 30rpx 0;
  569. font-weight: bold;
  570. font-size: $font-lg;
  571. }
  572. }
  573. .listTitleBox {
  574. border-bottom: 1px solid $border-color-light;
  575. align-items: flex-start;
  576. .leftBottom {
  577. flex-shrink: 0;
  578. font-size: $font-lg;
  579. font-weight: bold;
  580. .action {
  581. border-bottom: 2px solid $uni-color-warning;
  582. }
  583. .titleType {
  584. padding-bottom: 20rpx;
  585. }
  586. }
  587. .rightBottom {
  588. font-size: $font-base;
  589. color: #707A8A;
  590. flex-shrink: 0;
  591. .img {
  592. width: 36rpx;
  593. }
  594. }
  595. }
  596. .usdtList {
  597. color: #707A8A;
  598. border-bottom: 1px solid $border-color-light;
  599. .name {
  600. font-size: $font-lg;
  601. font-weight: bold;
  602. }
  603. .usdtListButtom {
  604. font-size: $font-base;
  605. background-color: #F5F5F5;
  606. color: $uni-color-warning;
  607. border-radius: 10rpx;
  608. padding: 10rpx 20rpx;
  609. }
  610. .tip {
  611. padding-top: 10rpx;
  612. padding-bottom: 30rpx;
  613. font-size: $font-base;
  614. }
  615. .tipList {
  616. font-size: $font-sm;
  617. text-align: center;
  618. .nameTip {
  619. padding-bottom: 20rpx;
  620. }
  621. }
  622. }
  623. }
  624. </style>