123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- import actions from "./actions"
- import mutations from "./mutations"
- // #ifdef H5
- // 解析地址栏参数
- function getQueryVariable(variable) {
- // 从?开始获取后面的所有数据
- var query = window.location.search.substring(1);
- // 从字符串&开始分隔成数组split
- var vars = query.split('&');
- // 遍历该数组
- for (var i = 0; i < vars.length; i++) {
- // 从等号部分分割成字符
- var pair = vars[i].split('=');
- // 如果第一个元素等于 传进来的参的话 就输出第二个元素
- if (pair[0] == variable) {
- return pair[1];
- }
- }
- return undefined;
- }
- var token = getQueryVariable("x-token")
- if (token) {
- uni.setStorageSync('recycle_mobile_token', token)
- }
- var openId = getQueryVariable("openId")
- if (openId) {
- uni.setStorageSync('recycle_mobile_openId', openId)
- }
- var username = getQueryVariable("username")
- if (username) {
- uni.setStorageSync('recycle_mobile_name', username)
- }
- var useravatar = getQueryVariable("useravatar")
- if (useravatar) {
- uni.setStorageSync('recycle_mobile_avatar', useravatar)
- }
- var userId = getQueryVariable("userId")
- if (userId) {
- uni.setStorageSync('recycle_mobile_userId', userId)
- }
- var miniProgram = getQueryVariable("miniProgram")
- if (miniProgram) {
- uni.setStorageSync('miniProgram', miniProgram)
- }
- // #endif
- const state = {
- openId: uni.getStorageSync('recycle_mobile_openId') || '',
- token: uni.getStorageSync('recycle_mobile_token') || '',
- name: uni.getStorageSync('recycle_mobile_name') || '',
- avatar: uni.getStorageSync('recycle_mobile_avatar') || '',
- userId: uni.getStorageSync('recycle_mobile_userId') || '',
- }
- export default {
- namespaced: true,
- state,
- mutations,
- actions
- }
|