goodsDetail.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  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" :dragPic="dragPic"></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. dragPic: '/static/cart.png', // 购物车图标
  82. };
  83. },
  84. onLoad(opts) {
  85. console.log(opts)
  86. this.id = opts.id
  87. this.goldLimit = opts.goldLimit
  88. this.getDetail()
  89. },
  90. methods: {
  91. // 查详情
  92. getDetail(){
  93. getGoodsDetail({id:this.id}).then(res => {
  94. console.log(res)
  95. if(res.status == 200){
  96. this.goodContent = res.data
  97. let arr=res.data.images.split(',')
  98. arr.map(item => {
  99. this.imageList.push({image:item})
  100. })
  101. }
  102. })
  103. },
  104. // 加入购物车
  105. addCart(){
  106. let _this = this
  107. let item = this.goodContent
  108. this.$bindClick(function(){
  109. uni.$emit("addCart",{goodsNo:item.goodsNo,buyQty:_this.nums})
  110. })
  111. },
  112. // 立即下单
  113. toOrder(){
  114. // console.log(this.goodContent,this.id,'pppppppp')
  115. if(this.goodContent.sellGold * this.nums >= this.goldLimit){
  116. this.$u.vuex("vuex_toOrderList",[{id:this.id,buyQty:this.nums,goodsNo:this.goodContent.goodsNo,goods:this.goodContent}])
  117. uni.redirectTo({
  118. url:"/pages/toOrder/index"
  119. })
  120. }else{
  121. uni.showToast({
  122. icon:"none",
  123. title:"此商品需要满" +this.goldLimit+ "乐豆才可购买"
  124. })
  125. }
  126. }
  127. },
  128. }
  129. </script>
  130. <style lang="scss">
  131. page{
  132. height: 100%;
  133. }
  134. .goods-detail{
  135. width: 100%;
  136. height: 100%;
  137. display: flex;
  138. flex-direction: column;
  139. > view{
  140. &:first-child{
  141. flex-grow: 1;
  142. overflow: auto;
  143. }
  144. }
  145. .goods-head{
  146. background: #FFFFFF;
  147. box-shadow: 1px 1px 3px #eee;
  148. padding: 10upx 0;
  149. .goods-imgs{
  150. position: relative;
  151. margin: 20upx 30upx 10upx;
  152. .goods-staus{
  153. width: 100%;
  154. height: 100%;
  155. position: absolute;
  156. z-index: 10000;
  157. background: url(../../static/yxt.png) no-repeat center center;
  158. background-size: 100% 100%;
  159. left: 0;
  160. top: 0;
  161. }
  162. }
  163. .goods-name{
  164. padding:0 40upx;
  165. margin: 20upx 0;
  166. display: flex;
  167. align-items: center;
  168. justify-content: space-between;
  169. >view{
  170. &:first-child{
  171. width: 60%;
  172. font-weight: bold;
  173. font-size: 30upx;
  174. }
  175. &:last-child{
  176. display: flex;
  177. align-items: center;
  178. text{
  179. color: #d42a26;
  180. font-size: 36upx;
  181. margin-right: 6upx;
  182. font-weight: bold;
  183. }
  184. }
  185. }
  186. }
  187. .goods-price{
  188. display: flex;
  189. align-items: center;
  190. justify-content: space-between;
  191. padding:0 40upx;
  192. >view{
  193. &:first-child{
  194. font-size: 22upx;
  195. text{
  196. color: #999;
  197. font-size: 24upx;
  198. margin-right: 6upx;
  199. }
  200. }
  201. }
  202. }
  203. .goods-goldLimit{
  204. padding: 10upx 40upx;
  205. color: #F0AD4E;
  206. font-size: 24rpx;
  207. text-align: right;
  208. text{
  209. color: red;
  210. }
  211. }
  212. }
  213. .goods-attr{
  214. margin: 20upx 0;
  215. background: #FFFFFF;
  216. padding: 20upx 40upx;
  217. box-shadow: 1px 1px 3px #eee;
  218. > view{
  219. display: flex;
  220. align-items: center;
  221. >view{
  222. padding: 10upx 0;
  223. &:first-child{
  224. padding-right: 15upx;
  225. color: #666;
  226. }
  227. }
  228. }
  229. }
  230. .goods-content{
  231. background: #F8F8F8;
  232. padding: 20upx;
  233. box-shadow: 1px 1px 3px #eee;
  234. min-height: 50vh;
  235. }
  236. .bottom-btns{
  237. background: #FFFFFF;
  238. display: flex;
  239. align-items: center;
  240. justify-content: space-around;
  241. padding: 30upx 100upx;
  242. >view{
  243. width: 50%;
  244. }
  245. }
  246. }
  247. </style>