three.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. <template>
  2. <view class="content">
  3. <!-- <view class="status_bar"></view> -->
  4. <view class="hotgoods">
  5. <view class="hotgoods-item" v-for="jfitem in list" :key="jfitem.id"
  6. @click="navto('/pages/product/product?id=' + jfitem.id )" style="height: 520rpx;">
  7. <view class="image-wrapper">
  8. <image class="image" :src="jfitem.image" mode="scaleToFill"></image>
  9. </view>
  10. <view class="flex" style="flex-direction: column;justify-content: space-between;align-items: flex-start;height: 170rpx;">
  11. <view class="title clamp2">{{jfitem.store_name}}</view>
  12. <view class="hot-price">
  13. <view class="price">
  14. <text>¥{{ jfitem.price * 1 }}</text>
  15. <text class="ot-pirce" >销量:{{jfitem.sales}}</text>
  16. </view>
  17. </view>
  18. </view>
  19. </view>
  20. </view>
  21. <empty v-if="loaded && list.length == 0"></empty>
  22. <uni-load-more :status="loadingType" v-if="!(loaded && list.length == 0)"></uni-load-more>
  23. </view>
  24. </template>
  25. <script>
  26. import empty from '@/components/empty.vue'
  27. import { getCate,getGoodList} from '@/api/three.js'
  28. import { getProducts } from '@/api/product.js'
  29. export default {
  30. components: {
  31. empty
  32. },
  33. data() {
  34. return {
  35. cid: '',
  36. sid: '',
  37. list: [],
  38. page:1,
  39. limit: 10,
  40. loaded:false,
  41. loadingType: 'more',
  42. keyword: '',
  43. is_one: 0,
  44. }
  45. },
  46. onLoad(opt) {
  47. if(opt.is_one) {
  48. this.is_one = opt.is_one
  49. }
  50. if(opt.cid) {
  51. this.cid = opt.cid
  52. }
  53. if(opt.sid) {
  54. this.sid = opt.sid
  55. }
  56. this.getGoodList()
  57. },
  58. onShow() {
  59. },
  60. onReachBottom() {
  61. this.getGoodList()
  62. },
  63. onReady() {
  64. },
  65. methods: {
  66. navto(url) {
  67. uni.navigateTo({
  68. url,
  69. fail() {
  70. uni.switchTab({
  71. url
  72. })
  73. }
  74. })
  75. },
  76. goIndex() {
  77. uni.switchTab({
  78. url:'/pages/index/index'
  79. })
  80. },
  81. clickSearch() {
  82. },
  83. getCate() {
  84. getCate({
  85. id: 0
  86. }).then(res => {
  87. })
  88. },
  89. getGoodList(type) {
  90. let that = this
  91. if(type == 're') {
  92. that.list = []
  93. that.page = 1
  94. that.loadingType = 'more'
  95. }
  96. if(that.loadingType == 'loading' || that.loadingType == 'noMore') {
  97. return
  98. }
  99. that.loadingType = 'loading'
  100. getProducts({
  101. is_level: that.is_level,
  102. page: that.page,
  103. limit: that.limit,
  104. is_one: that.is_one,
  105. cid: that.cid,
  106. sid: that.sid
  107. }).then(res => {
  108. console.log(res)
  109. let arr =res.data
  110. if(arr) {
  111. that.list = that.list.concat(arr)
  112. if(arr.length == that.limit) {
  113. that.loadingType = 'more'
  114. that.page++
  115. }else {
  116. that.loadingType = 'noMore'
  117. }
  118. }else {
  119. that.loadingType = 'noMore'
  120. }
  121. that.loaded = true
  122. })
  123. }
  124. }
  125. }
  126. </script>
  127. <style lang="scss" scoped>
  128. .hotgoods {
  129. // margin-top: 38rpx;
  130. width: 100%;
  131. display: flex;
  132. flex-wrap: wrap;
  133. padding: 20rpx 20rpx 30rpx;
  134. justify-content: space-between;
  135. .hotgoods-item {
  136. width: 345rpx;
  137. background-color: #ffffff;
  138. border-radius: 12rpx;
  139. box-shadow: 0 0 15rpx rgba(0, 0, 0, 0.2);
  140. margin-bottom: 15rpx;
  141. .image-wrapper {
  142. width: 345rpx;
  143. height: 345rpx;
  144. border-radius: 3px;
  145. overflow: hidden;
  146. position: relative;
  147. .image-bg {
  148. position: absolute;
  149. top: 0;
  150. left: 0;
  151. right: 0;
  152. bottom: 0;
  153. width: 100%;
  154. height: 100%;
  155. opacity: 1;
  156. border-radius: 12rpx 12rpx 0 0;
  157. z-index: 2;
  158. }
  159. .image {
  160. width: 100%;
  161. height: 100%;
  162. opacity: 1;
  163. border-radius: 12rpx 12rpx 0 0;
  164. }
  165. }
  166. .title {
  167. margin-top: 24rpx;
  168. padding: 0 20rpx;
  169. font-size: 32rpx;
  170. font-weight: 500;
  171. color: #333333;
  172. }
  173. .hot-price {
  174. display: flex;
  175. justify-content: flex-start;
  176. align-items: center;
  177. width: 100%;
  178. padding: 0 10rpx;
  179. // padding: 14rpx 0 30rpx;
  180. .hotPrice-box {
  181. padding: 2rpx 6rpx;
  182. background: linear-gradient(90deg, #c79a4c, #f9df7f);
  183. border-radius: 5rpx;
  184. text-align: center;
  185. line-height: 28rpx;
  186. font-size: 20rpx;
  187. font-family: Source Han Sans CN;
  188. font-weight: 400;
  189. color: #ffffff;
  190. }
  191. .price {
  192. margin-left: 10rpx;
  193. font-size: 36rpx;
  194. color: #ff0000;
  195. font-weight: 500;
  196. display: flex;
  197. width: 100%;
  198. justify-content: space-between !important;
  199. align-items: center;
  200. .jf {
  201. font-size: 20rpx;
  202. }
  203. .give-jf {
  204. display: inline-block;
  205. padding: 8rpx;
  206. background: linear-gradient(90deg, #FF834D, #FF2600);
  207. border-radius: 12rpx 0px 12rpx 0px;
  208. font-size: 22rpx;
  209. font-weight: 500;
  210. color: #FFFFFF;
  211. margin-left: 22rpx;
  212. }
  213. .ot-pirce {
  214. margin-left: 7rpx;
  215. font-size: 26rpx;
  216. font-weight: 500;
  217. // text-decoration: line-through;
  218. color: #999999;
  219. align-self: flex-end;
  220. }
  221. }
  222. .yuanPrice {
  223. margin-left: 10rpx;
  224. font-size: 20rpx;
  225. font-family: PingFang SC;
  226. font-weight: 500;
  227. text-decoration: line-through;
  228. color: #999999;
  229. }
  230. .cart-icon {
  231. image {
  232. width: 44rpx;
  233. height: 44rpx;
  234. }
  235. }
  236. }
  237. }
  238. }
  239. .status_bar {
  240. height: var(--status-bar-height);
  241. background-color: #fff;
  242. width: 100%;
  243. position: fixed;
  244. top: 0;
  245. z-index: 999;
  246. }
  247. </style>