likeProduct.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. <template>
  2. <view>
  3. <view class="like-title" v-show="list &&list.length > 0">
  4. <image src="/static/img_title.png" mode=""></image>
  5. <text class="text">猜你想要</text>
  6. <image src="/static/img_title.png" mode=""></image>
  7. </view>
  8. <view class="like-list">
  9. <view class="item" v-for="(item,index) in list" :key="index" @click="showProduct(item)">
  10. <view class="img-box">
  11. <image :src="item.image" mode=""></image>
  12. </view>
  13. <view class="info-box">
  14. <view class="title ellipsis2">{{ item.productName }}</view>
  15. <view class="price-box">
  16. <view class="now">
  17. <text class="unit">¥</text>
  18. <text class="num" v-if="userinfoa.isShow==1&&isuser==false">{{item.price.toFixed(2)}}</text>
  19. <text class="num" v-else>{{item.otPrice.toFixed(2)}}</text>
  20. </view>
  21. <view class="old" v-if="userinfoa.isShow==1&&isuser==false">¥{{item.otPrice.toFixed(2)}}</view>
  22. </view>
  23. </view>
  24. </view>
  25. </view>
  26. <Loading :loaded="loaded" :loading="loading"></Loading>
  27. </view>
  28. </template>
  29. <script>
  30. import {getGoodsProducts} from '@/api/product'
  31. import {getUserInfo} from '@/api/user'
  32. import Loading from "@/components/Loading";
  33. export default {
  34. components: {Loading },
  35. name: "likeProduct",
  36. data() {
  37. return {
  38. page:{
  39. page: 1,
  40. pageSize: 10,
  41. isDrug:this.$store.state.isDrug
  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: center;
  129. padding: 30upx 0;
  130. image{
  131. width: 40upx;
  132. height: 40upx;
  133. margin:0 4upx;
  134. }
  135. .text{
  136. font-size: 36upx;
  137. font-family: PingFang SC;
  138. font-weight: bold;
  139. color: #111111;
  140. line-height: 1;
  141. }
  142. }
  143. .like-list{
  144. display: flex;
  145. flex-wrap: wrap;
  146. .item{
  147. margin-right: 20rpx;
  148. margin-bottom: 20rpx;
  149. width: 345rpx;
  150. background: #FFFFFF;
  151. box-shadow: 0px 0px 10rpx 4rpx rgba(199, 199, 199, 0.22);
  152. border-radius: 20rpx;
  153. overflow: hidden;
  154. &:nth-child(2n) {
  155. margin-right: 0;
  156. }
  157. .img-box{
  158. width: 100%;
  159. height: 334upx;
  160. image{
  161. width: 100%;
  162. height: 100%;
  163. }
  164. }
  165. .info-box{
  166. box-sizing: border-box;
  167. height: 182upx;
  168. padding: 20upx 20upx 30upx;
  169. display: flex;
  170. flex-direction: column;
  171. justify-content: space-between;
  172. .title{
  173. font-size: 26upx;
  174. font-family: PingFang SC;
  175. font-weight: 500;
  176. color: #111111;
  177. line-height: 40upx;
  178. }
  179. .price-box{
  180. display: flex;
  181. align-items: flex-end;
  182. .now{
  183. display: flex;
  184. align-items: flex-end;
  185. margin-right: 20upx;
  186. .unit{
  187. font-size: 24upx;
  188. font-family: PingFang SC;
  189. font-weight: 500;
  190. color: #FF6633;
  191. line-height: 1.2;
  192. margin-right: 4upx;
  193. }
  194. .num{
  195. font-size: 36upx;
  196. font-family: PingFang SC;
  197. font-weight: bold;
  198. color: #FF6633;
  199. line-height: 1;
  200. }
  201. }
  202. .old{
  203. font-size: 26upx;
  204. font-family: PingFang SC;
  205. font-weight: 500;
  206. text-decoration: line-through;
  207. color: #BBBBBB;
  208. line-height: 1.1;
  209. }
  210. }
  211. }
  212. }
  213. }
  214. </style>