useFee.ts 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. import { postMessage } from '@/helpers/native-message';
  2. import { browser } from '@/helpers/utils';
  3. import { state } from '@/state';
  4. import dayjs from 'dayjs';
  5. import { showDialog } from 'vant';
  6. export const gotoMemberCenter = () => {
  7. const browserInfo = browser();
  8. let pathname = '/'
  9. if (/gym.lexiaoya.cn/.test(location.origin) || /test.gym.lexiaoya.cn/.test(location.origin)) {
  10. pathname = '/mdaya/'
  11. }
  12. if (browserInfo.isApp) {
  13. const url = window.location.origin + pathname + `#/member?id=${state.buyVipId}&type=${state.buyVipType}`;
  14. postMessage({
  15. api: 'openWebView',
  16. content: {
  17. url: url,
  18. orientation: 1
  19. }
  20. });
  21. return;
  22. }
  23. location.href = window.location.origin + pathname + `#/member?id=${state.buyVipId}&type=${state.buyVipType}`;
  24. };
  25. /**验证是否是会员 */
  26. export const hasVip = () => {
  27. return !dayjs().isBefore(dayjs(state.user.data.student.membershipEndTime)) &&
  28. !state.user.data.isExistPendingMember
  29. ? false
  30. : true;
  31. };
  32. export const handleCheckVip = () => {
  33. // 学员端验证
  34. if (state.platformType == 'STUDENT') {
  35. //学员有待激活会员
  36. // if (
  37. // !state.user.data.membershipDays &&
  38. // state.user.data.purchaseMemberRecord
  39. // ) {
  40. // showDialog({
  41. // title: '温馨提示',
  42. // message: '您的云练习暂未激活,请激活后使用'
  43. // }).then(() => {
  44. // gotoMemberCenter();
  45. // });
  46. // return false;
  47. // }
  48. //学员没有会员
  49. if (
  50. !dayjs().isBefore(dayjs(state.user.data.student.membershipEndTime)) &&
  51. !state.user.data.isExistPendingMember
  52. ) {
  53. showDialog({
  54. title: '温馨提示',
  55. message: '您暂未开通云练习,请开通后使用'
  56. }).then(() => {
  57. gotoMemberCenter();
  58. });
  59. return false;
  60. }
  61. }
  62. return true;
  63. };