怎么修改和联动
发布于 6 年前 作者 panxiulan 19334 次浏览 来自 问答

const app = getApp()

var multiArray0 =[‘浦东新区’];

var multiArray1 = [];

var multiArray2 = [];

var that;

var URL =  https://www.shmxet.cn/fire/dict/address/jdmc/?xzqy=浦东新区;

var URL1 = https://www.shmxet.cn/fire/dict/address/jwmc/?xzqy=浦东新区&jdmc=北蔡镇;//这是自己写的北蔡镇,

Page({

data: {

multiArray: [multiArray0, , ],

multiIndex: [0, 0, 0],

},

onLoad:function(){

this.getjd();

this.getjw();

},

getjd:function(){

that = this;

wx.request({

url: URL, //接口地址

header: {

‘content-type’: ‘application/json’ // 默认值

},

success: function (res) {

var log = res.data.result.data;

//console.log(log);

multiArray1 = [];

for(var i = 0; i<log.length;i++){

multiArray1.push(log[i].label)

}

that.setData({

multiArray: [multiArray0,multiArray1,0]

})

}

})

},

getjw:function(jdmc){

that = this;

wx.request({

url: URL1, //接口地址

header: {

‘content-type’: ‘application/json’ // 默认值

},

success: function (res) {

var log = res.data.result.data;

console.log(log);

multiArray2 = [];

for (var i = 0; i < log.length; i++) {

multiArray2.push(log[i].label)

}

that.setData({

multiArray: [multiArray0, multiArray1, multiArray2]

})

}

})

},

bindMultiPickerChange: function (e) {

console.log(‘picker发送选择改变,携带值为’, e.detail.value)

this.setData({

multiIndex: e.detail.value

})

},

bindMultiPickerColumnChange: function (e) {

console.log(‘修改的列为’, e.detail.column, ‘,值为’, e.detail.value);

var data = {

multiArray: this.data.multiArray,

multiIndex: this.data.multiIndex

};

data.multiIndex[e.detail.column] = e.detail.value;

switch (e.detail.column) {

case 0:

switch (data.multiIndex[0]) {

case 0:

data.multiArray[1] = multiArray1;

data.multiArray[2] = multiArray2

}

data.multiIndex[1] = 0;

data.multiIndex[2] = 0;

break;

case 1:

switch (data.multiIndex[0]) {

case 0:

switch (data.multiIndex[1]) {

case 0:

data.multiArray[2] = multiArray2;

break;

}

break;

}

data.multiIndex[2] = 0;

console.log(data.multiIndex);

break;

}

this.setData(data);

},

})

怎么可以让地址进行联动切换?

回到顶部