goodsDetail.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. <template>
  2. <view class="goods-detail">
  3. <view>
  4. <!-- 商品信息 -->
  5. <view class="goods-head">
  6. <view class="goods-imgs">
  7. <view class="goods-staus" v-if="goodContent.inventoryQty == 0 || goodContent.delFlage == 0 || goodContent.state == 0"></view>
  8. <u-swiper height="340" :border-radius="15" mode="number" indicator-pos="bottomRight" :list="imageList"></u-swiper>
  9. </view>
  10. <view class="goods-name">
  11. <view>
  12. {{goodContent.name}}
  13. </view>
  14. <view>
  15. <text>{{goodContent.sellGold}}</text>
  16. <u-image mode="scaleToFill" width="40rpx" height="40rpx" src="/static/ledou.png"></u-image>
  17. </view>
  18. </view>
  19. <view class="goods-price">
  20. <view>兑换数量<text>(库存{{goodContent.inventoryQty}}件)</text></view>
  21. <view>
  22. <u-number-box :max="goodContent.inventoryQty" v-model="nums"></u-number-box>
  23. </view>
  24. </view>
  25. <view v-if="goldLimit>0" class="goods-goldLimit">
  26. 此商品需要满<text>{{goldLimit}}</text>乐豆才可购买
  27. </view>
  28. </view>
  29. <!-- 商品属性 -->
  30. <view class="goods-attr">
  31. <view>
  32. <view>运费</view>
  33. <view>免运费</view>
  34. </view>
  35. <view>
  36. <view>限购</view>
  37. <view>每人限购1件</view>
  38. </view>
  39. <view>
  40. <view>售后</view>
  41. <view>兑换商品,一经售出,不支持退换货</view>
  42. </view>
  43. </view>
  44. <!-- 商品详情 -->
  45. <view class="goods-content">
  46. <jyf-parser :html="goodContent.desc" ref="article"></jyf-parser>
  47. </view>
  48. </view>
  49. <!-- 底部浮动按钮 -->
  50. <view class="bottom-btns" v-if="goodContent&&goodContent.inventoryQty > 0&&goodContent.state==1">
  51. <view><u-button :custom-style="addCartButton" type="warning" @click="addCart">加入购物车</u-button></view>
  52. <view><u-button :custom-style="toOrderButton" type="error" @click="toOrder()">立即下单</u-button></view>
  53. </view>
  54. <!-- 购物车 -->
  55. <uni-cart-fix :closeCurPage="true"></uni-cart-fix>
  56. </view>
  57. </template>
  58. <script>
  59. import {
  60. getGoodsDetail
  61. } from '@/api/goods.js'
  62. import jyfParser from "@/components/jyf-parser/jyf-parser";
  63. export default {
  64. components: {
  65. jyfParser
  66. },
  67. data() {
  68. return {
  69. addCartButton: {
  70. background: '#ff9000',
  71. borderRadius:'100rpx 0 0 100rpx'
  72. },
  73. toOrderButton: {
  74. borderRadius:'0 100rpx 100rpx 0'
  75. },
  76. imageList:[], // 商品图片
  77. nums:1, // 商品数量
  78. id: '',
  79. goodContent: null,
  80. goldLimit: 0
  81. };
  82. },
  83. onLoad(opts) {
  84. console.log(opts)
  85. this.id = opts.id
  86. this.goldLimit = opts.goldLimit
  87. this.getDetail()
  88. },
  89. methods: {
  90. // 查详情
  91. getDetail(){
  92. getGoodsDetail({id:this.id}).then(res => {
  93. console.log(res)
  94. if(res.status == 200){
  95. this.goodContent = res.data
  96. let arr=res.data.images.split(',')
  97. arr.map(item => {
  98. this.imageList.push({image:item})
  99. })
  100. }
  101. })
  102. },
  103. // 加入购物车
  104. addCart(){
  105. let _this = this
  106. let item = this.goodContent
  107. this.$bindClick(function(){
  108. uni.$emit("addCart",{goodsNo:item.goodsNo,buyQty:_this.nums})
  109. })
  110. },
  111. // 立即下单
  112. toOrder(){
  113. // console.log(this.goodContent,this.id,'pppppppp')
  114. if(this.goodContent.sellGold * this.nums >= this.goldLimit){
  115. this.$u.vuex("vuex_toOrderList",[{id:this.id,buyQty:this.nums,goodsNo:this.goodContent.goodsNo,goods:this.goodContent}])
  116. uni.redirectTo({
  117. url:"/pages/toOrder/index"
  118. })
  119. }else{
  120. uni.showToast({
  121. icon:"none",
  122. title:"此商品需要满" +this.goldLimit+ "乐豆才可购买"
  123. })
  124. }
  125. }
  126. },
  127. }
  128. </script>
  129. <style lang="scss">
  130. page{
  131. height: 100%;
  132. }
  133. .goods-detail{
  134. width: 100%;
  135. height: 100%;
  136. display: flex;
  137. flex-direction: column;
  138. > view{
  139. &:first-child{
  140. flex-grow: 1;
  141. overflow: auto;
  142. }
  143. }
  144. .goods-head{
  145. background: #FFFFFF;
  146. box-shadow: 1px 1px 3px #eee;
  147. padding: 10upx 0;
  148. .goods-imgs{
  149. position: relative;
  150. margin: 20upx 30upx 10upx;
  151. .goods-staus{
  152. width: 100%;
  153. height: 100%;
  154. position: absolute;
  155. z-index: 10000;
  156. background: url(../../static/yxt.png) no-repeat center center;
  157. background-size: 100% 100%;
  158. left: 0;
  159. top: 0;
  160. }
  161. }
  162. .goods-name{
  163. padding:0 40upx;
  164. margin: 20upx 0;
  165. display: flex;
  166. align-items: center;
  167. justify-content: space-between;
  168. >view{
  169. &:first-child{
  170. width: 60%;
  171. font-weight: bold;
  172. font-size: 30upx;
  173. }
  174. &:last-child{
  175. display: flex;
  176. align-items: center;
  177. text{
  178. color: #d42a26;
  179. font-size: 36upx;
  180. margin-right: 6upx;
  181. font-weight: bold;
  182. }
  183. }
  184. }
  185. }
  186. .goods-price{
  187. display: flex;
  188. align-items: center;
  189. justify-content: space-between;
  190. padding:0 40upx;
  191. >view{
  192. &:first-child{
  193. font-size: 22upx;
  194. text{
  195. color: #999;
  196. font-size: 24upx;
  197. margin-right: 6upx;
  198. }
  199. }
  200. }
  201. }
  202. .goods-goldLimit{
  203. padding: 10upx 40upx;
  204. color: #F0AD4E;
  205. font-size: 24rpx;
  206. text-align: right;
  207. text{
  208. color: red;
  209. }
  210. }
  211. }
  212. .goods-attr{
  213. margin: 20upx 0;
  214. background: #FFFFFF;
  215. padding: 20upx 40upx;
  216. box-shadow: 1px 1px 3px #eee;
  217. > view{
  218. display: flex;
  219. align-items: center;
  220. >view{
  221. padding: 10upx 0;
  222. &:first-child{
  223. padding-right: 15upx;
  224. color: #666;
  225. }
  226. }
  227. }
  228. }
  229. .goods-content{
  230. background: #F8F8F8;
  231. padding: 20upx;
  232. box-shadow: 1px 1px 3px #eee;
  233. min-height: 50vh;
  234. }
  235. .bottom-btns{
  236. background: #FFFFFF;
  237. display: flex;
  238. align-items: center;
  239. justify-content: space-around;
  240. padding: 30upx 100upx;
  241. >view{
  242. width: 50%;
  243. }
  244. }
  245. }
  246. </style>