goods_cate3.vue 29 KB

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