integral_goods_details.vue 31 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187
  1. <template>
  2. <view :style="colorStyle">
  3. <view class="product-con">
  4. <!-- 头部 -->
  5. <!-- #ifndef APP-PLUS -->
  6. <view class='navbar' :style="{height:navH+'rpx',opacity:opacity}">
  7. <view class='navbarH' :style='"height:"+navH+"rpx;"'>
  8. <view class='navbarCon acea-row row-center-wrapper'>
  9. <view class="header acea-row row-center-wrapper">
  10. <view class="item line1">
  11. {{storeInfo.title}}
  12. </view>
  13. </view>
  14. </view>
  15. </view>
  16. </view>
  17. <view id="home" class="home-nav acea-row row-center-wrapper" :class="[opacity>0.5?'on':'']"
  18. :style="{ top: homeTop +'rpx'}">
  19. <view class="iconfont icon-fanhui2" @tap="returns"></view>
  20. <!-- #ifdef MP -->
  21. <view class="line"></view>
  22. <view class="iconfont icon-gengduo5" @click="moreNav"></view>
  23. <!-- #endif -->
  24. </view>
  25. <!-- #endif -->
  26. <!-- #ifdef H5 -->
  27. <view id="home" class="home-nav right acea-row row-center-wrapper" :class="[opacity>0.5?'on':'']"
  28. :style="{ top: homeTop +'rpx'}">
  29. <!-- #ifdef APP-PLUS || H5 -->
  30. <view class="iconfont icon-gengduo2" @click="moreNav"></view>
  31. </view>
  32. <!-- #endif -->
  33. <!-- #endif -->
  34. <homeList :navH="navH" :returnShow="returnShow" :currentPage="currentPage" :sysHeight="sysHeight">
  35. </homeList>
  36. <scroll-view :scroll-top="scrollTop" scroll-y="true" scroll-with-animation="true"
  37. :style="'height:' + height + 'px;'" @scroll="scroll">
  38. <view id="past0">
  39. <!-- #ifdef APP-PLUS || MP -->
  40. <view class="" :style="'width:100%;' + 'height:'+sysHeight"></view>
  41. <!-- #endif -->
  42. <productConSwiper :imgUrls="imgUrls"></productConSwiper>
  43. <view class="nav acea-row row-between-wrapper">
  44. <view class="share acea-row row-between row-bottom">
  45. <view class="money font-color">
  46. <image src="./static/my-point.png" mode=""></image>
  47. <text class="num" v-text="storeInfo.price || 0"></text>{{$t(`积分`)}}
  48. </view>
  49. <view></view>
  50. </view>
  51. </view>
  52. <view class="wrapper">
  53. <view class="introduce acea-row row-between">
  54. <view class="infor"> {{ storeInfo.title }}</view>
  55. </view>
  56. <view class="limit_good" v-if="storeInfo.num > 0">
  57. {{ $t(`最多可兑换`)}}: {{storeInfo.num}}{{$t(storeInfo.unit_name)}}
  58. </view>
  59. <view class="label acea-row row-middle">
  60. <view class="stock">{{$t(`划线价`)}}:{{ storeInfo.product_price }}</view>
  61. <view class="stock">{{$t(`限量`)}}:
  62. {{ storeInfo.quota_show }}
  63. </view>
  64. <view class="stock">{{$t(`已兑换`)}}:{{ storeInfo.sales }} </view>
  65. </view>
  66. </view>
  67. <view class="attribute acea-row row-between-wrapper" @tap="selecAttr"
  68. v-if="attribute.productAttr.length">
  69. <!-- <view class="df"><text class='atterTxt line1'>{{attr}}:{{attrValue}}</text></view>
  70. <view class='iconfont icon-jiantou'></view> -->
  71. <view class="flex">
  72. <view style="display: flex; align-items: center; width: 90%">
  73. <view class="attr-txt"> {{ attr }}: </view>
  74. <view class="atterTxt line1" style="width: 82%">{{
  75. attrValue
  76. }}</view>
  77. </view>
  78. <view class="iconfont icon-jiantou"></view>
  79. </view>
  80. <view class="acea-row row-between-wrapper" style="margin-top: 7px; padding-left: 70px"
  81. v-if="skuArr.length > 1">
  82. <view class="flexs">
  83. <image :src="item.image" v-for="(item, index) in skuArr.slice(0, 4)" :key="index"
  84. class="attrImg"></image>
  85. </view>
  86. <view class="switchTxt">{{$t(`共`)}}{{ skuArr.length }}{{$t(`种规格可选`)}}</view>
  87. </view>
  88. </view>
  89. </view>
  90. <view class="product-intro" id="past2">
  91. <view class="title">{{$t(`产品介绍`)}}</view>
  92. <view class="conter">
  93. <jyf-parser :html="storeInfo.description" ref="article" :tag-style="tagStyle"></jyf-parser>
  94. </view>
  95. </view>
  96. </scroll-view>
  97. <view class="footer acea-row row-between-wrapper">
  98. <navigator hover-class="none" open-type="switchTab" class="item" url="/pages/index/index">
  99. <view class="iconfont icon-shouye6"></view>
  100. <view class="p_center">{{$t(`首页`)}}</view>
  101. </navigator>
  102. <view class="bnt acea-row" v-if="
  103. attribute.productSelect.quota > 0 &&
  104. attribute.productSelect.product_stock > 0
  105. ">
  106. <view class="buy bnts" @tap="goCat">{{$t(`立即兑换`)}}</view>
  107. </view>
  108. <view class="bnt acea-row" v-else>
  109. <view class="bnts no-goods">{{$t(`无法兑换`)}}</view>
  110. </view>
  111. </view>
  112. </view>
  113. <product-window :attr="attribute" :limitNum="1" @myevent="onMyEvent" @ChangeAttr="ChangeAttr"
  114. @ChangeCartNum="ChangeCartNum" @attrVal="attrVal" @iptCartNum="iptCartNum" @getImg="showImg">
  115. </product-window>
  116. <cus-previewImg ref="cusPreviewImg" :list="skuArr" @changeSwitch="changeSwitch"
  117. @shareFriend="listenerActionSheet" />
  118. <!-- 分享按钮 -->
  119. <kefuIcon :ids="storeInfo.product_id" :routineContact="routineContact"></kefuIcon>
  120. <!-- 发送给朋友图片 -->
  121. </view>
  122. </template>
  123. <script>
  124. const app = getApp();
  125. import {
  126. mapGetters
  127. } from "vuex";
  128. import {
  129. getIntegralProductDetail
  130. } from '@/api/activity.js';
  131. import productConSwiper from '@/components/productConSwiper/index.vue'
  132. import productWindow from './component/productWindow.vue'
  133. import userEvaluation from '@/components/userEvaluation/index.vue'
  134. import kefuIcon from '@/components/kefuIcon';
  135. // #ifdef MP
  136. import authorize from '@/components/Authorize';
  137. // #endif
  138. import parser from "@/components/jyf-parser/jyf-parser";
  139. import countDown from '@/components/countDown';
  140. import {
  141. imageBase64
  142. } from "@/api/public";
  143. import {
  144. toLogin
  145. } from '@/libs/login.js';
  146. import {
  147. getUserInfo
  148. } from '@/api/user.js';
  149. // #ifdef APP-PLUS
  150. import {
  151. TOKENNAME,
  152. HTTP_REQUEST_URL
  153. } from '@/config/app.js';
  154. // #endif
  155. import colors from "@/mixins/color";
  156. import cusPreviewImg from "@/components/cusPreviewImg/index.vue";
  157. import homeList from '@/components/homeList'
  158. let sysHeight = uni.getSystemInfoSync().statusBarHeight + 'px';
  159. export default {
  160. computed: mapGetters(['isLogin']),
  161. mixins: [colors],
  162. data() {
  163. return {
  164. dataShow: 0,
  165. id: 0,
  166. time: 0,
  167. countDownHour: "00",
  168. countDownMinute: "00",
  169. countDownSecond: "00",
  170. storeInfo: [],
  171. imgUrls: [],
  172. parameter: {
  173. 'navbar': '1',
  174. 'return': '1',
  175. 'title': this.$t(`抢购详情页`),
  176. 'color': false
  177. },
  178. attribute: {
  179. cartAttr: false,
  180. productAttr: [],
  181. productSelect: {}
  182. },
  183. productValue: [],
  184. isOpen: false,
  185. attr: this.$t(`请选择`),
  186. attrValue: '',
  187. status: 1,
  188. isAuto: false,
  189. isShowAuth: false,
  190. iShidden: false,
  191. limitNum: 1, //限制本属性产品的个数;
  192. iSplus: false,
  193. replyCount: 0, //总评论数量
  194. reply: [], //评论列表
  195. replyChance: 0,
  196. navH: "",
  197. navList: [this.$t(`商品`), this.$t(`详情`)],
  198. opacity: 0,
  199. scrollY: 0,
  200. topArr: [],
  201. toView: '',
  202. height: 0,
  203. heightArr: [],
  204. lock: false,
  205. scrollTop: 0,
  206. tagStyle: {
  207. img: 'width:100%;display:block;',
  208. table: 'width:100%',
  209. video: 'width:100%'
  210. },
  211. datatime: '',
  212. navActive: 0,
  213. meunHeight: 0,
  214. backH: '',
  215. posters: false,
  216. weixinStatus: false,
  217. posterImageStatus: false,
  218. storeImage: '', //海报产品图
  219. PromotionCode: '', //二维码图片
  220. posterImage: '', //海报路径
  221. actionSheetHidden: false,
  222. cart_num: 1,
  223. homeTop: 20,
  224. returnShow: true,
  225. H5ShareBox: false, //公众号分享图片
  226. routineContact: 0,
  227. skuArr: [],
  228. selectSku: {},
  229. currentPage: false,
  230. sysHeight: sysHeight,
  231. }
  232. },
  233. components: {
  234. productConSwiper,
  235. 'productWindow': productWindow,
  236. userEvaluation,
  237. kefuIcon,
  238. "jyf-parser": parser,
  239. countDown,
  240. cusPreviewImg,
  241. homeList,
  242. // #ifdef MP
  243. authorize
  244. // #endif
  245. },
  246. computed: mapGetters(['isLogin']),
  247. watch: {
  248. isLogin: {
  249. handler: function(newV, oldV) {
  250. if (newV) {
  251. this.getIntegralProductDetail();
  252. }
  253. },
  254. deep: true
  255. }
  256. },
  257. onLoad(options) {
  258. let that = this
  259. let statusBarHeight = ''
  260. var pages = getCurrentPages();
  261. that.returnShow = pages.length === 1 ? false : true;
  262. //设置商品列表高度
  263. uni.getSystemInfo({
  264. success: function(res) {
  265. that.height = res.windowHeight
  266. statusBarHeight = res.statusBarHeight
  267. //res.windowHeight:获取整个窗口高度为px,*2为rpx;98为头部占据的高度;
  268. },
  269. });
  270. // #ifdef H5
  271. that.navH = 96;
  272. // #endif
  273. // #ifdef APP-PLUS
  274. that.navH = 30;
  275. // #endif
  276. // #ifdef MP
  277. this.navH = app.globalData.navHeight;
  278. let menuButtonInfo = uni.getMenuButtonBoundingClientRect()
  279. this.meunHeight = menuButtonInfo.height
  280. this.backH = (that.navH / 2) + (this.meunHeight / 2)
  281. //扫码携带参数处理
  282. if (options.scene) {
  283. let value = this.$util.getUrlParams(decodeURIComponent(options.scene));
  284. if (value.id) {
  285. this.id = value.id;
  286. } else {
  287. return this.$util.Tips({
  288. title: this.$t(`缺少参数无法查看商品`)
  289. }, {
  290. tab: 3,
  291. url: 1
  292. });
  293. }
  294. //记录推广人uid
  295. if (value.pid) app.globalData.spid = value.pid;
  296. if (value.time) this.datatime = value.time
  297. }
  298. // #endif
  299. if (options.id) {
  300. this.id = options.id
  301. this.datatime = Number(options.time)
  302. this.status = options.status
  303. }
  304. if (this.isLogin) {
  305. this.getIntegralProductDetail();
  306. } else {
  307. toLogin();
  308. }
  309. this.$nextTick(() => {
  310. // #ifdef MP
  311. const menuButton = uni.getMenuButtonBoundingClientRect();
  312. const query = uni.createSelectorQuery().in(this);
  313. query
  314. .select('#home')
  315. .boundingClientRect(data => {
  316. this.homeTop = menuButton.top * 2 + menuButton.height - data.height;
  317. })
  318. .exec();
  319. // #endif
  320. })
  321. },
  322. onNavigationBarButtonTap(e) {
  323. this.currentPage = !this.currentPage
  324. },
  325. methods: {
  326. moreNav() {
  327. this.currentPage = !this.currentPage
  328. },
  329. // app分享
  330. // #ifdef APP-PLUS
  331. appShare(scene) {
  332. let that = this
  333. let routes = getCurrentPages(); // 获取当前打开过的页面路由数组
  334. let curRoute = routes[routes.length - 1].$page.fullPath // 获取当前页面路由,也就是最后一个打开的页面路由
  335. uni.share({
  336. provider: "weixin",
  337. scene: scene,
  338. type: 0,
  339. href: `${HTTP_REQUEST_URL}${curRoute}`,
  340. title: that.storeInfo.title,
  341. summary: that.storeInfo.info,
  342. imageUrl: that.storeInfo.small_image,
  343. success: function(res) {
  344. uni.showToast({
  345. title: title.$t(`分享成功`),
  346. icon: 'success'
  347. })
  348. that.posters = false;
  349. },
  350. fail: function(err) {
  351. uni.showToast({
  352. title: title.$t(`分享失败`),
  353. icon: 'none',
  354. duration: 2000
  355. })
  356. that.posters = false;
  357. }
  358. });
  359. },
  360. // #endif
  361. /**
  362. * 购物车手动填写
  363. *
  364. */
  365. iptCartNum: function(e) {
  366. this.$set(this.attribute.productSelect, 'cart_num', e);
  367. this.$set(this, "cart_num", e);
  368. },
  369. // 后退
  370. returns() {
  371. // #ifdef H5
  372. return history.back();
  373. // #endif
  374. // #ifndef H5
  375. return uni.navigateBack({
  376. delta: 1,
  377. })
  378. // #endif
  379. },
  380. onLoadFun: function(data) {
  381. if (this.isAuto) {
  382. this.isAuto = false;
  383. this.isShowAuth = false;
  384. this.getIntegralProductDetail();
  385. }
  386. },
  387. getIntegralProductDetail: function() {
  388. let that = this;
  389. getIntegralProductDetail(that.id).then(res => {
  390. this.dataShow = 1;
  391. let title = res.data.storeInfo.title;
  392. this.storeInfo = res.data.storeInfo;
  393. this.imgUrls = res.data.storeInfo.images;
  394. this.storeInfo.description = this.storeInfo.description.replace(/<img/gi,
  395. '<img style="max-width:100%;height:auto;float:left;display:block" ');
  396. this.attribute.productAttr = res.data.productAttr;
  397. this.productValue = res.data.productValue;
  398. this.attribute.productSelect.num = res.data.storeInfo.num;
  399. this.replyCount = res.data.replyCount;
  400. this.reply = res.data.reply ? [res.data.reply] : [];
  401. this.replyChance = res.data.replyChance;
  402. that.routineContact = Number(res.data.routine_contact_type);
  403. for (let key in res.data.productValue) {
  404. let obj = res.data.productValue[key];
  405. that.skuArr.push(obj);
  406. }
  407. this.$set(this, "selectSku", that.skuArr[0]);
  408. uni.setNavigationBarTitle({
  409. title: title.substring(0, 7) + '...'
  410. });
  411. // #ifdef H5
  412. this.PromotionCode = res.data.storeInfo.code_base
  413. that.storeImage = that.storeInfo.image
  414. // #endif
  415. that.DefaultSelect();
  416. app.globalData.openPages = '/pages/activity/goods_seckill_details/index?id=' + that.id +
  417. '&time=' + that.time +
  418. '&status=' + that.status + '&scene=' + that.storeInfo.uid;
  419. // wxParse.wxParse('description', 'html', that.data.storeInfo.description || '', that, 0);
  420. // wxh.time(that.data.time, that);
  421. }).catch(err => {
  422. that.$util.Tips({
  423. title: err
  424. }, {
  425. tab: 3
  426. })
  427. });
  428. },
  429. setShare: function() {
  430. this.$wechat.isWeixin() &&
  431. this.$wechat.wechatEvevt([
  432. "updateAppMessageShareData",
  433. "updateTimelineShareData",
  434. "onMenuShareAppMessage",
  435. "onMenuShareTimeline"
  436. ], {
  437. desc: this.storeInfo.info,
  438. title: this.storeInfo.title,
  439. link: location.href,
  440. imgUrl: this.storeInfo.image
  441. }).then(res => {}).catch(err => {});
  442. },
  443. /**
  444. * 默认选中属性
  445. *
  446. */
  447. DefaultSelect: function() {
  448. let self = this
  449. let productAttr = self.attribute.productAttr;
  450. let value = [];
  451. for (var key in this.productValue) {
  452. if (this.productValue[key].quota > 0) {
  453. value = this.attribute.productAttr.length ? key.split(",") : [];
  454. break;
  455. }
  456. }
  457. for (let i = 0; i < productAttr.length; i++) {
  458. this.$set(productAttr[i], "index", value[i]);
  459. }
  460. //sort();排序函数:数字-英文-汉字;
  461. let productSelect = this.productValue[value.join(",")];
  462. if (productSelect && productAttr.length) {
  463. self.$set(
  464. self.attribute.productSelect,
  465. "store_name",
  466. self.storeInfo.title
  467. );
  468. self.$set(self.attribute.productSelect, "image", productSelect.image);
  469. self.$set(self.attribute.productSelect, "price", productSelect.price);
  470. self.$set(self.attribute.productSelect, "stock", productSelect.stock);
  471. self.$set(self.attribute.productSelect, "unique", productSelect.unique);
  472. self.$set(self.attribute.productSelect, "quota", productSelect.quota);
  473. self.$set(self.attribute.productSelect, "quota_show", productSelect.quota_show);
  474. self.$set(self.attribute.productSelect, "product_stock", productSelect.product_stock);
  475. self.$set(self.attribute.productSelect, "cart_num", 1);
  476. self.$set(self, "attrValue", value.join(","));
  477. self.attrValue = value.join(",")
  478. } else if (!productSelect && productAttr.length) {
  479. self.$set(
  480. self.attribute.productSelect,
  481. "store_name",
  482. self.storeInfo.title
  483. );
  484. self.$set(self.attribute.productSelect, "image", self.storeInfo.image);
  485. self.$set(self.attribute.productSelect, "price", self.storeInfo.price);
  486. self.$set(self.attribute.productSelect, "quota", 0);
  487. self.$set(self.attribute.productSelect, "quota_show", 0);
  488. self.$set(self.attribute.productSelect, "product_stock", 0);
  489. self.$set(self.attribute.productSelect, "stock", 0);
  490. self.$set(self.attribute.productSelect, "unique", "");
  491. self.$set(self.attribute.productSelect, "cart_num", 0);
  492. self.$set(self, "attrValue", "");
  493. self.$set(self, "attrTxt", self.$t(`请选择`));
  494. } else if (!productSelect && !productAttr.length) {
  495. self.$set(
  496. self.attribute.productSelect,
  497. "store_name",
  498. self.storeInfo.title
  499. );
  500. self.$set(self.attribute.productSelect, "image", self.storeInfo.image);
  501. self.$set(self.attribute.productSelect, "price", self.storeInfo.price);
  502. self.$set(self.attribute.productSelect, "stock", self.storeInfo.stock);
  503. self.$set(self.attribute.productSelect, "quota", self.storeInfo.quota);
  504. self.$set(self.attribute.productSelect, "product_stock", self.storeInfo.product_stock);
  505. self.$set(
  506. self.attribute.productSelect,
  507. "unique",
  508. self.storeInfo.unique || ""
  509. );
  510. self.$set(self.attribute.productSelect, "cart_num", 1);
  511. self.$set(self.attribute.productSelect, "quota", productSelect.quota);
  512. self.$set(self.attribute.productSelect, "product_stock", productSelect.product_stock);
  513. self.$set(self, "attrValue", "");
  514. self.$set(self, "attrTxt", self.$t(`请选择`));
  515. }
  516. },
  517. selecAttr: function() {
  518. this.attribute.cartAttr = true
  519. },
  520. onMyEvent: function() {
  521. this.$set(this.attribute, 'cartAttr', false);
  522. this.$set(this, 'isOpen', false);
  523. },
  524. /**
  525. * 购物车数量加和数量减
  526. *
  527. */
  528. ChangeCartNum: function(changeValue) {
  529. //changeValue:是否 加|减
  530. //获取当前变动属性
  531. let productSelect = this.productValue[this.attrValue];
  532. if (this.cart_num) {
  533. productSelect.cart_num = this.cart_num;
  534. this.attribute.productSelect.cart_num = this.cart_num;
  535. }
  536. //如果没有属性,赋值给商品默认库存
  537. if (productSelect === undefined && !this.attribute.productAttr.length)
  538. productSelect = this.attribute.productSelect;
  539. //无属性值即库存为0;不存在加减;
  540. if (productSelect === undefined) return;
  541. let stock = productSelect.stock || 0;
  542. let quotaShow = productSelect.quota_show || 0;
  543. let quota = productSelect.quota || 0;
  544. let productStock = productSelect.product_stock || 0;
  545. let num = this.attribute.productSelect;
  546. let nums = this.storeInfo.num || 0;
  547. //设置默认数据
  548. if (productSelect.cart_num == undefined) productSelect.cart_num = 1;
  549. if (changeValue) {
  550. if (num.cart_num < this.attribute.productSelect.quota) {
  551. num.cart_num++;
  552. this.$set(this.attribute.productSelect, "cart_num", num.cart_num);
  553. this.$set(this, "cart_num", num.cart_num);
  554. this.$set(this.attribute.productSelect, "cart_num", num.cart_num);
  555. }
  556. } else {
  557. if (num.cart_num == 1) return
  558. num.cart_num--;
  559. this.$set(this, "cart_num", num.cart_num);
  560. this.$set(this.attribute.productSelect, "cart_num", num.cart_num);
  561. }
  562. },
  563. attrVal(val) {
  564. this.attribute.productAttr[val.indexw].index = this.attribute.productAttr[val.indexw].attr_values[val
  565. .indexn];
  566. },
  567. /**
  568. * 属性变动赋值
  569. *
  570. */
  571. ChangeAttr: function(res) {
  572. this.$set(this, 'cart_num', 1);
  573. let productSelect = this.productValue[res];
  574. this.$set(this, "selectSku", productSelect);
  575. if (productSelect) {
  576. this.$set(this.attribute.productSelect, "image", productSelect.image);
  577. this.$set(this.attribute.productSelect, "price", productSelect.price);
  578. this.$set(this.attribute.productSelect, "stock", productSelect.stock);
  579. this.$set(this.attribute.productSelect, "unique", productSelect.unique);
  580. this.$set(this.attribute.productSelect, "cart_num", 1);
  581. this.$set(this.attribute.productSelect, "quota", productSelect.quota);
  582. this.$set(this.attribute.productSelect, "quota_show", productSelect.quota_show);
  583. this.$set(this, "attrValue", res);
  584. this.attrTxt = this.$t(`已选择`)
  585. } else {
  586. this.$set(this.attribute.productSelect, "image", this.storeInfo.image);
  587. this.$set(this.attribute.productSelect, "price", this.storeInfo.price);
  588. this.$set(this.attribute.productSelect, "stock", 0);
  589. this.$set(this.attribute.productSelect, "unique", "");
  590. this.$set(this.attribute.productSelect, "cart_num", 0);
  591. this.$set(this.attribute.productSelect, "quota", 0);
  592. this.$set(this.attribute.productSelect, "quota_show", 0);
  593. this.$set(this, "attrValue", "");
  594. this.attrTxt = this.$t(`已选择`)
  595. }
  596. },
  597. scroll: function(e) {
  598. var that = this,
  599. scrollY = e.detail.scrollTop;
  600. var opacity = scrollY / 200;
  601. opacity = opacity > 1 ? 1 : opacity;
  602. that.opacity = opacity
  603. this.currentPage = false
  604. that.scrollY = scrollY
  605. if (that.lock) {
  606. that.lock = false
  607. return;
  608. }
  609. for (var i = 0; i < that.topArr.length; i++) {
  610. if (scrollY < that.topArr[i] - (app.globalData.navHeight / 2) + that.heightArr[i]) {
  611. that.navActive = i
  612. break
  613. }
  614. }
  615. },
  616. tap: function(item, index) {
  617. var id = item.id;
  618. var index = index;
  619. var that = this;
  620. // if (!this.data.good_list.length && id == "past2") {
  621. // id = "past3"
  622. // }
  623. this.toView = id;
  624. this.navActive = index;
  625. this.lock = true;
  626. this.scrollTop = index > 0 ? that.topArr[index] - (app.globalData.navHeight / 2) : that.topArr[index]
  627. },
  628. //点击sku图片打开轮播图
  629. showImg(index) {
  630. this.$refs.cusPreviewImg.open(this.selectSku.suk);
  631. },
  632. /**
  633. * 分享打开
  634. *
  635. */
  636. listenerActionSheet() {
  637. this.currentPage = false
  638. if (this.isLogin === false) {
  639. toLogin();
  640. } else {
  641. if (this.posterImage) {
  642. this.posters = true;
  643. return
  644. }
  645. // #ifdef H5
  646. if (this.$wechat.isWeixin() === true) {
  647. this.weixinStatus = true;
  648. }
  649. // #endif
  650. // #ifndef APP-PLUS
  651. this.downloadFilePromotionCode();
  652. // #endif
  653. // #ifdef APP-PLUS
  654. if (this.PromotionCode.indexOf("http") == 0) {
  655. // this.downloadFilePromotionCode();
  656. }
  657. // #endif
  658. this.posters = true;
  659. }
  660. },
  661. //滑动轮播图选择商品
  662. changeSwitch(e) {
  663. let productSelect = this.skuArr[e];
  664. this.$set(this, "selectSku", productSelect);
  665. var skuList = productSelect.suk.split(",");
  666. this.$set(this.attribute.productAttr[0], "index", skuList[0]);
  667. if (skuList.length == 2) {
  668. this.$set(this.attribute.productAttr[0], "index", skuList[0]);
  669. this.$set(this.attribute.productAttr[1], "index", skuList[1]);
  670. } else if (skuList.length == 3) {
  671. this.$set(this.attribute.productAttr[0], "index", skuList[0]);
  672. this.$set(this.attribute.productAttr[1], "index", skuList[1]);
  673. this.$set(this.attribute.productAttr[2], "index", skuList[2]);
  674. } else if (skuList.length == 4) {
  675. this.$set(this.attribute.productAttr[0], "index", skuList[0]);
  676. this.$set(this.attribute.productAttr[1], "index", skuList[1]);
  677. this.$set(this.attribute.productAttr[2], "index", skuList[2]);
  678. this.$set(this.attribute.productAttr[3], "index", skuList[3]);
  679. }
  680. if (productSelect) {
  681. this.$set(this.attribute.productSelect, "image", productSelect.image);
  682. this.$set(this.attribute.productSelect, "price", productSelect.price);
  683. this.$set(this.attribute.productSelect, "stock", productSelect.stock);
  684. this.$set(this.attribute.productSelect, "unique", productSelect.unique);
  685. this.$set(this.attribute.productSelect, "vipPrice", productSelect.vipPrice);
  686. this.$set(this, "attrTxt", this.$t(`已选择`));
  687. this.$set(this, "attrValue", productSelect.suk);
  688. }
  689. },
  690. /*
  691. * 下订单
  692. */
  693. goCat: function() {
  694. var that = this;
  695. this.currentPage = false
  696. var productSelect = this.productValue[this.attrValue];
  697. //打开属性
  698. if (this.isOpen)
  699. this.attribute.cartAttr = true
  700. else
  701. this.attribute.cartAttr = !this.attribute.cartAttr
  702. //只有关闭属性弹窗时进行加入购物车
  703. if (this.attribute.cartAttr === true && this.isOpen == false) return this.isOpen = true
  704. //如果有属性,没有选择,提示用户选择
  705. if (this.attribute.productAttr.length && productSelect === undefined && this.isOpen == true) return app
  706. .$util.Tips({
  707. title: this.$t(`请选择属性`)
  708. });
  709. if (this.cart_num <= 0) {
  710. return app.$util.Tips({
  711. title: this.$t(`请选择数量`)
  712. });
  713. }
  714. this.isOpen = false
  715. uni.navigateTo({
  716. url: `/pages/points_mall/integral_order?unique=${productSelect.unique}&num=${this.cart_num || 1}`
  717. });
  718. },
  719. }
  720. }
  721. </script>
  722. <style lang="scss">
  723. .generate-posters {
  724. width: 100%;
  725. height: 170rpx;
  726. background-color: #fff;
  727. position: fixed;
  728. left: 0;
  729. bottom: 0;
  730. z-index: 300;
  731. transform: translate3d(0, 100%, 0);
  732. transition: all 0.3s cubic-bezier(0.25, 0.5, 0.5, 0.9);
  733. border-top: 1rpx solid #eee;
  734. }
  735. .generate-posters.on {
  736. transform: translate3d(0, 0, 0);
  737. }
  738. .generate-posters .item {
  739. flex: 1;
  740. text-align: center;
  741. font-size: 30rpx;
  742. }
  743. .generate-posters .item .iconfont {
  744. font-size: 80rpx;
  745. color: #5eae72;
  746. }
  747. .generate-posters .item .iconfont.icon-haibao {
  748. color: #5391f1;
  749. }
  750. .navbar .header {
  751. width: 400rpx;
  752. height: 96rpx;
  753. font-size: 30rpx;
  754. color: #050505;
  755. background-color: #fff;
  756. /* #ifdef MP */
  757. padding-right: 95rpx;
  758. /* #endif */
  759. }
  760. .icon-xiangzuo {
  761. /* #ifdef H5 */
  762. top: 30rpx !important;
  763. /* #endif */
  764. }
  765. .navbar .header .item {
  766. position: relative;
  767. margin: 0 25rpx;
  768. }
  769. .navbar {
  770. position: fixed;
  771. background-color: #fff;
  772. top: 0;
  773. left: 0;
  774. z-index: 99;
  775. width: 100%;
  776. }
  777. .navbar .navbarH {
  778. position: relative;
  779. }
  780. .navbar .navbarH .navbarCon {
  781. position: absolute;
  782. bottom: 0;
  783. height: 100rpx;
  784. width: 100%;
  785. }
  786. .icon-xiangzuo {
  787. /* color: #000;
  788. position: fixed;
  789. font-size: 40rpx;
  790. width: 100rpx;
  791. height: 56rpx;
  792. line-height: 54rpx;
  793. z-index: 1000;
  794. left: 33rpx; */
  795. }
  796. .product-con .nav {
  797. width: 100%;
  798. height: 100rpx;
  799. padding: 0 30rpx;
  800. box-sizing: border-box;
  801. background-color: #fff;
  802. }
  803. .product-con .nav .money {
  804. font-size: 28rpx;
  805. color: #e93323;
  806. font-weight: bold;
  807. image {
  808. width: 34rpx;
  809. height: 34rpx;
  810. }
  811. }
  812. .product-con .nav .money .num {
  813. font-size: 48rpx;
  814. padding-left: 16rpx;
  815. }
  816. .product-con .nav .money .y-money {
  817. font-size: 26rpx;
  818. margin-left: 10rpx;
  819. text-decoration: line-through;
  820. }
  821. .product-con .nav .timeItem {
  822. font-size: 20rpx;
  823. color: #fff;
  824. text-align: center;
  825. }
  826. .product-con .nav .timeItem .timeCon {
  827. margin-top: 10rpx;
  828. }
  829. .product-con .nav .timeItem .timeCon .num {
  830. padding: 0 7rpx;
  831. font-size: 22rpx;
  832. color: #ff3d3d;
  833. background-color: #fff;
  834. border-radius: 2rpx;
  835. }
  836. .product-con .nav .timeState {
  837. font-size: 28rpx;
  838. color: #fff;
  839. }
  840. .product-con .nav .iconfont {
  841. color: #fff;
  842. font-size: 30rpx;
  843. margin-left: 20rpx;
  844. }
  845. .product-con .wrapper {
  846. padding: 0 32rpx 32rpx 32rpx;
  847. width: 100%;
  848. box-sizing: border-box;
  849. }
  850. .product-con .wrapper .introduce {
  851. margin: 0;
  852. }
  853. .limit_good {
  854. font-size: 16rpx;
  855. margin: 10rpx 0rpx;
  856. color: red;
  857. }
  858. .product-con .wrapper .introduce .infor {
  859. // width: 570rpx;
  860. }
  861. .product-con .wrapper .introduce .iconfont {
  862. font-size: 37rpx;
  863. color: #515151;
  864. }
  865. .product-con .wrapper .label {
  866. display: flex;
  867. justify-content: space-between;
  868. margin: 18rpx 0 0 0;
  869. font-size: 24rpx;
  870. color: #82848f;
  871. }
  872. .product-con .wrapper .label .stock {}
  873. .product-con .footer {
  874. padding: 0 20rpx 0 30rpx;
  875. position: fixed;
  876. bottom: 0;
  877. width: 100%;
  878. box-sizing: border-box;
  879. background-color: #fff;
  880. z-index: 277;
  881. border-top: 1rpx solid #f0f0f0;
  882. height: 100rpx;
  883. display: flex;
  884. align-items: center;
  885. flex-wrap: nowrap;
  886. height: calc(100rpx+ constant(safe-area-inset-bottom)); ///兼容 IOS<11.2/
  887. height: calc(100rpx + env(safe-area-inset-bottom)); ///兼容 IOS>11.2/
  888. }
  889. .product-con .footer .item {
  890. width: 100rpx;
  891. font-size: 18rpx;
  892. color: #666;
  893. }
  894. .product-con .footer .item .iconfont {
  895. text-align: center;
  896. font-size: 40rpx;
  897. }
  898. .product-con .footer .item .iconfont.icon-shoucang1 {
  899. color: var(--view-theme);
  900. }
  901. .product-con .footer .item .iconfont.icon-gouwuche1 {
  902. font-size: 40rpx;
  903. position: relative;
  904. }
  905. .product-con .footer .item .iconfont.icon-gouwuche1 .num {
  906. color: #fff;
  907. position: absolute;
  908. font-size: 18rpx;
  909. padding: 2rpx 8rpx 3rpx;
  910. border-radius: 200rpx;
  911. top: -10rpx;
  912. right: -10rpx;
  913. }
  914. .product-con .footer .bnt {
  915. width: 100%;
  916. height: 76rpx;
  917. }
  918. .product-con .footer .bnt .bnts {
  919. width: 100%;
  920. text-align: center;
  921. line-height: 76rpx;
  922. color: #fff;
  923. font-size: 28rpx;
  924. }
  925. .product-con .footer .bnt .joinCart {
  926. border-radius: 50rpx 0 0 50rpx;
  927. background-image: linear-gradient(to right, #fea10f 0%, #fa8013 100%);
  928. }
  929. .product-con .footer .bnt .buy {
  930. border-radius: 50rpx;
  931. // background-image: linear-gradient(to right, #fa6514 0%, #e93323 100%);
  932. background-color: var(--view-theme);
  933. }
  934. .product-con .footer .bnt .no-goods {
  935. border-radius: 50rpx;
  936. background-color: #cccccc;
  937. }
  938. .product-con .conter {
  939. display: block;
  940. }
  941. .product-con .conter img {
  942. display: block;
  943. }
  944. .bg-color-hui {
  945. background: #bbbbbb !important;
  946. }
  947. .canvas {
  948. width: 750px;
  949. height: 1190px;
  950. }
  951. .poster-pop {
  952. width: 450rpx;
  953. height: 714rpx;
  954. position: fixed;
  955. left: 50%;
  956. transform: translateX(-50%);
  957. z-index: 300;
  958. top: 50%;
  959. margin-top: -377rpx;
  960. }
  961. .poster-pop image {
  962. width: 100%;
  963. height: 100%;
  964. display: block;
  965. }
  966. .poster-pop .close {
  967. width: 46rpx;
  968. height: 75rpx;
  969. position: fixed;
  970. right: 0;
  971. top: -73rpx;
  972. display: block;
  973. }
  974. .poster-pop .save-poster {
  975. background-color: #df2d0a;
  976. font-size: :22rpx;
  977. color: #fff;
  978. text-align: center;
  979. height: 76rpx;
  980. line-height: 76rpx;
  981. width: 100%;
  982. }
  983. .poster-pop .keep {
  984. color: #fff;
  985. text-align: center;
  986. font-size: 25rpx;
  987. margin-top: 10rpx;
  988. }
  989. /deep/.mask {
  990. z-index: 99 !important;
  991. }
  992. .mask1 {
  993. position: fixed;
  994. top: 0;
  995. left: 0;
  996. right: 0;
  997. bottom: 0;
  998. background-color: #000;
  999. opacity: 0.5;
  1000. z-index: 288;
  1001. }
  1002. .home-nav {
  1003. /* #ifdef H5 */
  1004. top: 20rpx !important;
  1005. /* #endif */
  1006. }
  1007. .home-nav {
  1008. color: #333;
  1009. position: fixed;
  1010. /* #ifdef MP */
  1011. width: 126rpx;
  1012. left: 15rpx;
  1013. /* #endif */
  1014. /* #ifndef MP */
  1015. width: 56rpx;
  1016. left: 33rpx;
  1017. /* #endif */
  1018. height: 56rpx;
  1019. font-size: 33rpx;
  1020. z-index: 99;
  1021. background: rgba(255, 255, 255, 0.3);
  1022. border: 1px solid rgba(0, 0, 0, 0.1);
  1023. border-radius: 40rpx;
  1024. &.right {
  1025. right: 33rpx;
  1026. left: unset
  1027. }
  1028. &.on {
  1029. background: unset;
  1030. color: #333;
  1031. }
  1032. &.homeIndex {
  1033. /* #ifdef MP */
  1034. width: 98rpx;
  1035. /* #endif */
  1036. /* #ifndef MP */
  1037. border-color: rgba(255, 255, 255, 0);
  1038. /* #endif */
  1039. }
  1040. }
  1041. .home-nav .iconfont {
  1042. width: 58rpx;
  1043. text-align: center;
  1044. }
  1045. .home-nav .line {
  1046. width: 1rpx;
  1047. height: 34rpx;
  1048. background: #B3B3B3;
  1049. }
  1050. .home-nav .icon-xiangzuo {
  1051. width: auto;
  1052. font-size: 28rpx;
  1053. }
  1054. .share-box {
  1055. z-index: 1000;
  1056. position: fixed;
  1057. left: 0;
  1058. top: 0;
  1059. width: 100%;
  1060. height: 100%;
  1061. }
  1062. .share-box image {
  1063. width: 100%;
  1064. height: 100%;
  1065. }
  1066. .df {
  1067. display: flex;
  1068. align-items: center;
  1069. flex-wrap: nowrap;
  1070. width: 100%;
  1071. }
  1072. .attrImg {
  1073. width: 66rpx;
  1074. height: 66rpx;
  1075. border-radius: 6rpx;
  1076. display: block;
  1077. margin-right: 14rpx;
  1078. }
  1079. .switchTxt {
  1080. height: 60rpx;
  1081. flex: 1;
  1082. line-height: 60rpx;
  1083. box-sizing: border-box;
  1084. background: #eeeeee;
  1085. padding: 0 10rpx;
  1086. border-radius: 8rpx;
  1087. text-align: center;
  1088. }
  1089. .attribute {
  1090. padding: 10rpx 30rpx;
  1091. .line1 {
  1092. width: 600rpx;
  1093. }
  1094. }
  1095. .flex {
  1096. display: flex;
  1097. justify-content: space-between;
  1098. width: 100%;
  1099. }
  1100. .flexs {
  1101. display: flex;
  1102. }
  1103. .attr-txt {
  1104. display: flex;
  1105. flex-wrap: nowrap;
  1106. width: 130rpx;
  1107. }
  1108. </style>