| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- // components/remotePicker/remotePicker.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
- },
- },
- data: {
- arr: [],
- },
- methods: {
- async _getList() {
- let res = await postApi(this.data.url, {
- ...this.data.params,
- term: this.data.label
- })
- this.setData({
- arr: res.data.result,
- label: ''
- })
- },
- _selectItem(e) {
- let {
- label,
- value
- } = e.currentTarget.dataset
- this.setData({
- label,
- value,
- arr: []
- })
- this.triggerEvent('selectItem', {
- label,
- value
- })
- },
- _handlerOne() {
- this.setData({
- arr: []
- })
- },
- },
- options: {
- styleIsolation: 'isolated'
- }
- })
|