index.vue 29 KB

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