1.0.1 • Published 9 months ago

@ray-js/ty-outdoor-utils v1.0.1

Weekly downloads
-
License
MIT
Repository
-
Last release
9 months ago

English | 简体中文

@ray-js/ty-outdoor-utils

latest download

Outdoor Utils

Installation

Note: DeviceKit needs to be introduced when using the travel secondary page jump, and it must be in version >=1.2.6

$ npm install @ray-js/ty-outdoor-utils
# or
$ yarn add @ray-js/ty-outdoor-utils

Develop

# watch compile component code
yarn watch
# watch compile demo
yarn start:tuya

Usage

import OutdoorUtils from '@ray-js/ty-outdoor-utils';

const { hooks } = OutdoorUtils;
const { usePayUrls } = hooks;

export default function Home() {
  const [qrcode, setQrcode] = useState('');
  const { returnUrl } = usePayUrls();
  const makeQrcode = () => {
    const img = OutdoorUtils.QRcode.make('hello world!');
    setQrcode(img);
  };

  const openSubPage = () => {
    OutdoorUtils.jumpSubPage.toCyclingRecord({
      deviceId: 'devId',
      fail: e => console.log('err', e),
    });
  };
  return (
    <View className={styles.view}>
      <Button onClick={makeQrcode}>生成二维码</Button>
      <Button onClick={openSubPage}>跳转出行二级页</Button>
      {qrcode && (
        <View className={styles.center}>
          <Image src={qrcode} />
        </View>
      )}

      <Button onClick={() => console.log('returnUrl', returnUrl)}>获取收银台地址</Button>
      <Button
        onClick={() =>
          console.log(
            OutdoorUtils.pageParameters.setQuery({
              query: { name: '小钻风', age: 20, isBoy: true },
              chineseKey: ['name'],
            })
          )
        }
      >
        参数编码
      </Button>
      <Button
        onClick={() =>
          console.log(
            OutdoorUtils.pageParameters.getQuery({
              query: { name: '小钻风', age: '20', isBoy: 'true' },
              chineseKey: ['name'],
              numberKeys: ['age'],
              booleanKeys: ['isBoy'],
            })
          )
        }
      >
        参数解码
      </Button>
    </View>
  );
}
1.0.1

9 months ago

1.0.1-beta-3

9 months ago

1.0.1-beta-2

9 months ago

1.0.1-beta-1

12 months ago

1.0.0

12 months ago

1.0.0-beta-2

1 year ago

1.0.0-beta-1

1 year ago