likeProduct.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. <template>
  2. <view>
  3. <view class="like-title" v-show="list &&list.length > 0">
  4. <!-- <image src="https://jnlzjk-1323137866.cos.ap-chongqing.myqcloud.com/shop/images/like.png" mode=""></image> -->
  5. <text class="text">猜你喜欢</text>
  6. </view>
  7. <view class="like-list">
  8. <view class="item" v-for="(item,index) in list" :key="index" @click="showProduct(item)">
  9. <view class="img-box">
  10. <image class="img" :src="item.image" mode="aspectFill"></image>
  11. <view class="tag-row" v-if="item.tagList && item.tagList.length > 0">
  12. <text class="tag-chip" v-for="(t, i) in item.tagList" :key="i">{{ t }}</text>
  13. </view>
  14. </view>
  15. <view class="info-box">
  16. <view class="title ellipsis2">{{ item.productName }}</view>
  17. <view class="price-box">
  18. <view class="now">
  19. <text class="unit">¥</text>
  20. <text class="num">{{item.price.toFixed(2)}}</text>
  21. <text class="numOld" v-if="item.otPrice != null">原价¥{{item.otPrice.toFixed(2)}}</text>
  22. </view>
  23. </view>
  24. </view>
  25. </view>
  26. </view>
  27. <Loading :loaded="loaded" :loading="loading"></Loading>
  28. </view>
  29. </template>
  30. <script>
  31. import {getGoodsProducts} from '@/api/product'
  32. import {getUserInfo} from '@/api/user'
  33. import Loading from "@/components/Loading";
  34. export default {
  35. components: {Loading },
  36. name: "likeProduct",
  37. data() {
  38. return {
  39. page:{
  40. page: 1,
  41. pageSize: 10
  42. },
  43. total:0,
  44. list:[],
  45. loaded: false,
  46. loading: false,
  47. userinfoa:[],
  48. isuser:false,
  49. };
  50. },
  51. created() {
  52. },
  53. mounted() {
  54. this.getGoodsProducts();
  55. if(uni.getStorageSync('AppToken')){
  56. this.getUserInfos()
  57. }else{
  58. this.isuser=true
  59. }
  60. },
  61. watch: {
  62. UserInfo() {
  63. return uni.getStorageSync('AppToken')
  64. }
  65. },
  66. methods: {
  67. getUserInfos(){
  68. getUserInfo().then(res => {
  69. if(res.code==200){
  70. if(res.user!=null){
  71. // if(res.user.isPromoter==null||res.user.isPromoter==0){
  72. // this.tuiModalControl=true
  73. // }
  74. this.userinfoa=res.user
  75. console.log(this.userinfoa.isShow,78787)
  76. }
  77. }else{
  78. uni.showToast({
  79. icon:'none',
  80. title: "请求失败",
  81. });
  82. }
  83. },
  84. rej => {}
  85. );
  86. },
  87. getGoodsProducts(){
  88. console.log(1)
  89. var that=this;
  90. if (that.loaded == true || that.loading == true) return;
  91. that.loading = true;
  92. uni.showLoading({
  93. title:"加载中..."
  94. })
  95. getGoodsProducts(that.page).then(
  96. res => {
  97. if(res.code==200){
  98. that.total=res.data.total;
  99. that.list.push.apply(that.list, res.data.list);
  100. that.loading = false;
  101. that.loaded = that.list.length<that.total?false:true;
  102. that.page.page = that.page.page + 1;
  103. uni.hideLoading()
  104. }
  105. },
  106. err => {
  107. uni.hideLoading()
  108. uni.showToast({
  109. title: err.msg ,
  110. icon: 'none',
  111. duration: 2000
  112. });
  113. }
  114. );
  115. },
  116. showProduct(item){
  117. uni.navigateTo({
  118. url: '/pages/shopping/productDetails?productId='+item.productId
  119. })
  120. },
  121. }
  122. };
  123. </script>
  124. <style lang="scss">
  125. .like-title{
  126. display: flex;
  127. align-items: center;
  128. justify-content: left;
  129. padding-bottom:24rpx;
  130. image{
  131. width: 37upx;
  132. height: 37upx;
  133. margin-right: 20upx;
  134. }
  135. .text{
  136. font-family: PingFangSC, PingFang SC;
  137. font-weight: 600;
  138. font-size: 40rpx;
  139. color: #222222;
  140. line-height: 56rpx;
  141. color: #111111;
  142. }
  143. }
  144. .like-list{
  145. display: flex;
  146. flex-direction: column;
  147. //flex-wrap: wrap;
  148. .item{
  149. //margin-right: 20rpx;
  150. margin-bottom: 20rpx;
  151. //width: 345rpx;
  152. background: #FFFFFF;
  153. box-shadow: 0px 0px 10rpx 4rpx rgba(199, 199, 199, 0.22);
  154. border-radius: 20rpx;
  155. overflow: hidden;
  156. // &:nth-child(2n) {
  157. // margin-right: 0;
  158. // }
  159. .img-box{
  160. width: 100%;
  161. height: 394rpx;
  162. position: relative;
  163. image{
  164. width: 100%;
  165. height: 100%;
  166. }
  167. .tag-row {
  168. position: absolute;
  169. bottom:0;
  170. display: flex;
  171. flex-wrap: wrap;
  172. gap: 12rpx;
  173. padding: 0 12rpx;
  174. margin-bottom: 12rpx;
  175. }
  176. .tag-chip {
  177. font-family: PingFangSC, PingFang SC;
  178. font-weight: 400;
  179. font-size: 30rpx;
  180. color: #AA4726;
  181. line-height: 42rpx;
  182. background: #FFF4F1;
  183. padding: 4rpx 12rpx;
  184. border-radius: 6rpx;
  185. }
  186. }
  187. .info-box{
  188. box-sizing: border-box;
  189. //height: 182upx;
  190. padding: 20rpx;
  191. display: flex;
  192. flex-direction: column;
  193. justify-content: space-between;
  194. .title{
  195. font-family: PingFangSC, PingFang SC;
  196. font-weight: 500;
  197. font-size: 36rpx;
  198. color: #111111;
  199. line-height: 50rpx;
  200. }
  201. .price-box{
  202. margin-top: 8rpx;
  203. display: flex;
  204. align-items: flex-end;
  205. .now{
  206. display: flex;
  207. align-items: baseline;
  208. margin-right: 20upx;
  209. .unit{
  210. font-size: 28rpx;
  211. font-family: PingFang SC;
  212. font-weight: 500;
  213. color: #FF233C;
  214. margin-right: 4upx;
  215. }
  216. .num{
  217. font-size: 44rpx;
  218. font-family: PingFang SC;
  219. font-weight: bold;
  220. color: #FF233C;
  221. }
  222. .numOld{
  223. margin-left: 12rpx;
  224. font-size: 28rpx;
  225. color: #999;
  226. text-decoration: line-through;
  227. }
  228. }
  229. .old{
  230. font-size: 26upx;
  231. font-family: PingFang SC;
  232. font-weight: 500;
  233. text-decoration: line-through;
  234. color: #BBBBBB;
  235. line-height: 1.1;
  236. }
  237. }
  238. }
  239. }
  240. }
  241. </style>