Browse Source

最新最热开关

zhaoxiaohai 3 years ago
parent
commit
e2d072301e
1 changed files with 14 additions and 1 deletions
  1. 14 1
      components/My_switch/index.js

+ 14 - 1
components/My_switch/index.js

@@ -10,6 +10,13 @@ Component({
         },
         },
         change: {
         change: {
             type: Function
             type: Function
+        },
+        sort: {
+            type: Array
+        },
+        reversed: {
+            type: Number,
+            value: 0
         }
         }
     },
     },
     lifetimes: {
     lifetimes: {
@@ -43,7 +50,13 @@ Component({
             this.setData({
             this.setData({
                 checkedItem: this.data.checkedItem == 0 ? 1 : 0
                 checkedItem: this.data.checkedItem == 0 ? 1 : 0
             })
             })
-            this.triggerEvent('change', this.data.list[this.data.checkedItem])
+            let name = this.data.list[this.data.checkedItem],
+                sort = this.data.sort;
+            for (let i = 0; i < sort.length; i++) {
+                sort[i].sorted = sort[i].sortname == name ? 1 : 0;
+                sort[i].reversed = this.data.reversed
+            }
+            this.triggerEvent('change', sort)
             this.chengeSelect()
             this.chengeSelect()
         },
         },
         chengeSelect() {
         chengeSelect() {