tradlist.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369
  1. <template>
  2. <view class="content">
  3. <view class="flex navbar">
  4. <view class="" v-for="(item,index) in navList" :class="{'action':current == index}" @click="changetab(index)">
  5. {{item.name}}
  6. </view>
  7. </view>
  8. <swiper class="swiper" :style="{'height': height}" :current="current">
  9. <swiper-item v-for="navitem in navList">
  10. <scroll-view scroll-y="true" class="scroll" :style="{'height': height}">
  11. <view v-for="(item,ind) in navitem.list" class="usdtList padding-t-30 padding-b-30">
  12. <view class="flex">
  13. <view class="name">
  14. <text v-if="item.direction==1" class="font-color-green">
  15. 做多
  16. </text>
  17. <text v-if="item.direction==2" class="font-color-red">
  18. 做空
  19. </text>
  20. <text>
  21. {{item.symbol}}
  22. </text>
  23. <text v-if="current==0"
  24. :class="{'font-color-green':+item.profit>=0,'font-color-red':+item.profit<0}">
  25. {{+item.profit}}
  26. </text>
  27. </view>
  28. <view @click="clearorder(item)" v-if="current==0" class="usdtListButtom">
  29. 撤銷
  30. </view>
  31. <view @click="closeorder(item)" v-if="current==1" class="usdtListButtom">
  32. 一鍵平倉
  33. </view>
  34. </view>
  35. <view class="tip ">
  36. <text v-if="item.direction==1">
  37. 委託時間:{{item.wttime}}
  38. </text>
  39. <text v-if="item.direction==2">
  40. 開倉時間:{{item.addtime}}
  41. </text>
  42. </view>
  43. <view class="flex" style="flex-wrap: wrap;justify-content: flex-start;">
  44. <view v-if="current == 0" class="tipList">
  45. <view class="nameTip">
  46. 限價
  47. </view>
  48. <view class="text">
  49. {{item.wt_price}}
  50. </view>
  51. </view>
  52. <view v-if="current != 0" class="tipList">
  53. <view class="nameTip">
  54. 開倉單價
  55. </view>
  56. <view class="text">
  57. {{item.price}}
  58. </view>
  59. </view>
  60. <view class="tipList" v-if="current == 2">
  61. <view class="nameTip">
  62. 平倉單價
  63. </view>
  64. <view class="text">
  65. {{item.pc_price}}
  66. </view>
  67. </view>
  68. <view class="tipList">
  69. <view class="nameTip">
  70. {{current == 0?'委托手數': '交易個數'}}
  71. </view>
  72. <view class="text">
  73. {{item.num}}
  74. </view>
  75. </view>
  76. <view class="tipList">
  77. <view class="nameTip">
  78. 槓桿倍數
  79. </view>
  80. <view class="text">
  81. {{item.ggan}}
  82. </view>
  83. </view>
  84. <template v-if="current == 1">
  85. <view class="tipList">
  86. <view class="nameTip">
  87. 止盈單價
  88. </view>
  89. <view class="text">
  90. {{item.zyprice}}
  91. </view>
  92. </view>
  93. <view class="tipList">
  94. <view class="nameTip">
  95. 止損單價
  96. </view>
  97. <view class="text">
  98. {{item.zsprice}}
  99. </view>
  100. </view>
  101. </template>
  102. <view class="tipList" v-if="current != 0">
  103. <view class="nameTip">
  104. 手續費
  105. </view>
  106. <view class="text">
  107. {{item.fee}}
  108. </view>
  109. </view>
  110. <template v-if="current == 2">
  111. <view class="tipList" >
  112. <view class="nameTip">
  113. 盈虧狀態
  114. </view>
  115. <view class="text" :style="{'color': item.yk_status == 1?'#5DC887':'#dd524d'}">
  116. {{item.yk_status == 1?'盈利':'虧損'}}
  117. </view>
  118. </view>
  119. <view class="tipList">
  120. <view class="nameTip">
  121. 盈虧金額
  122. </view>
  123. <view class="text" :style="{'color': item.yk_status == 1?'#5DC887':'#dd524d'}">
  124. {{item.yk_status == 1?'+':'-'}}{{item.ylmoney}}
  125. </view>
  126. </view>
  127. </template>
  128. </view>
  129. </view>
  130. </scroll-view>
  131. </swiper-item>
  132. </swiper>
  133. </view>
  134. </template>
  135. <script>
  136. import {
  137. levertadeLaverorder,
  138. closeorder,
  139. clearorder,
  140. UpOrderHandle,
  141. bond
  142. } from '@/api/heyue.js';
  143. export default {
  144. data() {
  145. return {
  146. height: '',
  147. current: 0,
  148. navList: [{
  149. status: 1,
  150. name: '全部委托',
  151. page: 1,
  152. limit: 10,
  153. loadingType: 'more',
  154. loded: false,
  155. list: []
  156. },
  157. {
  158. status: 2,
  159. name: '全部持倉',
  160. page: 1,
  161. limit: 10,
  162. loadingType: 'more',
  163. loded: false,
  164. list: []
  165. },
  166. {
  167. status: 3,
  168. name: '成交明細',
  169. page: 1,
  170. limit: 10,
  171. loadingType: 'more',
  172. loded: false,
  173. list: []
  174. }
  175. ]
  176. }
  177. },
  178. onLoad() {
  179. },
  180. onShow() {
  181. this.loadData()
  182. },
  183. onReachBottom() {
  184. },
  185. onReady(res) {
  186. var obj = this;
  187. uni.getSystemInfo({
  188. success: resu => {
  189. const query = uni.createSelectorQuery();
  190. query.select('.swiper').boundingClientRect();
  191. query.exec(function(res) {
  192. obj.height = resu.windowHeight - res[0].top + 'px';
  193. });
  194. },
  195. fail: res => {}
  196. });
  197. },
  198. methods: {
  199. changetab(index) {
  200. this.current = index
  201. this.loadData('tab')
  202. },
  203. loadData(tab) {
  204. let obj = this
  205. let index = obj.current
  206. let item = obj.navList[index]
  207. if (tab == 'tab' && item.loaded) {
  208. return
  209. }
  210. if (item.loadingType == 'loading' || item.loadingType == 'noMore') {
  211. return
  212. }
  213. levertadeLaverorder({
  214. type: item.status,
  215. page: item.page,
  216. limit: item.limit
  217. })
  218. .then(({
  219. list
  220. }) => {
  221. // uni.hideLoading()
  222. console.log(list,'list+++++++')
  223. let arr = list.map(e => {
  224. e.direction = +e.direction;
  225. e.bond = +e.bond
  226. e.price = +e.price
  227. e.wt_price = +e.wt_price
  228. return e;
  229. });
  230. item.list = arr;
  231. this.$set(item, 'loaded', true);
  232. })
  233. .catch(e => {
  234. // uni.hideLoading()
  235. console.log(e);
  236. });
  237. },
  238. // 平倉
  239. closeorder(item) {
  240. const that = this;
  241. uni.showModal({
  242. title: '平倉',
  243. content: '是否立即平倉,確認後不可修改',
  244. confirmText: '確認',
  245. cancelText: '取消',
  246. success: res => {
  247. if (res.confirm) {
  248. uni.showLoading({
  249. title: '請求中...',
  250. mask: true
  251. });
  252. closeorder({
  253. id: item.id
  254. }).then((e) => {
  255. uni.hideLoading()
  256. uni.showToast({
  257. title: '平倉成功',
  258. icon: 'success'
  259. });
  260. that.ddTypeInit()
  261. }).catch(() => {
  262. uni.hideLoading()
  263. })
  264. }
  265. },
  266. fail: () => {},
  267. complete: () => {}
  268. });
  269. },
  270. // 撤銷
  271. clearorder(item) {
  272. const that = this;
  273. uni.showModal({
  274. title: '撤銷',
  275. content: '是否立即撤銷,確認後不可修改',
  276. confirmText: '確認',
  277. success: res => {
  278. if (res.confirm) {
  279. uni.showLoading({
  280. title: '請求中...',
  281. mask: true
  282. });
  283. clearorder({
  284. id: item.id
  285. }).then((e) => {
  286. uni.hideLoading()
  287. uni.showToast({
  288. title: '撤銷成功',
  289. icon: 'success'
  290. });
  291. that.ddTypeInit()
  292. }).catch(() => {
  293. uni.hideLoading()
  294. })
  295. }
  296. },
  297. fail: () => {},
  298. complete: () => {}
  299. });
  300. },
  301. }
  302. }
  303. </script>
  304. <style lang="scss">
  305. .swiper {
  306. background-color: #fff;
  307. }
  308. .scroll {
  309. padding: 0 20rpx;
  310. }
  311. .navbar {
  312. justify-content: flex-start;
  313. font-size: 40rpx;
  314. padding: 30rpx;
  315. view {
  316. width: 184rpx;
  317. height: 100rpx;
  318. line-height: 100rpx;
  319. }
  320. }
  321. .usdtList {
  322. color: #707A8A;
  323. border-bottom: 1px solid $border-color-light;
  324. .name {
  325. font-size: $font-lg;
  326. font-weight: bold;
  327. }
  328. .usdtListButtom {
  329. font-size: $font-base;
  330. background-color: #F5F5F5;
  331. color: $uni-color-warning;
  332. border-radius: 10rpx;
  333. padding: 10rpx 20rpx;
  334. }
  335. .tip {
  336. padding-top: 10rpx;
  337. padding-bottom: 30rpx;
  338. font-size: $font-base;
  339. }
  340. .tipList {
  341. font-size: $font-sm;
  342. text-align: center;
  343. width: 25%;
  344. max-width: 33%;
  345. padding-top: 20rpx;
  346. flex-grow: 1;
  347. .nameTip {
  348. padding-bottom: 20rpx;
  349. }
  350. }
  351. }
  352. .action {
  353. font-weight: bold;
  354. font-size: 44rpx;
  355. }
  356. </style>