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

1131 lines
30 KiB

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