collection.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695
  1. <template>
  2. <view class="container product clearfix">
  3. <view class="superv-header" v-if="!isEmpty">
  4. <view class="superv-header-click">
  5. <view class="oltext">共<text class="red">3</text>件商品</view>
  6. <view class="ortext" @click="supervClickFn" v-if="!isSuperv">编辑</view>
  7. <view class="ortext" @click="closeSupervFn" v-else>完成</view>
  8. </view>
  9. </view>
  10. <view class="product-content">
  11. <view :class="{'tui-order-list':scrollTop >= 0}" class="clearfix">
  12. <!-- 空白页 -->
  13. <view class="empty-container" v-if="isEmpty">
  14. <image class="empty-container-image" :src="StaticUrl+'/icon/icon-collection-empty@2x.png'"></image>
  15. <text class="error-text">暂无收藏商品~</text>
  16. </view>
  17. <!-- 列表 -->
  18. <view class="tui-cart-cell tui-mtop" v-for="(item,index) in dataList" :key="index">
  19. <view class="tui-goods-item">
  20. <view class="tui-goods-checkBox" v-if="isSuperv">
  21. <view class="checkbox iconfont"
  22. :class="[item.isChecked ?'icon-yixuanze':'icon-weixuanze']"
  23. @click="checkedSoperv(item)">
  24. </view>
  25. </view>
  26. <view class="tui-goods-image">
  27. <image :src="item.image" class="tui-goods-img"/>
  28. </view>
  29. <view class="tui-goods-info" :style="{width:isSuperv ? '360rpx' : '420rpx'}">
  30. <view class="tui-goods-title">{{ item.name }}</view>
  31. <view class="tui-price-box">
  32. <view class="tui-goods-price">¥{{item.price | NumFormat}}</view>
  33. </view>
  34. <view class="tui-goods-pip">市场价:¥{{item.normalPrice | NumFormat}}</view>
  35. <view class="tui-goods-pip">分类:{{ item.typeName ? item.typeName : '无' }}</view>
  36. </view>
  37. <view class="tui-goods-status">
  38. <view class="status-text" :style="{ color: verifyColorFilter(item.validFlag)}">
  39. {{ item.validFlag | verifyStatusFilter }}
  40. </view>
  41. </view>
  42. </view>
  43. </view>
  44. <!--加载loadding-->
  45. <tui-loadmore :visible="loadding" :index="3" type="black"></tui-loadmore>
  46. <tui-nomore :visible="!pullUpOn" :backgroundColor="'#ffffff'" :text='nomoreText'></tui-nomore>
  47. <!--加载loadding-->
  48. </view>
  49. </view>
  50. <!-- 批量操作 -->
  51. <tui-bottom-popup :radius="false" :mask="false" :show="isSuperv">
  52. <view class="tui-popup-box clearfix">
  53. <view class="tui-right-flex tui-popup-btn" :style="{ paddingBottom :isIphoneX ? '68rpx' : '0rpx' }">
  54. <view class="tui-flex-1">
  55. <view class="superv-header-checked">
  56. <view class="oltext" @click="isCheckedAll">
  57. <view class="checkbox iconfont" :class="[isAllChecked ? 'icon-yixuanze':'icon-weixuanze']"></view>
  58. <view class="text">全选</view>
  59. </view>
  60. </view>
  61. <view class="tui-button" :class="isProductChecked ? 'active' : ''" @click="handleAllUnder()">取消收藏</view>
  62. </view>
  63. </view>
  64. </view>
  65. </tui-bottom-popup>
  66. <!-- 弹窗提示 -->
  67. <tui-modal :show="modal"
  68. @click="handleClick"
  69. @cancel="hideMobel"
  70. :content="contentModalText"
  71. color="#333"
  72. :size="32"
  73. shape="circle"
  74. :maskClosable="false">
  75. </tui-modal>
  76. <!-- 可拖动悬浮按钮 -->
  77. <cm-drag :cartNum="cartQuantity"
  78. :isDock="true"
  79. :existTabBar="true"
  80. @btnClick="btnClick"
  81. @btnTouchstart="btnTouchstart"
  82. @btnTouchend="btnTouchend">
  83. </cm-drag>
  84. </view>
  85. </template>
  86. <script>
  87. import tuiLoadmore from "@/components/tui-components/loadmore/loadmore"
  88. import tuiNomore from "@/components/tui-components/nomore/nomore"
  89. import cmDrag from '@/components/cm-custom/cm-drag.vue'
  90. import { mapState,mapMutations } from 'vuex'
  91. const defaultListQuery = {
  92. userId:0,
  93. pageNum:1,
  94. pageSize:10
  95. };
  96. export default{
  97. components: {
  98. tuiLoadmore,
  99. tuiNomore,
  100. cmDrag
  101. },
  102. data() {
  103. return{
  104. StaticUrl:this.$Static,
  105. cartQuantity:0,
  106. isSuperv:false,
  107. isProductChecked:false,
  108. listQuery:Object.assign({}, defaultListQuery),
  109. dataList: [],
  110. scrollTop: 0,
  111. isEmpty: true,
  112. isAllChecked:false,
  113. loadding: false,
  114. pullUpOn: true,
  115. pullFlag: true,
  116. hasNextPage: false,
  117. navbarHeight:'',
  118. nomoreText: '上拉显示更多',
  119. contentModalText:'',//操作文字提示语句
  120. modal:false,
  121. }
  122. },
  123. onLoad(option){
  124. this.initGetStotage()
  125. // this.GetProductListInfo()
  126. },
  127. filters: {
  128. NumFormat:function(text) {//处理金额
  129. return Number(text).toFixed(2);
  130. }
  131. },
  132. computed: {
  133. ...mapState(['hasLogin','userInfo'])
  134. },
  135. methods:{
  136. ...mapMutations(['login','logout']),
  137. async initGetStotage(){
  138. const userInfo = await this.$api.getStorage()
  139. this.listQuery.userId = userInfo.userId ? userInfo.userId : 0
  140. },
  141. GetProductListInfo(){
  142. this.coupinList = []
  143. this.listQuery.pageNum = 1
  144. this.ProductService.QueryCouponCenter(this.listQuery).then(response =>{
  145. let data = response.data
  146. if(data.list&&data.list.length > 0){
  147. this.isEmpty = false
  148. this.hasNextPage = data.hasNextPage
  149. this.coupinList = data.list
  150. this.pullFlag = false;
  151. setTimeout(()=>{this.pullFlag = true;},500)
  152. if(this.hasNextPage){
  153. this.pullUpOn = false
  154. this.nomoreText = '上拉显示更多'
  155. }else{
  156. if(this.coupinList.length < 8){
  157. this.pullUpOn = true
  158. }else{
  159. this.pullUpOn = false
  160. this.loadding = false
  161. this.nomoreText = '已至底部'
  162. }
  163. }
  164. }else{
  165. this.isEmpty = true
  166. }
  167. this.isRequest = true;
  168. }).catch(error =>{
  169. this.$util.msg(error.msg,2000);
  170. })
  171. },
  172. GetOnReachBottomData(index){//上拉加载
  173. this.listQuery.pageNum+=1
  174. this.ProductService.QueryCouponCenter(this.listQuery).then(response =>{
  175. let data = response.data
  176. if(data.list&&data.list.length > 0){
  177. this.hasNextPage = data.hasNextPage
  178. this.coupinList = this.coupinList.concat(data.list)
  179. this.pullFlag = false;// 防上拉暴滑
  180. setTimeout(()=>{this.pullFlag = true;},500)
  181. if(this.hasNextPage){
  182. this.pullUpOn = false
  183. this.nomoreText = '上拉显示更多'
  184. }else{
  185. this.pullUpOn = false
  186. this.loadding = false
  187. this.nomoreText = '已至底部'
  188. }
  189. }
  190. })
  191. .catch(error =>{
  192. this.$util.msg(error.msg,2000)
  193. })
  194. },
  195. handlerButton(e,item){//监听侧滑按钮点击事件
  196. if(item.validFlag === 0 || item.validFlag === 3 || item.validFlag === 8 || item.validFlag === 9){
  197. if(e.index == 0){
  198. return
  199. }
  200. }else if(item.validFlag === 1 || item.validFlag === 10){
  201. if(e.index == 0){
  202. this.$api.navigateTo(`/pages/goods/product?id=${item.productId}`)
  203. }
  204. }else if(item.validFlag === 2){
  205. switch(e.index){
  206. case 0:
  207. this.$api.navigateTo(`/pages/goods/product?id=${item.productId}`)
  208. break;
  209. case 1:
  210. if(item.featuredFlag === 1){
  211. this.handleDeleteShopRemb(item)
  212. }else{
  213. this.handleAddShopRemb(item)
  214. }
  215. break;
  216. case 2:
  217. this.handleUnder(item)
  218. }
  219. }
  220. },
  221. handleAddShopRemb(item){//添加主页推荐
  222. let num = 4- this.featuredNum;
  223. this.OperationType = 'add'
  224. this.handlerProduct = item
  225. this.modal = true;
  226. this.contentModalText = `总共能添加4个主推商品,您还能添加${num}个确定将该商品添加为主推商品吗?`;
  227. },
  228. handleDeleteShopRemb(item){//删除主页推荐
  229. this.OperationType = 'delete'
  230. this.handlerProduct = item
  231. this.modal = true;
  232. this.contentModalText = '是否把该商品从主推商品中删除?';
  233. },
  234. handleUnder(item){//下架操作
  235. this.OperationType = 'under'
  236. this.handlerProduct = item
  237. this.modal = true;
  238. this.contentModalText = '确定下架该商品吗?';
  239. },
  240. handleAllUnder(){//批量下架操作
  241. let checkedArray = [];
  242. let isValidFlag = false;
  243. this.productIds = '';
  244. if(this.isProductChecked){
  245. this.dataList.forEach(el => {
  246. if(el.isChecked) {
  247. checkedArray.push(el)
  248. }
  249. })
  250. checkedArray.forEach(el =>{
  251. if(el.validFlag == 2){
  252. this.productIds += el.productId+','
  253. }
  254. if(el.validFlag != 2){
  255. isValidFlag = true;
  256. }
  257. })
  258. if(isValidFlag){
  259. this.$util.modal('','部分选中的商品暂未上架,不能进行下架操作','确定','',false,() =>{})
  260. return;
  261. }
  262. this.OperationType = 'allunder'
  263. this.modal = true;
  264. this.contentModalText = '确定下架选中的商品吗?';
  265. }
  266. },
  267. handleClick(e) {//弹窗提示用户操作
  268. if(e.index == 1){
  269. switch(this.OperationType){
  270. case 'delete'://删除主页推荐
  271. this.SupplierDeleteSwitchFeatured(this.handlerProduct)
  272. break;
  273. case 'add'://添加主页推荐
  274. this.SupplierAddSwitchFeatured(this.handlerProduct)
  275. break;
  276. case 'under'://下架商品
  277. this.SupplierSoldOutProduct(this.handlerProduct)
  278. break;
  279. case 'allunder'://批量下架
  280. this.SupplierAllSoldOutProduct(this.productIds)
  281. break;
  282. }
  283. }
  284. this.modal = false;
  285. },
  286. SupplierDeleteSwitchFeatured(item){//操作删除主页推荐
  287. this.ShopService.SupplierSwitchFeaturedyProduct({productId:item.productId,featuredFlag:0}).then(response =>{
  288. this.$util.msg('删除成功',2000,true,'success');
  289. setTimeout(() => {
  290. this.GetProductListInfo()
  291. },2000)
  292. }).catch(error =>{
  293. this.$util.msg(error.msg,2000)
  294. })
  295. },
  296. SupplierAddSwitchFeatured(item){//操作添加主页推荐
  297. this.ShopService.SupplierSwitchFeaturedyProduct({productId:item.productId,featuredFlag:1}).then(response =>{
  298. this.$util.msg('添加成功',2000,true,'success');
  299. setTimeout(() => {
  300. this.GetProductListInfo()
  301. },2000)
  302. }).catch(error =>{
  303. this.$util.msg(error.msg,2000)
  304. })
  305. },
  306. SupplierSoldOutProduct(item){//操作下架商品
  307. this.ShopService.SupplierSoldOutProduct({productIds:item.productId}).then(response =>{
  308. this.$util.msg('下架成功',2000,true,'success');
  309. setTimeout(() => {
  310. this.GetProductListInfo()
  311. },2000)
  312. }).catch(error =>{
  313. this.$util.msg(error.msg,2000)
  314. })
  315. },
  316. SupplierAllSoldOutProduct(ids){//操作批量下架商品
  317. this.ShopService.SupplierSoldOutProduct({productIds:ids}).then(response =>{
  318. this.$util.msg('下架成功',2000,true,'success');
  319. this.productIds = '';
  320. setTimeout(() => {
  321. this.GetProductListInfo()
  322. },2000)
  323. }).catch(error =>{
  324. this.$util.msg(error.msg,2000)
  325. })
  326. },
  327. hideMobel(){
  328. this.modal = false;
  329. },
  330. updateCheckAllBtn() {//勾选单个判断全选
  331. let goodsCheckedLength = 0
  332. this.dataList.forEach(item => {
  333. if(item.isChecked) { goodsCheckedLength++; }
  334. })
  335. this.isAllChecked = goodsCheckedLength === this.dataList.length;
  336. if(goodsCheckedLength>0){
  337. this.isProductChecked = true
  338. }else{
  339. this.isProductChecked = false
  340. }
  341. },
  342. updateBothCheckBtn() {//全选勾选判断
  343. this.dataList.forEach((item)=>{
  344. item.isChecked = this.isAllChecked
  345. })
  346. },
  347. isCheckedAll(){//全选
  348. this.isAllChecked = !this.isAllChecked
  349. if(this.isAllChecked){
  350. this.isProductChecked = true
  351. }else{
  352. this.isProductChecked = false
  353. }
  354. this.updateBothCheckBtn()
  355. },
  356. checkedSoperv(item){//选择
  357. item.isChecked = !item.isChecked
  358. console.log(item)
  359. this.updateCheckAllBtn()
  360. },
  361. supervClickFn(){//管理全选
  362. this.isSuperv = true
  363. },
  364. closeSupervFn(){
  365. this.isSuperv = false
  366. },
  367. btnClick() {
  368. this.$emit('goCartPage')
  369. },
  370. btnTouchstart() {
  371. // console.log('btnTouchstart');
  372. },
  373. btnTouchend() {
  374. // console.log('btnTouchend');
  375. }
  376. },
  377. onPageScroll(e){//实时获取到滚动的值
  378. },
  379. onReachBottom() {
  380. if(this.hasNextPage){
  381. this.loadding = true
  382. this.pullUpOn = true
  383. this.GetOnReachBottomData()
  384. }
  385. },
  386. onPullDownRefresh() {
  387. setTimeout(() => {
  388. this.listQuery.pageNum = 1
  389. uni.stopPullDownRefresh()
  390. }, 200)
  391. },
  392. onShow(){
  393. }
  394. }
  395. </script>
  396. <style lang="scss">
  397. @import "@/uni.scss";
  398. page{
  399. background:#FFF;
  400. }
  401. .empty-container{
  402. z-index: 9999;
  403. }
  404. .superv-header{
  405. width: 100%;
  406. height: 80rpx;
  407. background-color: #F7F7F7;
  408. line-height: 80rpx;
  409. position: fixed;
  410. top: 0;
  411. left: 0;
  412. box-sizing: border-box;
  413. padding: 0 24rpx;
  414. z-index: 999;
  415. .superv-header-click{
  416. width: 100%;
  417. height: 80rpx;
  418. font-size: $font-size-30;
  419. .oltext{
  420. float: left;
  421. color: #666666;
  422. .red{
  423. color: $color-system;
  424. }
  425. }
  426. .ortext{
  427. float: right;
  428. color: #333333;
  429. text-align: right;
  430. }
  431. }
  432. }
  433. .tui-header {
  434. width: 100%;
  435. font-size: 16px;
  436. font-weight: 500;
  437. height: 32px;
  438. display: flex;
  439. align-items: center;
  440. justify-content: center;
  441. position: relative;
  442. padding: 0 40rpx;
  443. }
  444. .header-sit{
  445. width:100%;
  446. box-sizing: border-box;
  447. height: 80rpx;
  448. line-height: 80rpx;
  449. box-sizing: border-box;
  450. padding:0 40rpx;
  451. text-align: left;
  452. font-size: $font-size-40;
  453. color: #FFFFFF;
  454. font-weight: 600;
  455. font-family: '正楷';
  456. margin-top: 30rpx;
  457. .iconfont{
  458. font-size: 42rpx;
  459. margin-left: 30rpx;
  460. }
  461. }
  462. .mine{
  463. width: 100%;
  464. height: 100%;
  465. position:relative;
  466. }
  467. .product-content{
  468. width: 100%;
  469. height: auto;
  470. position: relative;
  471. padding:0;
  472. padding-top: 80rpx;
  473. box-sizing: border-box;
  474. .empty-container-image {
  475. width: 260rpx;
  476. height: 260rpx;
  477. margin-top: -300rpx;
  478. }
  479. }
  480. .tui-goods-item {
  481. display: flex;
  482. padding: 30rpx 20rpx;
  483. box-sizing: border-box;
  484. border-bottom: 1px solid #EBEBEB;
  485. position: relative;
  486. }
  487. .tui-goods-checkBox{
  488. display: flex;
  489. align-items: center;
  490. margin: 0 15rpx;
  491. .checkbox{
  492. display: flex;
  493. margin: 0;
  494. padding: 0;
  495. display: flex;
  496. flex-direction: column;
  497. align-items: center;
  498. box-sizing: border-box;
  499. text-align: center;
  500. text-decoration: none;
  501. border-radius: 0;
  502. -webkit-tap-highlight-color: transparent;
  503. overflow: hidden;
  504. background-color:#FFFFFF;
  505. font-size: 36rpx;
  506. color:$color-system;
  507. }
  508. .text{
  509. font-size: $font-size-24;
  510. margin-left: 10rpx;
  511. }
  512. }
  513. .tui-goods-image{
  514. width: 180rpx;
  515. height: 180rpx !important;
  516. border-radius: 12rpx;
  517. .tui-goods-img {
  518. width: 180rpx;
  519. height: 180rpx !important;
  520. border-radius: 12rpx;
  521. flex-shrink: 0;
  522. display: block;
  523. }
  524. }
  525. .tui-goods-info {
  526. padding-left: 20rpx;
  527. display: flex;
  528. flex-direction: column;
  529. align-items: flex-start;
  530. justify-content: space-between;
  531. box-sizing: border-box;
  532. overflow: hidden;
  533. position: relative;
  534. }
  535. .tui-goods-status{
  536. width: 160rpx;
  537. position: absolute;
  538. right: 0;
  539. .status-text{
  540. font-size: $font-size-24;
  541. line-height: 44rpx;
  542. text-align: center;
  543. color: #666666;
  544. }
  545. }
  546. .tui-goods-title {
  547. white-space: normal;
  548. word-break: break-all;
  549. overflow: hidden;
  550. text-overflow: ellipsis;
  551. display: -webkit-box;
  552. -webkit-box-orient: vertical;
  553. -webkit-line-clamp: 2;
  554. font-size: 26rpx;
  555. color: #333;
  556. line-height: 44rpx;
  557. }
  558. .tui-goods-pip{
  559. white-space: normal;
  560. word-break: break-all;
  561. overflow: hidden;
  562. text-overflow: ellipsis;
  563. display: -webkit-box;
  564. -webkit-box-orient: vertical;
  565. -webkit-line-clamp: 2;
  566. font-size: 24rpx;
  567. color: #999;
  568. line-height: 44rpx;
  569. }
  570. .tui-goods-ediet{
  571. width: 60rpx;
  572. height: 60rpx;
  573. background: linear-gradient(90deg,rgba(122,165,250,1) 0%,rgba(87,110,250,1) 100%);
  574. border-radius: 50%;
  575. line-height: 60rpx;
  576. text-align: center;
  577. position: absolute;
  578. right: 0;
  579. top: 50%;
  580. .icon-bianji1 {
  581. flex-shrink: 0;
  582. display: flex;
  583. align-items: center;
  584. justify-content: center;
  585. color: #FFFFFF;
  586. font-size: 24rpx;
  587. }
  588. }
  589. .tui-goods-model {
  590. max-width: 100%;
  591. color: #FFFFFF;
  592. background: #4688fa;
  593. border-radius: 40rpx;
  594. display: flex;
  595. align-items: center;
  596. justify-content: space-between;
  597. padding: 0 20rpx;
  598. box-sizing: border-box;
  599. margin-top: 10rpx;
  600. }
  601. .tui-model-text {
  602. max-width: 100%;
  603. transform: scale(0.9);
  604. transform-origin: 0 center;
  605. font-size: 24rpx;
  606. line-height: 40rpx;
  607. white-space: nowrap;
  608. overflow: hidden;
  609. text-overflow: ellipsis;
  610. }
  611. .tui-price-box {
  612. width: 100%;
  613. display: flex;
  614. align-items: flex-end;
  615. justify-content: space-between;
  616. }
  617. .tui-goods-price {
  618. font-size: $font-size-28;
  619. font-weight: 500;
  620. color: #FF201F;
  621. }
  622. .tui-popup-box {
  623. position: relative;
  624. box-sizing: border-box;
  625. min-height: 200rpx;
  626. padding:6rpx 24rpx;
  627. }
  628. .tui-popup-btn {
  629. width: 100%;
  630. height: auto;
  631. float: left;
  632. box-sizing: border-box;
  633. margin-top: 30rpx;
  634. .superv-header-checked{
  635. float: left;
  636. font-size: $font-size-30;
  637. .oltext{
  638. width: 120rpx;
  639. float: left;
  640. color: #666666;
  641. display: flex;
  642. margin-left: 10rpx;
  643. .checkbox{
  644. display: flex;
  645. margin: 0;
  646. padding: 0;
  647. display: flex;
  648. flex-direction: column;
  649. align-items: center;
  650. box-sizing: border-box;
  651. text-align: center;
  652. text-decoration: none;
  653. border-radius: 0;
  654. -webkit-tap-highlight-color: transparent;
  655. overflow: hidden;
  656. font-size: 34rpx;
  657. color:$color-system;
  658. line-height: 80rpx;
  659. }
  660. .text{
  661. float: left;
  662. line-height: 80rpx;
  663. margin-left: 15rpx;
  664. }
  665. }
  666. .ortext{
  667. width: 120rpx;
  668. float: right;
  669. color: $color-system;
  670. text-align: right;
  671. }
  672. }
  673. .tui-button{
  674. width: 210rpx;
  675. height: 88rpx;
  676. float: right;
  677. background: #e1e1e1;
  678. line-height: 88rpx;
  679. text-align: center;
  680. color: #FFFFFF;
  681. font-size: $font-size-28;
  682. border-radius: 44rpx;
  683. &.active{
  684. background: $btn-confirm;
  685. }
  686. }
  687. }
  688. </style>