index.vue 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472
  1. <template>
  2. <view class="goodsDetail">
  3. <zs-skeleton type="goodsDetail" :loading="pageLoading"></zs-skeleton>
  4. <image class="good-img" :src="info.goodsPath" mode="aspectFit"></image>
  5. <view class="price-box">
  6. <view class="left">
  7. <view class="num-box">
  8. <view class="unit">
  9. </view>
  10. <view class="price">
  11. {{info.realPrice}}
  12. </view>
  13. </view>
  14. <view class="old-price">
  15. 市场价 ¥{{info.marketPrice}}
  16. </view>
  17. </view>
  18. <view class="right">
  19. 销量{{info.saleNum}}
  20. </view>
  21. </view>
  22. <view class="goods-info">
  23. <view class="goods-name">
  24. {{info.goodsName}}
  25. </view>
  26. <view class="desc">
  27. {{info.goodsDescribe}}
  28. </view>
  29. </view>
  30. <!-- 商品规格 -->
  31. <!-- <template v-if="info.specs[0].specValues.length">
  32. <view class="type-box" v-for="item in info.specs" :key="item.specId">
  33. <view class="type-title">
  34. {{item.specName}}
  35. </view>
  36. <view class="type-list">
  37. <view class="type-item" :class="[active == d?'active':'' ]" v-for="(i,d) in item.specValues" :key="i.specId">
  38. {{i.specValue}}
  39. </view>
  40. </view>
  41. </view>
  42. </template> -->
  43. <view class="shop-limit" @click="jump('/detail/shopList/index')">
  44. <view class="info">
  45. <view class="shop-name">
  46. <!-- 朱光玉火锅(天河店) -->
  47. {{shopInfo.shopVo.shopName}}
  48. </view>
  49. <view class="address">
  50. <!-- 花溪区天河潭旅游度假区天河潭 22.65km -->
  51. {{shopInfo.district}} {{(shopInfo.shopVo.distance/1000).toFixed(2)}} KM
  52. </view>
  53. </view>
  54. <view class="num">
  55. {{shopList.length}}家店适用
  56. <image class="icon" src="../../static/shop-desc.png" mode=""></image>
  57. </view>
  58. </view>
  59. <view class="tab-group">
  60. <view class="tab" :class="[tab == 1 ? 'active':'']" @click="handleTab(1)">
  61. 商品详情
  62. </view>
  63. <view class="tab" :class="[tab == 2 ? 'active':'']" @click="handleTab(2)">
  64. 购买须知
  65. </view>
  66. </view>
  67. <view class="desc-box" v-show="tab == 1">
  68. <rich-text class="goods-desc" :nodes="info.goodsDetail"></rich-text>
  69. </view>
  70. <view class="list" v-show="tab == 2">
  71. <view class="item" v-for="(item,index) in info.attrs" :key="index">
  72. <view class="label">
  73. {{item.attrName == 'validDay'?'有效期':item.attrName}}
  74. </view>
  75. <view class="value" v-html="filterMsg(item.attrValue,item.attrName)">
  76. </view>
  77. </view>
  78. <!-- <view class="item">
  79. <view class="label">
  80. 使用时间
  81. </view>
  82. <view class="value">
  83. 营业时间内可用
  84. </view>
  85. </view> -->
  86. </view>
  87. <view class="buy-box">
  88. <image class="head" :src="shopInfo.logoPath" @click="goShopDetail(shopInfo)" mode=""></image>
  89. <view class="btn-box">
  90. <!-- <view class="group-btn" @click="handleBuy">
  91. <view class="label">
  92. 团购
  93. </view>
  94. <view class="price">
  95. ¥{{info.realPrice}}
  96. </view>
  97. </view> -->
  98. <view class="buy-btn" :class="[info.realStockNum?'':'none']" @click="handleBuy">
  99. <view class="label">
  100. {{info.realStockNum?'会员专享价':'售罄'}}
  101. </view>
  102. <view class="price">
  103. ¥{{info.realPrice}}
  104. </view>
  105. </view>
  106. </view>
  107. </view>
  108. </view>
  109. </template>
  110. <script>
  111. import {detail} from '@/api/goods.js'
  112. import {search} from '@/api/shop.js'
  113. export default {
  114. data() {
  115. return {
  116. pageLoading:false,
  117. active:0,
  118. tab:1,
  119. shopList:[],
  120. info: {},
  121. shopInfo:{}
  122. }
  123. },
  124. methods: {
  125. filterMsg(val,name){
  126. let msg = val.replace(/\n/g, "<br>")
  127. if(name == 'validDay'){
  128. msg = val + '天'
  129. }
  130. return msg
  131. },
  132. jump(url){
  133. uni.navigateTo({
  134. url
  135. })
  136. },
  137. handleTab(val){
  138. this.tab = val
  139. },
  140. handleBuy() {
  141. if(!this.info.realStockNum) return
  142. let that = this
  143. if (uni.getStorageSync('token')) {
  144. uni.navigateTo({
  145. url:`/pay/pay`,
  146. success: function(res) {
  147. // 通过eventChannel向被打开页面传送数据
  148. res.eventChannel.emit('pay', that.info)
  149. }
  150. })
  151. } else {
  152. uni.showModal({
  153. title:'请登录',
  154. confirmText:'去登录',
  155. success(res){
  156. console.log(res);
  157. if(res.confirm){
  158. uni.navigateTo({
  159. url:`/login/login/login?redirect=/detail/goodsDetail/index&id=${that.info.goodsId}`
  160. })
  161. }
  162. }
  163. })
  164. }
  165. },
  166. detail(goodsId){
  167. this.pageLoading = true
  168. detail({goodsId,resource:2}).then(res=>{
  169. this.pageLoading = false
  170. if(res.state == 'Success'){
  171. this.info = res.content
  172. this.info.goodsDetail = res.content.goodsDetail.replace(/<img/gi, '<img class="img_class" ')
  173. }
  174. })
  175. },
  176. goShopDetail(shopInfo) {
  177. uni.setStorageSync('shopInfo', JSON.stringify(shopInfo))
  178. uni.navigateTo({
  179. url: `../../detail/shopDetail/shopDetail`
  180. })
  181. },
  182. getShopList(goodsId){
  183. let location = JSON.parse(uni.getStorageSync('location'))
  184. let obj = {
  185. goodsId,
  186. pageCurrent:1,
  187. pageSize:99
  188. }
  189. obj['location.lat'] = location.latitude
  190. obj['location.lon'] = location.longitude
  191. search(obj).then(res=>{
  192. if(res.state == 'Success'){
  193. this.shopList = res.content.records
  194. uni.setStorageSync('shopList',JSON.stringify(this.shopList))
  195. }
  196. })
  197. }
  198. },
  199. onLoad(option) {
  200. this.shopInfo = JSON.parse(uni.getStorageSync('shopInfo'))
  201. this.detail(option.id)
  202. this.getShopList(option.id)
  203. let that = this
  204. // this.info = JSON.parse(uni.getStorageSync('goodsInfo'))
  205. // const eventChannel = this.getOpenerEventChannel();
  206. // if(JSON.stringify(eventChannel) !=='{}'){
  207. // eventChannel.on('goodsInfo', function(data) {
  208. // that.info = data
  209. // })
  210. // }
  211. }
  212. }
  213. </script>
  214. <style lang="scss" >
  215. .goodsDetail{
  216. background: #F9F9F9;
  217. padding-bottom: 200rpx;
  218. min-height: 100vh;
  219. .good-img{
  220. width: 100%;
  221. height: 750rpx;
  222. vertical-align: bottom;
  223. }
  224. .price-box{
  225. display: flex;
  226. justify-content: space-between;
  227. align-items: center;
  228. width: 100%;
  229. height: 116rpx;
  230. box-sizing: border-box;
  231. background-image: url('../../static/price-bg.png');
  232. background-repeat: no-repeat;
  233. background-size: 100% 116rpx;
  234. padding: 24rpx;
  235. color: #fff;
  236. .left{
  237. display: flex;
  238. align-items: center;
  239. .num-box{
  240. display: flex;
  241. align-items: center;
  242. .unit{
  243. font-size: 20rpx;
  244. font-weight: bold;
  245. align-self: flex-end;
  246. margin-bottom: 10rpx;
  247. }
  248. .price{
  249. font-weight: 600;
  250. font-size: 48rpx;
  251. }
  252. }
  253. .old-price{
  254. text-decoration: line-through;
  255. margin-left: 12rpx;
  256. font-weight: 300;
  257. font-size: 20rpx;
  258. }
  259. }
  260. .right{
  261. font-size: 24rpx;
  262. font-weight: 300;
  263. font-size: 24rpx;
  264. }
  265. }
  266. .goods-info{
  267. padding: 24rpx;
  268. margin-bottom: 20rpx;
  269. background: #fff;
  270. .goods-name{
  271. font-size: 32rpx;
  272. color: #222222;
  273. font-weight: bold;
  274. }
  275. .desc{
  276. font-size: 24rpx;
  277. color: #AAAAAA;
  278. overflow: hidden;
  279. text-overflow: ellipsis;
  280. white-space: nowrap;
  281. margin-top: 12rpx;
  282. }
  283. }
  284. .type-box{
  285. padding: 24rpx;
  286. background: #fff;
  287. margin-bottom: 20rpx;
  288. .type-title{
  289. font-size: 28rpx;
  290. color: #222222;
  291. }
  292. .type-list{
  293. display: flex;
  294. flex-wrap: wrap;
  295. justify-content: space-between;
  296. .type-item{
  297. width: 316rpx;
  298. height: 52rpx;
  299. text-align: center;
  300. line-height: 52rpx;
  301. background: #F0F0F0;
  302. border-radius: 26rpx 26rpx 26rpx 26rpx;
  303. font-weight: 300;
  304. font-size: 24rpx;
  305. color: #AAAAAA;
  306. margin-top: 28rpx;
  307. }
  308. .type-item.active{
  309. background: #EE4320;
  310. color: #FFFFFF;
  311. }
  312. }
  313. }
  314. .shop-limit{
  315. padding: 24rpx;
  316. background: #fff;
  317. display: flex;
  318. align-items: center;
  319. justify-content: space-between;
  320. margin-bottom: 20rpx;
  321. .info{
  322. .shop-name{
  323. font-size: 28rpx;
  324. color: #222222;
  325. }
  326. .address{
  327. font-size: 24rpx;
  328. color: #AAAAAA;
  329. margin-top: 16rpx;
  330. }
  331. }
  332. .num{
  333. display: flex;
  334. align-items: center;
  335. font-size: 24rpx;
  336. color: #AAAAAA;
  337. .icon{
  338. width: 48rpx;
  339. height: 48rpx;
  340. transform: rotate(-90deg);
  341. }
  342. }
  343. }
  344. .tab-group{
  345. display: flex;
  346. background: #fff;
  347. .tab{
  348. flex:1;
  349. padding: 24rpx 0;
  350. text-align: center;
  351. font-size: 28rpx;
  352. color: #222222;
  353. }
  354. .tab.active{
  355. font-weight: 600;
  356. }
  357. }
  358. .desc-box{
  359. .goods-desc{
  360. color: #222222;
  361. font-size: 24rpx;
  362. .img_class{
  363. max-width: 100%!important;
  364. vertical-align: bottom;
  365. }
  366. }
  367. }
  368. .list{
  369. background: #fff;
  370. .item{
  371. padding: 24rpx;
  372. border-top:1rpx solid #F0F0F0;
  373. .label{
  374. font-weight: 600;
  375. font-size: 28rpx;
  376. color: #222222;
  377. }
  378. .value{
  379. font-size: 24rpx;
  380. color: #AAAAAA;
  381. margin-top: 16rpx;
  382. line-height: 40rpx;
  383. }
  384. }
  385. }
  386. .buy-box{
  387. position: fixed;
  388. bottom: 0%;
  389. left: 0%;
  390. width: 100%;
  391. background: #fff;
  392. padding: 10rpx 24rpx 76rpx;
  393. display: flex;
  394. justify-content: space-between;
  395. box-sizing: border-box;
  396. .head{
  397. width: 80rpx;
  398. height: 80rpx;
  399. background: #aaa;
  400. border-radius: 50%;
  401. }
  402. .btn-box{
  403. display: flex;
  404. text-align: center;
  405. .group-btn{
  406. width: 280rpx;
  407. height: 80rpx;
  408. background: #6499FF;
  409. border-radius: 40rpx 0rpx 0rpx 40rpx;
  410. display: flex;
  411. flex-direction: column;
  412. justify-content: space-around;
  413. .label{
  414. font-weight: 600;
  415. font-size: 28rpx;
  416. color: #FFFFFF;
  417. }
  418. .price{
  419. font-size: 24rpx;
  420. color: #FFFFFF;
  421. }
  422. }
  423. .buy-btn.none{
  424. filter: grayscale(1);
  425. }
  426. .buy-btn{
  427. // width: 280rpx;
  428. width: 560rpx;
  429. height: 80rpx;
  430. background: $uni-color-primary;
  431. border-radius: 40rpx;
  432. // border-radius: 0rpx 40rpx 40rpx 0rpx;
  433. display: flex;
  434. flex-direction: column;
  435. justify-content: space-around;
  436. .label{
  437. font-weight: 600;
  438. font-size: 28rpx;
  439. color: #FFFFFF;
  440. }
  441. .price{
  442. font-size: 24rpx;
  443. color: #FFFFFF;
  444. }
  445. }
  446. }
  447. }
  448. }
  449. </style>