index.vue 29 KB

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