detail.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <template>
  2. <view>
  3. <view class="top">
  4. <image :src="ip + item.pic" class="pic" mode="widthFix"></image>
  5. <view class="title">
  6. <text>{{ item.title }}</text>
  7. </view>
  8. <view class="price" v-if="item.price">
  9. <text>¥{{ item.price }}</text>
  10. <text class="day">/天</text>
  11. </view>
  12. </view>
  13. <view class="contents">
  14. <u-divider>服务介绍</u-divider>
  15. <u-parse :html="item.contents" style="margin-top: 15px;"></u-parse>
  16. </view>
  17. <view class="footer">
  18. <view class="lfx">
  19. <view class="f" style="flex:0.6;">
  20. <button class="kf" open-type="contact">
  21. <view class="icon">&#xe62a;</view>
  22. <view class="tag">客服</view>
  23. </button>
  24. <button class="kf" @click="car()">
  25. <view class="icon">&#xe65f;</view>
  26. <view class="tag">购物车</view>
  27. </button>
  28. </view>
  29. <view class="f" style="flex: 1;">
  30. <view class="lfx">
  31. <view class="f gwc" @click="add()">加入购物车</view>
  32. <view class="f gm" @click="buy()">立即租赁</view>
  33. </view>
  34. </view>
  35. </view>
  36. </view>
  37. </view>
  38. </template>
  39. <script>
  40. export default {
  41. data() {
  42. return {
  43. ip: this.$http.urls.ip,
  44. item: {}
  45. };
  46. },
  47. onLoad(e) {
  48. this.$http.request({
  49. url: this.$http.urls.goods_detail + e.id,
  50. success: res => {
  51. this.item = res.data.data;
  52. this.item.contents = res.data.data.contents.replace(/\<img/gi, '<img style=width:100%;height:auto');
  53. }
  54. });
  55. },
  56. methods: {
  57. //购物车
  58. car() {
  59. uni.switchTab({
  60. url: 'shopcar'
  61. });
  62. },
  63. //添加购物车
  64. add() {
  65. this.$http.request({
  66. url: this.$http.urls.cart_add,
  67. method: 'POST',
  68. data: { goodsId: this.item.id, userId: this.$getUser().id },
  69. success: res => {
  70. uni.showToast({ title: '已加入购物车', icon: 'none' });
  71. }
  72. });
  73. },
  74. //直接购买服务
  75. buy() {
  76. let list = [{ goodsId: this.item.id, goods: { title: this.item.title, price: this.item.price, pic: this.item.pic } }];
  77. uni.navigateTo({ url: 'pay?list=' + JSON.stringify(list) });
  78. }
  79. }
  80. };
  81. </script>
  82. <style lang="scss">
  83. page {
  84. background-color: $page;
  85. }
  86. .top {
  87. background-color: white;
  88. .pic {
  89. width: 100%;
  90. }
  91. .title {
  92. font-size: 15px;
  93. font-weight: bold;
  94. padding: 10px 15px 0px 15px;
  95. }
  96. .price {
  97. font-size: 15px;
  98. text-align: left;
  99. color: $theme-color;
  100. padding: 5px 15px 10px 15px;
  101. .day {
  102. padding-left: 3px;
  103. color: #c7c0c0;
  104. font-size: 12px;
  105. }
  106. }
  107. }
  108. .contents {
  109. margin-top: 10px;
  110. padding: 10px 10px 55px 10px;
  111. background-color: white;
  112. }
  113. .footer {
  114. padding-top: 8px;
  115. }
  116. </style>