drawer.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  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" 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. // noRefresh
  116. },
  117. methods: {
  118. setName(item){
  119. console.log(1 , item)
  120. if(this.searchName && item){
  121. if( item.currency_name.indexOf(this.searchName) >= 0 ){
  122. return true
  123. }
  124. return false
  125. }
  126. return true
  127. },
  128. aaa(item){
  129. console.log('--22-' , item)
  130. },
  131. setCurrency(item){
  132. this.$store.commit('websocket/set_currency_val' , item)
  133. this.close()
  134. },
  135. changePopup(obj){
  136. console.log('changePopup = ' , obj)
  137. if(obj.show){
  138. this.$store.dispatch('websocket/getQuotationNew')
  139. }else{
  140. this.$store.commit('websocket/set_currencySuspend' , false)
  141. }
  142. },
  143. close() {
  144. this.$refs.popupRef.close();
  145. },
  146. open() {
  147. this.$nextTick(() => {
  148. this.$refs.popupRef.open();
  149. })
  150. }
  151. }
  152. }
  153. </script>
  154. <style lang="scss" scoped>
  155. .drawer-box {
  156. width: 75vw;
  157. height: 100vh;
  158. display: flex;
  159. flex-direction: column;
  160. .drawer-content {
  161. flex: 1;
  162. width: 100%;
  163. background-color: #fff;
  164. .drawer-search {
  165. padding: 20rpx $pages-padding 0;
  166. .drawer-search-inp {
  167. width: 100%;
  168. height: 70rpx;
  169. background-color: #ccc;
  170. border-radius: 35rpx;
  171. display: flex;
  172. align-items: center;
  173. padding: 0 20rpx;
  174. font-size: 28rpx;
  175. color: #1a1a1a;
  176. .search-place {
  177. font-size: 28rpx;
  178. color: #1a1a1a;
  179. }
  180. }
  181. }
  182. .drawer-tab {
  183. padding: 0 6rpx 0 $pages-padding;
  184. width: 100%;
  185. height: 90rpx;
  186. border-bottom: 1rpx solid #f2f2f2;
  187. display: flex;
  188. justify-content: space-between;
  189. align-items: center;
  190. .tab-box {
  191. display: flex;
  192. align-items: stretch;
  193. height: 100%;
  194. .tab-item {
  195. margin-right: 40rpx;
  196. font-size: 26rpx;
  197. font-family: PingFang SC, PingFang SC-Bold;
  198. font-weight: 700;
  199. color: #808080;
  200. height: 100%;
  201. line-height: 90rpx;
  202. }
  203. .active-tab-item {
  204. position: relative;
  205. font-weight: 600;
  206. color: #20b482;
  207. &::before {
  208. content: '';
  209. position: absolute;
  210. left: 50%;
  211. bottom: 0;
  212. width: 80%;
  213. height: 2px;
  214. border-radius: 1px;
  215. background-color: #20b482;
  216. transform: translateX(-50%);
  217. }
  218. }
  219. }
  220. }
  221. .swiper-content,.swiper-item-box{
  222. width: 100%;
  223. }
  224. .table-box {
  225. width: 100%;
  226. .uni-table-tr {
  227. .uni-table-th {
  228. font-size: 24rpx;
  229. font-weight: 400;
  230. border-bottom: none;
  231. }
  232. .uni-table-td {
  233. font-size: 26rpx;
  234. font-family: PingFang SC, PingFang SC-Bold;
  235. font-weight: 800;
  236. color: #1a1a1a;
  237. .name {
  238. .name-text {}
  239. .name-tag {
  240. font-size: 22rpx;
  241. font-weight: 300;
  242. }
  243. }
  244. &:nth-child(3n - 1) {}
  245. &:nth-child(3n) {
  246. color: #20b482;
  247. }
  248. }
  249. .uni-table-th,
  250. .uni-table-td {
  251. flex-shrink: 0;
  252. &:nth-child(3n - 2) {
  253. flex: 6;
  254. padding-left: $pages-padding;
  255. }
  256. &:nth-child(3n - 1) {
  257. flex: 2;
  258. text-align: right !important;
  259. }
  260. &:nth-child(3n) {
  261. flex: 2;
  262. padding-right: $pages-padding;
  263. text-align: right !important;
  264. }
  265. }
  266. }
  267. }
  268. }
  269. }
  270. .swiper-content{
  271. // background-color: red;
  272. }
  273. </style>