Commit fd720797 by golton_gao

update: 清理无用的逻辑

parent 32e39373
// 获取设备信息id
import VMT from '@/main'
/* global VMT,device:true */
const getDeviceid = () => {
return new Promise((resolve, reject) => {
if (process.env.NODE_ENV === 'provt') {
VMT.$nativeApi.dataInteraction.getDeviceInfo().then(data => {
// alert('data:' + JSON.stringify(data))
resolve(data.deviceId)
}).catch(err => {
// alert('err:' + JSON.stringify(err))
console.log(err)
const deviceid = 'DEVICEERR' + parseInt(Math.random() * 100)
reject(deviceid)
})
} else if (process.env.NODE_ENV === 'production') {
resolve(device.uuid)
} else {
const deviceid = 'DEVICETEST' + parseInt(Math.random() * 100)
reject(deviceid)
}
})
}
export default getDeviceid
/*
actions.js
封装 获取相应 数据、状态值 方法
*/
/* global cordova:true */
// 引入接口
// import * as Connect from '@/common/connect'
import Base64 from '@/common/base64'
import axios from 'axios'
/*
测试数据分配,10: 房产,20: 物业。
*/
const TESTTYPES = 10
/* V+集成登录获取信息 */
export const getVUserInfo = ({ commit }, data) => {
return new Promise((resolve, reject) => {
const { uname, pwd, host } = data.data
const datas = {
username: uname,
password: Base64.encode(pwd)
}
axios({
method: 'post',
url: host + 'app/loginNew',
data: datas
}).then(res => {
console.log('comein:' + JSON.stringify(res.data))
if (res.data.status === 200) {
// 设置用户数据 userInfo
const dats = res.data.record
// 设置httpHead
const b2v = 'Basic ' + Base64.encode(uname + ':' + pwd)
const datas = {
userInfo: dats,
host,
header: b2v
}
commit('getInfos', { data: datas })
resolve()
} else {
reject(res.data.exception)
}
}).catch(error => {
console.log('fail:' + JSON.stringify(error))
reject(error)
})
})
}
/* 获取用户信息 */
export const getUserInfo = ({ commit }, data) => {
return new Promise((resolve, reject) => {
// console.log('function ' + JSON.stringify(data))
// 同步到state
if (process.env.NODE_ENV === 'production') {
cordova.exec(function (result) {
const dats = JSON.parse(result)
commit('getInfo', { data: dats, type: data.type })
resolve()
}, function (error) {
navigator.notification.alert(error)
resolve()
}, 'YFPlugin', data.type, [])
} else {
// 房产
const adf = {
'username': '邴博',
'cell': '13506027389',
'fid': 'DzmkcfSZQ\/CdF77ixahmwxO33n8=',
'userId': 'bingb@cndrealty.com'
}
// 物业
const adw = {
'username': '刘燕美',
'cell': '1',
'fid': 'dsG2\/e2wTMOehOmJU3HQ3hO33n8=',
'userId': 'liuym@ehomeol.cn'
}
commit('getInfo', {
data: TESTTYPES === 10 ? adf : adw,
type: data.type
})
resolve()
}
})
}
/* 获取hosts */
export const getHttpHost = ({ commit }, data) => {
return new Promise((resolve, reject) => {
// console.log('function ' + JSON.stringify(data))
// 同步到state
if (process.env.NODE_ENV === 'production') {
cordova.exec(function (result) {
commit('getInfo', { data: result, type: data.type })
resolve()
}, function (error) {
navigator.notification.alert(error)
resolve()
}, 'YFPlugin', data.type, [])
} else {
commit('getInfo', { data: 'http://csmtest.cndrealty.com/csm/', type: data.type })
resolve()
}
})
}
/* 获取httpHead */
export const getHttpHeadValue = ({ commit }, data) => {
return new Promise((resolve, reject) => {
// console.log('function ' + JSON.stringify(data))
// 同步到state
if (process.env.NODE_ENV === 'production') {
cordova.exec(function (result) {
commit('getInfo', { data: result, type: data.type })
resolve()
}, function (error) {
navigator.notification.alert(error)
resolve()
}, 'YFPlugin', data.type, [])
} else {
TESTTYPES === 10 ? commit('getInfo', { data: 'Basic YmluZ2JAY25kcmVhbHR5LmNvbTppdGFk', type: data.type }) : commit('getInfo', { data: 'Basic bGl1eW1AZWhvbWVvbC5jbjppdGFk', type: data.type })
resolve()
}
})
}
/*
清除Vuex缓存设置
*/
export const clearVuexData = ({ commit, state }, data) => {
const { userInfo, HttpHeadValue, HttpHost } = state
const datas = {
userInfo,
HttpHeadValue,
HttpHost
}
commit('reSetStateData', datas)
}
......@@ -6,31 +6,5 @@
export default {
showLoading (state, show) {
state.showLoading = show
},
// 更新 HttpHost、HttpHeadValue、UserInfo
getInfo (state, data) {
// 根据不同参数,同步数据到state
switch (data.type) {
case 'getUserInfo':
state.userInfo = data.data
break;
case 'getHttpHeadValue':
state.HttpHeadValue = data.data
break;
case 'getHttpHost':
state.HttpHost = data.data
break;
}
},
// 更新 HttpHost、HttpHeadValue、UserInfo,兼容V+
getInfos (state, data) {
const { userInfo, host, header } = data.data
state.userInfo = userInfo
state.HttpHost = host
state.HttpHeadValue = header
},
// 清空数据
reSetStateData (state, data) {
Object.assign(state, data)
}
}
......@@ -2,11 +2,5 @@
Vuex: state初始化
*/
export default {
// 用户信息
userInfo: null,
// 头部信息
HttpHeadValue: null,
// Host
HttpHost: null,
showLoading: false
}
......@@ -3,7 +3,7 @@
*/
import Vue from 'vue'
import Vuex from 'vuex'
import * as actions from './actions'
// import * as actions from './actions'
import mutations from './mutations'
import state from './state'
import satisfaction from './modules/satisfaction'
......@@ -19,6 +19,5 @@ export default new Vuex.Store({
},
state,
mutations,
actions,
strict: debug
})
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment