index.vue 27 KB

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