Commit 826cecc1 by golton_gao

update: 逻辑优化

parent 698c96f3
// 获取设备信息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
// 弹窗方法api // 弹窗方法api
const Alert = (title, func) => { const Alert = (title, func) => {
const titl = title const titl = title
/*
if (process.env.NODE_ENV === 'production' || process.env.NODE_ENV === 'provt') { if (process.env.NODE_ENV === 'production' || process.env.NODE_ENV === 'provt') {
navigator.notification.alert(titl, func, '', '确定'); navigator.notification.alert(titl, func, '', '确定');
} else { } else {
window.alert(titl) window.alert(titl)
func() func()
} }
*/
window.alert(titl)
func()
} }
const Confirm = (title, func) => { const Confirm = (title, func) => {
const tit = title const tit = title
/*
if (process.env.NODE_ENV === 'production' || process.env.NODE_ENV === 'provt') { if (process.env.NODE_ENV === 'production' || process.env.NODE_ENV === 'provt') {
navigator.notification.confirm(tit, function (buttonIndex) { navigator.notification.confirm(tit, function (buttonIndex) {
if (buttonIndex == 1) { if (buttonIndex == 1) {
...@@ -27,6 +32,13 @@ const Confirm = (title, func) => { ...@@ -27,6 +32,13 @@ const Confirm = (title, func) => {
func(false) func(false)
} }
} }
*/
let res = window.confirm(tit)
if (res) {
func(true)
} else {
func(false)
}
} }
export default { export default {
......
...@@ -12,7 +12,8 @@ import { APIPath } from './common' ...@@ -12,7 +12,8 @@ import { APIPath } from './common'
import Dialog from '@/base/plugins/dialog' import Dialog from '@/base/plugins/dialog'
// 全局axios默认配置 // 全局axios默认配置
axios.defaults.baseURL = APIPath.HOST // axios.defaults.baseURL = APIPath.HOST
axios.defaults.baseURL = APIPath.TESTHOST
Vue.prototype.$axios = axios Vue.prototype.$axios = axios
// 获取屏幕宽高 // 获取屏幕宽高
...@@ -38,6 +39,7 @@ Vue.prototype.$dialog = Dialog // 全局的对话框 ...@@ -38,6 +39,7 @@ Vue.prototype.$dialog = Dialog // 全局的对话框
let VMT let VMT
/* eslint-disable no-new */ /* eslint-disable no-new */
/*
if (process.env.NODE_ENV === 'production') { if (process.env.NODE_ENV === 'production') {
document.addEventListener('deviceready', function () { document.addEventListener('deviceready', function () {
VMT = new Vue({ VMT = new Vue({
...@@ -54,6 +56,14 @@ if (process.env.NODE_ENV === 'production') { ...@@ -54,6 +56,14 @@ if (process.env.NODE_ENV === 'production') {
store, store,
render: h => h(App) render: h => h(App)
}) })
} }*/
VMT = new Vue({
router,
store,
render: (h) => h(App)
})
window.qing.ready(() => {
VMT.$mount('#app')
})
export default VMT export default VMT
/*
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 @@ ...@@ -6,31 +6,5 @@
export default { export default {
showLoading (state, show) { showLoading (state, show) {
state.showLoading = 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 @@ ...@@ -2,11 +2,5 @@
Vuex: state初始化 Vuex: state初始化
*/ */
export default { export default {
// 用户信息
userInfo: null,
// 头部信息
HttpHeadValue: null,
// Host
HttpHost: null,
showLoading: false showLoading: false
} }
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
*/ */
import Vue from 'vue' import Vue from 'vue'
import Vuex from 'vuex' import Vuex from 'vuex'
import * as actions from './actions'
import mutations from './mutations' import mutations from './mutations'
import state from './state' import state from './state'
import deliveryHouse from './modules/deliveryHouse' import deliveryHouse from './modules/deliveryHouse'
...@@ -21,6 +20,5 @@ export default new Vuex.Store({ ...@@ -21,6 +20,5 @@ export default new Vuex.Store({
}, },
state, state,
mutations, mutations,
actions,
strict: debug 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