帧视界壹通告,付费看视频的微信小程序
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.

101 lines
2.0 KiB

11 months ago
11 months ago
10 months ago
10 months ago
11 months ago
10 months ago
10 months ago
10 months ago
11 months ago
11 months ago
10 months ago
11 months ago
10 months ago
11 months ago
11 months ago
10 months ago
11 months ago
10 months ago
11 months ago
11 months ago
  1. import Vue from 'vue'
  2. import Vuex from 'vuex'
  3. Vue.use(Vuex); //vue的插件机制
  4. import api from '@/api/api.js'
  5. //Vuex.Store 构造器选项
  6. const store = new Vuex.Store({
  7. state: {
  8. configList: [], //配置列表
  9. count : 10,
  10. userInfo : {},
  11. certifiedIndividual : {
  12. imageReverseSide: '',
  13. imageStraight: '',
  14. card: '',
  15. name: '',
  16. },
  17. // cartInfo : {},
  18. },
  19. getters: {},
  20. mutations: {
  21. // 初始化配置
  22. initConfig(state){
  23. // api('getConfig', res => {
  24. // if(res.code == 200){
  25. // state.configList = res.result
  26. // }
  27. // })
  28. let config = ['getPrivacyPolicy', 'getUserAgreement', 'getPublishPostNotice']
  29. config.forEach(k => {
  30. api(k, res => {
  31. if (res.code == 200) {
  32. state.configList[k] = res.result
  33. }
  34. })
  35. })
  36. },
  37. login(state){
  38. uni.showLoading({
  39. title: '登录中...'
  40. })
  41. uni.login({
  42. success(res) {
  43. if(res.errMsg != "login:ok"){
  44. return
  45. }
  46. api('loginLogin', {
  47. code : res.code
  48. }, res => {
  49. uni.hideLoading()
  50. if(res.code != 200){
  51. return
  52. }
  53. state.userInfo = res.result.userInfo
  54. uni.setStorageSync('token', res.result.token)
  55. if(!state.userInfo.nickName || !state.userInfo.headImage){
  56. uni.navigateTo({
  57. url: '/pages/auth/wxUserInfo'
  58. })
  59. }else{
  60. uni.navigateBack(-1)
  61. }
  62. })
  63. }
  64. })
  65. },
  66. getUserInfo(state){
  67. api('infoGetInfo', res => {
  68. if(res.code == 200){
  69. res.result.idCardOpen = parseInt(res.result.idCardOpen)
  70. state.userInfo = res.result
  71. if(res.result.idCardOpen){
  72. this.commit('getCartInfo')
  73. }
  74. }
  75. })
  76. },
  77. getCartInfo(state){
  78. // this.userInfo.idCardOpen 1企业认证 2个人认证
  79. api(['infoGetCompanyCertification',
  80. 'infoGetCertification'][state.userInfo.idCardOpen - 1],
  81. res => {
  82. if(res.code == 200){
  83. state.certifiedIndividual = res.result || {}
  84. }
  85. })
  86. },
  87. },
  88. actions: {},
  89. })
  90. export default store