index.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. webviewUrl: '',
  11. wsDanmuUrl: 'wss://userapp.cqsft.vip', // 弹幕评论接口地址
  12. //红包领取规则:
  13. answerType: 1, //红包领取规则 0:完课且最后一分钟(第二次无需最后一分钟), 1:按完课百分比答题领红包
  14. isSpare:1, // 0,主要小程序,1:备选
  15. uploadFile: 'https://userapp.cqsft.vip',
  16. imgpath: 'https://beiliyo-2025.obs.cn-north-4.myhuaweicloud.com',//倍力优图片请求地址
  17. logoname:'倍力优',
  18. appid:'wx503cf8ab31f83dd4',
  19. },
  20. mutations: {
  21. setCount(state, value) {
  22. state.count = value;
  23. },
  24. setUserInfo(state, info) {
  25. state.userInfo = info;
  26. },
  27. setWebviewUrl(state, value) {
  28. state.webviewUrl = value;
  29. }
  30. },
  31. actions: {
  32. fetchUser({ commit }) {
  33. // const res = await uni.request({ url: '/api/user' });
  34. commit('setUserInfo', 'noe');
  35. },
  36. getWebviewUrl({commit}) {
  37. var that = this;
  38. var data = {
  39. key: 'course.config'
  40. }
  41. return new Promise((resolve, reject) => {
  42. getConfigByKey(data).then(res => {
  43. if (res.code == 200) {
  44. console.log("getConfigByKey====", JSON.parse(res.data))
  45. let data = JSON.parse(res.data)
  46. commit('setWebviewUrl', data.userCourseAuthDomain);
  47. resolve()
  48. }
  49. }).catch(error => {
  50. reject(error)
  51. });
  52. })
  53. }
  54. }
  55. });