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

1052 lines
28 KiB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
  1. <template>
  2. <view>
  3. <lf-nav title="商品详情" titleColor="#fff" :spreadOut="false" :showIcon="true" bgColor="transparent"></lf-nav>
  4. <skeleton :loading="skeletonLoading" :row="12" :showAvatar="false" :showTitle="true">
  5. <block>
  6. <!-- 商品图片轮播 -->
  7. <swiper :current="current" :indicator-dots="pictures.length > 1" :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. <view class="seckill-box" v-if="type == 'seckill'">
  11. <view>距离结束还剩余</view>
  12. <view v-if="$isRight(time)">
  13. <countdown-timer :time="time" :autoStart="true" @finish="dateFinish">
  14. <template v-slot="{day, hour, minute, second}">
  15. <view class="lf-flex">
  16. <view>{{ day }}</view>
  17. <view></view>
  18. <view>{{ hour >= 10 ? hour : "0" + hour }}</view>
  19. <view></view>
  20. <view>{{ minute >= 10 ? minute : "0" + minute }}</view>
  21. <view></view>
  22. <view>{{ second >= 10 ? second : "0" + second }}</view>
  23. <view></view>
  24. </view>
  25. </template>
  26. </countdown-timer>
  27. </view>
  28. </view>
  29. </swiper-item>
  30. </swiper>
  31. <!-- 商品主要信息 -->
  32. <view class="head-info">
  33. <view class="lf-row-between">
  34. <view v-if="type == 'point'">
  35. <text class="lf-font-48 lf-color-primary lf-font-bold">{{ goods_detail.redeem_point }}</text>
  36. <text class="lf-font-28 lf-color-777 lf-m-l-10">个兑换</text>
  37. </view>
  38. <lf-price :iftext="false" :price="goods_detail.sell_price || 0" v-else></lf-price>
  39. <text class="lf-iconfont icon-fenxiang lf-font-40" @click="shareGraphic()"></text>
  40. </view>
  41. <view class="lf-row-between lf-font-24 lf-m-t-20 lf-p-b-20">
  42. <view class="lf-font-bold lf-font-32 lf-color-222">{{ goods_detail.name }}</view>
  43. </view>
  44. <view class="lf-row-between lf-font-24 lf-p-b-30">
  45. <view class="lf-font-28 lf-color-777 lf-row-between">可自提/可邮寄</view>
  46. </view>
  47. </view>
  48. <!-- 商品优惠 -->
  49. <block v-if="coupons && coupons.length">
  50. <self-line></self-line>
  51. <view class="bg-white" >
  52. <view class="cu-bar padding-lr">
  53. <view class="lf-flex">
  54. <text class="lf-color-777 lf-font-28">优惠</text>
  55. <view style="width: 580rpx;">
  56. <view class="lf-color-222 lf-font-26 lf-m-l-30"
  57. v-for="(item, index) in coupons" :key="index">{{ item.title }}
  58. </view>
  59. </view>
  60. </view>
  61. <view>
  62. <text class="lf-font-24 lf-color-777 lf-iconfont icon-xiangyou"></text>
  63. </view>
  64. </view>
  65. </view>
  66. </block>
  67. <self-line></self-line>
  68. <!-- 服务tags -->
  69. <block v-if="goods_detail.tags.length">
  70. <view class="bg-white">
  71. <view class="cu-bar padding-lr">
  72. <view class="lf-flex">
  73. <text class="lf-color-777 lf-font-28">服务</text>
  74. <view style="width: 600rpx;flex-wrap: wrap;display: flex;margin-top: 32rpx;">
  75. <view class="lf-m-l-30" v-for="(tagItem, tagIndex) in goods_detail.tags" :key="tagIndex">
  76. <text class="lf-iconfont icon-xuanzhong lf-font-30" style="color: #15716E;"></text>
  77. <text class="lf-m-l-10 lf-font-26 lf-color-black">{{ tagItem }}</text>
  78. </view>
  79. </view>
  80. </view>
  81. <view>
  82. <text class="lf-font-24 lf-color-777 lf-iconfont icon-xiangyou"></text>
  83. </view>
  84. </view>
  85. </view>
  86. </block>
  87. <!-- 商品选择规格 -->
  88. <block v-if="$isRight(goods_stock.specs)">
  89. <view class="bg-white">
  90. <view class="cu-bar padding-lr" @click="shoot(2)">
  91. <view class="lf-flex">
  92. <text class="lf-color-777 lf-font-28">选择</text>
  93. <text class="lf-color-222 lf-font-26 lf-m-l-30">{{ showSpec }}</text>
  94. </view>
  95. <view>
  96. <text class="lf-font-24 lf-color-777 lf-iconfont icon-xiangyou"></text>
  97. </view>
  98. </view>
  99. </view>
  100. <self-line></self-line>
  101. </block>
  102. <!-- 店铺信息 -->
  103. <view v-if="type != 'point'">
  104. <view class="user-top">
  105. <view class="lf-row-between lf-w-100">
  106. <view class="lf-flex" @click="$url('/pages/shop/shopdetail?id='+ brand_detail.id)">
  107. <view class="tag-father">
  108. <image :src="brand_detail.logo" mode="aspectFill" class="head-img"></image>
  109. </view>
  110. <view class="lf-flex-column lf-m-l-20">
  111. <text class="lf-font-28 lf-color-black lf-font-bold">{{ brand_detail.name }}</text>
  112. <view class="lf-font-24 lf-color-777">
  113. <text class="lf-iconfont icon-dizhi lf-font-24 lf-color-primary"></text>
  114. <text class="lf-m-l-10">{{ brand_detail.floor }}</text>
  115. </view>
  116. </view>
  117. </view>
  118. <!-- <view>
  119. <button class="head-btn" @click="$url('/pages/user/my/chatonline')">
  120. <text class="lf-iconfont icon-kefuhdpi lf-font-24"></text>
  121. <text class="lf-m-l-10">客服</text>
  122. </button>
  123. </view> -->
  124. </view>
  125. </view>
  126. <scroll-view class="scroll-view" :scroll-x="true">
  127. <view class="scroll-content">
  128. <view class="goods-item"
  129. v-for="(item, index) in brand_detail.goods"
  130. :key="index"
  131. @click="$url('/pages/shop/goodsdetail?id='+ item.id)">
  132. <image class="goods-img" :src="item.img"></image>
  133. <view class="goods-info">
  134. <view class="lf-line-1">{{ item.name }}</view>
  135. <view>{{ item.sell_price }}</view>
  136. </view>
  137. </view>
  138. <view class="goods-item" @click="$url('/pages/shop/shopdetail?id='+ brand_detail.id)">
  139. <view class="more-box">
  140. <text>查看更多</text>
  141. <text class="lf-iconfont icon--2 lf-text-vertical"></text>
  142. </view>
  143. </view>
  144. </view>
  145. </scroll-view>
  146. </view>
  147. <!-- 商品详情 -->
  148. <view class="goods-detail">
  149. <view class="lf-font-32 lf-font-bold lf-m-b-20">商品详情</view>
  150. <rich-text :nodes="formatRichText(goods_detail.content)"></rich-text>
  151. <!-- <image class="goods-img" :src="item" v-for="(item, index) in goods_detail.content" :key="index" v-if="goods_detail.content_type == 'img'"></image> -->
  152. </view>
  153. <!-- 修饰专用 -->
  154. <view class="extra"></view>
  155. <!-- 吸底操作按钮 -->
  156. <view class="lf-row-between fixed-bottom">
  157. <view class="lf-flex lf-p-t-10 lf-p-b-10">
  158. <!-- <view class="lf-flex-column lf-row-center icon-item" open-type="contact">
  159. <text class="lf-iconfont icon-pinglun- icon-img"></text>
  160. <view class="lf-m-t-1">客服</view>
  161. </view> -->
  162. <view class="lf-flex-column lf-row-center icon-item" @click="switchCollect">
  163. <text class="lf-iconfont icon-shoucang2 icon-img lf-color-price" v-if="is_collect"></text>
  164. <text class="lf-iconfont icon-shoucang11 icon-img" v-else></text>
  165. <view class="lf-m-t-1">{{ is_collect ? '已收藏' : '收藏' }}</view>
  166. </view>
  167. <button class="lf-flex-column lf-row-center icon-item" @click="$url('/pages/store/cart/cart')">
  168. <text class="lf-iconfont icon-gouwulan icon-img"></text>
  169. <view class="lf-m-t-1">购物车</view>
  170. </button>
  171. </view>
  172. <view v-if="type == 'seckill'">
  173. <button class="btn" style="width: 349rpx;">立即秒杀</button>
  174. </view>
  175. <view v-else-if="type == 'point'">
  176. <button class="btn" style="width: 349rpx;">立即兑换</button>
  177. </view>
  178. <view class="lf-flex" v-else>
  179. <button class="btn1" @click="shoot(1)">加入购物车</button>
  180. <button class="btn lf-m-l-15" @click="shoot(2)">立即购买</button>
  181. </view>
  182. </view>
  183. <!-- 加入购物车立即购买模态框选规格 -->
  184. <u-popup v-model="show_popup" mode="bottom" :round="true" borderRadius="20">
  185. <view class="popup-content">
  186. <!-- 商品信息及关闭按钮 -->
  187. <view class="popup-head">
  188. <view class="lf-flex">
  189. <image class="goods-img" :src="goods_detail.img"></image>
  190. <view class="goods-info">
  191. <view class="price">{{ showGoodsSpecPrice }}</view>
  192. <view class="goods-name">{{ goods_detail.name }}</view>
  193. </view>
  194. </view>
  195. <view @click="show_popup = false">
  196. <text class="lf-iconfont icon-cuo lf-font-50"></text>
  197. </view>
  198. </view>
  199. <!-- 规格 -->
  200. <view v-for="(value, key) in goods_stock.specs" :key="key">
  201. <view class="spec-title">{{ value.label }}</view>
  202. <view class="lf-flex-wrap">
  203. <view :class="{
  204. 'spec-item': true,
  205. 'spec-active': value.spec_current === index}"
  206. @click="activeSpec(key, index)"
  207. v-for="(item, index) in value.list"
  208. :key="index">{{ item.value }}
  209. </view>
  210. </view>
  211. </view>
  212. <!-- 数量 -->
  213. <view class="lf-row-between lf-m-t-40">
  214. <view class="lf-font-28 lf-color-555">数量</view>
  215. <view class="lf-flex">
  216. <view class="num-btn" @click="changeNum('less')">
  217. <text class="lf-iconfont icon-jian1 lf-font-30"></text>
  218. </view>
  219. <view>
  220. <input class="input" :value="goods_num" :disabled="true" />
  221. </view>
  222. <view class="num-btn lf-text-right" @click="changeNum('add')">
  223. <text class="lf-iconfont icon-jia lf-font-30"></text>
  224. </view>
  225. </view>
  226. </view>
  227. <!-- 操作按钮 -->
  228. <button class="comfirm-btn" @click="specConfirm">{{ click_type == 1 ? '加入购物车' : '立即购买' }}</button>
  229. </view>
  230. </u-popup>
  231. <!-- 回到顶部 -->
  232. <u-back-top :scroll-top="pageScrollTop"></u-back-top>
  233. </block>
  234. </skeleton>
  235. </view>
  236. </template>
  237. <script>
  238. import countdownTimer from '@/components/countdown-timer/countdown-timer';
  239. export default {
  240. components: {
  241. countdownTimer
  242. },
  243. data(){
  244. return {
  245. current: 0, // 轮播下标
  246. goods_id: 0,
  247. goods_detail: {},
  248. is_collect: false, // 1为当前收藏商品了,0为否
  249. skeletonLoading: false,
  250. pictures: [],
  251. show_popup: false, // 是否显示选规格模态框
  252. click_type: null, // 当前点击的是加入购物车[1]还是立即购买[2]
  253. type: 'mail', // 页面显示类型,mail普通可邮寄商品,point积分商品,seckill秒杀商品
  254. time: 0,
  255. goods_stock: {
  256. specs: {},
  257. stores: {}
  258. },
  259. seckill: {}, // 秒杀商品的信息
  260. brand_detail: {},
  261. token: '',
  262. coupons: [], // 优惠
  263. goods_num: 1,
  264. is_date_finish: false,
  265. show_share: false,
  266. shareImg: ''
  267. }
  268. },
  269. computed: {
  270. showGoodsSpecPrice(){
  271. let goods_detail = this.goods_detail;
  272. let stores = this.goods_stock.stores;
  273. let specs = this.goods_stock.specs;
  274. if(!this.$isRight(specs[1])){
  275. return `${goods_detail.min_price} - ¥${goods_detail.max_price}`;
  276. }
  277. let spec_current_1 = specs[1].spec_current;
  278. let spec_current_2 = specs[2].spec_current;
  279. if(specs[1].spec_current != null && specs[2].spec_current != null){
  280. let id_1 = specs[1].list[spec_current_1].id;
  281. let id_2 = specs[2].list[spec_current_2].id;
  282. if(id_1 < id_2){
  283. let id_3 = id_2;
  284. id_2 = id_1;
  285. id_1 = id_3;
  286. }
  287. return "¥"+ stores[id_2 +'-'+ id_1].price;
  288. }else{
  289. return `${goods_detail.min_price} - ¥${goods_detail.max_price}`;
  290. }
  291. },
  292. showSpec(){
  293. let specs = this.goods_stock.specs;
  294. let str = '';
  295. for(let i in specs){
  296. if(specs[i].spec_current != null){
  297. str += specs[i].list[specs[i].spec_current].value +';';
  298. }
  299. }
  300. if(str == ''){
  301. str = '请选择规格'
  302. }
  303. return str;
  304. }
  305. },
  306. onLoad(options){
  307. console.log("options", options)
  308. this.token = this.$cookieStorage.get('user_token');
  309. this.goods_id = options.id;
  310. this.getNewdetail();
  311. this.getGoodsStock(); // 获取商品库存、规格信息
  312. },
  313. methods: {
  314. // 切换商品收藏
  315. switchCollect(){
  316. if(!this.token){
  317. this.$url('/pages/login/index');
  318. return;
  319. }
  320. this.addCollcet()
  321. },
  322. //收藏
  323. addCollcet() {
  324. this.$http.post({
  325. api: 'api/collect/create',
  326. data: {
  327. type:'jc_goods',
  328. collect_id: this.goods_detail.id,
  329. },
  330. header: {
  331. Authorization: this.token
  332. }
  333. }).then(res => {
  334. this.$msg(res.data.data);
  335. this.getNewdetail();
  336. }).catch(err => {
  337. console.log("====", err);
  338. })
  339. },
  340. // 加入购物车和立即购买
  341. shoot(type){
  342. this.click_type = type;
  343. if(this.$isRight(this.goods_stock.specs)){
  344. this.show_popup = true;
  345. }else{
  346. this.confirm();
  347. }
  348. },
  349. // 选规格提交
  350. specConfirm(){
  351. let specs = this.goods_stock.specs;
  352. let flag = true;
  353. for(let i in specs){
  354. if(specs[i].spec_current == null){
  355. flag = false;
  356. }
  357. }
  358. if(flag){
  359. this.confirm();
  360. }else{
  361. this.$msg('您未选完整规格')
  362. }
  363. },
  364. // 商品选规格
  365. activeSpec(key, index){
  366. let obj = this.goods_stock.specs;
  367. if(obj[key]['spec_current'] == index){
  368. obj[key]['spec_current'] = null;
  369. }else{
  370. obj[key]['spec_current'] = index;
  371. }
  372. this.$set(this.goods_stock, 'specs', obj);
  373. },
  374. // 商品加减
  375. changeNum(type){
  376. if(type == 'add'){
  377. if(this.goods_num < 10){
  378. this.goods_num++;
  379. }
  380. }else if(type == 'less'){
  381. if(this.goods_num > 1){
  382. this.goods_num--;
  383. }
  384. }
  385. },
  386. // 跳转至下单页
  387. confirm(){
  388. if(this.is_date_finish){
  389. return this.$msg('活动已结束');
  390. }
  391. let goods_detail = this.goods_detail;
  392. let specs = this.goods_stock.specs;
  393. let stores = this.goods_stock.stores;
  394. let par = {};
  395. if(this.$isRight(specs)){
  396. let s_id_1 = 1;
  397. let s_id_2 = 2;
  398. for(let i in specs){
  399. if(specs[i].label_key == 'size'){
  400. s_id_1 = 1;
  401. }
  402. if(specs[i].label_key == 'color'){
  403. s_id_2 = 2;
  404. }
  405. }
  406. let spec_current_1 = specs[s_id_1].spec_current;
  407. let spec_current_2 = specs[s_id_2].spec_current;
  408. let id_1 = specs[s_id_1].list[spec_current_1].id;
  409. let id_2 = specs[s_id_2].list[spec_current_2].id;
  410. if(id_1 > id_2){
  411. let id_3 = id_2;
  412. id_2 = id_1;
  413. id_1 = id_3;
  414. }
  415. par = {
  416. attributes: {
  417. color: specs[s_id_2].list[specs[s_id_2].spec_current].value,
  418. com_id: goods_detail.id,
  419. img: goods_detail.img,
  420. size: specs[s_id_1].list[specs[s_id_1].spec_current].value,
  421. sku: goods_detail.goods_no +'-'+ specs[s_id_1].list[specs[s_id_1].spec_current].value
  422. },
  423. id: stores[id_1 +'-'+ id_2].id,
  424. product_id: stores[id_1 +'-'+ id_2].id,
  425. price: stores[id_1 +'-'+ id_2].price,
  426. store_count: stores[id_1 +'-'+ id_2].store,
  427. market_price: goods_detail.market_price,
  428. name: goods_detail.name,
  429. qty: this.goods_num
  430. }
  431. }else{
  432. par = {
  433. attributes: {
  434. com_id: goods_detail.id,
  435. img: goods_detail.img
  436. },
  437. id: goods_detail.id,
  438. product_id: goods_detail.id,
  439. price: goods_detail.sell_price,
  440. store_count: goods_detail.store_nums,
  441. market_price: goods_detail.market_price,
  442. name: goods_detail.name,
  443. qty: this.goods_num
  444. }
  445. }
  446. // 秒杀商品
  447. if(this.$isRight(this.seckill)){
  448. delete par.product_id;
  449. par.seckill_goods_id = this.seckill.item_id;
  450. par.seckill_item_id = this.seckill.id;
  451. }
  452. uni.showLoading({
  453. title: '正在提交'
  454. })
  455. this.show_popup = false;
  456. if(this.click_type == 1){
  457. // 加入购物车
  458. this.$http.post({
  459. api: 'api/shopping/cart',
  460. data: {"0": par},
  461. header: {
  462. Authorization: this.token
  463. }
  464. }).then(res => {
  465. if(res.data.code == 200){
  466. this.$msg('加入购物车成功', {icon: 'success'})
  467. }else{
  468. this.$msg('加入购物车失败', {icon: 'error'})
  469. }
  470. uni.hideLoading()
  471. }).catch(err => uni.hideLoading())
  472. }else if(this.click_type == 2){
  473. // 直接结算
  474. this.$cookieStorage.set('order_confirm', par);
  475. uni.hideLoading();
  476. this.$url('/pages/order/confirm/confirm');
  477. // this.$http.post({
  478. // api: 'api/shopping/order/checkout',
  479. // data: par,
  480. // header: {
  481. // Authorization: this.token
  482. // }
  483. // }).then(res => {
  484. // if(res.data.code == 200){
  485. // this.$url('/pages/order/confirm/confirm');
  486. // }else{
  487. // this.$msg('提交失败', {icon: 'error'})
  488. // }
  489. // uni.hideLoading()
  490. // }).catch(err => uni.hideLoading())
  491. }
  492. },
  493. // 点击页面分享按钮
  494. shareGraphic(){
  495. this.getShearImg();
  496. },
  497. // 获取分享图片
  498. getShearImg() {
  499. wx.showLoading({
  500. title: "生成中",
  501. mask: true
  502. });
  503. var token = this.token;
  504. this.$http.get({
  505. api: 'api/distribution/createMiniShareImg',
  506. header: {
  507. Authorization: token
  508. },
  509. data: {
  510. goods_id: this.goods_id
  511. }
  512. }).then(res => {
  513. if (res.statusCode == 200) {
  514. res = res.data;
  515. if (res.status) {
  516. this.setData({
  517. shareImg: res.data.image
  518. });
  519. setTimeout(() => {
  520. this.changeImg();
  521. }, 100)
  522. } else {
  523. wx.showModal({
  524. content: res.message || '请求失败',
  525. showCancel: false
  526. });
  527. }
  528. } else {
  529. wx.showModal({
  530. content: '请求失败',
  531. showCancel: false
  532. });
  533. }
  534. wx.hideLoading();
  535. this.changeShare();
  536. }).catch(rej => {
  537. wx.showModal({
  538. content: '内部错误',
  539. showCancel: false
  540. });
  541. wx.hideLoading();
  542. this.changeShare();
  543. });
  544. },
  545. // 弹出分享
  546. changeShare() {
  547. this.setData({
  548. show_share: !this.show_share
  549. });
  550. },
  551. // 商品详情
  552. getNewdetail(){
  553. this.$http.get({
  554. api: 'api/store/detail/'+ this.goods_id,
  555. header: {
  556. Authorization: this.token
  557. }
  558. }).then(res => {
  559. console.log("===---", res);
  560. let meta = res.data.meta;
  561. let goods_detail = res.data.data;
  562. this.goods_detail = goods_detail;
  563. this.pictures = [res.data.data.img];
  564. this.is_collect = Boolean(res.data.data.is_collect) || false;
  565. let type = 'mail';
  566. if(this.$isRight(goods_detail.is_largess)){
  567. type = 'point';
  568. }
  569. if(this.$isRight(meta.seckill)){
  570. type = 'seckill';
  571. this.seckill = meta.seckill;
  572. let currentDate = this.$shared.recordTime();
  573. this.time = new Date(meta.seckill.ends_at).getTime() - new Date(currentDate).getTime()
  574. console.log("time", this.time, meta.seckill.ends_at, currentDate)
  575. }
  576. if(type != 'point'){
  577. this.getBrandDetail(goods_detail.brand_id);
  578. }
  579. if(this.$isRight(meta.discounts)){
  580. this.coupons = meta.discounts.coupons;
  581. }
  582. this.type = type;
  583. }).catch(err => {
  584. console.log("====", err);
  585. })
  586. },
  587. // 获取商家信息
  588. getBrandDetail(brand_id){
  589. this.$http.get({
  590. api: 'api/brand/detail',
  591. data: {
  592. brand_id: brand_id
  593. },
  594. header: {
  595. Authorization: this.token
  596. }
  597. }).then(res => {
  598. this.brand_detail = res.data.data;
  599. })
  600. },
  601. // 获取商品库存信息
  602. getGoodsStock(){
  603. this.$http.get({
  604. api: `api/store/detail/${this.goods_id}/stock`
  605. }).then(res => {
  606. let data = res.data.data;
  607. for(let i in data.specs){
  608. data.specs[i].spec_current = null;
  609. }
  610. this.goods_stock = data;
  611. })
  612. },
  613. // 拨打电话
  614. makePhoneCall(phoneStr){
  615. uni.makePhoneCall({
  616. phoneNumber: String(phoneStr)
  617. })
  618. },
  619. // 打开地图 PS.暂时用不到
  620. openMap(){
  621. let { address, lat, lng } = this.goods_detail?.store || {};
  622. uni.openLocation({
  623. longitude: Number(lat),
  624. latitude: Number(lng),
  625. scale: 20,
  626. name: address
  627. });
  628. },
  629. // 预览图片
  630. lookImg(index){
  631. this.$u.throttle(() => {
  632. let banners = this.pictures;
  633. uni.previewImage({
  634. urls: banners,
  635. current: index
  636. })
  637. }, 200);
  638. },
  639. // 倒计时结束
  640. dateFinish(){
  641. this.is_date_finish = true;
  642. },
  643. // 富文本处理
  644. formatRichText(richText){
  645. if(richText != null){
  646. let newRichText= richText.replace(/<img[^>]*>/gi, function(match, capture){
  647. match = match.replace(/style="[^"]+"/gi, '').replace(/style='[^']+'/gi, '');
  648. match = match.replace(/width="[^"]+"/gi, '').replace(/width='[^']+'/gi, '');
  649. match = match.replace(/height="[^"]+"/gi, '').replace(/height='[^']+'/gi, '');
  650. return match;
  651. });
  652. newRichText = newRichText.replace(/style="[^"]+"/gi,function(match, capture){
  653. match = match.replace(/width:[^;]+;/gi, 'width:100%;').replace(/width:[^;]+;/gi, 'width:100%;');
  654. return match;
  655. });
  656. newRichText = newRichText.replace(/<br[^>]*\/>/gi, '');
  657. newRichText = newRichText.replace(/\<img/gi, '<img style="width:100%;height:auto;display:block;margin:10px 0;"');
  658. return newRichText;
  659. }else{
  660. return null;
  661. }
  662. }
  663. },
  664. onShareAppMessage(){
  665. let goods = this.goods_detail;
  666. let title = goods.name;
  667. let imageUrl = goods.share_cover || goods.cover || goods.img;
  668. let path = '/pages/route/index?route=detail&id='+ goods.id;
  669. return {
  670. title,
  671. path,
  672. imageUrl
  673. }
  674. }
  675. }
  676. </script>
  677. <style>
  678. page{
  679. background-color: #f5f5f5;
  680. overflow-x: hidden;
  681. }
  682. </style>
  683. <style lang="scss" scoped="scoped">
  684. //商品上去scrollview部分
  685. .scroll-view{
  686. height: 310rpx;
  687. width: 100%;
  688. // margin-top: 20rpx;
  689. padding: 0 30rpx 30rpx 30rpx;
  690. background-color: white;
  691. .scroll-content{
  692. display: flex;
  693. width: 100%;
  694. .goods-item{
  695. margin-right: 15rpx;
  696. width: 180rpx;
  697. }
  698. .goods-img{
  699. width: 180rpx;
  700. height: 180rpx;
  701. background-color: #EEEEEE;
  702. }
  703. .goods-info{
  704. text-align: center;
  705. color: #222222;
  706. &>view:nth-child(1n){
  707. font-size: 24rpx;
  708. }
  709. &>view:nth-child(2n){
  710. font-size: 28rpx;
  711. font-weight: bold;
  712. text-align: left;
  713. color: #F63434;
  714. }
  715. }
  716. .more-box{
  717. width: 180rpx;
  718. height: 180rpx;
  719. background-color: #EEEEEE;
  720. text-align: center;
  721. line-height: 180rpx;
  722. font-size: 24rpx;
  723. }
  724. }
  725. }
  726. //scrollview结束
  727. .tag-father {
  728. position: relative;
  729. }
  730. .head-tag {
  731. color: white;
  732. display: flex;
  733. align-items: center;
  734. justify-content: center;
  735. text-align: center;
  736. font-size: 24rpx;
  737. width: 36rpx;
  738. height: 36rpx;
  739. border-radius: 50%;
  740. background-color: #15716E;
  741. border: 1rpx solid #FFFFFF;
  742. position: absolute;
  743. left: 76rpx;
  744. top: 86rpx;
  745. z-index: 99;
  746. }
  747. .qzone-img {
  748. width: 220rpx;
  749. height: 220rpx;
  750. border-radius: 10rpx;
  751. margin-right: 12rpx;
  752. &:nth-child(3n) {
  753. margin-right: 0;
  754. }
  755. &:nth-child(n + 4) {
  756. margin-top: 12rpx;
  757. }
  758. }
  759. .user-top {
  760. background-color: #F3F8F8;
  761. padding: 30rpx;
  762. display: flex;
  763. align-items: center;
  764. background-color: white;
  765. }
  766. .head-img {
  767. width: 80rpx;
  768. height: 80rpx;
  769. border-radius: 50%;
  770. }
  771. .head-btn {
  772. display: flex;
  773. width: max-content;
  774. height: 45rpx;
  775. background: white;
  776. border: 2rpx solid #15716E;
  777. align-items: center;
  778. font-size: 22rpx;
  779. color: #15716E;
  780. justify-content: space-between;
  781. border-radius: 35rpx;
  782. padding: 10rpx!important;
  783. }
  784. .swiper-box{
  785. width: 750rpx;
  786. height: 750rpx;
  787. background-color: #FFFFFF;
  788. position: relative;
  789. .seckill-box{
  790. position: absolute;
  791. bottom: 0;
  792. left: 0;
  793. display: flex;
  794. justify-content: space-between;
  795. align-items: center;
  796. padding: 0 32rpx;
  797. width: 100%;
  798. height: 77rpx;
  799. background-color: #15716E;
  800. color: #FFFFFF;
  801. font-size: 26rpx;
  802. }
  803. }
  804. .head-info{
  805. width: 750rpx;
  806. height: auto;
  807. box-sizing: border-box;
  808. padding: 0 32rpx;
  809. padding-top: 20rpx;
  810. background-color: #FFFFFF;
  811. // .price>view:nth-of-type(1){
  812. // color: #FF0000;
  813. // margin-right: 22rpx;
  814. // font-weight: bold;
  815. // }
  816. .price>view:nth-of-type(1){
  817. text-decoration: line-through;
  818. color: #777777;
  819. margin-right: 22rpx;
  820. }
  821. .price>view:nth-of-type(2){
  822. width: max-content;
  823. padding: 0 18rpx;
  824. height: 46rpx;
  825. background-color: #1998FE;
  826. border-radius: 10rpx;
  827. display: flex;
  828. justify-content: center;
  829. align-items: center;
  830. color: #FFFFFF;
  831. }
  832. .label-box{
  833. min-height: 130rpx;
  834. width: 100%;
  835. border-top: 1rpx solid #E5E5E5;
  836. display: flex;
  837. flex-wrap: wrap;
  838. padding: 30rpx 0 10rpx 0;
  839. .label-item{
  840. width: max-content;
  841. padding: 20rpx;
  842. height: 70rpx;
  843. border-radius: 10rpx;
  844. border: 2rpx solid #1998FE;
  845. display: flex;
  846. justify-content: center;
  847. align-items: center;
  848. font-size: 28rpx;
  849. color: #1998FE;
  850. margin-right: 20rpx;
  851. margin-bottom: 20rpx;
  852. }
  853. }
  854. }
  855. .address-box{
  856. width: 750rpx;
  857. height: auto;
  858. box-sizing: border-box;
  859. background-color: #FFFFFF;
  860. padding: 32rpx;
  861. margin-top: 20rpx;
  862. .shop-img{
  863. width: 60rpx;
  864. height: 60rpx;
  865. border-radius: 50%;
  866. }
  867. }
  868. .goods-detail{
  869. width: 750rpx;
  870. height: auto;
  871. background-color: #FFFFFF;
  872. padding: 32rpx;
  873. box-sizing: border-box;
  874. margin-top: 20rpx;
  875. .goods-img{
  876. width: 100%;
  877. }
  878. }
  879. .extra{
  880. width: 100%;
  881. height: 110rpx;
  882. padding-bottom: constant(safe-area-inset-bottom);
  883. padding-bottom: env(safe-area-inset-bottom);
  884. box-sizing: content-box;
  885. }
  886. .fixed-bottom{
  887. position: fixed;
  888. bottom: 0;
  889. left: 0;
  890. background-color: #FFFFFF;
  891. width: 100%;
  892. height: auto;
  893. padding: 0 32rpx;
  894. border-top: 1rpx solid #e5e5e5;
  895. padding-bottom: constant(safe-area-inset-bottom);
  896. padding-bottom: env(safe-area-inset-bottom);
  897. .icon-item{
  898. text-align: center;
  899. margin-right: 16rpx;
  900. background-color: transparent;
  901. margin: 0;
  902. line-height: initial;
  903. font-size: 28rpx;
  904. font-weight: inherit;
  905. margin-right: 10rpx;
  906. padding: 0;
  907. width: 88rpx;
  908. position: relative;
  909. &:first-child{
  910. padding-left: 0;
  911. }
  912. .icon-img{
  913. height: 50rpx;
  914. width: 50rpx;
  915. font-size: 40rpx;
  916. line-height: 1;
  917. }
  918. }
  919. .btn1{
  920. margin: 0;
  921. width: max-content;
  922. height: 80rpx;
  923. background-color: rgba(21, 113, 110, 0.1);
  924. color: #15716E;
  925. line-height: 80rpx;
  926. font-size: 32rpx;
  927. padding: 0 20rpx;
  928. border-radius: 42rpx;
  929. font-size: 26rpx;
  930. border: 2rpx solid #15716E;
  931. }
  932. .btn{
  933. margin: 0;
  934. padding: 0 20rpx;
  935. width: max-content;
  936. height: 80rpx;
  937. background-color: #15716E;
  938. color: #FFFFFF;
  939. line-height: 80rpx;
  940. font-size: 26rpx;
  941. border-radius: 42rpx;
  942. }
  943. }
  944. .popup-content{
  945. height: max-content;
  946. width: 750rpx;
  947. background: #FFFFFF;
  948. border-radius: 20rpx 20rpx 0rpx 0rpx !important;
  949. padding: 40rpx 32rpx;
  950. max-height: 80vh;
  951. overflow-y: scroll;
  952. .popup-head{
  953. display: flex;
  954. justify-content: space-between;
  955. .goods-img{
  956. width: 150rpx;
  957. height: 150rpx;
  958. border-radius: 2rpx;
  959. margin-right: 20rpx;
  960. }
  961. .goods-info{
  962. width: 400rpx;
  963. height: 150rpx;
  964. display: flex;
  965. flex-direction: column;
  966. justify-content: space-around;
  967. .price{
  968. font-size: 48rpx;
  969. font-weight: bold;
  970. color: #F63434;
  971. line-height: 1;
  972. }
  973. .goods-name{
  974. font-size: 32rpx;
  975. color: #222222;
  976. line-height: 1.4;
  977. }
  978. }
  979. }
  980. .spec-title{
  981. font-size: 28rpx;
  982. color: #555555;
  983. margin-top: 40rpx;
  984. margin-bottom: 20rpx;
  985. }
  986. .spec-item{
  987. width: 142rpx;
  988. height: 64rpx;
  989. border-radius: 33rpx;
  990. border: 2rpx solid #555555;
  991. font-size: 28rpx;
  992. color: #555555;
  993. display: flex;
  994. justify-content: center;
  995. align-items: center;
  996. margin-right: 20rpx;
  997. &:nth-child(4n){
  998. margin-right: 0rpx;
  999. }
  1000. &:nth-child(n+5){
  1001. margin-top: 20rpx;
  1002. }
  1003. }
  1004. .spec-active{
  1005. border: none;
  1006. background-color: #15716E;
  1007. color: #FFFFFF;
  1008. }
  1009. .input{
  1010. width: 40rpx;
  1011. height: 45rpx;
  1012. border-radius: 2rpx;
  1013. background-color: #F3F8F7;
  1014. text-align: center;
  1015. }
  1016. .num-btn{
  1017. width: 36rpx;
  1018. }
  1019. .comfirm-btn{
  1020. width: 550rpx;
  1021. height: 100rpx;
  1022. background: #15716E;
  1023. border-radius: 50rpx;
  1024. color: #FFFFFF;
  1025. line-height: 100rpx;
  1026. margin-top: 62rpx;
  1027. }
  1028. }
  1029. </style>