金诚优选前端代码
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.

573 lines
15 KiB

  1. <template>
  2. <view>
  3. <lf-nav :spreadOut="false" :showIcon="true" bgColor="transparent!important"></lf-nav>
  4. <skeleton :loading="skeletonLoading" :row="12" :showAvatar="false" :showTitle="true">
  5. <block>
  6. <!-- 商品图片轮播 -->
  7. <swiper :current="current" :indicator-dots="2 > 1 ? false : true" :circular="true" class="swiper-box" indicator-active-color="#1998FE">
  8. <swiper-item v-for="(item, index) in pictures" :key="index">
  9. <image mode="aspectFill" :src="item" style="width: 100%; height: 100%;" @click="lookImg(index)"></image>
  10. </swiper-item>
  11. </swiper>
  12. <!-- 商品主要信息 -->
  13. <view class="head-info">
  14. <view class="lf-row-between">
  15. <lf-price :iftext="false" :price="111"></lf-price>
  16. <text class="lf-iconfont icon-fenxiang lf-font-40" @click="shareGraphic()"></text>
  17. </view>
  18. <view class="lf-row-between lf-font-24 lf-m-t-20 lf-p-b-20">
  19. <view class="lf-font-bold lf-font-32 lf-color-222">颐莲喷雾 500ml</view>
  20. </view>
  21. <view class="lf-row-between lf-font-24 lf-p-b-30">
  22. <view class="lf-font-28 lf-color-777">门店自提</view>
  23. </view>
  24. </view>
  25. <self-line></self-line>
  26. <view class="bg-white">
  27. <view class="cu-bar padding-lr">
  28. <view class="lf-flex">
  29. <text class="lf-color-777 lf-font-28">优惠</text>
  30. <view v-if="orderDetails.coupon == ''">
  31. <text class="lf-color-price lf-font-28 lf-m-l-10" v-for="(item,index) of orderDetails.coupon">{{item.tag}}</text>
  32. </view>
  33. <view v-else>
  34. <text class="lf-color-222 lf-font-26 lf-m-l-30">化妆品教师节满1200减200</text>
  35. </view>
  36. </view>
  37. <view>
  38. <text class="lf-font-24 lf-color-777 lf-iconfont icon-xiangyou"></text>
  39. </view>
  40. </view>
  41. </view>
  42. <self-line></self-line>
  43. <view class="bg-white">
  44. <view class="cu-bar padding-lr">
  45. <view class="lf-flex">
  46. <text class="lf-color-777 lf-font-28">服务</text>
  47. <view style="width: 600rpx;flex-wrap: wrap;display: flex;margin-top: 32rpx;">
  48. <view class="lf-m-l-30" v-for="i of 5">
  49. <text class="lf-iconfont icon-xuanzhong lf-font-30" style="color: #15716E;"></text>
  50. <text class="lf-m-l-10 lf-font-26 lf-color-black">正品保障</text>
  51. </view>
  52. </view>
  53. </view>
  54. <view>
  55. <text class="lf-font-24 lf-color-777 lf-iconfont icon-xiangyou"></text>
  56. </view>
  57. </view>
  58. </view>
  59. <view class="bg-white">
  60. <view class="cu-bar padding-lr">
  61. <view class="lf-flex">
  62. <text class="lf-color-777 lf-font-28">已选</text>
  63. <text class="lf-color-222 lf-font-26 lf-m-l-30">已选500ml x1</text>
  64. </view>
  65. <view>
  66. <text class="lf-font-24 lf-color-777 lf-iconfont icon-xiangyou"></text>
  67. </view>
  68. </view>
  69. </view>
  70. <self-line></self-line>
  71. <view>
  72. <view class="user-top">
  73. <view class="lf-row-between lf-w-100">
  74. <view class="lf-flex">
  75. <view class="tag-father">
  76. <image src="https://hainan.lanzulive.com/storage/images/v2-deb89623e0ee2a2dad34bcded6dfd1ed_1440w.png" mode="aspectFill" class="head-img"></image>
  77. </view>
  78. <view class="lf-flex-column lf-m-l-20">
  79. <text class="lf-font-28 lf-color-black lf-font-bold">颐莲官方店</text>
  80. <view class="lf-font-24 lf-color-777"><u-icon name="map" class="lf-m-r-10"></u-icon>L2</view>
  81. </view>
  82. </view>
  83. <view>
  84. <button class="head-btn"><u-icon name="chat" class="lf-m-r-10"></u-icon></button>
  85. </view>
  86. </view>
  87. </view>
  88. <scroll-view class="scroll-view" :scroll-x="true">
  89. <view class="scroll-content">
  90. <view class="goods-item" v-for="(item, index) in 5" :key="index">
  91. <image class="goods-img"></image>
  92. <view class="goods-info">
  93. <view class="lf-line-1">猪大肠卖咯 5毛钱一斤咯</view>
  94. <view>0.5</view>
  95. </view>
  96. </view>
  97. <view class="goods-item">
  98. <view class="more-box">
  99. <text>查看更多</text>
  100. <text class="lf-iconfont icon--2 lf-text-vertical"></text>
  101. </view>
  102. </view>
  103. </view>
  104. </scroll-view>
  105. </view>
  106. <!-- 商品详情 -->
  107. <view class="goods-detail">
  108. <view class="lf-font-32 lf-font-bold lf-m-b-20">商品详情</view>
  109. <rich-text :nodes="formatRichText('商品详情商品详情商品详情商品详情商品详情商品详情商品详情商品详情商品详情商品详情商品详情商品详情')"></rich-text>
  110. <!-- <image class="goods-img" :src="item" v-for="(item, index) in goods_detail.content" :key="index" v-if="goods_detail.content_type == 'img'"></image> -->
  111. </view>
  112. <!-- 修饰专用 -->
  113. <view class="extra"></view>
  114. <!-- 吸底操作按钮 -->
  115. <view class="lf-row-between fixed-bottom">
  116. <view class="lf-flex lf-p-t-10 lf-p-b-10">
  117. <view class="lf-flex-column lf-row-center icon-item" open-type="contact">
  118. <text class="lf-iconfont icon-shoucang icon-img"></text>
  119. <view class="lf-m-t-1">客服</view>
  120. </view>
  121. <view class="lf-flex-column lf-row-center icon-item" @click="switchCollect">
  122. <text class="lf-iconfont icon-shoucang icon-img" v-if="is_collect"></text>
  123. <text class="lf-iconfont icon-shoucang icon-img" v-else></text>
  124. <view class="lf-m-t-1">{{ is_collect ? '已收藏' : '收藏' }}</view>
  125. </view>
  126. <button class="lf-flex-column lf-row-center icon-item">
  127. <text class="lf-iconfont icon-shoucang icon-img"></text>
  128. <view class="lf-m-t-1">购物车</view>
  129. </button>
  130. </view>
  131. <view class="lf-flex">
  132. <button class="btn1" @click="toAddOrder">加入购物车</button>
  133. <button class="btn lf-m-l-15" @click="toAddOrder">立即购买</button>
  134. </view>
  135. </view>
  136. <!-- 回到顶部 -->
  137. <!-- <u-back-top :scroll-top="pageScrollTop" :custom-style="{background: 'rgba(51, 51 51, 0.3)'}" :icon-style="{color: '#ffffff'}"></u-back-top> -->
  138. <u-back-top :scroll-top="pageScrollTop" :custom-style="{background: 'rgba(51, 51 51, 0.3)'}"></u-back-top>
  139. </block>
  140. </skeleton>
  141. </view>
  142. </template>
  143. <script>
  144. export default {
  145. data(){
  146. return {
  147. current: 0, // 轮播下标
  148. goods_id: 0,
  149. goods_detail: {},
  150. is_collect: false, // 1为当前收藏商品了,0为否
  151. skeletonLoading: false,
  152. pictures: [
  153. 'https://hainan.lanzulive.com/storage/images/v2-deb89623e0ee2a2dad34bcded6dfd1ed_1440w.png',
  154. 'https://hainan.lanzulive.com/storage/images/v2-deb89623e0ee2a2dad34bcded6dfd1ed_1440w.png',
  155. 'https://hainan.lanzulive.com/storage/images/v2-deb89623e0ee2a2dad34bcded6dfd1ed_1440w.png'
  156. ]
  157. }
  158. },
  159. onLoad(options){
  160. this.goods_id = options.goods_id;
  161. console.log('商品',this.goods_id)
  162. // this.getGoodsDetail();
  163. },
  164. computed: {
  165. isRight() {
  166. return function(val) {
  167. return this.$shared.isRight(val);
  168. }
  169. }
  170. },
  171. methods: {
  172. shareGraphic(){
  173. this.getCreateShareImg();
  174. },
  175. //请求h5的图片接口
  176. getCreateShareImg(){
  177. wx.showLoading({
  178. title:"生成中",
  179. mask:true
  180. })
  181. let origin = window.location.origin;
  182. let share_url = origin+'/pages/store/detail/detail';
  183. this.$http.get({
  184. api:'api/distribution/createH5ShareImg',
  185. data:{
  186. goods_id:this.id,
  187. share_url:share_url
  188. }
  189. }).then(res=>{
  190. res = res.data;
  191. if(res.status){
  192. this.qr_code_image = res.data.image;
  193. if(this.qr_code_image){
  194. this.share_gaphic =!this.share_gaphic;
  195. this.is_toggle_share = false;
  196. }
  197. } else{
  198. wx.showModal({
  199. content: res.message || '请求失败,请重试',
  200. showCancel: false
  201. });
  202. }
  203. wx.hideLoading()
  204. }).catch(rej=>{
  205. wx.hideLoading()
  206. wx.showModal({
  207. content: rej.message || '内部错误,请重试',
  208. showCancel: false
  209. });
  210. })
  211. },
  212. getGoodsDetail(){
  213. this.$http(this.API.API_ADVICEDETAILS, {id: this.goods_id}).then(res => {
  214. this.skeletonLoading = false;
  215. this.goods_detail = res.data;
  216. this.is_collect = Boolean(res.data.is_collect) || false;
  217. }).catch(err => {
  218. this.skeletonLoading = false;
  219. setTimeout(() => {
  220. this.$toBack();
  221. }, 1000);
  222. })
  223. },
  224. // 切换商品收藏
  225. switchCollect(){
  226. let userInfo = uni.getStorageSync('userinfo') || {};
  227. if(!userInfo.id || !userInfo.nickname || !userInfo.avatar){
  228. this.$url('/pages/login/index?type=userinfo');
  229. return;
  230. }
  231. if(this.is_collect) {
  232. this.$http(this.API.API_DELCOLLECT, {agent_product_id:this.goods_id}).then(res => {
  233. this.$msg('取消收藏成功!')
  234. this.is_collect = false
  235. console.log(res)
  236. })
  237. }else {
  238. this.$http(this.API.API_ADDCOLLECT, {agent_product_id:this.goods_id}).then(res => {
  239. this.$msg('添加收藏成功!')
  240. this.is_collect = true
  241. console.log(res)
  242. })
  243. }
  244. },
  245. // 拨打电话
  246. makePhoneCall(phoneStr){
  247. uni.makePhoneCall({
  248. phoneNumber: String(phoneStr)
  249. })
  250. },
  251. // 打开地图
  252. openMap(){
  253. let { address, lat, lng } = this.goods_detail?.store || {};
  254. uni.openLocation({
  255. longitude: Number(lat),
  256. latitude: Number(lng),
  257. scale: 20,
  258. name: address
  259. });
  260. },
  261. // 跳转到确认下单页面
  262. toAddOrder(){
  263. let goods_id = this.goods_detail.id;
  264. this.$url('/pages/order/confirm_order?goods_id='+ goods_id);
  265. },
  266. // 预览图片
  267. lookImg(index){
  268. this.$u.throttle(() => {
  269. let goods_banner = this.goods_detail.banners || [];
  270. let banners = goods_banner.map(item => item.cover);
  271. uni.previewImage({
  272. urls: banners,
  273. current: index
  274. })
  275. }, 200);
  276. },
  277. // 富文本处理
  278. formatRichText(richText){
  279. if(richText != null){
  280. let newRichText= richText.replace(/<img[^>]*>/gi, function(match, capture){
  281. match = match.replace(/style="[^"]+"/gi, '').replace(/style='[^']+'/gi, '');
  282. match = match.replace(/width="[^"]+"/gi, '').replace(/width='[^']+'/gi, '');
  283. match = match.replace(/height="[^"]+"/gi, '').replace(/height='[^']+'/gi, '');
  284. return match;
  285. });
  286. newRichText = newRichText.replace(/style="[^"]+"/gi,function(match, capture){
  287. match = match.replace(/width:[^;]+;/gi, 'width:100%;').replace(/width:[^;]+;/gi, 'width:100%;');
  288. return match;
  289. });
  290. newRichText = newRichText.replace(/<br[^>]*\/>/gi, '');
  291. newRichText = newRichText.replace(/\<img/gi, '<img style="width:100%;height:auto;display:block;margin:10px 0;"');
  292. return newRichText;
  293. }else{
  294. return null;
  295. }
  296. }
  297. },
  298. onShareAppMessage(){
  299. let goods = this.goods_detail;
  300. let title = goods.name;
  301. let imageUrl = goods.share_cover || goods.cover;
  302. let path = '/pages/route/index?route=goods_detail&id='+ goods.id;
  303. return {
  304. title,
  305. path,
  306. imageUrl
  307. }
  308. }
  309. }
  310. </script>
  311. <style>
  312. page{
  313. background-color: #f5f5f5;
  314. overflow-x: hidden;
  315. }
  316. </style>
  317. <style lang="scss" scoped="scoped">
  318. //商品上去scrollview部分
  319. .scroll-view{
  320. height: 310rpx;
  321. width: 100%;
  322. // margin-top: 20rpx;
  323. padding: 0 30rpx 30rpx 30rpx;
  324. background-color: white;
  325. .scroll-content{
  326. display: flex;
  327. width: 100%;
  328. .goods-item{
  329. margin-right: 15rpx;
  330. width: 180rpx;
  331. }
  332. .goods-img{
  333. width: 180rpx;
  334. height: 180rpx;
  335. background-color: #EEEEEE;
  336. }
  337. .goods-info{
  338. text-align: center;
  339. color: #222222;
  340. &>view:nth-child(1n){
  341. font-size: 24rpx;
  342. }
  343. &>view:nth-child(2n){
  344. font-size: 28rpx;
  345. font-weight: bold;
  346. text-align: left;
  347. color: #F63434;
  348. }
  349. }
  350. .more-box{
  351. width: 180rpx;
  352. height: 180rpx;
  353. background-color: #EEEEEE;
  354. text-align: center;
  355. line-height: 180rpx;
  356. font-size: 24rpx;
  357. }
  358. }
  359. }
  360. //scrollview结束
  361. .tag-father {
  362. position: relative;
  363. }
  364. .head-tag {
  365. color: white;
  366. display: flex;
  367. align-items: center;
  368. justify-content: center;
  369. text-align: center;
  370. font-size: 24rpx;
  371. width: 36rpx;
  372. height: 36rpx;
  373. border-radius: 50%;
  374. background-color: #15716E;
  375. border: 1rpx solid #FFFFFF;
  376. position: absolute;
  377. left: 76rpx;
  378. top: 86rpx;
  379. z-index: 99;
  380. }
  381. .qzone-img {
  382. width: 220rpx;
  383. height: 220rpx;
  384. border-radius: 10rpx;
  385. margin-right: 12rpx;
  386. &:nth-child(3n) {
  387. margin-right: 0;
  388. }
  389. &:nth-child(n + 4) {
  390. margin-top: 12rpx;
  391. }
  392. }
  393. .user-top {
  394. background-color: #F3F8F8;
  395. padding: 30rpx;
  396. display: flex;
  397. align-items: center;
  398. background-color: white;
  399. }
  400. .head-img {
  401. width: 80rpx;
  402. height: 80rpx;
  403. border-radius: 50%;
  404. }
  405. .head-btn {
  406. display: flex;
  407. width: max-content;
  408. height: 45rpx;
  409. background: white;
  410. border: 2rpx solid #15716E;
  411. align-items: center;
  412. font-size: 22rpx;
  413. color: #15716E;
  414. justify-content: space-between;
  415. border-radius: 35rpx;
  416. padding: 10rpx!important;
  417. }
  418. .swiper-box{
  419. width: 750rpx;
  420. height: 750rpx;
  421. background-color: #FFFFFF;
  422. }
  423. .head-info{
  424. width: 750rpx;
  425. height: auto;
  426. box-sizing: border-box;
  427. padding: 0 32rpx;
  428. padding-top: 20rpx;
  429. background-color: #FFFFFF;
  430. // .price>view:nth-of-type(1){
  431. // color: #FF0000;
  432. // margin-right: 22rpx;
  433. // font-weight: bold;
  434. // }
  435. .price>view:nth-of-type(1){
  436. text-decoration: line-through;
  437. color: #777777;
  438. margin-right: 22rpx;
  439. }
  440. .price>view:nth-of-type(2){
  441. width: max-content;
  442. padding: 0 18rpx;
  443. height: 46rpx;
  444. background-color: #1998FE;
  445. border-radius: 10rpx;
  446. display: flex;
  447. justify-content: center;
  448. align-items: center;
  449. color: #FFFFFF;
  450. }
  451. .label-box{
  452. min-height: 130rpx;
  453. width: 100%;
  454. border-top: 1rpx solid #E5E5E5;
  455. display: flex;
  456. flex-wrap: wrap;
  457. padding: 30rpx 0 10rpx 0;
  458. .label-item{
  459. width: max-content;
  460. padding: 20rpx;
  461. height: 70rpx;
  462. border-radius: 10rpx;
  463. border: 2rpx solid #1998FE;
  464. display: flex;
  465. justify-content: center;
  466. align-items: center;
  467. font-size: 28rpx;
  468. color: #1998FE;
  469. margin-right: 20rpx;
  470. margin-bottom: 20rpx;
  471. }
  472. }
  473. }
  474. .address-box{
  475. width: 750rpx;
  476. height: auto;
  477. box-sizing: border-box;
  478. background-color: #FFFFFF;
  479. padding: 32rpx;
  480. margin-top: 20rpx;
  481. .shop-img{
  482. width: 60rpx;
  483. height: 60rpx;
  484. border-radius: 50%;
  485. }
  486. }
  487. .goods-detail{
  488. width: 750rpx;
  489. height: auto;
  490. background-color: #FFFFFF;
  491. padding: 32rpx;
  492. box-sizing: border-box;
  493. margin-top: 20rpx;
  494. .goods-img{
  495. width: 100%;
  496. }
  497. }
  498. .extra{
  499. width: 100%;
  500. height: 110rpx;
  501. padding-bottom: constant(safe-area-inset-bottom);
  502. padding-bottom: env(safe-area-inset-bottom);
  503. box-sizing: content-box;
  504. }
  505. .fixed-bottom{
  506. position: fixed;
  507. bottom: 0;
  508. left: 0;
  509. background-color: #FFFFFF;
  510. width: 100%;
  511. height: auto;
  512. padding: 0 32rpx;
  513. border-top: 1rpx solid #e5e5e5;
  514. padding-bottom: constant(safe-area-inset-bottom);
  515. padding-bottom: env(safe-area-inset-bottom);
  516. .icon-item{
  517. text-align: center;
  518. margin-right: 16rpx;
  519. background-color: transparent;
  520. margin: 0;
  521. line-height: initial;
  522. font-size: 28rpx;
  523. font-weight: inherit;
  524. margin-right: 10rpx;
  525. padding: 0;
  526. width: 88rpx;
  527. position: relative;
  528. &:first-child{
  529. padding-left: 0;
  530. }
  531. .icon-img{
  532. height: 50rpx;
  533. width: 50rpx;
  534. }
  535. }
  536. .btn1{
  537. margin: 0;
  538. width: max-content;
  539. height: 80rpx;
  540. background-color: rgba(21, 113, 110, 0.1);
  541. color: #15716E;
  542. line-height: 80rpx;
  543. font-size: 32rpx;
  544. padding: 0 20rpx;
  545. border-radius: 42rpx;
  546. font-size: 26rpx;
  547. border: 2rpx solid #15716E;
  548. }
  549. .btn{
  550. margin: 0;
  551. padding: 0 20rpx;
  552. width: max-content;
  553. height: 80rpx;
  554. background-color: #15716E;
  555. color: #FFFFFF;
  556. line-height: 80rpx;
  557. font-size: 26rpx;
  558. border-radius: 42rpx;
  559. }
  560. }
  561. </style>