index.vue 28 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003
  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.toFixed(5)
  265. that.query.longitude = res.longitude.toFixed(5)
  266. // that.query['location.lat'] = res.latitude
  267. // that.query['location.lon'] = res.longitude
  268. // 存储经纬度
  269. uni.setStorageSync('location',JSON.stringify({latitude:res.latitude.toFixed(5),longitude:res.longitude.toFixed(5)}))
  270. if(that.query.regionCode){//选择了城市
  271. uni.setStorageSync('regionCode',that.query.regionCode)
  272. console.log('选择了城市',that.city);
  273. that.city = uni.getStorageSync('HomeCity') || uni.getStorageSync('city')
  274. getDistrict({boundary:1,keyword:that.city,sub_admin:1,extensions_code:1}).then(r=>{
  275. console.log('区域',r);
  276. let data = []
  277. r.content.districts&&r.content.districts[0].districts.map((item,index)=>{
  278. data.push({
  279. label:item.name,
  280. id:index
  281. })
  282. })
  283. uni.setStorageSync('districtList',JSON.stringify(data))
  284. resolve()
  285. })
  286. }else{//没选择城市
  287. console.log('没选择城市',that.city);
  288. uni.setStorageSync('HomeCity','')
  289. queryFromLocation({
  290. coordType:'gcj02ll',
  291. lat: that.query.latitude,
  292. lng: that.query.longitude
  293. }).then(res=>{
  294. console.log('解析结果',res);
  295. if(res.content.status&&res.content.status == 302){
  296. that.query.regionCode = '520100'
  297. that.city = '贵阳'
  298. uni.setStorageSync('regionCode','520100')
  299. uni.setStorageSync('city','贵阳')
  300. resolve()
  301. }
  302. if(res.state == 'Success'){
  303. that.query.regionCode = res.content.geoAddressComponent.adcode.substr(0,4) +'00'
  304. uni.setStorageSync('regionCode',that.query.regionCode)
  305. that.city = res.content.geoAddressComponent.city
  306. uni.setStorageSync('city',res.content.geoAddressComponent.city)
  307. getDistrict({boundary:1,keyword:that.city,sub_admin:1,extensions_code:1}).then(r=>{
  308. console.log('区域',r);
  309. let data = []
  310. r.content.districts&&r.content.districts[0].districts.map((item,index)=>{
  311. data.push({
  312. label:item.name,
  313. id:index
  314. })
  315. })
  316. uni.setStorageSync('districtList',JSON.stringify(data))
  317. resolve()
  318. })
  319. }
  320. })
  321. // qqmapsdk.reverseGeocoder({
  322. // location: {
  323. // latitude: res.latitude,
  324. // longitude: res.longitude
  325. // },
  326. // success: function(res) {
  327. // // 市
  328. // that.city = res.result.address_component.city
  329. // if(uni.setStorageSync('districtList')&&uni.getStorageSync('city')==that.city) return
  330. // uni.setStorageSync('city',res.result.address_component.city)
  331. // // 获取市区的行政区
  332. // qqmapsdk.getDistrictByCityId({
  333. // // 传入对应省份ID获得城市数据,传入城市ID获得区县数据,依次类推
  334. // id: res.result.ad_info.city_code.substr(3), //对应接口getCityList返回数据的Id,如:北京是'110000'
  335. // success: function(res) {//成功后的回调
  336. // console.log('对应城市ID下的区县数据:', res.result[0]);
  337. // let data = res.result[0]
  338. // data.map(item=>{
  339. // item.label = item.fullname
  340. // })
  341. // uni.setStorageSync('districtList',JSON.stringify(data))
  342. // },
  343. // fail: function(error) {
  344. // console.error(error);
  345. // },
  346. // complete: function(res) {
  347. // console.log(res);
  348. // }
  349. // });
  350. // resolve()
  351. // },
  352. // fail: function(res) {
  353. // that.city = '定位失败'
  354. // },
  355. // })
  356. }
  357. },
  358. fail: () => {
  359. console.log("获取经纬度失败");
  360. },
  361. })
  362. })
  363. },
  364. // 跳转优惠详情
  365. goDetail(url,id,banner,title) {
  366. uni.navigateTo({
  367. url: `${url}?id=${id}&title=${title}`,
  368. success(res) {
  369. res.eventChannel.emit('banner', banner)
  370. }
  371. })
  372. },
  373. goGoodsDetail(item) {
  374. // uni.setStorageSync('shopInfo', JSON.stringify(item))
  375. let url = ''
  376. let cateName = '' //大牌点餐类型名
  377. let id = item.pid
  378. let epId = item.id
  379. if (item.productType === 'Web') {
  380. url = item.meta.url
  381. console.log('链接');
  382. } else if (item.productType === 'Recharge') {
  383. url = '/detail/virtualGoods/index'
  384. console.log('充值类');
  385. } else if (item.productType === 'Scenic') {
  386. url = '/scenic/detail'
  387. console.log('景区');
  388. } else if (item.productType === 'ScenicTicket') {
  389. console.log('景区门票');
  390. } else if (item.productType === 'StudyTour') {
  391. url = '/detail/virtualGoods/index'
  392. console.log('StudyTour');
  393. } else if (item.productType === 'Hotel') {
  394. url = '/hotel/hotelDetail'
  395. console.log('酒店');
  396. } else if (item.productType === 'HotelRoom') {
  397. url = '/hotel/hotelDetail'
  398. console.log('酒店房型');
  399. } else if (item.productType === 'Cinema') {
  400. url = '/movie/movieList'
  401. console.log('电影院');
  402. } else if (item.productType === 'MovieTicket') {
  403. url = '/movie/movieDetail'
  404. console.log('电影票');
  405. } else if (item.productType === 'Restaurant') {
  406. url = '/detail/virtualGoods/index'
  407. console.log('餐厅');
  408. } else if (item.productType === 'RestaurantFood') {
  409. url = '/orderFood/shopDetail'
  410. id = item.meta.menus.shop.id
  411. cateName = item.meta.menus.cate_name
  412. uni.setStorageSync('ot',item.meta.ot)
  413. console.log('大牌点餐');
  414. } else if (item.productType === 'CarMaintain') {
  415. url = '/detail/discountsDetail/index'
  416. console.log('汽车保养门店');
  417. } else if (item.productType === 'CarMaintainGoods') {
  418. url = '/detail/detail/discountsDetail/index/index'
  419. console.log('汽车保养商品');
  420. } else if (item.productType === 'CarMaintainService') {
  421. url = '/detail/detail/discountsDetail/index/index'
  422. console.log('汽车保养服务');
  423. } else if (item.productType === 'Shop') {
  424. url = '/detail/shopDetail/shopDetail'
  425. console.log('店铺');
  426. } else if (item.productType === 'ShopGoods') {
  427. url = '/detail/goodsDetail/index'
  428. console.log('店铺商品');
  429. } else if (item.productType === 'ShopService') {
  430. url = '/detail/goodsDetail/index'
  431. console.log('店铺服务');
  432. } else if (item.productType === 'Coupon') {
  433. url = '/detail/goodsDetail/index'
  434. console.log('优惠券');
  435. }
  436. else if (item.productType === 'PetrolStation') {
  437. url = '/refuel/refuelDetail'
  438. console.log('加油站');
  439. }
  440. else {
  441. // 处理未知或未定义的产品类型
  442. console.log('未知产品类型');
  443. }
  444. uni.navigateTo({
  445. // url: `../../detail/goodsDetail/index?id=${item.goodsVos[0].goodsId}`
  446. url: `${url}?id=${id}&epId=${epId}&cateName=${cateName}`
  447. })
  448. },
  449. // 更多套餐
  450. handleMore() {
  451. uni.reLaunch({
  452. // url:'../../login/login/login'
  453. url: '../../combo/combo/combo'
  454. })
  455. },
  456. // 获取用户详情
  457. getUserDetail() {
  458. getUserDetail().then(res => {
  459. uni.setStorageSync('userInfo', JSON.stringify(res.content))
  460. })
  461. },
  462. loadMore() {
  463. // if(this.query['location.lat']&&this.query['location.lon']){
  464. if(this.query.latitude&&this.query.longitude&&this.query.regionCode){
  465. this.search()
  466. }
  467. },
  468. search() {
  469. if(this.status == 'noMore' || this.status == 'loading') return
  470. this.status = 'loading'
  471. homeSearch(this.query).then(res=>{
  472. this.loading = false
  473. if(res.state == 'Success'){
  474. let list = []
  475. let list1 = []
  476. let data = res.content.content
  477. data.map((item,index)=>{
  478. if(item.productType == 'Cinema'){
  479. delete item.meta
  480. }
  481. if(index%2 == 0){
  482. list.push(item)
  483. }else{
  484. list1.push(item)
  485. }
  486. })
  487. // 存储原始数据
  488. this.list = this.list.concat(list)
  489. this.list1 = this.list1.concat(list1)
  490. let total = this.list.length + this.list1.length
  491. if(total >= res.content.totalElements){
  492. this.status = 'noMore'
  493. }else{
  494. this.status = 'more'
  495. this.query.page++
  496. }
  497. }
  498. })
  499. },
  500. // 金刚区
  501. getMenu(){
  502. return new Promise((resolve,reject)=>{
  503. getMenu({currentPage:1,pageSize:10,status:2,belongType:2}).then(res=>{
  504. if(res.state == 'Success'){
  505. this.discountsList = res.content.records
  506. resolve(1)
  507. }
  508. })
  509. })
  510. },
  511. // 广告位
  512. getAdv(){
  513. return new Promise((resolve,reject)=>{
  514. getAdv({currentPage:1,pageSize:10,advertsType:1,status:1,belongType:2}).then(res=>{
  515. if(res.state == 'Success'){
  516. this.advList = res.content.records
  517. // this.advList = res.content.records.filter((item,index)=>index<2)
  518. // this.advList1 = res.content.records.filter((item,index)=>index>=2)
  519. resolve(2)
  520. }
  521. })
  522. })
  523. },
  524. // 弹窗广告
  525. getDialogAdv() {
  526. let loginShow
  527. if(uni.getStorageSync('token')){
  528. loginShow = 2
  529. }else{
  530. loginShow = 1
  531. }
  532. getAdv({
  533. currentPage: 1,
  534. pageSize: 99,
  535. status:1,
  536. belongType: 2,
  537. loginShow,
  538. advertsType: 6,
  539. }).then((res) => {
  540. if (res.state == "Success") {
  541. this.dialogAdvList = res.content.records
  542. }
  543. });
  544. },
  545. // 获取商品列表内广告位
  546. getGoodsAdv(){
  547. return new Promise((resolve,reject)=>{
  548. getAdv({currentPage:1,pageSize:99,advertsType:2,status:1,belongType:2}).then(res=>{
  549. if(res.state == 'Success'){
  550. this.advList1 = res.content.records
  551. resolve(2)
  552. }
  553. })
  554. })
  555. },
  556. // 获取电影票城市id
  557. cityList(){
  558. return new Promise((resolve,reject)=>{
  559. cityList().then(res=>{
  560. if(res.state == 'Success'){
  561. let city = uni.getStorageSync('city').replace('市','')
  562. let cityId = res.content.data.filter(item=>item.name == city)[0].cityId
  563. uni.setStorageSync('movieCityId',cityId)
  564. resolve()
  565. }
  566. })
  567. })
  568. },
  569. getCityList() {
  570. return new Promise((resolve,reject)=>{
  571. getCityList({name:'',page:0,size:999}).then(res=>{
  572. if(res.state == 'Success'){
  573. let city = this.city.replace('市','')
  574. res.content.content.forEach(item=>{
  575. if(item.name.indexOf(city) != -1){
  576. // this.query.regionCode = item.code
  577. resolve()
  578. }
  579. })
  580. resolve()
  581. }
  582. })
  583. })
  584. }
  585. },
  586. onPageScroll(e) {
  587. if(e.scrollTop >= 50){
  588. this.background = true
  589. }else{
  590. this.background = false
  591. }
  592. },
  593. onShow() {
  594. if (uni.getStorageSync('token')&&!uni.getStorageSync('userInfo')) {
  595. this.getUserDetail()
  596. }
  597. if(uni.getStorageSync('token')){
  598. refreshVip().then(res=>{
  599. if(res.state == 'Success'){
  600. this.getUserDetail()
  601. }
  602. })
  603. }
  604. },
  605. onHide() {
  606. },
  607. onLoad(query){
  608. console.log(444,query);
  609. const token = uni.getStorageSync('token')
  610. console.log(!!token)
  611. if(query.scene){
  612. // const token = uni.getStorageSync('token')
  613. if(token){
  614. uni.showToast({
  615. title: '已经是平台用户',
  616. icon: 'none'
  617. });
  618. // return
  619. }else{
  620. uni.setStorageSync('inviteCode',decodeURIComponent(query.scene))
  621. }
  622. // uni.setStorageSync('inviteCode',decodeURIComponent(query.scene))
  623. }
  624. this.query.regionCode = query.regionCode || ''
  625. this.getDialogAdv()
  626. this.status = 'more'
  627. this.list = []
  628. this.list1 = []
  629. this.query.page = 0
  630. Promise.all([this.getMenu(),this.getCity()]).then(res=>{
  631. this.search()
  632. // if(query.regionCode){
  633. // this.search()
  634. // }else{
  635. // this.getCityList().then(()=>{
  636. // this.search()
  637. // })
  638. // }
  639. this.cityList()
  640. })
  641. },
  642. onShareTimeline() {
  643. return {
  644. title: "慧研学惠生活",
  645. query: "id=1",
  646. imageUrl: "https://hyxhsh.oss-cn-chengdu.aliyuncs.com/63b7c68b71a69169d1b33f92/store/bdb/user/avatar/XHBjBiMRhVYG8f1a30bbbd80c2346197b81470444c9a.png/1.png",
  647. };
  648. },
  649. onShareAppMessage() {
  650. return {
  651. title: "慧研学惠生活",
  652. path: "/pages/index/index",
  653. };
  654. },
  655. onPullDownRefresh() {
  656. this.status = 'more'
  657. this.list = []
  658. this.list1 = []
  659. this.query.page = 0
  660. Promise.all([this.getMenu(),this.getCity()]).then(res=>{
  661. this.getCityList().then(()=>{
  662. this.search()
  663. })
  664. // this.cityList()
  665. uni.stopPullDownRefresh()
  666. })
  667. },
  668. created() {
  669. // this.loading = true
  670. // this.getDialogAdv()
  671. // Promise.all([this.getMenu(),this.getCity()]).then(res=>{
  672. // this.getCityList().then(()=>{
  673. // this.search()
  674. // })
  675. // this.cityList()
  676. // })
  677. }
  678. }
  679. </script>
  680. <style lang="scss">
  681. .home {
  682. // padding-bottom:120rpx;
  683. // background: linear-gradient(180deg, #FFFFFF 0%, #DCE8FF 100%);
  684. background: #F9F9F9;
  685. .card-title {
  686. display: flex;
  687. justify-content: center;
  688. .title {
  689. font-size: 32rpx;
  690. text-align: center;
  691. color: #fff;
  692. width: 210rpx;
  693. line-height: 64rpx;
  694. background: linear-gradient(360deg, #3074F8 0%, #568FFF 100%);
  695. border-radius: 0rpx 0rpx 24rpx 24rpx;
  696. }
  697. }
  698. .login-home {
  699. // background: linear-gradient(178deg, #FFFFFF 0%, #F9F9F9 100%);
  700. // background: #FFF;
  701. .discount-list {
  702. display: flex;
  703. flex-wrap: wrap;
  704. // padding: 30rpx 0;
  705. margin: 0 24rpx 20rpx;
  706. // background: #fff;
  707. border-radius: 16rpx;
  708. position: relative;
  709. top: 20rpx;
  710. padding-top: 20rpx;
  711. .discount-item {
  712. width: 20%;
  713. display: flex;
  714. flex-direction: column;
  715. align-items: center;
  716. margin-top: 20rpx;
  717. margin-bottom: 20rpx;
  718. position: relative;
  719. .icon {
  720. width: 80rpx;
  721. height: 80rpx;
  722. }
  723. .title {
  724. font-size: 24rpx;
  725. margin-top: 10rpx;
  726. font-weight: 300;
  727. color: #222222;
  728. }
  729. .tag {
  730. position: absolute;
  731. top: -20rpx;
  732. left: 50%;
  733. background: #FF0615;
  734. box-shadow: inset 0rpx 6rpx 12rpx 2rpx rgba(255, 255, 255, 0.16);
  735. border-radius: 14rpx 14rpx 14rpx 0rpx;
  736. color: #fff;
  737. white-space: nowrap;
  738. font-size: 18rpx;
  739. line-height: 24rpx;
  740. height: 24rpx;
  741. padding: 0 10rpx;
  742. // width: fit-content;
  743. // background-size: 100% 34rpx;
  744. }
  745. .desc {
  746. color: #FF0817;
  747. font-size: 16rpx;
  748. text-align: center;
  749. margin-top: 4rpx;
  750. }
  751. }
  752. }
  753. .title-img {
  754. width: 686rpx;
  755. height: 166rpx;
  756. margin: 24rpx 32rpx;
  757. }
  758. .swiper-box{
  759. position: relative;
  760. width: 344rpx;
  761. height: 462rpx;
  762. border-radius: 16rpx;
  763. margin-bottom: 20rpx;
  764. .progress{
  765. position: absolute;
  766. top: 38rpx;
  767. right: 20rpx;
  768. z-index: 2;
  769. color: #FFFFFF;
  770. font-size: 16rpx;
  771. background: rgba(255, 255, 255, 0.3);
  772. padding: 2rpx 10rpx;
  773. border-radius: 14rpx;
  774. }
  775. .swiper {
  776. position: relative;
  777. height: 100%;
  778. .swiper-item {
  779. width: 344rpx;
  780. height: 462rpx;
  781. border-radius: 16rpx;
  782. object-fit: cover;
  783. }
  784. }
  785. }
  786. .advertise-box {
  787. display: flex;
  788. justify-content: space-between;
  789. margin: 0 24rpx;
  790. padding: 20rpx 0;
  791. }
  792. .content {
  793. border-radius: 16rpx 16rpx 0 0;
  794. }
  795. .zs-list {
  796. display: flex;
  797. flex-wrap: wrap;
  798. justify-content: space-between;
  799. padding: 0 24rpx;
  800. .left {
  801. .adv-swiper{
  802. width: 340rpx;
  803. height: 444rpx;
  804. margin-bottom: 25rpx;
  805. .adv-item{
  806. width: 340rpx;
  807. height: 444rpx;
  808. }
  809. }
  810. }
  811. .ad{
  812. width: 340rpx;
  813. border-radius: 16rpx;
  814. }
  815. .store-item {
  816. width: 344rpx;
  817. margin-bottom: 20rpx;
  818. // box-shadow: 0rpx 0rpx 24rpx 2rpx rgba(0, 0, 0, 0.08);
  819. border-radius: 16rpx;
  820. background: #fff;
  821. .icon {
  822. width: 100%;
  823. height: 300rpx;
  824. border-radius: 16rpx 16rpx 0 0;
  825. }
  826. .info{
  827. flex: 1;
  828. padding: 16rpx;
  829. position: relative;
  830. .title{
  831. margin-top: 10rpx;
  832. display: flex;
  833. align-items: center;
  834. .tag{
  835. display: inline-block;
  836. text-align: center;
  837. font-size: 20rpx;
  838. color: #FFFFFF;
  839. background: $uni-color-primary;
  840. padding: 2rpx 10rpx;
  841. border-radius: 8rpx;
  842. }
  843. .text{
  844. font-size: 28rpx;
  845. font-weight: bold;
  846. flex: 1;
  847. white-space: nowrap;
  848. overflow: hidden;
  849. text-overflow: ellipsis;
  850. }
  851. }
  852. .desc{
  853. font-size: 24rpx;
  854. color: #AAAAAA;
  855. overflow: hidden;
  856. text-overflow: ellipsis;
  857. /* 弹性伸缩盒子模型显示 */
  858. display: -webkit-box;
  859. /* 限制在一个块元素显示的文本的行数 */
  860. -webkit-line-clamp: 2;
  861. /* 设置或检索伸缩盒对象的子元素的排列方式 */
  862. -webkit-box-orient: vertical;
  863. margin-top: 12rpx;
  864. }
  865. .discount-tag{
  866. display: inline-block;
  867. padding: 0 10rpx;
  868. font-size: 20rpx;
  869. color: #EE4320;
  870. line-height: 28rpx;
  871. background: #FFF6F5;
  872. border-radius: 8rpx 8rpx 8rpx 8rpx;
  873. margin-top: 10rpx;
  874. }
  875. .price-box{
  876. display: flex;
  877. justify-content: space-between;
  878. align-items: center;
  879. margin-top: 12rpx;
  880. .left{
  881. display: flex;
  882. align-items: flex-end;
  883. vertical-align: bottom;
  884. .unit{
  885. font-size: 20rpx;
  886. color: $uni-color-primary;
  887. font-weight: bold;
  888. }
  889. .price{
  890. font-size: 32rpx;
  891. line-height: 32rpx;
  892. color: $uni-color-primary;
  893. font-weight: bold;
  894. }
  895. .label{
  896. font-size: 20rpx;
  897. color: #AAAAAA;
  898. margin-left: 6rpx;
  899. }
  900. .old-price{
  901. font-size: 20rpx;
  902. color: #AAAAAA;
  903. text-decoration: line-through;
  904. margin-left: 12rpx;
  905. }
  906. }
  907. .right{
  908. font-size: 24rpx;
  909. color: #AAAAAA;
  910. }
  911. }
  912. .address-box{
  913. display: flex;
  914. align-items: center;
  915. justify-content: space-between;
  916. font-size: 20rpx;
  917. color: #AAAAAA;
  918. margin-top: 15rpx;
  919. .address{
  920. width: 200rpx;
  921. overflow: hidden;
  922. text-overflow: ellipsis;
  923. /* 弹性伸缩盒子模型显示 */
  924. display: -webkit-box;
  925. /* 限制在一个块元素显示的文本的行数 */
  926. -webkit-line-clamp: 1;
  927. /* 设置或检索伸缩盒对象的子元素的排列方式 */
  928. -webkit-box-orient: vertical;
  929. }
  930. .distance{
  931. }
  932. }
  933. }
  934. }
  935. }
  936. }
  937. }
  938. </style>