goods_cate2.vue 27 KB

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