goods_cate2.vue 28 KB

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