tuiProduct.vue 4.5 KB

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