index.vue 9.0 KB

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