| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- // 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
- },
- spTop: {
- type: String
- },
- spHeight: {
- type: String,
- value: "0rpx"
- },
- 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'
- }
- })
|