bbjy.vue 25 KB

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