realyWhole.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  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. getUserInfo
  32. } from '@/api/user.js'
  33. import {
  34. getWholeDetai,
  35. reservePackage,
  36. getWholeInfo
  37. } from '@/api/whole.js'
  38. export default {
  39. components: {
  40. topSwiper,
  41. contentText
  42. },
  43. data() {
  44. return {
  45. imgList: [],
  46. goodItem: {},
  47. good_id: '',
  48. time_id: '',
  49. status: 1,
  50. is_new: '',
  51. description: '',
  52. loading: true,
  53. userInfo: {}
  54. }
  55. },
  56. onLoad(opt) {
  57. if (opt.id) {
  58. this.good_id = opt.id
  59. }
  60. if (opt.time) {
  61. this.time_id = opt.time
  62. // console.log()
  63. }
  64. this.getWholeDetai()
  65. },
  66. onShow() {
  67. this.getUserInfo()
  68. },
  69. methods: {
  70. getUserInfo() {
  71. getUserInfo().then(res => {
  72. console.log(res)
  73. this.userInfo = res.data
  74. })
  75. },
  76. getWholeDetai() {
  77. let obj = this
  78. getWholeInfo({}, obj.good_id).then(({
  79. data
  80. }) => {
  81. console.log(data)
  82. obj.goodItem = data
  83. obj.imgList = data.whole.images
  84. obj.description = data.whole.description.replace(/\<img/gi, '<img class="rich-img"')
  85. obj.loading = false
  86. })
  87. },
  88. // 预约包
  89. reservePackage() {
  90. let obj = this
  91. if (obj.goodItem.isSeckillEnd.status == 0) {
  92. obj.$api.msg('今日该场次已结束')
  93. return
  94. }
  95. if (obj.goodItem.isSeckillEnd.status == 2) {
  96. obj.$api.msg('今日该场次未开始,请稍后')
  97. return
  98. }
  99. if(!obj.userInfo.wx_qr) {
  100. this.$api.msg('您未完善信息,请完善信息后购买!')
  101. setTimeout(()=> {
  102. uni.navigateTo({
  103. url: '/pages/set/userinfo'
  104. })
  105. },1500)
  106. return
  107. }
  108. let updata = {
  109. whole_id: obj.goodItem.whole.id,
  110. time_id: obj.time_id,
  111. price: obj.goodItem.price,
  112. to_uid: obj.goodItem.uid,
  113. first_price: obj.goodItem.first_price,
  114. last_id: obj.goodItem.id
  115. }
  116. console.log(updata, 'updata')
  117. obj.loading = true
  118. reservePackage(updata).then(res => {
  119. uni.showToast({
  120. title: '预约成功',
  121. duration: 2000
  122. });
  123. setTimeout(function() {
  124. uni.navigateTo({
  125. url: '/pages/user/myWholesale'
  126. });
  127. }, 800);
  128. }).catch(err => {
  129. obj.loading = false
  130. console.log(err)
  131. this.getWholeDetai()
  132. })
  133. }
  134. },
  135. }
  136. </script>
  137. <style lang="scss" scoped>
  138. .good-price {
  139. padding-left: 20rpx;
  140. padding-top: 20rpx;
  141. justify-content: flex-start;
  142. background-color: #fff;
  143. // align-items: f;
  144. .new-price {
  145. font-size: 50rpx;
  146. font-family: PingFang SC;
  147. font-weight: bold;
  148. color: #FF4C4C;
  149. }
  150. .old-price {
  151. padding-left: 8rpx;
  152. font-size: 33rpx;
  153. font-family: PingFang SC;
  154. font-weight: bold;
  155. text-decoration: line-through;
  156. color: #999999;
  157. }
  158. }
  159. .good-tit {
  160. padding: 20rpx;
  161. background-color: #fff;
  162. }
  163. .btm-btn {
  164. position: fixed;
  165. bottom: 35rpx;
  166. left: 0;
  167. right: 0;
  168. margin: auto;
  169. width: 699rpx;
  170. height: 90rpx;
  171. line-height: 90rpx;
  172. text-align: center;
  173. background: linear-gradient(90deg, #FE6F61 0%, #FF4343 100%);
  174. border-radius: 45rpx;
  175. font-size: 36rpx;
  176. font-family: PingFang SC;
  177. font-weight: 500;
  178. color: #FFFFFF;
  179. // background-color: #fff;
  180. }
  181. /* 商品详情中限制图片大小 */
  182. /deep/ .rich-img {
  183. width: 100% !important;
  184. height: auto;
  185. }
  186. </style>