goods_cate2.vue 27 KB

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