index.vue 5.33 KB
<!--
 * @Date: 2023-12-13 11:13:13
 * @LastEditors: hookehuyr hookehuyr@gmail.com
 * @LastEditTime: 2023-12-20 18:22:40
 * @FilePath: /meihuaApp/src/pages/my/index.vue
 * @Description: 文件描述
-->
<template>
  <view>
    <view id="avator" style="position: relative; display: flex; align-items: center; background-color: #3A2013; color: #FFF; padding: 40rpx 0 40rpx 25rpx;">
      <view style="flex: 6; display: flex; align-items: center;">
        <nut-avatar size="60" style="border: 1px solid #fff;">
          <img style="border-radius: 50%;" src="https://img.yzcdn.cn/vant/cat.jpeg" />
        </nut-avatar>
        <text style="margin-left: 30rpx;">阿忆妞妞</text>
      </view>
      <view style="flex: 1;">
        <IconFont name="edit" @tap="goToEdit"></IconFont>
      </view>
      <view style="position: absolute; left: 0%; right: 0%; bottom: 0%; height: 20rpx; width: 100%; background-color: #FFF; border-top-left-radius: 20rpx;border-top-right-radius: 20rpx;"></view>
    </view>
    <view>
      <view id="title" style="padding-left: 1.5rem; font-size: 35rpx; font-weight: bold;">我的订单</view>
      <view>
        <nut-tabs v-model="value" title-scroll title-gutter="0" name="tabName" background="#FFF" color="#6A4925" animated-time="0">
          <nut-tab-pane v-for="item in tabList" :title="item.title" :pane-key="item.key">
          </nut-tab-pane>
        </nut-tabs>
        <view v-if="showContent" class="book-list">
          <scroll-view ref="refScrollView" :style="scrollStyle" :scroll-y="true" :scroll-with-animation="true" @scrolltolower="onScrollToLower">
            <view v-for="(item, index) in orderList" :key="index">
              <order-card :key="index" :data="item" @onPay="onPay"></order-card>
              <view v-if="index === orderList.length-1" style="height: 2rem;"></view>
            </view>
          </scroll-view>
        </view>
      </view>
    </view>

    <nav-bar activated="my" />

    <payCard :visible="show_pay" :data="payData" @close="onPayClose"/>
  </view>
</template>

<script setup>
import Taro from '@tarojs/taro'
import { ref } from "vue";
import { IconFont } from '@nutui/icons-vue-taro';
import navBar from '@/components/navBar.vue'
import orderCard from '@/components/orderCard.vue'
import payCard from '@/components/payCard.vue'

const refScrollView = ref(null);

const value = ref('0');
const tabList = ref([{
  title: '全部订单',
  key: '0',
}, {
  title: '待入住',
  key: '1',
}, {
  title: '待支付',
  key: '2',
}, {
  title: '已取消',
  key: '3',
}]);

const orderList = ref([
  {
    id: 1,
    name: '阿忆妞妞1',
    phone: '138****8888',
    address: '北京市朝阳区',
    time: '2023-12-13 11:13:13',
    price: 1200,
    remain_time: 10,
    status: 'no-pay',
  },
  {
    id: 2,
    name: '阿忆妞妞2',
    phone: '138****8888',
    address: '北京市朝阳区',
    time: '2023-12-13 11:13:13',
    price: 1200,
    remain_time: 100,
    status: 'apply',
  },
  {
    id: 3,
    name: '阿忆妞妞3',
    phone: '138****8888',
    address: '北京市朝阳区',
    time: '2023-12-13 11:13:13',
    price: 1200,
    remain_time: 100,
    status: 'enable',
  },
  {
    id: 4,
    name: '阿忆妞妞4',
    phone: '138****8888',
    address: '北京市朝阳区',
    time: '2023-12-13 11:13:13',
    price: 1200,
    remain_time: 100,
    status: 'cancel',
  },
])

const show_pay = ref(false);
const payData = ref({});
const onPay = ({ id, remain_time }) => {
  console.warn(id);
  // Taro.showToast({
  //   title: '支付已超时',
  //   icon: 'error',
  //   duration: 2000
  // });
  show_pay.value = true;
  payData.value.id = '123';
  payData.value.price = 1200;
  payData.value.remain_time = remain_time;
}

const onPayClose = () => {
  show_pay.value = false;
}

const goToEdit = () => {
  Taro.navigateTo({
    url: '/pages/myInfo/index',
  });
}
</script>

<script>
import "./index.less";
import { $ } from '@tarojs/extend'

export default {
  name: "myPage",
  computed: {
    scrollStyle() {
      return {
        height: this.indexCoverHeight + 'px',
        // paddingBottom: 50 + 'px',
      };
    },
  },
  mounted () {
    Taro.showLoading({
      title: '加载中',
    });
    // 设置首页封面高度
    const windowHeight = wx.getSystemInfoSync().windowHeight;
    // 处理切换显示白屏问题
    setTimeout(() => {
      this.showContent = true;
    }, 100);
    // setTimeout(async () => {
    //   const navHeight = await $('#navbar-page').height();
    //   const avatorHeight = await $('#avator').height();
    //   const titleHeight = await $('#title').height();
    //   this.indexCoverHeight = windowHeight - navHeight - avatorHeight - titleHeight - 50;
    // }, 500);
    this.$nextTick(async () => {
      const navHeight = await $('#navbar-page').height();
      const avatorHeight = await $('#avator').height();
      const titleHeight = await $('#title').height();
      this.indexCoverHeight = windowHeight - navHeight - avatorHeight - titleHeight - 50;
      if (this.$refs.refScrollView) {
        Taro.hideLoading();
        console.warn('加载完成');
      }
    });
  },
  data() {
    return {
      showContent: false,
      indexCoverHeight: 0,
    };
  },
  methods: {
    onScrollToLower () {
      // if(!this.flag){
      //   return
      // }
      // this.flag = false;
      // this.getList();
      console.warn('onScrollToLower');
    },
  }
};
</script>