details.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483
  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. <!-- <iframe
  58. :src="`https://doc.okenx.com/biking/kline.html?legal_id=${currencyVal.legal_id}&currency_id=${currencyVal.currency_id}&symbol=${currencyVal.currency_name}/${currencyVal.legal_name}`"
  59. frameborder="0"></iframe> -->
  60. </view>
  61. <gap />
  62. <view class="val-content">
  63. <view class="val-content-lable">
  64. <text @click.stop="valLableIndex = 0" :class="['lable-text' , valLableIndex === 0 ? 'active-lable-text' : '']">交易深度</text>
  65. <text @click.stop="valLableIndex = 1" :class="['lable-text' , valLableIndex === 1 ? 'active-lable-text' : '']">实时成交</text>
  66. </view>
  67. <swiper class="swiper-content" :current="valLableIndex"
  68. :style="{'height': swiperHeight ? `${swiperHeight}px` : '' }" disable-touch>
  69. <swiper-item class="swiper-item-box">
  70. <view class="val-content-type">
  71. <text class="left-type">买</text>
  72. <text class="right-type">卖</text>
  73. </view>
  74. <view class="val-content-list">
  75. <text>数量(张)</text>
  76. <text>价格(USDT)</text>
  77. <text>数量(张)</text>
  78. </view>
  79. <u-list class="swiper-list" :style="{'height': scrollLeftHeight ? `${scrollLeftHeight}px` : '' }">
  80. <view class="depth-content">
  81. <view class="depth-val">
  82. <template v-for="(item , index) in asks">
  83. <view class="depth-item depth-item-left">
  84. <text class="depth-item-bg" :style="{'width': item[2] + '%' }"></text>
  85. <view class="depth-item-val">
  86. <text>{{ item[1] }}</text>
  87. <text class="item-val-price">{{ item[0] }}</text>
  88. </view>
  89. </view>
  90. </template>
  91. </view>
  92. <view class="depth-val">
  93. <template v-for="(item , index) in bids">
  94. <view class="depth-item depth-item-right">
  95. <text class="depth-item-bg" :style="{'width': item[2] + '%' }"></text>
  96. <view class="depth-item-val">
  97. <text class="item-val-price">{{ item[0] }}</text>
  98. <text>{{ item[1] }}</text>
  99. </view>
  100. </view>
  101. </template>
  102. </view>
  103. </view>
  104. </u-list>
  105. </swiper-item>
  106. <swiper-item>
  107. <view class="val-content-list">
  108. <text>时间</text>
  109. <text>价格(USDT)</text>
  110. <text>数量(张)</text>
  111. </view>
  112. <u-list class="swiper-list" :style="{'height': scrollRightHeight ? `${scrollRightHeight}px` : '' }">
  113. <empty />
  114. </u-list>
  115. </swiper-item>
  116. </swiper>
  117. </view>
  118. <view class="details-footer">
  119. <view class="footer-btn" @click.stop="consumeBtn">买入/做多</view>
  120. <view class="footer-btn" @click.stop="consumeBtn">卖出/做空</view>
  121. </view>
  122. </view>
  123. </template>
  124. <script>
  125. import {
  126. mapGetters
  127. } from 'vuex'
  128. import { startSocket , closeSocket} 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({type: 'market_depth'});
  172. startSocket({type: 'daymarket'});
  173. },
  174. consumeBtn(){
  175. const pages = getCurrentPages();
  176. console.log('pages = ' , pages)
  177. if (pages.length >= 2 && pages[pages.length - 2].route === 'pages/contract/index') {
  178. uni.navigateBack({
  179. delta:1
  180. });
  181. } else {
  182. uni.reLaunch({
  183. url:'/pages/contract/index'
  184. })
  185. }
  186. }
  187. }
  188. }
  189. </script>
  190. <style lang="scss" scoped>
  191. .details-nav {
  192. display: flex;
  193. align-items: center;
  194. border-left: 1rpx solid $border-color4;
  195. padding-left: 20rpx;
  196. .nav-name {
  197. padding-left: 10rpx;
  198. font-size: 38rpx;
  199. font-weight: bold;
  200. }
  201. }
  202. .title-iocn {
  203. width: 28rpx;
  204. height: 24rpx;
  205. display: flex;
  206. flex-direction: column;
  207. // align-items: center;
  208. justify-content: space-between;
  209. .title-iocn-item {
  210. width: 100%;
  211. height: 4rpx;
  212. border-radius: 2rpx;
  213. background: #111111;
  214. &:first-child {
  215. width: 50%;
  216. }
  217. }
  218. }
  219. // <view class="top-index fixed-top-index" :style="{'top': navBarHeight + 'px'}">
  220. // <view :class="['index-val' , $setColor(27)]">
  221. // <text class="index-val-num color">27</text>
  222. // <text class="index-val-percent color">0.29%</text>
  223. // </view>
  224. // <view class="index-type">
  225. // 标记价格 <text class="iconfont">&#xeb6d;</text>
  226. // </view>
  227. // </view>
  228. .top-index {
  229. width: 100%;
  230. height: 94rpx;
  231. padding: 16rpx $pages-padding;
  232. border-bottom: 1rpx solid $border-color;
  233. display: flex;
  234. justify-content: space-between;
  235. background-color: #fff;
  236. .index-val-num {
  237. font-size: 30rpx;
  238. font-weight: bold;
  239. }
  240. .index-val-percent{
  241. font-size: 24rpx;
  242. padding-left: 10rpx;
  243. }
  244. .index-type{
  245. width: 240rpx;
  246. height: 100%;
  247. border: 1rpx solid $border-color6;
  248. display: flex;
  249. justify-content: space-between;
  250. align-items: center;
  251. font-size: 24rpx;
  252. padding: 0 20rpx;
  253. border-radius: 10rpx;
  254. .iconfont{
  255. font-size: 20rpx;
  256. color: $Theme-Color;
  257. }
  258. }
  259. }
  260. .fixed-top-index {
  261. position: fixed;
  262. z-index: 1;
  263. left: 0;
  264. }
  265. .iframe-content {
  266. width: 100%;
  267. height: 660rpx;
  268. iframe {
  269. width: 100%;
  270. height: 100%;
  271. }
  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>