wechat/base

base module provides frequently used miniprogram APIs extend them as much as one needs, all wechat bindings are asynchronous and returns a Promise

Types

javascript Date object

pub type Date

Functions

pub fn check_session(
  complete cb: fn() -> Nil,
) -> Promise(Result(JsObject, WechatError))

wx.checkSession

pub fn get_privacy_contract(
  complete cb: fn() -> Nil,
) -> Promise(Result(JsObject, WechatError))

wx.getPrivacyContract

pub fn get_privacy_setting(
  complete cb: fn() -> Nil,
) -> Promise(Result(JsObject, WechatError))

wx.getPrivacySetting

pub fn get_setting(
  subscriptions s: Bool,
  complete cb: fn() -> Nil,
) -> Promise(Result(JsObject, WechatError))

wx.getSetting

pub fn get_storage(
  key k: String,
  complete cb: fn() -> Nil,
) -> Promise(Result(JsObject, WechatError))

wx.getStorage

pub fn get_system_info(
  complete cb: fn() -> Nil,
) -> Promise(Result(JsObject, WechatError))

wx.getSystemInfo

pub fn hide_loading(
  complete cb: fn() -> Nil,
) -> Promise(Result(JsObject, WechatError))

wx.hideLoading

pub fn hide_tabbar(
  animation a: Bool,
  complete cb: fn() -> Nil,
) -> Promise(Result(JsObject, WechatError))

wx.hideTabbar

pub fn login(
  complete cb: fn() -> Nil,
) -> Promise(Result(JsObject, WechatError))

wx.login

pub fn navigate_back(
  by delta: Int,
  complete cb: fn() -> Nil,
) -> Promise(Result(JsObject, WechatError))

wx.navigateBack

pub fn navigate_to(
  to url: String,
  complete cb: fn() -> Nil,
) -> Promise(Result(JsObject, WechatError))

wx.navigateTo

pub fn now() -> Date

get timestamp of Date

pub fn open_document(
  path p: String,
  of t: String,
  complete cb: fn() -> Nil,
) -> Promise(Result(JsObject, WechatError))

wx.openDocument

pub fn relaunch(
  to url: String,
  complete cb: fn() -> Nil,
) -> Promise(Result(JsObject, WechatError))

wx.reLaunch

pub fn remove_storage(
  key k: String,
  complete cb: fn() -> Nil,
) -> Promise(Result(JsObject, WechatError))

wx.removeStorage

pub fn request(
  method m: String,
  url u: String,
  header h: JsObject,
  data d: JsObject,
  complete cb: fn() -> Nil,
) -> Promise(Result(JsObject, WechatError))

wx.request

pub fn request_payment(
  time_stamp t: String,
  nonce_str n: String,
  pkg p: String,
  sign_type s: String,
  pay_sign ps: String,
  complete cb: fn() -> Nil,
) -> Promise(Result(JsObject, WechatError))

wx.requestPayment

pub fn save_file(
  path p: String,
  complete cb: fn() -> Nil,
) -> Promise(Result(JsObject, WechatError))

wx.saveFile

pub fn set_clipboard(
  data d: JsObject,
  complete cb: fn() -> Nil,
) -> Promise(Result(JsObject, WechatError))

wx.setClipboardData

pub fn set_navigation_bar(
  title t: String,
  complete cb: fn() -> Nil,
) -> Promise(Result(JsObject, WechatError))

wx.setNavigationBarTitle

pub fn set_storage(
  key k: String,
  value v: JsObject,
  complete cb: fn() -> Nil,
) -> Promise(Result(JsObject, WechatError))

wx.setStorage

pub fn show_loading(
  title t: String,
  mask m: Bool,
  complete cb: fn() -> Nil,
) -> Promise(Result(JsObject, WechatError))

wx.showLoading

pub fn show_tabbar(
  animation a: Bool,
  complete cb: fn() -> Nil,
) -> Promise(Result(JsObject, WechatError))

wx.showTabbar

pub fn show_toast(
  title t: String,
  icon i: String,
  mask m: Bool,
  duration d: Int,
  complete cb: fn() -> Nil,
) -> Promise(Result(JsObject, WechatError))

wx.showToast

pub fn switch_tab(
  to url: String,
  complete cb: fn() -> Nil,
) -> Promise(Result(JsObject, WechatError))

wx.switchTab

pub fn to_payment(p: String) -> Int

utility function convert string to wechat payment

Examples

> to_payment("2.9")
290

> to_payment("129.013")
12901
pub fn upload_file(
  to url: String,
  path p: String,
  header h: JsObject,
  form f: JsObject,
  complete cb: fn() -> Nil,
) -> Promise(Result(JsObject, WechatError))

wx.uploadFile

pub fn vibrate_short(
  of t: String,
  complete cb: fn() -> Nil,
) -> Promise(Result(JsObject, WechatError))

wx.vibrateShort

pub fn ymd(d: Date) -> Promise(Result(JsObject, WechatError))

utility function to convert Date to local YYYY-MM-DD asynchronous, a test is written as showcase

Search Document