|
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- /**
- * 订单列表业务逻辑
- */
- import { onLoad, onShow, onUnload } from "@dcloudio/uni-app";
- import { reactive, ref } from 'vue';
- import { hasLogin, msg } from "@/utils/utils";
- export default function useOrderList() {
- const tabbarRef = ref<{ changeTab: (index: Number) => void }>()
-
- const data = reactive({
- //登录状态
- login: hasLogin(),
- //是否刷新
- refresh: false,
- //当前切换的index 0-全部 1-待发货 2-待收货 3-待激活 xx-退款/换货
- tabIndex: 0,
- //导航栏数据
- tabsList: [
- { id: 0, name: '全部' },
- { id: 1, name: '待发货' },
- { id: 2, name: '待收货' },
- { id: 3, name: '待激活' },
- { id: 4, name: '退款/换货' }
- ],
- })
-
- onLoad((option) => {
- console.log("option", option)
- if (!option.index) {
- data.tabIndex = 0
- } else {
- data.tabIndex = Number(option.index)
- }
- //监听订单刷新信息
- uni.$on('refreshOrder', () => {
- data.refresh = true;
- });
-
- uni.$on('refreshFinish', () => {
- data.refresh = false;
- })
-
- uni.$on('loginOut', () => {
- data.login = false;
- data.refresh = false;
- })
- });
-
- onUnload(() => {
- uni.$off('refreshOrder');
- });
-
- onShow(() => {
- data.login = hasLogin();
- if (data.login) {
- data.refresh = true;
- console.log("data.refresh", data.refresh)
- }
- })
-
- return {
- data, tabbarRef
- }
- }
|