goods_cate2.vue 26 KB

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