index.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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.ysya.top', // 弹幕评论接口地址
  13. //红包领取规则:
  14. answerType: 1, //红包领取规则 0:完课且最后一分钟(第二次无需最后一分钟), 1:按完课百分比答题领红包
  15. isSpare:0, // 0,主要小程序,1:备选
  16. uploadFile: 'https://userapp.ysya.top',
  17. imgpath: 'https://ysy-1329817240.cos.ap-guangzhou.myqcloud.com',//益寿缘图片请求地址
  18. logoname:'益寿缘',
  19. // appid:'wx0d1a3dd485268521',//益寿缘
  20. appid:'wx50bcb040b4963a7e',//营口市康安健康服务(益寿缘)
  21. // appid:'wx6d21646ba042d66f',//久运健康线上服务(益寿缘)
  22. },
  23. mutations: {
  24. setCount(state, value) {
  25. state.count = value;
  26. },
  27. setUserInfo(state, info) {
  28. state.userInfo = info;
  29. },
  30. setWebviewUrl(state, value) {
  31. state.webviewUrl = value;
  32. },
  33. setCoureLogin(state, payload) {
  34. uni.setStorageSync('coureLogin', payload);
  35. state.coureLogin = payload;
  36. }
  37. },
  38. getters: {
  39. coureLogin: (state) => state.coureLogin,
  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. });