heyue.vue 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971
  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="ddType == 0">{{ $t('hy.wtsj') }}:{{ item.wttime }}</text>
  169. <text v-if="ddType == 1">{{ $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. that.zyMoney = ''
  403. that.zsMoney = ''
  404. obj.levertadeLaverorder();
  405. })
  406. .catch(() => {
  407. uni.hideLoading();
  408. that.upDataLoding = false;
  409. });
  410. })
  411. .catch(() => {
  412. uni.hideLoading();
  413. that.upDataLoding = false;
  414. });
  415. },
  416. // 修改当前选中的数据对象
  417. changeData(item) {
  418. console.log(item, 'qh');
  419. this.actionList = item.instId;
  420. this.gmList = [];
  421. this.mcList = [];
  422. this.alertShow = false;
  423. },
  424. // 獲取保證金
  425. bond() {
  426. const taht = this;
  427. return new Promise((resolve, rejact) => {
  428. bond({
  429. name: taht.actionList.split('-')[0],
  430. num: taht.payNum,
  431. gann: taht.ggBs
  432. })
  433. .then(e => {
  434. taht.sxfMoney = e.data.fee;
  435. taht.bzjMoney = e.data.bong ? e.data.bong : 0;
  436. console.log(e);
  437. resolve();
  438. })
  439. .catch(() => {
  440. rejact();
  441. console.log(e);
  442. });
  443. });
  444. },
  445. //循環獲取數據
  446. initListData() {
  447. this.setTimeoutObj = setInterval(() => {
  448. this.levertadeLaverorder();
  449. }, 2000);
  450. },
  451. // 獲取幣種列表
  452. geLevertade() {
  453. uni.showLoading({
  454. title: this.$t('hy.sjjzz') + '...',
  455. mask: true
  456. });
  457. const that = this;
  458. geLevertade().then(e => {
  459. that.spList = e.list;
  460. // 开启长连接
  461. that.onScoket();
  462. });
  463. },
  464. // 开始请求长连接
  465. onScoket() {
  466. const that = this;
  467. that.scoket = scoketNew('wss://wsaws.okx.com:8443/ws/v5/public');
  468. that.scoket.scoketOpen().then(res => {
  469. uni.hideLoading();
  470. const requestList = that.spList.map(e => {
  471. return {
  472. channel: 'tickers',
  473. instId: e.coinname.toUpperCase() + '-USDT'
  474. };
  475. });
  476. that.scoket
  477. .scoketSend({
  478. op: 'subscribe',
  479. args: requestList
  480. })
  481. .then(res => {
  482. console.log(res, '发送成功');
  483. });
  484. that.scoket.scoketMessage(res => {
  485. try {
  486. if (res.data) {
  487. // 判断是否已经有这个对象
  488. // console.log(res.arg.instId, 'id', that.listOBj);
  489. that.listOBj[res.arg.instId] = res.data[0];
  490. const item = that.listOBj[res.arg.instId];
  491. // 转为数字
  492. item.last = +item.last;
  493. item.sodUtc0 = +item.sodUtc0;
  494. // 保存收益情况
  495. item.bool = item.last - item.sodUtc0 > 0 ? true : false;
  496. // 算出收益率
  497. item.dcf = +(((item.last - item.sodUtc0) / item.sodUtc0) * 100).toFixed(2) + '%';
  498. item.name = item.instId.replace('-', '/');
  499. if (that.actionList == item.instId) {
  500. that.gmList.unshift({ pri: (item.bidPx * 1).toFixed(5), num: (item.bidSz * 1).toFixed(5) });
  501. that.gmList = that.gmList.slice(0, 9);
  502. that.mcList.unshift({ pri: (item.askPx * 1).toFixed(5), num: (item.askSz * 1).toFixed(5) });
  503. that.mcList = that.mcList.slice(0, 9);
  504. }
  505. that.listOBj = Object.assign({}, that.listOBj);
  506. console.log(that.listOBj, 'that.listOBj');
  507. }
  508. } catch (e) {
  509. console.log(res, res.data, '报错');
  510. }
  511. });
  512. });
  513. },
  514. closeScoket() {
  515. this.scoket.scoketClose();
  516. },
  517. // 平倉
  518. closeorder(item) {
  519. const that = this;
  520. uni.showModal({
  521. title: that.$t('hy.pc'),
  522. content: that.$t('hy.sfljpc'),
  523. confirmText: that.$t('hy.s'),
  524. cancelText: that.$t('hy.f'),
  525. success: res => {
  526. if (res.confirm) {
  527. uni.showLoading({
  528. title: that.$t('hy.qqz') + '...',
  529. mask: true
  530. });
  531. closeorder({
  532. id: item.id
  533. })
  534. .then(e => {
  535. uni.hideLoading();
  536. uni.showToast({
  537. title: that.$t('hy.pccg'),
  538. icon: 'success'
  539. });
  540. that.ddTypeInit();
  541. })
  542. .catch(() => {
  543. uni.hideLoading();
  544. });
  545. }
  546. },
  547. fail: () => {},
  548. complete: () => {}
  549. });
  550. },
  551. // 撤銷
  552. clearorder(item) {
  553. const that = this;
  554. uni.showModal({
  555. title: that.$t('hy.cx'),
  556. content: that.$t('hy.sfljcx'),
  557. confirmText: that.$t('hy.qr'),
  558. cancelText: that.$t('cb.qx'),
  559. success: res => {
  560. if (res.confirm) {
  561. uni.showLoading({
  562. title: that.$t('hy.qqz') + '...',
  563. mask: true
  564. });
  565. clearorder({
  566. id: item.id
  567. })
  568. .then(e => {
  569. uni.hideLoading();
  570. uni.showToast({
  571. title: that.$t('hy.cxcg'),
  572. icon: 'success'
  573. });
  574. that.ddTypeInit();
  575. })
  576. .catch(() => {
  577. uni.hideLoading();
  578. });
  579. }
  580. },
  581. fail: () => {},
  582. complete: () => {}
  583. });
  584. },
  585. // 获取订单商品
  586. levertadeLaverorder(source) {
  587. //这里是将订单挂载到tab列表下
  588. let index = this.ddType;
  589. let navItem = this.loadData[index];
  590. let state = navItem.state;
  591. if (source === 'tabChange' && navItem.loaded === true) {
  592. //tab切换只有第一次需要加载数据
  593. return;
  594. }
  595. if (navItem.loadingType === 'loading') {
  596. //防止重复加载
  597. return;
  598. }
  599. // if (navItem.loadingType === 'noMore') {
  600. // //防止重复加载
  601. // return;
  602. // }
  603. // 修改当前对象状态为加载中
  604. navItem.loadingType = 'loading';
  605. // uni.showLoading({
  606. // title: '數據加載中',
  607. // mask: true
  608. // });
  609. levertadeLaverorder({
  610. type: state,
  611. page: navItem.page,
  612. limit: navItem.limit
  613. })
  614. .then(({ list }) => {
  615. // uni.hideLoading()
  616. let arr = list.map(e => {
  617. e.direction = +e.direction;
  618. e.bond = +e.bond;
  619. e.price = +e.price;
  620. e.wt_price = +e.wt_price;
  621. return e;
  622. });
  623. navItem.list = arr;
  624. navItem.loadingType = 'more';
  625. this.$set(navItem, 'loaded', true);
  626. this.getUser();
  627. })
  628. .catch(e => {
  629. // uni.hideLoading()
  630. console.log(e);
  631. });
  632. },
  633. // 修改杠杆倍数
  634. changeGG(ind, item) {
  635. this.ggBs = item.num;
  636. this.ggIndex = ind;
  637. },
  638. // 列表切换
  639. ddTypeChage(ind) {
  640. this.ddType = ind;
  641. this.levertadeLaverorder('tabChange');
  642. },
  643. // 初始化重新加載
  644. ddTypeInit() {
  645. // 初始化數據
  646. let item = this.loadData[this.ddType];
  647. item.loadingType = 'more';
  648. item.list = [];
  649. item.page = 1;
  650. item.limit = 10;
  651. item.loaded = false;
  652. this.levertadeLaverorder();
  653. },
  654. navto(url) {
  655. uni.navigateTo({
  656. url,
  657. fail() {
  658. uni.switchTab({
  659. url
  660. });
  661. }
  662. });
  663. },
  664. getUser() {
  665. getUser().then(re => {
  666. this.setUserInfo(re.data);
  667. });
  668. }
  669. }
  670. };
  671. </script>
  672. <style lang="scss">
  673. .usdtTitle,
  674. .box {
  675. padding: 0 20rpx;
  676. width: 750rpx;
  677. background-color: #ffffff;
  678. }
  679. .usdtTitle {
  680. border-bottom: 1px solid $border-color-light;
  681. line-height: 1;
  682. .left {
  683. font-size: 32rpx;
  684. font-weight: bold;
  685. .img {
  686. width: 36rpx;
  687. }
  688. }
  689. .right {
  690. .img {
  691. width: 48rpx;
  692. }
  693. }
  694. }
  695. .box {
  696. line-height: 1;
  697. align-items: flex-start;
  698. .itemTitle {
  699. font-weight: bold;
  700. font-size: $font-sm;
  701. }
  702. .item {
  703. // flex-grow: 1;
  704. // width: 50%;
  705. flex-shrink: 0;
  706. }
  707. .buttomBox {
  708. font-size: $font-sm;
  709. .buttom {
  710. width: 350rpx;
  711. padding: 20rpx 0;
  712. text-align: center;
  713. border-radius: 10rpx;
  714. background-color: #f5f5f5;
  715. &.action {
  716. color: #ffffff;
  717. background-color: $color-green;
  718. }
  719. }
  720. }
  721. .tabType {
  722. justify-content: space-around;
  723. .tab {
  724. padding-top: 30rpx;
  725. padding-bottom: 20rpx;
  726. color: #545d6f;
  727. font-size: $font-sm;
  728. font-weight: bold;
  729. &.action {
  730. color: $uni-color-warning;
  731. }
  732. }
  733. }
  734. .inputBox {
  735. height: 60rpx;
  736. border-radius: 10rpx;
  737. padding: 0 20rpx;
  738. display: flex;
  739. align-items: center;
  740. border: 1px solid $border-color-light;
  741. .buttomZd {
  742. font-size: $font-sm;
  743. }
  744. .input {
  745. font-size: $font-sm;
  746. flex-grow: 1;
  747. }
  748. .rightInputBox {
  749. .jg {
  750. border: 1px solid $border-color-light;
  751. height: 50rpx;
  752. margin: 0 30rpx;
  753. }
  754. .img {
  755. width: 28rpx;
  756. height: 28rpx;
  757. }
  758. }
  759. }
  760. .itemLeftList {
  761. justify-content: space-around;
  762. .ll {
  763. border: 1px solid $border-color-light;
  764. width: 74rpx;
  765. height: 54rpx;
  766. line-height: 54rpx;
  767. text-align: center;
  768. font-size: $font-sm;
  769. font-weight: bold;
  770. &.action {
  771. background-color: #f5f5f5;
  772. }
  773. }
  774. }
  775. .buttomSubmit {
  776. color: #ffffff;
  777. height: 64rpx;
  778. line-height: 64rpx;
  779. text-align: center;
  780. font-size: $font-sm;
  781. border-radius: 10rpx;
  782. }
  783. .itemName {
  784. .itemMinName {
  785. width: 20%;
  786. font-size: 22rpx;
  787. color: #5d6677;
  788. }
  789. }
  790. .itemList {
  791. .list {
  792. font-size: 20rpx;
  793. padding: 10rpx 0;
  794. .li {
  795. width: 20%;
  796. }
  797. }
  798. .llMax {
  799. padding: 30rpx 0;
  800. font-weight: bold;
  801. font-size: $font-lg;
  802. }
  803. }
  804. .listTitleBox {
  805. border-bottom: 1px solid $border-color-light;
  806. align-items: flex-start;
  807. .leftBottom {
  808. flex-shrink: 0;
  809. font-size: $font-lg;
  810. font-weight: bold;
  811. .action {
  812. border-bottom: 2px solid $uni-color-warning;
  813. }
  814. .titleType {
  815. padding-bottom: 20rpx;
  816. }
  817. }
  818. .rightBottom {
  819. font-size: $font-base;
  820. color: #707a8a;
  821. flex-shrink: 0;
  822. .img {
  823. width: 36rpx;
  824. }
  825. }
  826. }
  827. .usdtList {
  828. color: #707a8a;
  829. border-bottom: 1px solid $border-color-light;
  830. .name {
  831. font-size: $font-lg;
  832. font-weight: bold;
  833. }
  834. .usdtListButtom {
  835. font-size: $font-base;
  836. background-color: #f5f5f5;
  837. color: $uni-color-warning;
  838. border-radius: 10rpx;
  839. padding: 10rpx 20rpx;
  840. }
  841. .tip {
  842. padding-top: 10rpx;
  843. padding-bottom: 10rpx;
  844. font-size: $font-base;
  845. }
  846. .tipList {
  847. font-size: $font-sm;
  848. text-align: center;
  849. width: 33%;
  850. padding-top: 20rpx;
  851. .nameTip {
  852. padding-bottom: 20rpx;
  853. }
  854. }
  855. }
  856. }
  857. .alertBox {
  858. position: fixed;
  859. top: 0;
  860. left: 0;
  861. right: 0;
  862. bottom: 0;
  863. background-color: #ffffff;
  864. text-align: center;
  865. color: #707a8a;
  866. .reback {
  867. width: 100%;
  868. display: flex;
  869. justify-content: flex-start;
  870. padding-left: 10rpx;
  871. padding-top: 10rpx;
  872. image {
  873. width: 50rpx;
  874. height: 50rpx;
  875. }
  876. }
  877. .type {
  878. width: 30%;
  879. flex-grow: 1;
  880. }
  881. .itemlist {
  882. padding-top: 40rpx;
  883. align-items: flex-start;
  884. .name {
  885. font-weight: 700;
  886. font-family: 'PingFang SC, STHeitiSC-Light, Helvetica-Light, arial, sans-serif, Droid Sans Fallback';
  887. padding-left: 20rpx;
  888. text-align: left;
  889. color: #000;
  890. }
  891. .tip {
  892. padding-left: 20rpx;
  893. text-align: left;
  894. }
  895. }
  896. .list {
  897. padding: 30rpx 0;
  898. border-bottom: 1px solid $border-color-light;
  899. .type {
  900. font-size: $font-lg;
  901. font-weight: bold;
  902. }
  903. }
  904. }
  905. .right-wrap {
  906. flex-grow: 1;
  907. padding: 0 10rpx;
  908. font-size: 24rpx;
  909. color: #707a8a;
  910. .line {
  911. view {
  912. padding: 10rpx 0;
  913. }
  914. }
  915. }
  916. .new-price {
  917. font-size: 36rpx;
  918. color: #0ecb81;
  919. padding: 20rpx;
  920. }
  921. .vheight {
  922. height: var(--status-bar-height);
  923. }
  924. </style>