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

xt_user.js 13KB

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