在这里将不会自己写,会放在组件里面写。

    1. <template>
    2. <view class='goods_detail'>
    3. <swiper indicator-dots>
    4. <swiper-item v-for="(item,index) in swipers" :key="index">
    5. <image :src='item.src'></image>
    6. </swiper-item>
    7. </swiper>
    8. <view class='box1'>
    9. <view class='price'>
    10. <text>¥{{info.sell_price}}</text>
    11. <text>¥{{info.market_price}}</text>
    12. <view class='goods_name'>{{info.title}}</view>
    13. </view>
    14. </view>
    15. <view class='line'></view>
    16. <view class='box2'>
    17. <view>货号:{{info.goods_no}}</view>
    18. <view>库存:{{info.stock_quantity}}</view>
    19. </view>
    20. <view class='line'></view>
    21. <view class='box3'>
    22. <view class='tit'>详情介绍</view>
    23. <view class='content'><rich-text :nodes="content"></rich-text></view>
    24. </view>
    25. <view class='goods_nav'>
    26. <uni-goods-nav :fill="true" :options="options" :buttonGroup="buttonGroup" @click="onClick" @buttonClick="buttonClick" />
    27. </view>
    28. </view>
    29. </template>
    30. <script>
    31. import uniGoodsNav from '@/components/uni-goods-nav/uni-goods-nav.vue'
    32. export default {
    33. data() {
    34. return {
    35. id: 0,
    36. swipers: [],
    37. info:{},
    38. content:null,
    39. options: [{
    40. icon: 'headphones',
    41. text: '客服'
    42. }, {
    43. icon: 'shop',
    44. text: '店铺',
    45. info: 0,
    46. infoBackgroundColor:'#007aff',
    47. infoColor:"red"
    48. }, {
    49. icon: 'cart',
    50. text: '购物车',
    51. info: 2
    52. }],
    53. buttonGroup: [{
    54. text: '加入购物车',
    55. backgroundColor: '#ff0000',
    56. color: '#fff'
    57. },
    58. {
    59. text: '立即购买',
    60. backgroundColor: '#ffa200',
    61. color: '#fff'
    62. }
    63. ]
    64. }
    65. },
    66. methods: {
    67. //获取轮播图的数据,首先会有函数
    68. async getSwipers() {
    69. const res = await this.$myRequest({
    70. url: '/api/getthumimages/' + this.id
    71. })
    72. this.swipers = res.data.message
    73. },
    74. async getDetailInfo(){
    75. const res = await this.$myRequest({
    76. url:'/api/goods/getinfo/'+this.id
    77. })
    78. this.info = res.data.message[0]
    79. },
    80. async getDetailContent(){
    81. const res= await this.$myRequest({
    82. url:'/api/goods/getdesc/'+this.id
    83. })
    84. this.content = res.data.message[0].content
    85. },
    86. onClick (e) {
    87. uni.showToast({
    88. title: `点击${e.content.text}`,
    89. icon: 'none'
    90. })
    91. },
    92. buttonClick (e) {
    93. console.log(e)
    94. this.options[2].info++
    95. }
    96. },
    97. onLoad(options) {
    98. // console.log(options)
    99. this.id = options.id
    100. this.getSwipers()
    101. this.getDetailInfo()
    102. this.getDetailContent()
    103. },
    104. components: {uniGoodsNav}
    105. }
    106. </script>
    107. <style lang="scss">
    108. .goods_detail {
    109. swiper {
    110. height: 750rpx;
    111. image {
    112. width: 100%;
    113. height: 100%;
    114. }
    115. }
    116. .box1 {
    117. padding: 10px;
    118. .price {
    119. font-size: 35rpx;
    120. color: $shop-color;
    121. line-height: 80rpx;
    122. text:nth-child(2) {
    123. color: #ccc;
    124. font-size: 28rpx;
    125. text-decoration: line-through;
    126. margin-left: 20rpx;
    127. }
    128. }
    129. .goods_name {
    130. font-size: 35rpx;
    131. line-height: 60rpx;
    132. color:#333;
    133. }
    134. }
    135. .box2{
    136. padding:10rpx 20rpx;
    137. font-size: 35rpx;
    138. line-height: 60rpx;
    139. }
    140. .box3{
    141. padding-bottom: 50px;
    142. .tit{
    143. font-size: 40rpx;
    144. padding-left: 10px;
    145. border-bottom: 1px solid #eee;
    146. line-height: 70rpx;
    147. }
    148. .content{
    149. padding:10px;
    150. font-size:28rpx;
    151. color:#333;
    152. line-height: 50rpx;
    153. }
    154. }
    155. }
    156. .goods_nav{
    157. position: fixed;
    158. bottom:0;
    159. width:750rpx;
    160. }
    161. .line{
    162. height:10rpx;
    163. width:750rpx;
    164. background: #eee;
    165. }
    166. </style>

    image.png