common.js 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. import uni from '@/static/static/js/uni.webview.1.5.2';
  2. export default {
  3. data() {
  4. return {
  5. packageList: [], // 邀请人被邀请人选择的套餐
  6. visible: false
  7. }
  8. },
  9. mounted() {
  10. },
  11. methods: {
  12. // 获取套餐 personnelMealType 获取方: 1: 邀请人 2: 被邀请人
  13. getActivitySortRuleAndActivityMealList(obj) {
  14. this.$toast.loading({
  15. message: '加载中...',
  16. forbidClick: true,
  17. duration: 0
  18. })
  19. const operateActivityId = +localStorage.getItem('auth.operateActivityId')
  20. const data = { operateActivityId }
  21. Object.assign(data, obj)
  22. this.$axios.$post('activity/v5/assist/bargaining/getActivitySortRuleAndActivityMealList', data).then(res => {
  23. console.log(res)
  24. if (res.success) {
  25. if (obj.userCardId && !res.data[0]?.mealList?.length) {
  26. this.visible = true
  27. return
  28. }
  29. this.packageList = res.data || []
  30. }
  31. }).finally(() => {
  32. this.$toast.clear();
  33. })
  34. },
  35. // 获取服务器的当前时间
  36. getSystemTime() {
  37. return this.$axios.$get('pay/v1/order/getSystemTime')
  38. },
  39. // 退出相关逻辑
  40. leaveFun() {
  41. const isApp = this.$userAgent.isSzx || this.$userAgent.isSzxBrowser;
  42. const isAndroid = this.$userAgent.isAndroid;
  43. const isWx = this.$userAgent.isWx;
  44. if (isApp) {
  45. if (isAndroid) {
  46. window.native.backClick && window.native.backClick();
  47. } else {
  48. window.webkit.messageHandlers.appGoBack && window.webkit.messageHandlers.appGoBack.postMessage({})
  49. }
  50. } else {
  51. if (isWx) {
  52. this.$wx.miniProgram.navigateBack({
  53. data: 1
  54. })
  55. return
  56. }
  57. uni.reLaunch({
  58. url: '/pages/index/index'
  59. });
  60. }
  61. },
  62. // 拦截微信原生返回相关方法
  63. wxIntercept(handlePopstate) {
  64. window.removeEventListener('popstate', handlePopstate)
  65. history.pushState(null, null, document.URL)
  66. window.addEventListener('popstate', handlePopstate)
  67. }
  68. }
  69. }