bbjy.vue 26 KB

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