时空网前端
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.

286 lines
7.5 KiB

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