goodsDetail.vue 31 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060
  1. <template>
  2. <view class="goods-detail-wrapper">
  3. <!-- <view @click="toHome" class="to-home-img">-->
  4. <!-- <u-icon size="24rpx" name="arrow-left" bold="true" color="#666666"></u-icon>-->
  5. <!-- </view>-->
  6. <u-swiper :list="detailData.slider" keyName="url"
  7. :indicatorStyle="{right: '20rpx', bottom: '20rpx', width: '100px',marginLeft: 'auto'}" indicator
  8. indicatorMode="number" height="100vw" imgMode="aspectFit">
  9. </u-swiper>
  10. <view class="content-box">
  11. <!-- 详情 -->
  12. <view class="common-card">
  13. <view class="display-flex-between ">
  14. <text class="fw700 title">
  15. {{ detailData.goods_name }}
  16. </text>
  17. <view class="display-flex-center">
  18. <view @click="collectHandler" style="display: flex;flex-direction: column; align-items: center;">
  19. <u-icon name="heart" size="50rpx"
  20. :color="goodsCollected ? '#F39800' : '#717171’'"></u-icon>
  21. <text class="fenxiang">
  22. 收藏
  23. </text>
  24. </view>
  25. <view @click="showPoster = true"
  26. style="margin-left: 30rpx;flex:1;display: flex;flex-direction: column; align-items: center;">
  27. <image style="width: 36rpx;height: 36rpx;margin: 8rpx 0" src="/static/fenxiang.png" mode="aspectFill">
  28. </image>
  29. <text class="fenxiang">
  30. 分享
  31. </text>
  32. </view>
  33. </view>
  34. </view>
  35. <view class="fs12 sub-title">{{ detailData.remark }}</view>
  36. <view class="display-flex-between">
  37. <view>
  38. <text class="fs12 fw400 color-556">
  39. </text>
  40. <text
  41. class="fs20 color-556 fw700">
  42. {{ goodsType == 'msGoods' ? detailData.price_seckill : detailData.price_selling }}
  43. </text>
  44. </view>
  45. </view>
  46. <view class="display-flex-between">
  47. <view>
  48. <text class="text-through fs12 color-666">¥{{ detailData.price_market }}</text>
  49. </view>
  50. <view class="fs12 color-666">销量:{{ detailData.stock_sales + detailData.stock_virtual }}件</view>
  51. </view>
  52. <!-- <view class="display-flex-center">-->
  53. <!-- <view class="tag-red mb5 mr5" v-if="detailData.limit_money">满额赠品(满{{detailData.limit_money}}元赠)-->
  54. <!-- </view>-->
  55. <!-- <view v-for="(item, index) in freeData" :key="index" class="tag-red mb5 mr5">{{item.sNum}}件包邮</view>-->
  56. <!-- </view>-->
  57. </view>
  58. <!-- 运费 -->
  59. <view v-if="detailData.truck_type == 1" class="common-card ">
  60. <view class="display-flex-between display-flex-center">
  61. <view>
  62. <text class="mr10 color-777 fs14">运费</text>
  63. <text class="color-333 fs14">¥{{ truckData.firstAmt || 0 }}</text>
  64. </view>
  65. <view class="color-777 fs14">已售 {{ detailData.stock_sales + detailData.stock_virtual }} | 剩余 {{ detailData.stock_total }}</view>
  66. </view>
  67. <u-divider></u-divider>
  68. <view @click="suitHandler" class=" display-flex-between display-flex-center">
  69. <view>
  70. <text class="mr10 color-777 fs14 ">已选</text>
  71. <text class="color-333 fs14">{{ selectSuitDisplay }}</text>
  72. </view>
  73. <u1-icon name="arrow-right" color="#3A3A3A"></u1-icon>
  74. </view>
  75. <!-- <view class="color-7a fs13">已售1 | 剩余150</view> -->
  76. <!-- <u1-icon name="arrow-right" color="#3A3A3A"></u1-icon> -->
  77. </view>
  78. <!-- 参数 -->
  79. <view class="common-card" style="padding: 0;">
  80. <u-sticky zIndex="90">
  81. <view style="background-color: #fff;">
  82. <u-tabs lineColor="#C29556 " line-width="36" lineHeight="3" :inactiveStyle="{
  83. fontWeight: '400',
  84. fontSize: '24rpx',
  85. color: '#333333',
  86. lineHeight: '40rpx'
  87. }" :activeStyle="{
  88. fontWeight: '400',
  89. fontSize: '28rpx',
  90. color: '#333333',
  91. lineHeight: '40rpx'
  92. }" :list="detailList" @click="detailClick"></u-tabs>
  93. </view>
  94. </u-sticky>
  95. <view style="padding: 40rpx 40rpx;">
  96. <view class="mb5 display-flex-center fw600" id="detail_0">
  97. <image src="/static/good_detail1.png" style="width: 30rpx;height: 30rpx;margin-right: 10rpx;"
  98. mode=""></image>
  99. <text>商品详情</text>
  100. </view>
  101. <u-parse :content="detailData.content"></u-parse>
  102. <view id="detail_1" class="mb5 mt10 display-flex-center fw600">
  103. <image src="/static/good_detail2.png" style="width: 30rpx;height: 30rpx;margin-right: 10rpx;"
  104. mode=""></image>
  105. <text>商品规格</text>
  106. </view>
  107. <u-parse :content="detailData.info"></u-parse>
  108. <view class="mb5 mt10 display-flex-center fw600" id="detail_2">
  109. <image src="/static/good_detail3.png" style="width: 30rpx;height: 30rpx;margin-right: 10rpx;"
  110. mode=""></image>
  111. <text>售后保障</text>
  112. </view>
  113. <u-parse :content="sell_serv"></u-parse>
  114. </view>
  115. </view>
  116. </view>
  117. <view class="bottom-navigation">
  118. <view class="bottom-navigation-div">
  119. <view style="width: 40rpx;margin-right: 30rpx" @click="toJump( 1)" >
  120. <van-image
  121. height="36rpx"
  122. src="/static/hd-icon-a.png"
  123. width="36rpx"
  124. style="display: flex;align-items: center; justify-content: center;"
  125. />
  126. <span>
  127. 首页
  128. </span>
  129. </view>
  130. <view style="width: 40rpx;position:relative;margin-right: 30rpx" open-type="contact">
  131. <van-image
  132. height="36rpx"
  133. src="/static/hd-icon-c.png"
  134. width="36rpx"
  135. style="display: flex;align-items: center; justify-content: center;"
  136. />
  137. <span>
  138. 客服
  139. </span>
  140. <button style="position: absolute;width: 100%;height: 100%;z-index: 999;opacity: 0;top:0;"
  141. open-type="contact" ></button>
  142. </view>
  143. <view style="width: 60rpx;margin-right: 30rpx;position:relative;" @click="toJump( 3)" >
  144. <van-image
  145. height="36rpx"
  146. src="/static/bottom-menu-cert.png"
  147. width="36rpx"
  148. style="display: flex;align-items: center; justify-content: center;"
  149. />
  150. <u-badge :absolute="true" bgColor="#CA9359" :offset="[-5,-5]" :value="cartNumber">
  151. </u-badge>
  152. <span>
  153. 购物车
  154. </span>
  155. </view>
  156. </view>
  157. <button class="add-cart-button" @click="toAddCert">加入购物车</button>
  158. <button class="submit-order-button" @click="toApply">提交订单</button>
  159. </view>
  160. <u-toast ref="createPosterLoading"></u-toast>
  161. <u-overlay :show="showPoster" :mask-click-able="false">
  162. <view class="poster-wrap">
  163. <image :src="posterImgSrc" mode="widthFix"></image>
  164. </view>
  165. <view class="poster-box">
  166. <view class="poster-btn">
  167. <view class="poster-btn-left">
  168. <image style="height: 26px;width 26px;" src="@/static/icon-wechat.png" mode="heightFix"/>
  169. <view>分享好友</view>
  170. <u-button open-type="share"
  171. customStyle="position: absolute;top:0;bottom:0;left:0;right:0;opacity: 0;">
  172. </u-button>
  173. </view>
  174. <view class="poster-btn-right" @click="downloadPoster">
  175. <u-icon name="download" color="#815BFF" size="36"></u-icon>
  176. <view>保存海报</view>
  177. </view>
  178. </view>
  179. <view class="cancel-btn" @click="showPoster = false">取消</view>
  180. </view>
  181. </u-overlay>
  182. <!-- 海报生成器 -->
  183. <l-painter ref="painter" isCanvasToTempFilePath @success="posterImgSrc = $event"
  184. css="width: 750rpx; background: #fff;padding: 20rpx" v-if="detailData.goods_name" hidden>
  185. <l-painter-image :src="`${imageUrl}home_logo.png`" css="display: block; width: 100%; height: 146rpx;"/>
  186. <l-painter-view css="display: block; padding: 43rpx 0 22rpx 0;">
  187. <l-painter-text :text="detailData.goods_name"
  188. css=" color: #1D161F; font-size: 36rpx; fontWeight: 500; line-height: 42rpx;"/>
  189. </l-painter-view>
  190. <l-painter-view css="position: relative; height: 580rpx;">
  191. <l-painter-image :src="detailData.cover" css="object-fit: contain; width: 100%; height: 100%;"/>
  192. </l-painter-view>
  193. <l-painter-view
  194. css="display: flex; align-items: center; justify-content: space-between; padding-top: 38rpx;">
  195. <l-painter-view css="flex: 1;">
  196. <l-painter-view>
  197. <l-painter-text css="font-size: 32rpx; font-weight: 500; color: #858585; line-height: 38rpx;"
  198. text="售价:"></l-painter-text>
  199. <l-painter-text css="font-size: 32rpx; font-weight: 500; color: #7B52C8; line-height: 38rpx;"
  200. :text="`¥${detailData.price_selling}`"></l-painter-text>
  201. </l-painter-view>
  202. <l-painter-view css="margin-top: 11rpx;">
  203. <l-painter-text
  204. css="display: block; font-size: 28rpx; font-weight: 500; color: #858585; line-height: 33rpx;"
  205. text="长按小程序码参与"></l-painter-text>
  206. </l-painter-view>
  207. </l-painter-view>
  208. <l-painter-image :src="erCodeImg" css="width: 200rpx; height: 200rpx;"/>
  209. </l-painter-view>
  210. </l-painter>
  211. <!-- 选套装 -->
  212. <u-popup :show="show" mode="bottom" :safeAreaInsetTop="true" round="10" closeable @close="close" @open="open">
  213. <view class="suit-content">
  214. <view class="display-flex-center mr20 mb30 ">
  215. <u--image :src="detailData.cover" width="176rpx" height="176rpx" ></u--image>
  216. <view class="ml15">
  217. <view v-if="pageOptions.type == 'msGoods'">
  218. <text class="fs12 color-556 fw400">¥</text>
  219. <text class="fs20 color-556 fw700 mr20">{{ (goodSuitPriceData.price || 0) * suitNum }}</text>
  220. </view>
  221. <view v-else>
  222. <text class="fs12 color-556 fw400">¥</text>
  223. <text class="fs20 color-556 fw700 mr20">{{ (goodSuitPriceData.price || 0) * suitNum }}</text>
  224. </view>
  225. <view class="color-777 mt5">
  226. <text>已选择 {{ selectSuitDisplay }}</text>
  227. </view>
  228. </view>
  229. </view>
  230. <!-- 普通商品规格 -->
  231. <template v-if="pageOptions.type == 'common'">
  232. <view v-for="(item, pIndex) in goodsSpecData" :key="pIndex">
  233. <view class="fw700 mb10">{{ item.name }}</view>
  234. <view class="suit-btn-box">
  235. <view class="suit-btn" @click="suitChange(suit, item)" :key="index"
  236. :class="[suit.isChecked ? 'suit-btn-active' : '']" v-for="(suit, index) in item.list">
  237. {{ suit.name }}
  238. </view>
  239. </view>
  240. </view>
  241. </template>
  242. <!-- 秒杀商品规格 -->
  243. <template v-else>
  244. <view class="suit-btn-box">
  245. <view class="suit-btn suit-btn-column" @click="suitChange(suit, item)" :key="index"
  246. :class="[suit.isChecked ? 'suit-btn-active' : '', suit.disabled ? 'suit-btn-disabled' : '']"
  247. v-for="(suit, index) in goodsSpecData">
  248. {{ suit.spec }}
  249. </view>
  250. </view>
  251. </template>
  252. <view class="common-btn" @click="submit">提交</view>
  253. </view>
  254. </u-popup>
  255. <login-pop v-model="showUserRegister" @updateUserInfo="reUserInfo"></login-pop>
  256. </view>
  257. </template>
  258. <script>
  259. import LoginPop from '@/components/LoginPop.vue'
  260. import {
  261. makeErCode
  262. } from "@/common/api/task.js";
  263. import {
  264. getGoodsDetail,
  265. getGiftGoodsDetail,
  266. getMsGoodsDetail,
  267. getPointsGoodsDetail,
  268. msGoodsCreateOrder,
  269. giftAddCart,
  270. addCollect,
  271. delCollect,
  272. checkCollect
  273. } from '@/common/api/good.js'
  274. export default {
  275. components: {
  276. LoginPop
  277. },
  278. data() {
  279. return {
  280. erCodeImg: '',
  281. pageOptions: {},
  282. totalDetailData: {},
  283. selectSuitData: {},
  284. currentSuitIndex: 0,
  285. suitNum: 1,
  286. show: false,
  287. freeData: [],
  288. imageUrl: this.$C.imageUrl,
  289. detailList: [{
  290. name: '商品详情'
  291. }, {
  292. name: '商品规格'
  293. }, {
  294. name: '售后保障'
  295. }],
  296. currentNum: 0,
  297. detailData: {},
  298. goodsSpecData: [],
  299. truckData: {},
  300. showPoster: false,
  301. posterImgSrc: "",
  302. selectedSuitPriceData: [],
  303. goodSuitPriceData: {
  304. price: 0
  305. },
  306. goodsType: 'common',
  307. currentOperateType: '', // 1:购物车,2:立即购买
  308. cartNumber: 0,
  309. sell_serv: '',
  310. isUserRegister: false,
  311. showUserRegister: false,
  312. goodsCollected: false,
  313. btn_color: null,
  314. }
  315. },
  316. computed: {
  317. beUsedCode() {
  318. return this.detailData.code
  319. },
  320. selectSuitDisplay() {
  321. console.log(2333, this.selectedSuitPriceData)
  322. if (this.goodsType == 'common') {
  323. let tempData = this.selectedSuitPriceData.map(item => {
  324. return `${item.group_name}:${item.spec_name}`
  325. })
  326. return tempData.join(',')
  327. } else if (this.goodsType == 'gift') {
  328. return this.detailData.goods_spec
  329. } else {
  330. return this.goodSuitPriceData.goods_spec
  331. }
  332. },
  333. currentTypeApi() {
  334. let result = {
  335. detailApi: getGoodsDetail,
  336. params: {
  337. goods_code: this.pageOptions.code
  338. }
  339. }
  340. switch (this.pageOptions.type) {
  341. case 'gift':
  342. result.detailApi = getGiftGoodsDetail
  343. break;
  344. case 'points':
  345. result.detailApi = getPointsGoodsDetail
  346. break;
  347. case 'msGoods':
  348. result = {
  349. detailApi: getMsGoodsDetail,
  350. params: {
  351. id: this.pageOptions.code
  352. }
  353. }
  354. break;
  355. default:
  356. break;
  357. }
  358. return result
  359. }
  360. },
  361. onLoad(options) {
  362. console.log("optionssuboacge==", options)
  363. this.pageOptions = options
  364. this.goodsType = options.type
  365. this.getAfterSalePage()
  366. this.maekErImg(options.code)
  367. const configs = uni.getStorageSync('configs')
  368. if (configs) {
  369. this.btn_color = configs.btn_color
  370. }
  371. this.$nextTick(() => {
  372. this.getDetail()
  373. this.getCartNumber()
  374. })
  375. },
  376. onShow() {
  377. this.reUserInfo()
  378. },
  379. onShareAppMessage(res) {
  380. if (res.from === 'button') { // 来自页面内分享按钮
  381. console.log(res.target)
  382. }
  383. let userInfo = uni.getStorageSync('userInfo')
  384. userInfo = userInfo && JSON.parse(userInfo) || {}
  385. if (userInfo.id) {
  386. this.pageOptions.id = userInfo.id
  387. }
  388. return {
  389. title: this.detailData.goods_name,
  390. path: `/subPages/goodsDetail/goodsDetail${this.$stringPageOptions(this.pageOptions)}`
  391. }
  392. },
  393. onShareTimeline() {
  394. let userInfo = uni.getStorageSync('userInfo')
  395. userInfo = userInfo && JSON.parse(userInfo) || {}
  396. const posterImage = this.detailData.video && this.detailData.slider.length > 1 ? this.detailData.slider[1]
  397. .url : this.detailData.slider[0].url
  398. if (userInfo.id) {
  399. this.pageOptions.id = userInfo.id
  400. }
  401. return {
  402. title: this.detailData.goods_name,
  403. path: `/subPages/goodsDetail/goodsDetail${this.$stringPageOptions(this.pageOptions)}`,
  404. imageUrl: posterImage
  405. }
  406. },
  407. watch: {
  408. goodsSpecData: {
  409. handler(nv) {
  410. console.log(9999, nv)
  411. let priceSuit = []
  412. if (this.goodsType == 'common') {
  413. nv.forEach(pItem => {
  414. let tempList = pItem.list.filter(item => item.isChecked)
  415. tempList = tempList.map(item => {
  416. return {
  417. group_name: item.group,
  418. spec_name: item.name
  419. }
  420. })
  421. priceSuit = priceSuit.concat(tempList)
  422. })
  423. this.selectedSuitPriceData = priceSuit
  424. this.getSuitPrice()
  425. } else if (this.goodsType == 'msGoods') {
  426. const checkedData = nv.find(item => item.isChecked)
  427. this.goodSuitPriceData = {
  428. price: checkedData.price_seckill,
  429. goods_spec: checkedData.goods_spec,
  430. sku_id: checkedData.id,
  431. }
  432. }
  433. },
  434. deep: true
  435. }
  436. },
  437. methods: {
  438. checkCollect() {
  439. checkCollect({
  440. code: this.detailData.code
  441. }).then(res => {
  442. this.goodsCollected = !!(res.data && res.data.id)
  443. console.log(this.goodsCollected)
  444. })
  445. },
  446. collectHandler() {
  447. if (!this.isUserRegister) {
  448. this.showUserRegister = true
  449. return
  450. }
  451. if (this.goodsCollected) {
  452. // 取消收藏
  453. delCollect({
  454. code: this.detailData.code
  455. }).then(res => {
  456. this.goodsCollected = false
  457. uni.showToast({
  458. title: '取消收藏'
  459. })
  460. })
  461. } else {
  462. // 收藏
  463. addCollect({
  464. code: this.detailData.code
  465. }).then(res => {
  466. this.goodsCollected = true
  467. uni.showToast({
  468. title: '收藏成功'
  469. })
  470. })
  471. }
  472. },
  473. detailClick(item) {
  474. console.log(item.index)
  475. uni.pageScrollTo({
  476. selector: `#detail_${item.index}`
  477. })
  478. },
  479. reUserInfo() {
  480. const userInfo = uni.getStorageSync("userInfo");
  481. if (
  482. userInfo &&
  483. JSON.parse(userInfo).vip_code == 1 &&
  484. JSON.parse(userInfo).nickname != "" &&
  485. JSON.parse(userInfo).headimg != ""
  486. ) {
  487. this.isUserRegister = true;
  488. } else {
  489. this.isUserRegister = false;
  490. }
  491. },
  492. getAfterSalePage() {
  493. this.$api.getData({
  494. id: 4
  495. }).then(res => {
  496. this.sell_serv = res.data.content
  497. })
  498. },
  499. suitHandler() {
  500. this.currentOperateType = ''
  501. if (this.goodsType != 'gift') {
  502. this.show = true
  503. }
  504. },
  505. getCartNumber() {
  506. this.$api.getCartNumber().then(res => {
  507. this.cartNumber = res.data.cart_num
  508. })
  509. },
  510. getSuitPrice() {
  511. this.$api.getPriceBySuit({
  512. goods_code: this.pageOptions.code,
  513. spec: this.selectedSuitPriceData
  514. }).then(res => {
  515. this.goodSuitPriceData = res.data
  516. })
  517. },
  518. toAddCert() {
  519. // 加入购物车
  520. if (!this.isUserRegister) {
  521. this.showUserRegister = true
  522. return
  523. }
  524. if (this.goodsType == 'gift') {
  525. giftAddCart({
  526. code: this.detailData.code
  527. }).then(res => {
  528. uni.showToast({
  529. title: '已加入购物车'
  530. })
  531. this.getCartNumber()
  532. })
  533. } else {
  534. this.currentOperateType = 1
  535. this.show = true
  536. }
  537. },
  538. maekErImg(code) {
  539. let that = this;
  540. const data = {
  541. path: '/subPages/goodsDetail/goodsDetail?code=' + code,
  542. type: 'file'
  543. // ['api-name']: 'wxapp',
  544. // ['api-token']: uni.getStorageSync(`token`)
  545. }
  546. this.$api.getQRCode(data).then(res => {
  547. console.log("base64==", res.data.base64)
  548. this.erCodeImg = res.data.url
  549. })
  550. },
  551. downloadPoster() {
  552. // console.log(222, this.posterImgSrc)
  553. // uni.saveImageToPhotosAlbum({
  554. // filePath: this.posterImgSrc,
  555. // complete:() => {
  556. // this.showPoster = false
  557. // }
  558. // })
  559. let _this = this
  560. this.$refs.painter.canvasToTempFilePathSync({
  561. fileType: "jpg",
  562. // 如果返回的是base64是无法使用 saveImageToPhotosAlbum,需要设置 pathType为url
  563. pathType: 'url',
  564. quality: 1,
  565. success: (res) => {
  566. console.log(res.tempFilePath);
  567. // 非H5 保存到相册
  568. // H5 提示用户长按图另存
  569. uni.saveImageToPhotosAlbum({
  570. filePath: res.tempFilePath,
  571. success: function () {
  572. uni.showToast({
  573. title: '保存成功'
  574. })
  575. _this.showPoster = false
  576. }
  577. });
  578. },
  579. })
  580. },
  581. handlePoster(showPoster) {
  582. if (showPoster) {
  583. this.$refs.createPosterLoading.show({
  584. type: 'loading',
  585. message: "海报生成中...",
  586. duration: 1000,
  587. complete: () => {
  588. this.showPoster = showPoster;
  589. }
  590. })
  591. return
  592. }
  593. this.showPoster = showPoster;
  594. // uni.showLoading({
  595. // title: '海报生成中...',
  596. // })
  597. // setTimeout(function () {
  598. // uni.hideLoading();
  599. // this.showPoster = true;
  600. // }, 1000);
  601. },
  602. suitChange(item, pItem) {
  603. if (item.disabled) return
  604. if (this.goodsType == 'common') {
  605. pItem.list.forEach(spec => [
  606. spec.isChecked = false
  607. ])
  608. } else {
  609. this.goodsSpecData.forEach(spec => {
  610. spec.isChecked = false
  611. })
  612. }
  613. item.isChecked = true
  614. // this.selectSuitData = item
  615. // this.currentSuitIndex = index
  616. },
  617. close() {
  618. this.show = false
  619. },
  620. open() {
  621. },
  622. getDetail() {
  623. this.currentTypeApi.detailApi(this.currentTypeApi.params).then(res => {
  624. const {
  625. goods = {}, items = [], truck = {}
  626. } = res.data
  627. this.totalDetailData = res.data
  628. // this.sell_serv = res.data.sell_serv
  629. this.detailData = goods
  630. console.log(res.data.free)
  631. this.freeData = res.data.free || []
  632. this.truckData = truck.content && truck.content.length ? truck.content[0].rule : {}
  633. this.selectSuitData = items || []
  634. let data_specs = []
  635. if (this.goodsType == 'common') {
  636. data_specs = this.detailData.data_specs
  637. if (Array.isArray(data_specs)) {
  638. data_specs.forEach(pItem => {
  639. pItem.list = pItem.list.map((item, index) => {
  640. if (index === 0) {
  641. this.$set(item, 'isChecked', true)
  642. } else {
  643. this.$set(item, 'isChecked', false)
  644. }
  645. return item
  646. })
  647. })
  648. }
  649. } else if (this.goodsType == 'msGoods') {
  650. data_specs = res.data.items
  651. this.detailData.price_seckill = res.data.price_seckill
  652. if (Array.isArray(data_specs)) {
  653. data_specs.forEach((pItem, index) => {
  654. const {
  655. status,
  656. stock_sale,
  657. stock
  658. } = pItem
  659. if (index === 0) {
  660. this.$set(pItem, 'isChecked', true)
  661. } else {
  662. this.$set(pItem, 'isChecked', false)
  663. }
  664. this.$set(pItem, 'disabled', !(status == 1 && stock_sale < stock))
  665. })
  666. }
  667. }
  668. this.goodsSpecData = data_specs
  669. console.log(99999, this.detailData)
  670. this.detailData.slider = this.detailData.slider.map(item => {
  671. return {
  672. url: item
  673. }
  674. })
  675. if (this.detailData.video) {
  676. this.detailData.slider.unshift({
  677. url: this.detailData.video
  678. })
  679. }
  680. this.checkCollect()
  681. }).catch(() => {
  682. uni.hideLoading()
  683. })
  684. },
  685. submit() {
  686. // console.log(2345, ths.selectSuitData)
  687. if (!this.isUserRegister) {
  688. this.showUserRegister = true
  689. return
  690. }
  691. if (this.currentOperateType === 1) {
  692. // 添加购物车
  693. this.$api.addToShoppingCart({
  694. sku_id: this.goodSuitPriceData.sku_id,
  695. num: this.suitNum
  696. }).then(res => {
  697. this.show = false
  698. uni.showToast({
  699. title: '已加入购物车'
  700. })
  701. this.getCartNumber()
  702. })
  703. } else if (this.currentOperateType === 2) {
  704. // this.show = false
  705. if (this.goodsType == 'common') {
  706. let specText = this.selectedSuitPriceData.map(item => {
  707. return `${item.group_name}::${item.spec_name}`
  708. })
  709. const sendData = {
  710. items: [{
  711. code: this.pageOptions.code,
  712. count: this.suitNum,
  713. spec: specText.join(';;')
  714. }]
  715. }
  716. this.$api.createOrder(sendData).then(res => {
  717. uni.showToast({
  718. title: '订单创建成功'
  719. })
  720. uni.navigateTo({
  721. url: `/subPages/settleCenter/settleCenter?orderNo=${res.data.order_no}`
  722. })
  723. })
  724. } else {
  725. // 秒杀下单
  726. const sendData = {
  727. sk_goods_id: this.pageOptions.code,
  728. goods_spec: this.goodSuitPriceData.goods_spec,
  729. num: this.suitNum
  730. }
  731. msGoodsCreateOrder(sendData).then(res => {
  732. uni.showToast({
  733. title: '订单创建成功'
  734. })
  735. uni.navigateTo({
  736. url: `/subPages/settleCenter/settleCenter?orderNo=${res.data.order_no}&type=msGoods`
  737. })
  738. })
  739. }
  740. } else {
  741. this.show = false
  742. }
  743. },
  744. toHome() {
  745. uni.navigateBack({
  746. delta: 1
  747. })
  748. },
  749. toApply() {
  750. // 立即购买去选择规格
  751. if (!this.isUserRegister) {
  752. this.showUserRegister = true
  753. return
  754. }
  755. this.currentOperateType = 2
  756. this.show = true
  757. },
  758. toJump( index) {
  759. if(index==1){
  760. uni.switchTab({
  761. url:'/pages/home/index'
  762. });
  763. }else if(index==3){
  764. if (!this.isUserRegister) {
  765. this.showUserRegister = true
  766. return
  767. }
  768. uni.switchTab({
  769. url:'/pages/shoppingCart/shoppingCart'
  770. });
  771. }
  772. },
  773. }
  774. }
  775. </script>
  776. <style lang="scss" scoped>
  777. ::v-deep {
  778. img {
  779. width: 100%;
  780. }
  781. }
  782. .poster-wrap {
  783. text-align: center;
  784. margin-top: 40rpx;
  785. }
  786. .poster-box {
  787. background-color: #F5F6F8;
  788. width: calc(100% - 120rpx);
  789. padding: 20rpx 60rpx 60rpx;
  790. position: absolute;
  791. bottom: 0;
  792. }
  793. .poster-btn {
  794. display: flex;
  795. justify-content: space-around;
  796. align-items: flex-end;
  797. font-size: 28rpx;
  798. text-align: center;
  799. &-left {
  800. position: relative
  801. }
  802. &-right {
  803. display: flex;
  804. flex-direction: column;
  805. align-items: center;
  806. }
  807. }
  808. .cancel-btn {
  809. height: 72rpx;
  810. border-radius: 80rpx;
  811. text-align: center;
  812. line-height: 72rpx;
  813. background-color: #fff;
  814. margin-top: 16rpx;
  815. }
  816. .goods-detail-wrapper {
  817. //margin-top: 60rpx;
  818. background-color: $primary-bg-color;
  819. padding-bottom: 146rpx;
  820. ::v-deep {
  821. .u-swiper-indicator {
  822. padding: 0 !important
  823. }
  824. }
  825. .to-home-img {
  826. position: absolute;
  827. left: 30rpx;
  828. top: 100rpx;
  829. border-radius: 52rpx;
  830. width: 52rpx;
  831. height: 52rpx;
  832. background-color: #F0F0F2;
  833. z-index: 1;
  834. // 上下左右居中
  835. display: flex;
  836. align-items: center;
  837. justify-content: center;
  838. font-weight: 700 !important;
  839. }
  840. .content-box {
  841. padding: 20rpx 20rpx 0;
  842. .title {
  843. line-height: 36rpx;
  844. font-size: 30rpx;
  845. }
  846. .sub-title {
  847. color: #717171;
  848. margin: 30rpx 0 24rpx;
  849. }
  850. .detail-title {
  851. display: flex;
  852. align-items: center;
  853. font-size: 28rpx;
  854. font-weight: 600;
  855. margin-bottom: 18rpx;
  856. .title-icon {
  857. width: 3rpx;
  858. height: 24rpx;
  859. background: linear-gradient(180deg, #9276FE 0%, rgba(217, 217, 217, 0) 100%);
  860. border-radius: 0rpx 0rpx 0rpx 0rpx;
  861. margin-right: 8rpx;
  862. }
  863. }
  864. }
  865. .bottom-part {
  866. position: fixed;
  867. bottom: 0;
  868. background-color: #fff;
  869. width: calc(100% - 60rpx);
  870. padding: 14rpx 30rpx 30rpx;
  871. display: flex;
  872. justify-content: space-between;
  873. z-index: 100;
  874. .bar-list {
  875. display: flex;
  876. width: calc(100% - 340rpx);
  877. // justify-content: space-between;
  878. font-size: 22rpx;
  879. text-align: center;
  880. color: #525051;
  881. }
  882. .bar-list-icon {
  883. position: relative;
  884. margin-right: 15rpx;
  885. }
  886. }
  887. }
  888. .common-btn {
  889. //width: 160rpx;
  890. //flex-shrink: 0;
  891. background: linear-gradient( 315deg, #CA9359 0%, #E2B98E 100%)!important;
  892. border-radius: 292rpx 292rpx 292rpx 292rpx!important;
  893. border:0;
  894. }
  895. .suit-content {
  896. padding: 0 40rpx 60rpx;
  897. max-height: 80vh;
  898. box-sizing: border-box;
  899. overflow-y: auto;
  900. .suit-btn-box {
  901. display: flex;
  902. // justify-content: space-between;
  903. .suit-btn {
  904. background-color: #F6F6F6;
  905. border-radius: 8rpx;
  906. border: 1rpx solid transparent;
  907. height: 76rpx;
  908. line-height: 76rpx;
  909. text-align: center;
  910. width: calc(33% - 20rpx);
  911. color: #232323;
  912. margin-right: 20rpx;
  913. box-sizing: border-box;
  914. margin-bottom: 40rpx;
  915. &-active {
  916. color: #C29556;
  917. background-color: #F9F2E6 ;
  918. }
  919. &-disabled {
  920. background-color: #fffafa;
  921. border-color: #d0d0d0;
  922. color: #ababab;
  923. }
  924. &-column {
  925. width: 100%;
  926. text-align: left;
  927. padding: 0 10rpx;
  928. flex-shrink: 0;
  929. }
  930. }
  931. }
  932. }
  933. .bottom-navigation{
  934. position: fixed;
  935. // 文字垂直居中
  936. display: flex;
  937. align-items: center;
  938. justify-content: center;
  939. bottom: 0;
  940. height: 100rpx;
  941. width: calc(100% - 40rpx);
  942. background: #FFFFFF;
  943. box-shadow: 0rpx -2rpx 0rpx 0rpx #F1F3F6;
  944. border-radius: 24rpx 24rpx 0rpx 0rpx;
  945. border: 0rpx solid #979797;
  946. padding: 20rpx 20rpx 68rpx 20rpx ;
  947. z-index: 100;
  948. &-div{
  949. height: 76rpx;
  950. width: 270rpx;
  951. // 文字垂直居中
  952. display: flex;
  953. align-items: center;
  954. padding-left: 30rpx;
  955. padding-top: 10rpx;
  956. span{
  957. font-family: PingFang SC, PingFang SC;
  958. font-weight: 400;
  959. font-size: 20rpx;
  960. color: #333333;
  961. line-height: 32rpx;
  962. text-align: left;
  963. font-style: normal;
  964. text-transform: none;
  965. }
  966. }
  967. .add-cart-button {
  968. width: 216rpx;
  969. height: 76rpx;
  970. background: linear-gradient( 315deg, #323130 0%, #575757 100%);;
  971. border-radius: 292rpx 292rpx 292rpx 292rpx;
  972. font-family: PingFang SC, PingFang SC;
  973. font-weight: 400;
  974. font-size: 28rpx;
  975. color: #FFFFFF;
  976. line-height: 36rpx;
  977. text-align: center;
  978. font-style: normal;
  979. text-transform: none;
  980. // 文字垂直居中
  981. display: flex;
  982. margin-right: 20rpx;
  983. align-items: center;
  984. justify-content: center;
  985. padding: 0;
  986. }
  987. .submit-order-button {
  988. width: 216rpx;
  989. height: 76rpx;
  990. background: linear-gradient(315deg, #CA9359 0%, #E2B98E 100%);
  991. border-radius: 292rpx 292rpx 292rpx 292rpx;
  992. font-family: PingFang SC, PingFang SC;
  993. font-weight: 400;
  994. font-size: 28rpx;
  995. color: #FFFFFF;
  996. line-height: 36rpx;
  997. text-align: center;
  998. font-style: normal;
  999. text-transform: none;
  1000. // 文字垂直居中
  1001. display: flex;
  1002. align-items: center;
  1003. justify-content: center;
  1004. padding: 0;
  1005. }
  1006. }
  1007. .fenxiang {
  1008. font-weight: 400;
  1009. font-size: 18rpx;
  1010. color: #333333;
  1011. line-height: 24rpx;
  1012. text-align: left;
  1013. font-style: normal;
  1014. text-transform: none;
  1015. }
  1016. </style>