wxml文件
在上面的一个按钮里面设置点击事件
<van-popup show="{{concreteProductsStatus}}" position="bottom" custom-style="height: 40%;" bind:close="onClose" z-index="9999">
<van-picker show-toolbar columns="{{concreteOptions}}" value-key="label" bind:cancel="onCancel" bind:confirm="confirmConcreteProduct"/>
</van-popup>
在app.json或index.json中引入组件,详细介绍见快速上手。
"usingComponents": {
"van-picker": "@vant/weapp/picker/index"
}
js代码
对应的变量存储在data里面的
async chooseConcreteProducts() {
if (this.data.param.salesContractId == “”) {
wx.showToast({
title: ‘请先选择销售合同’,
icon: ‘none’
})
return
}
let data = await getSalesContractPricing(this.data.Authorization, this.data.param.salesContractId);
let concreteOptionsData = []
for (let i = 0; i < data.length; i++) {
let item = {
label: “”,
value: “”
}
console.log(data[i])
item.label = data[i].productName+“(”+“参考价:”+data[i].price+“)”
item.value = data[i]
concreteOptionsData.push(item)
}
this.setData({
concreteOptions: concreteOptionsData,
concreteProductsStatus:true
})
console.log(this.data.concreteOptions)
}
confirmConcreteProduct(e){
console.log(e, 3333)
let value = e.detail.value.value
}