index.vue 9.5 KB

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