index.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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/user.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:'wx11a2ce7c2bbc4521',//倍力优会员商城
  19. // appid:'wx301ab2fad04c658a',//倍力优工具
  20. },
  21. mutations: {
  22. setCount(state, value) {
  23. state.count = value;
  24. },
  25. setUserInfo(state, info) {
  26. state.userInfo = info;
  27. },
  28. setWebviewUrl(state, value) {
  29. state.webviewUrl = value;
  30. }
  31. },
  32. actions: {
  33. fetchUser({ commit }) {
  34. // const res = await uni.request({ url: '/api/user' });
  35. commit('setUserInfo', 'noe');
  36. },
  37. getWebviewUrl({commit}) {
  38. var that = this;
  39. var data = {
  40. key: 'course.config'
  41. }
  42. return new Promise((resolve, reject) => {
  43. getConfigByKey(data).then(res => {
  44. if (res.code == 200) {
  45. console.log("getConfigByKey====", JSON.parse(res.data))
  46. let data = JSON.parse(res.data)
  47. commit('setWebviewUrl', data.userCourseAuthDomain);
  48. resolve()
  49. }
  50. }).catch(error => {
  51. reject(error)
  52. });
  53. })
  54. }
  55. }
  56. });