integral_goods_details.vue 30 KB

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