index.vue 28 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004
  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. this.loading = true
  610. const token = uni.getStorageSync('token')
  611. console.log(!!token)
  612. if(query.scene){
  613. // const token = uni.getStorageSync('token')
  614. if(token){
  615. uni.showToast({
  616. title: '已经是平台用户',
  617. icon: 'none'
  618. });
  619. // return
  620. }else{
  621. uni.setStorageSync('inviteCode',decodeURIComponent(query.scene))
  622. }
  623. // uni.setStorageSync('inviteCode',decodeURIComponent(query.scene))
  624. }
  625. this.query.regionCode = query.regionCode || ''
  626. this.getDialogAdv()
  627. this.status = 'more'
  628. this.list = []
  629. this.list1 = []
  630. this.query.page = 0
  631. Promise.all([this.getMenu(),this.getCity()]).then(res=>{
  632. this.search()
  633. // if(query.regionCode){
  634. // this.search()
  635. // }else{
  636. // this.getCityList().then(()=>{
  637. // this.search()
  638. // })
  639. // }
  640. this.cityList()
  641. })
  642. },
  643. onShareTimeline() {
  644. return {
  645. title: "慧研学惠生活",
  646. query: "id=1",
  647. imageUrl: "https://hyxhsh.oss-cn-chengdu.aliyuncs.com/63b7c68b71a69169d1b33f92/store/bdb/user/avatar/XHBjBiMRhVYG8f1a30bbbd80c2346197b81470444c9a.png/1.png",
  648. };
  649. },
  650. onShareAppMessage() {
  651. return {
  652. title: "慧研学惠生活",
  653. path: "/pages/index/index",
  654. };
  655. },
  656. onPullDownRefresh() {
  657. this.status = 'more'
  658. this.list = []
  659. this.list1 = []
  660. this.query.page = 0
  661. Promise.all([this.getMenu(),this.getCity()]).then(res=>{
  662. this.getCityList().then(()=>{
  663. this.search()
  664. })
  665. // this.cityList()
  666. uni.stopPullDownRefresh()
  667. })
  668. },
  669. created() {
  670. // this.loading = true
  671. // this.getDialogAdv()
  672. // Promise.all([this.getMenu(),this.getCity()]).then(res=>{
  673. // this.getCityList().then(()=>{
  674. // this.search()
  675. // })
  676. // this.cityList()
  677. // })
  678. }
  679. }
  680. </script>
  681. <style lang="scss">
  682. .home {
  683. // padding-bottom:120rpx;
  684. // background: linear-gradient(180deg, #FFFFFF 0%, #DCE8FF 100%);
  685. background: #F9F9F9;
  686. .card-title {
  687. display: flex;
  688. justify-content: center;
  689. .title {
  690. font-size: 32rpx;
  691. text-align: center;
  692. color: #fff;
  693. width: 210rpx;
  694. line-height: 64rpx;
  695. background: linear-gradient(360deg, #3074F8 0%, #568FFF 100%);
  696. border-radius: 0rpx 0rpx 24rpx 24rpx;
  697. }
  698. }
  699. .login-home {
  700. // background: linear-gradient(178deg, #FFFFFF 0%, #F9F9F9 100%);
  701. // background: #FFF;
  702. .discount-list {
  703. display: flex;
  704. flex-wrap: wrap;
  705. // padding: 30rpx 0;
  706. margin: 0 24rpx 20rpx;
  707. // background: #fff;
  708. border-radius: 16rpx;
  709. position: relative;
  710. top: 20rpx;
  711. padding-top: 20rpx;
  712. .discount-item {
  713. width: 20%;
  714. display: flex;
  715. flex-direction: column;
  716. align-items: center;
  717. margin-top: 20rpx;
  718. margin-bottom: 20rpx;
  719. position: relative;
  720. .icon {
  721. width: 80rpx;
  722. height: 80rpx;
  723. }
  724. .title {
  725. font-size: 24rpx;
  726. margin-top: 10rpx;
  727. font-weight: 300;
  728. color: #222222;
  729. }
  730. .tag {
  731. position: absolute;
  732. top: -20rpx;
  733. left: 50%;
  734. background: #FF0615;
  735. box-shadow: inset 0rpx 6rpx 12rpx 2rpx rgba(255, 255, 255, 0.16);
  736. border-radius: 14rpx 14rpx 14rpx 0rpx;
  737. color: #fff;
  738. white-space: nowrap;
  739. font-size: 18rpx;
  740. line-height: 24rpx;
  741. height: 24rpx;
  742. padding: 0 10rpx;
  743. // width: fit-content;
  744. // background-size: 100% 34rpx;
  745. }
  746. .desc {
  747. color: #FF0817;
  748. font-size: 16rpx;
  749. text-align: center;
  750. margin-top: 4rpx;
  751. }
  752. }
  753. }
  754. .title-img {
  755. width: 686rpx;
  756. height: 166rpx;
  757. margin: 24rpx 32rpx;
  758. }
  759. .swiper-box{
  760. position: relative;
  761. width: 344rpx;
  762. height: 462rpx;
  763. border-radius: 16rpx;
  764. margin-bottom: 20rpx;
  765. .progress{
  766. position: absolute;
  767. top: 38rpx;
  768. right: 20rpx;
  769. z-index: 2;
  770. color: #FFFFFF;
  771. font-size: 16rpx;
  772. background: rgba(255, 255, 255, 0.3);
  773. padding: 2rpx 10rpx;
  774. border-radius: 14rpx;
  775. }
  776. .swiper {
  777. position: relative;
  778. height: 100%;
  779. .swiper-item {
  780. width: 344rpx;
  781. height: 462rpx;
  782. border-radius: 16rpx;
  783. object-fit: cover;
  784. }
  785. }
  786. }
  787. .advertise-box {
  788. display: flex;
  789. justify-content: space-between;
  790. margin: 0 24rpx;
  791. padding: 20rpx 0;
  792. }
  793. .content {
  794. border-radius: 16rpx 16rpx 0 0;
  795. }
  796. .zs-list {
  797. display: flex;
  798. flex-wrap: wrap;
  799. justify-content: space-between;
  800. padding: 0 24rpx;
  801. .left {
  802. .adv-swiper{
  803. width: 340rpx;
  804. height: 444rpx;
  805. margin-bottom: 25rpx;
  806. .adv-item{
  807. width: 340rpx;
  808. height: 444rpx;
  809. }
  810. }
  811. }
  812. .ad{
  813. width: 340rpx;
  814. border-radius: 16rpx;
  815. }
  816. .store-item {
  817. width: 344rpx;
  818. margin-bottom: 20rpx;
  819. // box-shadow: 0rpx 0rpx 24rpx 2rpx rgba(0, 0, 0, 0.08);
  820. border-radius: 16rpx;
  821. background: #fff;
  822. .icon {
  823. width: 100%;
  824. height: 300rpx;
  825. border-radius: 16rpx 16rpx 0 0;
  826. }
  827. .info{
  828. flex: 1;
  829. padding: 16rpx;
  830. position: relative;
  831. .title{
  832. margin-top: 10rpx;
  833. display: flex;
  834. align-items: center;
  835. .tag{
  836. display: inline-block;
  837. text-align: center;
  838. font-size: 20rpx;
  839. color: #FFFFFF;
  840. background: $uni-color-primary;
  841. padding: 2rpx 10rpx;
  842. border-radius: 8rpx;
  843. }
  844. .text{
  845. font-size: 28rpx;
  846. font-weight: bold;
  847. flex: 1;
  848. white-space: nowrap;
  849. overflow: hidden;
  850. text-overflow: ellipsis;
  851. }
  852. }
  853. .desc{
  854. font-size: 24rpx;
  855. color: #AAAAAA;
  856. overflow: hidden;
  857. text-overflow: ellipsis;
  858. /* 弹性伸缩盒子模型显示 */
  859. display: -webkit-box;
  860. /* 限制在一个块元素显示的文本的行数 */
  861. -webkit-line-clamp: 2;
  862. /* 设置或检索伸缩盒对象的子元素的排列方式 */
  863. -webkit-box-orient: vertical;
  864. margin-top: 12rpx;
  865. }
  866. .discount-tag{
  867. display: inline-block;
  868. padding: 0 10rpx;
  869. font-size: 20rpx;
  870. color: #EE4320;
  871. line-height: 28rpx;
  872. background: #FFF6F5;
  873. border-radius: 8rpx 8rpx 8rpx 8rpx;
  874. margin-top: 10rpx;
  875. }
  876. .price-box{
  877. display: flex;
  878. justify-content: space-between;
  879. align-items: center;
  880. margin-top: 12rpx;
  881. .left{
  882. display: flex;
  883. align-items: flex-end;
  884. vertical-align: bottom;
  885. .unit{
  886. font-size: 20rpx;
  887. color: $uni-color-primary;
  888. font-weight: bold;
  889. }
  890. .price{
  891. font-size: 32rpx;
  892. line-height: 32rpx;
  893. color: $uni-color-primary;
  894. font-weight: bold;
  895. }
  896. .label{
  897. font-size: 20rpx;
  898. color: #AAAAAA;
  899. margin-left: 6rpx;
  900. }
  901. .old-price{
  902. font-size: 20rpx;
  903. color: #AAAAAA;
  904. text-decoration: line-through;
  905. margin-left: 12rpx;
  906. }
  907. }
  908. .right{
  909. font-size: 24rpx;
  910. color: #AAAAAA;
  911. }
  912. }
  913. .address-box{
  914. display: flex;
  915. align-items: center;
  916. justify-content: space-between;
  917. font-size: 20rpx;
  918. color: #AAAAAA;
  919. margin-top: 15rpx;
  920. .address{
  921. width: 200rpx;
  922. overflow: hidden;
  923. text-overflow: ellipsis;
  924. /* 弹性伸缩盒子模型显示 */
  925. display: -webkit-box;
  926. /* 限制在一个块元素显示的文本的行数 */
  927. -webkit-line-clamp: 1;
  928. /* 设置或检索伸缩盒对象的子元素的排列方式 */
  929. -webkit-box-orient: vertical;
  930. }
  931. .distance{
  932. }
  933. }
  934. }
  935. }
  936. }
  937. }
  938. }
  939. </style>