index.vue 28 KB

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