heyue.vue 25 KB

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