tuiProduct.vue 4.5 KB

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