tradlist.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  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">
  44. <view v-if="item.direction==1" 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="item.direction==2" class="tipList">
  53. <view class="nameTip">
  54. 開倉單價
  55. </view>
  56. <view class="text">
  57. {{item.price}}
  58. </view>
  59. </view>
  60. <view class="tipList">
  61. <view class="nameTip">
  62. 保證金
  63. </view>
  64. <view class="text">
  65. {{item.bond}}
  66. </view>
  67. </view>
  68. <view class="tipList">
  69. <view class="nameTip">
  70. 交易個數
  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. </view>
  85. </view>
  86. </scroll-view>
  87. </swiper-item>
  88. </swiper>
  89. </view>
  90. </template>
  91. <script>
  92. import {
  93. levertadeLaverorder,
  94. closeorder,
  95. clearorder,
  96. UpOrderHandle,
  97. bond
  98. } from '@/api/heyue.js';
  99. export default {
  100. data() {
  101. return {
  102. height: '',
  103. current: 0,
  104. navList: [{
  105. status: 1,
  106. name: '全部委托',
  107. page: 1,
  108. limit: 10,
  109. loadingType: 'more',
  110. loded: false,
  111. list: []
  112. },
  113. {
  114. status: 2,
  115. name: '全部持倉',
  116. page: 1,
  117. limit: 10,
  118. loadingType: 'more',
  119. loded: false,
  120. list: []
  121. },
  122. {
  123. status: 3,
  124. name: '成交明細',
  125. page: 1,
  126. limit: 10,
  127. loadingType: 'more',
  128. loded: false,
  129. list: []
  130. }
  131. ]
  132. }
  133. },
  134. onLoad() {
  135. },
  136. onShow() {
  137. this.loadData()
  138. },
  139. onReachBottom() {
  140. },
  141. onReady(res) {
  142. var obj = this;
  143. uni.getSystemInfo({
  144. success: resu => {
  145. const query = uni.createSelectorQuery();
  146. query.select('.swiper').boundingClientRect();
  147. query.exec(function(res) {
  148. obj.height = resu.windowHeight - res[0].top + 'px';
  149. });
  150. },
  151. fail: res => {}
  152. });
  153. },
  154. methods: {
  155. changetab(index) {
  156. this.current = index
  157. this.loadData('tab')
  158. },
  159. loadData(tab) {
  160. let obj = this
  161. let index = obj.current
  162. let item = obj.navList[index]
  163. if (tab == 'tab' && item.loaded) {
  164. return
  165. }
  166. if (item.loadingType == 'loading' || item.loadingType == 'noMore') {
  167. return
  168. }
  169. levertadeLaverorder({
  170. type: item.status,
  171. page: item.page,
  172. limit: item.limit
  173. })
  174. .then(({
  175. list
  176. }) => {
  177. // uni.hideLoading()
  178. let arr = list.map(e => {
  179. e.direction = +e.direction;
  180. e.bond = +e.bond
  181. e.price = +e.price
  182. e.wt_price = +e.wt_price
  183. return e;
  184. });
  185. item.list = arr;
  186. this.$set(item, 'loaded', true);
  187. })
  188. .catch(e => {
  189. // uni.hideLoading()
  190. console.log(e);
  191. });
  192. },
  193. // 平倉
  194. closeorder(item) {
  195. const that = this;
  196. uni.showModal({
  197. title: '平倉',
  198. content: '是否立即平倉,確認後不可修改',
  199. confirmText: '確認',
  200. cancelText: '取消',
  201. success: res => {
  202. if (res.confirm) {
  203. uni.showLoading({
  204. title: '請求中...',
  205. mask: true
  206. });
  207. closeorder({
  208. id: item.id
  209. }).then((e) => {
  210. uni.hideLoading()
  211. uni.showToast({
  212. title: '平倉成功',
  213. icon: 'success'
  214. });
  215. that.ddTypeInit()
  216. }).catch(() => {
  217. uni.hideLoading()
  218. })
  219. }
  220. },
  221. fail: () => {},
  222. complete: () => {}
  223. });
  224. },
  225. // 撤銷
  226. clearorder(item) {
  227. const that = this;
  228. uni.showModal({
  229. title: '撤銷',
  230. content: '是否立即撤銷,確認後不可修改',
  231. confirmText: '確認',
  232. success: res => {
  233. if (res.confirm) {
  234. uni.showLoading({
  235. title: '請求中...',
  236. mask: true
  237. });
  238. clearorder({
  239. id: item.id
  240. }).then((e) => {
  241. uni.hideLoading()
  242. uni.showToast({
  243. title: '撤銷成功',
  244. icon: 'success'
  245. });
  246. that.ddTypeInit()
  247. }).catch(() => {
  248. uni.hideLoading()
  249. })
  250. }
  251. },
  252. fail: () => {},
  253. complete: () => {}
  254. });
  255. },
  256. }
  257. }
  258. </script>
  259. <style lang="scss">
  260. .swiper {
  261. background-color: #fff;
  262. }
  263. .scroll {
  264. padding: 0 20rpx;
  265. }
  266. .navbar {
  267. justify-content: flex-start;
  268. font-size: 40rpx;
  269. padding: 30rpx;
  270. view {
  271. width: 184rpx;
  272. height: 100rpx;
  273. line-height: 100rpx;
  274. }
  275. }
  276. .usdtList {
  277. color: #707A8A;
  278. border-bottom: 1px solid $border-color-light;
  279. .name {
  280. font-size: $font-lg;
  281. font-weight: bold;
  282. }
  283. .usdtListButtom {
  284. font-size: $font-base;
  285. background-color: #F5F5F5;
  286. color: $uni-color-warning;
  287. border-radius: 10rpx;
  288. padding: 10rpx 20rpx;
  289. }
  290. .tip {
  291. padding-top: 10rpx;
  292. padding-bottom: 30rpx;
  293. font-size: $font-base;
  294. }
  295. .tipList {
  296. font-size: $font-sm;
  297. text-align: center;
  298. .nameTip {
  299. padding-bottom: 20rpx;
  300. }
  301. }
  302. }
  303. .action {
  304. font-weight: bold;
  305. font-size: 44rpx;
  306. }
  307. </style>