goods_cate3.vue 27 KB

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