shopDetail.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663
  1. <template>
  2. <view class="shopDetail">
  3. <view class="top-box">
  4. <image class="bg target" :src="info.detailImg" mode="aspectFill"></image>
  5. <view class="shop-info">
  6. <image class="shop-logo" :src="info.logoPath" mode=""></image>
  7. <view class="info-box">
  8. <view class="title-box">
  9. <view class="title">
  10. {{info.shopName ||''}}
  11. </view>
  12. <image class="tel" src="../../static/phone.png" mode="" v-if="info.serviceTel" @click="handleCall"></image>
  13. </view>
  14. <view class="address-box" @click="handleAdress">
  15. <view class="distance">
  16. <image class="address-icon" src="../../static/address-icon.png" mode=""></image>
  17. {{info.address || ''}}
  18. <!-- <image class="address-icon" src="../../static/address-icon.png" mode=""></image> 距你直线距离{{(info.shopVo.distance/1000).toFixed(2)}}km &nbsp;·&nbsp;{{info.district}} -->
  19. </view>
  20. </view>
  21. </view>
  22. </view>
  23. <view class="card-box" v-if="freeList.length">
  24. <view class="card" v-for="(item,index) in freeList" :key="index" @click="openPop">
  25. {{item.couponName}}
  26. </view>
  27. </view>
  28. <view class="desc-box" :class="[showDesc?'':'hidden']" v-if="info.detailContent">
  29. <view class="shop-desc">
  30. {{info.detailContent|| ''}}
  31. </view>
  32. <image class="icon" @click="handleDesc" src="../../static/shop-desc.png" mode=""></image>
  33. </view>
  34. </view>
  35. <zs-list class="goods-list" mt="0" @load="loadMore" :status="status">
  36. <!-- <view class="goods-list"> -->
  37. <view class="goods-item" v-for="item in buyList" :key="item.goodsId" @click="goDetail(item)">
  38. <zs-img :src="item.goodsImg" width="160rpx" height="160rpx" radius="full" mode="" ></zs-img>
  39. <view class="info">
  40. <view class="title">
  41. {{item.goodsName}}
  42. </view>
  43. <view class="desc">
  44. {{item.goodsDescribe}}
  45. </view>
  46. <view class="price-box">
  47. <view class="left">
  48. <view class="tag" v-if="item.goodsLabel">
  49. {{item.goodsLabel}}
  50. </view>
  51. <view class="unit">
  52. </view>
  53. <view class="price">
  54. {{item.realPrice}}
  55. </view>
  56. <view class="discount-tag" v-if="item.marketPrice">
  57. <view class="discount-num">
  58. {{((item.realPrice/item.marketPrice)*10).toFixed(1)}}折
  59. </view>
  60. </view>
  61. <view class="old-price">
  62. ¥{{item.marketPrice}}
  63. </view>
  64. </view>
  65. <view class="right">
  66. 销量{{item.saleNum}}
  67. </view>
  68. </view>
  69. </view>
  70. </view>
  71. <!-- </view> -->
  72. </zs-list>
  73. <u-empty marginTop="100" textSize="20" v-if="!buyList.length" mode="data"></u-empty>
  74. <u-popup :show="show" round="32rpx" mode="bottom" @close="show = false" @open="openPop">
  75. <view class="discounts-title">
  76. 免费领取
  77. </view>
  78. <view class="discounts">
  79. <u-empty marginTop="100" textSize="20" v-if="!freeList.length" mode="data"></u-empty>
  80. <zs-list mt="0" @load="loadCoupon" :status="status1">
  81. <view class="discounts-item" v-for="(item,index) in freeList" :key="index" >
  82. <view class="type-box">
  83. <view class="price">
  84. {{item | filterPrice}}
  85. </view>
  86. <view class="type">
  87. {{item | filterType}}
  88. </view>
  89. </view>
  90. <view class="info">
  91. <view class="card-title">
  92. {{item.couponName}}
  93. </view>
  94. <view class="limit">
  95. {{item.useStartTime}}后可用
  96. </view>
  97. <view class="desc">
  98. {{item.usrDetail || '-'}}
  99. </view>
  100. </view>
  101. <view class="btn" :class="[item.exist > 0?'used':'']" @click="handleBuy(item.id,item.exist)">
  102. {{item.exist > 0?'已领取':'领取'}}
  103. </view>
  104. </view>
  105. </zs-list>
  106. </view>
  107. </u-popup>
  108. <!-- 地图 -->
  109. <map v-show="false" class="map" id="map"></map>
  110. </view>
  111. </template>
  112. <script>
  113. import {getCouponList,claim} from '@/api/coupon.js'
  114. import { creat,getGoods } from '@/api/goods.js';
  115. import {shopDetail} from '@/api/shop.js'
  116. import guid from '@/utils/guid.js'
  117. import {rpxTopx,transformFromBaiduToGCJ} from '@/utils/tool.js'
  118. export default {
  119. data() {
  120. return {
  121. open:999,
  122. info: {},
  123. status: 'more',
  124. status1: 'more',
  125. _mapContext: null,
  126. query:{
  127. currentPage:1,
  128. pageSize:10,
  129. setMealId:0,
  130. showType:2,
  131. shopId:'',
  132. userId:''
  133. },
  134. freeList:[],
  135. buyList:[],
  136. showDesc:false,
  137. show:false,
  138. currentPage:1
  139. };
  140. },
  141. filters: {
  142. filterPrice: function(val) {
  143. if(val.couponType == 1){
  144. return `¥${val.couponDiscount}`
  145. }else if(val.couponType == 2){
  146. return `${val.couponDiscount}折`
  147. }else if(val.couponType == 3){
  148. return `¥${val.couponDiscount}`
  149. }
  150. },
  151. filterType: function(val) {
  152. if(val.couponType == 1){
  153. if(val.couponCondition){
  154. return `满${val.couponCondition}立减`
  155. }else{
  156. return '无门槛立减'
  157. }
  158. }else if(val.couponType == 2){
  159. if(val.couponCondition){
  160. return `满${val.couponCondition}`
  161. }else{
  162. return '无门槛立减'
  163. }
  164. }else if(val.couponType == 3){
  165. if(val.couponCondition){
  166. return `满${val.couponCondition}立减`
  167. }else{
  168. return '无门槛立减'
  169. }
  170. }
  171. },
  172. },
  173. methods: {
  174. handleCall() {
  175. if(this.info.serviceTel){
  176. uni.makePhoneCall({
  177. phoneNumber: this.info.serviceTel //仅为示例
  178. });
  179. }else{
  180. uni.showToast({
  181. title:'商家没有预留电话',
  182. icon:'none'
  183. })
  184. }
  185. },
  186. openPop(){
  187. this.show = true
  188. },
  189. handleDesc(){
  190. this.showDesc = !this.showDesc
  191. },
  192. // 地图中打开商家
  193. handleAdress() {
  194. let {latitude,longitude} = transformFromBaiduToGCJ(this.info.mapLat,this.info.mapLon)
  195. uni.openLocation({
  196. latitude,
  197. longitude,
  198. name:this.info.shopName,
  199. address:this.info.address,
  200. success: function () {
  201. console.log('success');
  202. }
  203. });
  204. },
  205. init(){
  206. let userInfo
  207. if(uni.getStorageSync('userInfo')){
  208. userInfo = JSON.parse(uni.getStorageSync('userInfo'))
  209. }else{
  210. userInfo = {setMealId:0,userId:''}
  211. }
  212. let shopInfo = uni.getStorageSync('shopInfo')?JSON.parse(uni.getStorageSync('shopInfo')):''
  213. this.info = {...this.info,...shopInfo}
  214. this.shopDetail(this.info.shopId)
  215. this.query.shopId = this.info.shopId
  216. this.query.setMealId = userInfo.setMealId
  217. this.query.userId = userInfo.userId
  218. this.getGoods()
  219. this.getCouponList()//商品1 优惠券 2
  220. },
  221. handleOpen(val,open){
  222. if(val === this[open]){
  223. this[open] = 7
  224. }else{
  225. this[open] = val
  226. }
  227. },
  228. // 点击领取
  229. handleBuy(couponId,type) {
  230. if(!uni.getStorageSync('token')){
  231. uni.showModal({
  232. title:'请登录',
  233. confirmText:'去登录',
  234. success(res){
  235. if(res.confirm){
  236. uni.navigateTo({
  237. url:'/login/login/login'
  238. })
  239. }
  240. }
  241. })
  242. }else{
  243. if(type == 0){
  244. claim({couponId}).then(res=>{
  245. if(res.state == 'Success'){
  246. uni.showToast({
  247. title:'领取成功',
  248. icon:'success'
  249. })
  250. this.getCouponList()
  251. }
  252. })
  253. }
  254. }
  255. },
  256. goDetail(item){
  257. let data = item
  258. uni.navigateTo({
  259. url: `../goodsDetail/index?id=${item.goodsId}`,
  260. })
  261. },
  262. loadMore(){
  263. this.getGoods()
  264. },
  265. loadCoupon(){
  266. this.getCouponList()
  267. },
  268. getCouponList(val){
  269. getCouponList(this.query).then(res=>{
  270. uni.stopPullDownRefresh()
  271. if(res.state == 'Success'){
  272. this.freeList = this.freeList.concat(res.content.records)
  273. this.freeList.length>= res.content.total?this.status1 = 'noMore':this.status1 = 'more'
  274. this.query.currentPage++
  275. }
  276. })
  277. },
  278. getGoods(){
  279. if(this.status == 'noMore') return
  280. this.status = 'loading'
  281. getGoods({currentPage:this.currentPage,status:3,shopId:this.info.shopId}).then(res=>{
  282. if(res.state == 'Success'){
  283. this.buyList = this.buyList.concat(res.content.records)
  284. console.log(res.content.total,this.buyList.length);
  285. if(res.content.total>this.buyList.length){
  286. this.status = 'more'
  287. this.currentPage++
  288. }else{
  289. this.status = 'noMore'
  290. }
  291. }
  292. })
  293. },
  294. shopDetail(shopId){
  295. shopDetail({shopId}).then(res=>{
  296. if(res.state == 'Success'){
  297. this.info.shopLabel = res.content.shopLabel
  298. this.info.detailImg = res.content.detailImg
  299. this.info.address = res.content.address
  300. this.info.serviceTel = res.content.serviceTel
  301. this.info.mapLat = res.content.mapLat
  302. this.info.mapLon = res.content.mapLon
  303. this.info.detailContent = res.content.detailContent
  304. this.info.shopName = res.content.shopName
  305. this.info.logoPath = res.content.logoPath
  306. uni.setNavigationBarTitle({
  307. title:res.content.shopName
  308. })
  309. }
  310. })
  311. }
  312. },
  313. onPullDownRefresh() {
  314. this.init()
  315. },
  316. onReady() {
  317. this._mapContext = uni.createMapContext("map", this);
  318. },
  319. onPageScroll(e) {
  320. // if(e.scrollTop >= rpxTopx(658)-84-rpxTopx(80)){
  321. // this.background = true
  322. // }else{
  323. // this.background = false
  324. // }
  325. },
  326. onShow() {
  327. this.init()
  328. },
  329. onLoad(options) {
  330. console.log(66666);
  331. this.info.shopId = options.id
  332. // this.init()
  333. },
  334. }
  335. </script>
  336. <style lang="scss">
  337. .shopDetail {
  338. min-height: 100vh;
  339. background: #F9F9F9;
  340. .top-box{
  341. .bg {
  342. width: 100%;
  343. height: 240rpx;
  344. object-fit: cover;
  345. vertical-align: bottom;
  346. }
  347. .shop-info {
  348. padding: 16rpx 24rpx;
  349. margin-top: -30rpx;
  350. box-sizing: border-box;
  351. background: #fff;
  352. border-radius: 32rpx;
  353. position: relative;
  354. z-index: 2;
  355. display: flex;
  356. .shop-logo{
  357. width: 120rpx;
  358. height: 120rpx;
  359. border-radius: 16rpx 16rpx 16rpx 16rpx;
  360. // margin-top: -28rpx;
  361. }
  362. .info-box{
  363. flex: 1;
  364. margin-left: 20rpx;
  365. color: #222222;
  366. .title-box{
  367. display: flex;
  368. justify-content: space-between;
  369. align-items: flex-start;
  370. .title {
  371. font-size: 32rpx;
  372. font-weight: bold;
  373. }
  374. .tel{
  375. width: 40rpx;
  376. height: 40rpx;
  377. margin-left: 20rpx;
  378. }
  379. }
  380. .address-box{
  381. width: 100%;
  382. display: flex;
  383. align-items: center;
  384. // padding: 30rpx 0;
  385. margin-top: 12rpx;
  386. box-sizing: border-box;
  387. font-weight: 300;
  388. font-size: 22rpx;
  389. color: #222222;
  390. .distance{
  391. display: flex;
  392. align-items: center;
  393. .address-icon{
  394. width: 32rpx;
  395. height: 32rpx;
  396. margin-right: 10rpx;
  397. }
  398. }
  399. }
  400. }
  401. }
  402. .card-box{
  403. display: flex;
  404. flex-wrap: nowrap;
  405. align-items: center;
  406. padding: 12rpx 24rpx;
  407. background: #fff;
  408. overflow: auto;
  409. .card{
  410. flex-shrink: 0;
  411. height: 40rpx;
  412. line-height: 40rpx;
  413. padding: 0 14rpx;
  414. border-radius: 8rpx 8rpx 8rpx 8rpx;
  415. border: 1rpx solid rgba(255,76,57,0.3);
  416. color: #FF4C39;
  417. font-size: 20rpx;
  418. margin-right: 12rpx;
  419. }
  420. }
  421. .desc-box.hidden{
  422. .shop-desc{
  423. overflow: hidden;
  424. white-space: nowrap;
  425. text-overflow: ellipsis;
  426. }
  427. .icon{
  428. transform: rotateZ(0deg);
  429. }
  430. }
  431. .desc-box{
  432. position: relative;
  433. padding-right: 30rpx;
  434. background: #fff;
  435. padding-bottom: 24rpx;
  436. .shop-desc{
  437. font-size: 20rpx;
  438. color: #AAAAAA;
  439. padding: 0 24rpx;
  440. width: 100%;
  441. box-sizing: border-box;
  442. }
  443. .icon{
  444. position: absolute;
  445. right: 0;
  446. top: 0;
  447. transform-origin: center;
  448. transform: rotateZ(180deg);
  449. transition: transform .3s;
  450. width: 32rpx;
  451. height: 32rpx;
  452. }
  453. }
  454. }
  455. .goods-list{
  456. .goods-item{
  457. display: flex;
  458. padding: 24rpx;
  459. background: #fff;
  460. border-radius: 16rpx;
  461. margin: 20rpx 24rpx 0;
  462. .info{
  463. flex: 1;
  464. padding-left: 20rpx;
  465. display: flex;
  466. flex-direction: column;
  467. justify-content: space-between;
  468. position: relative;
  469. .title{
  470. font-size: 28rpx;
  471. font-weight: bold;
  472. width: 340rpx;
  473. white-space: nowrap;
  474. overflow: hidden;
  475. text-overflow: ellipsis;
  476. margin-top: 10rpx;
  477. }
  478. .desc{
  479. font-size: 24rpx;
  480. color: #AAAAAA;
  481. overflow: hidden;
  482. text-overflow: ellipsis;
  483. /* 弹性伸缩盒子模型显示 */
  484. display: -webkit-box;
  485. /* 限制在一个块元素显示的文本的行数 */
  486. -webkit-line-clamp: 1;
  487. /* 设置或检索伸缩盒对象的子元素的排列方式 */
  488. -webkit-box-orient: vertical;
  489. }
  490. .price-box{
  491. display: flex;
  492. align-items: center;
  493. justify-content: space-between;
  494. height: 60rpx;
  495. .left{
  496. display: flex;
  497. align-items: flex-end;
  498. .tag{
  499. text-align: center;
  500. font-size: 20rpx;
  501. color: #FFFFFF;
  502. background: $uni-color-primary;
  503. padding: 2rpx 10rpx;
  504. border-radius: 8rpx 8rpx 8rpx 8rpx;
  505. }
  506. .unit{
  507. font-size: 20rpx;
  508. color: $uni-color-primary;
  509. font-weight: bold;
  510. margin-left: 10rpx;
  511. }
  512. .price{
  513. font-size: 28rpx;
  514. color: $uni-color-primary;
  515. font-weight: bold;
  516. line-height: 30rpx;
  517. }
  518. .discount-tag{
  519. display: flex;
  520. align-items: center;
  521. width: 82rpx;
  522. height: 28rpx;
  523. line-height: 28rpx;
  524. background: #FFF6F5;
  525. border-radius: 8rpx 8rpx 8rpx 8rpx;
  526. border: 1rpx solid $uni-color-primary;
  527. margin-left: 10rpx;
  528. .icon{
  529. width: 30.5rpx;
  530. height: 28rpx;
  531. }
  532. .discount-num{
  533. flex: 1;
  534. text-align: center;
  535. font-size: 20rpx;
  536. color: $uni-color-primary;
  537. }
  538. }
  539. .old-price{
  540. font-size: 20rpx;
  541. color: #AAAAAA;
  542. text-decoration: line-through;
  543. margin-left: 12rpx;
  544. }
  545. }
  546. .right{
  547. font-size: 24rpx;
  548. color: #AAAAAA;
  549. }
  550. }
  551. }
  552. }
  553. }
  554. .discounts-title {
  555. font-weight: bold;
  556. font-size: 32rpx;
  557. color: #222222;
  558. text-align: center;
  559. margin-bottom: 28rpx;
  560. padding-top: 28rpx;
  561. }
  562. .discounts {
  563. padding: 0 24rpx 28rpx;
  564. max-height: 1000rpx;
  565. min-height: 600rpx;
  566. overflow: auto;
  567. .discounts-item {
  568. margin-bottom: 20rpx;
  569. display: flex;
  570. align-items: center;
  571. background-color: rgb(239, 239, 239);
  572. background: url('../../static/new-card.png') no-repeat;
  573. background-repeat: no-repeat;
  574. background-size: 100% 144rpx;
  575. border-radius: 16rpx;
  576. height: 144rpx;
  577. padding: 0 24rpx;
  578. box-sizing: border-box;
  579. .type-box{
  580. text-align: center;
  581. .price{
  582. ont-size: 40rpx;
  583. color: #FF4D3A;
  584. }
  585. .type{
  586. font-size: 20rpx;
  587. color: #AAAAAA;
  588. margin-top: 12rpx;
  589. }
  590. }
  591. .info {
  592. flex: 1;
  593. margin-left: 40rpx;
  594. .card-title {
  595. font-size: 28rpx;
  596. color: #222222;
  597. }
  598. .desc{
  599. font-size: 20rpx;
  600. color: #AAAAAA;
  601. }
  602. .limit{
  603. font-size: 20rpx;
  604. color: #AAAAAA;
  605. margin:10rpx 0;
  606. }
  607. }
  608. .btn {
  609. width: 118rpx;
  610. height: 48rpx;
  611. line-height: 48rpx;
  612. text-align: center;
  613. font-size: 24rpx;
  614. background: #EE4320;
  615. border-radius: 24rpx;
  616. color: #FFF;
  617. box-sizing: border-box;
  618. }
  619. .btn.used{
  620. border: 2rpx solid #EE421F;
  621. color: #EE421F;
  622. background: none;
  623. }
  624. }
  625. }
  626. .map {
  627. position: relative;
  628. top: -100000px;
  629. left: -1000000px;
  630. }
  631. }
  632. </style>