shopDetail.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662
  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. 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.info.shopId = options.id
  331. // this.init()
  332. },
  333. }
  334. </script>
  335. <style lang="scss">
  336. .shopDetail {
  337. min-height: 100vh;
  338. background: #F9F9F9;
  339. .top-box{
  340. .bg {
  341. width: 100%;
  342. height: 240rpx;
  343. object-fit: cover;
  344. vertical-align: bottom;
  345. }
  346. .shop-info {
  347. padding: 16rpx 24rpx;
  348. margin-top: -30rpx;
  349. box-sizing: border-box;
  350. background: #fff;
  351. border-radius: 32rpx;
  352. position: relative;
  353. z-index: 2;
  354. display: flex;
  355. .shop-logo{
  356. width: 120rpx;
  357. height: 120rpx;
  358. border-radius: 16rpx 16rpx 16rpx 16rpx;
  359. // margin-top: -28rpx;
  360. }
  361. .info-box{
  362. flex: 1;
  363. margin-left: 20rpx;
  364. color: #222222;
  365. .title-box{
  366. display: flex;
  367. justify-content: space-between;
  368. align-items: flex-start;
  369. .title {
  370. font-size: 32rpx;
  371. font-weight: bold;
  372. }
  373. .tel{
  374. width: 40rpx;
  375. height: 40rpx;
  376. margin-left: 20rpx;
  377. }
  378. }
  379. .address-box{
  380. width: 100%;
  381. display: flex;
  382. align-items: center;
  383. // padding: 30rpx 0;
  384. margin-top: 12rpx;
  385. box-sizing: border-box;
  386. font-weight: 300;
  387. font-size: 22rpx;
  388. color: #222222;
  389. .distance{
  390. display: flex;
  391. align-items: center;
  392. .address-icon{
  393. width: 32rpx;
  394. height: 32rpx;
  395. margin-right: 10rpx;
  396. }
  397. }
  398. }
  399. }
  400. }
  401. .card-box{
  402. display: flex;
  403. flex-wrap: nowrap;
  404. align-items: center;
  405. padding: 12rpx 24rpx;
  406. background: #fff;
  407. overflow: auto;
  408. .card{
  409. flex-shrink: 0;
  410. height: 40rpx;
  411. line-height: 40rpx;
  412. padding: 0 14rpx;
  413. border-radius: 8rpx 8rpx 8rpx 8rpx;
  414. border: 1rpx solid rgba(255,76,57,0.3);
  415. color: #FF4C39;
  416. font-size: 20rpx;
  417. margin-right: 12rpx;
  418. }
  419. }
  420. .desc-box.hidden{
  421. .shop-desc{
  422. overflow: hidden;
  423. white-space: nowrap;
  424. text-overflow: ellipsis;
  425. }
  426. .icon{
  427. transform: rotateZ(0deg);
  428. }
  429. }
  430. .desc-box{
  431. position: relative;
  432. padding-right: 30rpx;
  433. background: #fff;
  434. padding-bottom: 24rpx;
  435. .shop-desc{
  436. font-size: 20rpx;
  437. color: #AAAAAA;
  438. padding: 0 24rpx;
  439. width: 100%;
  440. box-sizing: border-box;
  441. }
  442. .icon{
  443. position: absolute;
  444. right: 0;
  445. top: 0;
  446. transform-origin: center;
  447. transform: rotateZ(180deg);
  448. transition: transform .3s;
  449. width: 32rpx;
  450. height: 32rpx;
  451. }
  452. }
  453. }
  454. .goods-list{
  455. .goods-item{
  456. display: flex;
  457. padding: 24rpx;
  458. background: #fff;
  459. border-radius: 16rpx;
  460. margin: 20rpx 24rpx 0;
  461. .info{
  462. flex: 1;
  463. padding-left: 20rpx;
  464. display: flex;
  465. flex-direction: column;
  466. justify-content: space-between;
  467. position: relative;
  468. .title{
  469. font-size: 28rpx;
  470. font-weight: bold;
  471. width: 340rpx;
  472. white-space: nowrap;
  473. overflow: hidden;
  474. text-overflow: ellipsis;
  475. margin-top: 10rpx;
  476. }
  477. .desc{
  478. font-size: 24rpx;
  479. color: #AAAAAA;
  480. overflow: hidden;
  481. text-overflow: ellipsis;
  482. /* 弹性伸缩盒子模型显示 */
  483. display: -webkit-box;
  484. /* 限制在一个块元素显示的文本的行数 */
  485. -webkit-line-clamp: 1;
  486. /* 设置或检索伸缩盒对象的子元素的排列方式 */
  487. -webkit-box-orient: vertical;
  488. }
  489. .price-box{
  490. display: flex;
  491. align-items: center;
  492. justify-content: space-between;
  493. height: 60rpx;
  494. .left{
  495. display: flex;
  496. align-items: flex-end;
  497. .tag{
  498. text-align: center;
  499. font-size: 20rpx;
  500. color: #FFFFFF;
  501. background: $uni-color-primary;
  502. padding: 2rpx 10rpx;
  503. border-radius: 8rpx 8rpx 8rpx 8rpx;
  504. }
  505. .unit{
  506. font-size: 20rpx;
  507. color: $uni-color-primary;
  508. font-weight: bold;
  509. margin-left: 10rpx;
  510. }
  511. .price{
  512. font-size: 28rpx;
  513. color: $uni-color-primary;
  514. font-weight: bold;
  515. line-height: 30rpx;
  516. }
  517. .discount-tag{
  518. display: flex;
  519. align-items: center;
  520. width: 82rpx;
  521. height: 28rpx;
  522. line-height: 28rpx;
  523. background: #FFF6F5;
  524. border-radius: 8rpx 8rpx 8rpx 8rpx;
  525. border: 1rpx solid $uni-color-primary;
  526. margin-left: 10rpx;
  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>