integral_goods_details.vue 30 KB

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