details.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486
  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. type: 'market_depth'
  173. });
  174. startSocket({
  175. type: 'daymarket'
  176. });
  177. },
  178. consumeBtn() {
  179. const pages = getCurrentPages();
  180. console.log('pages = ', pages)
  181. if (pages.length >= 2 && pages[pages.length - 2].route === 'pages/contract/index') {
  182. uni.navigateBack({
  183. delta: 1
  184. });
  185. } else {
  186. uni.reLaunch({
  187. url: '/pages/contract/index'
  188. })
  189. }
  190. }
  191. }
  192. }
  193. </script>
  194. <style lang="scss" scoped>
  195. .details-nav {
  196. display: flex;
  197. align-items: center;
  198. border-left: 1rpx solid $border-color4;
  199. padding-left: 20rpx;
  200. .nav-name {
  201. padding-left: 10rpx;
  202. font-size: 38rpx;
  203. font-weight: bold;
  204. }
  205. }
  206. .title-iocn {
  207. width: 28rpx;
  208. height: 24rpx;
  209. display: flex;
  210. flex-direction: column;
  211. // align-items: center;
  212. justify-content: space-between;
  213. .title-iocn-item {
  214. width: 100%;
  215. height: 4rpx;
  216. border-radius: 2rpx;
  217. background: #111111;
  218. &:first-child {
  219. width: 50%;
  220. }
  221. }
  222. }
  223. // <view class="top-index fixed-top-index" :style="{'top': navBarHeight + 'px'}">
  224. // <view :class="['index-val' , $setColor(27)]">
  225. // <text class="index-val-num color">27</text>
  226. // <text class="index-val-percent color">0.29%</text>
  227. // </view>
  228. // <view class="index-type">
  229. // 标记价格 <text class="iconfont">&#xeb6d;</text>
  230. // </view>
  231. // </view>
  232. .top-index {
  233. width: 100%;
  234. height: 94rpx;
  235. padding: 16rpx $pages-padding;
  236. border-bottom: 1rpx solid $border-color;
  237. display: flex;
  238. justify-content: space-between;
  239. background-color: #fff;
  240. .index-val-num {
  241. font-size: 30rpx;
  242. font-weight: bold;
  243. }
  244. .index-val-percent {
  245. font-size: 24rpx;
  246. padding-left: 10rpx;
  247. }
  248. .index-type {
  249. width: 240rpx;
  250. height: 100%;
  251. border: 1rpx solid $border-color6;
  252. display: flex;
  253. justify-content: space-between;
  254. align-items: center;
  255. font-size: 24rpx;
  256. padding: 0 20rpx;
  257. border-radius: 10rpx;
  258. .iconfont {
  259. font-size: 20rpx;
  260. color: $Theme-Color;
  261. }
  262. }
  263. }
  264. .fixed-top-index {
  265. position: fixed;
  266. z-index: 1;
  267. left: 0;
  268. }
  269. .iframe-content {
  270. width: 100%;
  271. height: 660rpx;
  272. }
  273. .info-content {
  274. display: flex;
  275. align-items: stretch;
  276. flex-wrap: wrap;
  277. padding: 26rpx $pages-padding 0;
  278. border-bottom: 1rpx solid $border-color;
  279. .info-item {
  280. min-height: 70rpx;
  281. width: calc(100% / 3);
  282. flex-shrink: 0;
  283. display: flex;
  284. flex-direction: column;
  285. font-size: 20rpx;
  286. margin-bottom: 26rpx;
  287. display: flex;
  288. flex-direction: column;
  289. justify-content: space-between;
  290. &:nth-child(3n),
  291. &:nth-child(3n - 1) {
  292. text-align: right;
  293. }
  294. }
  295. }
  296. .val-content {
  297. width: 100%;
  298. .val-content-lable {
  299. width: 100%;
  300. display: flex;
  301. align-items: stretch;
  302. padding: 0 $pages-padding;
  303. height: 96rpx;
  304. border-bottom: 1rpx solid $border-color;
  305. .lable-text {
  306. height: 100%;
  307. font-size: 28rpx;
  308. line-height: 90rpx;
  309. margin-right: 50rpx;
  310. }
  311. .active-lable-text {
  312. position: relative;
  313. color: $Theme-Color;
  314. &::before {
  315. content: '';
  316. position: absolute;
  317. left: 50%;
  318. bottom: 0;
  319. transform: translateX(-50%);
  320. width: 40rpx;
  321. height: 7rpx;
  322. border-radius: 4rpx;
  323. background-color: $Theme-Color;
  324. }
  325. }
  326. }
  327. .val-content-type {
  328. width: 100%;
  329. height: 66rpx;
  330. border-bottom: 1rpx solid $border-color;
  331. display: flex;
  332. align-items: center;
  333. justify-content: space-between;
  334. padding: 0 $pages-padding;
  335. font-size: 28rpx;
  336. font-weight: bold;
  337. .left-type {
  338. color: $mai_01;
  339. }
  340. .right-type {
  341. color: $mai_02;
  342. }
  343. }
  344. .val-content-list {
  345. width: 100%;
  346. padding: 0 $pages-padding;
  347. display: flex;
  348. justify-content: space-between;
  349. align-items: center;
  350. height: 60rpx;
  351. font-size: 26rpx;
  352. }
  353. .depth-content {
  354. padding: 0 $pages-padding;
  355. width: 100%;
  356. display: flex;
  357. .depth-val {
  358. width: 50%;
  359. flex-shrink: 0;
  360. .depth-item {
  361. height: 80rpx;
  362. position: relative;
  363. .depth-item-bg {
  364. height: 100%;
  365. position: absolute;
  366. top: 0;
  367. }
  368. .depth-item-val {
  369. position: absolute;
  370. width: 100%;
  371. height: 100%;
  372. font-size: 26rpx;
  373. display: flex;
  374. justify-content: space-between;
  375. align-items: center;
  376. font-weight: bold;
  377. }
  378. }
  379. .depth-item-left {
  380. .depth-item-val {
  381. padding-right: 10rpx;
  382. }
  383. .depth-item-bg {
  384. right: 0;
  385. background-color: $mai_03;
  386. }
  387. .item-val-price {
  388. color: $Theme-Color;
  389. }
  390. }
  391. .depth-item-right {
  392. .depth-item-val {
  393. padding-left: 10rpx;
  394. }
  395. .depth-item-bg {
  396. left: 0;
  397. background-color: $mai_04;
  398. }
  399. .item-val-price {
  400. color: $Theme-Color2;
  401. }
  402. }
  403. }
  404. }
  405. }
  406. .details-footer {
  407. position: fixed;
  408. left: 0;
  409. bottom: 0;
  410. height: 90rpx;
  411. width: 100%;
  412. padding: 5rpx 40rpx;
  413. display: flex;
  414. justify-content: space-between;
  415. align-items: stretch;
  416. background-color: #fff;
  417. .footer-btn {
  418. flex: 1;
  419. height: 80rpx;
  420. color: #fff;
  421. text-align: center;
  422. line-height: 80rpx;
  423. font-size: 30rpx;
  424. border-radius: 6rpx;
  425. &:first-child {
  426. background-color: $Theme-Color;
  427. }
  428. &:last-child {
  429. margin-left: 20rpx;
  430. background-color: $Theme-Color2;
  431. }
  432. }
  433. }
  434. </style>