wholesaleDetail.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  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">
  11. ¥{{goodItem.ot_price}}
  12. </view>
  13. </view>
  14. <!-- 标题 -->
  15. <view class="good-tit">
  16. {{goodItem.title}}
  17. </view>
  18. <content-text :description="description"></content-text>
  19. <view class="btn-ts" style="height: 130rpx; background-color: #fff;">
  20. </view>
  21. <view class="btm-btn" @click="loading? '':reservePackage()">
  22. 立即预约
  23. </view>
  24. </view>
  25. </template>
  26. <script>
  27. // 头部轮播图
  28. import topSwiper from './common/topSwiper.vue';
  29. // 图文详情
  30. import contentText from './common/contentText.vue';
  31. import {
  32. getUserInfo
  33. } from '@/api/user.js'
  34. import {
  35. getWholeDetai,
  36. reservePackage,
  37. getWholeInfo
  38. } from '@/api/whole.js'
  39. export default {
  40. components: {
  41. topSwiper,
  42. contentText
  43. },
  44. data() {
  45. return {
  46. imgList: [],
  47. goodItem: {},
  48. good_id: '',
  49. time_id: '',
  50. status: 1,
  51. is_new: 'non',
  52. description: '',
  53. loading: false,
  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. }
  63. if (opt.status) {
  64. this.status = opt.status
  65. }
  66. // if (opt.is_new) {
  67. // this.is_new = opt.is_new
  68. // }
  69. this.getUserInfo()
  70. this.getWholeDetai()
  71. },
  72. methods: {
  73. getUserInfo() {
  74. getUserInfo().then(res => {
  75. console.log(res)
  76. // this.setUserInfo(res.data);
  77. // this.userInfo = res.data
  78. this.is_new = res.data.is_whole == 0? 'isn': 'non'
  79. })
  80. },
  81. getWholeDetai() {
  82. let obj = this
  83. if (obj.is_new) {
  84. getWholeDetai({}, obj.good_id, obj.time_id, obj.status, 1).then(({
  85. data
  86. }) => {
  87. obj.goodItem = data.storeInfo
  88. obj.imgList = data.storeInfo.images
  89. obj.description = data.storeInfo.description.replace(/\<img/gi, '<img class="rich-img"')
  90. })
  91. } else {
  92. getWholeInfo({},obj.good_id).then(({data}) => {
  93. obj.goodItem = data.storeInfo
  94. obj.imgList = data.storeInfo.images
  95. obj.description = data.storeInfo.description.replace(/\<img/gi, '<img class="rich-img"')
  96. })
  97. // getWholeDetai({}, obj.good_id, obj.time_id, obj.status, 0).then(({
  98. // data
  99. // }) => {
  100. // obj.goodItem = data.storeInfo
  101. // obj.imgList = data.storeInfo.images
  102. // obj.description = data.storeInfo.description.replace(/\<img/gi, '<img class="rich-img"')
  103. // })
  104. }
  105. },
  106. // 预约包
  107. reservePackage() {
  108. let obj = this
  109. if(obj.is_new == 'non') {
  110. this.$api.msg('您已不是新人,无法购买新人专属商品')
  111. return
  112. }
  113. let updata = {
  114. whole_id: obj.good_id,
  115. time_id: obj.time_id,
  116. price: obj.goodItem.price,
  117. to_uid: obj.is_new == 'isn' ? 0 : '',
  118. first_price: obj.is_new == 'isn' ? 0 : '',
  119. last_id: obj.is_new == 'isn' ? 0 : ''
  120. }
  121. obj.loading = true
  122. reservePackage(updata).then(res => {
  123. uni.showToast({
  124. title: '预约成功',
  125. duration: 2000
  126. });
  127. setTimeout(function() {
  128. uni.navigateTo({
  129. url: '/pages/user/myWholesale'
  130. });
  131. }, 800);
  132. }).catch(err => {
  133. obj.loading = false
  134. console.log(err)
  135. })
  136. }
  137. }
  138. }
  139. </script>
  140. <style lang="scss" scoped>
  141. .good-price {
  142. padding-left: 20rpx;
  143. padding-top: 20rpx;
  144. justify-content: flex-start;
  145. background-color: #fff;
  146. // align-items: f;
  147. .new-price {
  148. font-size: 50rpx;
  149. font-family: PingFang SC;
  150. font-weight: bold;
  151. color: #FF4C4C;
  152. }
  153. .old-price {
  154. padding-left: 8rpx;
  155. font-size: 33rpx;
  156. font-family: PingFang SC;
  157. font-weight: bold;
  158. text-decoration: line-through;
  159. color: #999999;
  160. }
  161. }
  162. .good-tit {
  163. padding: 20rpx;
  164. background-color: #fff;
  165. }
  166. .btm-btn {
  167. position: fixed;
  168. bottom: 35rpx;
  169. left: 0;
  170. right: 0;
  171. margin: auto;
  172. width: 699rpx;
  173. height: 90rpx;
  174. line-height: 90rpx;
  175. text-align: center;
  176. background: linear-gradient(90deg, #FE6F61 0%, #FF4343 100%);
  177. border-radius: 45rpx;
  178. font-size: 36rpx;
  179. font-family: PingFang SC;
  180. font-weight: 500;
  181. color: #FFFFFF;
  182. // background-color: #fff;
  183. }
  184. /* 商品详情中限制图片大小 */
  185. /deep/ .rich-img {
  186. width: 100% !important;
  187. height: auto;
  188. }
  189. </style>