index.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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:0,//0隐藏药品1显示药品
  17. uploadFile: 'https://userapp.cqsft.vip',
  18. imgpath: 'https://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com',//惠 康商城图片请求地址
  19. // https://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/shop 惠 康商城图片链接
  20. logoname:'阜新枫汇三',
  21. // appid:'wx400102a6b28f27c6',//百 济堂小商城(@冰阔落)
  22. appid:'wxd8a9a602e7ddc4ba',//乾 逸小商城(汪于杰)
  23. },
  24. getters: {
  25. coureLogin: (state) => state.coureLogin,
  26. },
  27. mutations: {
  28. setCount(state, value) {
  29. state.count = value;
  30. },
  31. setUserInfo(state, info) {
  32. state.userInfo = info;
  33. },
  34. setWebviewUrl(state, value) {
  35. state.webviewUrl = value;
  36. },
  37. setCoureLogin(state, payload) {
  38. uni.setStorageSync('coureLogin', payload);
  39. state.coureLogin = payload;
  40. }
  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. });