goods_cate3.vue 29 KB

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