common.js 2.8 KB

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