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. uploadFile: 'https://userapp.cqsft.vip',
  17. imgpath: 'https://hst2-1323137866.cos.ap-chongqing.myqcloud.com',//建兴堂图片请求地址
  18. // https://hst2-1323137866.cos.ap-chongqing.myqcloud.com/shop 建兴堂图片链接
  19. // https://hst2-1323137866.cos.ap-chongqing.myqcloud.com/shop
  20. logoname:'建兴堂',
  21. // appid:'wxe0c36e14e697d8cf',//鸿森堂
  22. appid:'wx87221638fa168cc5',//建 兴堂
  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. });