index.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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.cqsft.vip', // 弹幕评论接口地址
  13. //红包领取规则:
  14. answerType: 1, //红包领取规则 0:完课且最后一分钟(第二次无需最后一分钟), 1:按完课百分比答题领红包
  15. isSpare:1, // 0,主要小程序,1:备选
  16. isDrug:1,//0隐藏药品1显示药品
  17. uploadFile: 'https://userapp.cqsft.vip',
  18. imgpath: 'https://zlwh.obs.cn-southwest-2.myhuaweicloud.com',//惠 康商城图片请求地址
  19. // https://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/shop 惠 康商城图片链接
  20. logoname:'盛世生活工具A',
  21. // appid:'wxbb4a813dea1774d7',//泽林文化
  22. // appid:'wxdf14438a85585494',//泽林文化
  23. // appid:'wx45cf09091aead547',//测试
  24. // appid:'wx4c5b965e6392faf3',//韵 鹏笑笑助手
  25. appid:'wx17f5dc470c3c565a',//泽 林生活助手A
  26. },
  27. getters: {
  28. coureLogin: (state) => state.coureLogin,
  29. },
  30. mutations: {
  31. setCount(state, value) {
  32. state.count = value;
  33. },
  34. setUserInfo(state, info) {
  35. state.userInfo = info;
  36. },
  37. setWebviewUrl(state, value) {
  38. state.webviewUrl = value;
  39. },
  40. setCoureLogin(state, payload) {
  41. uni.setStorageSync('coureLogin', payload);
  42. state.coureLogin = payload;
  43. }
  44. },
  45. actions: {
  46. fetchUser({ commit }) {
  47. // const res = await uni.request({ url: '/api/user' });
  48. commit('setUserInfo', 'noe');
  49. },
  50. getWebviewUrl({commit}) {
  51. var that = this;
  52. var data = {
  53. key: 'course.config'
  54. }
  55. return new Promise((resolve, reject) => {
  56. getConfigByKey(data).then(res => {
  57. if (res.code == 200) {
  58. console.log("getConfigByKey====", JSON.parse(res.data))
  59. let data = JSON.parse(res.data)
  60. commit('setWebviewUrl', data.userCourseAuthDomain);
  61. resolve()
  62. }
  63. }).catch(error => {
  64. reject(error)
  65. });
  66. })
  67. }
  68. }
  69. });