初始化
This commit is contained in:
99
pages/index/index.js
Normal file
99
pages/index/index.js
Normal file
@@ -0,0 +1,99 @@
|
||||
// index.js
|
||||
// 获取应用实例
|
||||
const app = getApp()
|
||||
Page({
|
||||
data: {
|
||||
userInfo: null,
|
||||
autho: null,
|
||||
selectGroupIndex: -1,
|
||||
ishotel: false,
|
||||
hotelIndex: -1,
|
||||
issel:false
|
||||
},
|
||||
///选择酒店
|
||||
SelHotel: function (e) {
|
||||
let index = e.currentTarget.dataset['index'];
|
||||
this.setData({
|
||||
hotelIndex: index
|
||||
})
|
||||
wx.setStorageSync(this.data.userInfo.Id + '_xiaoxi_hotelId', this.data.autho[this.data.selectGroupIndex].Hotels[this.data.hotelIndex].HotelId)
|
||||
},
|
||||
//确定选择酒店
|
||||
ShowSelHotel: function (e) {
|
||||
let id = e.currentTarget.dataset['id'];
|
||||
if(id==-1){
|
||||
id = this.data.autho[this.data.selectGroupIndex].Hotels[this.data.hotelIndex].HotelId;
|
||||
}
|
||||
if(this.data.hotelIndex>=0){
|
||||
wx.navigateTo({
|
||||
url: '/pages/Hosts/Hosts?HotelId=' + id
|
||||
})
|
||||
}else{
|
||||
app.toast(2,'未选择酒店')
|
||||
}
|
||||
},
|
||||
//选择酒店组
|
||||
bindgroup: function (e) {
|
||||
let index = e.currentTarget.dataset['index']
|
||||
this.setData({
|
||||
selectGroupIndex: index,
|
||||
hotelIndex: 0,
|
||||
ishotel: true
|
||||
})
|
||||
wx.setStorageSync(this.data.userInfo.Id + '_xiaoxi_hotelId', this.data.autho[this.data.selectGroupIndex].Hotels[this.data.hotelIndex].HotelId)
|
||||
wx.setStorageSync(this.data.userInfo.Id + '_xiaoxi_selectGroupId', this.data.autho[this.data.selectGroupIndex].HotelGroupsId)
|
||||
},
|
||||
//登录
|
||||
onLoad: async function (option) {
|
||||
this.setData({
|
||||
userInfo: app.globalData.userinfo,
|
||||
autho: app.globalData.autho
|
||||
})
|
||||
if (this.data.userInfo == null) {
|
||||
app.checkLoginReadyCallback = res => {
|
||||
this.setData({
|
||||
userInfo: app.globalData.userinfo,
|
||||
autho: app.globalData.autho
|
||||
})
|
||||
this.ReaSel()
|
||||
};
|
||||
} else {
|
||||
this.ReaSel()
|
||||
}
|
||||
|
||||
},
|
||||
//读取历史选择酒店
|
||||
ReaSel: function () {
|
||||
let _xiaoxi_hotelId = wx.getStorageSync(this.data.userInfo.Id + '_xiaoxi_hotelId')
|
||||
let _xiaoxi_selectGroupId = wx.getStorageSync(this.data.userInfo.Id + '_xiaoxi_selectGroupId')
|
||||
let _xiaoxi_selectGroupIndex = -1;
|
||||
let _xiaoxi_hotelIndex = -1;
|
||||
this.data.autho.forEach((element, index) => {
|
||||
if (element.HotelGroupsId == _xiaoxi_selectGroupId) {
|
||||
_xiaoxi_selectGroupIndex = index;
|
||||
element.Hotels.forEach((elements, indexs) => {
|
||||
if (elements.HotelId == _xiaoxi_hotelId) {
|
||||
_xiaoxi_hotelIndex = indexs;
|
||||
}
|
||||
})
|
||||
}
|
||||
});
|
||||
this.setData({
|
||||
selectGroupIndex: _xiaoxi_selectGroupIndex,
|
||||
hotelIndex: _xiaoxi_hotelIndex
|
||||
})
|
||||
//非选择 读取上次进行跳转
|
||||
if(!this.data.issel && this.data.hotelIndex>-1){
|
||||
wx.navigateTo({
|
||||
url: '/pages/Hosts/Hosts?HotelId='+this.data.autho[this.data.selectGroupIndex].Hotels[this.data.hotelIndex].HotelId
|
||||
})
|
||||
}
|
||||
// console.log(this.data.autho.length==1 && this.data.autho[0].Hotels.length==1 && option.issel!=0)
|
||||
//非选择 如果只有一个酒店就直接进行跳转
|
||||
if(this.data.autho.length==1 && this.data.autho[0].Hotels.length==1 && !this.data.issel){
|
||||
wx.navigateTo({
|
||||
url: '/pages/Hosts/Hosts?HotelId='+this.data.autho[0].Hotels[0].HotelId
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
3
pages/index/index.json
Normal file
3
pages/index/index.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"usingComponents": {}
|
||||
}
|
||||
38
pages/index/index.wxml
Normal file
38
pages/index/index.wxml
Normal file
@@ -0,0 +1,38 @@
|
||||
<cu-custom bgColor="bg-gradual-blue" >
|
||||
<block bindtap="" slot="backText" >返回</block>
|
||||
<view slot="content">BLV</view>
|
||||
</cu-custom>
|
||||
<view class="padding-sm bg-white radius shadow shadow-lg">
|
||||
<view id="groups">
|
||||
<view class="text-xl" wx:if="{{hotelIndex>=0}}">
|
||||
<!-- {{autho[selectGroupIndex].HotelGroupsName}} {{autho[selectGroupIndex].Hotels[hotelIndex].HotelId}}- -->
|
||||
<text class="text-green">{{autho[selectGroupIndex].Hotels[hotelIndex].Code}}:{{autho[selectGroupIndex].Hotels[hotelIndex].HotelName}}</text>
|
||||
<button wx:if="{{hotelIndex>=0}}" data-id="-1" class="cu-btn line-green margin-left" bindtap="ShowSelHotel">确定</button>
|
||||
<button wx:if="{{issel != false}}" data-id="{{issel}}" class="cu-btn line-green margin-left" bindtap="ShowSelHotel">返回</button>
|
||||
</view>
|
||||
<view wx:if="{{hotelIndex<0}}" >
|
||||
<button class="cu-btn bg-green margin-xs">请选择酒店</button>
|
||||
</view>
|
||||
<view class="text-black text-lg margin-left-xs" wx:if="{{autho.length>0}}">
|
||||
酒店组信息
|
||||
</view>
|
||||
<view class="grid col-3" wx:if="{{autho.length>0}}">
|
||||
<view class="padding-xs" bindtap="bindgroup" data-index="{{idx}}" wx:for="{{autho}}" wx:for-index="idx" wx:for-item="item" >
|
||||
<button style="width:100%;" class="cu-btn bg-{{selectGroupIndex==idx?'green':'grey'}}">{{item.HotelGroupsName}}({{item.Hotels.length}})</button>
|
||||
</view>
|
||||
</view>
|
||||
<view wx:if="{{autho.length==0}}" class="text-red margin-left-xs" >
|
||||
暂无相关酒店信息
|
||||
</view>
|
||||
</view>
|
||||
<view id="hotels" wx:if="{{selectGroupIndex>-1}}" class="margin-top">
|
||||
<view class="text-black text-xl">
|
||||
<!-- 选择酒店 -->
|
||||
<view class="grid col-4 text-center ">
|
||||
<view bindtap="SelHotel" data-index="{{idx}}" wx:for="{{autho[selectGroupIndex].Hotels}}" wx:for-index="idx" wx:for-item="item" >
|
||||
<view style="font:bold;white-space: nowrap;overflow: hidden;" class="{{hotelIndex == idx?'text-green':''}} text-df bg-gray padding-xs margin-xs" >{{item.HotelName}}</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
0
pages/index/index.wxss
Normal file
0
pages/index/index.wxss
Normal file
Reference in New Issue
Block a user