index.js 1.6 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/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://hst2-1323137866.cos.ap-chongqing.myqcloud.com',//鸿森堂商城图片请求地址
  17. // https://hst2-1323137866.cos.ap-chongqing.myqcloud.com/shop 鸿森堂商城图片链接
  18. // https://hst2-1323137866.cos.ap-chongqing.myqcloud.com/shop
  19. logoname:'鸿森堂便民商城',
  20. appid:'wx291619622c3ce89c',//鸿森堂
  21. },
  22. mutations: {
  23. setCount(state, value) {
  24. state.count = value;
  25. },
  26. setUserInfo(state, info) {
  27. state.userInfo = info;
  28. },
  29. setWebviewUrl(state, value) {
  30. state.webviewUrl = value;
  31. }
  32. },
  33. actions: {
  34. fetchUser({ commit }) {
  35. // const res = await uni.request({ url: '/api/user' });
  36. commit('setUserInfo', 'noe');
  37. },
  38. getWebviewUrl({commit}) {
  39. var that = this;
  40. var data = {
  41. key: 'course.config'
  42. }
  43. return new Promise((resolve, reject) => {
  44. getConfigByKey(data).then(res => {
  45. if (res.code == 200) {
  46. console.log("getConfigByKey====", JSON.parse(res.data))
  47. let data = JSON.parse(res.data)
  48. commit('setWebviewUrl', data.userCourseAuthDomain);
  49. resolve()
  50. }
  51. }).catch(error => {
  52. reject(error)
  53. });
  54. })
  55. }
  56. }
  57. });