FavoriteStore.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <template>
  2. <view class="div container">
  3. <view class="div store-wrapper" v-if="favorites_list && favorites_list.length">
  4. <view class="store-item" v-for="(item, index) in favorites_list" v-bind:key="item.fav_id" @click="goNavigate('/pages/home/storedetail/Storedetail',{'id': item.store_id})">
  5. <view class="div p-img">
  6. <image mode="aspectFit" class="img collection-img" v-bind:src="item.store_avatar_url"/>
  7. </view>
  8. <view class="div store_name">{{ item.store_name }}</view>
  9. <view class="div del-btn">
  10. <view class="iconfont">&#xe64d;</view>
  11. <view class="explain" @click.stop="delFavoriteStore($event,item.fav_id)">取消收藏</view>
  12. </view>
  13. </view>
  14. </view>
  15. <empty-record v-else-if="favorites_list && !favorites_list.length"></empty-record>
  16. <uni-popup background-color="#fff" ref="confirm" type="dialog">
  17. <uni-popup-dialog :mode="dialog.mode" :title="dialog.title" :content="dialog.content" :placeholder="dialog.content" @confirm="confirmDialog" @close="closeDialog"></uni-popup-dialog>
  18. </uni-popup>
  19. </view>
  20. </template>
  21. <script>
  22. import { urlencode } from '@/util/common'
  23. import EmptyRecord from '../../EmptyRecord'
  24. import { getFavoriteStoreList, delFavoriteStore } from '../../../api/memberFavorite'
  25. export default {
  26. components:{
  27. EmptyRecord
  28. },
  29. name: 'MemberFavoriteStore',
  30. data(){
  31. return {
  32. rightOptions:[{text:'删除',style:{backgroundColor:'#dd524d'}}],
  33. dialog:{},
  34. favorites_list: false
  35. }
  36. },
  37. created: function () {
  38. this.getFavoriteStoreList()
  39. },
  40. methods:{
  41. closeDialog(){
  42. },
  43. confirmDialog(value){
  44. this.getCancelCollection(this.dialog.data)
  45. },
  46. goNavigate(path,query=false){
  47. uni.navigateTo({url:path+(query?('?'+urlencode(query)):'')})
  48. },
  49. delFavoriteStore (e,favId) {
  50. this.dialog={content:'是否要取消收藏此机构?',title: '确认删除',data:favId}
  51. this.$refs.confirm.open()
  52. },
  53. // 取消收藏机构数据
  54. getCancelCollection (favId) {
  55. delFavoriteStore(favId).then(res => {
  56. if (res) {
  57. this.getFavoriteStoreList()
  58. }
  59. })
  60. },
  61. getFavoriteStoreList () {
  62. uni.showLoading({ title: '加载中' })
  63. getFavoriteStoreList(this.page, {}).then(res => {
  64. uni.hideLoading()
  65. this.favorites_list = res.result.favorites_list
  66. }).catch(function (error) {
  67. uni.hideLoading()
  68. uni.showToast({icon:'none',title:error.message})
  69. })
  70. }
  71. }
  72. }
  73. </script>
  74. <style lang="scss" scoped>
  75. .store-wrapper{background: #fff;border-radius: .5rem;padding:0 $pageSpace 2rem;}
  76. .store-wrapper .store-item{height:3rem;width:100%;padding: .8rem 0;border-bottom: 1px dashed #DBDADF;display: flex;align-items: center;}
  77. .store-wrapper .store-item .p-img{padding:0.25rem 0;}
  78. .store-wrapper .store-item .p-img .img{width:3rem;height:3rem;border-radius:.5rem}
  79. .store-wrapper .store-item .store_name{color: #333;font-size: .8rem;margin-left: 1rem;width: 40%;overflow: hidden;white-space: nowrap}
  80. .store-wrapper .store-item .del-btn{margin-left: auto;text-align: center;margin-right: 1rem;}
  81. .store-wrapper .store-item .del-btn .iconfont{font-size: 1.4rem;color: $primaryColor;}
  82. .store-wrapper .store-item .del-btn .explain{font-size: .7rem;color: #999;}
  83. </style>