heyue.vue 25 KB

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