index.vue 28 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012
  1. <template>
  2. <view class="home">
  3. <zs-skeleton :loading="loading"></zs-skeleton>
  4. <zs-banner :city="city" :background="background" position @handlePosition="chooseCity" @search="handleSearch"></zs-banner>
  5. <view class="login-home">
  6. <!-- 登录显示的套餐列表 -->
  7. <view class="discount-list">
  8. <view class="discount-item" v-for="(item,index) in discountsList" :key="index" @click="goDetail(item.domainUrl,item.id,item.secondaryImg,item.menuName)">
  9. <image class="icon" :src="item.imgUrl" mode=""></image>
  10. <view class="title">{{item.menuName}}</view>
  11. <view class="tag" v-if="item.labelAbove">
  12. {{item.labelAbove}}
  13. </view>
  14. <view class="desc">
  15. {{item.labelBelow || ''}}
  16. </view>
  17. </view>
  18. </view>
  19. <!-- 广告位 -->
  20. <!-- <view class="advertise-box">
  21. <view class="item" v-for="item in advList" :key="item.id">
  22. <zs-img
  23. :src="item.advertsImg"
  24. width="335rpx" height="188rpx" radius="full" mode=""></zs-img>
  25. </view>
  26. </view> -->
  27. <view class="content">
  28. <!-- 列表 -->
  29. <zs-list class="store-box" mt="0" @load="loadMore" :status="status">
  30. <view class="left">
  31. <!-- <view class="swiper-box">
  32. <swiper class="swiper" @change="swiperChange" skip-hidden-item-layout indicator-dots indicator-color="#fff" indicator-active-color="#FF4D3A" circular :autoplay="true"
  33. :interval="3000" :duration="1000">
  34. <swiper-item v-for="(item,index) in advList" :key="item.id" @click="jump(item.jumpUrl)">
  35. <image class="swiper-item" mode="" :src="item.advertsImg">
  36. </image>
  37. </swiper-item>
  38. </swiper>
  39. </view> -->
  40. <view class="store-item" v-for="(item,index) in list" :key="index">
  41. <view @click="goGoodsDetail(item)">
  42. <zs-img :src="item.cover[0]" width="344rpx" height="344rpx" :radius="item.productType=='Web'?'full':'half'" mode="widthFix"></zs-img>
  43. <!-- <zs-img :src="item.goodsVos[0].goodsImg" width="344rpx" height="344rpx" mode=""></zs-img> -->
  44. <view class="info" v-if="item.productType!='Web'">
  45. <view class="title">
  46. <!-- <view class="tag">
  47. 今日特惠
  48. </view> -->
  49. <view class="text">
  50. {{item.title}}
  51. </view>
  52. </view>
  53. <!-- <view class="desc">
  54. {{item.goodsVos[0].goodsDescribe}}
  55. </view> -->
  56. <!-- <view class="discount-tag" v-if="item.salePrice&&item.originalPrice">
  57. {{(item.salePrice/item.originalPrice)*10}}
  58. </view> -->
  59. <view class="price-box">
  60. <view class="left">
  61. <text class="price" v-if="item.salePrice">
  62. ¥{{(item.salePrice/100).toFixed(2)}} {{item.productType=='PetrolStation'?'/L':''}}
  63. </text>
  64. <text class="label" v-if="(item.productType=='Scenic'||item.productType=='Hotel'||item.productType=='Cinema'||item.productType=='MovieTicket'||item.productType=='Restaurant'||item.productType=='Shop')&&item.salePrice">
  65. </text>
  66. <text class="old-price" v-if="item.originalPrice">
  67. ¥{{(item.originalPrice/100).toFixed(2)}}
  68. </text>
  69. </view>
  70. <!-- <view class="right" v-if="item.salesCount">
  71. 销量{{item.salesCount}}
  72. </view> -->
  73. </view>
  74. <view class="address-box">
  75. <view class="address">
  76. {{item.address || ''}}
  77. </view>
  78. <view class="distance" v-if="item.distance">
  79. {{item.distance | filterDis}}
  80. </view>
  81. </view>
  82. </view>
  83. </view>
  84. </view>
  85. </view>
  86. <view class="right">
  87. <view class="store-item" v-for="(item,index) in list1" :key="index">
  88. <view @click="goGoodsDetail(item)">
  89. <zs-img :src="item.cover[0]" width="344rpx" height="344rpx" :radius="item.productType=='Web'?'full':'half'" mode="widthFix"></zs-img>
  90. <view class="info" v-if="item.productType!='Web'">
  91. <view class="title">
  92. <!-- <view class="tag">
  93. 今日特惠
  94. </view> -->
  95. <view class="text">
  96. {{item.title}}
  97. </view>
  98. </view>
  99. <!-- <view class="discount-tag">
  100. {{(item.salePrice/item.originalPrice)*10}}
  101. </view> -->
  102. <!-- <view class="desc">
  103. {{item.goodsVos[0].goodsDescribe}}
  104. </view> -->
  105. <view class="price-box">
  106. <view class="left">
  107. <text class="price" v-if="item.salePrice">
  108. ¥{{(item.salePrice/100).toFixed(2)}} {{item.productType=='PetrolStation'?'/L':''}}
  109. </text>
  110. <text class="label" v-if="(item.productType=='Scenic'||item.productType=='Hotel'||item.productType=='Cinema'||item.productType=='MovieTicket'||item.productType=='Restaurant'||item.productType=='Shop')&&item.salePrice">
  111. </text>
  112. <text class="old-price" v-if="item.originalPrice">
  113. ¥{{(item.originalPrice/100).toFixed(2)}}
  114. </text>
  115. </view>
  116. <!-- <view class="right" v-if="item.salesCount">
  117. 销量{{item.salesCount}}
  118. </view> -->
  119. </view>
  120. <view class="address-box">
  121. <view class="address">
  122. {{item.address || ''}}
  123. </view>
  124. <view class="distance" v-if="item.distance">
  125. {{item.distance |filterDis}}
  126. </view>
  127. </view>
  128. </view>
  129. </view>
  130. </view>
  131. </view>
  132. </zs-list>
  133. </view>
  134. </view>
  135. <!-- 广告弹窗 -->
  136. <zs-adv-dialog :list="dialogAdvList"></zs-adv-dialog>
  137. </view>
  138. </template>
  139. <script>
  140. import {
  141. getUserDetail,
  142. getMenu,
  143. getAdv,
  144. homeSearch,
  145. queryFromLocation,
  146. getDistrict
  147. } from '@/api/common.js'
  148. import {cityList} from '@/api/movie.js'
  149. import {getCityList,refreshVip} from '@/api/common'
  150. import { search } from '@/api/shop.js';
  151. // 腾讯地图
  152. var QQMapWX = require('../../libs/qqmap-wx-jssdk.min.js');
  153. var qqmapsdk = new QQMapWX({key:'KX5BZ-B64RC-RO62W-AMWAZ-VVTC3-YAFXF'});
  154. export default {
  155. data() {
  156. return {
  157. background:false,
  158. loading: false,
  159. userId: '',
  160. city:'定位中',
  161. status: 'more',
  162. current:0,
  163. discountsList: [],//菜单
  164. advList:[],
  165. advList1:[],
  166. dialogAdvList:[],
  167. list: [],
  168. copyList: [],
  169. list1: [],
  170. copyList1: [],
  171. query:{
  172. distance:1000000000,
  173. latitude:0,
  174. longitude:0,
  175. regionCode:'',
  176. page:0,
  177. size:10
  178. },
  179. imgUrl:{
  180. Kfc:'https://hyxhsh.oss-cn-chengdu.aliyuncs.com/63b7c68b71a69169d1b33f92/store/bdb/user/avatar/xgJrwD0vChsW012ac1e138a0aa5a970e8f8c59dab926.png/1.png',
  181. MDL:'https://hyxhsh.oss-cn-chengdu.aliyuncs.com/63b7c68b71a69169d1b33f92/store/bdb/user/avatar/K64jffEqRIDr487e8cab971c3b890d4066a26f5856d2.png/1.png',
  182. XBK:'https://hyxhsh.oss-cn-chengdu.aliyuncs.com/63b7c68b71a69169d1b33f92/store/bdb/user/avatar/xMwtPkICBcam5513c4ac644054e60009cb8b1eb52e8f.png/1.png',
  183. NXDC:'https://hyxhsh.oss-cn-chengdu.aliyuncs.com/63b7c68b71a69169d1b33f92/store/bdb/user/avatar/U9j6fgVmKeAt522ed50aa1a72f798260e0e30138d4c6.png/1.png',
  184. RXKF:'https://hyxhsh.oss-cn-chengdu.aliyuncs.com/63b7c68b71a69169d1b33f92/store/bdb/user/avatar/zS5Q8sC9AAQca76eef36da2bd5a2ec234d75d8dcc044.png/1.png',
  185. XC:'https://hyxhsh.oss-cn-chengdu.aliyuncs.com/63b7c68b71a69169d1b33f92/store/bdb/user/avatar/fA95my16Qunf967a9d992fc41134332926bcb5665881.png/1.png',
  186. KD:'https://hyxhsh.oss-cn-chengdu.aliyuncs.com/63b7c68b71a69169d1b33f92/store/bdb/user/avatar/wk5eyuvhighG206a7ea081e3f0b783ff2a9555375e85.png/1.png',
  187. }
  188. // query:{
  189. // queryName:'',
  190. // 'location.lat':0,
  191. // 'location.lon':0,
  192. // pageCurrent:1,
  193. // pageSize:100
  194. // },
  195. }
  196. },
  197. filters: {
  198. filterDis: function(value) {
  199. if(value<1000){
  200. return value.toFixed(0) +'m';
  201. }else{
  202. return (value/1000).toFixed(0)+'km'
  203. }
  204. }
  205. },
  206. methods: {
  207. formatImg(item){
  208. if(item.productType == 'Kfc'){
  209. // if(){
  210. // }
  211. }else{
  212. return item.cover[0]
  213. }
  214. },
  215. chooseCity(){
  216. uni.navigateTo({
  217. url:`/hotel/cityList?backUrl=/pages/index/index`
  218. })
  219. },
  220. // swiper变动
  221. swiperChange(val) {
  222. this.current = val.target.current
  223. },
  224. jump(url){
  225. uni.reLaunch({
  226. url
  227. })
  228. },
  229. // 点击搜索
  230. handleSearch(){
  231. if(!uni.getStorageSync('token')){
  232. return uni.showModal({
  233. title:'请登录',
  234. confirmText:'去登录',
  235. success(res){
  236. if(res.confirm){
  237. uni.navigateTo({
  238. url:'/login/login/login?redirect=/pages/index/index'
  239. })
  240. }
  241. }
  242. })
  243. }
  244. uni.reLaunch({
  245. url:'./search'
  246. })
  247. // if(!val) return
  248. // this.query.queryName = val
  249. // this.query.pageCurrent = 1
  250. // this.list = []
  251. // this.list1 = []
  252. // this.status = 'more'
  253. // this.search()
  254. },
  255. // 获取当前城市
  256. getCity(){
  257. let that = this
  258. this.city = '定位中'
  259. return new Promise((resolve,reject)=>{
  260. uni.getLocation({
  261. type: 'gcj02',
  262. success: (res) => {
  263. // 解析地址
  264. that.query.latitude = res.latitude
  265. that.query.longitude = res.longitude
  266. // that.query['location.lat'] = res.latitude
  267. // that.query['location.lon'] = res.longitude
  268. // 存储经纬度
  269. uni.setStorageSync('location',JSON.stringify({latitude:res.latitude,longitude:res.longitude}))
  270. if(that.query.regionCode){//选择了城市
  271. console.log('选择了城市',that.city);
  272. that.city = uni.getStorageSync('HomeCity') || uni.getStorageSync('city')
  273. getDistrict({boundary:1,keyword:that.city,sub_admin:1,extensions_code:1}).then(r=>{
  274. console.log('区域',r);
  275. let data = []
  276. r.content.districts&&r.content.districts[0].districts.map((item,index)=>{
  277. data.push({
  278. label:item.name,
  279. id:index
  280. })
  281. })
  282. uni.setStorageSync('districtList',JSON.stringify(data))
  283. resolve()
  284. })
  285. }else{//没选择城市
  286. console.log('没选择城市',that.city);
  287. queryFromLocation({
  288. coordType:'gcj02ll',
  289. lat: res.latitude,
  290. lng: res.longitude
  291. }).then(res=>{
  292. console.log('解析结果',res);
  293. if(res.state == 'Success'){
  294. that.query.regionCode = res.content.geoAddressComponent.adcode.substr(0,4) +'00'
  295. that.city = res.content.geoAddressComponent.city
  296. uni.setStorageSync('city',res.content.geoAddressComponent.city)
  297. getDistrict({boundary:1,keyword:that.city,sub_admin:1,extensions_code:1}).then(r=>{
  298. console.log('区域',r);
  299. let data = []
  300. r.content.districts&&r.content.districts[0].districts.map((item,index)=>{
  301. data.push({
  302. label:item.name,
  303. id:index
  304. })
  305. })
  306. uni.setStorageSync('districtList',JSON.stringify(data))
  307. resolve()
  308. })
  309. }
  310. })
  311. // qqmapsdk.reverseGeocoder({
  312. // location: {
  313. // latitude: res.latitude,
  314. // longitude: res.longitude
  315. // },
  316. // success: function(res) {
  317. // // 市
  318. // that.city = res.result.address_component.city
  319. // if(uni.setStorageSync('districtList')&&uni.getStorageSync('city')==that.city) return
  320. // uni.setStorageSync('city',res.result.address_component.city)
  321. // // 获取市区的行政区
  322. // qqmapsdk.getDistrictByCityId({
  323. // // 传入对应省份ID获得城市数据,传入城市ID获得区县数据,依次类推
  324. // id: res.result.ad_info.city_code.substr(3), //对应接口getCityList返回数据的Id,如:北京是'110000'
  325. // success: function(res) {//成功后的回调
  326. // console.log('对应城市ID下的区县数据:', res.result[0]);
  327. // let data = res.result[0]
  328. // data.map(item=>{
  329. // item.label = item.fullname
  330. // })
  331. // uni.setStorageSync('districtList',JSON.stringify(data))
  332. // },
  333. // fail: function(error) {
  334. // console.error(error);
  335. // },
  336. // complete: function(res) {
  337. // console.log(res);
  338. // }
  339. // });
  340. // resolve()
  341. // },
  342. // fail: function(res) {
  343. // that.city = '定位失败'
  344. // },
  345. // })
  346. }
  347. },
  348. fail: () => {
  349. console.log("获取经纬度失败");
  350. },
  351. })
  352. })
  353. },
  354. // 跳转优惠详情
  355. goDetail(url,id,banner,title) {
  356. uni.navigateTo({
  357. url: `${url}?id=${id}&title=${title}`,
  358. success(res) {
  359. res.eventChannel.emit('banner', banner)
  360. }
  361. })
  362. },
  363. goGoodsDetail(item) {
  364. // uni.setStorageSync('shopInfo', JSON.stringify(item))
  365. let url = ''
  366. if (item.productType === 'Web') {
  367. url = item.meta.url
  368. console.log('链接');
  369. } else if (item.productType === 'Recharge') {
  370. url = '/detail/virtualGoods/index'
  371. console.log('充值类');
  372. } else if (item.productType === 'Scenic') {
  373. url = '/scenic/detail'
  374. console.log('景区');
  375. } else if (item.productType === 'ScenicTicket') {
  376. console.log('景区门票');
  377. } else if (item.productType === 'StudyTour') {
  378. url = '/detail/virtualGoods/index'
  379. console.log('StudyTour');
  380. } else if (item.productType === 'Hotel') {
  381. url = '/hotel/hotelDetail'
  382. console.log('酒店');
  383. } else if (item.productType === 'HotelRoom') {
  384. url = '/hotel/hotelDetail'
  385. console.log('酒店房型');
  386. } else if (item.productType === 'Cinema') {
  387. url = '/movie/movieList'
  388. console.log('电影院');
  389. } else if (item.productType === 'MovieTicket') {
  390. url = '/movie/movieDetail'
  391. console.log('电影票');
  392. } else if (item.productType === 'Restaurant') {
  393. url = '/detail/virtualGoods/index'
  394. console.log('餐厅');
  395. } else if (item.productType === 'RestaurantFood') {
  396. url = '/detail/discountsDetail/index'
  397. console.log('餐厅美食');
  398. } else if (item.productType === 'CarMaintain') {
  399. url = '/detail/discountsDetail/index'
  400. console.log('汽车保养门店');
  401. } else if (item.productType === 'CarMaintainGoods') {
  402. url = '/detail/detail/discountsDetail/index/index'
  403. console.log('汽车保养商品');
  404. } else if (item.productType === 'CarMaintainService') {
  405. url = '/detail/detail/discountsDetail/index/index'
  406. console.log('汽车保养服务');
  407. } else if (item.productType === 'Shop') {
  408. url = '/detail/shopDetail/shopDetail'
  409. console.log('店铺');
  410. } else if (item.productType === 'ShopGoods') {
  411. url = '/detail/goodsDetail/index'
  412. console.log('店铺商品');
  413. } else if (item.productType === 'ShopService') {
  414. url = '/detail/goodsDetail/index'
  415. console.log('店铺服务');
  416. } else if (item.productType === 'Coupon') {
  417. url = '/detail/goodsDetail/index'
  418. console.log('优惠券');
  419. }
  420. else if (item.productType === 'PetrolStation') {
  421. url = '/refuel/refuelDetail'
  422. console.log('加油站');
  423. }
  424. else {
  425. // 处理未知或未定义的产品类型
  426. console.log('未知产品类型');
  427. }
  428. uni.navigateTo({
  429. // url: `../../detail/goodsDetail/index?id=${item.goodsVos[0].goodsId}`
  430. url: `${url}?id=${item.pid}&epId=${item.id}`
  431. })
  432. },
  433. // 更多套餐
  434. handleMore() {
  435. uni.reLaunch({
  436. // url:'../../login/login/login'
  437. url: '../../combo/combo/combo'
  438. })
  439. },
  440. // 获取用户详情
  441. getUserDetail() {
  442. getUserDetail().then(res => {
  443. uni.setStorageSync('userInfo', JSON.stringify(res.content))
  444. })
  445. },
  446. loadMore() {
  447. // if(this.query['location.lat']&&this.query['location.lon']){
  448. if(this.query.latitude&&this.query.longitude&&this.query.regionCode){
  449. this.search()
  450. }
  451. },
  452. search() {
  453. if(this.status == 'noMore' || this.status == 'loading') return
  454. this.status = 'loading'
  455. homeSearch(this.query).then(res=>{
  456. if(res.state == 'Success'){
  457. this.loading = false
  458. let list = []
  459. let list1 = []
  460. let data = res.content.content
  461. data.map((item,index)=>{
  462. if(item.productType == 'Cinema'){
  463. delete item.meta
  464. }
  465. if(index%2 == 0){
  466. list.push(item)
  467. }else{
  468. list1.push(item)
  469. }
  470. })
  471. // 存储原始数据
  472. this.list = this.list.concat(list)
  473. this.list1 = this.list1.concat(list1)
  474. // this.list = JSON.parse(JSON.stringify(this.copyList))
  475. // this.list1 = JSON.parse(JSON.stringify(this.copyList1))
  476. let total = this.list.length + this.list1.length
  477. if(total >= res.content.totalElements){
  478. this.status = 'noMore'
  479. }else{
  480. this.status = 'more'
  481. this.query.page++
  482. }
  483. // if(!this.advList1.length){
  484. // this.getGoodsAdv().then(()=>{
  485. // this.advList1.map(item=>{
  486. // if(item.showSort<= (this.list.length + this.list1.length)){
  487. // if((item.showSort-1)%2 == 0){
  488. // this.list.splice(Math.ceil(item.showSort/2)-1,0,{isAdv:true,...item})
  489. // }else{
  490. // this.list1.splice(Math.ceil(item.showSort/2)-1,0,{isAdv:true,...item})
  491. // }
  492. // }
  493. // })
  494. // }
  495. // )
  496. // }else{
  497. // this.advList1.map(item=>{
  498. // if(item.showSort<= (this.list.length + this.list1.length)){
  499. // if((item.showSort-1)%2 == 0){
  500. // this.list.splice(Math.ceil(item.showSort/2)-1,0,{isAdv:true,...item})
  501. // }else{
  502. // this.list1.splice(Math.ceil(item.showSort/2)-1,0,{isAdv:true,...item})
  503. // }
  504. // }
  505. // })
  506. // }
  507. }
  508. })
  509. },
  510. // 金刚区
  511. getMenu(){
  512. return new Promise((resolve,reject)=>{
  513. getMenu({currentPage:1,pageSize:10,status:2,belongType:2}).then(res=>{
  514. if(res.state == 'Success'){
  515. this.discountsList = res.content.records
  516. resolve(1)
  517. }
  518. })
  519. })
  520. },
  521. // 广告位
  522. getAdv(){
  523. return new Promise((resolve,reject)=>{
  524. getAdv({currentPage:1,pageSize:10,advertsType:1,status:1,belongType:2}).then(res=>{
  525. if(res.state == 'Success'){
  526. this.advList = res.content.records
  527. // this.advList = res.content.records.filter((item,index)=>index<2)
  528. // this.advList1 = res.content.records.filter((item,index)=>index>=2)
  529. resolve(2)
  530. }
  531. })
  532. })
  533. },
  534. // 弹窗广告
  535. getDialogAdv() {
  536. let loginShow
  537. if(uni.getStorageSync('token')){
  538. loginShow = 2
  539. }else{
  540. loginShow = 1
  541. }
  542. getAdv({
  543. currentPage: 1,
  544. pageSize: 99,
  545. status:1,
  546. belongType: 2,
  547. loginShow,
  548. advertsType: 6,
  549. }).then((res) => {
  550. if (res.state == "Success") {
  551. this.dialogAdvList = res.content.records
  552. }
  553. });
  554. },
  555. // 获取商品列表内广告位
  556. getGoodsAdv(){
  557. return new Promise((resolve,reject)=>{
  558. getAdv({currentPage:1,pageSize:99,advertsType:2,status:1,belongType:2}).then(res=>{
  559. if(res.state == 'Success'){
  560. this.advList1 = res.content.records
  561. resolve(2)
  562. }
  563. })
  564. })
  565. },
  566. // 获取电影票城市id
  567. cityList(){
  568. return new Promise((resolve,reject)=>{
  569. cityList().then(res=>{
  570. if(res.state == 'Success'){
  571. let city = uni.getStorageSync('city').replace('市','')
  572. let cityId = res.content.data.filter(item=>item.name == city)[0].cityId
  573. uni.setStorageSync('movieCityId',cityId)
  574. resolve()
  575. }
  576. })
  577. })
  578. },
  579. getCityList() {
  580. return new Promise((resolve,reject)=>{
  581. getCityList({name:'',page:0,size:999}).then(res=>{
  582. if(res.state == 'Success'){
  583. let city = this.city.replace('市','')
  584. res.content.content.forEach(item=>{
  585. if(item.name.indexOf(city) != -1){
  586. // this.query.regionCode = item.code
  587. resolve()
  588. }
  589. })
  590. resolve()
  591. }
  592. })
  593. })
  594. }
  595. },
  596. onPageScroll(e) {
  597. if(e.scrollTop >= 50){
  598. this.background = true
  599. }else{
  600. this.background = false
  601. }
  602. },
  603. onShow() {
  604. if (uni.getStorageSync('token')&&!uni.getStorageSync('userInfo')) {
  605. this.getUserDetail()
  606. }
  607. if(uni.getStorageSync('token')){
  608. refreshVip().then(res=>{
  609. if(res.state == 'Success'){
  610. this.getUserDetail()
  611. }
  612. })
  613. }
  614. },
  615. onHide() {
  616. },
  617. onLoad(query){
  618. console.log(444,query);
  619. this.loading = true
  620. const token = uni.getStorageSync('token')
  621. console.log(!!token)
  622. if(query.scene){
  623. // const token = uni.getStorageSync('token')
  624. if(token){
  625. uni.showToast({
  626. title: '已经是平台用户',
  627. icon: 'none'
  628. });
  629. return
  630. }
  631. uni.setStorageSync('inviteCode',decodeURIComponent(query.scene))
  632. }
  633. this.query.regionCode = query.regionCode || ''
  634. this.getDialogAdv()
  635. this.status = 'more'
  636. this.list = []
  637. this.list1 = []
  638. this.query.page = 0
  639. Promise.all([this.getMenu(),this.getCity()]).then(res=>{
  640. this.search()
  641. // if(query.regionCode){
  642. // this.search()
  643. // }else{
  644. // this.getCityList().then(()=>{
  645. // this.search()
  646. // })
  647. // }
  648. this.cityList()
  649. })
  650. },
  651. onShareTimeline() {
  652. return {
  653. title: "慧研学惠生活",
  654. query: "id=1",
  655. imageUrl: "https://hyxhsh.oss-cn-chengdu.aliyuncs.com/63b7c68b71a69169d1b33f92/store/bdb/user/avatar/XHBjBiMRhVYG8f1a30bbbd80c2346197b81470444c9a.png/1.png",
  656. };
  657. },
  658. onShareAppMessage() {
  659. return {
  660. title: "慧研学惠生活",
  661. path: "/pages/index/index",
  662. };
  663. },
  664. onPullDownRefresh() {
  665. this.status = 'more'
  666. this.list = []
  667. this.list1 = []
  668. this.query.page = 0
  669. Promise.all([this.getMenu(),this.getCity()]).then(res=>{
  670. this.getCityList().then(()=>{
  671. this.search()
  672. })
  673. // this.cityList()
  674. uni.stopPullDownRefresh()
  675. })
  676. },
  677. created() {
  678. // this.loading = true
  679. // this.getDialogAdv()
  680. // Promise.all([this.getMenu(),this.getCity()]).then(res=>{
  681. // this.getCityList().then(()=>{
  682. // this.search()
  683. // })
  684. // this.cityList()
  685. // })
  686. }
  687. }
  688. </script>
  689. <style lang="scss">
  690. .home {
  691. // padding-bottom:120rpx;
  692. // background: linear-gradient(180deg, #FFFFFF 0%, #DCE8FF 100%);
  693. background: #F9F9F9;
  694. .card-title {
  695. display: flex;
  696. justify-content: center;
  697. .title {
  698. font-size: 32rpx;
  699. text-align: center;
  700. color: #fff;
  701. width: 210rpx;
  702. line-height: 64rpx;
  703. background: linear-gradient(360deg, #3074F8 0%, #568FFF 100%);
  704. border-radius: 0rpx 0rpx 24rpx 24rpx;
  705. }
  706. }
  707. .login-home {
  708. // background: linear-gradient(178deg, #FFFFFF 0%, #F9F9F9 100%);
  709. // background: #FFF;
  710. .discount-list {
  711. display: flex;
  712. flex-wrap: wrap;
  713. // padding: 30rpx 0;
  714. margin: 0 24rpx 20rpx;
  715. // background: #fff;
  716. border-radius: 16rpx;
  717. position: relative;
  718. top: 20rpx;
  719. padding-top: 20rpx;
  720. .discount-item {
  721. width: 20%;
  722. display: flex;
  723. flex-direction: column;
  724. align-items: center;
  725. margin-top: 20rpx;
  726. margin-bottom: 20rpx;
  727. position: relative;
  728. .icon {
  729. width: 80rpx;
  730. height: 80rpx;
  731. }
  732. .title {
  733. font-size: 24rpx;
  734. margin-top: 10rpx;
  735. font-weight: 300;
  736. color: #222222;
  737. }
  738. .tag {
  739. position: absolute;
  740. top: -20rpx;
  741. left: 50%;
  742. background: #FF0615;
  743. box-shadow: inset 0rpx 6rpx 12rpx 2rpx rgba(255, 255, 255, 0.16);
  744. border-radius: 14rpx 14rpx 14rpx 0rpx;
  745. color: #fff;
  746. white-space: nowrap;
  747. font-size: 18rpx;
  748. line-height: 24rpx;
  749. height: 24rpx;
  750. padding: 0 10rpx;
  751. // width: fit-content;
  752. // background-size: 100% 34rpx;
  753. }
  754. .desc {
  755. color: #FF0817;
  756. font-size: 16rpx;
  757. text-align: center;
  758. margin-top: 4rpx;
  759. }
  760. }
  761. }
  762. .title-img {
  763. width: 686rpx;
  764. height: 166rpx;
  765. margin: 24rpx 32rpx;
  766. }
  767. .swiper-box{
  768. position: relative;
  769. width: 344rpx;
  770. height: 462rpx;
  771. border-radius: 16rpx;
  772. margin-bottom: 20rpx;
  773. .progress{
  774. position: absolute;
  775. top: 38rpx;
  776. right: 20rpx;
  777. z-index: 2;
  778. color: #FFFFFF;
  779. font-size: 16rpx;
  780. background: rgba(255, 255, 255, 0.3);
  781. padding: 2rpx 10rpx;
  782. border-radius: 14rpx;
  783. }
  784. .swiper {
  785. position: relative;
  786. height: 100%;
  787. .swiper-item {
  788. width: 344rpx;
  789. height: 462rpx;
  790. border-radius: 16rpx;
  791. object-fit: cover;
  792. }
  793. }
  794. }
  795. .advertise-box {
  796. display: flex;
  797. justify-content: space-between;
  798. margin: 0 24rpx;
  799. padding: 20rpx 0;
  800. }
  801. .content {
  802. border-radius: 16rpx 16rpx 0 0;
  803. }
  804. .zs-list {
  805. display: flex;
  806. flex-wrap: wrap;
  807. justify-content: space-between;
  808. padding: 0 24rpx;
  809. .left {
  810. .adv-swiper{
  811. width: 340rpx;
  812. height: 444rpx;
  813. margin-bottom: 25rpx;
  814. .adv-item{
  815. width: 340rpx;
  816. height: 444rpx;
  817. }
  818. }
  819. }
  820. .ad{
  821. width: 340rpx;
  822. border-radius: 16rpx;
  823. }
  824. .store-item {
  825. width: 344rpx;
  826. margin-bottom: 20rpx;
  827. // box-shadow: 0rpx 0rpx 24rpx 2rpx rgba(0, 0, 0, 0.08);
  828. border-radius: 16rpx;
  829. background: #fff;
  830. .icon {
  831. width: 100%;
  832. height: 300rpx;
  833. border-radius: 16rpx 16rpx 0 0;
  834. }
  835. .info{
  836. flex: 1;
  837. padding: 16rpx;
  838. position: relative;
  839. .title{
  840. margin-top: 10rpx;
  841. display: flex;
  842. align-items: center;
  843. .tag{
  844. display: inline-block;
  845. text-align: center;
  846. font-size: 20rpx;
  847. color: #FFFFFF;
  848. background: $uni-color-primary;
  849. padding: 2rpx 10rpx;
  850. border-radius: 8rpx;
  851. }
  852. .text{
  853. font-size: 28rpx;
  854. font-weight: bold;
  855. flex: 1;
  856. white-space: nowrap;
  857. overflow: hidden;
  858. text-overflow: ellipsis;
  859. }
  860. }
  861. .desc{
  862. font-size: 24rpx;
  863. color: #AAAAAA;
  864. overflow: hidden;
  865. text-overflow: ellipsis;
  866. /* 弹性伸缩盒子模型显示 */
  867. display: -webkit-box;
  868. /* 限制在一个块元素显示的文本的行数 */
  869. -webkit-line-clamp: 2;
  870. /* 设置或检索伸缩盒对象的子元素的排列方式 */
  871. -webkit-box-orient: vertical;
  872. margin-top: 12rpx;
  873. }
  874. .discount-tag{
  875. display: inline-block;
  876. padding: 0 10rpx;
  877. font-size: 20rpx;
  878. color: #EE4320;
  879. line-height: 28rpx;
  880. background: #FFF6F5;
  881. border-radius: 8rpx 8rpx 8rpx 8rpx;
  882. margin-top: 10rpx;
  883. }
  884. .price-box{
  885. display: flex;
  886. justify-content: space-between;
  887. align-items: center;
  888. margin-top: 12rpx;
  889. .left{
  890. display: flex;
  891. align-items: flex-end;
  892. vertical-align: bottom;
  893. .unit{
  894. font-size: 20rpx;
  895. color: $uni-color-primary;
  896. font-weight: bold;
  897. }
  898. .price{
  899. font-size: 32rpx;
  900. line-height: 32rpx;
  901. color: $uni-color-primary;
  902. font-weight: bold;
  903. }
  904. .label{
  905. font-size: 20rpx;
  906. color: #AAAAAA;
  907. margin-left: 6rpx;
  908. }
  909. .old-price{
  910. font-size: 20rpx;
  911. color: #AAAAAA;
  912. text-decoration: line-through;
  913. margin-left: 12rpx;
  914. }
  915. }
  916. .right{
  917. font-size: 24rpx;
  918. color: #AAAAAA;
  919. }
  920. }
  921. .address-box{
  922. display: flex;
  923. align-items: center;
  924. justify-content: space-between;
  925. font-size: 20rpx;
  926. color: #AAAAAA;
  927. margin-top: 15rpx;
  928. .address{
  929. width: 200rpx;
  930. overflow: hidden;
  931. text-overflow: ellipsis;
  932. /* 弹性伸缩盒子模型显示 */
  933. display: -webkit-box;
  934. /* 限制在一个块元素显示的文本的行数 */
  935. -webkit-line-clamp: 1;
  936. /* 设置或检索伸缩盒对象的子元素的排列方式 */
  937. -webkit-box-orient: vertical;
  938. }
  939. .distance{
  940. }
  941. }
  942. }
  943. }
  944. }
  945. }
  946. }
  947. </style>