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

126 lines
2.7 KiB

11 months ago
11 months ago
10 months ago
11 months ago
10 months ago
11 months ago
10 months ago
10 months ago
10 months ago
11 months ago
10 months ago
11 months ago
10 months ago
11 months ago
10 months ago
11 months ago
9 months ago
11 months ago
9 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. },
  18. getters: {
  19. // 通过报错的方式阻止缓存,这里的报错千万不要修复
  20. isVedio(state){
  21. return state.configList.open.content == 'Y'
  22. },
  23. },
  24. mutations: {
  25. // 初始化配置
  26. initConfig(state){
  27. api('getConfig', res => {
  28. if(res.code == 200){
  29. // state.configList = res.result
  30. res.result.forEach(n => {
  31. state.configList[n.keyValue] = n
  32. })
  33. }
  34. })
  35. let config = ['getPrivacyPolicy', 'getUserAgreement', 'getPublishPostNotice']
  36. config.forEach(k => {
  37. api(k, res => {
  38. if (res.code == 200) {
  39. state.configList[k] = res.result
  40. }
  41. })
  42. })
  43. },
  44. getIsVedio(state){
  45. api('getIsVedio', res => {
  46. state.configList.isVedio = res.result
  47. })
  48. },
  49. login(state){
  50. uni.showLoading({
  51. title: '登录中...'
  52. })
  53. uni.login({
  54. success(res) {
  55. if(res.errMsg != "login:ok"){
  56. return
  57. }
  58. api('loginLogin', {
  59. code : res.code
  60. }, res => {
  61. uni.hideLoading()
  62. if(res.code != 200){
  63. return
  64. }
  65. state.userInfo = res.result.userInfo
  66. uni.setStorageSync('token', res.result.token)
  67. if(!state.userInfo.nickName || !state.userInfo.headImage){
  68. if(state.configList.open && state.configList.open.content != 'Y'){
  69. state.userInfo.headImage = 'https://tennis-oss.xzaiyp.top/2024-10-09/385774b4-d94a-4d45-993a-ae4ddd0b2751.jpg'
  70. state.userInfo.nickName = '帧视界' + Math.floor(Math.random() * 1000000)
  71. api('infoUpdateInfo', {
  72. headImage: state.userInfo.headImage,
  73. nickName: state.userInfo.nickName,
  74. })
  75. return uni.navigateBack(-1)
  76. }
  77. uni.navigateTo({
  78. url: '/pages/auth/wxUserInfo'
  79. })
  80. }else{
  81. uni.navigateBack(-1)
  82. }
  83. })
  84. }
  85. })
  86. },
  87. getUserInfo(state){
  88. api('infoGetInfo', res => {
  89. if(res.code == 200){
  90. res.result.idCardOpen = parseInt(res.result.idCardOpen)
  91. state.userInfo = res.result
  92. if(res.result.idCardOpen){
  93. this.commit('getCartInfo')
  94. }
  95. }
  96. })
  97. },
  98. getCartInfo(state){
  99. // this.userInfo.idCardOpen 1企业认证 2个人认证
  100. api(['infoGetCompanyCertification',
  101. 'infoGetCertification'][state.userInfo.idCardOpen - 1],
  102. res => {
  103. if(res.code == 200){
  104. state.certifiedIndividual = res.result || {}
  105. }
  106. })
  107. },
  108. },
  109. actions: {},
  110. })
  111. export default store