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. <image class="icon" src="@/static/down.png" mode=""></image>
  58. <view class="discount-num">
  59. {{((item.realPrice/item.marketPrice)*10).toFixed(1)}}折
  60. </view>
  61. </view>
  62. <view class="old-price">
  63. ¥{{item.marketPrice}}
  64. </view>
  65. </view>
  66. <view class="right">
  67. 销量{{item.saleNum}}
  68. </view>
  69. </view>
  70. </view>
  71. </view>
  72. <!-- </view> -->
  73. </zs-list>
  74. <u-empty marginTop="100" textSize="20" v-if="!buyList.length" mode="data"></u-empty>
  75. <u-popup :show="show" round="32rpx" mode="bottom" @close="show = false" @open="openPop">
  76. <view class="discounts-title">
  77. 免费领取
  78. </view>
  79. <view class="discounts">
  80. <u-empty marginTop="100" textSize="20" v-if="!freeList.length" mode="data"></u-empty>
  81. <zs-list mt="0" @load="loadCoupon" :status="status1">
  82. <view class="discounts-item" v-for="(item,index) in freeList" :key="index" >
  83. <view class="type-box">
  84. <view class="price">
  85. {{item | filterPrice}}
  86. </view>
  87. <view class="type">
  88. {{item | filterType}}
  89. </view>
  90. </view>
  91. <view class="info">
  92. <view class="card-title">
  93. {{item.couponName}}
  94. </view>
  95. <view class="limit">
  96. {{item.useStartTime}}后可用
  97. </view>
  98. <view class="desc">
  99. {{item.usrDetail || '-'}}
  100. </view>
  101. </view>
  102. <view class="btn" :class="[item.exist > 0?'used':'']" @click="handleBuy(item.id,item.exist)">
  103. {{item.exist > 0?'已领取':'领取'}}
  104. </view>
  105. </view>
  106. </zs-list>
  107. </view>
  108. </u-popup>
  109. <!-- 地图 -->
  110. <map v-show="false" class="map" id="map"></map>
  111. </view>
  112. </template>
  113. <script>
  114. import {getCouponList,claim} from '@/api/coupon.js'
  115. import { creat,getGoods } from '@/api/goods.js';
  116. import {shopDetail} from '@/api/shop.js'
  117. import guid from '@/utils/guid.js'
  118. import {rpxTopx,transformFromBaiduToGCJ} from '@/utils/tool.js'
  119. export default {
  120. data() {
  121. return {
  122. open:999,
  123. info: null,
  124. status: 'more',
  125. status1: 'more',
  126. _mapContext: null,
  127. query:{
  128. currentPage:1,
  129. pageSize:10,
  130. setMealId:0,
  131. showType:2,
  132. shopId:'',
  133. userId:''
  134. },
  135. freeList:[],
  136. buyList:[],
  137. goodsTypeObj:{},
  138. showDesc:false,
  139. show:false,
  140. currentPage:1
  141. };
  142. },
  143. filters: {
  144. filterPrice: function(val) {
  145. if(val.couponType == 1){
  146. return `¥${val.couponDiscount}`
  147. }else if(val.couponType == 2){
  148. return `${val.couponDiscount}折`
  149. }else if(val.couponType == 3){
  150. return `¥${val.couponDiscount}`
  151. }
  152. },
  153. filterType: function(val) {
  154. if(val.couponType == 1){
  155. if(val.couponCondition){
  156. return `满${val.couponCondition}立减`
  157. }else{
  158. return '无门槛立减'
  159. }
  160. }else if(val.couponType == 2){
  161. if(val.couponCondition){
  162. return `满${val.couponCondition}`
  163. }else{
  164. return '无门槛立减'
  165. }
  166. }else if(val.couponType == 3){
  167. if(val.couponCondition){
  168. return `满${val.couponCondition}立减`
  169. }else{
  170. return '无门槛立减'
  171. }
  172. }
  173. },
  174. },
  175. methods: {
  176. handleCall() {
  177. if(this.info.serviceTel){
  178. uni.makePhoneCall({
  179. phoneNumber: this.info.serviceTel //仅为示例
  180. });
  181. }else{
  182. uni.showToast({
  183. title:'商家没有预留电话',
  184. icon:'none'
  185. })
  186. }
  187. },
  188. openPop(){
  189. this.show = true
  190. },
  191. handleDesc(){
  192. this.showDesc = !this.showDesc
  193. },
  194. // 地图中打开商家
  195. handleAdress() {
  196. let {latitude,longitude} = transformFromBaiduToGCJ(this.info.mapLat,this.info.mapLon)
  197. uni.openLocation({
  198. latitude,
  199. longitude,
  200. name:this.info.shopName,
  201. address:this.info.address,
  202. success: function () {
  203. console.log('success');
  204. }
  205. });
  206. },
  207. init(){
  208. let userInfo
  209. if(uni.getStorageSync('userInfo')){
  210. userInfo = JSON.parse(uni.getStorageSync('userInfo'))
  211. }else{
  212. userInfo = {setMealId:0,userId:''}
  213. }
  214. this.info = JSON.parse(uni.getStorageSync('shopInfo'))
  215. this.shopDetail(this.info.shopId)
  216. this.query.shopId = this.info.shopId
  217. this.query.setMealId = userInfo.setMealId
  218. this.query.userId = userInfo.userId
  219. this.getGoods()
  220. this.getCouponList()//商品1 优惠券 2
  221. },
  222. handleOpen(val,open){
  223. if(val === this[open]){
  224. this[open] = 7
  225. }else{
  226. this[open] = val
  227. }
  228. },
  229. // 点击领取
  230. handleBuy(couponId,type) {
  231. if(!uni.getStorageSync('token')){
  232. uni.showModal({
  233. title:'请登录',
  234. confirmText:'去登录',
  235. success(res){
  236. if(res.confirm){
  237. uni.navigateTo({
  238. url:'/login/login/login'
  239. })
  240. }
  241. }
  242. })
  243. }else{
  244. if(type == 0){
  245. claim({couponId}).then(res=>{
  246. if(res.state == 'Success'){
  247. uni.showToast({
  248. title:'领取成功',
  249. icon:'success'
  250. })
  251. this.getCouponList()
  252. }
  253. })
  254. }
  255. }
  256. },
  257. goDetail(item){
  258. let data = item
  259. uni.navigateTo({
  260. url: `../goodsDetail/index?id=${item.goodsId}`,
  261. })
  262. },
  263. loadMore(){
  264. this.getGoods()
  265. },
  266. loadCoupon(){
  267. this.getCouponList()
  268. },
  269. getCouponList(val){
  270. getCouponList(this.query).then(res=>{
  271. uni.stopPullDownRefresh()
  272. if(res.state == 'Success'){
  273. this.freeList = this.freeList.concat(res.content.records)
  274. this.freeList.length>= res.content.total?this.status1 = 'noMore':this.status1 = 'more'
  275. this.query.currentPage++
  276. }
  277. })
  278. },
  279. getGoods(){
  280. if(this.status == 'noMore') return
  281. this.status = 'loading'
  282. getGoods({currentPage:this.currentPage,status:3,shopId:this.info.shopId}).then(res=>{
  283. if(res.state == 'Success'){
  284. this.buyList = this.buyList.concat(res.content.records)
  285. console.log(res.content.total,this.buyList.length);
  286. if(res.content.total>this.buyList.length){
  287. this.status = 'more'
  288. this.currentPage++
  289. }else{
  290. this.status = 'noMore'
  291. }
  292. }
  293. })
  294. },
  295. shopDetail(shopId){
  296. shopDetail({shopId}).then(res=>{
  297. if(res.state == 'Success'){
  298. this.info.shopLabel = res.content.shopLabel
  299. this.info.detailImg = res.content.detailImg
  300. this.info.address = res.content.address
  301. this.info.serviceTel = res.content.serviceTel
  302. this.info.mapLat = res.content.mapLat
  303. this.info.mapLon = res.content.mapLon
  304. this.info.detailContent = res.content.detailContent
  305. uni.setNavigationBarTitle({
  306. title:res.content.shopName
  307. })
  308. }
  309. })
  310. }
  311. },
  312. onPullDownRefresh() {
  313. this.init()
  314. },
  315. onReady() {
  316. this._mapContext = uni.createMapContext("map", this);
  317. },
  318. onPageScroll(e) {
  319. // if(e.scrollTop >= rpxTopx(658)-84-rpxTopx(80)){
  320. // this.background = true
  321. // }else{
  322. // this.background = false
  323. // }
  324. },
  325. onShow() {
  326. this.init()
  327. },
  328. onLoad(options) {
  329. console.log(66666);
  330. this.goodsTypeObj = JSON.parse(uni.getStorageSync('goodsTypeObj'))
  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: 92rpx;
  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. .icon{
  528. width: 30.5rpx;
  529. height: 28rpx;
  530. }
  531. .discount-num{
  532. flex: 1;
  533. text-align: center;
  534. font-size: 20rpx;
  535. color: $uni-color-primary;
  536. }
  537. }
  538. .old-price{
  539. font-size: 20rpx;
  540. color: #AAAAAA;
  541. text-decoration: line-through;
  542. margin-left: 12rpx;
  543. }
  544. }
  545. .right{
  546. font-size: 24rpx;
  547. color: #AAAAAA;
  548. }
  549. }
  550. }
  551. }
  552. }
  553. .discounts-title {
  554. font-weight: bold;
  555. font-size: 32rpx;
  556. color: #222222;
  557. text-align: center;
  558. margin-bottom: 28rpx;
  559. padding-top: 28rpx;
  560. }
  561. .discounts {
  562. padding: 0 24rpx 28rpx;
  563. max-height: 1000rpx;
  564. min-height: 600rpx;
  565. overflow: auto;
  566. .discounts-item {
  567. margin-bottom: 20rpx;
  568. display: flex;
  569. align-items: center;
  570. background-color: rgb(239, 239, 239);
  571. background: url('../../static/new-card.png') no-repeat;
  572. background-repeat: no-repeat;
  573. background-size: 100% 144rpx;
  574. border-radius: 16rpx;
  575. height: 144rpx;
  576. padding: 0 24rpx;
  577. box-sizing: border-box;
  578. .type-box{
  579. text-align: center;
  580. .price{
  581. ont-size: 40rpx;
  582. color: #FF4D3A;
  583. }
  584. .type{
  585. font-size: 20rpx;
  586. color: #AAAAAA;
  587. margin-top: 12rpx;
  588. }
  589. }
  590. .info {
  591. flex: 1;
  592. margin-left: 40rpx;
  593. .card-title {
  594. font-size: 28rpx;
  595. color: #222222;
  596. }
  597. .desc{
  598. font-size: 20rpx;
  599. color: #AAAAAA;
  600. }
  601. .limit{
  602. font-size: 20rpx;
  603. color: #AAAAAA;
  604. margin:10rpx 0;
  605. }
  606. }
  607. .btn {
  608. width: 118rpx;
  609. height: 48rpx;
  610. line-height: 48rpx;
  611. text-align: center;
  612. font-size: 24rpx;
  613. background: #EE4320;
  614. border-radius: 24rpx;
  615. color: #FFF;
  616. box-sizing: border-box;
  617. }
  618. .btn.used{
  619. border: 2rpx solid #EE421F;
  620. color: #EE421F;
  621. background: none;
  622. }
  623. }
  624. }
  625. .map {
  626. position: relative;
  627. top: -100000px;
  628. left: -1000000px;
  629. }
  630. }
  631. </style>