tpl.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import { getTplList } from '@/api/rental'
  2. import { authDB } from '@/db'
  3. const state = {
  4. comment: {},
  5. province: {}
  6. }
  7. const mutations = {
  8. SET_PROVINCE: (state, province) => {
  9. authDB.set('province', province)
  10. state.province = province
  11. },
  12. SET_COMMENT: (state, comment) => {
  13. authDB.set('comment', comment)
  14. state.comment = comment
  15. },
  16. SET_WEBSITE: (state, website) => {
  17. authDB.set('website', website)
  18. state.website = website
  19. }
  20. }
  21. const actions = {
  22. // get user info
  23. getTplList({ commit, state }) {
  24. return new Promise((resolve, reject) => {
  25. getTplList().then(response => {
  26. if (!response) {
  27. reject('Verification failed, please Login again.')
  28. }
  29. console.log("getTplList", response)
  30. const { province, comment, website } = response;
  31. commit('SET_PROVINCE', province)
  32. commit('SET_COMMENT', comment)
  33. commit('SET_WEBSITE', website)
  34. // commit('SET_ROLES', roles)
  35. // commit('SET_AVATAR', avatar)
  36. // commit('SET_INTRODUCTION', introduction)
  37. resolve(response)
  38. }).catch(error => {
  39. reject(error)
  40. })
  41. })
  42. }
  43. }
  44. export default {
  45. namespaced: true,
  46. state,
  47. mutations,
  48. actions
  49. }