three.vue 6.2 KB

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