goodsDetail.vue 31 KB

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