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