| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- // components/newPicker/newPicker.js
- import {
- postApi
- } from "../../apis/api"
- import {
- debounce
- } from "../../utils/utils"
- Component({
- properties: {
- url: {
- type: String
- },
- params: {
- type: Object
- },
- inputStyle: {
- type: String
- },
- disabled: {
- type: Boolean
- },
- value: {
- type: String || Number
- },
- label: {
- type: String
- },
- placeholder: {
- type: String
- },
- },
- data: {
- arr: [],
- visable: false,
- isLoading: false,
- isInit: true,
- index: -1
- },
- methods: {
- _getList: debounce(async function (e) {
- this.setData({
- isInit: false
- })
- let res = await postApi(this.data.url, {
- ...this.data.params,
- term: e.detail.value
- })
- this.setData({
- arr: res.data.result
- })
- }, 600),
- _selectItem(e) {
- let {
- label,
- value
- } = e.currentTarget.dataset
- this.triggerEvent('selectItem', {
- label,
- value,
- })
- this.setData({
- label: '',
- })
- this.cancel()
- },
- showModal() {
- this.setData({
- visable: true,
- })
- },
- cancel() {
- this.setData({
- visable: false,
- isInit: true,
- arr: [],
- index: -1
- })
- }
- },
- options: {
- styleIsolation: 'isolated'
- }
- })
|