时空网前端
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.2 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="toAddOrder">立即抢购</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. toAddOrder(){
  123. let goods_id = this.goods_detail.id;
  124. let goods_specs_id = this.goods_detail.specs[0].id
  125. this.$url('/pages/order/confirm-order?goods_id='+ goods_id +'&goods_specs_id='+ goods_specs_id);
  126. }
  127. },
  128. onShareAppMessage(){
  129. let goods = this.goods_detail;
  130. let title = goods.name;
  131. let imageUrl = goods.cover;
  132. let path = '/pages/route/index';
  133. return {
  134. title,
  135. path,
  136. imageUrl
  137. }
  138. }
  139. }
  140. </script>
  141. <style>
  142. page{
  143. background-color: #f5f5f5;
  144. overflow-x: hidden;
  145. }
  146. </style>
  147. <style lang="scss" scoped="scoped">
  148. .swiper-box{
  149. width: 750rpx;
  150. height: 520rpx;
  151. background-color: #FFFFFF;
  152. }
  153. .head-info{
  154. width: 750rpx;
  155. height: auto;
  156. box-sizing: border-box;
  157. padding: 0 32rpx;
  158. padding-top: 20rpx;
  159. background-color: #FFFFFF;
  160. .price>view:nth-of-type(1){
  161. color: #FF0000;
  162. font-size: 40rpx;
  163. margin-right: 22rpx;
  164. }
  165. .price>view:nth-of-type(2){
  166. text-decoration: line-through;
  167. color: #777777;
  168. margin-right: 22rpx;
  169. }
  170. .price>view:nth-of-type(3){
  171. width: max-content;
  172. padding: 0 18rpx;
  173. height: 46rpx;
  174. background-color: #FE9903;
  175. border-radius: 10rpx;
  176. display: flex;
  177. justify-content: center;
  178. align-items: center;
  179. color: #FFFFFF;
  180. }
  181. .label-box{
  182. min-height: 130rpx;
  183. width: 100%;
  184. border-top: 1rpx solid #E5E5E5;
  185. display: flex;
  186. flex-wrap: wrap;
  187. padding: 30rpx 0 10rpx 0;
  188. .label-item{
  189. width: 156rpx;
  190. height: 70rpx;
  191. border-radius: 10rpx;
  192. border: 2rpx solid #FE9903;
  193. display: flex;
  194. justify-content: center;
  195. align-items: center;
  196. font-size: 28rpx;
  197. color: #FE9903;
  198. margin-right: 20rpx;
  199. margin-bottom: 20rpx;
  200. }
  201. }
  202. }
  203. .address-box{
  204. width: 750rpx;
  205. height: auto;
  206. box-sizing: border-box;
  207. background-color: #FFFFFF;
  208. padding: 32rpx;
  209. margin-top: 20rpx;
  210. .shop-img{
  211. width: 60rpx;
  212. height: 60rpx;
  213. border-radius: 10rpx;
  214. background-color: #EEEEEE;
  215. }
  216. }
  217. .goods-detail{
  218. width: 750rpx;
  219. height: auto;
  220. background-color: #FFFFFF;
  221. padding: 32rpx;
  222. box-sizing: border-box;
  223. margin-top: 20rpx;
  224. .goods-img{
  225. width: 100%;
  226. }
  227. }
  228. .extra{
  229. width: 100%;
  230. height: 120rpx;
  231. padding-bottom: constant(safe-area-inset-bottom);
  232. padding-bottom: env(safe-area-inset-bottom);
  233. box-sizing: content-box;
  234. }
  235. .fixed-bottom{
  236. position: fixed;
  237. bottom: 0;
  238. left: 0;
  239. background-color: #FFFFFF;
  240. width: 100%;
  241. height: auto;
  242. padding: 0 32rpx;
  243. border-top: 1rpx solid #e5e5e5;
  244. padding-bottom: constant(safe-area-inset-bottom);
  245. padding-bottom: env(safe-area-inset-bottom);
  246. .icon-item{
  247. padding: 0 14rpx;
  248. margin-right: 16rpx;
  249. background-color: transparent;
  250. margin: 0;
  251. line-height: initial;
  252. font-size: 28rpx;
  253. font-weight: inherit;
  254. &:first-child{
  255. padding-left: 0;
  256. }
  257. }
  258. .btn{
  259. margin: 0;
  260. padding: 0;
  261. width: 208rpx;
  262. height: 80rpx;
  263. background-color: #FE9903;
  264. color: #FFFFFF;
  265. line-height: 80rpx;
  266. font-size: 32rpx;
  267. border-radius: 42rpx;
  268. }
  269. }
  270. </style>