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. 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:1, // 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. appid:'wx77eb4fff8ea1384b',//营口市康安健康服务(益 寿缘)
  23. },
  24. mutations: {
  25. setCount(state, value) {
  26. state.count = value;
  27. },
  28. setUserInfo(state, info) {
  29. state.userInfo = info;
  30. },
  31. setWebviewUrl(state, value) {
  32. state.webviewUrl = value;
  33. },
  34. setCoureLogin(state, payload) {
  35. uni.setStorageSync('coureLogin', payload);
  36. state.coureLogin = payload;
  37. }
  38. },
  39. getters: {
  40. coureLogin: (state) => state.coureLogin,
  41. },
  42. actions: {
  43. fetchUser({ commit }) {
  44. // const res = await uni.request({ url: '/api/user' });
  45. commit('setUserInfo', 'noe');
  46. },
  47. getWebviewUrl({commit}) {
  48. var that = this;
  49. var data = {
  50. key: 'course.config'
  51. }
  52. return new Promise((resolve, reject) => {
  53. getConfigByKey(data).then(res => {
  54. if (res.code == 200) {
  55. console.log("getConfigByKey====", JSON.parse(res.data))
  56. let data = JSON.parse(res.data)
  57. commit('setWebviewUrl', data.userCourseAuthDomain);
  58. resolve()
  59. }
  60. }).catch(error => {
  61. reject(error)
  62. });
  63. })
  64. }
  65. }
  66. });