index.vue 28 KB

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