drawer.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  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" v-model="searchName" 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 v-if="setName(item)" :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. <template v-for="(item , index) in marketAll" >
  59. <uni-tr v-if="setName(item)" :class="[$setColor(item.change)]" @clicktr="setCurrency(item)">
  60. <uni-td>
  61. <view class="name">
  62. <text class="name-text">{{ item.currency_name }}</text>
  63. <text class="name-tag">{{ item.legal_name ? `/${item.legal_name}` : '' }}</text>
  64. </view>
  65. </uni-td>
  66. <uni-td align="right">{{ item.now_price }}</uni-td>
  67. <uni-td class="color">{{ item.change }}%</uni-td>
  68. </uni-tr>
  69. </template>
  70. </uni-table>
  71. </u-list>
  72. </swiper-item>
  73. </swiper>
  74. </view>
  75. </view>
  76. </uni-popup>
  77. </template>
  78. <script>
  79. import {
  80. mapGetters
  81. } from 'vuex'
  82. import { Api_getQuotationNew } from "@/api/index.js"
  83. export default {
  84. data() {
  85. return {
  86. tabIndex:0,
  87. scrollHeight:0,
  88. searchName:''
  89. };
  90. },
  91. computed: {
  92. // maxPageHeight: state => state.app.maxPageHeight,
  93. // tabBarHeight: state => state.app.tabBarHeight,
  94. ...mapGetters([
  95. 'tabBarHeight',
  96. 'maxPageHeight',
  97. 'statusBarHeight',
  98. 'stocksColor',
  99. 'optional',
  100. 'marketAll'
  101. ]),
  102. },
  103. watch:{
  104. maxPageHeight:{
  105. handler(newH){
  106. this.scrollHeight = this.maxPageHeight - this.tabBarHeight - this.statusBarHeight - uni.upx2px(200)
  107. },
  108. immediate:true
  109. },
  110. },
  111. created() {
  112. },
  113. mounted() {
  114. // this.$refs.popupRef.open()
  115. },
  116. methods: {
  117. setName(item){
  118. console.log()
  119. if(this.searchName){
  120. if( item.currency_name.indexOf(this.searchName) >= 0 ){
  121. return true
  122. }
  123. return false
  124. }
  125. return true
  126. },
  127. aaa(item){
  128. console.log('--22-' , item)
  129. },
  130. setCurrency(item){
  131. console.log('--211-' , item)
  132. this.$store.commit('websocket/set_currency_val' , item)
  133. this.close()
  134. },
  135. close() {
  136. this.$refs.popupRef.close();
  137. },
  138. open() {
  139. this.$nextTick(() => {
  140. this.$refs.popupRef.open();
  141. })
  142. }
  143. }
  144. }
  145. </script>
  146. <style lang="scss" scoped>
  147. .drawer-box {
  148. width: 75vw;
  149. height: 100vh;
  150. display: flex;
  151. flex-direction: column;
  152. .drawer-content {
  153. flex: 1;
  154. width: 100%;
  155. background-color: #fff;
  156. .drawer-search {
  157. padding: 20rpx $pages-padding 0;
  158. .drawer-search-inp {
  159. width: 100%;
  160. height: 70rpx;
  161. background-color: #ccc;
  162. border-radius: 35rpx;
  163. display: flex;
  164. align-items: center;
  165. padding: 0 20rpx;
  166. font-size: 28rpx;
  167. color: #1a1a1a;
  168. .search-place {
  169. font-size: 28rpx;
  170. color: #1a1a1a;
  171. }
  172. }
  173. }
  174. .drawer-tab {
  175. padding: 0 6rpx 0 $pages-padding;
  176. width: 100%;
  177. height: 90rpx;
  178. border-bottom: 1rpx solid #f2f2f2;
  179. display: flex;
  180. justify-content: space-between;
  181. align-items: center;
  182. .tab-box {
  183. display: flex;
  184. align-items: stretch;
  185. height: 100%;
  186. .tab-item {
  187. margin-right: 40rpx;
  188. font-size: 26rpx;
  189. font-family: PingFang SC, PingFang SC-Bold;
  190. font-weight: 700;
  191. color: #808080;
  192. height: 100%;
  193. line-height: 90rpx;
  194. }
  195. .active-tab-item {
  196. position: relative;
  197. font-weight: 600;
  198. color: #20b482;
  199. &::before {
  200. content: '';
  201. position: absolute;
  202. left: 50%;
  203. bottom: 0;
  204. width: 80%;
  205. height: 2px;
  206. border-radius: 1px;
  207. background-color: #20b482;
  208. transform: translateX(-50%);
  209. }
  210. }
  211. }
  212. }
  213. .swiper-content,.swiper-item-box{
  214. width: 100%;
  215. }
  216. .table-box {
  217. width: 100%;
  218. .uni-table-tr {
  219. .uni-table-th {
  220. font-size: 24rpx;
  221. font-weight: 400;
  222. border-bottom: none;
  223. }
  224. .uni-table-td {
  225. font-size: 26rpx;
  226. font-family: PingFang SC, PingFang SC-Bold;
  227. font-weight: 800;
  228. color: #1a1a1a;
  229. .name {
  230. .name-text {}
  231. .name-tag {
  232. font-size: 22rpx;
  233. font-weight: 300;
  234. }
  235. }
  236. &:nth-child(3n - 1) {}
  237. &:nth-child(3n) {
  238. color: #20b482;
  239. }
  240. }
  241. .uni-table-th,
  242. .uni-table-td {
  243. flex-shrink: 0;
  244. &:nth-child(3n - 2) {
  245. flex: 6;
  246. padding-left: $pages-padding;
  247. }
  248. &:nth-child(3n - 1) {
  249. flex: 2;
  250. text-align: right !important;
  251. }
  252. &:nth-child(3n) {
  253. flex: 2;
  254. padding-right: $pages-padding;
  255. text-align: right !important;
  256. }
  257. }
  258. }
  259. }
  260. }
  261. }
  262. .swiper-content{
  263. // background-color: red;
  264. }
  265. </style>