goods_cate2.vue 28 KB

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