goodsDetails.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. <template>
  2. <view>
  3. <!-- <navigation-bar background-color="#fff" front-color="#000000" /> -->
  4. <view class="back" @click="back">
  5. <uni-icons type="back" color="#000000" size="30"></uni-icons>
  6. </view>
  7. <swiper style="width: 100%; height: 700rpx;" circular :indicator-dots="true" :autoplay="true">
  8. <swiper-item style="width: 100%;">
  9. <image style="width: 100%; height: 100%;" mode="aspectFill" src="../../static/news.jpg"></image>
  10. </swiper-item>
  11. </swiper>
  12. <!-- <u-image width="100%" height="800rpx" :src="goods.goodsImg"></u-image> -->
  13. <!-- <u-image width="100%" height="400rpx" src="../../static/news.jpg"></u-image> -->
  14. <view class="title pad">
  15. {{goods.goodsName}}
  16. </view>
  17. <view class="price pad">
  18. ¥{{goods.price}} {{goods.goodsUnits}}
  19. </view>
  20. <view class="pad">
  21. <u-tag class="tag" v-for="(item,index) in type" :key="index" :text="item" type="warning" plain></u-tag>
  22. </view>
  23. <view class="pad">
  24. <u--text prefixIcon="home" iconStyle="font-size: 50rpx" :text="goods.merchantName" size="26"></u--text>
  25. </view>
  26. <view class="pad">
  27. <u--text prefixIcon="map" iconStyle="font-size: 50rpx" :text="goods.tradeAreaName" size="26"></u--text>
  28. </view>
  29. <view class="pad des">
  30. <u--text text="商品描述:" size="24"></u--text>
  31. <u--text :text="goods.description? goods.description : '卖家很懒,什么都没有留下'" size="24"></u--text>
  32. </view>
  33. <view class="footer">
  34. <view class="cart">
  35. <uni-icons color="#ef732a" type="cart" size="30"></uni-icons>
  36. <text>购物车</text>
  37. <!-- <u-icon label="购物车" size="40" color="#ef732a" labelColor="#ef732a" name="shopping-cart"></u-icon> -->
  38. </view>
  39. <u-button class="custom-style" type="warning" @click="addCar()">加入购物车</u-button>
  40. <u-button class="custom-style" type="error" @click="buy()">提交订单</u-button>
  41. </view>
  42. <!-- <u-popup :show="show" @close="close" @open="open">
  43. <view>
  44. <view class="num">
  45. <u-button class="numBtn" icon="minus" @click="minus()"></u-button>
  46. <text v-model="num">{{num}}</text>
  47. <u-button class="numBtn" icon="plus" @click="add()"></u-button>
  48. </view>
  49. <u-button type="primary" shape="circle" size="40" text="确定" @click="addCar()"></u-button>
  50. </view>
  51. </u-popup> -->
  52. </view>
  53. </template>
  54. <script>
  55. import common from '../../common/js/common'
  56. export default {
  57. data() {
  58. return {
  59. id: '',
  60. goods: {},
  61. type: [],
  62. show: false,
  63. num: 1
  64. }
  65. },
  66. onLoad(option) {
  67. this.id = option.id
  68. this.getGoodsDetails()
  69. },
  70. methods: {
  71. getGoodsDetails() {
  72. this.http.request({
  73. url: '/level-one-server/TbGoodsTransit/getById',
  74. data: {
  75. id: this.id
  76. },
  77. success: res => {
  78. this.goods = res.data.data;
  79. if (this.goods) {
  80. this.type = this.goods.goodsType.toString().split("、")
  81. }
  82. }
  83. });
  84. },
  85. minus() {
  86. if (this.num == 1) {
  87. this.$$common.toast("已经到最小数量,无法在减少")
  88. return
  89. } else {
  90. this.num--
  91. }
  92. },
  93. add() {
  94. this.num++
  95. },
  96. addCar() {
  97. let user = uni.getStorageSync("info")
  98. let params = {
  99. buyUserId: user.id,
  100. enterpriseId: this.goods.merchantId,
  101. shopId: this.goods.shopId,
  102. tradeAreaId: this.goods.tradeAreaId,
  103. saleGoodsInfoId: this.goods.id,
  104. goodsImg: this.goods.goodsImg,
  105. goodsName: this.goods.goodsName,
  106. // buyNum: parseInt(this.num)
  107. }
  108. this.http.request({
  109. url: '/level-one-server/app/TbGoodsCart/addGoodsInShopCart',
  110. data: params,
  111. contentType: 'application/json; charset=utf-8',
  112. method: 'POST',
  113. success: res => {
  114. setTimeout(function() {
  115. uni.showToast({
  116. title: res.data.msg
  117. });
  118. }, 1000)
  119. }
  120. });
  121. },
  122. // 立即购买
  123. buy() {
  124. this.http.request({
  125. url: '/level-one-server/app/TbGoodsTransit/purchaseLevelOntGoodsTransit',
  126. data: {
  127. goodsTransitId: this.goods.id
  128. },
  129. method: 'POST',
  130. contentType: 'application/json; charset=utf-8',
  131. success: res => {
  132. setTimeout(function() {
  133. uni.showToast({
  134. title: res.data.msg
  135. });
  136. }, 1000)
  137. }
  138. });
  139. },
  140. back() {
  141. uni.navigateBack({
  142. delta: 1
  143. })
  144. }
  145. }
  146. }
  147. </script>
  148. <style lang="scss">
  149. page {
  150. padding: 0;
  151. background-color: #f3f4f6;
  152. }
  153. .back {
  154. position: absolute;
  155. top: 10rpx;
  156. left: 10rpx;
  157. width: 80rpx;
  158. height: 80rpx;
  159. border-radius: 40rpx;
  160. background-color: #828282;
  161. display: flex;
  162. opacity: 0.7;
  163. z-index: 1;
  164. align-items: center;
  165. justify-content: center;
  166. }
  167. .pad {
  168. width: 100%;
  169. padding: 10rpx;
  170. display: flex;
  171. }
  172. .title {
  173. font-size: 42rpx;
  174. }
  175. .price {
  176. color: red;
  177. font-size: 40rpx;
  178. }
  179. .cart {
  180. width: 30%;
  181. color: #ef732a;
  182. font-size: 40rpx;
  183. display: flex;
  184. align-items: center;
  185. justify-content: center;
  186. }
  187. .tag {
  188. width: auto;
  189. margin-right: 10rpx;
  190. }
  191. .custom-style {
  192. width: 30%;
  193. height: 100rpx;
  194. font-size: 30rpx;
  195. }
  196. .des {
  197. border-top: 1rpx #888 solid;
  198. margin-bottom: 10rpx;
  199. }
  200. .footer {
  201. padding: 20rpx;
  202. width: 100%;
  203. display: flex;
  204. position: absolute;
  205. bottom: 1rpx;
  206. }
  207. </style>