drawer.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. <template>
  2. <uni-popup ref="popupRef" type="left">
  3. <view class="drawer-box" :rise-fall="stocksColor">
  4. <view :style="{'width': '100%', 'height': `${statusBarHeight}px`}"></view>
  5. <view class="drawer-content">
  6. <view class="drawer-search">
  7. <view class="drawer-search-inp">
  8. <u-icon name="search" class="search-icon" color="#666" size="40"></u-icon>
  9. <input class="search-inp" placeholder-class="search-place" type="text" placeholder="搜索">
  10. </view>
  11. </view>
  12. <view class="drawer-tab">
  13. <view class="tab-box">
  14. <view @click.stop="tabIndex = 0 " :class="['tab-item' , tabIndex === 0 ? 'active-tab-item' : '']">
  15. 自选
  16. </view>
  17. <view @click.stop="tabIndex = 1 " :class="['tab-item' , tabIndex === 1 ? 'active-tab-item' : '']">
  18. 市场
  19. </view>
  20. </view>
  21. <!-- <u-icon name="edit-pen" class="search-icon" color="#666" size="24"></u-icon> -->
  22. </view>
  23. <swiper class="swiper-content" :current="tabIndex"
  24. :style="{'height': scrollHeight ? `${scrollHeight}px` : '' }">
  25. <swiper-item class="swiper-item-box" >
  26. <uni-table class="table-box" emptyText="暂无更多数据" @selection-change="aaa">
  27. <!-- 表头行 -->
  28. <uni-tr>
  29. <uni-th>交易对</uni-th>
  30. <uni-th align="right">最新价</uni-th>
  31. <uni-th sortable align="right">日涨跌</uni-th>
  32. </uni-tr>
  33. <!-- 表格数据行 @click="setCurrency(item)" @row-click="rowclick(item)"-->
  34. <template v-for="(item , index) in optional" >
  35. <uni-tr :class="[$setColor(item.change)]" @clicktr="setCurrency(item)">
  36. <uni-td>
  37. <view class="name">
  38. <text class="name-text">{{ item.currency_name }}</text>
  39. <text class="name-tag">{{ item.legal_name ? `/${item.legal_name}` : '' }}</text>
  40. </view>
  41. </uni-td>
  42. <uni-td align="right">{{ item.now_price }}</uni-td>
  43. <uni-td class="color">{{ item.change }}%</uni-td>
  44. </uni-tr>
  45. </template>
  46. </uni-table>
  47. </swiper-item>
  48. <swiper-item>
  49. <u-list class="swiper-list" :style="{'height': scrollHeight ? `${scrollHeight}px` : '' }">
  50. <uni-table class="table-box" emptyText="暂无更多数据">
  51. <!-- 表头行 -->
  52. <uni-tr>
  53. <uni-th>交易对</uni-th>
  54. <uni-th align="right">最新价</uni-th>
  55. <uni-th align="right">日涨跌</uni-th>
  56. </uni-tr>
  57. <!-- 表格数据行 -->
  58. <uni-tr v-for="(item , index) in marketAll" :class="[$setColor(item.change)]" :key="`all_${index}`" @click.stop="setCurrency(item)">
  59. <uni-td>
  60. <view class="name">
  61. <text class="name-text">{{ item.currency_name }}</text>
  62. <text class="name-tag">{{ item.legal_name ? `/${item.legal_name}` : '' }}</text>
  63. </view>
  64. </uni-td>
  65. <uni-td align="right">{{ item.now_price }}</uni-td>
  66. <uni-td class="color">{{ item.change }}%</uni-td>
  67. </uni-tr>
  68. </uni-table>
  69. </u-list>
  70. </swiper-item>
  71. </swiper>
  72. </view>
  73. </view>
  74. </uni-popup>
  75. </template>
  76. <script>
  77. import {
  78. mapGetters
  79. } from 'vuex'
  80. import { Api_getQuotationNew } from "@/api/index.js"
  81. export default {
  82. data() {
  83. return {
  84. tabIndex:0,
  85. scrollHeight:0,
  86. };
  87. },
  88. computed: {
  89. // maxPageHeight: state => state.app.maxPageHeight,
  90. // tabBarHeight: state => state.app.tabBarHeight,
  91. ...mapGetters([
  92. 'tabBarHeight',
  93. 'maxPageHeight',
  94. 'statusBarHeight',
  95. 'stocksColor',
  96. 'optional',
  97. 'marketAll'
  98. ]),
  99. },
  100. watch:{
  101. maxPageHeight:{
  102. handler(newH){
  103. this.scrollHeight = this.maxPageHeight - this.tabBarHeight - this.statusBarHeight - uni.upx2px(200)
  104. },
  105. immediate:true
  106. }
  107. },
  108. created() {
  109. this.$store.dispatch('websocket/getQuotationNew')
  110. },
  111. mounted() {
  112. // this.$refs.popupRef.open()
  113. },
  114. methods: {
  115. aaa(item){
  116. console.log('--22-' , item)
  117. },
  118. setCurrency(item){
  119. console.log('--211-' , item)
  120. this.$store.commit('websocket/set_currency_val' , item)
  121. this.close()
  122. },
  123. close() {
  124. this.$refs.popupRef.close();
  125. },
  126. open() {
  127. this.$nextTick(() => {
  128. this.$refs.popupRef.open();
  129. })
  130. }
  131. }
  132. }
  133. </script>
  134. <style lang="scss" scoped>
  135. .drawer-box {
  136. width: 75vw;
  137. height: 100vh;
  138. display: flex;
  139. flex-direction: column;
  140. .drawer-content {
  141. flex: 1;
  142. width: 100%;
  143. background-color: #fff;
  144. .drawer-search {
  145. padding: 20rpx $pages-padding 0;
  146. .drawer-search-inp {
  147. width: 100%;
  148. height: 70rpx;
  149. background-color: #ccc;
  150. border-radius: 35rpx;
  151. display: flex;
  152. align-items: center;
  153. padding: 0 20rpx;
  154. font-size: 28rpx;
  155. color: #1a1a1a;
  156. .search-place {
  157. font-size: 28rpx;
  158. color: #1a1a1a;
  159. }
  160. }
  161. }
  162. .drawer-tab {
  163. padding: 0 6rpx 0 $pages-padding;
  164. width: 100%;
  165. height: 90rpx;
  166. border-bottom: 1rpx solid #f2f2f2;
  167. display: flex;
  168. justify-content: space-between;
  169. align-items: center;
  170. .tab-box {
  171. display: flex;
  172. align-items: stretch;
  173. height: 100%;
  174. .tab-item {
  175. margin-right: 40rpx;
  176. font-size: 26rpx;
  177. font-family: PingFang SC, PingFang SC-Bold;
  178. font-weight: 700;
  179. color: #808080;
  180. height: 100%;
  181. line-height: 90rpx;
  182. }
  183. .active-tab-item {
  184. position: relative;
  185. font-weight: 600;
  186. color: #20b482;
  187. &::before {
  188. content: '';
  189. position: absolute;
  190. left: 50%;
  191. bottom: 0;
  192. width: 80%;
  193. height: 2px;
  194. border-radius: 1px;
  195. background-color: #20b482;
  196. transform: translateX(-50%);
  197. }
  198. }
  199. }
  200. }
  201. .swiper-content,.swiper-item-box{
  202. width: 100%;
  203. }
  204. .table-box {
  205. width: 100%;
  206. .uni-table-tr {
  207. .uni-table-th {
  208. font-size: 24rpx;
  209. font-weight: 400;
  210. border-bottom: none;
  211. }
  212. .uni-table-td {
  213. font-size: 26rpx;
  214. font-family: PingFang SC, PingFang SC-Bold;
  215. font-weight: 800;
  216. color: #1a1a1a;
  217. .name {
  218. .name-text {}
  219. .name-tag {
  220. font-size: 22rpx;
  221. font-weight: 300;
  222. }
  223. }
  224. &:nth-child(3n - 1) {}
  225. &:nth-child(3n) {
  226. color: #20b482;
  227. }
  228. }
  229. .uni-table-th,
  230. .uni-table-td {
  231. flex-shrink: 0;
  232. &:nth-child(3n - 2) {
  233. flex: 6;
  234. padding-left: $pages-padding;
  235. }
  236. &:nth-child(3n - 1) {
  237. flex: 2;
  238. text-align: right !important;
  239. }
  240. &:nth-child(3n) {
  241. flex: 2;
  242. padding-right: $pages-padding;
  243. text-align: right !important;
  244. }
  245. }
  246. }
  247. }
  248. }
  249. }
  250. .swiper-content{
  251. background-color: red;
  252. }
  253. </style>