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

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