You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

194 lines
3.7 KiB

10 months ago
  1. <template>
  2. <view class="collect">
  3. <u-navbar
  4. :title="$t('page.collect.title')"
  5. :safeAreaInsetTop="false"
  6. placeholder
  7. @leftClick="leftClick"
  8. >
  9. </u-navbar>
  10. <view class="list" v-if="list.length">
  11. <view class="item"
  12. v-for="(item, index) in list"
  13. v-if="item.shoplist"
  14. :key="index">
  15. <view class="top-info" @click="toProductDetail(item.shoplist.id)">
  16. <view class="left-img">
  17. <image
  18. mode="aspectFill" :src="item.shoplist.image ? item.shoplist.image.split(',')[0] : ''" alt="" />
  19. </view>
  20. <view class="right-text">
  21. <view class="title">
  22. <u--text :lines="2" :text="item.shoplist.title"></u--text>
  23. </view>
  24. <view class="price">
  25. {{ item.shoplist.price }}
  26. </view>
  27. </view>
  28. </view>
  29. <view class="bottom-info">
  30. <view class="date">
  31. {{ item.createTime }}
  32. <!-- <uni-dateformat :date="item.shoplist.date" format="yyyy-MM-dd hh:mm"></uni-dateformat> -->
  33. </view>
  34. <view class="btn">
  35. <button class="delete" @click="del(item.shoplist.id)">{{ $t('page.collect.detele') }}</button>
  36. </view>
  37. </view>
  38. </view>
  39. </view>
  40. <view v-else class="no-product">
  41. <view class="box">
  42. <view class="no-product-title">{{ $t('page.cart.none-product') }}</view>
  43. <view @click="toHome()" class="to-home">{{ $t('page.cart.stroll')}}</view>
  44. </view>
  45. </view>
  46. </view>
  47. </template>
  48. <script>
  49. export default {
  50. data() {
  51. return {
  52. list : [
  53. {
  54. price : '199.0',
  55. oldPrice : '299.0',
  56. date : new Date('2024-04-25 00:46').getTime(),
  57. title : 'Huawei Enjoy 70/ ProHuawei Enjoy 70 Pro/Huawei Enjoy 70 Pro',
  58. }
  59. ]
  60. };
  61. },
  62. onShow() {
  63. this.getData()
  64. },
  65. methods : {
  66. getData(){
  67. this.request('collectionPage', {}, {
  68. "pageSize":999,
  69. "currentPage": 0
  70. })
  71. .then(res => {
  72. if(res.code == 200){
  73. let arr = []
  74. res.result.records.forEach(n => {
  75. if(n.shoplist){
  76. arr.push(n)
  77. }
  78. })
  79. this.list = arr
  80. }
  81. })
  82. },
  83. toProductDetail(shop_id) {
  84. uni.navigateTo({
  85. url: '/pages/productDetail/productDetail?id=' + shop_id
  86. })
  87. },
  88. del(shopId){
  89. this.request('collectionShop', {}, {
  90. shopId
  91. })
  92. .then(res => {
  93. if(res.code == 200){
  94. this.getData()
  95. uni.$u.toast(this.$t('success-operation'))
  96. }
  97. })
  98. },
  99. leftClick(){
  100. uni.switchTab({
  101. url: '/pages/user/user'
  102. })
  103. },
  104. toHome(){
  105. uni.switchTab({
  106. url: '/pages/home/home'
  107. })
  108. }
  109. }
  110. }
  111. </script>
  112. <style lang="scss" scoped>
  113. .collect{
  114. .list{
  115. .item{
  116. background-color: #fff;
  117. margin-top: 10px;
  118. .top-info{
  119. display: flex;
  120. width: 100%;
  121. box-sizing: border-box;
  122. padding: 20px;
  123. .left-img{
  124. flex: 1;
  125. width: 170px;
  126. height: 20vw;
  127. image{
  128. width: 100%;
  129. height: 100%;
  130. }
  131. }
  132. .right-text{
  133. flex: 3;
  134. padding-left: 10px;
  135. .title{
  136. font-size: 28rpx;
  137. margin-bottom: 5px;
  138. }
  139. .price{
  140. font-size: 39rpx;
  141. padding-right: 8px;
  142. color: #E01717;
  143. }
  144. }
  145. }
  146. .bottom-info{
  147. border-top: 1px solid #00000033;
  148. padding: 10px 20px;
  149. display: flex;
  150. justify-content: space-between;
  151. align-items: center;
  152. .date{
  153. font-size: 13px;
  154. color: #777;
  155. }
  156. .btn{
  157. .delete{
  158. border-radius: 5px;
  159. height: 30px;
  160. font-size: 13px;
  161. line-height: 30px;
  162. }
  163. }
  164. }
  165. }
  166. }
  167. }
  168. .no-product {
  169. height: calc(100vh - 44px);
  170. display: flex;
  171. justify-content: center;
  172. .box {
  173. margin-top: 400rpx;
  174. font-size: 26rpx;
  175. text-align: center;
  176. .to-home {
  177. padding: 20rpx 140rpx;
  178. border: 1px solid #ccc;
  179. border-radius: 5px;
  180. text-align: center;
  181. margin: 20rpx 0px;
  182. }
  183. }
  184. }
  185. </style>