| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- // 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
- },
- arrow: {
- type: Boolean,
- value: true
- }
- },
- 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'
- }
- })
|