index.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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:'wxcc2de555e32acb08',//百域佳选 // logonam百域佳选域臻品',
  22. // appid:'wxcc2de555e32acb08'百域佳选域臻品
  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. });