index.vue 27 KB

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