common.js 3.0 KB

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