Uview关闭弹窗

59 阅读1分钟
<template>
  <view class="machine-info">
    <!-- 顶部标题栏 -->
    <u-navbar title="Machine详情" background-color="#2979ff" color="#fff">
      <u-navbar-left>
        <u-icon name="back" color="#fff" @click="goBack"></u-icon>
      </u-navbar-left>
    </u-navbar>

    <!-- Machine信息卡片 -->
    <view class="machine-card">
      <view class="info-item">
        <view class="item-label">编号:</view>
        <view class="item-value">{{ machine_no }}</view>
      </view>
      <view class="info-item">
        <view class="item-label">时间:</view>
        <view class="item-value">{{ info.created_at }}</view>
      </view>
      <view class="info-item">
        <view class="item-label">备注:</view>
        <view class="item-value">{{ info.remark }}</view>
      </view>
      <!-- 其他Machine信息项 -->
    </view>
	
	<view>
		<u-button type="primary" size="small" text="history" style="width: 100rpx;" @click="showHistory"></u-button>
	</view>
	<u-calendar :show="show" :mode="mode" @confirm="confirm" @close="close"></u-calendar>
  </view>
</template>

<script>
export default {
  data() {
    return {
      machine_no: 0,
	  info: {},
	  show: false,
	  mode: 'single'
    };
  },
  methods: {
	showHistory() {
		this.show = true
	},
	close(e) {
		console.log("关闭");
		this.show = false
	},
	confirm(e) {
		let date = e[0]
		uni.navigateTo({
			url: "/pages/machine/history?date=" + date + "&machine_no=" + this.machine_no
		});
	},
    goBack() {
      uni.navigateBack();
    },
	getMachine() {
	  uni.request({
		 url: this.$baseUrl + "/api/machine?machine_no="+this.machine_no,
		 success: (res) => {
		   console.log('show info', res.data); 
		   // Access the data property directly
		   this.info = res.data.data; // 需要res.data.data才有数据
		 }
	  });
	},
  },
  onShow() {
    // 模拟获取Machine信息,实际项目中可能需要通过接口获取
   	this.machine_no = this.$route.query.machine_no
	this.getMachine(this.machine_no)
  },
};
</script>