Elizabeth's proactive approach involves introducing urinal toilet attachment , an ingenious concept that optimizes space and functionality.

xt_user.js 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407
  1. import { modifyAdminInfo, verifyToken } from '@/api/login/login'
  2. // import { mapGetters } from 'vuex'
  3. // import { getToken, setToken, removeToken } from '@/utils/auth'
  4. import { cacheAdminUserInfo, getAdminUserInfoCache, removeAdminUserInfoCache } from '@/utils/admin_info_cache'
  5. import { getFiledConfigList, setFiledConfigList } from '@/utils/data_config' // getConfigList from sessionStorage
  6. const xt_user = {
  7. state: {
  8. org_id: 0,
  9. schedule_type_selected: 0,
  10. zone_selected: 0,
  11. patient_state_selected: 0,
  12. treat_state_selected: 0,
  13. selected_date:new Date(),
  14. app_id: 0,
  15. user: {
  16. id: 0,
  17. mobile: '',
  18. avatar: '',
  19. user_name: '',
  20. intro: '',
  21. user_type: 0, // 用户类型(1.管理员;2.医生;3.护士;4.运营)
  22. user_title: 0 // 用户职称(1.医士;2.医师;3.住院医师;4.主治医师;5.副主任医师;6.主任医师;7.护士;8.护师;9.主管护师;10.副主任护师;11.主任护师;12.运营专员;13.运营主管)
  23. },
  24. template_info: {
  25. id: 0,
  26. org_id: 0,
  27. template_id: 0
  28. },
  29. org: {
  30. id: 0,
  31. org_name: '',
  32. org_short_name: '',
  33. org_intro: '',
  34. org_logo: '',
  35. province: 0,
  36. city: 0,
  37. district: 0,
  38. address: ''
  39. },
  40. subscibe: {
  41. id: 0,
  42. period_start: 0,
  43. period_end: 0,
  44. state: 2, // 1正版(标准) 2试用(免费) 3过期(或其他无效状态) 8 专业 9 永久,
  45. patients: 20 // 患者数
  46. },
  47. scrm_role_exist: false,
  48. cdm_role_exist: false,
  49. mall_role_exist: false,
  50. // 示例: ['', '',]
  51. urlfors: [],
  52. fileds: []
  53. },
  54. mutations: {
  55. SET_SCHEDULE_TYPE_SELECTED: (state, schedule_type_selected) => {
  56. state.schedule_type_selected = schedule_type_selected
  57. },
  58. SET_ZONE_SELECTED: (state, zone_selected) => {
  59. state.zone_selected = zone_selected
  60. },
  61. SET_PAtIENT_STATE_SELECTED: (state, patient_state_selected) => {
  62. state.patient_state_selected = patient_state_selected
  63. },
  64. SET_TREAT_STATE_SELECTED: (state, treat_state_selected) => {
  65. state.treat_state_selected = treat_state_selected
  66. },
  67. SET_SELECTED_DATE: (state, selected_date) => {
  68. state.selected_date = selected_date
  69. },
  70. SET_FILEDS_LIST: (state, configlist) => {
  71. state.fileds = configlist
  72. },
  73. // cur_info: { user, cur_org_id, cur_app_id }
  74. SET_CURRENT_INFO: (state, cur_info) => {
  75. state.user.id = cur_info.user.id
  76. state.user.mobile = cur_info.user.mobile
  77. state.user.avatar = cur_info.user.avatar
  78. state.user.user_name = cur_info.user.user_name
  79. state.user.intro = cur_info.user.intro
  80. state.user.user_type = cur_info.user.user_type
  81. state.user.user_title = cur_info.user.user_title
  82. state.org_id = cur_info.cur_org_id
  83. state.app_id = cur_info.cur_app_id
  84. state.org.id = cur_info.org.id
  85. state.org.org_name = cur_info.org.org_name
  86. state.org.org_short_name = cur_info.org.org_short_name
  87. state.org.org_logo = cur_info.org.org_logo
  88. state.org.org_intro = cur_info.org.org_intro
  89. state.org.province = cur_info.org.province
  90. state.org.city = cur_info.org.city
  91. state.org.district = cur_info.org.district
  92. state.org.address = cur_info.org.address
  93. state.subscibe.id = cur_info.subscibe.id
  94. state.subscibe.period_start = cur_info.subscibe.period_start
  95. state.subscibe.period_end = cur_info.subscibe.period_end
  96. state.subscibe.state = cur_info.subscibe.state
  97. state.scrm_role_exist = cur_info.scrm_role_exist
  98. state.cdm_role_exist = cur_info.cdm_role_exist
  99. state.mall_role_exist = cur_info.mall_role_exist
  100. state.template_info.id = cur_info.template_info.id
  101. state.template_info.org_id = cur_info.template_info.org_id
  102. state.template_info.template_id = cur_info.template_info.template_id
  103. },
  104. SET_FILEDS: (state, payload) => {
  105. state.fileds = payload.fileds
  106. },
  107. SET_URLFORS: (state, payload) => {
  108. state.urlfors = payload.urlfors
  109. },
  110. MODIFY_USER_INFO: (state, payload) => {
  111. state.user.user_name = payload.user_name
  112. state.user.avatar = payload.avatar
  113. },
  114. MODIFY_ORG_INFO: (state, payload) => {
  115. state.org.org_name = payload.org_name
  116. state.org.org_short_name = payload.org_short_name
  117. },
  118. SET_SUBSCIBE_PATIENT: (state) => {
  119. state.subscibe.patients += 1
  120. },
  121. CLEAR_USER_INFO: (state) => {
  122. state.org_id = 0
  123. state.app_id = 0
  124. state.user.id = 0
  125. state.user.mobile = ''
  126. state.user.avatar = ''
  127. state.user.user_name = ''
  128. state.user.intro = ''
  129. state.user_type = ''
  130. state.user_title = ''
  131. state.org.id = 0
  132. state.org.org_name = ''
  133. state.org.org_short_name = ''
  134. state.org.org_logo = ''
  135. state.org.org_intro = ''
  136. state.org.province = 0
  137. state.org.city = 0
  138. state.org.district = 0
  139. state.org.address = ''
  140. state.subscibe.id = 0
  141. state.subscibe.period_start = 0
  142. state.subscibe.period_end = 0
  143. state.subscibe.state = 3
  144. state.subscibe.patients = 0
  145. state.scrm_role_exist = false
  146. state.cdm_role_exist = false
  147. state.mall_role_exist = false
  148. state.template_info.id = 0
  149. state.template_info.org_id = 0
  150. state.template_info.template_id = 1
  151. state.urlfors = []
  152. state.fileds = []
  153. }
  154. },
  155. getters: {
  156. current_role_urls: state => {
  157. return state.urlfors
  158. }
  159. },
  160. actions: {
  161. SetScheduleTypeSelected({ commit }, schedule_type_selected) {
  162. commit('SET_SCHEDULE_TYPE_SELECTED', schedule_type_selected)
  163. },
  164. SetZoneSelected({ commit }, zone_selected) {
  165. commit('SET_ZONE_SELECTED', zone_selected)
  166. },
  167. SetPatientStateSelected({ commit }, patient_state_selected) {
  168. commit('SET_PAtIENT_STATE_SELECTED', patient_state_selected)
  169. },
  170. SetTreatStateSelected({ commit }, treat_state_selected) {
  171. commit('SET_TREAT_STATE_SELECTED', treat_state_selected)
  172. },
  173. SetSelectedDate({ commit }, selected_date) {
  174. commit('SET_SELECTED_DATE', selected_date)
  175. },
  176. SetSubscibePatients({
  177. commit,
  178. state
  179. }) {
  180. commit('SET_SUBSCIBE_PATIENT')
  181. },
  182. VerifyToken({
  183. commit,
  184. state
  185. }, token) {
  186. // console.log('验证 token 之前:token = ' + token)
  187. return new Promise((resolve, reject) => {
  188. var cacheInfo = getAdminUserInfoCache()
  189. var fileds = getFiledConfigList()
  190. var infoJSON = JSON.parse(fileds)
  191. commit('SET_FILEDS', {
  192. fileds: infoJSON
  193. })
  194. // console.log('登录信息缓存:', cacheInfo)
  195. verifyToken(token).then(response => {
  196. if (response.data.state === 1) {
  197. // alert('验证通过')
  198. // console.log('验证通过')
  199. var data = response.data.data
  200. this.commit('SET_CURRENT_INFO', {
  201. user: data.user,
  202. cur_org_id: data.current_org_id,
  203. cur_app_id: data.current_app_id,
  204. org: data.org,
  205. subscibe: data.subscibe,
  206. template_info: data.template_info,
  207. scrm_role_exist: data.scrm_role_exist,
  208. cdm_role_exist: data.cdm_role_exist,
  209. mall_role_exist: data.mall_role_exist
  210. })
  211. const urlfors = data.urlfors
  212. if (data.cdm_role_exist == true) {
  213. console.log('有')
  214. urlfors.push('/slow')
  215. this.commit('SET_URLFORS', {
  216. urlfors: urlfors
  217. })
  218. } else {
  219. this.commit('SET_URLFORS', {
  220. urlfors: data.urlfors
  221. })
  222. }
  223. if (data.scrm_role_exist == true) {
  224. urlfors.push('/scrm')
  225. this.commit('SET_URLFORS', {
  226. urlfors: urlfors
  227. })
  228. } else {
  229. this.commit('SET_URLFORS', {
  230. urlfors: data.urlfors
  231. })
  232. }
  233. if (data.mall_role_exist == true) {
  234. console.log('有')
  235. urlfors.push('/shop')
  236. this.commit('SET_URLFORS', {
  237. urlfors: urlfors
  238. })
  239. } else {
  240. this.commit('SET_URLFORS', {
  241. urlfors: data.urlfors
  242. })
  243. }
  244. // this.commit('SET_URLFORS', {
  245. // urlfors: data.urlfors
  246. // })
  247. commit('SET_FILEDS', {
  248. fileds: data.fileds
  249. })
  250. setFiledConfigList(JSON.stringify(data.fileds))
  251. cacheAdminUserInfo(JSON.stringify(data))
  252. resolve(data.user.id)
  253. } else {
  254. alert('请求失败:' + response.data.msg)
  255. reject({
  256. msg: response.data.msg,
  257. code: response.data.code
  258. })
  259. }
  260. })
  261. })
  262. },
  263. ModifyAdminUserInfo({
  264. commit,
  265. state
  266. }, params) {
  267. commit('MODIFY_USER_INFO', {
  268. user_name: params.user_name,
  269. avatar: params.avatar
  270. })
  271. cacheAdminUserInfo(
  272. JSON.stringify({
  273. user: state.user,
  274. org: state.org,
  275. current_org_id: state.org_id,
  276. current_app_id: state.app_id,
  277. urlfors: state.urlfors,
  278. subscibe: state.subscibe,
  279. template_info: state.template_info,
  280. scrm_role_exist: state.scrm_role_exist,
  281. cdm_role_exist: state.cdm_role_exist,
  282. mall_role_exist: state.mall_role_exist
  283. })
  284. )
  285. },
  286. ModifyOrgInfo({
  287. commit,
  288. state
  289. }, params) {
  290. commit('MODIFY_ORG_INFO', {
  291. org_name: params.org_name,
  292. org_short_name: params.org_short_name
  293. })
  294. cacheAdminUserInfo(
  295. JSON.stringify({
  296. user: state.user,
  297. org: state.org,
  298. current_org_id: state.org_id,
  299. current_app_id: state.app_id,
  300. urlfors: state.urlfors,
  301. subscibe: state.subscibe,
  302. template_info: state.template_info,
  303. scrm_role_exist: state.scrm_role_exist,
  304. cdm_role_exist: state.cdm_role_exist,
  305. mall_role_exist: state.mall_role_exist
  306. })
  307. )
  308. },
  309. // InitAdminUserInfo( {commit, state} ) {
  310. // var cacheInfo = getAdminUserInfoCache()
  311. // console.log("登录信息缓存:", cacheInfo)
  312. // if (cacheInfo != null && cacheInfo.length > 0) {
  313. // var infoJSON = JSON.parse(cacheInfo)
  314. // console.log(infoJSON)
  315. // commit('SET_CURRENT_INFO', {
  316. // user: infoJSON.user,
  317. // cur_org_id: infoJSON.current_org_id,
  318. // cur_app_id: infoJSON.current_app_id,
  319. // org: infoJSON.org,
  320. // })
  321. // commit('SET_URLFORS', {
  322. // urlfors: infoJSON.urlfors
  323. // })
  324. // }
  325. // }
  326. // 登出
  327. FrontendLogout({
  328. commit
  329. }) {
  330. commit('CLEAR_USER_INFO')
  331. removeAdminUserInfoCache()
  332. }, updateFiledConfigList({ commit }, object) {
  333. var oldFiledList = getFiledConfigList()
  334. console.log('oldFiledList', oldFiledList)
  335. var infoJSON = JSON.parse(oldFiledList)
  336. console.log(object)
  337. return new Promise((resolve, reject) => {
  338. for (let i = 0; i < infoJSON.length; i++) {
  339. if (infoJSON[i].id == object.id) {
  340. infoJSON[i].is_show = object.is_show
  341. }
  342. }
  343. setFiledConfigList(JSON.stringify(infoJSON))
  344. commit('SET_FILEDS_LIST', infoJSON)
  345. resolve()
  346. })
  347. }, updateAllFiledConfigList({ commit }, object) {
  348. console.log(object)
  349. var oldFiledList = getFiledConfigList()
  350. var infoJSON = JSON.parse(oldFiledList)
  351. return new Promise((resolve, reject) => {
  352. infoJSON = object
  353. console.log(infoJSON)
  354. setFiledConfigList(JSON.stringify(infoJSON))
  355. commit('SET_FILEDS_LIST', infoJSON)
  356. resolve()
  357. })
  358. }, ModifyAdminUserOrgInfo({ commit, state }, obj) {
  359. this.commit('SET_CURRENT_INFO', obj)
  360. }, ModifyUrlInfo({ commit, state }, obj) {
  361. this.commit('SET_URLFORS', obj)
  362. }, ModifyFiled({ commit, state }, obj) {
  363. commit('SET_FILEDS', obj)
  364. }
  365. }
  366. }
  367. export default xt_user