shopDetail.vue 13 KB

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