How to use the @tarojs/taro.setStorageSync 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 SolidZORO / leaa / packages / leaa-miniprogram / src / pages / account / _components / LoginButton / LoginButton.tsx View on Github external
let sessionResponse: {
      data: {
        openid: string;
        session_key: string;
      };
    };

    try {
      sessionResponse = await Taro.request({
        method: 'POST',
        url: `${envConfig.WECHAT_HOST}/oauth/wechat/session`,
        data: loginResponse,
      });

      if (sessionResponse && sessionResponse.data) {
        Taro.setStorageSync('openId', sessionResponse.data.openid);
        Taro.setStorageSync('sessionKey', sessionResponse.data.session_key);
      }
    } catch (e) {
      console.log(e);
      setLoginLoading(false);
      await Taro.showToast({ title: '获取 Key 失败' });

      return;
    }

    console.log('sessionResponse', sessionResponse);

    //
    // ------------------------------------
    let userInfoResponse: {
      encryptedData: string;
github SolidZORO / leaa / packages / leaa-miniprogram / src / pages / account / _components / LoginButton / LoginButton.tsx View on Github external
data: {
        openid: string;
        session_key: string;
      };
    };

    try {
      sessionResponse = await Taro.request({
        method: 'POST',
        url: `${envConfig.WECHAT_HOST}/oauth/wechat/session`,
        data: loginResponse,
      });

      if (sessionResponse && sessionResponse.data) {
        Taro.setStorageSync('openId', sessionResponse.data.openid);
        Taro.setStorageSync('sessionKey', sessionResponse.data.session_key);
      }
    } catch (e) {
      console.log(e);
      setLoginLoading(false);
      await Taro.showToast({ title: '获取 Key 失败' });

      return;
    }

    console.log('sessionResponse', sessionResponse);

    //
    // ------------------------------------
    let userInfoResponse: {
      encryptedData: string;
      iv: string;
github huangjianke / Gitter / src / pages / account / about.js View on Github external
success(res) {
        if (res.confirm) {
          Taro.setStorageSync('Authorization', '')
          Taro.setStorageSync('userInfo', null)
          Taro.navigateBack()
        } else if (res.cancel) {
          console.log('用户点击取消')
        }
      }
    })
github BinZhiZhu / Taro-v2ex-weapp / src / pages / index / index.tsx View on Github external
Taro.startPullDownRefresh().then((result) => {
      const {isPullRefresh} = this.state
      console.log('onPullDownRefresh',result)
      Taro.setStorageSync('IS_LATEST_DATA_REFRESH',true);
      Taro.eventCenter.trigger('LATEST_DATA_REFRESH',isPullRefresh)
      this.setState({
        isPullRefresh: false
      },()=>{
        Taro.stopPullDownRefresh();
      })
    }).catch((failResullt) => {
      console.log('failResullt', failResullt);
github BinZhiZhu / Taro-v2ex-weapp / src / pages / hot / index.tsx View on Github external
Taro.startPullDownRefresh().then((result) => {
      const {isPullRefresh} = this.state
      console.log('onPullDownRefresh',result)
      Taro.setStorageSync('IS_LATEST_DATA_REFRESH',true);
      Taro.eventCenter.trigger('LATEST_DATA_REFRESH',isPullRefresh)
      this.setState({
        isPullRefresh: false
      },()=>{
        Taro.stopPullDownRefresh();
      })
    }).catch((failResullt) => {
      console.log('failResullt', failResullt);
github wsdo / taro-kit / src / utils / cutter.js View on Github external
success: function (res) {
        Taro.hideLoading()
        Taro.setStorageSync('resultImg', res.tempFilePath)
      },
      fail: function (res) {
github lsqy / taro-music / src / pages / login / index.tsx View on Github external
}).then((res) => {
          const { code } = res.data
          let tip = '登录成功'
          if (code !== 200) {
            tip = res.data.msg || '登录失败'
          }
          this.setState({
            showLoading: false,
            showTip: true,
            tip
          })
          if (code === 200) {
            Taro.setStorageSync('userInfo', res.data)
            Taro.setStorageSync('userId', res.data.account.id)
            Taro.navigateTo({
              url: '/pages/index/index'
            })
          }
      })
  }
github EasyTuan / taro-msparis / src / pages / cart / model.js View on Github external
save(state, { payload }) {
      Taro.setStorageSync('items', [...state.items, ...payload.items]);
      return { ...state, ...payload };
    },
    deleteClothes(state, { payload }) {
github Harhao / miniProgram / src / pages / movies / movies.js View on Github external
}).then(res => {
      if (res.statusCode == 200) {
        let data = res.data.data.data.data;
        Taro.setStorageSync("cities", data);
      }
    });
  }
github EasyTuan / taro-msparis / src / pages / login / model.js View on Github external
*login(_, { call, put, select }) {
      const { code, mobile } = yield select(state => state.login);
      const res = yield call(login.login, { code, mobile });
      if (res.status == 'ok') {
        const userInfo = {
          access_token: res.data.access_token,
          invitation_code: res.data.invitation_code,
          mobile: res.data.mobile,
          nickname: res.data.nickname,
          new_user: res.data.new_user,
          is_has_buy_card: res.data.is_has_buy_card,
          erroMessage: '',
        };

        Taro.setStorageSync('user_info', userInfo);
        Taro.setStorageSync('access_token', res.data.access_token);

        yield put({
          type: 'common/save',
          payload: {
            access_token: res.data.access_token,
            invitation_code: res.data.invitation_code,
            mobile: res.data.mobile,
            nickname: res.data.nickname,
            new_user: res.data.new_user,
            is_has_buy_card: res.data.is_has_buy_card,
            erroMessage: '',
            code: '',
          },
        });

        yield put({