import { onLaunch } from '@dcloudio/uni-app'
import { PARAMS_LOCAL_KEY } from '../constant'

export const initParams = () => {
  return new Promise((resolve) => {
    onLaunch(({ referrerInfo }) => {
      const params = referrerInfo?.extraData
      if (params.authorization) {
        uni.setStorage({
          key: PARAMS_LOCAL_KEY,
          data: params,
          success() {
            resolve(params)
          }
        })
      }

    })
  })
}
