健康同学微信公众号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.

347 lines
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. },
  54. mutations: {
  55. authToken(state, token) {
  56. state.authToken = token;
  57. window.localStorage[prefix + 'authToken'] = token;
  58. },
  59. ssjlToken(state, ssjlToken) {
  60. state.ssjlToken = ssjlToken;
  61. window.localStorage[prefix + 'ssjlToken'] = ssjlToken;
  62. },
  63. userId(state, userId) {
  64. state.userId = userId;
  65. window.localStorage[prefix + 'userId'] = userId;
  66. },
  67. deviceId(state, deviceId) {
  68. state.deviceId = deviceId;
  69. window.localStorage[prefix + 'deviceId'] = deviceId;
  70. },
  71. code(state, code) {
  72. state.code = code;
  73. window.localStorage[prefix + 'code'] = code;
  74. },
  75. serialNo(state, serialNo) {
  76. state.serialNo = serialNo;
  77. window.localStorage[prefix + 'serialNo'] = serialNo;
  78. },
  79. isAdmin(state, isAdmin) {
  80. const result = isAdmin ? 1 : 0;
  81. state.isAdmin = result;
  82. window.localStorage[prefix + 'isAdmin'] = result;
  83. },
  84. openId(state, openId) {
  85. state.openId = openId;
  86. window.localStorage[prefix + 'openId'] = openId;
  87. },
  88. bindSerialNo(state, bindSerialNo) {
  89. state.bindSerialNo = bindSerialNo;
  90. window.localStorage[prefix + 'bindSerialNo'] = bindSerialNo;
  91. },
  92. // 用户登录用的手机号码
  93. loginName(state, loginName) {
  94. state.loginName = loginName;
  95. window.localStorage[prefix + 'loginName'] = loginName;
  96. },
  97. // 圆形围栏和多边形围栏
  98. fenceNameList(state, fenceNameList) {
  99. state.fenceNameList = fenceNameList;
  100. window.localStorage[prefix + 'fenceNameList'] = fenceNameList;
  101. },
  102. // 亲情号码名字
  103. familyNameList(state, familyNameList) {
  104. state.familyNameList = familyNameList;
  105. window.localStorage[prefix + 'familyNameList'] = familyNameList;
  106. },
  107. // currentAddressAndPostion
  108. currentAddressAndPostion(state, currentAddressAndPostion) {
  109. state.currentAddressAndPostion = currentAddressAndPostion;
  110. window.localStorage[prefix + 'currentAddressAndPostion'] = currentAddressAndPostion;
  111. },
  112. wxRecAuth(state, wxRecAuth) {
  113. state.wxRecAuth = wxRecAuth;
  114. window.localStorage[prefix + 'wxRecAuth'] = wxRecAuth;
  115. },
  116. familyShortKeyList(state, familyShortKeyList) {
  117. state.familyShortKeyList = familyShortKeyList;
  118. window.localStorage[prefix + 'familyShortKeyList'] = familyShortKeyList;
  119. },
  120. isRegister(state, isRegister) {
  121. state.isRegister = isRegister;
  122. window.localStorage[prefix + 'isRegister'] = isRegister;
  123. },
  124. isLogin(state, isLogin) {
  125. state.isLogin = isLogin;
  126. window.localStorage[prefix + 'isLogin'] = isLogin;
  127. },
  128. gatewayToken(state, gatewayToken) {
  129. state.gatewayToken = gatewayToken;
  130. window.localStorage[prefix + 'gatewayToken'] = gatewayToken;
  131. },
  132. isFromWx(state, isFromWx) {
  133. state.isFromWx = isFromWx;
  134. window.localStorage[prefix + 'isFromWx'] = isFromWx;
  135. },
  136. uniPhone(state, uniPhone) {
  137. state.uniPhone = uniPhone;
  138. window.localStorage[prefix + 'uniPhone'] = uniPhone;
  139. },
  140. roleUser(state, roleUser) {
  141. state.roleUser = roleUser;
  142. window.localStorage[prefix + 'roleUser'] = roleUser;
  143. },
  144. deviceType(state, deviceType) {
  145. state.deviceType = deviceType;
  146. window.localStorage[prefix + 'deviceType'] = deviceType;
  147. },
  148. uploadinteval(state, uploadinteval) {
  149. state.uploadinteval = uploadinteval;
  150. window.localStorage[prefix + 'uploadinteval'] = uploadinteval;
  151. },
  152. notJump(state, notJump) {
  153. state.notJump = notJump;
  154. window.localStorage[prefix + 'notJump'] = notJump;
  155. },
  156. showLogin(state, showLogin) {
  157. state.showLogin = showLogin;
  158. window.localStorage[prefix + 'showLogin'] = showLogin;
  159. },
  160. watchRole(state, watchRole) {
  161. state.watchRole = watchRole;
  162. window.localStorage[prefix + 'watchRole'] = watchRole;
  163. },
  164. iotCardTitle(state, iotCardTitle) {
  165. state.iotCardTitle = iotCardTitle;
  166. window.localStorage[prefix + 'iotCardTitle'] = iotCardTitle;
  167. },
  168. fromRuoter(state, fromRuoter) {
  169. state.fromRuoter = fromRuoter;
  170. window.localStorage[prefix + 'fromRuoter'] = fromRuoter;
  171. },
  172. deviceVersion(state, deviceVersion) {
  173. state.deviceVersion = deviceVersion;
  174. window.localStorage[prefix + 'deviceVersion'] = deviceVersion;
  175. },
  176. tabClick(state, tabClick) {
  177. state.tabClick = tabClick;
  178. window.localStorage[prefix + 'tabClick'] = tabClick;
  179. },
  180. personId(state, personId) {
  181. state.personId = personId;
  182. window.localStorage[prefix + 'personId'] = personId;
  183. },
  184. uid(state, uid) {
  185. state.uid = uid;
  186. window.localStorage[prefix + 'uid'] = uid;
  187. }
  188. },
  189. getters: {
  190. authToken: state => {
  191. if (state.authToken != '') {
  192. return state.authToken;
  193. } else {
  194. return window.localStorage[prefix + 'authToken'] == null ? '' : window.localStorage[prefix + 'authToken'];
  195. }
  196. },
  197. ssjlToken: state => {
  198. if (state.ssjlToken != '') {
  199. return state.ssjlToken;
  200. } else {
  201. return window.localStorage[prefix + 'ssjlToken'] == null ? '' : window.localStorage[prefix + 'ssjlToken'];
  202. }
  203. },
  204. userId: state => {
  205. if (state.userId != '') return state.userId;
  206. return window.localStorage[prefix + 'userId'] == null ? '' : window.localStorage[prefix + 'userId'];
  207. },
  208. deviceId: state => {
  209. if (state.deviceId != '') return state.deviceId;
  210. return window.localStorage[prefix + 'deviceId'] == null ? '' : window.localStorage[prefix + 'deviceId'];
  211. },
  212. code: state => {
  213. if (state.code != '') return state.code;
  214. return window.localStorage[prefix + 'code'] == null ? '' : window.localStorage[prefix + 'code'];
  215. },
  216. serialNo: state => {
  217. if (state.serialNo != '') return state.serialNo;
  218. return window.localStorage[prefix + 'serialNo'] == null ? '' : window.localStorage[prefix + 'serialNo'];
  219. },
  220. isAdmin: state => {
  221. if (state.isAdmin != '') return state.isAdmin;
  222. return window.localStorage[prefix + 'isAdmin'] == null ? '' : window.localStorage[prefix + 'isAdmin'];
  223. },
  224. openId: state => {
  225. if (state.openId != '') return state.openId;
  226. return window.localStorage[prefix + 'openId'] == null ? '' : window.localStorage[prefix + 'openId'];
  227. },
  228. bindSerialNo: state => {
  229. if (state.bindSerialNo != '') return state.bindSerialNo;
  230. return window.localStorage[prefix + 'bindSerialNo'] == null ? '' : window.localStorage[prefix + 'bindSerialNo'];
  231. },
  232. loginName: state => {
  233. if (state.loginName != '') return state.loginName;
  234. return window.localStorage[prefix + 'loginName'] == null ? '' : window.localStorage[prefix + 'loginName'];
  235. },
  236. // 圆形围栏和多边形围栏
  237. fenceNameList: state => {
  238. if (isNotNull(state.fenceNameList)) return state.fenceNameList;
  239. else
  240. return window.localStorage[prefix + 'fenceNameList'] == null
  241. ? ''
  242. : window.localStorage[prefix + 'fenceNameList'];
  243. },
  244. familyNameList: state => {
  245. if (isNotNull(state.familyNameList)) return state.familyNameList;
  246. else
  247. return window.localStorage[prefix + 'familyNameList'] == null
  248. ? ''
  249. : window.localStorage[prefix + 'familyNameList'];
  250. },
  251. // currentAddressAndPostion
  252. currentAddressAndPostion: state => {
  253. if (isNotNull(state.currentAddressAndPostion)) return state.currentAddressAndPostion;
  254. else
  255. return window.localStorage[prefix + 'currentAddressAndPostion'] == null
  256. ? ''
  257. : window.localStorage[prefix + 'currentAddressAndPostion'];
  258. },
  259. wxRecAuth: state => {
  260. if (isNotNull(state.wxRecAuth)) return state.wxRecAuth;
  261. else return window.localStorage[prefix + 'wxRecAuth'] == null ? '' : window.localStorage[prefix + 'wxRecAuth'];
  262. },
  263. familyShortKeyList: state => {
  264. if (state.familyShortKeyList != '') return state.familyShortKeyList;
  265. return window.localStorage[prefix + 'familyShortKeyList'] == null
  266. ? ''
  267. : window.localStorage[prefix + 'familyShortKeyList'];
  268. },
  269. isRegister: state => {
  270. if (state.isRegister != '') return state.isRegister;
  271. return window.localStorage[prefix + 'isRegister'] == null ? '' : window.localStorage[prefix + 'isRegister'];
  272. },
  273. isLogin: state => {
  274. if (state.isLogin != '') return state.isLogin;
  275. return window.localStorage[prefix + 'isLogin'] == null ? '' : window.localStorage[prefix + 'isLogin'];
  276. },
  277. gatewayToken: state => {
  278. if (state.gatewayToken != '') return state.gatewayToken;
  279. return window.localStorage[prefix + 'gatewayToken'] == null ? '' : window.localStorage[prefix + 'gatewayToken'];
  280. },
  281. isFromWx: state => {
  282. if (state.isFromWx != '') return state.isFromWx;
  283. return window.localStorage[prefix + 'isFromWx'] == null ? '' : window.localStorage[prefix + 'isFromWx'];
  284. },
  285. uniPhone: state => {
  286. if (state.uniPhone != '') return state.uniPhone;
  287. return window.localStorage[prefix + 'uniPhone'] == null ? '' : window.localStorage[prefix + 'uniPhone'];
  288. },
  289. roleUser: state => {
  290. if (state.roleUser != '') return state.roleUser;
  291. return window.localStorage[prefix + 'roleUser'] == null ? '' : window.localStorage[prefix + 'roleUser'];
  292. },
  293. deviceType: state => {
  294. if (state.deviceType != '') return state.deviceType;
  295. return window.localStorage[prefix + 'deviceType'] == null ? '' : window.localStorage[prefix + 'deviceType'];
  296. },
  297. uploadinteval: state => {
  298. if (state.uploadinteval != '') return state.uploadinteval;
  299. return window.localStorage[prefix + 'uploadinteval'] == null ? '' : window.localStorage[prefix + 'uploadinteval'];
  300. },
  301. notJump: state => {
  302. if (state.notJump != '') return state.notJump;
  303. return window.localStorage[prefix + 'notJump'] == null ? '' : window.localStorage[prefix + 'notJump'];
  304. },
  305. showLogin: state => {
  306. if (state.showLogin != '') return state.showLogin;
  307. return window.localStorage[prefix + 'showLogin'] == null ? '' : window.localStorage[prefix + 'showLogin'];
  308. },
  309. watchRole: state => {
  310. if (state.watchRole != '') return state.watchRole;
  311. return window.localStorage[prefix + 'watchRole'] == null ? '' : window.localStorage[prefix + 'watchRole'];
  312. },
  313. iotCardTitle: state => {
  314. if (state.iotCardTitle != '') return state.iotCardTitle;
  315. return window.localStorage[prefix + 'iotCardTitle'] == null ? '' : window.localStorage[prefix + 'iotCardTitle'];
  316. },
  317. fromRuoter: state => {
  318. if (state.fromRuoter != '') return state.fromRuoter;
  319. return window.localStorage[prefix + 'fromRuoter'] == null ? '' : window.localStorage[prefix + 'fromRuoter'];
  320. },
  321. deviceVersion: state => {
  322. if (state.deviceVersion != '') return state.deviceVersion;
  323. return window.localStorage[prefix + 'deviceVersion'] == null ? '' : window.localStorage[prefix + 'deviceVersion'];
  324. },
  325. tabClick: state => {
  326. if (state.tabClick != '') return state.tabClick;
  327. return window.localStorage[prefix + 'tabClick'] == null ? '' : window.localStorage[prefix + 'tabClick'];
  328. },
  329. personId: state => {
  330. if (state.personId != '') return state.personId;
  331. return window.localStorage[prefix + 'personId'] == null ? '' : window.localStorage[prefix + 'personId'];
  332. },
  333. uid: state => {
  334. if (state.uid != '') return state.uid;
  335. return window.localStorage[prefix + 'uid'] == null ? '' : window.localStorage[prefix + 'uid'];
  336. }
  337. },
  338. actions: {},
  339. modules: {}
  340. });