How to use the @tarojs/taro.getStorageSync function in @tarojs/taro

To help you get started, we’ve selected a few @tarojs/taro examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hugetiny / quit-smoking / src / pages / quitSmoking / doing.js View on Github external
componentWillMount () {
    console.log('doingWillMount')
    this.props.dispatch({
      type: 'doing/save',
      payload: {
        lastsign: Taro.getStorageSync('lastsign'),
        days: Taro.getStorageSync('days'),
        healthPercent: parseInt(Taro.getStorageSync('unitamount') / 20 * Taro.getStorageSync('days')),
        moneyPercent: parseInt(Taro.getStorageSync('unitprice') / Taro.getStorageSync('unitamount') * Taro.getStorageSync('amount') * Taro.getStorageSync('days') / 10),
        rewardPercent: Taro.getStorageSync('days') / 10
      },
    })
    // if(Date.parse(new Date()) - Taro.getStorageSync('lastsign')>= 864000000){
    //   this.props.dispatch({
    //     type: 'doing/allowSign'
    //   };
    // }
  }
github BinZhiZhu / Taro-v2ex-weapp / src / components / latest-data-default-list / index.tsx View on Github external
}).then((result: apiData) => {
      Taro.hideLoading();
      console.log('获取最新节点', result);
      this.props.dispatch({
        type: LATEST_TOPIC_LIST,
        data: result.data
      });
      const isRefresh = Taro.getStorageSync('IS_LATEST_DATA_REFRESH')
      if(isRefresh){
        showToast({
          title:'刷新成功',
          icon:'success'
        });
        Taro.setStorageSync('IS_LATEST_DATA_REFRESH',false)
      }
    }).catch((error) => {
      showToast(error.message)
github Harhao / miniProgram / src / pages / search / search.js View on Github external
searchList(){
    let cityId = Taro.getStorageSync('cities').geoCity.id;
    let keyWord = this.state.keyWord;
    let self = this;
    Taro.request({
      url:`https://m.maoyan.com/ajax/search?kw=${keyWord}&cityId=${cityId}&stype=-1`,
      method:'GET'
    }).then(res=>{
      if(res.statusCode == 200){
          let data = res.data;
          let list = data.movies?data.movies.list:[];
          list.map(item=>{
            let arr = item["img"].split("w.h");
            item["img"] = arr[0]+'120.180'+arr[1];
          })
          self.setState({
              cinemasList:data.cinemas?data.cinemas.list:[],
              movieList:data.movies?data.movies.list:[]
github EasyTuan / taro-msparis / src / models / common.js View on Github external
import Taro from '@tarojs/taro';

export default {
  namespace: 'common',
  state: {
    access_token: Taro.getStorageSync('access_token'),
    mobile: Taro.getStorageSync('user_info')
      ? Taro.getStorageSync('user_info').mobile
      : '',
    nickname: Taro.getStorageSync('user_info')
      ? Taro.getStorageSync('user_info').nickname
      : '',
    new_user: Taro.getStorageSync('user_info')
      ? Taro.getStorageSync('user_info').new_user
      : '',
    is_has_buy_card: Taro.getStorageSync('user_info')
      ? Taro.getStorageSync('user_info').is_has_buy_card
      : '',
    erroMessage: Taro.getStorageSync('user_info')
      ? Taro.getStorageSync('user_info').erroMessage
      : '',
  },

  effects: {},

  reducers: {
    save(state, { payload }) {
      return { ...state, ...payload };
    },
  },
github Harhao / miniProgram / src / pages / cinema / cinema.js View on Github external
getStorageData(){
    let self = this;
    let cityData = Taro.getStorageSync('cities');
    this.setState({
      cityData:cityData.geoCity
    },()=>{
      self.filterCinemasList();
      self.getCinemasList();
    });
  }
  filterCinemasList(){
github lsqy / taro-music / src / pages / myFocus / index.tsx View on Github external
constructor (props) {
    super(props)
    this.state = {
      userId: Taro.getStorageSync('userId'),
      userList: [],
      hasMore: true
    }
  }
github lsqy / taro-music / src / pages / recentPlay / index.tsx View on Github external
getData() {
    const { currentTab } = this.state
    const userId = Taro.getStorageSync('userId')
    api.get('/user/record', {
      uid: userId,
      type: currentTab === 0 ? 1 : 0
    }).then((res) => {
      const dataType = currentTab === 0 ? 'weekData' : 'allData'
      if (res.data && res.data[dataType] && res.data[dataType].length > 0) {
        this.setState({
          list: res.data[dataType]
        })
      }
    })
  }
github Harhao / miniProgram / src / pages / search / search.js View on Github external
navigateToURL(url,item){
    let cityId = Taro.getStorageSync('cities').geoCity.id;
    url = url+`?title=${item.nm}&id=${item.id}&cityId=${cityId}`
    Taro.navigateTo({
      url:url
    });
  }
  navigateToCinema(url,item){
github TigerHee / taro-request / servers / http.js View on Github external
baseOptions(params, method = "GET") {
    let { url, data } = params;
    const BASE_URL = getBaseUrl(url);
    let contentType = "application/json";
    contentType = params.contentType || contentType;
    const option = {
      url: BASE_URL + url,
      data: data,
      method: method,
      header: {
        'content-type': contentType,
        'Authorization': Taro.getStorageSync('Authorization')
      }
    };
    return Taro.request(option);
  }