realyWhole.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. <template>
  2. <view class="content">
  3. <!-- 轮播图 -->
  4. <top-swiper :imgList="imgList"></top-swiper>
  5. <!-- 价格 -->
  6. <view class="good-price flex">
  7. <view class="new-price">
  8. ¥{{goodItem.price}}
  9. </view>
  10. <view class="old-price" v-if="goodItem.whole && (goodItem.whole.ot_price*1 > goodItem.price*1)">
  11. ¥{{goodItem.whole.ot_price}}
  12. </view>
  13. </view>
  14. <!-- 标题 -->
  15. <view class="good-tit" v-if="goodItem.whole">
  16. {{goodItem.whole.title}}
  17. </view>
  18. <content-text :description="description"></content-text>
  19. <view class="btn-ts" style="height: 130rpx; background-color: #fff;"></view>
  20. <view class="btm-btn" @click="loading? '':reservePackage()">
  21. 立即预约
  22. </view>
  23. </view>
  24. </template>
  25. <script>
  26. // 头部轮播图
  27. import topSwiper from './common/topSwiper.vue';
  28. // 图文详情
  29. import contentText from './common/contentText.vue';
  30. import {
  31. getWholeDetai,
  32. reservePackage,
  33. getWholeInfo
  34. } from '@/api/whole.js'
  35. export default {
  36. components: {
  37. topSwiper,
  38. contentText
  39. },
  40. data() {
  41. return {
  42. imgList: [],
  43. goodItem: {},
  44. good_id: '',
  45. time_id: '',
  46. status: 1,
  47. is_new: '',
  48. description: '',
  49. loading: true,
  50. }
  51. },
  52. onLoad(opt) {
  53. if (opt.id) {
  54. this.good_id = opt.id
  55. }
  56. if (opt.time) {
  57. this.time_id = opt.time
  58. // console.log()
  59. }
  60. this.getWholeDetai()
  61. },
  62. methods: {
  63. getWholeDetai() {
  64. let obj = this
  65. getWholeInfo({}, obj.good_id).then(({
  66. data
  67. }) => {
  68. console.log(data)
  69. obj.goodItem = data
  70. obj.imgList = data.whole.images
  71. obj.description = data.whole.description.replace(/\<img/gi, '<img class="rich-img"')
  72. obj.loading = false
  73. })
  74. },
  75. // 预约包
  76. reservePackage() {
  77. let obj = this
  78. if (obj.goodItem.isSeckillEnd.status == 0) {
  79. obj.$api.msg('今日该场次已结束')
  80. return
  81. }
  82. if (obj.goodItem.isSeckillEnd.status == 2) {
  83. obj.$api.msg('今日该场次未开始,请稍后')
  84. return
  85. }
  86. let updata = {
  87. whole_id: obj.goodItem.whole.id,
  88. time_id: obj.time_id,
  89. price: obj.goodItem.price,
  90. to_uid: obj.goodItem.to_uid,
  91. first_price: obj.goodItem.first_price,
  92. last_id: obj.goodItem.id
  93. }
  94. console.log(updata, 'updata')
  95. obj.loading = true
  96. reservePackage(updata).then(res => {
  97. uni.showToast({
  98. title: '预约成功',
  99. duration: 2000
  100. });
  101. setTimeout(function() {
  102. uni.navigateTo({
  103. url: '/pages/user/myWholesale'
  104. });
  105. }, 800);
  106. }).catch(err => {
  107. obj.loading = false
  108. console.log(err)
  109. this.getWholeDetai()
  110. })
  111. }
  112. },
  113. }
  114. </script>
  115. <style lang="scss" scoped>
  116. .good-price {
  117. padding-left: 20rpx;
  118. padding-top: 20rpx;
  119. justify-content: flex-start;
  120. background-color: #fff;
  121. // align-items: f;
  122. .new-price {
  123. font-size: 50rpx;
  124. font-family: PingFang SC;
  125. font-weight: bold;
  126. color: #FF4C4C;
  127. }
  128. .old-price {
  129. padding-left: 8rpx;
  130. font-size: 33rpx;
  131. font-family: PingFang SC;
  132. font-weight: bold;
  133. text-decoration: line-through;
  134. color: #999999;
  135. }
  136. }
  137. .good-tit {
  138. padding: 20rpx;
  139. background-color: #fff;
  140. }
  141. .btm-btn {
  142. position: fixed;
  143. bottom: 35rpx;
  144. left: 0;
  145. right: 0;
  146. margin: auto;
  147. width: 699rpx;
  148. height: 90rpx;
  149. line-height: 90rpx;
  150. text-align: center;
  151. background: linear-gradient(90deg, #FE6F61 0%, #FF4343 100%);
  152. border-radius: 45rpx;
  153. font-size: 36rpx;
  154. font-family: PingFang SC;
  155. font-weight: 500;
  156. color: #FFFFFF;
  157. // background-color: #fff;
  158. }
  159. /* 商品详情中限制图片大小 */
  160. /deep/ .rich-img {
  161. width: 100% !important;
  162. height: auto;
  163. }
  164. </style>