健康同学微信公众号h5项目
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

356 line
13KB

  1. /* import Vue from 'vue';
  2. import Vuex from 'vuex';
  3. import getters from './getters';
  4. import app from './modules/app';
  5. Vue.use(Vuex);
  6. const store = new Vuex.Store({
  7. modules: {
  8. app
  9. },
  10. getters
  11. });
  12. export default store;
  13. */
  14. import Vue from 'vue';
  15. import Vuex from 'vuex';
  16. import prefix from '@/store/prefix';
  17. import { isNotNull } from '@/services/utils-service';
  18. Vue.use(Vuex);
  19. export default new Vuex.Store({
  20. state: {
  21. authToken: '',
  22. userId: '',
  23. deviceId: '',
  24. code: '',
  25. serialNo: '',
  26. isAdmin: '', // 绑定时申请人是否管理员/家属
  27. openId: '',
  28. bindSerialNo: '', //设备绑定成功时的输入的serialNo
  29. loginName: '', //用户登录用的手机号码
  30. fenceNameList: '', //用户所拥有的全部围栏名字
  31. familyNameList: '', //用户所拥有的全部亲情名字
  32. currentAddressAndPostion: '', //导航界面用户当前地址
  33. wxRecAuth: false, //获取微信第一次授权
  34. familyShortKeyList: '', //亲情号码快捷键
  35. isRegister: '', //判断用户是否是第一次进入公众号并且注册成功
  36. isLogin: '', //判断用户是否是已经登录成功
  37. gatewayToken: '', //gateway接口token
  38. isFromWx: '', //是否从微信过来的
  39. uniPhone: '', //物联网卡号
  40. roleUser: '', //身份角色, 1 学生; 2 长辈
  41. deviceType: '', //设备类型 1 电子设备 2 手表
  42. uploadinteval: '', //设备-手表采集频率
  43. notJump: null,
  44. showLogin: '', //是否显示登录
  45. watchRole: '',
  46. iotCardTitle: '', //物联网卡商名字
  47. fromRuoter: null,
  48. deviceVersion: '', //设备版本号
  49. ssjlToken: '', //b端接口token
  50. tabClick: '', //心理监测点击tab
  51. personId: '', //设备列表的personId
  52. uid: '', //心理相关用户的uid
  53. campId: '' //训练营Id
  54. },
  55. mutations: {
  56. authToken(state, token) {
  57. state.authToken = token;
  58. window.localStorage[prefix + 'authToken'] = token;
  59. },
  60. ssjlToken(state, ssjlToken) {
  61. state.ssjlToken = ssjlToken;
  62. window.localStorage[prefix + 'ssjlToken'] = ssjlToken;
  63. },
  64. userId(state, userId) {
  65. state.userId = userId;
  66. window.localStorage[prefix + 'userId'] = userId;
  67. },
  68. deviceId(state, deviceId) {
  69. state.deviceId = deviceId;
  70. window.localStorage[prefix + 'deviceId'] = deviceId;
  71. },
  72. code(state, code) {
  73. state.code = code;
  74. window.localStorage[prefix + 'code'] = code;
  75. },
  76. serialNo(state, serialNo) {
  77. state.serialNo = serialNo;
  78. window.localStorage[prefix + 'serialNo'] = serialNo;
  79. },
  80. isAdmin(state, isAdmin) {
  81. const result = isAdmin ? 1 : 0;
  82. state.isAdmin = result;
  83. window.localStorage[prefix + 'isAdmin'] = result;
  84. },
  85. openId(state, openId) {
  86. state.openId = openId;
  87. window.localStorage[prefix + 'openId'] = openId;
  88. },
  89. bindSerialNo(state, bindSerialNo) {
  90. state.bindSerialNo = bindSerialNo;
  91. window.localStorage[prefix + 'bindSerialNo'] = bindSerialNo;
  92. },
  93. // 用户登录用的手机号码
  94. loginName(state, loginName) {
  95. state.loginName = loginName;
  96. window.localStorage[prefix + 'loginName'] = loginName;
  97. },
  98. // 圆形围栏和多边形围栏
  99. fenceNameList(state, fenceNameList) {
  100. state.fenceNameList = fenceNameList;
  101. window.localStorage[prefix + 'fenceNameList'] = fenceNameList;
  102. },
  103. // 亲情号码名字
  104. familyNameList(state, familyNameList) {
  105. state.familyNameList = familyNameList;
  106. window.localStorage[prefix + 'familyNameList'] = familyNameList;
  107. },
  108. // currentAddressAndPostion
  109. currentAddressAndPostion(state, currentAddressAndPostion) {
  110. state.currentAddressAndPostion = currentAddressAndPostion;
  111. window.localStorage[prefix + 'currentAddressAndPostion'] = currentAddressAndPostion;
  112. },
  113. wxRecAuth(state, wxRecAuth) {
  114. state.wxRecAuth = wxRecAuth;
  115. window.localStorage[prefix + 'wxRecAuth'] = wxRecAuth;
  116. },
  117. familyShortKeyList(state, familyShortKeyList) {
  118. state.familyShortKeyList = familyShortKeyList;
  119. window.localStorage[prefix + 'familyShortKeyList'] = familyShortKeyList;
  120. },
  121. isRegister(state, isRegister) {
  122. state.isRegister = isRegister;
  123. window.localStorage[prefix + 'isRegister'] = isRegister;
  124. },
  125. isLogin(state, isLogin) {
  126. state.isLogin = isLogin;
  127. window.localStorage[prefix + 'isLogin'] = isLogin;
  128. },
  129. gatewayToken(state, gatewayToken) {
  130. state.gatewayToken = gatewayToken;
  131. window.localStorage[prefix + 'gatewayToken'] = gatewayToken;
  132. },
  133. isFromWx(state, isFromWx) {
  134. state.isFromWx = isFromWx;
  135. window.localStorage[prefix + 'isFromWx'] = isFromWx;
  136. },
  137. uniPhone(state, uniPhone) {
  138. state.uniPhone = uniPhone;
  139. window.localStorage[prefix + 'uniPhone'] = uniPhone;
  140. },
  141. roleUser(state, roleUser) {
  142. state.roleUser = roleUser;
  143. window.localStorage[prefix + 'roleUser'] = roleUser;
  144. },
  145. deviceType(state, deviceType) {
  146. state.deviceType = deviceType;
  147. window.localStorage[prefix + 'deviceType'] = deviceType;
  148. },
  149. uploadinteval(state, uploadinteval) {
  150. state.uploadinteval = uploadinteval;
  151. window.localStorage[prefix + 'uploadinteval'] = uploadinteval;
  152. },
  153. notJump(state, notJump) {
  154. state.notJump = notJump;
  155. window.localStorage[prefix + 'notJump'] = notJump;
  156. },
  157. showLogin(state, showLogin) {
  158. state.showLogin = showLogin;
  159. window.localStorage[prefix + 'showLogin'] = showLogin;
  160. },
  161. watchRole(state, watchRole) {
  162. state.watchRole = watchRole;
  163. window.localStorage[prefix + 'watchRole'] = watchRole;
  164. },
  165. iotCardTitle(state, iotCardTitle) {
  166. state.iotCardTitle = iotCardTitle;
  167. window.localStorage[prefix + 'iotCardTitle'] = iotCardTitle;
  168. },
  169. fromRuoter(state, fromRuoter) {
  170. state.fromRuoter = fromRuoter;
  171. window.localStorage[prefix + 'fromRuoter'] = fromRuoter;
  172. },
  173. deviceVersion(state, deviceVersion) {
  174. state.deviceVersion = deviceVersion;
  175. window.localStorage[prefix + 'deviceVersion'] = deviceVersion;
  176. },
  177. tabClick(state, tabClick) {
  178. state.tabClick = tabClick;
  179. window.localStorage[prefix + 'tabClick'] = tabClick;
  180. },
  181. personId(state, personId) {
  182. state.personId = personId;
  183. window.localStorage[prefix + 'personId'] = personId;
  184. },
  185. uid(state, uid) {
  186. state.uid = uid;
  187. window.localStorage[prefix + 'uid'] = uid;
  188. },
  189. campId(state, campId) {
  190. state.campId = campId;
  191. window.localStorage[prefix + 'campId'] = campId;
  192. }
  193. },
  194. getters: {
  195. authToken: state => {
  196. if (state.authToken != '') {
  197. return state.authToken;
  198. } else {
  199. return window.localStorage[prefix + 'authToken'] == null ? '' : window.localStorage[prefix + 'authToken'];
  200. }
  201. },
  202. ssjlToken: state => {
  203. if (state.ssjlToken != '') {
  204. return state.ssjlToken;
  205. } else {
  206. return window.localStorage[prefix + 'ssjlToken'] == null ? '' : window.localStorage[prefix + 'ssjlToken'];
  207. }
  208. },
  209. userId: state => {
  210. if (state.userId != '') return state.userId;
  211. return window.localStorage[prefix + 'userId'] == null ? '' : window.localStorage[prefix + 'userId'];
  212. },
  213. deviceId: state => {
  214. if (state.deviceId != '') return state.deviceId;
  215. return window.localStorage[prefix + 'deviceId'] == null ? '' : window.localStorage[prefix + 'deviceId'];
  216. },
  217. code: state => {
  218. if (state.code != '') return state.code;
  219. return window.localStorage[prefix + 'code'] == null ? '' : window.localStorage[prefix + 'code'];
  220. },
  221. serialNo: state => {
  222. if (state.serialNo != '') return state.serialNo;
  223. return window.localStorage[prefix + 'serialNo'] == null ? '' : window.localStorage[prefix + 'serialNo'];
  224. },
  225. isAdmin: state => {
  226. if (state.isAdmin != '') return state.isAdmin;
  227. return window.localStorage[prefix + 'isAdmin'] == null ? '' : window.localStorage[prefix + 'isAdmin'];
  228. },
  229. openId: state => {
  230. if (state.openId != '') return state.openId;
  231. return window.localStorage[prefix + 'openId'] == null ? '' : window.localStorage[prefix + 'openId'];
  232. },
  233. bindSerialNo: state => {
  234. if (state.bindSerialNo != '') return state.bindSerialNo;
  235. return window.localStorage[prefix + 'bindSerialNo'] == null ? '' : window.localStorage[prefix + 'bindSerialNo'];
  236. },
  237. loginName: state => {
  238. if (state.loginName != '') return state.loginName;
  239. return window.localStorage[prefix + 'loginName'] == null ? '' : window.localStorage[prefix + 'loginName'];
  240. },
  241. // 圆形围栏和多边形围栏
  242. fenceNameList: state => {
  243. if (isNotNull(state.fenceNameList)) return state.fenceNameList;
  244. else
  245. return window.localStorage[prefix + 'fenceNameList'] == null
  246. ? ''
  247. : window.localStorage[prefix + 'fenceNameList'];
  248. },
  249. familyNameList: state => {
  250. if (isNotNull(state.familyNameList)) return state.familyNameList;
  251. else
  252. return window.localStorage[prefix + 'familyNameList'] == null
  253. ? ''
  254. : window.localStorage[prefix + 'familyNameList'];
  255. },
  256. // currentAddressAndPostion
  257. currentAddressAndPostion: state => {
  258. if (isNotNull(state.currentAddressAndPostion)) return state.currentAddressAndPostion;
  259. else
  260. return window.localStorage[prefix + 'currentAddressAndPostion'] == null
  261. ? ''
  262. : window.localStorage[prefix + 'currentAddressAndPostion'];
  263. },
  264. wxRecAuth: state => {
  265. if (isNotNull(state.wxRecAuth)) return state.wxRecAuth;
  266. else return window.localStorage[prefix + 'wxRecAuth'] == null ? '' : window.localStorage[prefix + 'wxRecAuth'];
  267. },
  268. familyShortKeyList: state => {
  269. if (state.familyShortKeyList != '') return state.familyShortKeyList;
  270. return window.localStorage[prefix + 'familyShortKeyList'] == null
  271. ? ''
  272. : window.localStorage[prefix + 'familyShortKeyList'];
  273. },
  274. isRegister: state => {
  275. if (state.isRegister != '') return state.isRegister;
  276. return window.localStorage[prefix + 'isRegister'] == null ? '' : window.localStorage[prefix + 'isRegister'];
  277. },
  278. isLogin: state => {
  279. if (state.isLogin != '') return state.isLogin;
  280. return window.localStorage[prefix + 'isLogin'] == null ? '' : window.localStorage[prefix + 'isLogin'];
  281. },
  282. gatewayToken: state => {
  283. if (state.gatewayToken != '') return state.gatewayToken;
  284. return window.localStorage[prefix + 'gatewayToken'] == null ? '' : window.localStorage[prefix + 'gatewayToken'];
  285. },
  286. isFromWx: state => {
  287. if (state.isFromWx != '') return state.isFromWx;
  288. return window.localStorage[prefix + 'isFromWx'] == null ? '' : window.localStorage[prefix + 'isFromWx'];
  289. },
  290. uniPhone: state => {
  291. if (state.uniPhone != '') return state.uniPhone;
  292. return window.localStorage[prefix + 'uniPhone'] == null ? '' : window.localStorage[prefix + 'uniPhone'];
  293. },
  294. roleUser: state => {
  295. if (state.roleUser != '') return state.roleUser;
  296. return window.localStorage[prefix + 'roleUser'] == null ? '' : window.localStorage[prefix + 'roleUser'];
  297. },
  298. deviceType: state => {
  299. if (state.deviceType != '') return state.deviceType;
  300. return window.localStorage[prefix + 'deviceType'] == null ? '' : window.localStorage[prefix + 'deviceType'];
  301. },
  302. uploadinteval: state => {
  303. if (state.uploadinteval != '') return state.uploadinteval;
  304. return window.localStorage[prefix + 'uploadinteval'] == null ? '' : window.localStorage[prefix + 'uploadinteval'];
  305. },
  306. notJump: state => {
  307. if (state.notJump != '') return state.notJump;
  308. return window.localStorage[prefix + 'notJump'] == null ? '' : window.localStorage[prefix + 'notJump'];
  309. },
  310. showLogin: state => {
  311. if (state.showLogin != '') return state.showLogin;
  312. return window.localStorage[prefix + 'showLogin'] == null ? '' : window.localStorage[prefix + 'showLogin'];
  313. },
  314. watchRole: state => {
  315. if (state.watchRole != '') return state.watchRole;
  316. return window.localStorage[prefix + 'watchRole'] == null ? '' : window.localStorage[prefix + 'watchRole'];
  317. },
  318. iotCardTitle: state => {
  319. if (state.iotCardTitle != '') return state.iotCardTitle;
  320. return window.localStorage[prefix + 'iotCardTitle'] == null ? '' : window.localStorage[prefix + 'iotCardTitle'];
  321. },
  322. fromRuoter: state => {
  323. if (state.fromRuoter != '') return state.fromRuoter;
  324. return window.localStorage[prefix + 'fromRuoter'] == null ? '' : window.localStorage[prefix + 'fromRuoter'];
  325. },
  326. deviceVersion: state => {
  327. if (state.deviceVersion != '') return state.deviceVersion;
  328. return window.localStorage[prefix + 'deviceVersion'] == null ? '' : window.localStorage[prefix + 'deviceVersion'];
  329. },
  330. tabClick: state => {
  331. if (state.tabClick != '') return state.tabClick;
  332. return window.localStorage[prefix + 'tabClick'] == null ? '' : window.localStorage[prefix + 'tabClick'];
  333. },
  334. personId: state => {
  335. if (state.personId != '') return state.personId;
  336. return window.localStorage[prefix + 'personId'] == null ? '' : window.localStorage[prefix + 'personId'];
  337. },
  338. uid: state => {
  339. if (state.uid != '') return state.uid;
  340. return window.localStorage[prefix + 'uid'] == null ? '' : window.localStorage[prefix + 'uid'];
  341. },
  342. campId: state => {
  343. if (state.campId != '') return state.campId;
  344. return window.localStorage[prefix + 'campId'] == null ? '' : window.localStorage[prefix + 'campId'];
  345. }
  346. },
  347. actions: {},
  348. modules: {}
  349. });