heyue.vue 24 KB

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