index.vue 29 KB

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