index.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. // store/index.js
  2. import Vue from 'vue';
  3. import Vuex from 'vuex';
  4. Vue.use(Vuex);
  5. import {
  6. getConfigByKey
  7. } from '@/api/index.js'
  8. export default new Vuex.Store({
  9. state: {
  10. coureLogin: uni.getStorageSync('coureLogin') || 0,
  11. webviewUrl: '',
  12. wsDanmuUrl: 'wss://userapp.cqsft.vip', // 弹幕评论接口地址
  13. //红包领取规则:
  14. answerType: 1, //红包领取规则 0:完课且最后一分钟(第二次无需最后一分钟), 1:按完课百分比答题领红包
  15. isSpare:1, // 0,主要小程序,1:备选
  16. uploadFile: 'https://userapp.cqsft.vip',
  17. imgpath: 'https://kuanyitang-1317640934.cos.ap-shanghai.myqcloud.com',//宽 益堂图片请求地址
  18. // https://kuanyitang-1317640934.cos.ap-shanghai.myqcloud.com/shop 宽 益堂图片链接
  19. logoname:'宽益堂九',
  20. appid:'wx6f821705fbe9fc95',//宽益 堂
  21. // appid:'wxe9169275655fa961',//宽益 堂-1
  22. // appid:'wxcb2a284f84947808',//宽益 堂-1
  23. // appid:'wx76121b6e19a9031d',//宽益 堂-2
  24. // appid:'wxcb2a284f84947808',//世维会员管理
  25. // appid:'wxe7e617fb6da83dd0',//宽益 堂博博
  26. // appid:'wx9289087a1b32e857',//宽益 堂琦琦
  27. // appid:'wx27188d0c214227cf',//宽益 堂堂堂
  28. },
  29. getters: {
  30. coureLogin: (state) => state.coureLogin,
  31. },
  32. mutations: {
  33. setUserInfo(state, info) {
  34. state.userInfo = info;
  35. },
  36. setWebviewUrl(state, value) {
  37. state.webviewUrl = value;
  38. },
  39. setCoureLogin(state, payload) {
  40. uni.setStorageSync('coureLogin', payload);
  41. state.coureLogin = payload;
  42. }
  43. },
  44. actions: {
  45. fetchUser({ commit }) {
  46. // const res = await uni.request({ url: '/api/user' });
  47. commit('setUserInfo', 'noe');
  48. },
  49. getWebviewUrl({commit}) {
  50. var that = this;
  51. var data = {
  52. key: 'course.config'
  53. }
  54. return new Promise((resolve, reject) => {
  55. getConfigByKey(data).then(res => {
  56. if (res.code == 200) {
  57. console.log("getConfigByKey====", JSON.parse(res.data))
  58. let data = JSON.parse(res.data)
  59. commit('setWebviewUrl', data.userCourseAuthDomain);
  60. resolve()
  61. }
  62. }).catch(error => {
  63. reject(error)
  64. });
  65. })
  66. }
  67. }
  68. });