index.js 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. // store/index.js
  2. import Vue from 'vue';
  3. import Vuex from 'vuex';
  4. Vue.use(Vuex);
  5. export default new Vuex.Store({
  6. state: {
  7. coureLogin: uni.getStorageSync('coureLogin') || 0,
  8. webviewUrl: '',
  9. wsDanmuUrl: 'wss://userapp.moonxiang.com', // 弹幕评论接口地址
  10. //红包领取规则:
  11. answerType: 1, //红包领取规则 0:完课且最后一分钟(第二次无需最后一分钟), 1:按完课百分比答题领红包
  12. isSpare:0, // 0,主要小程序,1:备选
  13. uploadFile: 'https://userapp.moonxiang.com',
  14. imgpath: 'https://bjczwh.oss-cn-beijing.aliyuncs.com',//北京存在文化
  15. logoname:'食养生活',
  16. appid:'wx94951f52d3ac5e25',//家常食养记
  17. // appid:'wx3fb7ca188c55e2e8',//存梦食道养集
  18. // appid:'wxe9d944625a5ce247',//食养早安生活
  19. // appid:'wx0611e784c0309386',//存梦健食养身
  20. // appid:'wx1c32ab023bfd109e',//存梦清香养身心
  21. // appid:'wxcebb0a6606f3fbcf',//其他
  22. },
  23. getters: {
  24. coureLogin: (state) => state.coureLogin,
  25. },
  26. mutations: {
  27. setCount(state, value) {
  28. state.count = value;
  29. },
  30. setUserInfo(state, info) {
  31. state.userInfo = info;
  32. },
  33. setWebviewUrl(state, value) {
  34. state.webviewUrl = value;
  35. },
  36. setCoureLogin(state, payload) {
  37. uni.setStorageSync('coureLogin', payload);
  38. state.coureLogin = payload;
  39. }
  40. },
  41. actions: {
  42. fetchUser({ commit }) {
  43. // const res = await uni.request({ url: '/api/user' });
  44. commit('setUserInfo', 'noe');
  45. },
  46. getWebviewUrl({commit}) {
  47. var that = this;
  48. var data = {
  49. key: 'course.config'
  50. }
  51. return new Promise((resolve, reject) => {
  52. getConfigByKey(data).then(res => {
  53. if (res.code == 200) {
  54. console.log("getConfigByKey====", JSON.parse(res.data))
  55. let data = JSON.parse(res.data)
  56. commit('setWebviewUrl', data.userCourseAuthDomain);
  57. resolve()
  58. }
  59. }).catch(error => {
  60. reject(error)
  61. });
  62. })
  63. }
  64. }
  65. });