bbjy.vue 25 KB

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