home.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400
  1. <template>
  2. <view class="container">
  3. <view class="top">
  4. <NavigateBar title="源享住"></NavigateBar>
  5. </view>
  6. <view class="adv-pic">
  7. <u-swiper :list="advPicList" keyName="image" indicator indicatorMode="dot" circular height="540rpx"
  8. imgMode="aspectFit" interval="8000"></u-swiper>
  9. </view>
  10. <view class="hotel-name">
  11. <view class="hotel-name--fix" :style="[fixStyle]"></view>
  12. <view class="hotel-name--content" :style="[hotelNameFontSize]">
  13. <view>{{ currentHotel.name }}</view>
  14. </view>
  15. <view class="hotel-name--fix" @click="gotoSelectHotel" id="changeHotel">
  16. <img src="/static/switch.svg" style="width: 30rpx; height: 30rpx;">
  17. 切换
  18. </view>
  19. </view>
  20. <view class="bottom">
  21. <view class="bottom--row">
  22. <view class="bottom--row-item" id="checkin"
  23. @click="navigateTo('/subpkg_checkin/selectCheckinType/selectCheckinType')">
  24. <view class="bottom--row-item__img">
  25. <u-image src="/static/checkin.png" width="118rpx" height="108rpx"></u-image>
  26. </view>
  27. <view class="bottom--row-item__word">入住</view>
  28. </view>
  29. <view class="bottom--row-item" id="extend" @click="navigateTo('/subpkg/extend/extend?fromExtend=true')">
  30. <view class="bottom--row-item__img">
  31. <u-image src="/static/extend.png" width="105rpx" height="103rpx"></u-image>
  32. </view>
  33. <view class="bottom--row-item__word">续住</view>
  34. </view>
  35. <view class="bottom--row-item" id="checkout"
  36. @click="navigateTo('/subpkg/extend/extend?fromExtend=false')">
  37. <view class="bottom--row-item__img">
  38. <u-image src="/static/checkout.png" width="113rpx" height="105rpx"></u-image>
  39. </view>
  40. <view class="bottom--row-item__word">退房</view>
  41. </view>
  42. </view>
  43. <view class="bottom--row">
  44. <view class="bottom--row-item" id="lift_qrcode"
  45. @click="navigateTo('/subpkg/elevatorControl/elevatorControl')">
  46. <view class="bottom--row-item__img">
  47. <u-image src="/static/lift_qrcode.png" width="105rpx" height="93rpx"></u-image>
  48. </view>
  49. <view class="bottom--row-item__word">梯控二维码</view>
  50. </view>
  51. <view class="bottom--row-item" id="emergency_key"
  52. @click="navigateTo('/subpkg/emergencyKey/emergencyKey')">
  53. <view class="bottom--row-item__img">
  54. <u-image src="/static/emergency_key.png" width="78rpx" height="95rpx"></u-image>
  55. </view>
  56. <view class="bottom--row-item__word">手机开门</view>
  57. </view>
  58. <view class="bottom--row-item" id="shop" v-if="false">
  59. <view class="bottom--row-item__img">
  60. <u-image src="/static/shop.png" width="118rpx" height="108rpx"></u-image>
  61. </view>
  62. <view class="bottom--row-item__word">客房超市</view>
  63. </view>
  64. </view>
  65. </view>
  66. <guide :show="showGuide" :width="cWidth" :height="cHeight" :left="cLeft" :right="cRight" :top="cTop"
  67. :showMessage='cShowMsg' :currentIndex="currentIndex" :noticeArray="noticeArray" @click="clickNext">
  68. </guide>
  69. </view>
  70. </template>
  71. <script>
  72. import guide from '@/components/guide/guide.vue'
  73. import {
  74. mapState,
  75. mapMutations
  76. } from "vuex";
  77. import {
  78. IMG_BASE_URL
  79. } from "../../config.js"
  80. import NavigateBar from '../../components/navigateBar/navigate-bar.vue';
  81. export default {
  82. components: {
  83. NavigateBar,
  84. guide
  85. },
  86. data() {
  87. return {
  88. topSrc: IMG_BASE_URL + "/home_top.png",
  89. advPicList: [{
  90. image: IMG_BASE_URL + "/home_adv1.png",
  91. title: ""
  92. },
  93. {
  94. image: IMG_BASE_URL + "/home_adv2.png",
  95. title: ""
  96. }
  97. ],
  98. showGuide: false, //引导是否显示
  99. cShowMsg: '', // 展示的解释语
  100. cWidth: '',
  101. cHeight: '',
  102. cLeft: '',
  103. cRight: '',
  104. cTop: '',
  105. currentIndex: 0,
  106. //配置需要显示引导的view以及引导显示的msg
  107. noticeArray: [{
  108. "showID": "changeHotel", // 对应的id
  109. "showMessage": "点击“切换” 选择您要入住的酒店", // 对应的解释文本
  110. "type": "bottom" // 解释框的气泡类型
  111. },
  112. {
  113. "showID": "checkin", // 对应的id
  114. "showMessage": "点击“入住”办理当前酒店入住流程", // 对应的解释文本
  115. "type": "bottom" // 解释框的气泡类型
  116. },
  117. {
  118. "showID": "extend",
  119. "showMessage": "点击“续住”办理当前房间续住流程",
  120. "type": "bottom"
  121. },
  122. {
  123. "showID": "checkout",
  124. "showMessage": "点击“退房”办理当前房间退房流程",
  125. "type": "bottom"
  126. },
  127. {
  128. "showID": "lift_qrcode",
  129. "showMessage": "如面部无法识别, 点击进入梯控二维码界面",
  130. "type": "top"
  131. },
  132. {
  133. "showID": "emergency_key",
  134. "showMessage": "如面部无法识别, 点击进入手机开门界面",
  135. "type": "top"
  136. },
  137. // {
  138. // "showID": "shop",
  139. // "showMessage": "点击进入酒店小超市, 挑选心仪商品",
  140. // "type": "top"
  141. // }
  142. ],
  143. appId: ''
  144. };
  145. },
  146. computed: {
  147. ...mapState("m_user", ["userInfo"]),
  148. ...mapState("m_business", ["currentHotel"]),
  149. fixStyle() {
  150. let style = {}
  151. if (this.currentHotel.hasOwnProperty('name') && this.currentHotel.name.length <= 14) return style
  152. style.display = "none"
  153. return style
  154. },
  155. hotelNameFontSize() {
  156. let style = {}
  157. if (this.currentHotel.hasOwnProperty('name') && this.currentHotel.name.length <= 14) return style
  158. style.fontSize = "30rpx"
  159. return style
  160. }
  161. },
  162. methods: {
  163. ...mapMutations('m_user', ['updateUserInfo']),
  164. navigateTo(url) {
  165. if (url !== "" && url !== null && url !== undefined) {
  166. if (url !== "/subpkg_checkin/selectCheckinType/selectCheckinType") {
  167. if (!this.userInfo.idNumber) {
  168. uni.showModal({
  169. title: '身份信息未完善',
  170. content: '请至个人中心实名认证处完善个人信息',
  171. showCancel: false,
  172. success() {
  173. uni.switchTab({
  174. url: '/pages/my/my'
  175. })
  176. }
  177. })
  178. return
  179. }
  180. }
  181. uni.navigateTo({
  182. url: url,
  183. });
  184. }
  185. },
  186. gotoSelectHotel() {
  187. uni.redirectTo({
  188. url: '/subpkg/chooseHotel/chooseHotel?source=home'
  189. })
  190. },
  191. clickNext() {
  192. console.log('点击了下一个')
  193. if (this.currentIndex >= this.noticeArray.length) {
  194. this.showGuide = false;
  195. uni.setStorageSync('showGuide', false)
  196. return;
  197. }
  198. this.noticeArray[this.currentIndex].zindex = 0;
  199. this.cShowMsg = '';
  200. this.currentIndex++;
  201. if (this.currentIndex >= this.noticeArray.length) {
  202. this.showGuide = false;
  203. return;
  204. }
  205. this.cShowMsg = this.noticeArray[this.currentIndex].showMessage;
  206. var idS = '#' + this.noticeArray[this.currentIndex].showID;
  207. console.log(idS)
  208. const query = uni.createSelectorQuery().in(this);
  209. query.select(idS).boundingClientRect(data => {
  210. console.log("得到布局位置信息" + JSON.stringify(data));
  211. this.cWidth = data.width;
  212. this.cHeight = data.height;
  213. this.cLeft = data.left;
  214. this.cRight = data.right;
  215. this.cTop = data.top;
  216. }).exec();
  217. },
  218. },
  219. onShow() {
  220. //进入页面时 currentHotel 为空时 跳转选择酒店
  221. if (JSON.stringify(this.currentHotel) === '{}') {
  222. uni.redirectTo({
  223. url: '/subpkg/chooseHotel/chooseHotel?source=home'
  224. })
  225. }
  226. },
  227. async onLoad() {
  228. const {
  229. miniProgram: {
  230. appId
  231. }
  232. } = uni.getAccountInfoSync();
  233. this.appId = appId
  234. // console.log(__wxConfig)
  235. //获取openid
  236. if (!this.userInfo.openid) {
  237. // #ifdef MP-WEIXIN
  238. wx.login({
  239. success: (res) => {
  240. if (res.code) {
  241. //发起网络请求
  242. uni.$http.post('/user/weChatOpenid', {
  243. code: res.code,
  244. appId: this.appId
  245. }).then((res) => {
  246. this.userInfo.openid = res.data.data
  247. this.updateUserInfo(this.userInfo)
  248. })
  249. } else {
  250. console.log('登录失败!' + res.errMsg)
  251. }
  252. }
  253. })
  254. // #endif
  255. // #ifdef MP-ALIPAY
  256. my.getAuthCode({
  257. scopes: 'auth_user',
  258. success: res => {
  259. const authCode = res.authCode;
  260. // console.log("authCode",authCode);
  261. //发起网络请求
  262. uni.$http.post('/user/aliOpenid', {
  263. code: authCode,
  264. appId: '2021004131662268'
  265. }).then((res) => {
  266. this.userInfo.openid = res.data.data
  267. console.log("获取支付宝端的openid", res.data.data);
  268. this.updateUserInfo(this.userInfo)
  269. })
  270. },
  271. fail: err => {
  272. console.log('my.getAuthCode 调用失败', err)
  273. }
  274. });
  275. // #endif
  276. }
  277. //显示引导
  278. // uni.setStorageSync('showGuide', true)
  279. let showGuide = uni.getStorageSync('showGuide')
  280. if (showGuide === '') {
  281. // if (true) {
  282. this.showGuide = true
  283. uni.setStorageSync('showGuide', 'false')
  284. let _this = this;
  285. this.$nextTick(function() {
  286. if (_this.currentIndex >= _this.noticeArray.length) {
  287. _this.showGuide = false;
  288. return;
  289. }
  290. _this.showGuide = true;
  291. _this.cShowMsg = _this.noticeArray[_this.currentIndex].showMessage;
  292. var idS = '#' + _this.noticeArray[_this.currentIndex].showID;
  293. console.log(idS)
  294. //根据布局信息显示引导框位置
  295. const query = uni.createSelectorQuery().in(_this);
  296. query.select(idS).boundingClientRect(data => {
  297. console.log("得到布局位置信息" + JSON.stringify(data));
  298. _this.cWidth = data.width;
  299. _this.cHeight = data.height;
  300. _this.cLeft = data.left;
  301. this.cRight = data.right;
  302. _this.cTop = data.top;
  303. }).exec();
  304. });
  305. }
  306. },
  307. // #ifdef MP-WEIXIN
  308. onShareAppMessage(info) {
  309. return {
  310. title: '源享住',
  311. path: 'pages/login/login',
  312. imageUrl: "/static/logo.png"
  313. }
  314. },
  315. onShareTimeline(info) {}
  316. // #endif
  317. };
  318. </script>
  319. <style lang="scss" scoped>
  320. .container {
  321. height: 100%;
  322. width: 100%;
  323. display: flex;
  324. flex-direction: column;
  325. .top {
  326. width: 100%;
  327. height: 130rpx;
  328. position: fixed;
  329. top: 0;
  330. left: 0;
  331. right: 0;
  332. z-index: 99;
  333. }
  334. .adv-pic {
  335. width: 100%;
  336. height: 540rpx;
  337. }
  338. .hotel-name {
  339. margin: 0 40rpx 10rpx;
  340. display: flex;
  341. flex-direction: row;
  342. color: #FFFFFF;
  343. background-color: hsla(0, 100%, 0%, 0.5);
  344. padding: 20rpx 0;
  345. border-radius: 10rpx;
  346. transform: translateY(-60rpx);
  347. .hotel-name--fix {
  348. font-size: 20rpx;
  349. width: 100rpx;
  350. padding-right: 16rpx;
  351. display: flex;
  352. flex-direction: row;
  353. align-items: center;
  354. }
  355. .hotel-name--content {
  356. width: 100%;
  357. display: flex;
  358. align-items: center;
  359. justify-content: center;
  360. }
  361. }
  362. .bottom {
  363. display: flex;
  364. flex-direction: column;
  365. margin: 0 20rpx;
  366. border-radius: 10rpx;
  367. box-shadow: 1px 1px #eaeaf5, -1px 2px #eaeaf5;
  368. .bottom--row {
  369. display: flex;
  370. flex-direction: row;
  371. justify-content: space-around;
  372. margin: 0 60rpx 30rpx;
  373. padding-top: 60rpx;
  374. .bottom--row-item {
  375. width: 30vw;
  376. display: flex;
  377. justify-content: center;
  378. flex-direction: column;
  379. align-items: center;
  380. }
  381. }
  382. }
  383. }
  384. </style>