wholesaleDetail.vue 4.8 KB

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