Преглед изворни кода

持仓分析过滤显示历史合约信息

jwyu пре 2 година
родитељ
комит
aef44b4af0
3 измењених фајлова са 53 додато и 3 уклоњено
  1. 2 1
      pages.json
  2. 48 2
      pages/positionAnalysis/components/indexContent.vue
  3. 3 0
      pages/positionAnalysis/index.vue

+ 2 - 1
pages.json

@@ -478,7 +478,8 @@
 			"van-cell": "/wxcomponents/vant/cell/index",
 			"van-tree-select": "/wxcomponents/vant/tree-select/index",
 			"van-datetime-picker": "/wxcomponents/vant/datetime-picker/index",
-			"van-swipe-cell": "/wxcomponents/vant/swipe-cell/index"
+			"van-swipe-cell": "/wxcomponents/vant/swipe-cell/index",
+			"van-switch": "/wxcomponents/vant/switch/index"
 		}
 	}
 }

+ 48 - 2
pages/positionAnalysis/components/indexContent.vue

@@ -4,8 +4,13 @@
             <text style="margin-right:20rpx">{{num}}品种</text>
             <text>{{time}}</text>
         </view>
+        <view style="display: flex;align-items:center;padding:40rpx 34rpx">
+            <van-switch active-color="#E3B377" size="20px" :checked="isHistory" @change="onChange" />
+            <text style="margin:-8rpx 0 0 10rpx">历史合约</text>
+        </view>
+          
         <view class="list-wrap">
-            <view class="flex item" v-for="item in list" :key="item.classify_name">
+            <view class="flex item" v-for="item in clist" :key="item.classify_name">
                 <view class="label">{{item.classify_name}}</view>
                 <view style="flex:1">
                     <view 
@@ -17,7 +22,7 @@
                 </view>
             </view>
         </view>
-        <view class="empty-box" v-if="!list||list.length===0">
+        <view class="empty-box" v-if="!clist||clist.length===0">
             <image
                 :src="globalImgUrls.chartEmpty"
                 mode="widthFix"
@@ -47,7 +52,48 @@ export default {
             default:''
         }
     },
+    computed:{
+        clist(){
+            if(this.isHistory){
+                console.log('看历史');
+                return this.list
+            }
+
+            const now=dayjs().format('YYMM')//当前时间
+            const arr=this.list?JSON.parse(JSON.stringify(this.list)):[]
+            let resArr=[]
+            if(this.exchange!='郑商所'){
+                resArr=arr.map(item=>{
+                    item.items=item.items.filter(_item=>{
+                        const t=_item.classify_type.substr(-4)
+                        return Number(t)>=now
+                    })
+                    return item
+                })
+            }else{
+                resArr=arr.map(item=>{
+                    item.items=item.items.filter(_item=>{
+                        // 如果合约编号没有含日期 肯定是少于4位的 因为至少为一个字母加三位数的日期
+                        if(_item.classify_type.length<4) return true
+                        const t=2+_item.classify_type.substr(-3)
+                        return Number(t)>=now
+                    })
+                    return item
+                })
+            }
+            return resArr
+        }
+    },
+    data() {
+        return {
+            isHistory:false
+        }
+    },
     methods: {
+        onChange(e){
+            console.log(e);
+            this.isHistory=e.detail
+        },
         goDetail(_item,item){
             const queryObj={
                 classify_name:item.classify_name,

+ 3 - 0
pages/positionAnalysis/index.vue

@@ -76,6 +76,9 @@ page{
     padding-bottom: constant(safe-area-inset-bottom);
     padding-bottom: env(safe-area-inset-bottom);
 }
+.van-sticky{
+    z-index: 9999 !important;
+}
 .van-sticky-wrap--fixed{
     box-shadow: 0px 4px 4px rgba(198, 198, 198, 0.25);
 }