1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- /**
- * 订单列表业务逻辑
- */
- 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: -1,
- //导航栏数据
- tabsList: [
- { id: 0, name: '全部' },
- { id: 1, name: '待发货' },
- { id: 2, name: '待收货' },
- { id: 3, name: '待激活' },
- { id: 4, name: '退款/换货' }
- ],
-
- })
-
- onLoad((option) => {
- console.log('=============输出内容',option)
- if (!option.index) {
- data.tabIndex = 0
- } else {
- data.tabIndex = Number(option.index)
- } console.log('===========111==输出内容',data.tabIndex)
- //监听订单刷新信息
- 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
- }
- }
|