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

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