时空网前端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

277 lines
7.1 KiB

  1. <template>
  2. <view>
  3. <!-- 商品图片轮播 -->
  4. <swiper :current="current" :indicator-dots="true" :circular="true" class="swiper-box">
  5. <swiper-item v-for="item in goods_detail.banners" :key="item.id">
  6. <image :src="item.cover" style="width: 100%; height: 100%;"></image>
  7. <!-- <image :src="item.cover" mode="aspectFit"></image> -->
  8. </swiper-item>
  9. </swiper>
  10. <!-- 商品主要信息 -->
  11. <view class="head-info">
  12. <view class="lf-font-40">{{ goods_detail.name }}</view>
  13. <view class="lf-row-between lf-font-24 lf-m-t-30 lf-p-b-20">
  14. <view class="lf-flex price">
  15. <view>¥{{ goods_detail.specs[0].selling_price }}</view>
  16. <view>¥{{ goods_detail.specs[0].original_price }}</view>
  17. <view v-if="goods_detail.specs[0].cost">{{ goods_detail.specs[0].cost }}</view>
  18. </view>
  19. <view>
  20. <view class="lf-color-gray">{{ goods_detail.specs[0].sold_stock_text }}</view>
  21. <view class="lf-color-primary">{{ goods_detail.specs[0].stock_text }}</view>
  22. </view>
  23. </view>
  24. <view class="label-box" v-if="goods_detail.tags && goods_detail.tags.length">
  25. <view class="label-item" v-for="(item, index) in goods_detail.tags" :key="index">{{ item }}</view>
  26. </view>
  27. </view>
  28. <!-- 地址信息 -->
  29. <view class="address-box">
  30. <view class="lf-font-32 lf-font-bold">适用门店</view>
  31. <view class="lf-m-t-20 lf-row-between">
  32. <view class="lf-flex">
  33. <image class="lf-fle shop-img" :src="goods_detail.store.cover"></image>
  34. <view class="lf-font-32 lf-m-l-20" style="max-width: 512rpx;">{{ goods_detail.store.name }}</view>
  35. </view>
  36. <view @click="makePhoneCall(goods_detail.store.tel)">
  37. <u-icon name="phone" color="#3A62FF" size="46"></u-icon>
  38. </view>
  39. </view>
  40. <view class="lf-flex lf-m-t-20" @click="openMap">
  41. <u-icon name="map-fill" size="60"></u-icon>
  42. <view class="lf-m-l-20 lf-font-32">{{ goods_detail.store.address }}</view>
  43. </view>
  44. </view>
  45. <!-- 商品详情 -->
  46. <view class="goods-detail">
  47. <view class="lf-font-32 lf-font-bold lf-m-b-20">商品详情</view>
  48. <image class="goods-img" :src="item" v-for="(item, index) in goods_detail.content" :key="index"></image>
  49. </view>
  50. <!-- 修饰专用 -->
  51. <view class="extra"></view>
  52. <!-- 吸底操作按钮 -->
  53. <view class="lf-row-between fixed-bottom">
  54. <view class="lf-flex lf-p-t-10 lf-p-b-10">
  55. <view class="lf-flex-column lf-row-center icon-item" @click="$url('/pages/index/index', {type: 'switch'})">
  56. <u-icon name="home" size="50"></u-icon>
  57. <view class="lf-m-t-1">首页</view>
  58. </view>
  59. <view class="lf-flex-column lf-row-center icon-item" @click="$url('/pages/contactService/index')">
  60. <u-icon name="server-fill" size="50"></u-icon>
  61. <view class="lf-m-t-1">客服</view>
  62. </view>
  63. <view class="lf-flex-column lf-row-center icon-item" @click="switchCollect">
  64. <u-icon name="heart-fill" size="50" color="#FF0000" v-if="is_collect"></u-icon>
  65. <u-icon name="heart" size="50" v-else></u-icon>
  66. <view class="lf-m-t-1">{{ is_collect ? '已收藏' : '收藏' }}</view>
  67. </view>
  68. <button class="lf-flex-column lf-row-center icon-item" open-type="share">
  69. <u-icon name="share" size="50"></u-icon>
  70. <view class="lf-m-t-1">分享</view>
  71. </button>
  72. </view>
  73. <button class="btn" @click="addCart">立即抢购</button>
  74. </view>
  75. </view>
  76. </template>
  77. <script>
  78. export default {
  79. data(){
  80. return {
  81. current: 0, // 轮播下标
  82. goods_id: 0,
  83. goods_detail: {},
  84. is_collect: 0 // 1为当前收藏商品了,0为否
  85. }
  86. },
  87. onLoad(options){
  88. this.goods_id = options.id;
  89. this.getGoodsDetail();
  90. },
  91. methods: {
  92. getGoodsDetail(){
  93. this.$http(this.API.API_GOODS_DETAIL, {goods_id: this.goods_id}).then(res => {
  94. console.log("res", res);
  95. this.goods_detail = res.data;
  96. this.is_collect = Boolean(res.data.user.is_collect);
  97. })
  98. },
  99. // 切换商品收藏
  100. switchCollect(){
  101. this.$http(this.API.API_COLLECT_DEAL, {goods_id: this.goods_id}).then(res => {
  102. console.log("res", res);
  103. this.is_collect = Boolean(res.data.user.is_collect);
  104. })
  105. },
  106. // 拨打电话
  107. makePhoneCall(phoneStr){
  108. uni.makePhoneCall({
  109. phoneNumber: String(phoneStr)
  110. })
  111. },
  112. // 打开地图
  113. openMap(){
  114. return;
  115. uni.openLocation({
  116. longitude: 108.36637,
  117. latitude: 22.817746,
  118. scale: 18
  119. })
  120. },
  121. // 立即抢购加入购物车
  122. addCart(){
  123. // this.$http(this.API.).then(res => {
  124. // })
  125. }
  126. },
  127. onShareAppMessage(){
  128. let goods = this.goods_detail;
  129. let title = goods.name;
  130. let imageUrl = goods.cover;
  131. let path = '/pages/route/index';
  132. return {
  133. title,
  134. path,
  135. imageUrl
  136. }
  137. }
  138. }
  139. </script>
  140. <style>
  141. page{
  142. background-color: #f5f5f5;
  143. overflow-x: hidden;
  144. }
  145. </style>
  146. <style lang="scss" scoped="scoped">
  147. .swiper-box{
  148. width: 750rpx;
  149. height: 520rpx;
  150. background-color: #FFFFFF;
  151. }
  152. .head-info{
  153. width: 750rpx;
  154. height: auto;
  155. box-sizing: border-box;
  156. padding: 0 32rpx;
  157. padding-top: 20rpx;
  158. background-color: #FFFFFF;
  159. .price>view:nth-of-type(1){
  160. color: #FF0000;
  161. font-size: 40rpx;
  162. margin-right: 22rpx;
  163. }
  164. .price>view:nth-of-type(2){
  165. text-decoration: line-through;
  166. color: #777777;
  167. margin-right: 22rpx;
  168. }
  169. .price>view:nth-of-type(3){
  170. width: max-content;
  171. padding: 0 18rpx;
  172. height: 46rpx;
  173. background-color: #FE9903;
  174. border-radius: 10rpx;
  175. display: flex;
  176. justify-content: center;
  177. align-items: center;
  178. color: #FFFFFF;
  179. }
  180. .label-box{
  181. min-height: 130rpx;
  182. width: 100%;
  183. border-top: 1rpx solid #E5E5E5;
  184. display: flex;
  185. flex-wrap: wrap;
  186. padding: 30rpx 0 10rpx 0;
  187. .label-item{
  188. width: 156rpx;
  189. height: 70rpx;
  190. border-radius: 10rpx;
  191. border: 2rpx solid #FE9903;
  192. display: flex;
  193. justify-content: center;
  194. align-items: center;
  195. font-size: 28rpx;
  196. color: #FE9903;
  197. margin-right: 20rpx;
  198. margin-bottom: 20rpx;
  199. }
  200. }
  201. }
  202. .address-box{
  203. width: 750rpx;
  204. height: auto;
  205. box-sizing: border-box;
  206. background-color: #FFFFFF;
  207. padding: 32rpx;
  208. margin-top: 20rpx;
  209. .shop-img{
  210. width: 60rpx;
  211. height: 60rpx;
  212. border-radius: 10rpx;
  213. background-color: #EEEEEE;
  214. }
  215. }
  216. .goods-detail{
  217. width: 750rpx;
  218. height: auto;
  219. background-color: #FFFFFF;
  220. padding: 32rpx;
  221. box-sizing: border-box;
  222. margin-top: 20rpx;
  223. .goods-img{
  224. width: 100%;
  225. }
  226. }
  227. .extra{
  228. width: 100%;
  229. height: 120rpx;
  230. padding-bottom: constant(safe-area-inset-bottom);
  231. padding-bottom: env(safe-area-inset-bottom);
  232. box-sizing: content-box;
  233. }
  234. .fixed-bottom{
  235. position: fixed;
  236. bottom: 0;
  237. left: 0;
  238. background-color: #FFFFFF;
  239. width: 100%;
  240. height: auto;
  241. padding: 0 32rpx;
  242. border-top: 1rpx solid #e5e5e5;
  243. padding-bottom: constant(safe-area-inset-bottom);
  244. padding-bottom: env(safe-area-inset-bottom);
  245. .icon-item{
  246. padding: 0 14rpx;
  247. margin-right: 16rpx;
  248. background-color: transparent;
  249. margin: 0;
  250. line-height: initial;
  251. font-size: 28rpx;
  252. font-weight: inherit;
  253. &:first-child{
  254. padding-left: 0;
  255. }
  256. }
  257. .btn{
  258. margin: 0;
  259. padding: 0;
  260. width: 208rpx;
  261. height: 80rpx;
  262. background-color: #FE9903;
  263. color: #FFFFFF;
  264. line-height: 80rpx;
  265. font-size: 32rpx;
  266. border-radius: 42rpx;
  267. }
  268. }
  269. </style>