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.cqsft.vip', // 弹幕评论接口地址
  13. //红包领取规则:
  14. answerType: 1, //红包领取规则 0:完课且最后一分钟(第二次无需最后一分钟), 1:按完课百分比答题领红包
  15. isSpare:0, // 0,主要小程序,1:备选
  16. uploadFile: 'https://userapp.cqsft.vip',
  17. // imgpath: 'https://jnlzjk-1323137866.cos.ap-chongqing.myqcloud.com',//百域承品图片请求地址
  18. imgpath: 'https://bjzmky-1323137866.cos.ap-chongqing.myqcloud.com',//百域承品图片请求地址
  19. // https://jnlzjk-1323137866.cos.ap-chongqing.myqcloud.com/shop 百域承品图片链接
  20. logoname:'百域承品',
  21. appid:'wx44beed5640bcb1ba',//百域承品
  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. });