goods_cate2.vue 27 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072
  1. <template>
  2. <view class="goodCate">
  3. <!-- <view>
  4. <scroll-view scroll-y="true" class="scroll-Y"> -->
  5. <view class="header acea-row row-center-wrapper">
  6. <navigator open-type="switchTab" url="/pages/index/index" class="pageIndex" hover-class="none" @click="jumpIndex">
  7. <text class="iconfont icon-shouye3"></text>
  8. </navigator>
  9. <navigator url="/pages/goods/goods_search/index" class="search acea-row row-center-wrapper" hover-class="none">
  10. <text class="iconfont icon-xiazai5"></text>
  11. {{ $t(`搜索商品名称`) }}
  12. </navigator>
  13. </view>
  14. <view class="conter">
  15. <view class="aside">
  16. <scroll-view scroll-y="true" scroll-with-animation="true" style="height: calc(100% - 100rpx)">
  17. <view class="item acea-row row-center-wrapper" :class="index == navActive ? 'on' : ''" v-for="(item, index) in categoryList" :key="index" @click="tapNav(index, item)">
  18. <text>{{ $t(item.cate_name) }}</text>
  19. </view>
  20. </scroll-view>
  21. </view>
  22. <view class="wrapper">
  23. <view class="bgcolor" v-if="iSlong">
  24. <view class="longTab acea-row row-middle">
  25. <scroll-view scroll-x="true" style="white-space: nowrap; display: flex; height: 44rpx" scroll-with-animation :scroll-left="tabLeft" show-scrollbar="true">
  26. <view
  27. class="longItem"
  28. :style="'width:' + isWidth + 'px'"
  29. :class="index === tabClick ? 'click' : ''"
  30. v-for="(item, index) in categoryErList"
  31. :key="index"
  32. @click="longClick(index)"
  33. >
  34. {{ $t(item.cate_name) }}
  35. </view>
  36. </scroll-view>
  37. </view>
  38. <view class="openList" @click="openTap"><text class="iconfont icon-xiala"></text></view>
  39. </view>
  40. <view v-else>
  41. <view class="downTab">
  42. <view class="title acea-row row-between-wrapper">
  43. <view>{{ categoryTitle }}</view>
  44. <view class="closeList" @click="closeTap"><text class="iconfont icon-xiala"></text></view>
  45. </view>
  46. <view class="children">
  47. <view class="acea-row row-middle">
  48. <view class="item line1" :class="index === tabClick ? 'click' : ''" v-for="(item, index) in categoryErList" :key="index" @click="longClick(index)">
  49. {{ $t(item.cate_name) }}
  50. </view>
  51. </view>
  52. </view>
  53. </view>
  54. <view class="mask" @click="closeTap"></view>
  55. </view>
  56. <goodList
  57. ref="d_goodClass"
  58. :tempArr="tempArr"
  59. :isLogin="isLogin"
  60. @gocartduo="goCartDuo"
  61. @gocartdan="goCartDan"
  62. @ChangeCartNumDan="ChangeCartNumDan"
  63. @detail="goDetail"
  64. ></goodList>
  65. <view class="loadingicon acea-row row-center-wrapper">
  66. <text class="loading iconfont icon-jiazai" :hidden="loading == false"></text>
  67. {{ loadTitle }}
  68. </view>
  69. </view>
  70. </view>
  71. <view class="footer acea-row row-between-wrapper">
  72. <view class="cartIcon acea-row row-center-wrapper" @click="getCartList(0)" v-if="cartData.cartList.length">
  73. <view class="iconfont icon-gouwuche-yangshi2"></view>
  74. <view class="num">{{ cartCount }}</view>
  75. </view>
  76. <view class="cartIcon acea-row row-center-wrapper noCart" v-else>
  77. <view class="iconfont icon-gouwuche-yangshi2"></view>
  78. </view>
  79. <view class="money acea-row row-middle">
  80. <view>
  81. {{ $t(`¥`) }}
  82. <text class="num">{{ totalPrice }}</text>
  83. </view>
  84. <view class="bnt" @click="subOrder">{{ $t(`去付款`) }}</view>
  85. </view>
  86. </view>
  87. <cartList :cartData="cartData" @closeList="closeList" @ChangeCartNumDan="ChangeCartList" @ChangeSubDel="ChangeSubDel" @ChangeOneDel="ChangeOneDel"></cartList>
  88. <productWindow
  89. :attr="attr"
  90. :isShow="1"
  91. :iSplus="1"
  92. :iScart="1"
  93. :minQty="storeInfo.min_qty"
  94. @myevent="onMyEvent"
  95. @ChangeAttr="ChangeAttr"
  96. @ChangeCartNum="ChangeCartNumDuo"
  97. @attrVal="attrVal"
  98. @iptCartNum="iptCartNum"
  99. @goCat="goCatNum"
  100. id="product-window"
  101. :is_vip="is_vip"
  102. ></productWindow>
  103. <!-- </scroll-view>
  104. </view> -->
  105. </view>
  106. </template>
  107. <script>
  108. import { getCategoryList, getProductslist, getAttr, postCartNum } from '@/api/store.js';
  109. import { vcartList, getCartCounts, cartDel } from '@/api/order.js';
  110. import productWindow from '@/components/productWindow';
  111. import goodList from '@/components/catGoodList';
  112. import cartList from '@/components/cartList';
  113. import { mapGetters } from 'vuex';
  114. import { goShopDetail } from '@/libs/order.js';
  115. import { toLogin } from '@/libs/login.js';
  116. export default {
  117. props: {
  118. isNew: {
  119. type: Boolean,
  120. default: false
  121. }
  122. },
  123. watch: {
  124. isNew(newVal) {
  125. this.getAllCategory(1);
  126. }
  127. },
  128. computed: mapGetters(['isLogin', 'uid']),
  129. components: {
  130. productWindow,
  131. goodList,
  132. cartList
  133. },
  134. data() {
  135. return {
  136. categoryList: [],
  137. navActive: 0,
  138. categoryTitle: '',
  139. categoryErList: [],
  140. tabLeft: 0,
  141. isWidth: 0, //每个导航栏占位
  142. tabClick: 0, //导航栏被点击
  143. iSlong: true,
  144. tempArr: [],
  145. loading: false,
  146. loadend: false,
  147. loadTitle: this.$t(`加载更多`),
  148. page: 1,
  149. limit: 10,
  150. cid: 0, //一级分类
  151. sid: 0, //二级分类
  152. isAuto: false, //没有授权的不会自动授权
  153. isShowAuth: false, //是否隐藏授权
  154. attr: {
  155. cartAttr: false,
  156. productAttr: [],
  157. productSelect: {}
  158. },
  159. productValue: [],
  160. attrValue: '', //已选属性
  161. storeName: '', //多属性产品名称
  162. id: 0,
  163. cartData: {
  164. cartList: [],
  165. iScart: false
  166. },
  167. cartCount: 0,
  168. totalPrice: 0.0,
  169. is_vip: 0, //是否是会员
  170. cart_num: 0,
  171. storeInfo: {}
  172. };
  173. },
  174. mounted() {
  175. let that = this;
  176. // 获取设备宽度
  177. uni.getSystemInfo({
  178. success(e) {
  179. that.isWidth = e.windowWidth / 5;
  180. }
  181. });
  182. this.getAllCategory(1);
  183. },
  184. methods: {
  185. jumpIndex() {
  186. this.$emit('jumpIndex');
  187. },
  188. // 生成订单;
  189. subOrder: function () {
  190. let that = this,
  191. list = that.cartData.cartList,
  192. ids = [];
  193. if (list.length) {
  194. list.forEach((item) => {
  195. ids.push(item.id);
  196. });
  197. uni.navigateTo({
  198. url: '/pages/goods/order_confirm/index?cartId=' + ids.join(',')
  199. });
  200. that.cartData.iScart = false;
  201. } else {
  202. return that.$util.Tips({
  203. title: this.$t(`请选择产品`)
  204. });
  205. }
  206. },
  207. // 计算总价;
  208. getTotalPrice: function () {
  209. let that = this,
  210. list = that.cartData.cartList,
  211. totalPrice = 0.0;
  212. list.forEach((item) => {
  213. if (item.attrStatus && item.status) {
  214. totalPrice = that.$util.$h.Add(totalPrice, that.$util.$h.Mul(item.cart_num, item.truePrice));
  215. }
  216. });
  217. that.$set(that, 'totalPrice', totalPrice);
  218. },
  219. ChangeSubDel: function (event) {
  220. let that = this,
  221. list = that.cartData.cartList,
  222. ids = [];
  223. list.forEach((item) => {
  224. ids.push(item.id);
  225. });
  226. cartDel(ids.join(',')).then((res) => {
  227. that.$set(that.cartData, 'cartList', []);
  228. that.cartData.iScart = false;
  229. that.totalPrice = 0.0;
  230. that.page = 1;
  231. that.loadend = false;
  232. that.tempArr = [];
  233. that.productslist();
  234. that.getCartNum();
  235. });
  236. },
  237. ChangeOneDel: function (id, index) {
  238. let that = this,
  239. list = that.cartData.cartList;
  240. cartDel(id.toString()).then((res) => {
  241. list.splice(index, 1);
  242. if (!list.length) {
  243. that.cartData.iScart = false;
  244. that.page = 1;
  245. that.loadend = false;
  246. that.tempArr = [];
  247. that.productslist();
  248. }
  249. that.getCartNum();
  250. });
  251. },
  252. getCartList(iSshow) {
  253. let that = this;
  254. vcartList().then((res) => {
  255. that.$set(that.cartData, 'cartList', res.data);
  256. if (res.data.length) {
  257. that.$set(that.cartData, 'iScart', iSshow ? false : !that.cartData.iScart);
  258. } else {
  259. that.$set(that.cartData, 'iScart', false);
  260. }
  261. that.getTotalPrice();
  262. });
  263. },
  264. closeList(e) {
  265. this.$set(this.cartData, 'iScart', e);
  266. this.page = 1;
  267. this.loadend = false;
  268. this.tempArr = [];
  269. this.productslist();
  270. },
  271. getCartNum: function () {
  272. let that = this;
  273. getCartCounts().then((res) => {
  274. that.cartCount = res.data.count;
  275. that.$refs.d_goodClass.addIng = false;
  276. });
  277. },
  278. onMyEvent: function () {
  279. this.$set(this.attr, 'cartAttr', false);
  280. },
  281. /**
  282. * 默认选中属性
  283. *
  284. */
  285. DefaultSelect: function () {
  286. let productAttr = this.attr.productAttr;
  287. let value = [];
  288. for (let key in this.productValue) {
  289. if (this.productValue[key].stock > 0) {
  290. value = this.attr.productAttr.length ? key.split(',') : [];
  291. break;
  292. }
  293. }
  294. for (let i = 0; i < productAttr.length; i++) {
  295. this.$set(productAttr[i], 'index', value[i]);
  296. }
  297. //sort();排序函数:数字-英文-汉字;
  298. let productSelect = this.productValue[value.join(',')];
  299. if (productSelect && productAttr.length) {
  300. this.$set(this.attr.productSelect, 'store_name', this.storeName);
  301. this.$set(this.attr.productSelect, 'image', productSelect.image);
  302. this.$set(this.attr.productSelect, 'price', productSelect.price);
  303. this.$set(this.attr.productSelect, 'stock', productSelect.stock);
  304. this.$set(this.attr.productSelect, 'unique', productSelect.unique);
  305. this.$set(this.attr.productSelect, 'cart_num', this.storeInfo.min_qty);
  306. this.$set(this.attr.productSelect, 'vip_price', productSelect.vip_price);
  307. this.$set(this, 'attrValue', value.join(','));
  308. } else if (!productSelect && productAttr.length) {
  309. this.$set(this.attr.productSelect, 'store_name', this.storeName);
  310. this.$set(this.attr.productSelect, 'image', this.storeInfo.image);
  311. this.$set(this.attr.productSelect, 'price', this.storeInfo.price);
  312. this.$set(this.attr.productSelect, 'stock', 0);
  313. this.$set(this.attr.productSelect, 'unique', '');
  314. this.$set(this.attr.productSelect, 'cart_num', 0);
  315. this.$set(this.attr.productSelect, 'vip_price', this.storeInfo.vip_price);
  316. this.$set(this, 'attrValue', '');
  317. } else if (!productSelect && !productAttr.length) {
  318. this.$set(this.attr.productSelect, 'store_name', this.storeName);
  319. this.$set(this.attr.productSelect, 'image', this.storeInfo.image);
  320. this.$set(this.attr.productSelect, 'price', this.storeInfo.price);
  321. this.$set(this.attr.productSelect, 'stock', this.storeInfo.stock);
  322. this.$set(this.attr.productSelect, 'unique', this.storeInfo.unique || '');
  323. this.$set(this.attr.productSelect, 'cart_num', this.storeInfo.min_qty);
  324. this.$set(this, 'attrValue', '');
  325. this.$set(this.attr.productSelect, 'vip_price', this.storeInfo.vip_price);
  326. }
  327. },
  328. /**
  329. * 属性变动赋值
  330. *
  331. */
  332. ChangeAttr: function (res) {
  333. let productSelect = this.productValue[res];
  334. if (productSelect && productSelect.stock > 0) {
  335. this.$set(this.attr.productSelect, 'image', productSelect.image);
  336. this.$set(this.attr.productSelect, 'price', productSelect.price);
  337. this.$set(this.attr.productSelect, 'stock', productSelect.stock);
  338. this.$set(this.attr.productSelect, 'unique', productSelect.unique);
  339. this.$set(this.attr.productSelect, 'vip_price', productSelect.vip_price);
  340. this.$set(this.attr.productSelect, 'cart_num', this.storeInfo.min_qty);
  341. this.$set(this, 'attrValue', res);
  342. } else if (productSelect && productSelect.stock == 0) {
  343. this.$set(this.attr.productSelect, 'image', productSelect.image);
  344. this.$set(this.attr.productSelect, 'price', productSelect.price);
  345. this.$set(this.attr.productSelect, 'stock', 0);
  346. this.$set(this.attr.productSelect, 'unique', '');
  347. this.$set(this.attr.productSelect, 'vip_price', productSelect.vip_price);
  348. this.$set(this.attr.productSelect, 'cart_num', 0);
  349. this.$set(this, 'attrValue', '');
  350. } else {
  351. this.$set(this.attr.productSelect, 'image', this.storeInfo.image);
  352. this.$set(this.attr.productSelect, 'price', this.storeInfo.price);
  353. this.$set(this.attr.productSelect, 'stock', 0);
  354. this.$set(this.attr.productSelect, 'unique', '');
  355. this.$set(this.attr.productSelect, 'vip_price', this.storeInfo.vip_price);
  356. this.$set(this.attr.productSelect, 'cart_num', 0);
  357. this.$set(this, 'attrValue', '');
  358. }
  359. },
  360. attrVal(val) {
  361. this.$set(this.attr.productAttr[val.indexw], 'index', this.attr.productAttr[val.indexw].attr_values[val.indexn]);
  362. },
  363. /**
  364. * 购物车手动填写
  365. *
  366. */
  367. iptCartNum: function (e) {
  368. // this.$set(this.attr.productSelect, 'cart_num', e);
  369. if (e) {
  370. let number = this.storeInfo.min_qty;
  371. if (Number.isInteger(parseInt(e)) && parseInt(e) >= this.storeInfo.min_qty) {
  372. number = parseInt(e);
  373. }
  374. this.$nextTick((e) => {
  375. this.$set(this.attr.productSelect, 'cart_num', e < 0 ? this.storeInfo.min_qty : number);
  376. });
  377. }
  378. },
  379. onLoadFun() {},
  380. // 产品列表
  381. productslist: function () {
  382. let that = this;
  383. if (that.loadend) return;
  384. if (that.loading) return;
  385. that.loading = true;
  386. that.loadTitle = '';
  387. getProductslist({
  388. page: that.page,
  389. limit: that.limit,
  390. type: 1,
  391. cid: that.cid,
  392. sid: that.sid
  393. })
  394. .then((res) => {
  395. let list = res.data,
  396. loadend = list.length < that.limit;
  397. that.tempArr = that.$util.SplitArray(list, that.tempArr);
  398. that.$set(that, 'tempArr', that.tempArr);
  399. that.loading = false;
  400. that.loadend = loadend;
  401. that.loadTitle = loadend ? that.$t(`没有更多内容啦~`) : that.$t(`加载更多`);
  402. that.page = that.page + 1;
  403. })
  404. .catch((err) => {
  405. (that.loading = false), (that.loadTitle = that.$t(`加载更多`));
  406. });
  407. },
  408. // 改变单属性购物车
  409. ChangeCartNumDan(changeValue, index, item) {
  410. let num = this.tempArr[index];
  411. let stock = this.tempArr[index].stock;
  412. this.ChangeCartNum(changeValue, num, stock, 0, item.id);
  413. },
  414. // 改变多属性购物车
  415. ChangeCartNumDuo(changeValue) {
  416. //获取当前变动属性
  417. let productSelect = this.productValue[this.attrValue];
  418. //如果没有属性,赋值给商品默认库存
  419. if (productSelect === undefined && !this.attr.productAttr.length) productSelect = this.attr.productSelect;
  420. //无属性值即库存为0;不存在加减;
  421. if (productSelect === undefined) return;
  422. let stock = productSelect.stock || 0;
  423. let num = this.attr.productSelect;
  424. this.ChangeCartNum(changeValue, num, stock, 1, this.id);
  425. },
  426. // 已经加入购物车时的购物加减;
  427. ChangeCartList(changeValue, index, isCartPop) {
  428. let list = this.cartData.cartList;
  429. let num = list[index];
  430. let stock = list[index].trueStock;
  431. if (!changeValue && num.cart_num <= num.min_qty) {
  432. return this.$util.Tips({
  433. title: this.$t(`该商品${num.min_qty}件起购`)
  434. });
  435. }
  436. this.ChangeCartNum(changeValue, num, stock, 0, num.product_id, index, 1);
  437. if (!list.length) {
  438. this.cartData.iScart = false;
  439. this.page = 1;
  440. this.loadend = false;
  441. this.tempArr = [];
  442. this.productslist();
  443. }
  444. },
  445. // 购物车加减计算函数
  446. ChangeCartNum(changeValue, num, stock, isDuo, id, index, cart) {
  447. this.$refs.d_goodClass.addIng = false;
  448. if (changeValue) {
  449. num.cart_num++;
  450. if (num.cart_num > stock) {
  451. if (isDuo) {
  452. this.$set(this.attr.productSelect, 'cart_num', stock ? stock : 1);
  453. this.$set(this, 'cart_num', stock ? stock : 1);
  454. } else {
  455. num.cart_num = stock ? stock : 0;
  456. this.$set(this, 'tempArr', this.tempArr);
  457. this.$set(this.cartData, 'cartList', this.cartData.cartList);
  458. }
  459. return this.$util.Tips({
  460. title: this.$t(`该产品没有更多库存了`)
  461. });
  462. } else {
  463. if (!isDuo) {
  464. if (cart) {
  465. this.goCat(0, id, 1, 1, num.product_attr_unique, num);
  466. this.getTotalPrice();
  467. } else {
  468. this.goCat(0, id, 1, 0, false, num);
  469. }
  470. }
  471. }
  472. } else {
  473. if (num.cart_num <= num.min_qty) {
  474. return this.$util.Tips({
  475. title: this.$t(`该商品${num.min_qty}件起购`)
  476. });
  477. }
  478. num.cart_num--;
  479. if (num.cart_num == 0) {
  480. this.cartData.cartList.splice(index, 1);
  481. }
  482. if (num.cart_num < 0) {
  483. if (isDuo) {
  484. this.$set(this.attr.productSelect, 'cart_num', this.storeInfo.min_qty);
  485. this.$set(this, 'cart_num', this.storeInfo.min_qty);
  486. } else {
  487. num.cart_num = 0;
  488. this.$set(this, 'tempArr', this.tempArr);
  489. this.$set(this.cartData, 'cartList', this.cartData.cartList);
  490. }
  491. } else {
  492. if (!isDuo) {
  493. if (cart) {
  494. this.goCat(0, id, 0, 1, num.product_attr_unique, num);
  495. this.getTotalPrice();
  496. } else {
  497. this.goCat(0, id, 0, 0, false, num);
  498. }
  499. }
  500. }
  501. }
  502. },
  503. // 多规格加入购物车;
  504. goCatNum() {
  505. this.goCat(1, this.id, 1);
  506. },
  507. /*
  508. * 加入购物车
  509. */
  510. goCat: function (duo, id, type, cart, unique, data) {
  511. let that = this;
  512. if (duo) {
  513. let productSelect = that.productValue[this.attrValue];
  514. //如果有属性,没有选择,提示用户选择
  515. if (that.attr.productAttr.length && productSelect === undefined) {
  516. return that.$util.Tips({
  517. title: that.$t(`该产品没有更多库存了`)
  518. });
  519. }
  520. if (that.attr.productSelect.cart_num <= 0) {
  521. return that.$util.Tips({
  522. title: that.$t(`最少添加 1 件商品`)
  523. });
  524. }
  525. }
  526. let q = {
  527. product_id: id,
  528. type: type,
  529. unique: duo ? that.attr.productSelect.unique : cart ? unique : ''
  530. };
  531. data && data.cart_num < data.min_qty ? (q.num = data.min_qty) : '';
  532. if (!that.cartData.iScart) q.num = duo ? that.attr.productSelect.cart_num : this.storeInfo.min_qty;
  533. postCartNum(q)
  534. .then(function (res) {
  535. if (duo) {
  536. that.attr.cartAttr = false;
  537. that.$util.Tips({
  538. title: that.$t(`添加成功`)
  539. });
  540. // that.page = 1;
  541. // that.loadend = false;
  542. that.tempArr.forEach((item, index) => {
  543. if (item.id == that.id) {
  544. let arrtStock = that.attr.productSelect.stock;
  545. let objNum = parseInt(item.cart_num) + parseInt(that.attr.productSelect.cart_num);
  546. item.cart_num = objNum > arrtStock ? arrtStock : objNum;
  547. }
  548. });
  549. // that.productslist();
  550. }
  551. that.getCartNum();
  552. if (!cart) {
  553. that.getCartList(1);
  554. }
  555. })
  556. .catch((err) => {
  557. return that.$util.Tips({
  558. title: err
  559. });
  560. });
  561. },
  562. // 点击默认单属性购物车
  563. goCartDan(item, index) {
  564. if (!this.isLogin) {
  565. this.getIsLogin();
  566. } else {
  567. if (!item.cart_button) {
  568. goShopDetail(item, this.uid).then((res) => {
  569. uni.navigateTo({
  570. url: `/pages/goods_details/index?id=${item.id}`
  571. });
  572. });
  573. return;
  574. }
  575. this.tempArr[index].cart_num = this.storeInfo.min_qty;
  576. this.$set(this, 'tempArr', this.tempArr);
  577. this.goCat(0, item.id, 1);
  578. }
  579. },
  580. goCartDuo(item) {
  581. if (!this.isLogin) {
  582. this.getIsLogin();
  583. } else {
  584. if (!item.cart_button) {
  585. goShopDetail(item, this.uid).then((res) => {
  586. uni.navigateTo({
  587. url: `/pages/goods_details/index?id=${item.id}`
  588. });
  589. });
  590. return;
  591. }
  592. uni.showLoading({
  593. title: this.$t(`正在加载中`)
  594. });
  595. this.storeName = item.store_name;
  596. this.getAttrs(item.id);
  597. this.$set(this, 'id', item.id);
  598. this.$set(this.attr, 'cartAttr', true);
  599. }
  600. },
  601. getIsLogin() {
  602. toLogin();
  603. },
  604. // 商品详情接口;
  605. getAttrs(id) {
  606. let that = this;
  607. getAttr(id, 0).then((res) => {
  608. uni.hideLoading();
  609. that.$set(that.attr, 'productAttr', res.data.productAttr);
  610. that.$set(that, 'productValue', res.data.productValue);
  611. that.$set(that, 'is_vip', res.data.storeInfo.is_vip);
  612. that.$set(that, 'storeInfo', res.data.storeInfo);
  613. that.DefaultSelect();
  614. });
  615. },
  616. // 去详情页
  617. goDetail(item) {
  618. if (!this.isLogin) {
  619. toLogin();
  620. } else {
  621. goShopDetail(item, this.uid).then((res) => {
  622. uni.navigateTo({
  623. url: `/pages/goods_details/index?id=${item.id}`
  624. });
  625. });
  626. }
  627. },
  628. openTap() {
  629. this.iSlong = false;
  630. },
  631. closeTap() {
  632. this.iSlong = true;
  633. },
  634. getAllCategory: function (type) {
  635. let that = this;
  636. if (type || !uni.getStorageSync('CAT2_DATA')) {
  637. getCategoryList().then((res) => {
  638. uni.setStorageSync('CAT2_DATA', res.data);
  639. let data = res.data;
  640. data.forEach((item) => {
  641. item.children.unshift({
  642. id: 0,
  643. cate_name: that.$t(`全部`)
  644. });
  645. });
  646. that.categoryTitle = data[0].cate_name;
  647. that.cid = data[0].id;
  648. that.sid = 0;
  649. that.navActive = 0;
  650. that.tabClick = 0;
  651. that.categoryList = data;
  652. that.categoryErList = res.data[0].children ? res.data[0].children : [];
  653. that.page = 1;
  654. that.loadend = false;
  655. that.tempArr = [];
  656. that.productslist();
  657. });
  658. } else {
  659. let data = uni.getStorageSync('CAT2_DATA');
  660. data.forEach((item) => {
  661. item.children.unshift({
  662. id: 0,
  663. cate_name: that.$t(`全部`)
  664. });
  665. });
  666. that.categoryTitle = data[0].cate_name;
  667. that.cid = data[0].id;
  668. that.sid = 0;
  669. that.navActive = 0;
  670. that.tabClick = 0;
  671. that.categoryList = data;
  672. that.categoryErList = data[0].children ? data[0].children : [];
  673. that.page = 1;
  674. that.loadend = false;
  675. that.tempArr = [];
  676. that.productslist();
  677. }
  678. },
  679. tapNav(index, item) {
  680. let list = this.categoryList[index];
  681. this.navActive = index;
  682. this.categoryTitle = list.cate_name;
  683. this.categoryErList = item.children ? item.children : [];
  684. this.tabClick = 0;
  685. this.tabLeft = 0;
  686. this.cid = list.id;
  687. this.sid = 0;
  688. this.page = 1;
  689. this.loadend = false;
  690. this.tempArr = [];
  691. this.productslist();
  692. },
  693. // 导航栏点击
  694. longClick(index) {
  695. if (this.categoryErList.length > 3) {
  696. this.tabLeft = (index - 1) * (this.isWidth + 6); //设置下划线位置
  697. }
  698. this.tabClick = index; //设置导航点击了哪一个
  699. this.iSlong = true;
  700. this.sid = this.categoryErList[index].id;
  701. this.page = 1;
  702. this.loadend = false;
  703. this.tempArr = [];
  704. this.productslist();
  705. }
  706. }
  707. };
  708. </script>
  709. <style lang="scss">
  710. .scroll-Y {
  711. height: 100vh;
  712. }
  713. page {
  714. background-color: #fff;
  715. }
  716. /deep/.product-window.joinCart {
  717. z-index: 999;
  718. }
  719. ::-webkit-scrollbar {
  720. width: 0;
  721. height: 0;
  722. color: transparent;
  723. display: none;
  724. }
  725. .goodCate {
  726. .mask {
  727. z-index: 99;
  728. }
  729. /deep/.attrProduct {
  730. .mask {
  731. z-index: 100;
  732. }
  733. }
  734. .header {
  735. position: fixed;
  736. height: 128rpx;
  737. background-color: #fff;
  738. top: 0;
  739. left: 0;
  740. width: 100%;
  741. z-index: 99;
  742. border-bottom: 1px solid #f0f0f0;
  743. .pageIndex {
  744. width: 68rpx;
  745. height: 68rpx;
  746. border-radius: 50%;
  747. background-color: var(--view-theme);
  748. text-align: center;
  749. line-height: 68rpx;
  750. .iconfont {
  751. color: #fff;
  752. font-size: 30rpx;
  753. }
  754. }
  755. .search {
  756. width: 600rpx;
  757. height: 68rpx;
  758. border-radius: 36rpx;
  759. background-color: #f8f8f8;
  760. font-size: 26rpx;
  761. color: #adadad;
  762. margin-left: 22rpx;
  763. .iconfont {
  764. font-size: 30rpx;
  765. margin: 4rpx 16rpx 0 0;
  766. }
  767. }
  768. }
  769. .conter {
  770. margin-top: 128rpx;
  771. height: 100vh;
  772. background-color: #fff;
  773. .aside {
  774. position: fixed;
  775. width: 23%;
  776. left: 0;
  777. bottom: 100rpx;
  778. top: 0;
  779. background-color: #f7f7f7;
  780. overflow-y: auto;
  781. overflow-x: hidden;
  782. margin-top: 128rpx;
  783. z-index: 99;
  784. .item {
  785. height: 100rpx;
  786. width: 100%;
  787. font-size: 26rpx;
  788. color: #424242;
  789. &.on {
  790. background-color: #fff;
  791. width: 100%;
  792. text-align: center;
  793. color: var(--view-theme);
  794. font-weight: 500;
  795. position: relative;
  796. &::after {
  797. content: '';
  798. position: absolute;
  799. width: 6rpx;
  800. height: 46rpx;
  801. background: var(--view-theme);
  802. border-radius: 0 4rpx 4rpx 0;
  803. left: 0;
  804. }
  805. }
  806. }
  807. }
  808. .wrapper {
  809. margin-top: 104rpx;
  810. width: 77%;
  811. float: right;
  812. background-color: #fff;
  813. padding-bottom: 100rpx;
  814. .bgcolor {
  815. width: 100%;
  816. background-color: #fff;
  817. }
  818. .goodsList {
  819. margin-top: 0 !important;
  820. }
  821. .mask {
  822. z-index: 9;
  823. }
  824. .longTab {
  825. width: 65%;
  826. position: fixed;
  827. top: 0;
  828. margin-top: 128rpx;
  829. height: 100rpx;
  830. z-index: 99;
  831. background-color: #fff;
  832. .longItem {
  833. height: 44rpx;
  834. display: inline-block;
  835. line-height: 44rpx;
  836. text-align: center;
  837. font-size: 26rpx;
  838. overflow: hidden;
  839. text-overflow: ellipsis;
  840. white-space: nowrap;
  841. color: #989898;
  842. background-color: #f7f7f7;
  843. border-radius: 22rpx;
  844. margin-left: 12rpx;
  845. &.click {
  846. font-weight: bold;
  847. background-color: var(--view-minorColorT);
  848. color: var(--view-theme);
  849. }
  850. }
  851. .underlineBox {
  852. height: 3px;
  853. width: 20%;
  854. display: flex;
  855. align-content: center;
  856. justify-content: center;
  857. transition: 0.5s;
  858. .underline {
  859. width: 33rpx;
  860. height: 4rpx;
  861. background-color: white;
  862. }
  863. }
  864. }
  865. .openList {
  866. width: 12%;
  867. height: 100rpx;
  868. background-color: #fff;
  869. line-height: 100rpx;
  870. padding-left: 30rpx;
  871. position: fixed;
  872. right: 0;
  873. top: 128rpx;
  874. z-index: 99;
  875. .iconfont {
  876. font-size: 22rpx;
  877. color: #989898;
  878. }
  879. }
  880. .downTab {
  881. width: 77%;
  882. position: fixed;
  883. top: 0;
  884. margin-top: 128rpx;
  885. z-index: 99;
  886. background-color: #fff;
  887. right: 0;
  888. .title {
  889. height: 100rpx;
  890. font-size: 26rpx;
  891. color: #adadad;
  892. padding-left: 20rpx;
  893. .closeList {
  894. width: 90rpx;
  895. height: 100%;
  896. line-height: 100rpx;
  897. padding-left: 30rpx;
  898. transform: rotate(180deg);
  899. .iconfont {
  900. font-size: 22rpx;
  901. color: #989898;
  902. }
  903. }
  904. }
  905. .children {
  906. max-height: 500rpx;
  907. overflow-x: hidden;
  908. overflow-y: auto;
  909. padding-bottom: 20rpx;
  910. .item {
  911. height: 60rpx;
  912. background-color: #f7f7f7;
  913. border-radius: 30rpx;
  914. line-height: 60rpx;
  915. padding: 0 15rpx;
  916. margin: 0 0 20rpx 20rpx;
  917. width: 165rpx;
  918. text-align: center;
  919. &.click {
  920. font-weight: bold;
  921. background-color: var(--view-minorColorT);
  922. color: var(--view-theme);
  923. }
  924. }
  925. }
  926. }
  927. .goodsList {
  928. margin-top: 228rpx;
  929. padding: 0 30rpx 0 20rpx;
  930. /deep/.item {
  931. margin-bottom: 33rpx !important;
  932. .pictrue {
  933. // height: 216rpx;
  934. }
  935. .text {
  936. font-size: 26rpx;
  937. }
  938. .bottom {
  939. .sales {
  940. .money {
  941. font-size: 34rpx;
  942. text {
  943. font-size: 26rpx;
  944. }
  945. }
  946. }
  947. .cart {
  948. .pictrue {
  949. width: 50rpx;
  950. height: 50rpx;
  951. }
  952. }
  953. }
  954. }
  955. }
  956. }
  957. }
  958. .footer {
  959. position: fixed;
  960. left: 0;
  961. bottom: 0;
  962. width: 100%;
  963. background-color: #fff;
  964. box-shadow: 0px -3rpx 16rpx rgba(36, 12, 12, 0.05);
  965. z-index: 101;
  966. padding: 0 30rpx;
  967. box-sizing: border-box;
  968. height: 100rpx;
  969. .cartIcon {
  970. width: 96rpx;
  971. height: 96rpx;
  972. border-radius: 50%;
  973. position: relative;
  974. margin-top: -36rpx;
  975. .iconfont {
  976. font-size: 115rpx;
  977. margin-top: -5px;
  978. color: var(--view-theme);
  979. }
  980. &.noCart {
  981. .iconfont {
  982. color: #cbcbcb;
  983. }
  984. }
  985. .num {
  986. background-color: var(--view-priceColor);
  987. min-width: 12rpx;
  988. color: #fff;
  989. border-radius: 15px;
  990. position: absolute;
  991. right: -6rpx;
  992. top: -10rpx;
  993. font-size: 22rpx;
  994. padding: 0 10rpx;
  995. height: 34rpx;
  996. line-height: 34rpx;
  997. }
  998. }
  999. .money {
  1000. color: var(--view-priceColor);
  1001. font-size: 28rpx;
  1002. font-weight: bold;
  1003. .num {
  1004. font-size: 42rpx;
  1005. }
  1006. .bnt {
  1007. width: 222rpx;
  1008. height: 76rpx;
  1009. background: var(--view-theme);
  1010. border-radius: 46rpx;
  1011. line-height: 76rpx;
  1012. text-align: center;
  1013. color: #fff;
  1014. margin-left: 24rpx;
  1015. }
  1016. }
  1017. }
  1018. }
  1019. </style>