tuiProduct.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. <template>
  2. <view>
  3. <!-- <view class="like-title">
  4. <image src="https://zlwh.obs.cn-southwest-2.myhuaweicloud.com/orangeShop/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. computed: {
  65. isDrug() {
  66. return this.$store.state.isDrug
  67. },
  68. },
  69. methods: {
  70. getUserInfos(){
  71. getUserInfo().then(res => {
  72. if(res.code==200){
  73. if(res.user!=null){
  74. // if(res.user.isPromoter==null||res.user.isPromoter==0){
  75. // this.tuiModalControl=true
  76. // }
  77. this.userinfoa=res.user
  78. console.log(this.userinfoa.isShow,78787)
  79. }
  80. }else{
  81. uni.showToast({
  82. icon:'none',
  83. title: "请求失败",
  84. });
  85. }
  86. },
  87. rej => {}
  88. );
  89. },
  90. getTuiProducts(){
  91. console.log(1)
  92. var that=this;
  93. if (that.loaded == true || that.loading == true) return;
  94. that.loading = true;
  95. uni.showLoading({
  96. title:"加载中..."
  97. })
  98. getTuiProducts({...that.page}).then(
  99. res => {
  100. if(res.code==200){
  101. that.total=res.data.total;
  102. that.list.push.apply(that.list, res.data.list);
  103. that.loading = false;
  104. that.loaded = that.list.length<that.total?false:true;
  105. that.page.page = that.page.page + 1;
  106. uni.hideLoading()
  107. }
  108. },
  109. err => {
  110. uni.hideLoading()
  111. uni.showToast({
  112. title: err.msg ,
  113. icon: 'none',
  114. duration: 2000
  115. });
  116. }
  117. );
  118. },
  119. showProduct(item){
  120. uni.navigateTo({
  121. url: '/pages/shopping/productDetails?productId='+item.productId
  122. })
  123. },
  124. }
  125. };
  126. </script>
  127. <style lang="scss">
  128. .like-title{
  129. display: flex;
  130. align-items: center;
  131. justify-content: center;
  132. padding: 15upx 0rpx 30upx 0rpx;
  133. image{
  134. width: 37upx;
  135. height: 37upx;
  136. margin-right: 20upx;
  137. }
  138. .text{
  139. font-size: 36upx;
  140. font-family: PingFang SC;
  141. font-weight: bold;
  142. color: #111111;
  143. line-height: 1;
  144. }
  145. }
  146. .like-list{
  147. display: flex;
  148. flex-wrap: wrap;
  149. .item{
  150. margin-right: 20rpx;
  151. margin-bottom: 20rpx;
  152. width: 345rpx;
  153. background: #FFFFFF;
  154. box-shadow: 0px 0px 10rpx 4rpx rgba(199, 199, 199, 0.22);
  155. border-radius: 20rpx;
  156. overflow: hidden;
  157. &:nth-child(2n) {
  158. margin-right: 0;
  159. }
  160. .img-box{
  161. width: 100%;
  162. height: 334upx;
  163. image{
  164. width: 100%;
  165. height: 100%;
  166. }
  167. }
  168. .info-box{
  169. box-sizing: border-box;
  170. height: 182upx;
  171. padding: 20upx 20upx 30upx;
  172. display: flex;
  173. flex-direction: column;
  174. justify-content: space-between;
  175. .title{
  176. font-size: 26upx;
  177. font-family: PingFang SC;
  178. font-weight: 500;
  179. color: #111111;
  180. line-height: 40upx;
  181. }
  182. .price-box{
  183. display: flex;
  184. align-items: flex-end;
  185. .now{
  186. display: flex;
  187. align-items: flex-end;
  188. margin-right: 20upx;
  189. .unit{
  190. font-size: 24upx;
  191. font-family: PingFang SC;
  192. font-weight: 500;
  193. color: #FF6633;
  194. line-height: 1.2;
  195. margin-right: 4upx;
  196. }
  197. .num{
  198. font-size: 36upx;
  199. font-family: PingFang SC;
  200. font-weight: bold;
  201. color: #FF6633;
  202. line-height: 1;
  203. }
  204. }
  205. .old{
  206. font-size: 26upx;
  207. font-family: PingFang SC;
  208. font-weight: 500;
  209. text-decoration: line-through;
  210. color: #BBBBBB;
  211. line-height: 1.1;
  212. }
  213. }
  214. }
  215. }
  216. }
  217. </style>