studyGoodsDetail.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406
  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" @click="choose(d)">
  38. {{i.specValue}}
  39. </view>
  40. </view>
  41. </view>
  42. </template>
  43. <view class="tab-group">
  44. <view class="tab" :class="[tab == 1 ? 'active':'']" @click="handleTab(1)">
  45. 商品详情
  46. </view>
  47. <view class="tab" :class="[tab == 2 ? 'active':'']" @click="handleTab(2)">
  48. 购买须知
  49. </view>
  50. </view>
  51. <view class="desc-box" v-show="tab == 1">
  52. <rich-text class="goods-desc" :nodes="info.goodsDetail"></rich-text>
  53. </view>
  54. <view class="list" v-show="tab == 2">
  55. <view class="item" v-for="(item,index) in info.attrs" :key="index">
  56. <view class="label">
  57. {{item.attrName == 'validDay'?'有效期':item.attrName}}
  58. </view>
  59. <view class="value" v-html="filterMsg(item.attrValue,item.attrName)">
  60. </view>
  61. </view>
  62. <!-- <view class="item">
  63. <view class="label">
  64. 使用时间
  65. </view>
  66. <view class="value">
  67. 营业时间内可用
  68. </view>
  69. </view> -->
  70. </view>
  71. <view class="buy-box">
  72. <image class="head" :src="shopInfo.logoPath" @click="goShopDetail(shopInfo)" mode=""></image>
  73. <view class="btn-box">
  74. <!-- <view class="group-btn" @click="handleBuy">
  75. <view class="label">
  76. 团购
  77. </view>
  78. <view class="price">
  79. ¥{{info.realPrice}}
  80. </view>
  81. </view> -->
  82. <view class="buy-btn" :class="[info.realStockNum?'':'none']" @click="handleBuy">
  83. <view class="label">
  84. {{info.realStockNum?'会员专享价':'售罄'}}
  85. </view>
  86. <view class="price">
  87. ¥{{info.realPrice}}
  88. </view>
  89. </view>
  90. </view>
  91. </view>
  92. </view>
  93. </template>
  94. <script>
  95. import {detail} from '@/api/goods.js'
  96. export default {
  97. data() {
  98. return {
  99. pageLoading:false,
  100. active:0,
  101. tab:1,
  102. shopList:[],
  103. info: {},
  104. shopInfo:{}
  105. }
  106. },
  107. methods: {
  108. choose(index){
  109. this.active = index
  110. },
  111. filterMsg(val,name){
  112. let msg = val.replace(/\n/g, "<br>")
  113. if(name == 'validDay'){
  114. msg = val + '天'
  115. }
  116. return msg
  117. },
  118. jump(url){
  119. uni.navigateTo({
  120. url
  121. })
  122. },
  123. handleTab(val){
  124. this.tab = val
  125. },
  126. handleBuy() {
  127. if(!this.info.realStockNum) return
  128. let that = this
  129. if (uni.getStorageSync('token')) {
  130. uni.navigateTo({
  131. url:`/pay/pay`,
  132. success: function(res) {
  133. // 通过eventChannel向被打开页面传送数据
  134. res.eventChannel.emit('pay', that.info)
  135. }
  136. })
  137. } else {
  138. uni.showModal({
  139. title:'请登录',
  140. confirmText:'去登录',
  141. success(res){
  142. console.log(res);
  143. if(res.confirm){
  144. uni.navigateTo({
  145. url:`/login/login/login?redirect=/detail/goodsDetail/index&id=${that.info.goodsId}`
  146. })
  147. }
  148. }
  149. })
  150. }
  151. },
  152. detail(goodsId){
  153. this.pageLoading = true
  154. detail({goodsId,resource:2}).then(res=>{
  155. this.pageLoading = false
  156. if(res.state == 'Success'){
  157. this.info = res.content
  158. this.info.goodsDetail = res.content.goodsDetail.replace(/<img/gi, '<img class="img_class" ')
  159. uni.setNavigationBarTitle({
  160. title:this.info.goodsName
  161. })
  162. }
  163. })
  164. },
  165. goShopDetail(shopInfo) {
  166. uni.setStorageSync('shopInfo', JSON.stringify(shopInfo))
  167. uni.navigateTo({
  168. url: `/detail/shopDetail/shopDetail`
  169. })
  170. },
  171. },
  172. onLoad(option) {
  173. this.shopInfo = JSON.parse(uni.getStorageSync('shopInfo'))
  174. this.detail(option.id)
  175. }
  176. }
  177. </script>
  178. <style lang="scss" >
  179. .goodsDetail{
  180. background: #F9F9F9;
  181. padding-bottom: 200rpx;
  182. min-height: 100vh;
  183. .good-img{
  184. width: 100%;
  185. height: 750rpx;
  186. vertical-align: bottom;
  187. }
  188. .price-box{
  189. display: flex;
  190. justify-content: space-between;
  191. align-items: center;
  192. width: 100%;
  193. height: 116rpx;
  194. box-sizing: border-box;
  195. background: #fff;
  196. // background-image: url('@/static/price-bg.png');
  197. // background-repeat: no-repeat;
  198. // background-size: 100% 116rpx;
  199. padding: 24rpx 24rpx 0;
  200. .left{
  201. display: flex;
  202. align-items: center;
  203. .num-box{
  204. display: flex;
  205. align-items: center;
  206. .unit{
  207. color: #FF4D3A;
  208. font-size: 20rpx;
  209. font-weight: bold;
  210. align-self: flex-end;
  211. margin-bottom: 10rpx;
  212. }
  213. .price{
  214. font-weight: 600;
  215. font-size: 56rpx;
  216. color: #FF4D3A;
  217. }
  218. }
  219. .old-price{
  220. text-decoration: line-through;
  221. margin-left: 12rpx;
  222. font-weight: 300;
  223. font-size: 20rpx;
  224. }
  225. }
  226. .right{
  227. font-size: 24rpx;
  228. font-weight: 300;
  229. font-size: 24rpx;
  230. }
  231. }
  232. .goods-info{
  233. padding: 0 24rpx 24rpx;
  234. margin-bottom: 20rpx;
  235. background: #fff;
  236. .goods-name{
  237. font-size: 32rpx;
  238. color: #222222;
  239. font-weight: bold;
  240. }
  241. .desc{
  242. font-size: 24rpx;
  243. color: #AAAAAA;
  244. overflow: hidden;
  245. text-overflow: ellipsis;
  246. white-space: nowrap;
  247. margin-top: 12rpx;
  248. }
  249. }
  250. .type-box{
  251. padding: 24rpx;
  252. background: #fff;
  253. margin-bottom: 20rpx;
  254. .type-title{
  255. font-size: 28rpx;
  256. color: #222222;
  257. }
  258. .type-list{
  259. display: flex;
  260. flex-wrap: wrap;
  261. justify-content: space-between;
  262. .type-item{
  263. width: 316rpx;
  264. height: 52rpx;
  265. text-align: center;
  266. line-height: 52rpx;
  267. background: #F0F0F0;
  268. border-radius: 26rpx 26rpx 26rpx 26rpx;
  269. font-weight: 300;
  270. font-size: 24rpx;
  271. color: #AAAAAA;
  272. margin-top: 28rpx;
  273. }
  274. .type-item.active{
  275. background: #EE4320;
  276. color: #FFFFFF;
  277. }
  278. }
  279. }
  280. .tab-group{
  281. display: flex;
  282. background: #fff;
  283. .tab{
  284. flex:1;
  285. padding: 24rpx 0;
  286. text-align: center;
  287. font-size: 28rpx;
  288. color: #222222;
  289. }
  290. .tab.active{
  291. font-weight: 600;
  292. }
  293. }
  294. .desc-box{
  295. .goods-desc{
  296. color: #222222;
  297. font-size: 24rpx;
  298. .img_class{
  299. max-width: 100%!important;
  300. vertical-align: bottom;
  301. }
  302. }
  303. }
  304. .list{
  305. background: #fff;
  306. .item{
  307. padding: 24rpx;
  308. border-top:1rpx solid #F0F0F0;
  309. .label{
  310. font-weight: 600;
  311. font-size: 28rpx;
  312. color: #222222;
  313. }
  314. .value{
  315. font-size: 24rpx;
  316. color: #AAAAAA;
  317. margin-top: 16rpx;
  318. line-height: 40rpx;
  319. }
  320. }
  321. }
  322. .buy-box{
  323. position: fixed;
  324. bottom: 0%;
  325. left: 0%;
  326. width: 100%;
  327. background: #fff;
  328. padding: 10rpx 24rpx 76rpx;
  329. display: flex;
  330. justify-content: space-between;
  331. box-sizing: border-box;
  332. .head{
  333. width: 80rpx;
  334. height: 80rpx;
  335. background: #aaa;
  336. border-radius: 50%;
  337. }
  338. .btn-box{
  339. display: flex;
  340. text-align: center;
  341. .group-btn{
  342. width: 280rpx;
  343. height: 80rpx;
  344. background: #6499FF;
  345. border-radius: 40rpx 0rpx 0rpx 40rpx;
  346. display: flex;
  347. flex-direction: column;
  348. justify-content: space-around;
  349. .label{
  350. font-weight: 600;
  351. font-size: 28rpx;
  352. color: #FFFFFF;
  353. }
  354. .price{
  355. font-size: 24rpx;
  356. color: #FFFFFF;
  357. }
  358. }
  359. .buy-btn.none{
  360. filter: grayscale(1);
  361. }
  362. .buy-btn{
  363. // width: 280rpx;
  364. width: 560rpx;
  365. height: 80rpx;
  366. background: #3B83FF;
  367. border-radius: 40rpx;
  368. // border-radius: 0rpx 40rpx 40rpx 0rpx;
  369. display: flex;
  370. flex-direction: column;
  371. justify-content: space-around;
  372. .label{
  373. font-weight: 600;
  374. font-size: 28rpx;
  375. color: #FFFFFF;
  376. }
  377. .price{
  378. font-size: 24rpx;
  379. color: #FFFFFF;
  380. }
  381. }
  382. }
  383. }
  384. }
  385. </style>