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.

useOrderList.ts 1.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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: 0,
  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(() => {
  26. //监听订单刷新信息
  27. uni.$on('refreshOrder',() => {
  28. data.refresh = true;
  29. });
  30. uni.$on('refreshFinish',()=>{
  31. data.refresh = false;
  32. })
  33. uni.$on('loginOut',()=>{
  34. data.login = false;
  35. data.refresh = false;
  36. })
  37. });
  38. onUnload(()=>{
  39. uni.$off('refreshOrder');
  40. });
  41. onShow(()=>{
  42. data.login = hasLogin();
  43. if(data.login){
  44. data.refresh = true;
  45. }
  46. })
  47. return {
  48. data, tabbarRef
  49. }
  50. }