index.js 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585
  1. import axios from '~plugins/axios'
  2. // 获取品牌详情产品分类信息
  3. function loadBrandCategories({ commit }, params = {}) {
  4. let id = params.id
  5. commit('brandCategories/REQUEST_CATEGORIES', params)
  6. return axios.get(`/api/product/brand/${id}/kinds`)
  7. .then(response => {
  8. commit('brandCategories/GET_CATEGORIES_SUCCESS', response.data)
  9. }, err => {
  10. commit('brandCategories/GET_CATEGORIES_FAILURE', err)
  11. })
  12. }
  13. // 获取品牌详情型号列表数据
  14. function loadBrandComponent({ commit }, params = {}) {
  15. commit('brandComponent/REQUEST_COMPONENT', params)
  16. return axios.get('/api/product/component/list', { params })
  17. .then(response => {
  18. commit('brandComponent/GET_COMPONENT_SUCCESS', response.data)
  19. }, err => {
  20. commit('brandComponent/GET_COMPONENT_FAILURE', err)
  21. })
  22. }
  23. export const actions = {
  24. // 全局服务初始化
  25. nuxtServerInit(store, { params, route, isDev, req }) {
  26. // 检查设备类型
  27. const userAgent = process.server ? req.headers['user-agent'] : navigator.userAgent
  28. const isMobile = /(iPhone|iPad|Opera Mini|Android.*Mobile|NetFront|PSP|BlackBerry|Windows Phone)/ig.test(userAgent)
  29. const cookie = process.server ? req.headers['cookie'] : null
  30. store.commit('option/SET_MOBILE_LAYOUT', isMobile)
  31. store.commit('option/SET_USER_AGENT', userAgent)
  32. store.commit('option/SET_COOKIES', cookie)
  33. // console.log(req.headers.referer)
  34. if (route.query) {
  35. let messageType = route.query.messageType || ''
  36. store.commit('option/GET_MESSAGETYPE', messageType)
  37. }
  38. if (cookie && cookie.length) {
  39. for (let i = 0; i < cookie.length; i++) {
  40. if (cookie[i].indexOf('JSESSIONID') > -1) {
  41. const sessionId = cookie[i]
  42. const first = sessionId.indexOf(';')
  43. const second = sessionId.lastIndexOf(';')
  44. const newSessionId = sessionId.replace(sessionId.substring(first, second), '')
  45. store.commit('option/SET_SESSION_ID', newSessionId)
  46. break
  47. }
  48. }
  49. axios.defaults.headers['cookie'] = store.state.option.cookies + '; ' + store.state.option.sessionId
  50. axios.defaults.headers['User-Agent'] = store.state.option.userAgent
  51. } else {
  52. axios.defaults.headers['cookie'] = ''
  53. axios.defaults.headers['User-Agent'] = ''
  54. }
  55. // 设置跳转的URL
  56. if (!isDev) {
  57. store.commit('option/UPDATE_URL', 'http://www.usoftmall.com')
  58. }
  59. return Promise.all([
  60. // 全局数据
  61. store.dispatch('loadUserInfo'),
  62. store.dispatch('loadProductCounts', { _status: 'actived' }),
  63. store.dispatch('loadHotSearchDevice'),
  64. store.dispatch('loadHotSearchBrand'),
  65. store.dispatch('loadNewFloors')
  66. ])
  67. },
  68. // 获取用户信息
  69. loadUserInfo({ commit }) {
  70. commit('option/REQUEST_USER_INFO')
  71. return axios.get('/user/authentication')
  72. .then(response => {
  73. if (response.data.userName) {
  74. let ens = response.data.enterprises
  75. if (ens && ens.length) {
  76. response.data.enterprise = ens.find(item => item.current) || { enName: '个人账户' }
  77. } else {
  78. response.data.enterprise = { enName: '个人账户' }
  79. }
  80. }
  81. commit('option/REQUEST_USER_INFO_SUCCESS', response.data)
  82. }, err => {
  83. commit('option/REQUEST_USER_INFO_FAILURE', err)
  84. })
  85. },
  86. loadUserWithAdmin ({commit}, params = {}) {
  87. commit('option/REQUEST_ADMIN_INFO')
  88. return axios.get('/basic/user/getUserByUU', {params: params})
  89. .then(response => {
  90. commit('option/REQUEST_ADMIN_INFO_SUCCESS', response.data)
  91. }, err => {
  92. commit('option/REQUEST_ADMIN_INFO_FAILURE', err)
  93. })
  94. },
  95. // 用户退出
  96. logout({ commit }) {
  97. return axios.get('/logout')
  98. .then(response => {
  99. commit('option/REQUEST_LOGOUT_SUCCESS', response.data)
  100. })
  101. },
  102. // 获取楼层配置
  103. loadFloors({ commit }) {
  104. commit('floor/REQUEST_LIST')
  105. return axios.get('/api/floors/home')
  106. .then(response => {
  107. commit('floor/GET_LIST_SUCCESS', response.data)
  108. }, err => {
  109. commit('floor/GET_LIST_FAILURE', err)
  110. })
  111. },
  112. // 批量获取产品信息
  113. loadBatchCommodities({ commit }, params = {}) {
  114. commit('floor/REQUEST_EXPANDLIST')
  115. return axios.post('/api/commodity/detail', params.batchCodeList)
  116. .then(response => {
  117. commit('floor/GET_EXPANDLIST_SUCCESS', response.data)
  118. }, err => {
  119. commit('floor/GET_EXPANDLIST_FAILURE', err)
  120. })
  121. },
  122. // 获取轮播配置
  123. loadBanners({ commit }, params = {}) {
  124. commit('carousel/REQUEST_BANNER')
  125. return axios.get(`/cmsApi?method=queryContentPage&module=${params.type}&orderBy=order_number%20ASC`)
  126. .then(response => {
  127. commit('carousel/GET_BANNER_SUCCESS', response.data)
  128. }, err => {
  129. commit('carousel/GET_BANNER_FAILURE', err)
  130. })
  131. },
  132. // 获取新楼层配置
  133. loadNewFloors({ commit }) {
  134. commit('floor/REQUEST_NEWLIST')
  135. return axios.get('/api/floors/home-v3')
  136. .then(response => {
  137. commit('floor/GET_NEWLIST_SUCCESS', response.data)
  138. }, err => {
  139. commit('floor/GET_NEWLIST_FAILURE', err)
  140. })
  141. },
  142. // 获取楼层配置f1
  143. loadNewFloorsF1({ commit }) {
  144. commit('floor/REQUEST_LISTF1')
  145. return axios.get(`/cmsApi?method=queryContentPage&module=home_floor_f1&orderBy=order_number%20ASC`)
  146. .then(response => {
  147. commit('floor/GET_LIST_SUCCESSF1', response.data)
  148. }, err => {
  149. commit('floor/GET_LIST_FAILUREF1', err)
  150. })
  151. },
  152. // 获取楼层配置f2
  153. loadNewFloorsF2({ commit }) {
  154. commit('floor/REQUEST_LISTF2')
  155. return axios.get(`/cmsApi?method=queryContentPage&module=home_floor_f2&orderBy=order_number%20ASC`)
  156. .then(response => {
  157. commit('floor/GET_LIST_SUCCESSF2', response.data)
  158. }, err => {
  159. commit('floor/GET_LIST_FAILUREF2', err)
  160. })
  161. },
  162. // 获取楼层配置f3
  163. loadNewFloorsF3({ commit }) {
  164. commit('floor/REQUEST_LISTF3')
  165. return axios.get(`/cmsApi?method=queryContentPage&module=home_floor_f3&orderBy=order_number%20ASC`)
  166. .then(response => {
  167. commit('floor/GET_LIST_SUCCESSF3', response.data)
  168. }, err => {
  169. commit('floor/GET_LIST_FAILUREF3', err)
  170. })
  171. },
  172. // 获取楼层配置f4
  173. loadNewFloorsF4({ commit }) {
  174. commit('floor/REQUEST_LISTF4')
  175. return axios.get(`/cmsApi?method=queryContentPage&module=home_floor_f4&orderBy=order_number%20ASC`)
  176. .then(response => {
  177. commit('floor/GET_LIST_SUCCESSF4', response.data)
  178. }, err => {
  179. commit('floor/GET_LIST_FAILUREF4', err)
  180. })
  181. },
  182. // 获取楼层配置f5
  183. loadNewFloorsF5({ commit }) {
  184. commit('floor/REQUEST_LISTF5')
  185. return axios.get(`/cmsApi?method=queryContentPage&module=home_floor_f5&orderBy=order_number%20ASC`)
  186. .then(response => {
  187. commit('floor/GET_LIST_SUCCESSF5', response.data)
  188. }, err => {
  189. commit('floor/GET_LIST_FAILUREF5', err)
  190. })
  191. },
  192. // 获取子器件类目
  193. loadProductKinds({ commit }, params = {}) {
  194. let id = params.id
  195. commit('product/kind/REQUEST_KIND', params)
  196. return axios.get(`/api/product/kind/${id}/children`)
  197. .then(response => {
  198. commit('product/kind/GET_KIND_SUCCESS', { id, result: response.data })
  199. }, err => {
  200. commit('product/kind/GET_KIND_FAILURE', { id, err })
  201. })
  202. },
  203. // 获取全部子器件类目
  204. loadAllProductKinds({ commit }, params = {}) {
  205. let id = params.id
  206. commit('product/kind/REQUEST_KIND', params)
  207. return axios.get(`/api/product/kind/${id}/children_all`)
  208. .then(response => {
  209. commit('product/kind/GET_KIND_SUCCESS', { id, result: response.data })
  210. }, err => {
  211. commit('product/kind/GET_KIND_FAILURE', { id, err })
  212. })
  213. },
  214. // 获取首页新闻
  215. loadNewsSnapshot({ commit }, params = {}) {
  216. commit('news/REQUEST_SNAPSHOT')
  217. return axios.get('/api/news/created', { params })
  218. .then(response => {
  219. commit('news/GET_SNAPSHOT_SUCCESS', response.data)
  220. }, err => {
  221. commit('news/GET_SNAPSHOT_FAILURE', err)
  222. })
  223. },
  224. // 获取器件统计信息
  225. loadProductCounts({ commit }, params = {}) {
  226. commit('product/common/REQUEST_COUNTS')
  227. return axios.get('/api/product/commoncount', { params })
  228. .then(response => {
  229. commit('product/common/GET_COUNTS_SUCCESS', response.data)
  230. }, err => {
  231. commit('product/common/GET_COUNTS_FAILURE', err)
  232. })
  233. },
  234. // 搜索关键字
  235. searchKeywords({ commit }, params = {}) {
  236. commit('search/REQUEST_KEYWORDS')
  237. return axios.get('/search/similarKeywords', { params })
  238. .then(response => {
  239. commit('search/GET_KEYWORDS_SUCCESS', response.data)
  240. }, err => {
  241. commit('search/GET_KEYWORDS_FAILURE', err)
  242. })
  243. },
  244. // 搜索关键字列表
  245. searchKeywordsList({ commit }, params = {}) {
  246. commit('search/REQUEST_KEYWORDSLIST')
  247. return axios.get('/search/201819', { params })
  248. .then(response => {
  249. commit('search/GET_KEYWORDSLIST_SUCCESS', response.data)
  250. }, err => {
  251. commit('search/GET_KEYWORDSLIST_FAILURE', err)
  252. })
  253. },
  254. resetSearchKeywords({ commit }) {
  255. commit('search/RESET_KEYWORDS')
  256. },
  257. // 热卖推荐页面
  258. loadProductHot({ commit }, params = {}) {
  259. commit('original/REQUEST_HOT')
  260. return axios.get('/api/commodity/latest', { params })
  261. .then(response => {
  262. commit('original/GET_HOT_SUCCESS', response.data)
  263. }, err => {
  264. commit('original/GET_HOT_FAILURE', err)
  265. })
  266. },
  267. // 器件详情页面
  268. // 获得器件详情信息
  269. loadComponentDetail({ commit }, params = {}) {
  270. let id = params.id
  271. commit('componentDetail/REQUEST_DETAIL', params)
  272. return axios.get(`/api/product/component/${id}`)
  273. .then(response => {
  274. commit('componentDetail/GET_DETAIL_SUCCESS', response.data)
  275. if (response.data) {
  276. commit('componentMenu/REQUEST_MENU', params)
  277. return axios.get(`/api/product/kind/structing/${response.data.kindid}`)
  278. .then(response => {
  279. commit('componentMenu/GET_MENU_SUCCESS', response.data)
  280. }, err => {
  281. commit('componentMenu/GET_MENU_FAILURE', err)
  282. })
  283. }
  284. }, err => {
  285. commit('componentDetail/GET_DETAIL_FAILURE', err)
  286. })
  287. },
  288. // 获取器件详情页面包屑导航
  289. loadComponentMenu({ commit }, params = {}) {
  290. let pid = params.id
  291. commit('componentMenu/REQUEST_MENU', params)
  292. return axios.get(`/api/product/kind/structing/${pid}`)
  293. .then(response => {
  294. commit('componentMenu/GET_MENU_SUCCESS', response.data)
  295. }, err => {
  296. commit('componentMenu/GET_MENU_FAILURE', err)
  297. })
  298. },
  299. // 器件详情页选择商家
  300. loadComponentStore({ commit }, params = {}) {
  301. let id = params.uuid
  302. commit('componentStore/REQUEST_STORE', params)
  303. return axios.get(`/api/store-service/stores/uuid/${id}`)
  304. .then(response => {
  305. commit('componentStore/GET_STORE_SUCCESS', response.data)
  306. }, err => {
  307. commit('componentStore/GET_STORE_FAILURE', err)
  308. })
  309. },
  310. // 器件详情页商家列表
  311. loadComponentInformation({ commit }, params = {}) {
  312. // let params = {}
  313. // let filter = {uuid: uuid.uuid, ignoreUMall: false, ignoreStore: false}
  314. // // let sorting = {minPriceRMB: 'ASC'}
  315. // params.filter = filter
  316. // // params.sorting = sorting
  317. // params.page = pageParams.page
  318. // params.count = pageParams.count
  319. commit('componentInformation/REQUEST_INFORMATION')
  320. return axios.get('/api/commodity/goods/page', { params })
  321. .then(response => {
  322. commit('componentInformation/GET_INFORMATION_SUCCESS', response.data)
  323. }, err => {
  324. commit('componentInformation/GET_INFORMATION_FAILURE', err)
  325. })
  326. },
  327. // 获取库存寄售店铺storeid
  328. getUmallStoreId({ commit }) {
  329. commit('componentUmallStoreId/REQUEST_STOREID')
  330. return axios.get('/api/store-service/stores/UmallStore')
  331. .then(response => {
  332. commit('componentUmallStoreId/GET_STOREID_SUCCESS', response.data)
  333. }, err => {
  334. commit('componentUmallStoreId/GET_STOREID_FAILURE', err)
  335. })
  336. },
  337. // 品牌详情页面
  338. // 获得品牌详情信息
  339. loadBrandDetail({ commit, dispatch }, params = {}) {
  340. let id = params.id
  341. commit('brandDetail/REQUEST_DETAIL', params)
  342. return axios.get(`/api/product/brand/${id}`)
  343. .then(response => {
  344. let brand = response.data || {}
  345. commit('brandDetail/GET_DETAIL_SUCCESS', response.data)
  346. return Promise.all([
  347. loadBrandCategories({ commit }, { id: brand.id }),
  348. loadBrandComponent({ commit }, { count: 10, filter: { brandid: brand.id }, page: 1 })
  349. ])
  350. }, err => {
  351. commit('brandDetail/GET_DETAIL_FAILURE', err)
  352. })
  353. },
  354. // 获取品牌详情产品分类信息
  355. loadBrandCategories({ commit }, params = {}) {
  356. let id = params.id
  357. commit('brandCategories/REQUEST_CATEGORIES', params)
  358. return axios.get(`/api/product/brand/${id}/kinds`)
  359. .then(response => {
  360. commit('brandCategories/GET_CATEGORIES_SUCCESS', response.data)
  361. }, err => {
  362. commit('brandCategories/GET_CATEGORIES_FAILURE', err)
  363. })
  364. },
  365. // 获取品牌详情型号列表数据
  366. loadBrandComponent({ commit }, params = {}) {
  367. commit('brandComponent/REQUEST_COMPONENT', params)
  368. return axios.get('/api/product/component/list', { params })
  369. .then(response => {
  370. commit('brandComponent/GET_COMPONENT_SUCCESS', response.data)
  371. }, err => {
  372. commit('brandComponent/GET_COMPONENT_FAILURE', err)
  373. })
  374. },
  375. // 获取品牌详情分页信息
  376. loadBrandPages({ commit }, params = {}) {
  377. commit('brandPages/REQUEST_PAGES', params)
  378. return axios.get('/api/product/PAGES/list', { params })
  379. .then(response => {
  380. commit('brandPages/GET__SUCCESS', response.data)
  381. }, err => {
  382. commit('brandPages/GET_COMPONENT_FAILURE', err)
  383. })
  384. },
  385. // 留言板
  386. // 提交了留言板信息
  387. uploadMessageBoardInformation({ commit }, params) {
  388. commit('messageBoard/REQUEST_INFORMATION')
  389. return axios.post('/api/operation/messageBoard', params)
  390. .then(response => {
  391. commit('messageBoard/GET_INFORMATION_SUCCESS', response.data)
  392. }, err => {
  393. commit('messageBoard/GET_INFORMATION_FAILURE', err)
  394. })
  395. },
  396. // 验证用户是否登录
  397. userIsLogin({ commit }) {
  398. commit('messageBoardIsLogin/REQUEST_LOGIN')
  399. return axios.get('/user/authentication')
  400. .then(response => {
  401. commit('messageBoardIsLogin/GET_LOGIN_SUCCESS', response.data)
  402. }, err => {
  403. commit('messageBoardIsLogin/GET_LOGIN_FAILURE', err)
  404. })
  405. },
  406. // 获取留言记录信息
  407. getMessageBoardInformation({ commit }, params) {
  408. let sorting = { createDate: 'DESC' }
  409. params.sorting = sorting
  410. commit('messageBoardInformation/REQUEST_INFORMATION', params)
  411. return axios.get('/operation/messageBoard/pageInfo/user', { params })
  412. .then(response => {
  413. commit('messageBoardInformation/GET_INFORMATION_SUCCESS', response.data)
  414. }, err => {
  415. commit('messageBoardInformation/GET_INFORMATION_FAILURE', err)
  416. })
  417. },
  418. // 获取帮助中心信息
  419. loadHelpSnapsho({ commit }, params = {}) {
  420. commit('help/REQUEST_SNAPSHO')
  421. return axios.get('/api/help-service/helps', { params })
  422. .then(response => {
  423. commit('help/GET_SNAPSHO_SUCCESS', response.data)
  424. }, err => {
  425. commit('help/GET_SNAPSHO_FAILURE', err)
  426. })
  427. },
  428. // 获取帮助中心二级菜单
  429. loadHelpList({ commit }, params = {}) {
  430. commit('help/REQUEST_HELPLIST')
  431. return axios.get('/api/help-service/issues', { params })
  432. .then(response => {
  433. commit('help/GET_HELPLIST_SUCCESS', response.data)
  434. }, err => {
  435. commit('help/GET_HELPLIST_FAILURE', err)
  436. })
  437. },
  438. // 获取帮助中心名称
  439. loadHelpTitle({ commit }, params = {}) {
  440. let id = params.id
  441. commit('help/REQUEST_TITLE')
  442. return axios.get(`/api/help-service/${id}`, { params })
  443. .then(response => {
  444. commit('help/GET_TITLE_SUCCESS', response.data)
  445. }, err => {
  446. commit('help/GET_TITLE_FAILURE', err)
  447. })
  448. },
  449. // 获取详情
  450. loadHelpDetail({ commit }, params = {}) {
  451. let id = params.id
  452. commit('help/REQUEST_DETAIL')
  453. return axios.get(`/api/help-service/issues/${id}`, { params })
  454. .then(response => {
  455. commit('help/GET_DETAIL_SUCCESS', response.data)
  456. let id = response.data.navId
  457. commit('help/REQUEST_TITLE')
  458. return axios.get(`/api/help-service/${id}`)
  459. .then(response => {
  460. commit('help/GET_TITLE_SUCCESS', response.data)
  461. }, err => {
  462. commit('help/GET_TITLE_FAILURE', err)
  463. })
  464. }, err => {
  465. commit('help/GET_DETAIL_FAILURE', err)
  466. })
  467. },
  468. // 获取最多搜索量的 器件
  469. loadHotSearchDevice({ commit }) {
  470. commit('hotSearchDevice/REQUEST_HOT')
  471. return axios.get('/api/product/component/mostSearchComponent')
  472. .then(response => {
  473. commit('hotSearchDevice/GET_HOT_SUCCESS', response.data)
  474. }, err => {
  475. commit('hotSearchDevice/GET_HOT_FAILURE', err)
  476. })
  477. },
  478. // 获取最多搜索量的 品牌
  479. loadHotSearchBrand({ commit }) {
  480. commit('hotSearchBrand/REQUEST_HOT')
  481. return axios.get('/api/product/brand/mostSearchBrands')
  482. .then(response => {
  483. commit('hotSearchBrand/GET_HOT_SUCCESS', response.data)
  484. }, err => {
  485. commit('hotSearchBrand/GET_HOT_FAILURE', err)
  486. })
  487. },
  488. // 获取用户开店信息
  489. loadStoreStatus({ commit }, params = {}) {
  490. commit('option/REQUEST_STORE_STATUS')
  491. return axios.get('/store-service/stores', { params: params })
  492. .then(response => {
  493. commit('option/REQUEST_STORE_STATUS_SUCCESS', response.data)
  494. }, err => {
  495. commit('option/REQUEST_STORE_STATUS_FAILURE', err)
  496. })
  497. },
  498. // 获取首页悬浮计数器交易金额
  499. loadAllCount ({commit}, params) {
  500. commit('count/REQUEST_ALLCOUNT')
  501. return axios.get('/api/product/commoncount', {params})
  502. .then(res => {
  503. commit('count/GET_ALLCOUNT_SUCCESS', res.data)
  504. }, (err) => {
  505. commit('count/GET_ALLCOUNT_FAILURE', err)
  506. })
  507. },
  508. // 获取首页悬浮计数器询价单
  509. loadInquirySheet ({commit}, params) {
  510. commit('count/REQUEST_INQUIRYSHEET')
  511. return axios.get('/inquiry/public/getPurcInquiryItemCountByMonth', {params})
  512. .then(res => {
  513. commit('count/GET_INQUIRYSHEET_SUCCESS', res.data)
  514. }, (err) => {
  515. commit('count/GET_INQUIRYSHEET_FAILURE', err)
  516. })
  517. },
  518. loadInquirySheetLast ({commit}, params) {
  519. commit('count/REQUEST_INQUIRYSHEETLAST')
  520. return axios.get('/inquiry/public/getPurcInquiryItemCountByMonth', {params})
  521. .then(res => {
  522. commit('count/GET_INQUIRYSHEETLAST_SUCCESS', res.data)
  523. }, (err) => {
  524. commit('count/GET_INQUIRYSHEETLAST_FAILURE', err)
  525. })
  526. },
  527. // 保存微信信息
  528. GerWechatInfo({ commit }, params = {}) {
  529. let id = params.openId
  530. console.log('openid:' + id)
  531. commit('option/REQUEST_WECHATINFO_STATUS')
  532. return axios.get('/wx/getWxUserInfo', { params: params })
  533. .then(response => {
  534. let Userinfo = localStorage.getItem('USOFTMALLWECHATINFO')
  535. Userinfo = Userinfo && JSON.parse(Userinfo) || {}
  536. localStorage.removeItem('USOFTMALLWECHATINFO')
  537. if (response.data.status >= 0) { // 请求到数据
  538. if (id !== '' && id && id !== undefined) { // 传了openid
  539. Userinfo.openid = id
  540. } else { // 没有openid
  541. Userinfo.headimgurl = response.data.headimgurl
  542. Userinfo.nickname = response.data.nickname
  543. Userinfo.openid = response.data.openid
  544. }
  545. if (response.data.status === 1) { // 已绑定
  546. Userinfo.userAccount = response.data.userAccount
  547. }
  548. Userinfo.status = response.data.status
  549. Userinfo.enterprises = response.data.enterprises
  550. localStorage.setItem('USOFTMALLWECHATINFO', JSON.stringify(Userinfo))
  551. commit('option/REQUEST_WECHATINFO_STATUS_SUCCESS', Userinfo)
  552. } else {
  553. // localStorage.removeItem('USOFTMALLWECHATINFO')
  554. }
  555. }, err => {
  556. localStorage.removeItem('USOFTMALLWECHATINFO')
  557. commit('option/REQUEST_WECHATINFO_STATUS_FAILURE', err)
  558. })
  559. },
  560. // 获取品牌中心轮播图
  561. loadBrandCarousel ({ commit }) {
  562. commit('carousel/REQUEST_BRANDCAROUSEL')
  563. return axios.get('/cmsApi?method=queryContentPage&module=brandCenter_littleSlideshow')
  564. .then(response => {
  565. commit('carousel/GET_BRANDCAROUSEL_SUCCESS', response.data)
  566. }, err => {
  567. commit('carousel/GET_BRANDCAROUSEL_FAILURE', err)
  568. })
  569. },
  570. // 获取品牌中心首屏背景图
  571. loadBrandBanner ({ commit }) {
  572. commit('product/banner/REQUEST_BRANDBANNER')
  573. return axios.get('/cmsApi?method=queryContentPage&module=brandCenter_firstScreen')
  574. .then(response => {
  575. commit('product/banner/GET_BRANDBANNER_SUCCESS', response.data)
  576. }, err => {
  577. commit('product/banner/GET_BRANDBANNER_FAILURE', err)
  578. })
  579. }
  580. }