integral_goods_details.vue 30 KB

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