details - 副本.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481
  1. <template>
  2. <view :rise-fall="stocksColor">
  3. <headContent borderBottom>
  4. <template #left>
  5. <reverse-back>
  6. <template #extend>
  7. <view class="details-nav">
  8. <view class="title-iocn">
  9. <text class="title-iocn-item"></text>
  10. <text class="title-iocn-item"></text>
  11. <text class="title-iocn-item"></text>
  12. </view>
  13. <text class="nav-name">
  14. {{ currencyVal.currency_name }}/ {{ currencyVal.legal_name }}
  15. </text>
  16. </view>
  17. </template>
  18. </reverse-back>
  19. </template>
  20. <template #right>
  21. <headCollect />
  22. </template>
  23. </headContent>
  24. <view class="top-index fixed-top-index" :style="{'top': navBarHeight + 'px'}">
  25. <view :class="['index-val' , $setColor(daymarket.open)]">
  26. <text class="index-val-num color">{{ daymarket.open }}</text>
  27. <text class="index-val-percent color">{{ daymarket.change }}%</text>
  28. </view>
  29. <view class="index-type">
  30. 标记价格 <text class="iconfont">&#xeb6d;</text>
  31. </view>
  32. </view>
  33. <view style="width:100%;height:90rpx;"></view>
  34. <view class="info-content">
  35. <view class="info-item">
  36. <text class="info-lable">标记价格</text>
  37. <text class="info-val">{{ daymarket.now_price }}</text>
  38. </view>
  39. <view class="info-item">
  40. <text class="info-lable">24H高</text>
  41. <text class="info-val">{{ daymarket.high }}</text>
  42. </view>
  43. <view class="info-item">
  44. <text class="info-lable">24H低</text>
  45. <text class="info-val">{{ daymarket.low }}</text>
  46. </view>
  47. <view class="info-item">
  48. <text class="info-lable">24H额(BTC)</text>
  49. <text class="info-val">{{ daymarket.volume }}</text>
  50. </view>
  51. <view class="info-item">
  52. <text class="info-lable">24H量(BTC)</text>
  53. <text class="info-val">{{ daymarket.volume * daymarket.open }}</text>
  54. </view>
  55. </view>
  56. <view class="iframe-content">
  57. <template v-if="currencyVal.legal_id">
  58. <k-line></k-line>
  59. </template>
  60. </view>
  61. <gap />
  62. <view class="val-content">
  63. <view class="val-content-lable">
  64. <text @click.stop="valLableIndex = 0"
  65. :class="['lable-text' , valLableIndex === 0 ? 'active-lable-text' : '']">交易深度</text>
  66. <text @click.stop="valLableIndex = 1"
  67. :class="['lable-text' , valLableIndex === 1 ? 'active-lable-text' : '']">实时成交</text>
  68. </view>
  69. <swiper class="swiper-content" :current="valLableIndex"
  70. :style="{'height': swiperHeight ? `${swiperHeight}px` : '' }" disable-touch>
  71. <swiper-item class="swiper-item-box">
  72. <view class="val-content-type">
  73. <text class="left-type">买</text>
  74. <text class="right-type">卖</text>
  75. </view>
  76. <view class="val-content-list">
  77. <text>数量(张)</text>
  78. <text>价格(USDT)</text>
  79. <text>数量(张)</text>
  80. </view>
  81. <u-list class="swiper-list" :style="{'height': scrollLeftHeight ? `${scrollLeftHeight}px` : '' }">
  82. <view class="depth-content">
  83. <view class="depth-val">
  84. <template v-for="(item , index) in asks">
  85. <market-depth :type="2" :val="item" height="80rpx"></market-depth>
  86. <!-- <view class="depth-item depth-item-left">
  87. <text class="depth-item-bg" :style="{'width': item[2] + '%' }"></text>
  88. <view class="depth-item-val">
  89. <text>{{ item[1] }}</text>
  90. <text class="item-val-price">{{ item[0] }}</text>
  91. </view>
  92. </view> -->
  93. </template>
  94. </view>
  95. <view class="depth-val">
  96. <template v-for="(item , index) in bids">
  97. <market-depth :type="1" :val="item" height="80rpx" leftbg></market-depth>
  98. </template>
  99. </view>
  100. </view>
  101. </u-list>
  102. </swiper-item>
  103. <swiper-item>
  104. <view class="val-content-list">
  105. <text>时间</text>
  106. <text>价格(USDT)</text>
  107. <text>数量(张)</text>
  108. </view>
  109. <u-list class="swiper-list" :style="{'height': scrollRightHeight ? `${scrollRightHeight}px` : '' }">
  110. <empty />
  111. </u-list>
  112. </swiper-item>
  113. </swiper>
  114. </view>
  115. <view class="details-footer">
  116. <view class="footer-btn" @click.stop="consumeBtn">买入/做多</view>
  117. <view class="footer-btn" @click.stop="consumeBtn">卖出/做空</view>
  118. </view>
  119. </view>
  120. </template>
  121. <script>
  122. import {
  123. mapGetters
  124. } from 'vuex'
  125. import {
  126. startSocket,
  127. closeSocket
  128. } from "@/utils/websocket.js"
  129. export default {
  130. data() {
  131. return {
  132. valLableIndex: 0,
  133. swiperHeight: 0,
  134. scrollLeftHeight: 0,
  135. scrollRightHeight: 0
  136. };
  137. },
  138. computed: {
  139. ...mapGetters([
  140. "currencyVal",
  141. "stocksColor",
  142. 'bids',
  143. 'asks',
  144. 'daymarket',
  145. 'tabBarHeight',
  146. 'PageContentHeight',
  147. 'navBarHeight',
  148. 'contractAccount'
  149. ])
  150. },
  151. watch: {
  152. PageContentHeight: {
  153. handler(newH) {
  154. this.swiperHeight = newH - uni.upx2px(90) - uni.upx2px(94)
  155. this.scrollLeftHeight = this.swiperHeight - uni.upx2px(66) - uni.upx2px(60) - uni.upx2px(96)
  156. this.scrollRightHeight = this.swiperHeight - uni.upx2px(60) - uni.upx2px(96)
  157. },
  158. immediate: true
  159. }
  160. },
  161. onShow() {
  162. this.setSocket();
  163. },
  164. onHide() {
  165. closeSocket()
  166. },
  167. mounted() {
  168. },
  169. methods: {
  170. setSocket() {
  171. startSocket();
  172. },
  173. consumeBtn() {
  174. const pages = getCurrentPages();
  175. console.log('pages = ', pages)
  176. if (pages.length >= 2 && pages[pages.length - 2].route === 'pages/contract/index') {
  177. uni.navigateBack({
  178. delta: 1
  179. });
  180. } else {
  181. uni.reLaunch({
  182. url: '/pages/contract/index'
  183. })
  184. }
  185. }
  186. }
  187. }
  188. </script>
  189. <style lang="scss" scoped>
  190. .details-nav {
  191. display: flex;
  192. align-items: center;
  193. border-left: 1rpx solid $border-color4;
  194. padding-left: 20rpx;
  195. .nav-name {
  196. padding-left: 10rpx;
  197. font-size: 38rpx;
  198. font-weight: bold;
  199. }
  200. }
  201. .title-iocn {
  202. width: 28rpx;
  203. height: 24rpx;
  204. display: flex;
  205. flex-direction: column;
  206. // align-items: center;
  207. justify-content: space-between;
  208. .title-iocn-item {
  209. width: 100%;
  210. height: 4rpx;
  211. border-radius: 2rpx;
  212. background: #111111;
  213. &:first-child {
  214. width: 50%;
  215. }
  216. }
  217. }
  218. // <view class="top-index fixed-top-index" :style="{'top': navBarHeight + 'px'}">
  219. // <view :class="['index-val' , $setColor(27)]">
  220. // <text class="index-val-num color">27</text>
  221. // <text class="index-val-percent color">0.29%</text>
  222. // </view>
  223. // <view class="index-type">
  224. // 标记价格 <text class="iconfont">&#xeb6d;</text>
  225. // </view>
  226. // </view>
  227. .top-index {
  228. width: 100%;
  229. height: 94rpx;
  230. padding: 16rpx $pages-padding;
  231. border-bottom: 1rpx solid $border-color;
  232. display: flex;
  233. justify-content: space-between;
  234. background-color: #fff;
  235. .index-val-num {
  236. font-size: 30rpx;
  237. font-weight: bold;
  238. }
  239. .index-val-percent {
  240. font-size: 24rpx;
  241. padding-left: 10rpx;
  242. }
  243. .index-type {
  244. width: 240rpx;
  245. height: 100%;
  246. border: 1rpx solid $border-color6;
  247. display: flex;
  248. justify-content: space-between;
  249. align-items: center;
  250. font-size: 24rpx;
  251. padding: 0 20rpx;
  252. border-radius: 10rpx;
  253. .iconfont {
  254. font-size: 20rpx;
  255. color: $Theme-Color;
  256. }
  257. }
  258. }
  259. .fixed-top-index {
  260. position: fixed;
  261. z-index: 1;
  262. left: 0;
  263. }
  264. .iframe-content {
  265. width: 100%;
  266. height: 660rpx;
  267. }
  268. .info-content {
  269. display: flex;
  270. align-items: stretch;
  271. flex-wrap: wrap;
  272. padding: 26rpx $pages-padding 0;
  273. border-bottom: 1rpx solid $border-color;
  274. .info-item {
  275. min-height: 70rpx;
  276. width: calc(100% / 3);
  277. flex-shrink: 0;
  278. display: flex;
  279. flex-direction: column;
  280. font-size: 20rpx;
  281. margin-bottom: 26rpx;
  282. display: flex;
  283. flex-direction: column;
  284. justify-content: space-between;
  285. &:nth-child(3n),
  286. &:nth-child(3n - 1) {
  287. text-align: right;
  288. }
  289. }
  290. }
  291. .val-content {
  292. width: 100%;
  293. .val-content-lable {
  294. width: 100%;
  295. display: flex;
  296. align-items: stretch;
  297. padding: 0 $pages-padding;
  298. height: 96rpx;
  299. border-bottom: 1rpx solid $border-color;
  300. .lable-text {
  301. height: 100%;
  302. font-size: 28rpx;
  303. line-height: 90rpx;
  304. margin-right: 50rpx;
  305. }
  306. .active-lable-text {
  307. position: relative;
  308. color: $Theme-Color;
  309. &::before {
  310. content: '';
  311. position: absolute;
  312. left: 50%;
  313. bottom: 0;
  314. transform: translateX(-50%);
  315. width: 40rpx;
  316. height: 7rpx;
  317. border-radius: 4rpx;
  318. background-color: $Theme-Color;
  319. }
  320. }
  321. }
  322. .val-content-type {
  323. width: 100%;
  324. height: 66rpx;
  325. border-bottom: 1rpx solid $border-color;
  326. display: flex;
  327. align-items: center;
  328. justify-content: space-between;
  329. padding: 0 $pages-padding;
  330. font-size: 28rpx;
  331. font-weight: bold;
  332. .left-type {
  333. color: $mai_01;
  334. }
  335. .right-type {
  336. color: $mai_02;
  337. }
  338. }
  339. .val-content-list {
  340. width: 100%;
  341. padding: 0 $pages-padding;
  342. display: flex;
  343. justify-content: space-between;
  344. align-items: center;
  345. height: 60rpx;
  346. font-size: 26rpx;
  347. }
  348. .depth-content {
  349. padding: 0 $pages-padding;
  350. width: 100%;
  351. display: flex;
  352. .depth-val {
  353. width: 50%;
  354. flex-shrink: 0;
  355. .depth-item {
  356. height: 80rpx;
  357. position: relative;
  358. .depth-item-bg {
  359. height: 100%;
  360. position: absolute;
  361. top: 0;
  362. }
  363. .depth-item-val {
  364. position: absolute;
  365. width: 100%;
  366. height: 100%;
  367. font-size: 26rpx;
  368. display: flex;
  369. justify-content: space-between;
  370. align-items: center;
  371. font-weight: bold;
  372. }
  373. }
  374. .depth-item-left {
  375. .depth-item-val {
  376. padding-right: 10rpx;
  377. }
  378. .depth-item-bg {
  379. right: 0;
  380. background-color: $mai_03;
  381. }
  382. .item-val-price {
  383. color: $Theme-Color;
  384. }
  385. }
  386. .depth-item-right {
  387. .depth-item-val {
  388. padding-left: 10rpx;
  389. }
  390. .depth-item-bg {
  391. left: 0;
  392. background-color: $mai_04;
  393. }
  394. .item-val-price {
  395. color: $Theme-Color2;
  396. }
  397. }
  398. }
  399. }
  400. }
  401. .details-footer {
  402. position: fixed;
  403. left: 0;
  404. bottom: 0;
  405. height: 90rpx;
  406. width: 100%;
  407. padding: 5rpx 40rpx;
  408. display: flex;
  409. justify-content: space-between;
  410. align-items: stretch;
  411. background-color: #fff;
  412. .footer-btn {
  413. flex: 1;
  414. height: 80rpx;
  415. color: #fff;
  416. text-align: center;
  417. line-height: 80rpx;
  418. font-size: 30rpx;
  419. border-radius: 6rpx;
  420. &:first-child {
  421. background-color: $Theme-Color;
  422. }
  423. &:last-child {
  424. margin-left: 20rpx;
  425. background-color: $Theme-Color2;
  426. }
  427. }
  428. }
  429. </style>