home.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  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">
  16. <img src="/static/switch.svg" style="width: 30rpx; height: 30rpx;">
  17. 切换
  18. </view>
  19. </view>
  20. <view class="bottom">
  21. <view class="botton--row" v-for="(row, rowIndex) in bottomList" :key="rowIndex">
  22. <view class="botton--row-item" v-for="(item, itemIndex) in row" :key="itemIndex">
  23. <view class="botton--row-item__content" @click="navigateTo(item.url)">
  24. <view class="botton--row-item__img">
  25. <u-image :src="item.src" :width="item.width" :height="item.height"></u-image>
  26. </view>
  27. <view class="botton--row-item__word">{{ item.text }}</view>
  28. </view>
  29. </view>
  30. </view>
  31. </view>
  32. </view>
  33. </template>
  34. <script>
  35. import {
  36. mapState,
  37. mapMutations
  38. } from "vuex";
  39. import {
  40. IMG_BASE_URL
  41. } from "../../config.js"
  42. import NavigateBar from '../../components/navigateBar/navigate-bar.vue';
  43. export default {
  44. components: {
  45. NavigateBar
  46. },
  47. data() {
  48. return {
  49. topSrc: IMG_BASE_URL + "/home_top.png",
  50. bottomList: [
  51. [{
  52. src: "/static/checkin.png",
  53. text: "入住",
  54. url: "/subpkg_checkin/selectCheckinType/selectCheckinType",
  55. width: "118rpx",
  56. height: "108rpx"
  57. },
  58. {
  59. src: "/static/extand.png",
  60. text: "续住",
  61. url: "/subpkg/extend/extend?fromExtend=true",
  62. width: "105rpx",
  63. height: "103rpx"
  64. },
  65. {
  66. src: "/static/checkout.png",
  67. text: "退房",
  68. url: "/subpkg/extend/extend?fromExtend=false",
  69. width: "113rpx",
  70. height: "105rpx"
  71. },
  72. ],
  73. [{
  74. src: "/static/lift_qrcode.png",
  75. text: "梯控二维码",
  76. url: "/subpkg/elevatorControl/elevatorControl",
  77. width: "105rpx",
  78. height: "93rpx"
  79. },
  80. {
  81. src: "/static/emergency_key.png",
  82. text: "手机开门",
  83. url: "/subpkg/emergencyKey/emergencyKey",
  84. width: "78rpx",
  85. height: "95rpx"
  86. }
  87. ]
  88. ],
  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. };
  99. },
  100. computed: {
  101. ...mapState("m_user", ["userInfo"]),
  102. ...mapState("m_business", ["currentHotel"]),
  103. fixStyle() {
  104. let style = {}
  105. if (this.currentHotel.hasOwnProperty('name') && this.currentHotel.name.length <= 14) return style
  106. style.display = "none"
  107. return style
  108. },
  109. hotelNameFontSize() {
  110. let style = {}
  111. if (this.currentHotel.hasOwnProperty('name') && this.currentHotel.name.length <= 14) return style
  112. style.fontSize = "30rpx"
  113. return style
  114. }
  115. },
  116. methods: {
  117. ...mapMutations('m_user', ['updateUserInfo']),
  118. navigateTo(url) {
  119. if (url !== "" && url !== null && url !== undefined) {
  120. uni.navigateTo({
  121. url: url,
  122. });
  123. }
  124. },
  125. gotoSelectHotel() {
  126. uni.redirectTo({
  127. url: '/subpkg/chooseHotel/chooseHotel?source=home'
  128. })
  129. }
  130. },
  131. onShow() {
  132. //进入页面时 currentHotel 为空时 跳转选择酒店
  133. if (JSON.stringify(this.currentHotel) === '{}') {
  134. uni.redirectTo({
  135. url: '/subpkg/chooseHotel/chooseHotel?source=home'
  136. })
  137. }
  138. },
  139. async onLoad() {
  140. //获取openid
  141. if (!this.userInfo.openid) {
  142. // #ifdef MP-WEIXIN
  143. wx.login({
  144. success: (res) => {
  145. if (res.code) {
  146. //发起网络请求
  147. uni.$http.post('/userInfo/openid', {
  148. code: res.code,
  149. platform: 'WECHAT'
  150. }).then((res) => {
  151. this.userInfo.openid = res.data.data
  152. this.updateUserInfo(this.userInfo)
  153. })
  154. } else {
  155. console.log('登录失败!' + res.errMsg)
  156. }
  157. }
  158. })
  159. // #endif
  160. // #ifdef MP-ALIPAY
  161. my.getAuthCode({
  162. scopes: 'auth_user',
  163. success: res => {
  164. const authCode = res.authCode;
  165. // console.log("authCode",authCode);
  166. //发起网络请求
  167. uni.$http.post('/userInfo/aliOpenid', {
  168. code: authCode,
  169. appId: '2021004131662268'
  170. }).then((res) => {
  171. this.userInfo.openid = res.data.data
  172. console.log("获取支付宝端的openid", res.data.data);
  173. this.updateUserInfo(this.userInfo)
  174. })
  175. },
  176. fail: err => {
  177. console.log('my.getAuthCode 调用失败', err)
  178. }
  179. });
  180. // #endif
  181. }
  182. },
  183. // #ifdef MP-WEIXIN
  184. onShareAppMessage(info) {
  185. return {
  186. title: '源享住',
  187. path: 'pages/login/login',
  188. imageUrl: "/static/logo.png"
  189. }
  190. },
  191. onShareTimeline(info) {}
  192. // #endif
  193. };
  194. </script>
  195. <style lang="scss" scoped>
  196. @import "../../config.scss";
  197. .container {
  198. height: 100%;
  199. width: 100%;
  200. display: flex;
  201. flex-direction: column;
  202. .top {
  203. width: 100%;
  204. height: 130rpx;
  205. position: fixed;
  206. top: 0;
  207. left: 0;
  208. right: 0;
  209. z-index: 99;
  210. }
  211. .adv-pic {
  212. width: 100%;
  213. height: 540rpx;
  214. }
  215. .hotel-name {
  216. margin: 0 40rpx 10rpx;
  217. display: flex;
  218. flex-direction: row;
  219. color: #FFFFFF;
  220. background-color: hsla(0, 100%, 0%, 0.5);
  221. padding: 20rpx 0;
  222. border-radius: 10rpx;
  223. transform: translateY(-60rpx);
  224. .hotel-name--fix {
  225. font-size: 20rpx;
  226. width: 100rpx;
  227. padding-right: 16rpx;
  228. display: flex;
  229. flex-direction: row;
  230. align-items: center;
  231. }
  232. .hotel-name--content {
  233. width: 100%;
  234. display: flex;
  235. align-items: center;
  236. justify-content: center;
  237. }
  238. }
  239. .bottom {
  240. display: flex;
  241. flex-direction: column;
  242. margin: 0 20rpx;
  243. border-radius: 10rpx;
  244. box-shadow: 1px 1px #eaeaf5, -1px 2px #eaeaf5;
  245. .botton--row:first-child {
  246. display: flex;
  247. flex-direction: row;
  248. justify-content: space-between;
  249. margin: 0 60rpx 30rpx;
  250. padding-top: 60rpx;
  251. .botton--row-item__content {
  252. display: flex;
  253. flex-direction: column;
  254. align-items: center;
  255. justify-content: space-between;
  256. height: 170rpx;
  257. width: 170rpx;
  258. .botton--row-item__img {
  259. height: 120rpx;
  260. display: flex;
  261. align-items: center;
  262. justify-content: center;
  263. }
  264. }
  265. }
  266. .botton--row:last-child {
  267. display: flex;
  268. flex-direction: row;
  269. justify-content: space-between;
  270. margin: 0 180rpx;
  271. padding-bottom: 80rpx;
  272. .botton--row-item__content {
  273. display: flex;
  274. flex-direction: column;
  275. align-items: center;
  276. justify-content: space-between;
  277. height: 170rpx;
  278. width: 170rpx;
  279. .botton--row-item__img {
  280. height: 120rpx;
  281. display: flex;
  282. align-items: center;
  283. justify-content: center;
  284. }
  285. }
  286. }
  287. }
  288. }
  289. </style>