index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439
  1. <template>
  2. <view class="content">
  3. <!-- <view>
  4. <view>点击授权{{hasLogin}}</view>
  5. <button @click="wxlogion" open-type="getUserInfo">请点击授权</button>
  6. </view> -->
  7. <logionDialog @confirmDiaolog="confirmDiaolog" @cancelDiaolog="cancelDiaolog" :showdialog="showdialog"/>
  8. <scroll-view style="height: 100vh;" class="floor-list"
  9. :scroll-top="scrollTop" scroll-y="true" @scroll="scroll" @scrolltoupper="upper" @scrolltolower="lower"
  10. refresher-enabled="true">
  11. <uniNavBar class="top" :shadow="false" :fixed="false" color="#333333" background-color="#FFFFFF">
  12. <block style="width: 70%;padding-left: 32upx;" slot="left">
  13. <view class="city">
  14. <view style="font-size: 35upx;">{{ location }}</view>
  15. </view>
  16. </block>
  17. <view class="input-view" style="float: right;">
  18. <uni-icon color="#606266" size="22" @click="scan" type="scan"></uni-icon>
  19. </view>
  20. <block slot="right">
  21. <view @click="goinfor">
  22. <uni-icon color="#606266" size="22" type="chat"></uni-icon>
  23. </view>
  24. </block>
  25. </uniNavBar>
  26. <view @click="goSearch" class="searchType" style="background: #fff;">
  27. <view class="input-view">
  28. <uni-icon type="search" size="22" color="#666666" />
  29. <input confirm-type="search" class="input" type="text" placeholder="搜索您入住的酒店" @confirm="confirm" />
  30. </view>
  31. </view>
  32. <view class="scrollswiper">
  33. <swiper class="swiper"
  34. :indicator-dots="indicatorDots"
  35. :autoplay="autoplay"
  36. :interval="interval"
  37. :duration="duration"
  38. >
  39. <!-- <img src="' + siteurl + "uploads/home/adv/" + item.adv_code + '"/></div>'); -->
  40. <swiper-item v-for="(item,index) in backgroundlist" :key="index">
  41. <view class="swiper-item" @tap="shopDetail(item)" >
  42. <image style="height: 100%;width: 100%;" :src='pictureUrl +"/uploads/home/adv/"+item.adv_code' />
  43. </view>
  44. </swiper-item>
  45. </swiper>
  46. </view>
  47. <view class="tips">
  48. 在附近酒店找到您入住的酒店
  49. </view>
  50. <view style="border-bottom: 2upx solid #EEEEEE;width: 100%;margin-bottom: 24upx 0;"></view>
  51. <view>
  52. <view class="hotelList" v-for='(item,index) in hotelist' :key="index" @click="openinfo(item)">
  53. <view class="hotleLeft">
  54. <image style="width: 214upx;height: 152upx;" :src="pictureUrl+'/uploads/home/adv/'+item.store_logo"/>
  55. </view>
  56. <view class="hotelright">
  57. <view style="font-size: 32upx;color: #303133;font-weight: 550;">{{item.store_name}}
  58. </view>
  59. <view style="display: flex;flex-direction: row;justify-content: space-between;align-items: center;padding: 10rpx 0;">
  60. <view style="font-size: 32upx; color: #303133;font-weight: 550;">{{item.store_servicecredit}}</view>
  61. <view style="color: #606266;font-size: 24upx;">月访客{{item.store_visitor}}</view>
  62. <view style="color: #606266;font-size: 24upx;">{{item.distance}}</view>
  63. </view>
  64. <view v-if="item.tages.length!=1" class="undertip">
  65. <view v-for="(items,index) in item.tages" :key="index" class="tipsTop">{{items}}</view>
  66. </view>
  67. </view>
  68. </view>
  69. </view>
  70. </scroll-view>
  71. </view>
  72. </template>
  73. <script>
  74. import {
  75. mapMutations,mapState
  76. } from 'vuex'
  77. import uniNavBar from '@/component/uni-nav-bar/uni-nav-bar.vue'
  78. import uniIcon from '@/component/uni-icon/uni-icon.vue'
  79. import logionDialog from '@/component/loginDialog.vue'
  80. import amap from '@/common/amap-wx.js'
  81. export default {
  82. components: {
  83. uniNavBar,
  84. uniIcon,
  85. logionDialog
  86. },
  87. data() {
  88. return {
  89. itemurl: '../../image/',
  90. page: 1,
  91. ispull: true,
  92. pagesize: 10,
  93. store_summary:[], // 标签数组
  94. pictureUrl: this.pictureUrl,
  95. amapPlugin: null,
  96. key: '7277de7a5833626b7da8f2496e9d6bf9',
  97. showdialog: false, // 点击确定显示弹窗
  98. backgroundlist: ['color1', 'color2', 'color3'], // 轮播数组
  99. hotelist:[], // 酒店数组
  100. indicatorDots: true,
  101. autoplay: true,
  102. interval: 2000,
  103. duration: 500,
  104. title: 'Hello',
  105. location:'正在定位...',
  106. scrollTop: 0,
  107. old: {
  108. scrollTop: 0
  109. }
  110. }
  111. },
  112. computed:{
  113. ...mapState([
  114. 'hasLogin',
  115. 'userInfo'
  116. ]),
  117. },
  118. onLoad() {
  119. this.getswiper(); // 获取首页轮播
  120. this.gethotelist(); // 酒店列表
  121. this.isGetLocation(); // 检查是否开启定位权限
  122. this.isUserInfo(); // 检查是否允许获取用户授权
  123. // 用户授全
  124. this.amapPlugin = new amap.AMapWX({
  125. key: this.key
  126. });
  127. },
  128. methods: {
  129. ...mapMutations(['login','showDialog']),
  130. goinfor() {
  131. if(this.hasLogin) {
  132. uni.navigateTo({
  133. url: '../myCenter/information' // 我的收藏
  134. })
  135. }else {
  136. this.showdialog = true;
  137. } },
  138. // 关闭弹窗
  139. cancelDiaolog() {
  140. this.showdialog = false;
  141. },
  142. // 确定
  143. confirmDiaolog() {
  144. this.showdialog = false;
  145. uni.navigateTo({
  146. url: '../myCenter/information' // 我的收藏
  147. })
  148. },
  149. goSearch() {
  150. uni.navigateTo({
  151. url: './searchresult' // 我的搜索
  152. })
  153. },
  154. // 滚动到顶部
  155. upper(e) {
  156. console.log("顶部")
  157. },
  158. // 滚到底部
  159. lower(e) {
  160. this.page = this.page + 1;
  161. if(this.ispull) {
  162. this.gethotelist();
  163. }
  164. },
  165. // 滚动时触发
  166. scroll(e) {
  167. this.old.scrollTop = e.detail.scrollTop
  168. },
  169. isGetLocation(a="scope.userLocation"){ // 检查当前是否已经授权访问scope属性W
  170. let _this=this;
  171. uni.getSetting({
  172. success(res) {
  173. // 用户定位接口
  174. if (!res.authSetting[a]) { // 每次进入程序判断当前是否获得授权,如果没有就去获得授权,如果获得授权,就直接获取当前地理位置
  175. _this.getAuthorizeInfo()
  176. }else{
  177. _this.getRegeo()
  178. }
  179. }
  180. });
  181. },
  182. // 进入判断是否授权
  183. isUserInfo(b='scope.userInfo') {
  184. let _this = this;
  185. uni.getSetting({
  186. success(res) {
  187. if(!res.authSetting[b]) {
  188. _this.showDialog(false);
  189. }else {
  190. _this.showDialog(true);
  191. }
  192. }
  193. })
  194. },
  195. getAuthorizeInfo(a="scope.userLocation"){ //uniapp弹窗弹出获取授权弹窗
  196. let _this=this;
  197. uni.authorize({
  198. scope: a,
  199. success() { //允许授权
  200. console.log("调用位置授权")
  201. _this.getRegeo();
  202. },
  203. fail(){ //拒绝授权
  204. _this.$msg("你拒绝了授权,无法获得周边信息")
  205. }
  206. })
  207. },
  208. getRegeo(){ //获取地理位置
  209. let _this=this;
  210. uni.showLoading({
  211. title: '获取信息中'
  212. });
  213. _this.amapPlugin.getRegeo({
  214. success: (data) => {
  215. this.location = data[0].name;
  216. uni.hideLoading();
  217. },
  218. fail: (res) => {
  219. console.log(res);
  220. uni.hideLoading();
  221. }
  222. });
  223. },
  224. // 获取首页轮播
  225. getswiper() {
  226. let _this = this;
  227. this.request({
  228.                 url:"/v1/entry/adv",
  229.                 method:'get',
  230. success: function(res) {
  231. _this.backgroundlist = res.data.data;
  232. }
  233. })
  234. },
  235. // 获取酒店列表
  236. gethotelist() {
  237. let _this=this;
  238. this.request({
  239.                 url:"/v2/entry/storeList",
  240.                 method:'get',
  241. data: {
  242. page: _this.page,
  243. page_size: 10
  244. },
  245. success: function(res) {
  246. let { data,code } = res.data;
  247. if(code == 1000) {
  248. if(data.store_list.length<10) {
  249. _this.ispull = false;
  250. }
  251. if(_this.hotelist.length == 0) {
  252. _this.hotelist = data.store_list
  253. }else {
  254. _this.hotelist = _this.hotelist.concat(data.store_list);
  255. }
  256. _this.hotelist.forEach(item => {
  257. item.tages = item.store_summary.split(' ');
  258. })
  259. console.log(_this.hotelist)
  260. }else {
  261. _this.$msg("网络错误稍后再试")
  262. }
  263. }
  264. })
  265. },
  266. // 点击扫码
  267. scan(){
  268. uni.scanCode({
  269. success: (res) => {
  270. console.log(res);
  271. }
  272. });
  273. },
  274. // 跳转到新页面 酒店详情
  275. openinfo(item) {
  276. let id = item.store_id;
  277. uni.navigateTo({
  278. url: `/pages/index/hotel?id=${id}`
  279. });
  280. },
  281. // 跳转到商品详情
  282. shopDetail(item) {
  283. let id = item.adv_target.goods_id;
  284. let store_id = item.adv_target.store_id;
  285. if(item.adv_target.type == 'goods') {
  286. uni.navigateTo({
  287. url: `/pages/index/shop?id=${id}&store_id=${store_id}`
  288. });
  289. }else if(item.adv_target.type == 'store') {
  290. let id = item.adv_target.store_id;
  291. let title = item.adv_target.store_name;
  292. uni.navigateTo({
  293. url: `/pages/index/hotel?id=${id}`
  294. });
  295. }
  296. }
  297. }
  298. }
  299. </script>
  300. <style>
  301. .top .uni-navbar__header-btns {
  302. width: 77%!important;
  303. }
  304. .top .uni-navbar__header-container {
  305. width: 50%!important;
  306. }
  307. .content {
  308. background: #fff;
  309. }
  310. .city {
  311. width: 100%;
  312. height: 100%;
  313. white-space:nowrap;
  314. overflow:hidden;
  315. text-overflow:ellipsis;
  316. }
  317. .logo {
  318. height: 200upx;
  319. width: 200upx;
  320. margin-top: 200upx;
  321. margin-left: auto;
  322. margin-right: auto;
  323. margin-bottom: 50upx;
  324. }
  325. .text-area {
  326. display: flex;
  327. justify-content: center;
  328. }
  329. .title {
  330. font-size: 36upx;
  331. color: #8f8f94;
  332. }
  333. .van-cell--borderless {
  334. background-color: #e7e7e7!important;
  335. }
  336. .searchType .input-view {
  337. width: 85%;
  338. display: flex;
  339. background-color: #e7e7e7;
  340. height: 30px;
  341. border-radius: 15px;
  342. padding: 0 4%;
  343. flex-wrap: nowrap;
  344. margin: 7px 0;
  345. line-height: 30px;
  346. margin: 24upx auto;
  347. }
  348. .searchType .input-view .uni-icon {
  349. line-height: 30px !important;
  350. }
  351. .searchType .input-view .input {
  352. height: 30px;
  353. line-height: 30px;
  354. width: 94%;
  355. padding: 0 3%;
  356. }
  357. .uni-navbar--border::after {
  358. background: #fff!important;
  359. }
  360. .swiper {
  361. height: 300upx;
  362. }
  363. .swiper-item {
  364. display: block;
  365. height: 300upx;
  366. line-height: 300upx;
  367. text-align: center;
  368. }
  369. .scrollswiper {
  370. width: 90%;
  371. margin: 20upx auto;
  372. }
  373. .tips {
  374. color: #303133;
  375. font-size: 28upx;
  376. text-align: center;
  377. margin: 24upx 0;
  378. }
  379. .hotelList {
  380. display: flex;
  381. flex-direction: row;
  382. padding: 24upx 32upx;
  383. }
  384. .hotleLeft {
  385. width: 214upx;
  386. height: 152upx;
  387. }
  388. .hotelright {
  389. padding-left: 16upx;
  390. display: flex;
  391. flex-direction: column;
  392. width: 100%;
  393. }
  394. .undertip {
  395. display: flex;
  396. flex-direction: row;
  397. align-items: center;
  398. }
  399. .tipsTop {
  400. border: 2upx solid #606266;
  401. margin-right: 12upx;
  402. color: #606266;
  403. padding: 4upx;
  404. font-size: 24upx;
  405. border-radius: 4rpx;
  406. padding: 0 10rpx;
  407. }
  408. </style>