template3.vue 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842
  1. <template>
  2. <view>
  3. <view class="flex-col bg--w111-fff" :style="{ height: windowHeight + 'px' }">
  4. <view :style="{paddingTop: sysHeight + 'px'}" class="text--w111-999">
  5. <view class="h-80 px-32 flex-y-center">
  6. <!-- #ifdef MP -->
  7. <view class="flex-1 h-58 flex-y-center rd-30rpx bg--w111-f5f5f5 px-32" @tap="goSearch">
  8. <!-- #endif -->
  9. <!-- #ifndef MP -->
  10. <view class="w-full h-58 flex-y-center rd-30rpx bg--w111-f5f5f5 px-32" @tap="goSearch">
  11. <!-- #endif -->
  12. <text class="iconfont icon-ic_search fs-28"></text>
  13. <text class="fs-24 pl-18">请输入商品名称</text>
  14. </view>
  15. <!-- 胶囊占据的位置 -->
  16. <!-- #ifdef MP -->
  17. <view class="ml-12" :style="'width:'+getHeight.barWidth+'px'"></view>
  18. <!-- #endif -->
  19. </view>
  20. </view>
  21. <view class="scroll_box flex flex-1">
  22. <view class="w-168 h-full bg--w111-f5f5f5">
  23. <scroll-view :scroll-top="0" scroll-y="true" class="h-full">
  24. <view class="w-168 h-96 flex-center fs-26 text--w111-666"
  25. v-for="(item,index) in categoryList":key="index"
  26. :class="index == navActive?'aside_active':''"
  27. @tap="tapNav(index,item)">
  28. <view class="top-ra">
  29. <text></text>
  30. </view>
  31. {{item.cate_name}}
  32. <view class="bottom-ra">
  33. <text></text>
  34. </view>
  35. </view>
  36. <view class="white-box"></view>
  37. </scroll-view>
  38. </view>
  39. <view class="relative w-full h-full">
  40. <view class="flex-1 pl-24 pr-20 abs-lt">
  41. <view class="flex mt-24 mb-16">
  42. <scroll-view scroll-x="true" class="white-nowrap vertical-middle w-464"
  43. show-scrollbar="false">
  44. <view class="inline-block mr-16"
  45. v-for="(item,index) in categoryErList" :key="index"
  46. @tap="longClick(index,item)">
  47. <view
  48. class="w-144 h-56 rd-30rpx bg--w111-f5f5f5 flex-center fs-24 text--w111-333"
  49. :class="index===tabClick?'cate_active':''">{{item.cate_name}}</view>
  50. </view>
  51. </scroll-view>
  52. <view class="bntCon w-56 h-56 rd-30rpx bg--w111-f5f5f5 flex-center ml-16"
  53. v-if="categoryErList.length"
  54. @tap="openCateDrawer(false)">
  55. <text class="iconfont icon-ic_downarrow fs-32 text--w111-333"></text>
  56. </view>
  57. </view>
  58. </view>
  59. <view class="h-96"></view>
  60. <view class="pl-24 pr-24 pt-12">
  61. <scroll-view :scroll-top="0" scroll-y="true" @scrolltolower="lower" @scroll="scroll"
  62. :style="{'height':scrollHeight + 'px'}">
  63. <!-- 大图模板 -->
  64. <view v-if="showType == 1">
  65. <view class="mb-24" v-for="(item,index) in tempArr" :key="index"
  66. @tap="goDetail(item)">
  67. <easy-loadimage
  68. :image-src="item.recommend_image ? item.recommend_image : item.image"
  69. :borderSrc="item.recommend_image ? '' :item.activity_frame.image"
  70. width="540rpx"
  71. :height="item.recommend_image ? '216rpx' : '540rpx'"
  72. borderRadius="20rpx 20rpx 0 0"></easy-loadimage>
  73. <view class="bg--w111-fff rd-b-20rpx pt-16 pl-24 pr-24 pb-24">
  74. <view class="w-full line2 fs-28 text--w111-333 lh-40rpx">{{item.store_name}}
  75. </view>
  76. <view class="flex-between-center mt-20">
  77. <view class="flex items-baseline">
  78. <baseMoney :money="item.price" symbolSize="28" integerSize="44"
  79. decimalSize="28" incolor="var(--primary-theme-con)" weight>
  80. </baseMoney>
  81. <text class="fs-22 text--w111-8e8e8e pl-12">已售{{item.sales}}</text>
  82. </view>
  83. <view
  84. class="w-172 h-58 rd-30rpx bg-color flex-center fs-24 text--w111-fff relative"
  85. v-if="item.spec_type" @tap.stop="goCartDuo(item)">
  86. <text>{{item.cart_button == 0 ? '立即购买' : '加入购物车'}}</text>
  87. <uni-badge class="badge-style" :custom-style="{background: 'var(--view-theme)'}" v-if="item.cart_num > 0" :text="item.cart_num"></uni-badge>
  88. </view>
  89. <view v-if="!item.spec_type && !item.cart_num">
  90. <view
  91. class="flex-center w-48 h-48 rd-30rpx bg-color text--w111-fff "
  92. @tap.stop="goCartDan(item,index)">
  93. <text class="iconfont icon-ic_ShoppingCart1 fs-30"></text>
  94. </view>
  95. </view>
  96. <view class="flex-y-center" v-if="!item.spec_type && item.cart_num">
  97. <view
  98. class="flex-center w-48 h-48 rd-30rpx bg--w111-f5f5f5 text--w111-333"
  99. @tap.stop="ChangeCartNumDan(false,index,item)">
  100. <text class="iconfont icon-ic_Reduce fs-32"></text>
  101. </view>
  102. <view class="fs-30 text--w111-333 px-20">{{item.cart_num}}</view>
  103. <view class="flex-center w-48 h-48 rd-30rpx bg-color text--w111-fff"
  104. @tap.stop="CartNumAdd(index,item)">
  105. <text class="iconfont icon-ic_increase fs-32"></text>
  106. </view>
  107. </view>
  108. </view>
  109. </view>
  110. </view>
  111. </view>
  112. <!-- 小图模板 -->
  113. <view v-else-if="showType == 4">
  114. <view class="mb-24 flex justify-between" v-for="(item,index) in tempArr"
  115. :key="index" @tap="goDetail(item)">
  116. <easy-loadimage
  117. :image-src="item.image"
  118. :borderSrc="item.activity_frame.image"
  119. width="176rpx"
  120. height="176rpx"
  121. borderRadius="16rpx"></easy-loadimage>
  122. <view class="flex-1 flex-col justify-between pl-20">
  123. <view class="w-full">
  124. <view class="line1 w-346 fs-28 text-#333 lh-40rpx">{{item.store_name}}</view>
  125. <view class="flex items-end flex-wrap mt-12 w-full">
  126. <BaseTag
  127. :text="label.label_name"
  128. :color="label.color"
  129. :background="label.bg_color"
  130. :borderColor="label.border_color"
  131. :circle="label.border_color ? true : false"
  132. :imgSrc="label.icon"
  133. v-for="(label, idx) in item.store_label" :key="idx"></BaseTag>
  134. </view>
  135. </view>
  136. <view class="flex-between-center">
  137. <view class="flex items-baseline">
  138. <baseMoney :money="item.price" symbolSize="24" integerSize="40"
  139. decimalSize="24" weight>
  140. </baseMoney>
  141. </view>
  142. <view class="flex-center w-48 h-48 rd-30rpx bg-color text--w111-fff"
  143. @tap.stop="goCartDuo(item)" v-if="item.spec_type">
  144. <text class="iconfont icon-ic_ShoppingCart1 fs-30"></text>
  145. </view>
  146. <view v-if="!item.spec_type && !item.cart_num">
  147. <view
  148. class="flex-center w-48 h-48 rd-30rpx bg-color text--w111-fff "
  149. @tap.stop="goCartDan(item,index)">
  150. <text class="iconfont icon-ic_ShoppingCart1 fs-30"></text>
  151. </view>
  152. </view>
  153. <view class="flex-y-center" v-if="!item.spec_type && item.cart_num">
  154. <view
  155. class="flex-center w-48 h-48 rd-30rpx bg--w111-f5f5f5 text--w111-333"
  156. @tap.stop="ChangeCartNumDan(false,index,item)">
  157. <text class="iconfont icon-ic_Reduce fs-32"></text>
  158. </view>
  159. <view class="fs-30 text--w111-333 px-20">{{item.cart_num}}</view>
  160. <view class="flex-center w-48 h-48 rd-30rpx bg-color text--w111-fff"
  161. @tap.stop="CartNumAdd(index,item)">
  162. <text class="iconfont icon-ic_increase fs-32"></text>
  163. </view>
  164. </view>
  165. </view>
  166. </view>
  167. </view>
  168. </view>
  169. <view v-if="!tempArr.length && !loading">
  170. <emptyPage title="暂无商品,去看点别的吧~" ></emptyPage>
  171. </view>
  172. <view class="white-box"></view>
  173. </scroll-view>
  174. </view>
  175. </view>
  176. </view>
  177. </view>
  178. <view class="h-96 footer" :class="isFooter == 1 ? 'show-footer' : ''">
  179. <view class="w-100 h-100 rd-50rpx bg-gradient1 flex-center abs-lt top-2 ml--4" @tap="openCart">
  180. <image src="@/static/img/cart_pic.png" class="w-54 h-54"></image>
  181. <uni-badge class="badge-style" :custom-style="{background: 'var(--view-theme)'}" v-if="cartNum > 0" :text="cartNum"></uni-badge>
  182. </view>
  183. <view class="w-710 h-full flex-between-center overflow cart_box" :class="{ open: footerOpen }">
  184. <view class="flex-y-center" @tap="getCartList(0)">
  185. <view class="items-baseline ml-32 inline-flex h-60 lh-60rpx overflow">
  186. <baseMoney :money="totalPrice" symbolSize="32" integerSize="48" decimalSize="32"
  187. incolor="#fff" weight></baseMoney>
  188. <view class="fs-24 text--w111-fff lh-34rpx pl-16" v-show="totalPrice > 0 && !cartData.iScart">查看明细 <text
  189. class="iconfont icon-ic_uparrow fs-24"></text> </view>
  190. </view>
  191. </view>
  192. <view class="w-186 h-72 lh-72rpx text-center rd-40rpx text--w111-fff fs-26 fw-500 bg-gradient1 mr-12"
  193. @tap="subOrder">去结算({{cartNum}})</view>
  194. </view>
  195. </view>
  196. <view class="more_box abs-lt w-full bg--w111-fff rd-b-32rpx z-20" v-show="showCateDrawer">
  197. <view :style="{paddingTop: sysHeight + 'px'}">
  198. <view class="h-80 px-32 flex-y-center">
  199. <!-- #ifdef MP -->
  200. <view class="flex-1 h-58 flex-y-center rd-30rpx bg--w111-f5f5f5 px-32" @tap="goSearch">
  201. <!-- #endif -->
  202. <!-- #ifndef MP -->
  203. <view class="w-full h-58 flex-y-center rd-30rpx bg--w111-f5f5f5 px-32" @tap="goSearch">
  204. <!-- #endif -->
  205. <text class="iconfont icon-ic_search fs-28"></text>
  206. <text class="fs-24 text--w111-999 pl-18">请输入商品名称</text>
  207. </view>
  208. <!-- 胶囊占据的位置 -->
  209. <!-- #ifdef MP -->
  210. <view class="ml-12" :style="'width:'+getHeight.barWidth+'px'"></view>
  211. <!-- #endif -->
  212. </view>
  213. </view>
  214. <view class="pt-32 pl-30 pr-30">
  215. <view>
  216. <view class="fs-32 text--w111-333" v-if="categoryErList.length">
  217. {{categoryErList[tabClick].cate_name}}
  218. </view>
  219. <view class="grid-column-4 grid-gap-24rpx mt-24">
  220. <view class="w-154 h-56 rd-30rpx flex-center fs-24 text--w111-333 bg--w111-f5f5f5"
  221. v-for="(item,index) in categoryErList" :key="index" @tap="longClick(index,item)"
  222. :class="index===tabClick?'cate_active':''">
  223. {{item.cate_name}}
  224. </view>
  225. </view>
  226. </view>
  227. <view class="flex-center fs-24 text--w111-999 h-80 mt-32" @tap="closeCateDrawer">
  228. <text>点击收起 <text class="iconfont icon-ic_uparrow fs-24 pl-4"></text> </text>
  229. </view>
  230. </view>
  231. </view>
  232. <view class="mask" v-show="showCateDrawer" @tap="closeCateDrawer"></view>
  233. <cartList :cartData="cartData" :isFooter='isFooter' @closeList="closeList"
  234. @ChangeCartNumDan="ChangeCartList" @ChangeSubDel="ChangeSubDel" @ChangeOneDel="ChangeOneDel">
  235. </cartList>
  236. <productWindow
  237. :attr="attr"
  238. :isShow='1'
  239. :iSplus='1'
  240. :iScart='1'
  241. :is_vip="is_vip"
  242. :type="2"
  243. @myevent="onMyEvent"
  244. @ChangeAttr="ChangeAttr"
  245. @ChangeCartNum="ChangeCartNumDuo"
  246. @attrVal="attrVal"
  247. @iptCartNum="iptCartNum"
  248. @goCat="goCatNum"
  249. @getImg="showImg"
  250. id='product-window' ></productWindow>
  251. <cusPreviewImg ref="cusPreviewImg" :list="skuArr" @changeSwitch="changeSwitch"></cusPreviewImg>
  252. </view>
  253. </template>
  254. <script>
  255. let windowHeight = uni.getSystemInfoSync().screenHeight;
  256. let sysHeight = uni.getSystemInfoSync().statusBarHeight;
  257. import {
  258. getCategoryList,
  259. getProductslist,
  260. getAttr,
  261. postCartNum
  262. } from '@/api/store.js';
  263. import {
  264. vcartList,
  265. getCartCounts,
  266. cartDel
  267. } from '@/api/order.js';
  268. import productWindow from '@/components/productWindow';
  269. import cartList from '@/components/cartList';
  270. import {
  271. mapState,
  272. mapGetters
  273. } from 'vuex';
  274. import {
  275. goShopDetail
  276. } from '@/libs/order.js';
  277. import {
  278. toLogin
  279. } from '@/libs/login.js';
  280. import skuSelect from '@/mixins/skuSelect.js'
  281. import emptyPage from '@/components/emptyPage.vue';
  282. import cusPreviewImg from '@/components/cusPreviewImg';
  283. export default {
  284. props: {
  285. showType: {
  286. type: Number,
  287. default: 1
  288. },
  289. isFooter:{
  290. type: Boolean,
  291. default: false
  292. }
  293. },
  294. data() {
  295. return {
  296. windowHeight: this.isFooter?windowHeight:windowHeight-50,
  297. showCateDrawer: false,
  298. sysHeight: sysHeight,
  299. categoryList: [],
  300. navActive: 0,
  301. categoryTitle: '',
  302. categoryErList: [],
  303. tabLeft: 0,
  304. isWidth: 0, //每个导航栏占位
  305. tabClick: 0, //导航栏被点击
  306. iSlong: false,
  307. tempArr: [],
  308. loading: false,
  309. loadend: false,
  310. loadTitle: '加载更多',
  311. page: 1,
  312. limit: 10,
  313. cid: 0, //一级分类
  314. sid: 0, //二级分类
  315. tid: 0, //三级分类
  316. isAuto: false, //没有授权的不会自动授权
  317. isShowAuth: false, //是否隐藏授权
  318. attr: {
  319. cartAttr: false,
  320. productAttr: [],
  321. productSelect: {}
  322. },
  323. productValue: [],
  324. attrValue: '', //已选属性
  325. storeName: '', //多属性产品名称
  326. id: 0,
  327. cartData: {
  328. cartList: [],
  329. iScart: false
  330. },
  331. totalPrice: 0.00,
  332. lengthCart: 0,
  333. is_vip: 0, //是否是会员
  334. cart_num: 0,
  335. storeInfo: {},
  336. scrollHeight: 0,
  337. threeCateList: [],
  338. threeClick: 0,
  339. topNavShow: true,
  340. selectSku: {},
  341. skuArr: [],
  342. getHeight: this.$util.getWXStatusHeight(),
  343. footerOpen:true
  344. }
  345. },
  346. components: {
  347. productWindow,
  348. cartList,
  349. emptyPage,
  350. cusPreviewImg
  351. },
  352. mixins: [skuSelect],
  353. computed: {
  354. ...mapState({
  355. cartNum: state => state.indexData.cartNum
  356. }),
  357. ...mapGetters(['isLogin', 'uid', 'cartNum']),
  358. },
  359. watch:{
  360. cartNum(){
  361. this.getCartList(1);
  362. }
  363. },
  364. mounted() {
  365. this.getAllCategory();
  366. setTimeout(() => {
  367. this.getScrollHeight();
  368. }, 500)
  369. if(this.isLogin){
  370. this.getCartList(1);
  371. }
  372. uni.$on('newAttrNum', (data) => {
  373. if (data.length) {
  374. this.tempArr.forEach((item) => {
  375. data.forEach(j => {
  376. if (item.id == j.id) {
  377. item.cart_num = j.num
  378. }
  379. })
  380. })
  381. }
  382. })
  383. uni.$on('newCartNum', (data) => {
  384. if (data.length) {
  385. this.tempArr.forEach((item) => {
  386. data.forEach(j => {
  387. if (item.id == j.product_id) {
  388. item.cart_num = 0
  389. }
  390. })
  391. })
  392. }
  393. })
  394. },
  395. methods: {
  396. openCart(){
  397. if(this.footerOpen){
  398. this.getCartList(0)
  399. }else{
  400. this.footerOpen = true
  401. }
  402. },
  403. getScrollHeight() {
  404. let sysH = uni.getSystemInfoSync().statusBarHeight;
  405. this.scrollHeight = windowHeight - 88 - sysH;
  406. },
  407. getAllCategory() {
  408. let that = this;
  409. getCategoryList().then(res => {
  410. if (!res.data.length) return
  411. res.data.map(item=>{
  412. if(item.children && item.children.length){
  413. item.children.unshift({
  414. id:item.id,
  415. cate_name: '全部商品'
  416. })
  417. }
  418. })
  419. let data = res.data;
  420. that.categoryTitle = data[0].cate_name;
  421. that.cid = data[0].id;
  422. that.sid = 0;
  423. that.tid = 0;
  424. that.navActive = 0;
  425. that.tabClick = 0;
  426. that.categoryList = data;
  427. that.categoryErList = res.data[0].children ? res.data[0].children : [];
  428. that.page = 1;
  429. that.loadend = false;
  430. that.tempArr = [];
  431. that.productslist();
  432. })
  433. },
  434. // 产品列表
  435. productslist() {
  436. let that = this;
  437. if (that.loadend) return;
  438. if (that.loading) return;
  439. that.loading = true;
  440. that.loadTitle = '';
  441. getProductslist({
  442. page: that.page,
  443. limit: that.limit,
  444. type: 1,
  445. cid: that.cid,
  446. sid: that.sid,
  447. tid: that.tid
  448. }).then(res => {
  449. let list = res.data,
  450. loadend = list.length < that.limit;
  451. that.tempArr = that.$util.SplitArray(list, that.tempArr);
  452. that.$set(that, 'tempArr', that.tempArr);
  453. that.loading = false;
  454. that.loadend = loadend;
  455. that.loadTitle = loadend ? "没有更多内容啦~" : "加载更多";
  456. that.page = that.page + 1;
  457. }).catch(err => {
  458. that.loading = false;
  459. that.loadTitle = '加载更多'
  460. });
  461. },
  462. tapNav(index, item) {
  463. uni.pageScrollTo({
  464. duration: 0,
  465. scrollTop: 0
  466. })
  467. let list = this.categoryList[index];
  468. this.navActive = index;
  469. this.categoryTitle = list.cate_name;
  470. this.categoryErList = item.children ? item.children : [];
  471. this.tabClick = 0;
  472. this.tabLeft = 0;
  473. this.cid = list.id;
  474. this.sid = 0;
  475. this.page = 1;
  476. this.loadend = false;
  477. this.tempArr = [];
  478. this.productslist();
  479. },
  480. // 导航栏点击
  481. longClick(index, item) {
  482. this.tabClick = index; //设置导航点击了哪一个
  483. this.sid = this.categoryErList[index].id;
  484. this.page = 1;
  485. this.loadend = false;
  486. this.tempArr = [];
  487. this.productslist();
  488. },
  489. deepClone(obj) {
  490. let newObj = Array.isArray(obj) ? [] : {}
  491. if (obj && typeof obj === "object") {
  492. for (let key in obj) {
  493. if (obj.hasOwnProperty(key)) {
  494. newObj[key] = (obj && typeof obj[key] === 'object') ? this.deepClone(obj[key]) : obj[key];
  495. }
  496. }
  497. }
  498. return newObj
  499. },
  500. haveAll(arr) {
  501. let cloneMap = this.deepClone(arr),
  502. list = [];
  503. cloneMap.forEach(item => {
  504. list.push(item.id);
  505. })
  506. return list.includes(0) ? true : false
  507. },
  508. // 生成订单;
  509. subOrder() {
  510. let that = this,
  511. list = that.cartData.cartList,
  512. ids = [];
  513. if (list.length) {
  514. list.forEach(item => {
  515. if (item.attrStatus && item.status) {
  516. ids.push(item.id)
  517. }
  518. });
  519. uni.navigateTo({
  520. url: '/pages/goods/order_confirm/index?cartId=' + ids.join(',')
  521. });
  522. that.cartData.iScart = false;
  523. } else {
  524. return that.$util.Tips({
  525. title: '请选择产品'
  526. });
  527. }
  528. },
  529. // 计算总价;
  530. getTotalPrice() {
  531. let that = this,
  532. list = that.cartData.cartList,
  533. totalPrice = 0.00;
  534. list.forEach(item => {
  535. if (item.attrStatus && item.status) {
  536. totalPrice = that.$util.$h.Add(totalPrice, that.$util.$h.Mul(item.cart_num, item
  537. .truePrice));
  538. }
  539. })
  540. that.$set(that, 'totalPrice', totalPrice);
  541. },
  542. getCartList(iSshow) {
  543. let that = this;
  544. vcartList().then(res => {
  545. that.$set(that.cartData, 'cartList', res.data);
  546. if (res.data.length) {
  547. that.$set(that.cartData, 'iScart', iSshow ? false : !that.cartData.iScart);
  548. } else {
  549. that.$set(that.cartData, 'iScart', false);
  550. }
  551. if (!res.data.length) {
  552. this.$store.commit('indexData/setCartNum', 0);
  553. this.tempArr.forEach((item) => {
  554. item.cart_num = 0
  555. })
  556. }
  557. that.getTotalPrice();
  558. })
  559. },
  560. getCartNum() {
  561. let that = this;
  562. getCartCounts().then(res => {
  563. this.$store.commit('indexData/setCartNum', res.data.count)
  564. });
  565. },
  566. CartNumAdd(index, item) {
  567. if (item.is_limit && item.cart_num >= item.limit_num) {
  568. this.$util.Tips({
  569. title: "购买最多不能超过" + item.limit_num
  570. });
  571. } else {
  572. this.ChangeCartNumDan(true, index, item);
  573. }
  574. },
  575. // 商品详情接口;
  576. getAttrs(id) {
  577. let that = this;
  578. getAttr(id, 0).then(res => {
  579. // uni.hideLoading();
  580. that.$set(that.attr, 'productAttr', res.data.productAttr);
  581. that.$set(that, 'productValue', res.data.productValue);
  582. that.$set(that, 'is_vip', res.data.storeInfo.is_vip);
  583. that.$set(that, 'storeInfo', res.data.storeInfo);
  584. that.skuArr = [];
  585. for (let key in res.data.productValue) {
  586. let obj = res.data.productValue[key];
  587. that.skuArr.push(obj)
  588. }
  589. if (!that.skuArr.length) {
  590. that.skuArr = [{
  591. image: this.storeInfo.image,
  592. suk: this.storeInfo.store_name,
  593. price: this.storeInfo.price
  594. }];
  595. }
  596. this.$set(this, "selectSku", that.skuArr[0]);
  597. that.DefaultSelect();
  598. })
  599. },
  600. //点击sku图片打开轮播图
  601. showImg(index) {
  602. this.$refs.cusPreviewImg.open(this.selectSku.suk)
  603. },
  604. //滑动轮播图选择商品
  605. changeSwitch(e) {
  606. let productSelect = this.skuArr[e];
  607. this.$set(this, 'selectSku', productSelect);
  608. var skuList = productSelect.suk.split(',');
  609. skuList.forEach((i, index) => {
  610. this.$set(this.attr.productAttr[index], 'index', skuList[index]);
  611. })
  612. if (productSelect) {
  613. this.$set(this.attr.productSelect, 'image', productSelect.image);
  614. this.$set(this.attr.productSelect, 'price', productSelect.price);
  615. this.$set(this.attr.productSelect, 'stock', productSelect.stock);
  616. this.$set(this.attr.productSelect, 'unique', productSelect.unique);
  617. this.$set(this.attr.productSelect, 'cart_num', 1);
  618. this.$set(this.attr.productSelect, 'vip_price', productSelect.vip_price);
  619. this.$set(this, 'attrValue', productSelect.suk);
  620. this.$set(this, 'attrTxt', '已选择');
  621. }
  622. },
  623. // 去详情页
  624. goDetail(item) {
  625. goShopDetail(item, this.uid).catch(res => {
  626. uni.navigateTo({
  627. url: `/pages/goods_details/index?id=${item.id}&fromType=1`
  628. });
  629. });
  630. },
  631. closeCateDrawer() {
  632. this.showCateDrawer = false;
  633. },
  634. openCateDrawer(type) {
  635. this.topNavShow = type;
  636. this.showCateDrawer = true;
  637. },
  638. lower(e) {
  639. this.productslist();
  640. },
  641. scroll(e) {
  642. this.footerOpen = false;
  643. uni.$emit('scroll');
  644. },
  645. goSearch() {
  646. uni.navigateTo({
  647. url: '/pages/goods/goods_search/index'
  648. })
  649. }
  650. }
  651. }
  652. </script>
  653. <style lang="scss" scoped>
  654. /deep/.base-tag{
  655. background-color: #f5f5f5;
  656. }
  657. .bntCon{
  658. position: relative;
  659. &:before{
  660. position: absolute;
  661. content: '';
  662. width: 6rpx;
  663. height: 80rpx;
  664. background: radial-gradient( rgba(0,0,0,0.082) 0%, rgba(0,0,0,0) 100%);
  665. left:-22rpx;
  666. }
  667. }
  668. .scroll_box {
  669. overflow: hidden;
  670. }
  671. .aside_active {
  672. background-color: #fff;
  673. width: 100%;
  674. text-align: center;
  675. color: var(--view-theme);
  676. font-weight: 500;
  677. position: relative;
  678. &::after {
  679. content: '';
  680. width: 6rpx;
  681. height: 48rpx;
  682. background-color: var(--view-theme);
  683. position: absolute;
  684. left: 0;
  685. top: 50%;
  686. transform: translateY(-50%);
  687. border-radius: 0 10rpx 10rpx 0;
  688. }
  689. .top-ra{
  690. width: 32rpx;
  691. height: 32rpx;
  692. background-color: #fff;
  693. position: absolute;
  694. right: 0;
  695. top:-32rpx;
  696. text{
  697. position: absolute;
  698. top:0;
  699. right: 0;
  700. width: 100%;
  701. height: 100%;
  702. background-color: #f5f5f5;
  703. display: inline-block;
  704. border-radius: 0 0 24rpx 0;
  705. }
  706. }
  707. .bottom-ra{
  708. width: 32rpx;
  709. height: 32rpx;
  710. background-color: #fff;
  711. position: absolute;
  712. right: 0;
  713. bottom:-32rpx;
  714. text{
  715. position: absolute;
  716. top:0;
  717. right: 0;
  718. width: 100%;
  719. height: 100%;
  720. background-color: #f5f5f5;
  721. display: inline-block;
  722. border-radius: 0 24rpx 0 0;
  723. }
  724. }
  725. }
  726. .cate_active {
  727. color: var(--view-theme);
  728. background: var(--view-minorColorT);
  729. border: 1rpx solid var(--view-theme);
  730. }
  731. .footer{
  732. position: fixed;
  733. /* #ifdef H5 */
  734. bottom: 140rpx;
  735. /* #endif */
  736. /* #ifdef MP || APP-PLUS */
  737. bottom: 20px;
  738. /* #endif */
  739. left: 20rpx;
  740. z-index: 101;
  741. }
  742. .cart_box {
  743. width: 0;
  744. height: 96rpx;
  745. border-radius: 48rpx;
  746. background-color: rgba(0, 0, 0, 0.83);
  747. padding-left: 94rpx;
  748. transition: 0.3s;
  749. &.open{
  750. width: 710rpx;
  751. }
  752. }
  753. .show-footer{
  754. /* #ifdef MP || APP-PLUS */
  755. bottom: calc(140rpx + env(safe-area-inset-bottom));
  756. /* #endif */
  757. }
  758. .jianbian {
  759. background: linear-gradient(90deg, #ff7931 0%, #e93323 100%);
  760. }
  761. .text-primary-con {
  762. color: var(--view-theme);
  763. }
  764. .bg-primary-light {
  765. background: var(--view-minorColorT);
  766. }
  767. .pl-30 {
  768. padding-left: 30rpx;
  769. }
  770. .con_border {
  771. border: 1px solid var(--view-theme);
  772. }
  773. .border_e {
  774. border: 1px solid #eee;
  775. }
  776. .active_pic {
  777. width: 104rpx;
  778. height: 104rpx;
  779. background-color: #fff;
  780. padding: 3rpx;
  781. border-radius: 50%;
  782. border: 3rpx solid var(--view-theme);
  783. image {
  784. width: 100%;
  785. height: 100%;
  786. border-radius: 50%;
  787. }
  788. }
  789. .scroll_pic {
  790. image {
  791. width: 92rpx;
  792. height: 92rpx;
  793. border-radius: 50%;
  794. }
  795. }
  796. .active_cate_text {
  797. background: linear-gradient(90deg, var(--view-gradient) 0, var(--view-theme) 100%);
  798. color: #fff;
  799. border-radius: 20rpx;
  800. margin-top: 8rpx;
  801. }
  802. .w-346 {
  803. width: 346rpx;
  804. }
  805. .badge-style {
  806. position: absolute;
  807. top: -2rpx;
  808. right: -14rpx;
  809. /deep/ .uni-badge--error {
  810. background-color: var(--view-theme) !important;
  811. }
  812. .uni-badge {
  813. color: var(--view-theme);
  814. border: 1px solid var(--view-theme);
  815. z-index: 29;
  816. }
  817. }
  818. .white-box{
  819. height: calc(300rpx + env(safe-area-inset-bottom));
  820. }
  821. </style>