puzzleGoodsInfo.vue 32 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109
  1. <template>
  2. <view class="container">
  3. <navbar :config="config" backColor="#666"></navbar>
  4. <view class="product">
  5. <view class="u-bg-fff pb40">
  6. <view class="pic">
  7. <!-- <image src="../../../static/delImg/product2.png" mode="aspectFill"></image> -->
  8. <swiper class="swiper" indicator-dots="true" autoplay="true" interval="5000" duration="1500" circular="true">
  9. <swiper-item v-if="dataForm.video_url">
  10. <!-- <video :src="dataForm.video_url"></video> -->
  11. <j-video class="jvideo" :url="dataForm.video_url" width="750rpx" height="620rpx"></j-video>
  12. </swiper-item>
  13. <swiper-item v-for="(item, index) in imglist" :key="index">
  14. <image :src="item" mode="aspectFill"></image>
  15. </swiper-item>
  16. </swiper>
  17. <view class="p-price">
  18. <view class="pd24 u-flex-center">
  19. <view class="u-FFF u-font36">
  20. <rich-text :nodes="$mUtil.priceBigSmall(dataForm.min_price)"></rich-text>
  21. </view>
  22. <text class="discount u-font24 u-ml20 u-del">¥{{ dataForm.max_sale_price }}</text>
  23. <text class="discount u-font24 u-ml15">{{ dataForm.discount }}折</text>
  24. <view v-if="dataForm.group_people_num>0">
  25. <text
  26. style="font-size: 22rpx;font-weight: 500; color: #053420;padding: 3rpx 14rpx;margin-left: 18rpx;background-color: #DCCDA4;border-radius: 20rpx;">
  27. {{dataForm.group_people_num}}人拼</text>
  28. </view>
  29. </view>
  30. <view class="p-ab u-flex-center">
  31. <view class="triangle-bottomright"></view>
  32. <view class="seckill u-text-center u-font28">
  33. <!-- active_state 0:未开始 * 1:进行中 * 2:已结束 -->
  34. <view class="u-bold" style="padding: 20rpx;" v-if="dataForm.active_state == 2">已结束
  35. </view>
  36. <view class="u-bold" v-if="dataForm.active_state == 1">距结束</view>
  37. <view class="u-bold" v-if="dataForm.active_state == 0">离开抢</view>
  38. <view v-if="dataForm.active_state != 2 ">
  39. <uni-countdown :backgroundColor="'none'" :color="'#0B844A'" :splitorColor="'#0B844A'"
  40. :show-day="time2[0] > 0" :day="time2[0]" :hour="time2[1]" :minute="time2[2]"
  41. :second="time2[3]"></uni-countdown>
  42. </view>
  43. </view>
  44. </view>
  45. </view>
  46. <view class="mt10 u-plr30">
  47. <view>
  48. <view class="tipsStatus" v-if="dataForm.platform_store">自营</view>
  49. <text class="u-font34 u-bold u-1A1A1A">{{ dataForm.title }}</text>
  50. </view>
  51. <view class="u-font24 u-mt15 u-999">
  52. <text>已售
  53. <text class="u-FF0000">{{ dataForm.result_sale_num }}</text>件,仅剩<text class="u-FF0000">{{
  54. dataForm.residue_stock_total
  55. }}</text>件</text>
  56. </view>
  57. <!--优惠-->
  58. <!-- <view
  59. class="bg-FFF6EE pd20 u-mt20 u-flex-center br-rd10"
  60. v-if="shopDiscounts.is_use == true"
  61. >
  62. <view class="u-FF0000 br-FF0000 u-font24">首单优惠</view>
  63. <view class="u-ml15 u-font24 u-CA7E57"
  64. >满{{ shopDiscounts.full }}元减{{
  65. shopDiscounts.reduction
  66. }}元</view
  67. >
  68. </view> -->
  69. </view>
  70. </view>
  71. </view>
  72. <view class="u-bg-fff u-mt10">
  73. <view class="u-plr30 u-flex-center-sb pt-pb35">
  74. <view class="u-flex-center">
  75. <view @click="goShop">
  76. <image class="u-avatar104" :src="shop.logo"></image>
  77. </view>
  78. <view class="u-ml25">
  79. <view class="u-font28 u-1A1A1A u-bold">{{ shop.shop_name }} </view>
  80. <view class="u-999 u-font24 u-mt5 u-text2" @click="goLocal">
  81. <text class="iconfont u-193E2C">&#xe6db;</text>
  82. {{ shop.province_name }}{{ shop.city_name }}{{ shop.area_name
  83. }}{{ shop.address }}
  84. </view>
  85. </view>
  86. </view>
  87. <view class="iconfont" @click="goShop">&#xe6c7;</view>
  88. </view>
  89. </view>
  90. <view class="u-bg-fff u-mt10">
  91. <view class="tab u-flex-center-sa u-font30 u-1A1A1A u-border-one-one">
  92. <view @tap="change(0)" class="pb30" :class="{ active: isChecked == 0 }">商品详情</view>
  93. <view @tap="change(1)" class="pb30" :class="{ active: isChecked == 1 }">
  94. 用户评论({{ commentList.length }})</view>
  95. </view>
  96. <view class="u-mt10">
  97. <!--商品详情-->
  98. <view v-if="isChecked == 0">
  99. <view class="richText ql-editor-box">
  100. <rich-text :nodes="goodsInfo.mobile_detail"></rich-text>
  101. <!-- <jyf-parser :html="$mUtil.formatRichText(goodsInfo.mobile_detail)" ref="article">
  102. </jyf-parser> -->
  103. </view>
  104. </view>
  105. <!--评论-->
  106. <view class="u-plr30" v-else>
  107. <comment :value="commentList"></comment>
  108. </view>
  109. </view>
  110. </view>
  111. </view>
  112. <view class="bottom-btn u-bg-fff">
  113. <view class="pt-pb30 u-plr30 u-flex-center-sb">
  114. <button @click="share" open-type="share" class="u-text-center" style="line-height: normal">
  115. <view class="iconfont u-font40 u-999">&#xe6b1;</view>
  116. <view class="u-font28 u-1A1A1A">分享</view>
  117. </button>
  118. <!-- 三个按钮 -->
  119. <view class="u-flex-center">
  120. <button class="gb-btn btn-bg-dccda4 u-00321E" @click="goProduct(dataForm.goods_id)">
  121. <view>
  122. <view class="u-font36 u-bold">
  123. <rich-text :nodes="$mUtil.priceBigSmall(dataForm.min_sale_price)"></rich-text>
  124. </view>
  125. </view>
  126. <view class="u-font22">单独购买</view>
  127. </button>
  128. <button class="gb-btn btn-bg-00320E u-DCCDA4" @click="groupGoBuy">
  129. <view>
  130. <view class="u-font36 u-bold">
  131. <rich-text :nodes="$mUtil.priceBigSmall(dataForm.min_price)"></rich-text>
  132. </view>
  133. </view>
  134. <view class="u-font22">发起拼团</view>
  135. </button>
  136. <button class="gb-btn btn-bg-dccda4 u-00321E" @click="goGdProduct(dataForm.goods_id)">
  137. <view>
  138. <view class="u-font36 u-bold">
  139. <rich-text :nodes="$mUtil.priceBigSmall(dataForm.min_price)"></rich-text>
  140. </view>
  141. </view>
  142. <view class="u-font22">去拼团</view>
  143. </button>
  144. </view>
  145. </view>
  146. </view>
  147. <!--规格-->
  148. <uniPopup type="bottom" ref="specOpen" :touchmove="true">
  149. <view class="u-bg-fff spec">
  150. <view class="u-plr30 flex-sb u-border-one-one pb30">
  151. <view class="u-flex-center">
  152. <image class="u-goods200" :src="choseConfig.cover ? choseConfig.cover : cover"></image>
  153. <view class="u-ml20">
  154. <view class="u-999 u-font24 u-flex-center">
  155. <view class="u-FF0000 u-font36">
  156. <rich-text :nodes="
  157. $mUtil.priceBigSmall(
  158. choseConfig.activity_price
  159. ? choseConfig.activity_price
  160. : moPrice
  161. )
  162. "></rich-text>
  163. </view>
  164. <text class="u-del u-ml15">¥{{
  165. choseConfig.market_price
  166. ? choseConfig.market_price
  167. : moDelPrice
  168. }}
  169. </text>
  170. <!-- <text class="u-ml10">{{ dataForm.discount }}折</text> -->
  171. </view>
  172. <view class="u-font22 u-999 u-mt5">库存 {{ stock }} 件</view>
  173. <view class="u-1A1A1A u-mt25">{{
  174. choseConfig.sku_set_name ? choseConfig.sku_set_name : "请选择"
  175. }}
  176. </view>
  177. </view>
  178. </view>
  179. <view class="iconfont u-999 closeIcon" @click="specOpenClose">&#xe612;</view>
  180. </view>
  181. <view>
  182. <view class="content">
  183. <scroll-view scroll-y="true" style="height: 400rpx">
  184. <view class="overHeight">
  185. <view class="u-mt30" v-for="(item, index) in skuTab" :key="item.head.id">
  186. <view class="u-plr30">{{ item.head.name }}</view>
  187. <view class="u-mt20 u-border-one-one pb30">
  188. <view class="u-plr30 u-flex u-flex-warp">
  189. <view class="spec-item" :class="childrenItem.flag ? 'activeColor' : ''"
  190. @click="chonseSku(index, childrenItem.id)" v-for="childrenItem in item.values"
  191. :key="childrenItem.id">
  192. {{ childrenItem.name }}
  193. </view>
  194. </view>
  195. </view>
  196. </view>
  197. </view>
  198. </scroll-view>
  199. </view>
  200. <view class="u-plr30 u-mt30">
  201. <view class="u-flex-center-sb">
  202. <view>购买数量</view>
  203. <view class="u-flex-center">
  204. <view class="iconfont minus" @click="resNum">&#xe60b;</view>
  205. <view class="num">{{ add_num }}</view>
  206. <view class="iconfont plus-sign" @click="addNum">&#xe686;</view>
  207. </view>
  208. </view>
  209. <view class="specOpen-btn">
  210. <view v-if="btnType == 0">
  211. <button class="u-btn-two" @click="btnBuy(btnType)">
  212. 立即购买
  213. </button>
  214. </view>
  215. <view v-else>
  216. <button class="u-btn-two" @click="btnBuy(btnType)">
  217. 立即购买
  218. </button>
  219. </view>
  220. </view>
  221. </view>
  222. </view>
  223. </view>
  224. </uniPopup>
  225. <!--更多拼团-->
  226. <uniPopup type="center" ref="gbOpen">
  227. <view class="iconfont u-text-right u-font40 u-FFF" @click="gbClose">&#xe603;</view>
  228. <view class="u-bg-D5C49B u-mt30 br-rd20">
  229. <view class="br-284534">
  230. <view class="u-text-center gb-te">正在拼团</view>
  231. </view>
  232. <view class="gb-list pb50">
  233. <view class="gb-item u-plr30" v-for="item in teamlist" :key="item.id">
  234. <view class="u-flex-center-sb br-284534 pt28-pb18">
  235. <view class="u-flex-center u-00321E">
  236. <image class="u-avatar65" v-if="item.leader_user_info.head_photo" :src="item.leader_user_info.head_photo"></image>
  237. <image class="u-avatar65" v-else src="/static/default-avatar.png" mode=""></image>
  238. <view class="u-ml25">
  239. <view class="u-font24">{{
  240. item.leader_user_info.nickname
  241. }}</view>
  242. <view class="u-font20">
  243. <text>还差</text>
  244. <text class="u-FF0000">{{
  245. item.group_person_number - item.member_user_infos.length
  246. }}</text>
  247. <text>人拼成</text>
  248. <view class="u-flex-start" style="display: flex">
  249. <view class="u-707070">剩余</view>
  250. <view class="u-FF0000">
  251. <uni-countdown :backgroundColor="'none'" :color="'#0B844A'" :splitorColor="'#0B844A'"
  252. :show-day="item.time[0] > 0" :day="item.time[0]" :hour="item.time[1]" :minute="item.time[2]"
  253. :second="item.time[3]" @timeup="overDown2"></uni-countdown>
  254. </view>
  255. </view>
  256. </view>
  257. </view>
  258. </view>
  259. <view class="u-FFF stb-btn u-font24 ml54" @click="gogroup(item)">我要参团</view>
  260. </view>
  261. </view>
  262. </view>
  263. </view>
  264. </uniPopup>
  265. <!--页面加载动画-->
  266. <ldLoading isFullScreen :active="loading"></ldLoading>
  267. <share ref="shares" :contentHeight="580" v-if="isvisible"></share>
  268. </view>
  269. </template>
  270. <script>
  271. import uniPopup from "../../../components/uni-popup/uni-popup.vue";
  272. import comment from "../../../components/ld-comment/ld-comment.vue";
  273. import jyfParser from "../../../components/jyf-parser/jyf-parser";
  274. import share from "./../../public/share";
  275. import jVideo from "../../../components/j-video/j-video.vue"
  276. export default {
  277. components: {
  278. uniPopup,
  279. comment,
  280. jyfParser,
  281. share,
  282. jVideo
  283. },
  284. data() {
  285. return {
  286. config: {
  287. back: true, //false是tolbar页面 是则不写
  288. title: "商品详情",
  289. color: "#1a1a1a",
  290. //背景颜色;参数一:透明度(0-1);参数二:背景颜色(array则为线性渐变,string为单色背景)
  291. backgroundColor: [1, "#ffffff"],
  292. backTabPage: "",
  293. },
  294. imglist: [], //详情图片数组
  295. isChecked: 0,
  296. btnName: "",
  297. btnType: "", //0 购物车,1 立即购买
  298. dataForm: {}, //商品详情
  299. shop: {}, //店铺信息
  300. shopDiscounts: {}, //店铺首单优惠
  301. stock: 0,
  302. cover: "",
  303. loading: true,
  304. moDelPrice: "",
  305. moPrice: "",
  306. goodsSkuList: [], //sku组合值
  307. skuTab: [], //sku二位数组
  308. goods_id: null,
  309. limit_buy_num: 0,
  310. choseConfig: {},
  311. hasId: "",
  312. add_num: 1,
  313. goStatus: 0, //0:购物车,1下单
  314. shop_id: 0,
  315. commentList: [],
  316. goodsInfo: {},
  317. time1: [0, 0, 0, 0],
  318. time2: [0, 0, 0, 0],
  319. teamlist: [],
  320. selectGroup: null,
  321. show: false,
  322. teamId: null,
  323. isvisible: false,
  324. backoffid: null
  325. };
  326. },
  327. onShow() {
  328. var pages = getCurrentPages();
  329. var prevPage = pages[pages.length - 2];
  330. if (prevPage == undefined) {
  331. // this.config.backTabPage = "/pages/research/homepage/lidaPage";
  332. }
  333. },
  334. onLoad(options) {
  335. this.time2 = this.$mUtil
  336. .countDown(Math.floor(1620726251))
  337. .split(":").map(val => Number(val));
  338. console.log(this.time2)
  339. //当用户进来有缓存店铺
  340. // this.selectGroup = options.shareId
  341. //店铺推荐(商品)
  342. if (options.id) {
  343. this.backoffid = options.id
  344. this.getDetailInfo(options.id);
  345. }
  346. if (options.teamId) {
  347. this.teamId = options.teamId;
  348. }
  349. if (options.shareId) {
  350. this.recordSave(options.shareId, options.id)
  351. }
  352. },
  353. onShareAppMessage(res) {
  354. if (res.from === "button") {
  355. // 来自页面内分享按钮
  356. console.log(res.target);
  357. }
  358. return {
  359. title: this.shareTitle,
  360. imageUrl: this.shareImg,
  361. path: `/pages/product/goods/puzzleGoods?id=${this.dataForm.id}&Sshopid=${this.shop_id}&teamId=${this.selectGroup.id}`,
  362. };
  363. },
  364. methods: {
  365. goLocal() {
  366. uni.openLocation({
  367. latitude: Number(this.shop.tx_latitude),
  368. longitude: Number(this.shop.tx_longitude),
  369. // name:shop.name,
  370. // address: shop.address,
  371. success: function() {
  372. console.log("success");
  373. },
  374. });
  375. },
  376. goShop() {
  377. uni.navigateTo({
  378. url: "/pages/research/homepage/shopHomepage?shopId=" + this.shop_id,
  379. });
  380. },
  381. recordSave(share_user_id, goods_id) {
  382. this.$http.post('/share/record/save', {
  383. share_user_id: share_user_id,
  384. goods_id: goods_id
  385. }).then(res => {
  386. })
  387. },
  388. share() {
  389. this.isvisible = false
  390. let token = uni.getStorageSync("apiToken")
  391. if (!token) {
  392. uni.navigateTo({
  393. url: "/pages/login/index"
  394. })
  395. } else {
  396. let user = uni.getStorageSync('personal')
  397. this.isvisible = true;
  398. this.$nextTick(() => {
  399. this.$refs.shares.shareInfo('/?pageType=1&type=3&id=' + this.dataForm.id + '&shareId=' +
  400. user.id, 'pages/down', this.dataForm.title, '', this.dataForm.cover);
  401. })
  402. }
  403. },
  404. /**发起拼团 */
  405. groupGoBuy() {
  406. uni.navigateTo({
  407. url: "./puzzleGoods?id=" + this.backoffid
  408. })
  409. // this.selectGroup = null;
  410. // this.getTeam();
  411. },
  412. /**去拼团 */
  413. gogroup(item) {
  414. this.$refs.gbOpen.close();
  415. this.btnType = 1;
  416. this.selectGroup = item;
  417. this.time2 = this.$mUtil
  418. .countDown(Math.floor(this.selectGroup.end_time / 1000))
  419. .split(":").map(val => Number(val));
  420. // this.checkSku(item.group_buy_goods_id);
  421. },
  422. goGdProduct() {
  423. this.checkSku(this.selectGroup.group_buy_goods_id);
  424. },
  425. overDown2() {
  426. this.getTeam();
  427. },
  428. // 获取主页数据
  429. getIndexList(shopid) {
  430. this.$http.get("/yxt/shop/info/" + shopid).then((res) => {
  431. uni.stopPullDownRefresh();
  432. this.loading = false;
  433. if (res.data && res.code == 200) {
  434. this.shop = res.data;
  435. }
  436. });
  437. },
  438. getByShop(id) {
  439. //店铺优惠查询
  440. this.$http.get("/marketing/firstOrder/getByShop/" + id).then((res) => {
  441. if (res && res.code == 200) {
  442. this.shopDiscounts = res.data;
  443. }
  444. });
  445. },
  446. getTeam() {
  447. this.$http
  448. .get(`/groupbuy/team/list/${this.shop_id}/${this.dataForm.id}`)
  449. .then((res) => {
  450. if (res && res.code == 200) {
  451. res.list.forEach((val) => {
  452. val.time = this.$mUtil
  453. .countDown(Math.floor(val.end_time / 1000))
  454. .split(":").map(val => Number(val));
  455. });
  456. this.teamlist = res.list;
  457. // console.log(res.list)
  458. if (this.teamId) {
  459. this.btnType = 1;
  460. this.selectGroup = this.teamlist.filter(
  461. (val) => val.id == this.teamId
  462. )[0];
  463. console.log("团队信息2" + JSON.stringify(this.selectGroup));
  464. this.time2 = this.$mUtil
  465. .countDown(Math.floor(this.selectGroup.end_time / 1000))
  466. .split(":").map(val => Number(val));
  467. }
  468. }
  469. });
  470. },
  471. getDetailInfo(id) {
  472. this.$http.get("/groupbuy/activitygoods/goodsInfo/" + id).then((res) => {
  473. this.loading = false;
  474. if (res && res.code == 200) {
  475. this.dataForm = res.data;
  476. this.shop_id = res.data.shop_id;
  477. this.imglist = res.data.cover.split(",");
  478. this.getByShop(this.shop_id);
  479. this.getIndexList(this.shop_id);
  480. // active_state 0:未开始 * 1:进行中 * 2:已结束
  481. if (res.data.active_state == 0) {
  482. this.time1 = this.$mUtil
  483. .countDown(res.data.activity_start_time)
  484. .split(":").map(val => Number(val));
  485. } else {
  486. this.time1 = this.$mUtil
  487. .countDown(res.data.finish_time)
  488. .split(":")
  489. .map((val) => Number(val));
  490. }
  491. this.$http
  492. .get(`/goods/content/${this.dataForm.goods_id}`)
  493. .then((res) => {
  494. if (res && res.code == 200) {
  495. this.goodsInfo = res.data;
  496. this.$http
  497. .get("/marketing/firstOrder/getByShop/" + this.shop_id)
  498. .then((res) => {
  499. if (res && res.code == 200) {
  500. this.shopDiscounts = res.data;
  501. }
  502. });
  503. }
  504. });
  505. this.$http
  506. .get(
  507. `/comment/orderGoods/getgoodscomments/${this.dataForm.goods_id}`
  508. )
  509. .then((res) => {
  510. if (res && res.code == 200) {
  511. this.commentList = res.list;
  512. }
  513. });
  514. this.getTeam();
  515. }
  516. });
  517. },
  518. goProduct(id) {
  519. uni.navigateTo({
  520. url: "./goods?id=" + id,
  521. });
  522. },
  523. goTocart() {
  524. uni.navigateTo({
  525. url: "/pages/index/shop",
  526. });
  527. },
  528. //点击拼团更多
  529. goGb() {
  530. this.$refs.gbOpen.open();
  531. },
  532. //点击关闭
  533. gbClose() {
  534. this.$refs.gbOpen.close();
  535. },
  536. //评论,商品详情切换
  537. change(i) {
  538. this.isChecked = i;
  539. },
  540. //点购物车,立即购买
  541. buy(i, id) {
  542. this.btnType = i;
  543. this.selectGroup = null;
  544. this.checkSku(id);
  545. if (i == 0) {
  546. this.btnName = "加入购物车";
  547. } else {
  548. this.btnName = "立即购买";
  549. }
  550. },
  551. // 减数量
  552. resNum() {
  553. if (this.add_num > 1) {
  554. this.add_num--;
  555. }
  556. },
  557. //加数量
  558. addNum() {
  559. this.add_num++;
  560. },
  561. chonseSku(index, id) {
  562. this.skuTab[index].values.forEach((res) => {
  563. res.flag = false;
  564. if (res.id == id) {
  565. res.flag = true;
  566. }
  567. });
  568. let choseId = [];
  569. this.skuTab.forEach((res) => {
  570. res.values.forEach((Key) => {
  571. if (Key.flag) {
  572. choseId.push(Key.id);
  573. }
  574. });
  575. });
  576. let totalId = choseId.join("|");
  577. this.hasId = totalId;
  578. this.goodsSkuList.forEach((res) => {
  579. if (res.sku_hash_code == totalId) {
  580. this.choseConfig = res;
  581. this.stock = this.dataForm.real_stock_total;
  582. this.able_stock = res.able_stock;
  583. }
  584. });
  585. },
  586. //查询sku
  587. checkSku(id) {
  588. this.$http
  589. .get(`/groupbuy/activitygoods/skus/${this.dataForm.id}`)
  590. .then((res) => {
  591. this.loading = false;
  592. if (res && res.code == 200) {
  593. this.choseConfig = {};
  594. this.hasId = ''
  595. res.data.goods.sku_table.forEach((keys) => {
  596. keys.values.forEach((val) => {
  597. val.flag = false;
  598. });
  599. });
  600. this.limit_buy_num = this.dataForm.limit_buy_num;
  601. this.goods_id = this.dataForm.goods_id;
  602. this.goodsSkuList = res.data.goods_sku_list;
  603. this.moPrice = this.dataForm.min_price;
  604. this.moDelPrice = this.dataForm.min_sale_price;
  605. this.cover = this.imglist[0];
  606. this.stock = this.dataForm.real_stock_total;
  607. if (res.data.goods_auth) {
  608. if (res.data.goods_auth.added) {
  609. this.$refs.specOpen.open();
  610. } else {
  611. this.$mUtil.toast("该商品已经下架");
  612. }
  613. } else {
  614. this.$mUtil.toast("没有经营权限");
  615. }
  616. //只有没数据才去重新渲染sku的数据
  617. if (this.skuTab.length == 0) {
  618. this.skuTab = res.data.goods.sku_table;
  619. for (let i in this.skuTab) {
  620. //默认选中第一个可选项
  621. this.skuTab[i].values[0].flag = true;
  622. }
  623. //显示选中的sku信息
  624. this.chonseSku(0, this.skuTab[0].values[0].id);
  625. }
  626. // if(res.data.goods.sku_table.length>0){
  627. // this.$refs.specOpen.open()
  628. // }else{
  629. // this.hasId = ''
  630. // this.btnBuy()
  631. // }
  632. }
  633. });
  634. },
  635. //关闭规格弹窗
  636. specOpenClose() {
  637. // this.show=false
  638. this.$refs.specOpen.close();
  639. },
  640. //加入购物车
  641. btnBuys() {
  642. // 判断是否选中sku
  643. if (this.skuTab.length > 0 && this.hasId == "") {
  644. this.$mUtil.toast("请选中sku");
  645. return false;
  646. }
  647. // 判断限购
  648. if (this.add_num > this.limit_buy_num && this.limit_buy_num != 0) {
  649. this.$mUtil.toast("商品限购" + this.limit_buy_num + "件");
  650. return false;
  651. }
  652. //判断库存
  653. if (this.goodsSkuList.length > 0 && this.able_stock < this.add_num) {
  654. this.$mUtil.toast("商品库存只有" + this.able_stock + "件");
  655. this.$http.post(`/singlegoods/understockrecord/save`, {
  656. shop_id: this.shop_id,
  657. goods_id: this.goods_id,
  658. single_goods_id: this.choseConfig.single_goods_id,
  659. sku_set_name: this.choseConfig.sku_set_name,
  660. buy_num: this.add_num
  661. }).then((res) => {
  662. });
  663. return false;
  664. }
  665. if (this.goStatus == 0) {
  666. let data = {
  667. goods_id: this.goods_id,
  668. sku_hash_code: this.hasId,
  669. add_num: this.add_num,
  670. source_shop_id: this.shop_id.toString(),
  671. };
  672. this.$http.post(`/cart/add`, data).then((res) => {
  673. if (res && res.code == 200) {
  674. this.$mUtil.toast("添加成功");
  675. this.show = false;
  676. // this.$refs.specOpen.close();
  677. this.choseConfig = {};
  678. this.add_num = 1;
  679. }
  680. });
  681. } else {
  682. this.psotJson();
  683. }
  684. },
  685. //组合数据
  686. psotJson() {
  687. // this.loading = true;
  688. let dataJson = {};
  689. let childArr = [];
  690. let parendArr = [];
  691. // let shop = uni.getStorageSync('shop')
  692. // let shopid = shop.id ? shop.id : ''
  693. this.choseConfig;
  694. childArr.push({
  695. user_cart_id: 0,
  696. activity_goods_id: this.choseConfig.activity_goods_id,
  697. goods_id: this.goods_id,
  698. num: this.add_num,
  699. sku_hash_code: this.hasId,
  700. });
  701. parendArr.push({
  702. shop_id: this.shop.id,
  703. source_shop_id: this.shop.id,
  704. activity_id: this.dataForm.group_buy_id, //活动id
  705. sponsor_activity_id: this.selectGroup ? this.selectGroup.id : 0, //拼团id
  706. user_remark: "",
  707. items: childArr,
  708. });
  709. dataJson = {
  710. is_cart: false, //是否来源于购物车
  711. receipt_id: null, //收货地址ID
  712. shipment_mode: 0, //0物流,1自提
  713. shop_orders: parendArr,
  714. marketing_type: 2, //0无活动,1秒杀,2拼团
  715. };
  716. uni.setStorageSync("dataJson", dataJson);
  717. uni.navigateTo({
  718. url: "/pages/product/surePay/surePaySechill?type=group",
  719. });
  720. // let shop = uni.getStorageSync('shop')
  721. // let shopid=shop.id?shop.id:''
  722. // this.loading = false;
  723. // this.$http.post(`/order/build`, dataJson).then(res => {
  724. // if (res && res.code == 200) {
  725. // uni.setStorageSync('sureData', res.data)
  726. // uni.navigateTo({
  727. // url: '../surePay/surePay'
  728. // })
  729. // }
  730. // })
  731. },
  732. //
  733. btnBuy(i) {
  734. this.goStatus = i;
  735. let token = uni.getStorageSync("apiToken");
  736. //判断是否微信授权登录(没有授权登录进wx-login,授权了但没有注册进login)
  737. if (!token) {
  738. uni.navigateTo({
  739. url: "/pages/login/index",
  740. });
  741. } else {
  742. this.btnBuys();
  743. }
  744. //0 购物车,1 立即购买
  745. },
  746. },
  747. };
  748. </script>
  749. <style lang="scss">
  750. page {
  751. background-color: #f5f5f5;
  752. }
  753. </style>
  754. <style lang="scss" scoped>
  755. .pd24 {
  756. padding: 24rpx;
  757. }
  758. .pd20 {
  759. padding: 20rpx;
  760. }
  761. .pt20-pb14 {
  762. padding-top: 20rpx;
  763. padding-bottom: 14rpx;
  764. }
  765. .pt28-pb18 {
  766. padding-top: 28rpx;
  767. padding-bottom: 18rpx;
  768. }
  769. .pb30 {
  770. padding-bottom: 30rpx;
  771. }
  772. .pb40 {
  773. padding-bottom: 40rpx;
  774. }
  775. .pb50 {
  776. padding-bottom: 50rpx;
  777. }
  778. .pt-pb30 {
  779. padding-top: 30rpx;
  780. padding-bottom: 30rpx;
  781. }
  782. .pt-pb35 {
  783. padding-top: 35rpx;
  784. padding-bottom: 35rpx;
  785. }
  786. .ml54 {
  787. margin-left: 54rpx;
  788. }
  789. .ml138 {
  790. margin-left: 138rpx;
  791. }
  792. .br-rd10 {
  793. border-radius: 10rpx;
  794. }
  795. .br-rd20 {
  796. border-radius: 20rpx;
  797. }
  798. .stb-btn {
  799. padding: 8rpx 18rpx;
  800. border-radius: 10rpx;
  801. background: ff0000;
  802. }
  803. .br-FF0000 {
  804. border: 1rpx solid #ff0000;
  805. border-radius: 24rpx;
  806. padding: 6rpx 12rpx;
  807. }
  808. .bg-FFF6EE {
  809. background-color: #fff6ee;
  810. }
  811. .mt80 {
  812. margin-top: 80rpx;
  813. }
  814. .mt10 {
  815. margin-top: 10rpx;
  816. }
  817. .product {
  818. padding-bottom: 150rpx;
  819. }
  820. .pic {
  821. width: 100%;
  822. position: relative;
  823. .swiper {
  824. height: 620rpx;
  825. video {
  826. width: 100%;
  827. height: 620rpx;
  828. }
  829. image {
  830. width: 100%;
  831. height: 620rpx;
  832. }
  833. }
  834. .p-price {
  835. width: 100%;
  836. // position: absolute;
  837. top: 460rpx;
  838. background: linear-gradient(90deg, #20a733, #0a824b);
  839. border-radius: 20rpx 20rpx 0px 0px;
  840. position: relative;
  841. top: -18rpx;
  842. .discount {
  843. color: #ffffff;
  844. }
  845. }
  846. }
  847. .richText {
  848. padding: 30rpx;
  849. /deep/ img {
  850. margin-top: 0 !important;
  851. }
  852. }
  853. //秒杀,拼团样式
  854. .p-ab {
  855. position: absolute;
  856. z-index: 2;
  857. top: -12rpx;
  858. right: 0;
  859. }
  860. .stb-list {
  861. padding-bottom: 10rpx;
  862. }
  863. .triangle-bottomright {
  864. width: 0;
  865. height: 0;
  866. border-bottom: 108rpx solid #dccda4;
  867. border-left: 60rpx solid transparent;
  868. }
  869. .seckill {
  870. background-color: #dccda4;
  871. color: #0B844A;
  872. padding: 12rpx 16rpx 16rpx 16rpx;
  873. padding-right: 28rpx;
  874. border-radius: 5rpx 20rpx 0px 0px;
  875. }
  876. .seckill-btn {
  877. width: 86%;
  878. }
  879. .br-284534 {
  880. border-bottom: 1rpx solid rgba($color: #284534, $alpha: 0.3);
  881. }
  882. .gb-te {
  883. padding-top: 20rpx;
  884. padding-bottom: 15rpx;
  885. }
  886. .gb-btn {
  887. padding: 20rpx 48rpx;
  888. line-height: 30rpx;
  889. }
  890. .btn-bg-dccda4 {
  891. background: #dccda4;
  892. border-radius: 48px;
  893. }
  894. .btn-bg-00321E {
  895. background: #0B844A;
  896. border-radius: 48px;
  897. }
  898. .btn-bg-00320E {
  899. background: #0B844A;
  900. border-radius: 48px;
  901. }
  902. .btn-bg-dccda4-48 {
  903. padding: 20rpx 85rpx;
  904. border-radius: 48px 0 0 48px;
  905. }
  906. .btn-bg-dccda4-482 {
  907. padding: 20rpx 85rpx;
  908. border-radius: 0 48px 48px 0;
  909. }
  910. .tab {
  911. padding-top: 38rpx;
  912. .active {
  913. font-size: 30rpx;
  914. color: #0B844A;
  915. font-weight: 700;
  916. border-bottom: 1rpx solid #0B844A;
  917. }
  918. }
  919. .bottom-btn {
  920. width: 100%;
  921. position: fixed;
  922. bottom: 0;
  923. border-top: 1rpx solid #e6e6e6;
  924. z-index: 9;
  925. .cart {
  926. position: relative;
  927. .number {
  928. position: absolute;
  929. top: -10rpx;
  930. left: 45rpx;
  931. padding: 4rpx 8rpx;
  932. background-color: #ff0000;
  933. border: 4rpx solid #ffffff;
  934. border-radius: 40rpx;
  935. }
  936. }
  937. .cart-btn {
  938. width: 230rpx;
  939. height: 85rpx;
  940. background: #dccda4;
  941. border-radius: 43rpx 0rpx 0rpx 43rpx;
  942. }
  943. .buy-btn {
  944. width: 230rpx;
  945. height: 85rpx;
  946. line-height: 85rpx;
  947. background: #0B844A;
  948. border-radius: 0rpx 43rpx 43rpx 0rpx;
  949. }
  950. }
  951. .flex-sb {
  952. display: flex;
  953. justify-content: space-between;
  954. }
  955. //弹窗
  956. .spec {
  957. border-radius: 18rpx 18rpx 0rpx 0rpx;
  958. padding-top: 30rpx;
  959. max-height: 900rpx;
  960. overflow-y: auto;
  961. // position: fixed;
  962. // bottom: 0;
  963. // z-index: 999;
  964. // width: 100%;
  965. .spec-item {
  966. background-color: #f6f6f6;
  967. border: 1px solid #f6f6f6;
  968. padding: 12rpx 30rpx;
  969. font-size: 24rpx;
  970. color: #1a1a1a;
  971. border-radius: 4px;
  972. }
  973. .activeColor {
  974. background-color: #e1e6e3;
  975. border: 1px solid #01321d;
  976. color: #01321d;
  977. border-radius: 4px;
  978. }
  979. .spec-item:not(:last-child) {
  980. margin-right: 24rpx;
  981. }
  982. //减号
  983. .minus {
  984. width: 50rpx;
  985. height: 50rpx;
  986. line-height: 50rpx;
  987. text-align: center;
  988. background: #dedede;
  989. border-radius: 8rpx 0rpx 0rpx 8rpx;
  990. }
  991. .num {
  992. width: 74rpx;
  993. height: 46rpx;
  994. line-height: 46rpx;
  995. text-align: center;
  996. border: 1px solid #dedede;
  997. }
  998. //加号
  999. .plus-sign {
  1000. width: 50rpx;
  1001. height: 50rpx;
  1002. line-height: 50rpx;
  1003. text-align: center;
  1004. background: #dedede;
  1005. border-radius: 0rpx 8rpx 8rpx 0rpx;
  1006. }
  1007. .specOpen-btn {
  1008. margin-top: 68rpx;
  1009. padding-bottom: 34rpx;
  1010. button {
  1011. background-color: #0B844A;
  1012. color: #ffffff;
  1013. }
  1014. }
  1015. }
  1016. </style>