浏览代码

修复筛选

宇宙无敌M1处理器的MacBook Pro 4 年之前
父节点
当前提交
4ca2e8fdb2
共有 2 个文件被更改,包括 44 次插入25 次删除
  1. 42 22
      mini/pages/filter-data/index.js
  2. 2 3
      mini/pages/filter-data/index.wxml

+ 42 - 22
mini/pages/filter-data/index.js

xqd xqd xqd xqd xqd xqd xqd xqd
@@ -24,22 +24,22 @@ Page({
    * 生命周期函数--监听页面加载
    */
   onLoad: function (options) {
-    
+
   },
 
-  onChange: function(e) {
+  onChange: function (e) {
     var name = e.currentTarget.dataset.name
     this.setData({
       [name]: e.detail
     })
-    if(['device_id', 'device_name_id'].indexOf(name) != -1) {
-      if(name == 'device_id') {
+    if (['device_id', 'device_name_id'].indexOf(name) != -1) {
+      if (name == 'device_id') {
         this.setData({
           device_name_id: '',
           spec_id: ''
         })
       }
-      if(name == 'device_name_id') {
+      if (name == 'device_name_id') {
         this.setData({
           spec_id: ''
         })
@@ -48,7 +48,7 @@ Page({
     }
   },
 
-  confirm: function() {
+  confirm: function () {
     this.saveFilter()
     wx.navigateBack()
   },
@@ -60,21 +60,21 @@ Page({
 
   },
 
-  delete: function(e) {
+  delete: function (e) {
     var name = e.currentTarget.dataset.name
     var index = e.currentTarget.dataset.index
     var items = this.data[name]
-    if(index == 0) return false;
+    if (index == 0) return false;
     items.splice(index, 1)
     this.setData({
       [name]: items
     })
   },
 
-  add: function(e) {
+  add: function (e) {
     var name = e.currentTarget.dataset.name
     var items = this.data[name]
-    if(!items[items.length - 1]) {
+    if (!items[items.length - 1]) {
       util.error('请先选择');
       return false
     }
@@ -83,21 +83,25 @@ Page({
       [name]: items
     })
   },
-
-  onDropChange: function(e) {
+  onrentChange: function (e) {
+    this.setData({
+      rent_type_ids: [e.detail]
+    })
+    console.log(this.data.rent_type_ids)
+  },
+  onDropChange: function (e) {
     var index = e.currentTarget.dataset.index
     var name = e.currentTarget.dataset.name
     var val = e.detail
     var items = this.data[name]
     items[index] = val
-    console.log(items)
     this.setData({
       [name]: items
     })
-    if(name == 'device_ids') {
+    if (name == 'device_ids') {
       this.updateDeviceNames()
     }
-    if(name == 'device_name_ids') {
+    if (name == 'device_name_ids') {
       this.updateSpecs()
     }
   },
@@ -107,7 +111,10 @@ Page({
     that.setData({
       device_name_ids: ['']
     })
-    api.getByName(this, 'device-names/get', 'names', {type: 'drop_menu', device_ids: this.data.device_ids}, function() {
+    api.getByName(this, 'device-names/get', 'names', {
+      type: 'drop_menu',
+      device_ids: this.data.device_ids
+    }, function () {
       that.updateSpecs();
     });
   },
@@ -117,7 +124,10 @@ Page({
     that.setData({
       spec_ids: ['']
     })
-    api.getByName(this, 'specs/get', 'specs', {type: 'drop_menu', device_name_ids: this.data.device_name_ids});
+    api.getByName(this, 'specs/get', 'specs', {
+      type: 'drop_menu',
+      device_name_ids: this.data.device_name_ids
+    });
   },
 
   /**
@@ -126,10 +136,20 @@ Page({
   onShow: function () {
     var data = wx.getStorageSync('sg-data-filters')
     this.setData(data)
-    api.getByName(this, 'devices/get', 'devices', {type: 'drop_menu'});
-    api.getByName(this, 'device-names/get', 'names', {type: 'drop_menu', device_ids: this.data.device_ids});
-    api.getByName(this, 'specs/get', 'specs', {type: 'drop_menu', device_name_ids: this.data.device_name_ids});
-    api.getByName(this, 'rent-types/get', 'rent_types', {type: 'drop_menu'});
+    api.getByName(this, 'devices/get', 'devices', {
+      type: 'drop_menu'
+    });
+    api.getByName(this, 'device-names/get', 'names', {
+      type: 'drop_menu',
+      device_ids: this.data.device_ids
+    });
+    api.getByName(this, 'specs/get', 'specs', {
+      type: 'drop_menu',
+      device_name_ids: this.data.device_name_ids
+    });
+    api.getByName(this, 'rent-types/get', 'rent_types', {
+      type: 'drop_menu'
+    });
   },
 
   /**
@@ -171,7 +191,7 @@ Page({
    * 页面上拉触底事件的处理函数
    */
   onReachBottom: function () {
-    
+
   },
 
   /**

+ 2 - 3
mini/pages/filter-data/index.wxml

xqd
@@ -72,10 +72,9 @@
         <view class="sg-list sg-pad sg-light-gray-bg">
           <view class="sg-bold sg-text-center sg-center sg-margin-tb">- 请选择特殊条件 - </view>
           <view>
-            <view wx:for="{{spec_ids}}" wx:key="index" class="sg-flex sg-align-center">
+            <view class="sg-flex sg-align-center">
               <van-dropdown-menu class="sg-flex-grow sg-margin-tb-sm sg-margin-right" active-color="#1989fa">
-                <van-dropdown-item value="{{ item }}" options="{{ rent_types }}" bind:change="onDropChange"
-                  data-name="spec_ids" data-index="{{index}}" />
+                <van-dropdown-item value="{{ }}" options="{{ rent_types }}" bind:change="onrentChange"/>
               </van-dropdown-menu>
               <!-- <van-button icon="cross" type="danger" bindtap="delete"
                 data-name="spec_ids" data-index="{{index}}"></van-button> -->