tanyanfei 4 years ago
parent
commit
be90a6c3ba
7 changed files with 78 additions and 20 deletions
  1. 1 1
      app.json
  2. 53 2
      pages/hotel/hotel.js
  3. 12 12
      pages/hotel/hotel.wxml
  4. 3 0
      pages/hotel/hotel.wxss
  5. 5 1
      pages/order/hotel.js
  6. 2 2
      pages/order/hotel.wxml
  7. 2 2
      pages/order/order.wxml

+ 1 - 1
app.json

@@ -1,10 +1,10 @@
 {
   "pages": [
+    
     "pages/order/order",
     "pages/mine/mine",
     "pages/eventDetail/eventDetail",
     "pages/hotel/hotel",
-    
     "pages/order/hotel",
    
    

+ 53 - 2
pages/hotel/hotel.js

@@ -1,18 +1,69 @@
 // pages/hotel/hotel.js
+const app = getApp()
+var host = app.globalData.host;
 Page({
 
   /**
    * 页面的初始数据
    */
   data: {
-
+    info:{},
+    aid:''
   },
 
   /**
    * 生命周期函数--监听页面加载
    */
   onLoad: function (options) {
-
+    wx.showNavigationBarLoading();
+    // options.id=1;
+    // options.conference_id=1;
+    this.setData({
+      aid: Number(options.aid)
+    })
+    wx.request({
+      url: host + '/api/signup/hotel',
+      method: 'GET',
+      data: {
+        id: options.id
+      },
+      success: res => {
+        wx.hideNavigationBarLoading();
+        this.setData({
+          info: res.data.data
+        })
+      },
+      fail: function () {
+        wx.hideLoading();
+        wx.showToast({
+          title: '服务器开小差啦!',
+          icon: 'none'
+        })
+      }
+    })
+  },
+  order:function(e){
+    var data={};
+    data.hotel_id=this.data.info.id;
+    data.room_id=e.target.dataset.id;
+    data.id = this.data.aid
+    wx.request({
+      url: host + '/api/user/signup',
+      method: 'PUT',
+      data: data,
+      success: (res => {
+        if (res.data.code == 0) {
+          wx.showToast({
+            title: '预定成功',
+          })
+        } else {
+          wx.showToast({
+            title: '提交失败',
+            icon: 'none'
+          })
+        }
+      })
+    })
   },
 
   /**

+ 12 - 12
pages/hotel/hotel.wxml

@@ -1,20 +1,20 @@
 <!--pages/hotel/hotel.wxml-->
-  <!-- <image style="width:100%;" mode="widthFix" src="../images/qk1.jpeg"></image> -->
+  <image style="width:100%;" mode="widthFix" src="{{info.img}}"></image>
 <view class="top">
-  <view class="tt">迎园饭店</view>
-  <text>地址:上海市嘉定区清河路115号</text>
-  <text>联系电话:021-59521346</text>
+  <view class="tt">{{info.name}}</view>
+  <text>地址:{{info.address}}</text>
+  <text>联系电话:{{info.telephone}}</text>
 </view>
 
 <view class="content">
-    <navigator class="list">
-        <image src="../images/qk1.jpeg"></image>
+    <view class="list" wx:for='{{info.rooms}}'>
+        <image src="{{item.imgs}}"></image>
         <view>
-            <view class="title">标间</view>
-            <text style="color:#999;">15m²   早餐   双床房   2人入住    </text>
-            <text>350元</text>
-            <text>剩余数量:50</text>
-            <navigator class="btn">预定</navigator>
+            <view class="title">{{item.name}}</view>
+            <text style="color:#999;">{{item.room_area}}m²   {{item.food_condition}}   {{item.floor}}层   {{item.enable_number}}人入住    </text>
+            <text>{{item.unit_price}}元</text>
+            <text>剩余数量:{{item.room_number}}</text>
+            <view bindtap="order" data-id='{{item.id}}' class="btn">预定</view>
         </view>
-    </navigator>
+    </view>
 </view>

+ 3 - 0
pages/hotel/hotel.wxss

@@ -2,6 +2,9 @@
 page{
   padding: 0;
 }
+.content{
+  height: auto;
+}
 .top{
   background: #fff;
   padding: 20rpx;

+ 5 - 1
pages/order/hotel.js

@@ -7,13 +7,17 @@ Page({
    * 页面的初始数据
    */
   data: {
-    act: 0
+    act: 0,
+    aid:'',   //报名id
   },
 
   /**
    * 生命周期函数--监听页面加载
    */
   onLoad: function (options) {
+    this.setData({
+      aid: options.aid
+    })
     wx.showNavigationBarLoading()
     wx.request({
       url: host + '/api/signup/hotel/list',

+ 2 - 2
pages/order/hotel.wxml

@@ -1,6 +1,6 @@
 <view class="content">
-    <navigator class="list" wx:for='{{list}}'>
-        <image src="../images/qk1.jpeg"></image>
+    <navigator class="list" wx:for='{{list}}' url="../hotel/hotel?aid={{aid}}&id={{item.id}}">
+        <image src="{{item.img}}"></image>
         <view>
             <view class="title">{{item.name}}</view>
             <text>地址:{{item.address}}</text>

+ 2 - 2
pages/order/order.wxml

@@ -4,11 +4,11 @@
 </view>
 <view class="content">
     <view class="list" wx:for='{{list}}'>
-        <image src="../images/qk1.jpeg"></image>
+        <image src="{{item.conference_img}}"></image>
         <view>
             <view class="title">{{item.conference_name}}</view>
             <text>报名时间:{{item.ctime}}</text>
-            <navigator wx:if='{{!item.hotel_id}}' url="../order/hotel?id={{item.conference_id}}"  class="btn">选酒店</navigator>
+            <navigator wx:if='{{!item.hotel_id}}' url="../order/hotel?id={{item.conference_id}}&&aid={{item.id}}"  class="btn">选酒店</navigator>
         </view>
     </view>
 </view>