shopDetail.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661
  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. this.goodsTypeObj = JSON.parse(uni.getStorageSync('goodsTypeObj'))
  330. },
  331. }
  332. </script>
  333. <style lang="scss">
  334. .shopDetail {
  335. min-height: 100vh;
  336. background: #F9F9F9;
  337. .top-box{
  338. .bg {
  339. width: 100%;
  340. height: 240rpx;
  341. object-fit: cover;
  342. vertical-align: bottom;
  343. }
  344. .shop-info {
  345. padding: 16rpx 24rpx;
  346. margin-top: -30rpx;
  347. box-sizing: border-box;
  348. background: #fff;
  349. border-radius: 32rpx;
  350. position: relative;
  351. z-index: 2;
  352. display: flex;
  353. .shop-logo{
  354. width: 120rpx;
  355. height: 120rpx;
  356. border-radius: 16rpx 16rpx 16rpx 16rpx;
  357. // margin-top: -28rpx;
  358. }
  359. .info-box{
  360. flex: 1;
  361. margin-left: 20rpx;
  362. color: #222222;
  363. .title-box{
  364. display: flex;
  365. justify-content: space-between;
  366. align-items: flex-start;
  367. .title {
  368. font-size: 32rpx;
  369. font-weight: bold;
  370. }
  371. .tel{
  372. width: 40rpx;
  373. height: 40rpx;
  374. margin-left: 20rpx;
  375. }
  376. }
  377. .address-box{
  378. width: 100%;
  379. display: flex;
  380. align-items: center;
  381. // padding: 30rpx 0;
  382. margin-top: 12rpx;
  383. box-sizing: border-box;
  384. font-weight: 300;
  385. font-size: 22rpx;
  386. color: #222222;
  387. .distance{
  388. display: flex;
  389. align-items: center;
  390. .address-icon{
  391. width: 32rpx;
  392. height: 32rpx;
  393. margin-right: 10rpx;
  394. }
  395. }
  396. }
  397. }
  398. }
  399. .card-box{
  400. display: flex;
  401. flex-wrap: nowrap;
  402. align-items: center;
  403. padding: 12rpx 24rpx;
  404. background: #fff;
  405. overflow: auto;
  406. .card{
  407. flex-shrink: 0;
  408. height: 40rpx;
  409. line-height: 40rpx;
  410. padding: 0 14rpx;
  411. border-radius: 8rpx 8rpx 8rpx 8rpx;
  412. border: 1rpx solid rgba(255,76,57,0.3);
  413. color: #FF4C39;
  414. font-size: 20rpx;
  415. margin-right: 12rpx;
  416. }
  417. }
  418. .desc-box.hidden{
  419. .shop-desc{
  420. overflow: hidden;
  421. white-space: nowrap;
  422. text-overflow: ellipsis;
  423. }
  424. .icon{
  425. transform: rotateZ(0deg);
  426. }
  427. }
  428. .desc-box{
  429. position: relative;
  430. padding-right: 30rpx;
  431. background: #fff;
  432. padding-bottom: 24rpx;
  433. .shop-desc{
  434. font-size: 20rpx;
  435. color: #AAAAAA;
  436. padding: 0 24rpx;
  437. width: 100%;
  438. box-sizing: border-box;
  439. }
  440. .icon{
  441. position: absolute;
  442. right: 0;
  443. top: 0;
  444. transform-origin: center;
  445. transform: rotateZ(180deg);
  446. transition: transform .3s;
  447. width: 32rpx;
  448. height: 32rpx;
  449. }
  450. }
  451. }
  452. .goods-list{
  453. .goods-item{
  454. display: flex;
  455. padding: 24rpx;
  456. background: #fff;
  457. border-radius: 16rpx;
  458. margin: 20rpx 24rpx 0;
  459. .info{
  460. flex: 1;
  461. padding-left: 20rpx;
  462. display: flex;
  463. flex-direction: column;
  464. justify-content: space-between;
  465. position: relative;
  466. .title{
  467. font-size: 28rpx;
  468. font-weight: bold;
  469. width: 340rpx;
  470. white-space: nowrap;
  471. overflow: hidden;
  472. text-overflow: ellipsis;
  473. margin-top: 10rpx;
  474. }
  475. .desc{
  476. font-size: 24rpx;
  477. color: #AAAAAA;
  478. overflow: hidden;
  479. text-overflow: ellipsis;
  480. /* 弹性伸缩盒子模型显示 */
  481. display: -webkit-box;
  482. /* 限制在一个块元素显示的文本的行数 */
  483. -webkit-line-clamp: 1;
  484. /* 设置或检索伸缩盒对象的子元素的排列方式 */
  485. -webkit-box-orient: vertical;
  486. }
  487. .price-box{
  488. display: flex;
  489. align-items: center;
  490. justify-content: space-between;
  491. height: 60rpx;
  492. .left{
  493. display: flex;
  494. align-items: flex-end;
  495. .tag{
  496. text-align: center;
  497. font-size: 20rpx;
  498. color: #FFFFFF;
  499. background: $uni-color-primary;
  500. padding: 2rpx 10rpx;
  501. border-radius: 8rpx 8rpx 8rpx 8rpx;
  502. }
  503. .unit{
  504. font-size: 20rpx;
  505. color: $uni-color-primary;
  506. font-weight: bold;
  507. margin-left: 10rpx;
  508. }
  509. .price{
  510. font-size: 28rpx;
  511. color: $uni-color-primary;
  512. font-weight: bold;
  513. line-height: 30rpx;
  514. }
  515. .discount-tag{
  516. display: flex;
  517. align-items: center;
  518. width: 92rpx;
  519. height: 28rpx;
  520. line-height: 28rpx;
  521. background: #FFF6F5;
  522. border-radius: 8rpx 8rpx 8rpx 8rpx;
  523. border: 1rpx solid $uni-color-primary;
  524. .icon{
  525. width: 30.5rpx;
  526. height: 28rpx;
  527. }
  528. .discount-num{
  529. flex: 1;
  530. text-align: center;
  531. font-size: 20rpx;
  532. color: $uni-color-primary;
  533. }
  534. }
  535. .old-price{
  536. font-size: 20rpx;
  537. color: #AAAAAA;
  538. text-decoration: line-through;
  539. margin-left: 12rpx;
  540. }
  541. }
  542. .right{
  543. font-size: 24rpx;
  544. color: #AAAAAA;
  545. }
  546. }
  547. }
  548. }
  549. }
  550. .discounts-title {
  551. font-weight: bold;
  552. font-size: 32rpx;
  553. color: #222222;
  554. text-align: center;
  555. margin-bottom: 28rpx;
  556. padding-top: 28rpx;
  557. }
  558. .discounts {
  559. padding: 0 24rpx 28rpx;
  560. max-height: 1000rpx;
  561. min-height: 600rpx;
  562. overflow: auto;
  563. .discounts-item {
  564. margin-bottom: 20rpx;
  565. display: flex;
  566. align-items: center;
  567. background-color: rgb(239, 239, 239);
  568. background: url('../../static/new-card.png') no-repeat;
  569. background-repeat: no-repeat;
  570. background-size: 100% 144rpx;
  571. border-radius: 16rpx;
  572. height: 144rpx;
  573. padding: 0 24rpx;
  574. box-sizing: border-box;
  575. .type-box{
  576. text-align: center;
  577. .price{
  578. ont-size: 40rpx;
  579. color: #FF4D3A;
  580. }
  581. .type{
  582. font-size: 20rpx;
  583. color: #AAAAAA;
  584. margin-top: 12rpx;
  585. }
  586. }
  587. .info {
  588. flex: 1;
  589. margin-left: 40rpx;
  590. .card-title {
  591. font-size: 28rpx;
  592. color: #222222;
  593. }
  594. .desc{
  595. font-size: 20rpx;
  596. color: #AAAAAA;
  597. }
  598. .limit{
  599. font-size: 20rpx;
  600. color: #AAAAAA;
  601. margin:10rpx 0;
  602. }
  603. }
  604. .btn {
  605. width: 118rpx;
  606. height: 48rpx;
  607. line-height: 48rpx;
  608. text-align: center;
  609. font-size: 24rpx;
  610. background: #EE4320;
  611. border-radius: 24rpx;
  612. color: #FFF;
  613. box-sizing: border-box;
  614. }
  615. .btn.used{
  616. border: 2rpx solid #EE421F;
  617. color: #EE421F;
  618. background: none;
  619. }
  620. }
  621. }
  622. .map {
  623. position: relative;
  624. top: -100000px;
  625. left: -1000000px;
  626. }
  627. }
  628. </style>