| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- // components/localPicker/localPicker.js
- import {
- postApi
- } from "../../apis/api"
- Component({
- properties: {
- url: {
- type: String
- },
- params: {
- type: Object
- },
- inputStyle: {
- type: String
- },
- disabled: {
- type: Boolean
- },
- value: {
- type: String || Number
- },
- label: {
- type: String
- },
- placeholder: {
- type: String
- },
- autoGet: {
- type: Boolean
- }
- },
- data: {
- arr: [],
- index: ''
- },
- lifetimes: {
- ready() {
- if (this.data.autoGet) {
- this._getList()
- }
- }
- },
- methods: {
- async _getList(params) {
- let res = await postApi(this.data.url, {
- ...this.data.params,
- ...params,
- term: this.data.label
- })
- this.setData({
- arr: res.data.result,
- label: ''
- })
- },
- _selectItem(e) {
- let index = e.detail.value
- let {
- value: label,
- key: value
- } = this.data.arr[index]
- this.setData({
- label,
- value,
- index,
- })
- this.triggerEvent('selectItem', {
- label,
- value
- })
- },
- _handlerOne() {
- this.setData({
- arr: [],
- visable: true
- })
- },
- },
- options: {
- styleIsolation: 'isolated'
- }
- })
|