drawer.vue 7.1 KB

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