goodsDetail.vue 31 KB

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