integral_goods_details.vue 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185
  1. <template>
  2. <view :style="colorStyle">
  3. <view class="product-con">
  4. <!-- 头部 -->
  5. <!-- #ifndef APP-PLUS -->
  6. <view class='navbar' :style="{height:navH+'rpx',opacity:opacity}">
  7. <view class='navbarH' :style='"height:"+navH+"rpx;"'>
  8. <view class='navbarCon acea-row row-center-wrapper'>
  9. <view class="header acea-row row-center-wrapper">
  10. <view class="item line1">
  11. {{storeInfo.title}}
  12. </view>
  13. </view>
  14. </view>
  15. </view>
  16. </view>
  17. <view id="home" class="home-nav acea-row row-center-wrapper" :class="[opacity>0.5?'on':'']"
  18. :style="{ top: homeTop +'rpx'}">
  19. <view class="iconfont icon-fanhui2" @tap="returns"></view>
  20. <!-- #ifdef MP -->
  21. <view class="line"></view>
  22. <view class="iconfont icon-gengduo5" @click="moreNav"></view>
  23. <!-- #endif -->
  24. </view>
  25. <!-- #endif -->
  26. <!-- #ifdef H5 -->
  27. <view id="home" class="home-nav right acea-row row-center-wrapper" :class="[opacity>0.5?'on':'']"
  28. :style="{ top: homeTop +'rpx'}">
  29. <!-- #ifdef APP-PLUS || H5 -->
  30. <view class="iconfont icon-gengduo2" @click="moreNav"></view>
  31. </view>
  32. <!-- #endif -->
  33. <!-- #endif -->
  34. <homeList :navH="navH" :returnShow="returnShow" :currentPage="currentPage" :sysHeight="sysHeight">
  35. </homeList>
  36. <scroll-view :scroll-top="scrollTop" scroll-y="true" scroll-with-animation="true"
  37. :style="'height:' + height + 'px;'" @scroll="scroll">
  38. <view id="past0">
  39. <!-- #ifdef APP-PLUS || MP -->
  40. <view class="" :style="'width:100%;' + 'height:'+sysHeight"></view>
  41. <!-- #endif -->
  42. <productConSwiper :imgUrls="imgUrls"></productConSwiper>
  43. <view class="nav acea-row row-between-wrapper">
  44. <view class="share acea-row row-between row-bottom">
  45. <view class="money font-color">
  46. <image src="./static/my-point.png" mode=""></image>
  47. <text class="num" v-text="storeInfo.price || 0"></text>{{$t(`积分`)}}
  48. </view>
  49. <view></view>
  50. </view>
  51. </view>
  52. <view class="wrapper">
  53. <view class="introduce acea-row row-between">
  54. <view class="infor"> {{ storeInfo.title }}</view>
  55. </view>
  56. <view class="limit_good" v-if="storeInfo.num > 0">
  57. {{ $t(`最多可兑换`)}}: {{storeInfo.num}}{{$t(storeInfo.unit_name)}}
  58. </view>
  59. <view class="label acea-row row-middle">
  60. <view class="stock delete-line">{{$t(`划线价`)}}:{{ storeInfo.product_price }}</view>
  61. <view class="stock">{{$t(`限量`)}}:
  62. {{ storeInfo.quota_show }}
  63. </view>
  64. <view class="stock">{{$t(`已兑换`)}}:{{ storeInfo.sales }} </view>
  65. </view>
  66. </view>
  67. <view class="attribute acea-row row-between-wrapper" @tap="selecAttr" v-if="attribute.productAttr.length">
  68. <!-- <view class="df"><text class='atterTxt line1'>{{attr}}:{{attrValue}}</text></view>
  69. <view class='iconfont icon-jiantou'></view> -->
  70. <view class="flex">
  71. <view style="display: flex; align-items: center; width: 90%">
  72. <view class="attr-txt"> {{ attr }}: </view>
  73. <view class="atterTxt line1" style="width: 82%">{{
  74. attrValue
  75. }}</view>
  76. </view>
  77. <view class="iconfont icon-jiantou"></view>
  78. </view>
  79. <view class="acea-row row-between-wrapper" style="margin-top: 7px; padding-left: 70px"
  80. v-if="skuArr.length > 1">
  81. <view class="flexs">
  82. <image :src="item.image" v-for="(item, index) in skuArr.slice(0, 4)" :key="index" class="attrImg">
  83. </image>
  84. </view>
  85. <view class="switchTxt">{{$t(`共`)}}{{ skuArr.length }}{{$t(`种规格可选`)}}</view>
  86. </view>
  87. </view>
  88. </view>
  89. <view class="product-intro" id="past2">
  90. <view class="title">{{$t(`产品介绍`)}}</view>
  91. <view class="conter">
  92. <jyf-parser :html="storeInfo.description" ref="article" :tag-style="tagStyle"></jyf-parser>
  93. </view>
  94. </view>
  95. </scroll-view>
  96. <view class="footer acea-row row-between-wrapper">
  97. <navigator hover-class="none" open-type="switchTab" class="item" url="/pages/index/index">
  98. <view class="iconfont icon-shouye6"></view>
  99. <view class="p_center">{{$t(`首页`)}}</view>
  100. </navigator>
  101. <view class="bnt acea-row" v-if="
  102. attribute.productSelect.quota > 0 &&
  103. attribute.productSelect.product_stock > 0
  104. ">
  105. <view class="buy bnts" @tap="goCat">{{$t(`立即兑换`)}}</view>
  106. </view>
  107. <view class="bnt acea-row" v-else>
  108. <view class="bnts no-goods">{{$t(`无法兑换`)}}</view>
  109. </view>
  110. </view>
  111. </view>
  112. <product-window :attr="attribute" :limitNum="1" @myevent="onMyEvent" @ChangeAttr="ChangeAttr"
  113. @ChangeCartNum="ChangeCartNum" @attrVal="attrVal" @iptCartNum="iptCartNum" @getImg="showImg">
  114. </product-window>
  115. <cus-previewImg ref="cusPreviewImg" :list="skuArr" @changeSwitch="changeSwitch"
  116. @shareFriend="listenerActionSheet" />
  117. <!-- 分享按钮 -->
  118. <kefuIcon :ids="storeInfo.product_id" :routineContact="routineContact"></kefuIcon>
  119. <!-- 发送给朋友图片 -->
  120. </view>
  121. </template>
  122. <script>
  123. const app = getApp();
  124. import {
  125. mapGetters
  126. } from "vuex";
  127. import {
  128. getIntegralProductDetail
  129. } from '@/api/activity.js';
  130. import productConSwiper from '@/components/productConSwiper/index.vue'
  131. import productWindow from './component/productWindow.vue'
  132. import userEvaluation from '@/components/userEvaluation/index.vue'
  133. import kefuIcon from '@/components/kefuIcon';
  134. // #ifdef MP
  135. import authorize from '@/components/Authorize';
  136. // #endif
  137. import parser from "@/components/jyf-parser/jyf-parser";
  138. import countDown from '@/components/countDown';
  139. import {
  140. imageBase64
  141. } from "@/api/public";
  142. import {
  143. toLogin
  144. } from '@/libs/login.js';
  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. countDown,
  239. cusPreviewImg,
  240. homeList,
  241. // #ifdef MP
  242. authorize
  243. // #endif
  244. },
  245. computed: mapGetters(['isLogin']),
  246. watch: {
  247. isLogin: {
  248. handler: function(newV, oldV) {
  249. if (newV) {
  250. this.getIntegralProductDetail();
  251. }
  252. },
  253. deep: true
  254. }
  255. },
  256. onLoad(options) {
  257. let that = this
  258. let statusBarHeight = ''
  259. var pages = getCurrentPages();
  260. that.returnShow = pages.length === 1 ? false : true;
  261. //设置商品列表高度
  262. uni.getSystemInfo({
  263. success: function(res) {
  264. that.height = res.windowHeight
  265. statusBarHeight = res.statusBarHeight
  266. //res.windowHeight:获取整个窗口高度为px,*2为rpx;98为头部占据的高度;
  267. },
  268. });
  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 = Number(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. }).catch(err => {
  416. that.$util.Tips({
  417. title: err
  418. }, {
  419. tab: 3
  420. })
  421. });
  422. },
  423. setShare: function() {
  424. this.$wechat.isWeixin() &&
  425. this.$wechat.wechatEvevt([
  426. "updateAppMessageShareData",
  427. "updateTimelineShareData",
  428. "onMenuShareAppMessage",
  429. "onMenuShareTimeline"
  430. ], {
  431. desc: this.storeInfo.info,
  432. title: this.storeInfo.title,
  433. link: location.href,
  434. imgUrl: this.storeInfo.image
  435. }).then(res => {}).catch(err => {});
  436. },
  437. /**
  438. * 默认选中属性
  439. *
  440. */
  441. DefaultSelect: function() {
  442. let self = this
  443. let productAttr = self.attribute.productAttr;
  444. let value = [];
  445. for (var key in this.productValue) {
  446. if (this.productValue[key].quota > 0) {
  447. value = this.attribute.productAttr.length ? key.split(",") : [];
  448. break;
  449. }
  450. }
  451. for (let i = 0; i < productAttr.length; i++) {
  452. this.$set(productAttr[i], "index", value[i]);
  453. }
  454. //sort();排序函数:数字-英文-汉字;
  455. let productSelect = this.productValue[value.join(",")];
  456. if (productSelect && productAttr.length) {
  457. self.$set(
  458. self.attribute.productSelect,
  459. "store_name",
  460. self.storeInfo.title
  461. );
  462. self.$set(self.attribute.productSelect, "image", productSelect.image);
  463. self.$set(self.attribute.productSelect, "price", productSelect.price);
  464. self.$set(self.attribute.productSelect, "stock", productSelect.stock);
  465. self.$set(self.attribute.productSelect, "unique", productSelect.unique);
  466. self.$set(self.attribute.productSelect, "quota", productSelect.quota);
  467. self.$set(self.attribute.productSelect, "quota_show", productSelect.quota_show);
  468. self.$set(self.attribute.productSelect, "product_stock", productSelect.product_stock);
  469. self.$set(self.attribute.productSelect, "cart_num", 1);
  470. self.$set(self, "attrValue", value.join(","));
  471. self.attrValue = value.join(",")
  472. } else if (!productSelect && productAttr.length) {
  473. self.$set(
  474. self.attribute.productSelect,
  475. "store_name",
  476. self.storeInfo.title
  477. );
  478. self.$set(self.attribute.productSelect, "image", self.storeInfo.image);
  479. self.$set(self.attribute.productSelect, "price", self.storeInfo.price);
  480. self.$set(self.attribute.productSelect, "quota", 0);
  481. self.$set(self.attribute.productSelect, "quota_show", 0);
  482. self.$set(self.attribute.productSelect, "product_stock", 0);
  483. self.$set(self.attribute.productSelect, "stock", 0);
  484. self.$set(self.attribute.productSelect, "unique", "");
  485. self.$set(self.attribute.productSelect, "cart_num", 0);
  486. self.$set(self, "attrValue", "");
  487. self.$set(self, "attrTxt", self.$t(`请选择`));
  488. } else if (!productSelect && !productAttr.length) {
  489. self.$set(
  490. self.attribute.productSelect,
  491. "store_name",
  492. self.storeInfo.title
  493. );
  494. self.$set(self.attribute.productSelect, "image", self.storeInfo.image);
  495. self.$set(self.attribute.productSelect, "price", self.storeInfo.price);
  496. self.$set(self.attribute.productSelect, "stock", self.storeInfo.stock);
  497. self.$set(self.attribute.productSelect, "quota", self.storeInfo.quota);
  498. self.$set(self.attribute.productSelect, "product_stock", self.storeInfo.product_stock);
  499. self.$set(
  500. self.attribute.productSelect,
  501. "unique",
  502. self.storeInfo.unique || ""
  503. );
  504. self.$set(self.attribute.productSelect, "cart_num", 1);
  505. self.$set(self.attribute.productSelect, "quota", productSelect.quota);
  506. self.$set(self.attribute.productSelect, "product_stock", productSelect.product_stock);
  507. self.$set(self, "attrValue", "");
  508. self.$set(self, "attrTxt", self.$t(`请选择`));
  509. }
  510. },
  511. selecAttr: function() {
  512. this.attribute.cartAttr = true
  513. },
  514. onMyEvent: function() {
  515. this.$set(this.attribute, 'cartAttr', false);
  516. this.$set(this, 'isOpen', false);
  517. },
  518. /**
  519. * 购物车数量加和数量减
  520. *
  521. */
  522. ChangeCartNum: function(changeValue) {
  523. //changeValue:是否 加|减
  524. //获取当前变动属性
  525. let productSelect = this.productValue[this.attrValue];
  526. if (this.cart_num) {
  527. productSelect.cart_num = this.cart_num;
  528. this.attribute.productSelect.cart_num = this.cart_num;
  529. }
  530. //如果没有属性,赋值给商品默认库存
  531. if (productSelect === undefined && !this.attribute.productAttr.length)
  532. productSelect = this.attribute.productSelect;
  533. //无属性值即库存为0;不存在加减;
  534. if (productSelect === undefined) return;
  535. let stock = productSelect.stock || 0;
  536. let quotaShow = productSelect.quota_show || 0;
  537. let quota = productSelect.quota || 0;
  538. let productStock = productSelect.product_stock || 0;
  539. let num = this.attribute.productSelect;
  540. let nums = this.storeInfo.num || 0;
  541. //设置默认数据
  542. if (productSelect.cart_num == undefined) productSelect.cart_num = 1;
  543. if (changeValue) {
  544. if (num.cart_num < this.attribute.productSelect.quota) {
  545. num.cart_num++;
  546. this.$set(this.attribute.productSelect, "cart_num", num.cart_num);
  547. this.$set(this, "cart_num", num.cart_num);
  548. this.$set(this.attribute.productSelect, "cart_num", num.cart_num);
  549. }
  550. } else {
  551. if (num.cart_num == 1) return
  552. num.cart_num--;
  553. this.$set(this, "cart_num", num.cart_num);
  554. this.$set(this.attribute.productSelect, "cart_num", num.cart_num);
  555. }
  556. },
  557. attrVal(val) {
  558. this.attribute.productAttr[val.indexw].index = this.attribute.productAttr[val.indexw].attr_values[val
  559. .indexn];
  560. },
  561. /**
  562. * 属性变动赋值
  563. *
  564. */
  565. ChangeAttr: function(res) {
  566. this.$set(this, 'cart_num', 1);
  567. let productSelect = this.productValue[res];
  568. this.$set(this, "selectSku", productSelect);
  569. if (productSelect) {
  570. this.$set(this.attribute.productSelect, "image", productSelect.image);
  571. this.$set(this.attribute.productSelect, "price", productSelect.price);
  572. this.$set(this.attribute.productSelect, "stock", productSelect.stock);
  573. this.$set(this.attribute.productSelect, "unique", productSelect.unique);
  574. this.$set(this.attribute.productSelect, "cart_num", 1);
  575. this.$set(this.attribute.productSelect, "quota", productSelect.quota);
  576. this.$set(this.attribute.productSelect, "quota_show", productSelect.quota_show);
  577. this.$set(this, "attrValue", res);
  578. this.attrTxt = this.$t(`已选择`)
  579. } else {
  580. this.$set(this.attribute.productSelect, "image", this.storeInfo.image);
  581. this.$set(this.attribute.productSelect, "price", this.storeInfo.price);
  582. this.$set(this.attribute.productSelect, "stock", 0);
  583. this.$set(this.attribute.productSelect, "unique", "");
  584. this.$set(this.attribute.productSelect, "cart_num", 0);
  585. this.$set(this.attribute.productSelect, "quota", 0);
  586. this.$set(this.attribute.productSelect, "quota_show", 0);
  587. this.$set(this, "attrValue", "");
  588. this.attrTxt = this.$t(`已选择`)
  589. }
  590. },
  591. scroll: function(e) {
  592. var that = this,
  593. scrollY = e.detail.scrollTop;
  594. var opacity = scrollY / 200;
  595. opacity = opacity > 1 ? 1 : opacity;
  596. that.opacity = opacity
  597. this.currentPage = false
  598. that.scrollY = scrollY
  599. if (that.lock) {
  600. that.lock = false
  601. return;
  602. }
  603. for (var i = 0; i < that.topArr.length; i++) {
  604. if (scrollY < that.topArr[i] - (app.globalData.navHeight / 2) + that.heightArr[i]) {
  605. that.navActive = i
  606. break
  607. }
  608. }
  609. },
  610. tap: function(item, index) {
  611. var id = item.id;
  612. var index = index;
  613. var that = this;
  614. // if (!this.data.good_list.length && id == "past2") {
  615. // id = "past3"
  616. // }
  617. this.toView = id;
  618. this.navActive = index;
  619. this.lock = true;
  620. this.scrollTop = index > 0 ? that.topArr[index] - (app.globalData.navHeight / 2) : that.topArr[index]
  621. },
  622. //点击sku图片打开轮播图
  623. showImg(index) {
  624. this.$refs.cusPreviewImg.open(this.selectSku.suk);
  625. },
  626. /**
  627. * 分享打开
  628. *
  629. */
  630. listenerActionSheet() {
  631. this.currentPage = false
  632. if (this.isLogin === false) {
  633. toLogin();
  634. } else {
  635. if (this.posterImage) {
  636. this.posters = true;
  637. return
  638. }
  639. // #ifdef H5
  640. if (this.$wechat.isWeixin() === true) {
  641. this.weixinStatus = true;
  642. }
  643. // #endif
  644. // #ifndef APP-PLUS
  645. this.downloadFilePromotionCode();
  646. // #endif
  647. // #ifdef APP-PLUS
  648. if (this.PromotionCode.indexOf("http") == 0) {
  649. // this.downloadFilePromotionCode();
  650. }
  651. // #endif
  652. this.posters = true;
  653. }
  654. },
  655. //滑动轮播图选择商品
  656. changeSwitch(e) {
  657. let productSelect = this.skuArr[e];
  658. this.$set(this, "selectSku", productSelect);
  659. var skuList = productSelect.suk.split(",");
  660. this.$set(this.attribute.productAttr[0], "index", skuList[0]);
  661. if (skuList.length == 2) {
  662. this.$set(this.attribute.productAttr[0], "index", skuList[0]);
  663. this.$set(this.attribute.productAttr[1], "index", skuList[1]);
  664. } else if (skuList.length == 3) {
  665. this.$set(this.attribute.productAttr[0], "index", skuList[0]);
  666. this.$set(this.attribute.productAttr[1], "index", skuList[1]);
  667. this.$set(this.attribute.productAttr[2], "index", skuList[2]);
  668. } else if (skuList.length == 4) {
  669. this.$set(this.attribute.productAttr[0], "index", skuList[0]);
  670. this.$set(this.attribute.productAttr[1], "index", skuList[1]);
  671. this.$set(this.attribute.productAttr[2], "index", skuList[2]);
  672. this.$set(this.attribute.productAttr[3], "index", skuList[3]);
  673. }
  674. if (productSelect) {
  675. this.$set(this.attribute.productSelect, "image", productSelect.image);
  676. this.$set(this.attribute.productSelect, "price", productSelect.price);
  677. this.$set(this.attribute.productSelect, "stock", productSelect.stock);
  678. this.$set(this.attribute.productSelect, "unique", productSelect.unique);
  679. this.$set(this.attribute.productSelect, "vipPrice", productSelect.vipPrice);
  680. this.$set(this, "attrTxt", this.$t(`已选择`));
  681. this.$set(this, "attrValue", productSelect.suk);
  682. }
  683. },
  684. /*
  685. * 下订单
  686. */
  687. goCat: function() {
  688. var that = this;
  689. this.currentPage = false
  690. var productSelect = this.productValue[this.attrValue];
  691. //打开属性
  692. if (this.isOpen)
  693. this.attribute.cartAttr = true
  694. else
  695. this.attribute.cartAttr = !this.attribute.cartAttr
  696. //只有关闭属性弹窗时进行加入购物车
  697. if (this.attribute.cartAttr === true && this.isOpen == false) return this.isOpen = true
  698. //如果有属性,没有选择,提示用户选择
  699. if (this.attribute.productAttr.length && productSelect === undefined && this.isOpen == true) return app
  700. .$util.Tips({
  701. title: this.$t(`请选择属性`)
  702. });
  703. if (this.cart_num <= 0) {
  704. return app.$util.Tips({
  705. title: this.$t(`请选择数量`)
  706. });
  707. }
  708. this.isOpen = false
  709. uni.navigateTo({
  710. url: `/pages/points_mall/integral_order?unique=${productSelect.unique}&num=${this.cart_num || 1}`
  711. });
  712. },
  713. }
  714. }
  715. </script>
  716. <style lang="scss">
  717. .generate-posters {
  718. width: 100%;
  719. height: 170rpx;
  720. background-color: #fff;
  721. position: fixed;
  722. left: 0;
  723. bottom: 0;
  724. z-index: 300;
  725. transform: translate3d(0, 100%, 0);
  726. transition: all 0.3s cubic-bezier(0.25, 0.5, 0.5, 0.9);
  727. border-top: 1rpx solid #eee;
  728. }
  729. .generate-posters.on {
  730. transform: translate3d(0, 0, 0);
  731. }
  732. .generate-posters .item {
  733. flex: 1;
  734. text-align: center;
  735. font-size: 30rpx;
  736. }
  737. .generate-posters .item .iconfont {
  738. font-size: 80rpx;
  739. color: #5eae72;
  740. }
  741. .generate-posters .item .iconfont.icon-haibao {
  742. color: #5391f1;
  743. }
  744. .navbar .header {
  745. width: 400rpx;
  746. height: 96rpx;
  747. font-size: 30rpx;
  748. color: #050505;
  749. background-color: #fff;
  750. /* #ifdef MP */
  751. padding-right: 95rpx;
  752. /* #endif */
  753. }
  754. .icon-xiangzuo {
  755. /* #ifdef H5 */
  756. top: 30rpx !important;
  757. /* #endif */
  758. }
  759. .navbar .header .item {
  760. position: relative;
  761. margin: 0 25rpx;
  762. }
  763. .navbar {
  764. position: fixed;
  765. background-color: #fff;
  766. top: 0;
  767. left: 0;
  768. z-index: 99;
  769. width: 100%;
  770. }
  771. .navbar .navbarH {
  772. position: relative;
  773. }
  774. .navbar .navbarH .navbarCon {
  775. position: absolute;
  776. bottom: 0;
  777. height: 100rpx;
  778. width: 100%;
  779. }
  780. .icon-xiangzuo {
  781. /* color: #000;
  782. position: fixed;
  783. font-size: 40rpx;
  784. width: 100rpx;
  785. height: 56rpx;
  786. line-height: 54rpx;
  787. z-index: 1000;
  788. left: 33rpx; */
  789. }
  790. .product-con .nav {
  791. width: 100%;
  792. height: 100rpx;
  793. padding: 0 30rpx;
  794. box-sizing: border-box;
  795. background-color: #fff;
  796. }
  797. .product-con .nav .money {
  798. font-size: 28rpx;
  799. color: #e93323;
  800. font-weight: bold;
  801. image {
  802. width: 34rpx;
  803. height: 34rpx;
  804. }
  805. }
  806. .product-con .nav .money .num {
  807. font-size: 48rpx;
  808. padding-left: 16rpx;
  809. }
  810. .product-con .nav .money .y-money {
  811. font-size: 26rpx;
  812. margin-left: 10rpx;
  813. text-decoration: line-through;
  814. }
  815. .product-con .nav .timeItem {
  816. font-size: 20rpx;
  817. color: #fff;
  818. text-align: center;
  819. }
  820. .product-con .nav .timeItem .timeCon {
  821. margin-top: 10rpx;
  822. }
  823. .product-con .nav .timeItem .timeCon .num {
  824. padding: 0 7rpx;
  825. font-size: 22rpx;
  826. color: #ff3d3d;
  827. background-color: #fff;
  828. border-radius: 2rpx;
  829. }
  830. .product-con .nav .timeState {
  831. font-size: 28rpx;
  832. color: #fff;
  833. }
  834. .product-con .nav .iconfont {
  835. color: #fff;
  836. font-size: 30rpx;
  837. margin-left: 20rpx;
  838. }
  839. .product-con .wrapper {
  840. padding: 0 32rpx 32rpx 32rpx;
  841. width: 100%;
  842. box-sizing: border-box;
  843. }
  844. .product-con .wrapper .introduce {
  845. margin: 0;
  846. }
  847. .limit_good {
  848. font-size: 16rpx;
  849. margin: 10rpx 0rpx;
  850. color: red;
  851. }
  852. .product-con .wrapper .introduce .infor {
  853. // width: 570rpx;
  854. }
  855. .product-con .wrapper .introduce .iconfont {
  856. font-size: 37rpx;
  857. color: #515151;
  858. }
  859. .product-con .wrapper .label {
  860. display: flex;
  861. justify-content: space-between;
  862. margin: 18rpx 0 0 0;
  863. font-size: 24rpx;
  864. color: #82848f;
  865. }
  866. .product-con .wrapper .label .stock {}
  867. .product-con .footer {
  868. padding: 0 20rpx 0 30rpx;
  869. position: fixed;
  870. bottom: 0;
  871. width: 100%;
  872. box-sizing: border-box;
  873. background-color: #fff;
  874. z-index: 277;
  875. border-top: 1rpx solid #f0f0f0;
  876. height: 100rpx;
  877. display: flex;
  878. align-items: center;
  879. flex-wrap: nowrap;
  880. height: calc(100rpx+ constant(safe-area-inset-bottom)); ///兼容 IOS<11.2/
  881. height: calc(100rpx + env(safe-area-inset-bottom)); ///兼容 IOS>11.2/
  882. }
  883. .product-con .footer .item {
  884. width: 100rpx;
  885. font-size: 18rpx;
  886. color: #666;
  887. }
  888. .product-con .footer .item .iconfont {
  889. text-align: center;
  890. font-size: 40rpx;
  891. }
  892. .product-con .footer .item .iconfont.icon-shoucang1 {
  893. color: var(--view-theme);
  894. }
  895. .product-con .footer .item .iconfont.icon-gouwuche1 {
  896. font-size: 40rpx;
  897. position: relative;
  898. }
  899. .product-con .footer .item .iconfont.icon-gouwuche1 .num {
  900. color: #fff;
  901. position: absolute;
  902. font-size: 18rpx;
  903. padding: 2rpx 8rpx 3rpx;
  904. border-radius: 200rpx;
  905. top: -10rpx;
  906. right: -10rpx;
  907. }
  908. .product-con .footer .bnt {
  909. width: 100%;
  910. height: 76rpx;
  911. }
  912. .product-con .footer .bnt .bnts {
  913. width: 100%;
  914. text-align: center;
  915. line-height: 76rpx;
  916. color: #fff;
  917. font-size: 28rpx;
  918. }
  919. .product-con .footer .bnt .joinCart {
  920. border-radius: 50rpx 0 0 50rpx;
  921. background-image: linear-gradient(to right, #fea10f 0%, #fa8013 100%);
  922. }
  923. .product-con .footer .bnt .buy {
  924. border-radius: 50rpx;
  925. // background-image: linear-gradient(to right, #fa6514 0%, #e93323 100%);
  926. background-color: var(--view-theme);
  927. }
  928. .product-con .footer .bnt .no-goods {
  929. border-radius: 50rpx;
  930. background-color: #cccccc;
  931. }
  932. .product-con .conter {
  933. display: block;
  934. }
  935. .product-con .conter img {
  936. display: block;
  937. }
  938. .bg-color-hui {
  939. background: #bbbbbb !important;
  940. }
  941. .canvas {
  942. width: 750px;
  943. height: 1190px;
  944. }
  945. .poster-pop {
  946. width: 450rpx;
  947. height: 714rpx;
  948. position: fixed;
  949. left: 50%;
  950. transform: translateX(-50%);
  951. z-index: 300;
  952. top: 50%;
  953. margin-top: -377rpx;
  954. }
  955. .poster-pop image {
  956. width: 100%;
  957. height: 100%;
  958. display: block;
  959. }
  960. .poster-pop .close {
  961. width: 46rpx;
  962. height: 75rpx;
  963. position: fixed;
  964. right: 0;
  965. top: -73rpx;
  966. display: block;
  967. }
  968. .poster-pop .save-poster {
  969. background-color: #df2d0a;
  970. font-size: :22rpx;
  971. color: #fff;
  972. text-align: center;
  973. height: 76rpx;
  974. line-height: 76rpx;
  975. width: 100%;
  976. }
  977. .poster-pop .keep {
  978. color: #fff;
  979. text-align: center;
  980. font-size: 25rpx;
  981. margin-top: 10rpx;
  982. }
  983. /deep/.mask {
  984. z-index: 99 !important;
  985. }
  986. .mask1 {
  987. position: fixed;
  988. top: 0;
  989. left: 0;
  990. right: 0;
  991. bottom: 0;
  992. background-color: #000;
  993. opacity: 0.5;
  994. z-index: 288;
  995. }
  996. .home-nav {
  997. /* #ifdef H5 */
  998. top: 20rpx !important;
  999. /* #endif */
  1000. }
  1001. .home-nav {
  1002. color: #333;
  1003. position: fixed;
  1004. /* #ifdef MP */
  1005. width: 126rpx;
  1006. left: 15rpx;
  1007. /* #endif */
  1008. /* #ifndef MP */
  1009. width: 56rpx;
  1010. left: 33rpx;
  1011. /* #endif */
  1012. height: 56rpx;
  1013. font-size: 33rpx;
  1014. z-index: 99;
  1015. background: rgba(255, 255, 255, 0.3);
  1016. border: 1px solid rgba(0, 0, 0, 0.1);
  1017. border-radius: 40rpx;
  1018. &.right {
  1019. right: 33rpx;
  1020. left: unset
  1021. }
  1022. &.on {
  1023. background: unset;
  1024. color: #333;
  1025. }
  1026. &.homeIndex {
  1027. /* #ifdef MP */
  1028. width: 98rpx;
  1029. /* #endif */
  1030. /* #ifndef MP */
  1031. border-color: rgba(255, 255, 255, 0);
  1032. /* #endif */
  1033. }
  1034. }
  1035. .home-nav .iconfont {
  1036. width: 58rpx;
  1037. text-align: center;
  1038. }
  1039. .home-nav .line {
  1040. width: 1rpx;
  1041. height: 34rpx;
  1042. background: #B3B3B3;
  1043. }
  1044. .home-nav .icon-xiangzuo {
  1045. width: auto;
  1046. font-size: 28rpx;
  1047. }
  1048. .share-box {
  1049. z-index: 1000;
  1050. position: fixed;
  1051. left: 0;
  1052. top: 0;
  1053. width: 100%;
  1054. height: 100%;
  1055. }
  1056. .share-box image {
  1057. width: 100%;
  1058. height: 100%;
  1059. }
  1060. .df {
  1061. display: flex;
  1062. align-items: center;
  1063. flex-wrap: nowrap;
  1064. width: 100%;
  1065. }
  1066. .attrImg {
  1067. width: 66rpx;
  1068. height: 66rpx;
  1069. border-radius: 6rpx;
  1070. display: block;
  1071. margin-right: 14rpx;
  1072. }
  1073. .switchTxt {
  1074. height: 60rpx;
  1075. flex: 1;
  1076. line-height: 60rpx;
  1077. box-sizing: border-box;
  1078. background: #eeeeee;
  1079. padding: 0 10rpx;
  1080. border-radius: 8rpx;
  1081. text-align: center;
  1082. }
  1083. .attribute {
  1084. padding: 10rpx 30rpx;
  1085. .line1 {
  1086. width: 600rpx;
  1087. }
  1088. }
  1089. .flex {
  1090. display: flex;
  1091. justify-content: space-between;
  1092. width: 100%;
  1093. }
  1094. .flexs {
  1095. display: flex;
  1096. }
  1097. .attr-txt {
  1098. display: flex;
  1099. flex-wrap: nowrap;
  1100. width: 130rpx;
  1101. }
  1102. .delete-line {
  1103. text-decoration: line-through;
  1104. }
  1105. </style>