You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /**
  2. * 订单列表业务逻辑
  3. */
  4. import { onLoad, onShow, onUnload } from "@dcloudio/uni-app";
  5. import { reactive, ref } from 'vue';
  6. import { hasLogin, msg } from "@/utils/utils";
  7. export default function useOrderList() {
  8. const tabbarRef = ref<{ changeTab : (index : Number) => void }>()
  9. const data = reactive({
  10. //登录状态
  11. login: hasLogin(),
  12. //是否刷新
  13. refresh: false,
  14. //当前切换的index 0-全部 1-待发货 2-待收货 3-待激活 xx-退款/换货
  15. tabIndex: -1,
  16. //导航栏数据
  17. tabsList: [
  18. { id: 0, name: '全部' },
  19. { id: 1, name: '待发货' },
  20. { id: 2, name: '待收货' },
  21. { id: 3, name: '待激活' },
  22. { id: 4, name: '退款/换货' }
  23. ],
  24. })
  25. onLoad((option) => {
  26. console.log('=============输出内容',option)
  27. if (!option.index) {
  28. data.tabIndex = 0
  29. } else {
  30. data.tabIndex = Number(option.index)
  31. } console.log('===========111==输出内容',data.tabIndex)
  32. //监听订单刷新信息
  33. uni.$on('refreshOrder', () => {
  34. data.refresh = true;
  35. });
  36. uni.$on('refreshFinish', () => {
  37. data.refresh = false;
  38. })
  39. uni.$on('loginOut', () => {
  40. data.login = false;
  41. data.refresh = false;
  42. })
  43. });
  44. onUnload(() => {
  45. uni.$off('refreshOrder');
  46. });
  47. onShow(() => {
  48. data.login = hasLogin();
  49. if (data.login) {
  50. data.refresh = true;
  51. console.log("data.refresh", data.refresh)
  52. }
  53. })
  54. return {
  55. data, tabbarRef
  56. }
  57. }