npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@retailwe/ui-area-picker

v0.0.18

Published

## 引入

Downloads

16

Readme

级联选择

引入

全局引入,在 miniprogram 根目录下的app.json中配置,局部引入,在需要引入的页面或组件的index.json中配置。

// app.json 或 index.json
"usingComponents": {
  "wr-area-picker": "@retailwe/ui-area-picker/index"
}

代码演示

基本用法

两级联动

<wr-cell title="省市两级联动" is-link bindclick="onTap" data-type="1"></wr-cell>
<wr-area-picker
  show="{{visible1}}"
  area-data="{{areaData}}"
  title="选择地区"
  value="{{value}}"
  columns="{{columns}}"
  bindconfirm="onConfirm"
  data-type="1"
/>

三级联动

<wr-cell
  title="省市区三级联动"
  is-link
  bindclick="onTap"
  data-type="2"
></wr-cell>
<wr-area-picker
  show="{{visible1}}"
  area-data="{{areaData}}"
  title="选择地区"
  value="{{value}}"
  columns="{{columns}}"
  bindconfirm="onConfirm"
  data-type="1"
/>
Page({
  data: {
    show: false,
    columns: 3,
    areaData: [
      {
        name: '北京市',
        code: '110000',
        children: [
          {
            name: '北京市',
            code: '110100',
            children: [
              {
                name: '东城区',
                code: '110101',
                children: null,
              },
              {
                name: '西城区',
                code: '110102',
                children: null,
              },
              {
                name: '朝阳区',
                code: '110105',
                children: null,
              },
              {
                name: '丰台区',
                code: '110106',
                children: null,
              },
              {
                name: '石景山区',
                code: '110107',
                children: null,
              },
              {
                name: '海淀区',
                code: '110108',
                children: null,
              },
              {
                name: '门头沟区',
                code: '110109',
                children: null,
              },
              {
                name: '房山区',
                code: '110111',
                children: null,
              },
              {
                name: '通州区',
                code: '110112',
                children: null,
              },
              {
                name: '顺义区',
                code: '110113',
                children: null,
              },
              {
                name: '昌平区',
                code: '110114',
                children: null,
              },
              {
                name: '大兴区',
                code: '110115',
                children: null,
              },
              {
                name: '怀柔区',
                code: '110116',
                children: null,
              },
              {
                name: '平谷区',
                code: '110117',
                children: null,
              },
              {
                name: '密云区',
                code: '110118',
                children: null,
              },
              {
                name: '延庆区',
                code: '110119',
                children: null,
              },
            ],
          },
        ],
      },
      {
        name: '天津市',
        code: '120000',
        children: [
          {
            name: '天津市',
            code: '120100',
            children: [
              {
                name: '和平区',
                code: '120101',
                children: null,
              },
              {
                name: '河东区',
                code: '120102',
                children: null,
              },
              {
                name: '河西区',
                code: '120103',
                children: null,
              },
              {
                name: '南开区',
                code: '120104',
                children: null,
              },
              {
                name: '河北区',
                code: '120105',
                children: null,
              },
              {
                name: '红桥区',
                code: '120106',
                children: null,
              },
              {
                name: '东丽区',
                code: '120110',
                children: null,
              },
              {
                name: '西青区',
                code: '120111',
                children: null,
              },
              {
                name: '津南区',
                code: '120112',
                children: null,
              },
              {
                name: '北辰区',
                code: '120113',
                children: null,
              },
              {
                name: '武清区',
                code: '120114',
                children: null,
              },
              {
                name: '宝坻区',
                code: '120115',
                children: null,
              },
              {
                name: '滨海新区',
                code: '120116',
                children: null,
              },
              {
                name: '宁河区',
                code: '120117',
                children: null,
              },
              {
                name: '静海区',
                code: '120118',
                children: null,
              },
              {
                name: '蓟州区',
                code: '120119',
                children: null,
              },
            ],
          },
        ],
      },
    ],
  },
  onTap(e: any) {
    const { type } = e.currentTarget.dataset;
    if (type == 1) {
      this.setData({
        visible1: true,
        columns: 2,
      });
    }
    if (type == 2) {
      this.setData({
        visible1: true,
        columns: 3,
      });
    }
  },
  onConfirm(e: any) {
    const { type } = e.currentTarget.dataset;
    if (type == 1) {
      this.setData({
        visible1: false,
      });
    }
    if (type == 2) {
      this.setData({
        visible1: false,
      });
    }
  },
});

area-picker Props

| 参数 | 说明 | 类型 | 默认值 | 版本 | | --------- | ---------------- | --------- | ---------- | ---- | | columns | 省市区展示列数 | number | 3 | - | | show | 弹窗显示 | boolean | false | - | | area-data | 数据源 | array | - | - | | title | 弹窗标题 | string |- | - | | value | 当前选中的省市区 | string |- | - |

area-data Props

| 参数 | 说明 | 类型 | 默认值 | 版本 | | --------- | ---------------- | --------- | ---------- | ---- | | name | 地域名 | string | - | - | | code | code码| string | - | - | | children | 下级数据 | array | - | - |

area-picker Event

| 事件名 | 说明 | 参数 | | ---------- | ---- | ---- | | pullchildren | 通知父组件/页面拉取数据 | parentCode: 可选参数,通知拉取该省份代码的下级行政区数据,为空则是通知拉取省级行政区 | | pullchildren | 通知父组件/页面拉取数据 | parentCode: 可选参数,通知拉取该省份代码的下级行政区数据,为空则是通知拉取省级行政区 | | change | 用户操作控件时触发 | value: 当前选取的该级行政区代码,areas:当前选择各级行政区组成的数组 | | confirm | 用户操作控件时触发 | value: 当前选取的该级行政区代码,areas:当前选择各级行政区组成的数组 | | close | 用户主动关闭弹框时触发 | - |