index.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. <template>
  2. <view class="goodsDetail">
  3. <image class="good-img" :src="info.studyItem" mode=""></image>
  4. <view class="goods-box">
  5. <view class="goods-name">
  6. {{info.goodsName}}
  7. </view>
  8. <view class="tab">
  9. {{goodsTypeObj[info.goodsCode]}}
  10. </view>
  11. </view>
  12. <view class="price">
  13. ¥ {{info.buyPrice}}
  14. </view>
  15. <view class="desc-box">
  16. <view class="title">
  17. 商品说明
  18. </view>
  19. <!-- <view class="goods-desc">
  20. {{info.goodsDescribe}}
  21. </view> -->
  22. <rich-text class="goods-desc" :nodes="info.goodsDescribe"></rich-text>
  23. </view>
  24. <button class="buy-btn" type="default" @click="handleBuy">立即购买</button>
  25. </view>
  26. </template>
  27. <script>
  28. export default {
  29. data() {
  30. return {
  31. info: {},
  32. goodsTypeObj:{}
  33. }
  34. },
  35. methods: {
  36. handleBuy() {
  37. if (uni.getStorageSync('token')) {
  38. let that = this
  39. uni.navigateTo({
  40. url:`/pay/pay`,
  41. success: function(res) {
  42. // 通过eventChannel向被打开页面传送数据
  43. res.eventChannel.emit('pay', that.info)
  44. }
  45. })
  46. } else {
  47. uni.showModal({
  48. title:'请登录',
  49. confirmText:'去登录',
  50. success(res){
  51. console.log(res);
  52. if(res.confirm){
  53. uni.navigateTo({
  54. url:'/login/login/login?redirect=/detail/goodsDetail/index'
  55. })
  56. }
  57. }
  58. })
  59. }
  60. }
  61. },
  62. onLoad() {
  63. let that = this
  64. this.goodsTypeObj = JSON.parse(uni.getStorageSync('goodsTypeObj'))
  65. this.info = JSON.parse(uni.getStorageSync('goodsInfo'))
  66. // const eventChannel = this.getOpenerEventChannel();
  67. // if(JSON.stringify(eventChannel) !=='{}'){
  68. // eventChannel.on('goodsInfo', function(data) {
  69. // that.info = data
  70. // })
  71. // }
  72. }
  73. }
  74. </script>
  75. <style lang="scss" scoped>
  76. .goodsDetail{
  77. .good-img{
  78. width: 100%;
  79. height: 420rpx;
  80. }
  81. .goods-box{
  82. display: flex;
  83. align-items: center;
  84. margin-left: 32rpx;
  85. margin-top: 28rpx;
  86. .goods-name{
  87. font-weight: bold;
  88. color: #222222;
  89. font-size: 32rpx;
  90. }
  91. .tab{
  92. height: 36rpx;
  93. line-height: 36rpx;
  94. text-align: center;
  95. color: #FFFFFF;
  96. font-size: 24rpx;
  97. background: #FF4C3A;
  98. border-radius: 0rpx 12rpx 0rpx 12rpx;
  99. margin-left: 20rpx;
  100. padding: 0 6rpx;
  101. }
  102. }
  103. .price{
  104. font-weight: 800;
  105. color: #FF4C3A;
  106. font-size: 36rpx;
  107. margin-left: 32rpx;
  108. margin-top: 20rpx;
  109. padding-bottom: 28rpx;
  110. }
  111. .desc-box{
  112. padding: 0 32rpx 150rpx;
  113. .title{
  114. font-weight: bold;
  115. color: #222222;
  116. font-size: 32rpx;
  117. padding: 30rpx 0;
  118. border-top: 1rpx solid #F0F0F0;
  119. }
  120. .goods-desc{
  121. color: #222222;
  122. font-size: 24rpx;
  123. }
  124. }
  125. .buy-btn{
  126. position: fixed;
  127. bottom: 60rpx;
  128. left: 50%;
  129. transform: translateX(-50%);
  130. width: 688rpx;
  131. height: 80rpx;
  132. line-height: 80rpx;
  133. text-align: center;
  134. font-weight: bold;
  135. color: #FFFFFF;
  136. font-size: 28rpx;
  137. background: $uni-color-primary;
  138. box-shadow: inset 0rpx 6rpx 12rpx 2rpx rgba(255,255,255,0.16);
  139. border-radius: 46rpx 46rpx 46rpx 46rpx;
  140. }
  141. }
  142. </style>