12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- import Vue from 'vue'
- import Vuex from 'vuex'
- import { getLang } from '@/utils/util'
- const app = getApp();
- Vue.use(Vuex)
- const store = new Vuex.Store({
- state: {
- isLogin:1,//1已登录 2未登录
- info:{
- avatar:''
- },
- language: getLang(),
- loginShowSign: false,
- loginShowCloseSign: false,
- eyes1:false,
- isVoice:false,
- timeZone:'',
- qiuNiu: JSON.parse(localStorage.getItem('qiuNiu')) || {},
- system:{}
- },
- modules: {},
- mutations: {
- setLang: (state, i) => {
- state.language = i
- localStorage.setItem('language', JSON.stringify(i))
- }
- },
- actions: {
- loginTim(state, data) {
- if(data.types == 'youke') {
- data.userID = data.id
- data.userSig = data.sig
- }else {
- let information = JSON.parse(localStorage.getItem('information')) || {data:{}}
- data.userID = String(information.data.id)
- data.userSig = information.data.userSig
- }
- return new Promise((resolve, reject) => {
- // const SDKAppID = app.globalData.SDKAppID;
- uni.$TUIKit.login(data).then((res) => {
- setTimeout(() => {
- state.dispatch('editInfo', data).then(() => {
- resolve()
- }).catch(() => {
- reject()
- })
- }, 1000)
-
- // uni.$aegis.reportEvent({
- // name: 'login',
- // ext1: 'login-success',
- // ext2: 'uniTuikitExternal',
- // ext3: `${SDKAppID}`,
- // })
- }).catch((error) => {
- console.error('errr', error)
- reject()
- // uni.$aegis.reportEvent({
- // name: 'login',
- // ext1: `login-failed#error:${error}`,
- // ext2: 'uniTuikitExternal',
- // ext3: `${SDKAppID}`,
- // })
- })
- })
-
- },
- editInfo(state, data) {
- return new Promise((resolve, reject) => {
- console.error(state.state.info.user_nickname)
- uni.$TUIKit.updateMyProfile({
- nick: state.state.info.user_nickname || data.id
- }).then((imResponse) => {
- setTimeout(() => {
- resolve()
- }, 1000)
- }).catch((err) => {
- reject()
- })
- })
- },
- getQiNiu(state, data) {
- uni.$u.http.get('/api/Member/getQiniuToken').then(res => {
- localStorage.setItem('qiuNiu', JSON.stringify(res))
- state.state.qiuNiu = res
- })
- }
- }
- })
- export default store
|