home.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  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. .container {
  197. height: 100%;
  198. width: 100%;
  199. display: flex;
  200. flex-direction: column;
  201. .top {
  202. width: 100%;
  203. height: 130rpx;
  204. position: fixed;
  205. top: 0;
  206. left: 0;
  207. right: 0;
  208. z-index: 99;
  209. }
  210. .adv-pic {
  211. width: 100%;
  212. height: 540rpx;
  213. }
  214. .hotel-name {
  215. margin: 0 40rpx 10rpx;
  216. display: flex;
  217. flex-direction: row;
  218. color: #FFFFFF;
  219. background-color: hsla(0, 100%, 0%, 0.5);
  220. padding: 20rpx 0;
  221. border-radius: 10rpx;
  222. transform: translateY(-60rpx);
  223. .hotel-name--fix {
  224. font-size: 20rpx;
  225. width: 100rpx;
  226. padding-right: 16rpx;
  227. display: flex;
  228. flex-direction: row;
  229. align-items: center;
  230. }
  231. .hotel-name--content {
  232. width: 100%;
  233. display: flex;
  234. align-items: center;
  235. justify-content: center;
  236. }
  237. }
  238. .bottom {
  239. display: flex;
  240. flex-direction: column;
  241. margin: 0 20rpx;
  242. border-radius: 10rpx;
  243. box-shadow: 1px 1px #eaeaf5, -1px 2px #eaeaf5;
  244. .botton--row:first-child {
  245. display: flex;
  246. flex-direction: row;
  247. justify-content: space-between;
  248. margin: 0 60rpx 30rpx;
  249. padding-top: 60rpx;
  250. .botton--row-item__content {
  251. display: flex;
  252. flex-direction: column;
  253. align-items: center;
  254. justify-content: space-between;
  255. height: 170rpx;
  256. width: 170rpx;
  257. .botton--row-item__img {
  258. height: 120rpx;
  259. display: flex;
  260. align-items: center;
  261. justify-content: center;
  262. }
  263. }
  264. }
  265. .botton--row:last-child {
  266. display: flex;
  267. flex-direction: row;
  268. justify-content: space-between;
  269. margin: 0 180rpx;
  270. padding-bottom: 80rpx;
  271. .botton--row-item__content {
  272. display: flex;
  273. flex-direction: column;
  274. align-items: center;
  275. justify-content: space-between;
  276. height: 170rpx;
  277. width: 170rpx;
  278. .botton--row-item__img {
  279. height: 120rpx;
  280. display: flex;
  281. align-items: center;
  282. justify-content: center;
  283. }
  284. }
  285. }
  286. }
  287. }
  288. </style>