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

1056 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;" @click="goExchange()">立即兑换</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. goExchange() {
  315. if(this.showSpec == '请选择规格') {
  316. this.shoot(3)
  317. }
  318. },
  319. // 切换商品收藏
  320. switchCollect(){
  321. if(!this.token){
  322. this.$url('/pages/login/index');
  323. return;
  324. }
  325. this.addCollcet()
  326. },
  327. //收藏
  328. addCollcet() {
  329. this.$http.post({
  330. api: 'api/collect/create',
  331. data: {
  332. type:'jc_goods',
  333. collect_id: this.goods_detail.id,
  334. },
  335. header: {
  336. Authorization: this.token
  337. }
  338. }).then(res => {
  339. this.$msg(res.data.data);
  340. this.getNewdetail();
  341. }).catch(err => {
  342. console.log("====", err);
  343. })
  344. },
  345. // 加入购物车和立即购买
  346. shoot(type){
  347. this.click_type = type;
  348. if(this.$isRight(this.goods_stock.specs)){
  349. this.show_popup = true;
  350. }else{
  351. this.confirm();
  352. }
  353. },
  354. // 选规格提交
  355. specConfirm(){
  356. let specs = this.goods_stock.specs;
  357. let flag = true;
  358. for(let i in specs){
  359. if(specs[i].spec_current == null){
  360. flag = false;
  361. }
  362. }
  363. if(flag){
  364. this.confirm();
  365. }else{
  366. this.$msg('您未选完整规格')
  367. }
  368. },
  369. // 商品选规格
  370. activeSpec(key, index){
  371. let obj = this.goods_stock.specs;
  372. if(obj[key]['spec_current'] == index){
  373. obj[key]['spec_current'] = null;
  374. }else{
  375. obj[key]['spec_current'] = index;
  376. }
  377. this.$set(this.goods_stock, 'specs', obj);
  378. },
  379. // 商品加减
  380. changeNum(type){
  381. if(type == 'add'){
  382. if(this.goods_num < 10){
  383. this.goods_num++;
  384. }
  385. }else if(type == 'less'){
  386. if(this.goods_num > 1){
  387. this.goods_num--;
  388. }
  389. }
  390. },
  391. // 跳转至下单页
  392. confirm(){
  393. if(this.is_date_finish){
  394. return this.$msg('活动已结束');
  395. }
  396. let goods_detail = this.goods_detail;
  397. let specs = this.goods_stock.specs;
  398. let stores = this.goods_stock.stores;
  399. let par = {};
  400. if(this.$isRight(specs)){
  401. let s_id_1 = 1;
  402. let s_id_2 = 2;
  403. for(let i in specs){
  404. if(specs[i].label_key == 'size'){
  405. s_id_1 = 1;
  406. }
  407. if(specs[i].label_key == 'color'){
  408. s_id_2 = 2;
  409. }
  410. }
  411. let spec_current_1 = specs[s_id_1].spec_current;
  412. let spec_current_2 = specs[s_id_2].spec_current;
  413. let id_1 = specs[s_id_1].list[spec_current_1].id;
  414. let id_2 = specs[s_id_2].list[spec_current_2].id;
  415. if(id_1 > id_2){
  416. let id_3 = id_2;
  417. id_2 = id_1;
  418. id_1 = id_3;
  419. }
  420. par = {
  421. attributes: {
  422. color: specs[s_id_2].list[specs[s_id_2].spec_current].value,
  423. com_id: goods_detail.id,
  424. img: goods_detail.img,
  425. size: specs[s_id_1].list[specs[s_id_1].spec_current].value,
  426. sku: goods_detail.goods_no +'-'+ specs[s_id_1].list[specs[s_id_1].spec_current].value
  427. },
  428. id: stores[id_1 +'-'+ id_2].id,
  429. product_id: stores[id_1 +'-'+ id_2].id,
  430. price: stores[id_1 +'-'+ id_2].price,
  431. store_count: stores[id_1 +'-'+ id_2].store,
  432. market_price: goods_detail.market_price,
  433. name: goods_detail.name,
  434. qty: this.goods_num
  435. }
  436. }else{
  437. par = {
  438. attributes: {
  439. com_id: goods_detail.id,
  440. img: goods_detail.img
  441. },
  442. id: goods_detail.id,
  443. product_id: goods_detail.id,
  444. price: goods_detail.sell_price,
  445. store_count: goods_detail.store_nums,
  446. market_price: goods_detail.market_price,
  447. name: goods_detail.name,
  448. qty: this.goods_num
  449. }
  450. }
  451. uni.showLoading({
  452. title: '正在提交'
  453. })
  454. this.show_popup = false;
  455. if(this.click_type == 1){
  456. // 加入购物车
  457. this.$http.post({
  458. api: 'api/shopping/cart',
  459. data: {"0": par},
  460. header: {
  461. Authorization: this.token
  462. }
  463. }).then(res => {
  464. if(res.data.code == 200){
  465. this.$msg('加入购物车成功', {icon: 'success'})
  466. }else{
  467. this.$msg('加入购物车失败', {icon: 'error'})
  468. }
  469. uni.hideLoading()
  470. }).catch(err => uni.hideLoading())
  471. }else if(this.click_type == 2){
  472. // 直接结算
  473. this.$cookieStorage.set('order_confirm', par);
  474. uni.hideLoading();
  475. this.$url('/pages/order/confirm/confirm?goods_type=1');
  476. // this.$http.post({
  477. // api: 'api/shopping/order/checkout',
  478. // data: par,
  479. // header: {
  480. // Authorization: this.token
  481. // }
  482. // }).then(res => {
  483. // if(res.data.code == 200){
  484. // this.$url('/pages/order/confirm/confirm');
  485. // }else{
  486. // this.$msg('提交失败', {icon: 'error'})
  487. // }
  488. // uni.hideLoading()
  489. // }).catch(err => uni.hideLoading())
  490. }else if(this.click_type == 3) {
  491. // 直接结算
  492. this.$cookieStorage.set('order_confirm', par);
  493. uni.hideLoading();
  494. this.$url('/pages/order/confirm/confirm?goods_type=0');
  495. }
  496. },
  497. // 点击页面分享按钮
  498. shareGraphic(){
  499. this.getShearImg();
  500. },
  501. // 获取分享图片
  502. getShearImg() {
  503. wx.showLoading({
  504. title: "生成中",
  505. mask: true
  506. });
  507. var token = this.token;
  508. this.$http.get({
  509. api: 'api/distribution/createMiniShareImg',
  510. header: {
  511. Authorization: token
  512. },
  513. data: {
  514. goods_id: this.goods_id
  515. }
  516. }).then(res => {
  517. if (res.statusCode == 200) {
  518. res = res.data;
  519. if (res.status) {
  520. this.setData({
  521. shareImg: res.data.image
  522. });
  523. setTimeout(() => {
  524. this.changeImg();
  525. }, 100)
  526. } else {
  527. wx.showModal({
  528. content: res.message || '请求失败',
  529. showCancel: false
  530. });
  531. }
  532. } else {
  533. wx.showModal({
  534. content: '请求失败',
  535. showCancel: false
  536. });
  537. }
  538. wx.hideLoading();
  539. this.changeShare();
  540. }).catch(rej => {
  541. wx.showModal({
  542. content: '内部错误',
  543. showCancel: false
  544. });
  545. wx.hideLoading();
  546. this.changeShare();
  547. });
  548. },
  549. // 弹出分享
  550. changeShare() {
  551. this.setData({
  552. show_share: !this.show_share
  553. });
  554. },
  555. // 商品详情
  556. getNewdetail(){
  557. this.$http.get({
  558. api: 'api/store/detail/'+ this.goods_id,
  559. header: {
  560. Authorization: this.token
  561. }
  562. }).then(res => {
  563. console.log("===---", res);
  564. let meta = res.data.meta;
  565. let goods_detail = res.data.data;
  566. this.goods_detail = goods_detail;
  567. this.pictures = [res.data.data.img];
  568. this.is_collect = Boolean(res.data.data.is_collect) || false;
  569. let type = 'mail';
  570. if(this.$isRight(goods_detail.is_largess)){
  571. type = 'point';
  572. }
  573. if(this.$isRight(meta.seckill)){
  574. type = 'seckill';
  575. this.seckill = meta.seckill;
  576. let currentDate = this.$shared.recordTime();
  577. this.time = new Date(meta.seckill.ends_at).getTime() - new Date(currentDate).getTime()
  578. console.log("time", this.time, meta.seckill.ends_at, currentDate)
  579. }
  580. if(type != 'point'){
  581. this.getBrandDetail(goods_detail.brand_id);
  582. }
  583. if(this.$isRight(meta.discounts)){
  584. this.coupons = meta.discounts.coupons;
  585. }
  586. this.type = type;
  587. }).catch(err => {
  588. console.log("====", err);
  589. })
  590. },
  591. // 获取商家信息
  592. getBrandDetail(brand_id){
  593. this.$http.get({
  594. api: 'api/brand/detail',
  595. data: {
  596. brand_id: brand_id
  597. },
  598. header: {
  599. Authorization: this.token
  600. }
  601. }).then(res => {
  602. this.brand_detail = res.data.data;
  603. })
  604. },
  605. // 获取商品库存信息
  606. getGoodsStock(){
  607. this.$http.get({
  608. api: `api/store/detail/${this.goods_id}/stock`
  609. }).then(res => {
  610. let data = res.data.data;
  611. for(let i in data.specs){
  612. data.specs[i].spec_current = null;
  613. }
  614. this.goods_stock = data;
  615. })
  616. },
  617. // 拨打电话
  618. makePhoneCall(phoneStr){
  619. uni.makePhoneCall({
  620. phoneNumber: String(phoneStr)
  621. })
  622. },
  623. // 打开地图 PS.暂时用不到
  624. openMap(){
  625. let { address, lat, lng } = this.goods_detail?.store || {};
  626. uni.openLocation({
  627. longitude: Number(lat),
  628. latitude: Number(lng),
  629. scale: 20,
  630. name: address
  631. });
  632. },
  633. // 预览图片
  634. lookImg(index){
  635. this.$u.throttle(() => {
  636. let banners = this.pictures;
  637. uni.previewImage({
  638. urls: banners,
  639. current: index
  640. })
  641. }, 200);
  642. },
  643. // 倒计时结束
  644. dateFinish(){
  645. this.is_date_finish = true;
  646. },
  647. // 富文本处理
  648. formatRichText(richText){
  649. if(richText != null){
  650. let newRichText= richText.replace(/<img[^>]*>/gi, function(match, capture){
  651. match = match.replace(/style="[^"]+"/gi, '').replace(/style='[^']+'/gi, '');
  652. match = match.replace(/width="[^"]+"/gi, '').replace(/width='[^']+'/gi, '');
  653. match = match.replace(/height="[^"]+"/gi, '').replace(/height='[^']+'/gi, '');
  654. return match;
  655. });
  656. newRichText = newRichText.replace(/style="[^"]+"/gi,function(match, capture){
  657. match = match.replace(/width:[^;]+;/gi, 'width:100%;').replace(/width:[^;]+;/gi, 'width:100%;');
  658. return match;
  659. });
  660. newRichText = newRichText.replace(/<br[^>]*\/>/gi, '');
  661. newRichText = newRichText.replace(/\<img/gi, '<img style="width:100%;height:auto;display:block;margin:10px 0;"');
  662. return newRichText;
  663. }else{
  664. return null;
  665. }
  666. }
  667. },
  668. onShareAppMessage(){
  669. let goods = this.goods_detail;
  670. let title = goods.name;
  671. let imageUrl = goods.share_cover || goods.cover || goods.img;
  672. let path = '/pages/route/index?route=detail&id='+ goods.id;
  673. return {
  674. title,
  675. path,
  676. imageUrl
  677. }
  678. }
  679. }
  680. </script>
  681. <style>
  682. page{
  683. background-color: #f5f5f5;
  684. overflow-x: hidden;
  685. }
  686. </style>
  687. <style lang="scss" scoped="scoped">
  688. //商品上去scrollview部分
  689. .scroll-view{
  690. height: 310rpx;
  691. width: 100%;
  692. // margin-top: 20rpx;
  693. padding: 0 30rpx 30rpx 30rpx;
  694. background-color: white;
  695. .scroll-content{
  696. display: flex;
  697. width: 100%;
  698. .goods-item{
  699. margin-right: 15rpx;
  700. width: 180rpx;
  701. }
  702. .goods-img{
  703. width: 180rpx;
  704. height: 180rpx;
  705. background-color: #EEEEEE;
  706. }
  707. .goods-info{
  708. text-align: center;
  709. color: #222222;
  710. &>view:nth-child(1n){
  711. font-size: 24rpx;
  712. }
  713. &>view:nth-child(2n){
  714. font-size: 28rpx;
  715. font-weight: bold;
  716. text-align: left;
  717. color: #F63434;
  718. }
  719. }
  720. .more-box{
  721. width: 180rpx;
  722. height: 180rpx;
  723. background-color: #EEEEEE;
  724. text-align: center;
  725. line-height: 180rpx;
  726. font-size: 24rpx;
  727. }
  728. }
  729. }
  730. //scrollview结束
  731. .tag-father {
  732. position: relative;
  733. }
  734. .head-tag {
  735. color: white;
  736. display: flex;
  737. align-items: center;
  738. justify-content: center;
  739. text-align: center;
  740. font-size: 24rpx;
  741. width: 36rpx;
  742. height: 36rpx;
  743. border-radius: 50%;
  744. background-color: #15716E;
  745. border: 1rpx solid #FFFFFF;
  746. position: absolute;
  747. left: 76rpx;
  748. top: 86rpx;
  749. z-index: 99;
  750. }
  751. .qzone-img {
  752. width: 220rpx;
  753. height: 220rpx;
  754. border-radius: 10rpx;
  755. margin-right: 12rpx;
  756. &:nth-child(3n) {
  757. margin-right: 0;
  758. }
  759. &:nth-child(n + 4) {
  760. margin-top: 12rpx;
  761. }
  762. }
  763. .user-top {
  764. background-color: #F3F8F8;
  765. padding: 30rpx;
  766. display: flex;
  767. align-items: center;
  768. background-color: white;
  769. }
  770. .head-img {
  771. width: 80rpx;
  772. height: 80rpx;
  773. border-radius: 50%;
  774. }
  775. .head-btn {
  776. display: flex;
  777. width: max-content;
  778. height: 45rpx;
  779. background: white;
  780. border: 2rpx solid #15716E;
  781. align-items: center;
  782. font-size: 22rpx;
  783. color: #15716E;
  784. justify-content: space-between;
  785. border-radius: 35rpx;
  786. padding: 10rpx!important;
  787. }
  788. .swiper-box{
  789. width: 750rpx;
  790. height: 750rpx;
  791. background-color: #FFFFFF;
  792. position: relative;
  793. .seckill-box{
  794. position: absolute;
  795. bottom: 0;
  796. left: 0;
  797. display: flex;
  798. justify-content: space-between;
  799. align-items: center;
  800. padding: 0 32rpx;
  801. width: 100%;
  802. height: 77rpx;
  803. background-color: #15716E;
  804. color: #FFFFFF;
  805. font-size: 26rpx;
  806. }
  807. }
  808. .head-info{
  809. width: 750rpx;
  810. height: auto;
  811. box-sizing: border-box;
  812. padding: 0 32rpx;
  813. padding-top: 20rpx;
  814. background-color: #FFFFFF;
  815. // .price>view:nth-of-type(1){
  816. // color: #FF0000;
  817. // margin-right: 22rpx;
  818. // font-weight: bold;
  819. // }
  820. .price>view:nth-of-type(1){
  821. text-decoration: line-through;
  822. color: #777777;
  823. margin-right: 22rpx;
  824. }
  825. .price>view:nth-of-type(2){
  826. width: max-content;
  827. padding: 0 18rpx;
  828. height: 46rpx;
  829. background-color: #1998FE;
  830. border-radius: 10rpx;
  831. display: flex;
  832. justify-content: center;
  833. align-items: center;
  834. color: #FFFFFF;
  835. }
  836. .label-box{
  837. min-height: 130rpx;
  838. width: 100%;
  839. border-top: 1rpx solid #E5E5E5;
  840. display: flex;
  841. flex-wrap: wrap;
  842. padding: 30rpx 0 10rpx 0;
  843. .label-item{
  844. width: max-content;
  845. padding: 20rpx;
  846. height: 70rpx;
  847. border-radius: 10rpx;
  848. border: 2rpx solid #1998FE;
  849. display: flex;
  850. justify-content: center;
  851. align-items: center;
  852. font-size: 28rpx;
  853. color: #1998FE;
  854. margin-right: 20rpx;
  855. margin-bottom: 20rpx;
  856. }
  857. }
  858. }
  859. .address-box{
  860. width: 750rpx;
  861. height: auto;
  862. box-sizing: border-box;
  863. background-color: #FFFFFF;
  864. padding: 32rpx;
  865. margin-top: 20rpx;
  866. .shop-img{
  867. width: 60rpx;
  868. height: 60rpx;
  869. border-radius: 50%;
  870. }
  871. }
  872. .goods-detail{
  873. width: 750rpx;
  874. height: auto;
  875. background-color: #FFFFFF;
  876. padding: 32rpx;
  877. box-sizing: border-box;
  878. margin-top: 20rpx;
  879. .goods-img{
  880. width: 100%;
  881. }
  882. }
  883. .extra{
  884. width: 100%;
  885. height: 110rpx;
  886. padding-bottom: constant(safe-area-inset-bottom);
  887. padding-bottom: env(safe-area-inset-bottom);
  888. box-sizing: content-box;
  889. }
  890. .fixed-bottom{
  891. position: fixed;
  892. bottom: 0;
  893. left: 0;
  894. background-color: #FFFFFF;
  895. width: 100%;
  896. height: auto;
  897. padding: 0 32rpx;
  898. border-top: 1rpx solid #e5e5e5;
  899. padding-bottom: constant(safe-area-inset-bottom);
  900. padding-bottom: env(safe-area-inset-bottom);
  901. .icon-item{
  902. text-align: center;
  903. margin-right: 16rpx;
  904. background-color: transparent;
  905. margin: 0;
  906. line-height: initial;
  907. font-size: 28rpx;
  908. font-weight: inherit;
  909. margin-right: 10rpx;
  910. padding: 0;
  911. width: 88rpx;
  912. position: relative;
  913. &:first-child{
  914. padding-left: 0;
  915. }
  916. .icon-img{
  917. height: 50rpx;
  918. width: 50rpx;
  919. font-size: 40rpx;
  920. line-height: 1;
  921. }
  922. }
  923. .btn1{
  924. margin: 0;
  925. width: max-content;
  926. height: 80rpx;
  927. background-color: rgba(21, 113, 110, 0.1);
  928. color: #15716E;
  929. line-height: 80rpx;
  930. font-size: 32rpx;
  931. padding: 0 20rpx;
  932. border-radius: 42rpx;
  933. font-size: 26rpx;
  934. border: 2rpx solid #15716E;
  935. }
  936. .btn{
  937. margin: 0;
  938. padding: 0 20rpx;
  939. width: max-content;
  940. height: 80rpx;
  941. background-color: #15716E;
  942. color: #FFFFFF;
  943. line-height: 80rpx;
  944. font-size: 26rpx;
  945. border-radius: 42rpx;
  946. }
  947. }
  948. .popup-content{
  949. height: max-content;
  950. width: 750rpx;
  951. background: #FFFFFF;
  952. border-radius: 20rpx 20rpx 0rpx 0rpx !important;
  953. padding: 40rpx 32rpx;
  954. max-height: 80vh;
  955. overflow-y: scroll;
  956. .popup-head{
  957. display: flex;
  958. justify-content: space-between;
  959. .goods-img{
  960. width: 150rpx;
  961. height: 150rpx;
  962. border-radius: 2rpx;
  963. margin-right: 20rpx;
  964. }
  965. .goods-info{
  966. width: 400rpx;
  967. height: 150rpx;
  968. display: flex;
  969. flex-direction: column;
  970. justify-content: space-around;
  971. .price{
  972. font-size: 48rpx;
  973. font-weight: bold;
  974. color: #F63434;
  975. line-height: 1;
  976. }
  977. .goods-name{
  978. font-size: 32rpx;
  979. color: #222222;
  980. line-height: 1.4;
  981. }
  982. }
  983. }
  984. .spec-title{
  985. font-size: 28rpx;
  986. color: #555555;
  987. margin-top: 40rpx;
  988. margin-bottom: 20rpx;
  989. }
  990. .spec-item{
  991. width: 142rpx;
  992. height: 64rpx;
  993. border-radius: 33rpx;
  994. border: 2rpx solid #555555;
  995. font-size: 28rpx;
  996. color: #555555;
  997. display: flex;
  998. justify-content: center;
  999. align-items: center;
  1000. margin-right: 20rpx;
  1001. &:nth-child(4n){
  1002. margin-right: 0rpx;
  1003. }
  1004. &:nth-child(n+5){
  1005. margin-top: 20rpx;
  1006. }
  1007. }
  1008. .spec-active{
  1009. border: none;
  1010. background-color: #15716E;
  1011. color: #FFFFFF;
  1012. }
  1013. .input{
  1014. width: 40rpx;
  1015. height: 45rpx;
  1016. border-radius: 2rpx;
  1017. background-color: #F3F8F7;
  1018. text-align: center;
  1019. }
  1020. .num-btn{
  1021. width: 36rpx;
  1022. }
  1023. .comfirm-btn{
  1024. width: 550rpx;
  1025. height: 100rpx;
  1026. background: #15716E;
  1027. border-radius: 50rpx;
  1028. color: #FFFFFF;
  1029. line-height: 100rpx;
  1030. margin-top: 62rpx;
  1031. }
  1032. }
  1033. </style>