index.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395
  1. <template>
  2. <view class="goods-list-container">
  3. <JHeader title="商品列表" width="50" height="50" style="padding: 24upx 0 0;"></JHeader>
  4. <view class="flex-items-plus flex-row search">
  5. <view class="searchBg">
  6. <view class="searchImg-box flex-items-plus">
  7. <tui-icon style="position: absolute;left: 0;" name="search" :size="50" unit="upx" color="#d1d1d1"></tui-icon>
  8. <input
  9. v-model="queryInfo.search" class="search-box" maxlength="20" placeholder-class="searchboxPlace"
  10. placeholder="请输入您想要的宝贝"
  11. />
  12. </view>
  13. <label class="mar-left-40 fs28" @click="queryInfo.search && (queryInfo.page = 1) && getGoodsSearchList()">
  14. 搜索
  15. </label>
  16. </view>
  17. </view>
  18. <view class="shop-list-nav">
  19. <view class="mlr-20">
  20. <view class="nav-item-sort" @click="handleSortTap(1)">
  21. <text class="nav-title" :class="{ 'active': sortIndex == 1 }">
  22. 默认
  23. </text>
  24. </view>
  25. <view class="nav-item-sort" @click="handleSortTap(2)">
  26. <text class="nav-title" :class="{ 'active': sortIndex == 2 }">
  27. 价格
  28. </text>
  29. <view class="r">
  30. <view class="arrowUp" :class="{ activeUp: queryInfo.type == 1 }"></view>
  31. <view class="arrowDown" :class="{ activeDown: queryInfo.type == 2 }"></view>
  32. </view>
  33. </view>
  34. <view class="nav-item-sort" @click="handleSortTap(3)">
  35. <text class="nav-title" :class="{ 'active': sortIndex == 3 }">
  36. 销量
  37. </text>
  38. <view class="r">
  39. <view class="arrowUp" :class="{ activeUp: queryInfo.volume == 1 }"></view>
  40. <view class="arrowDown" :class="{ activeDown: queryInfo.volume == 2 }"></view>
  41. </view>
  42. </view>
  43. </view>
  44. </view>
  45. <!-- 商品列表 -->
  46. <view v-if="goodsList && goodsList.length" class="listBox">
  47. <view
  48. v-for="(item, index) in goodsList" :key="index" class="goodsDetails-box flex-display flex-column"
  49. @click="go(`/another-tf/another-serve/goodsDetails/index?shopId=${item.shopId}&productId=${item.productId}&skuId=${item.skuId}`)"
  50. >
  51. <view class="spikeList goodsDetails">
  52. <view class="listItem">
  53. <view class="itemBox">
  54. <image :src="common.seamingImgUrl(item.image)" class="pic-img default-img"></image>
  55. </view>
  56. <view class="itemInfo">
  57. <p>{{ item.productName }}</p>
  58. <view v-if="item.number != null" class="number">
  59. <view class="numText">已售{{ item.number }}件</view>
  60. <view v-if="item.total != 0 && item.activityType !== 0" class="numText">
  61. 限量{{ item.total }}件
  62. </view>
  63. </view>
  64. <view class="flex-row-plus flex-item mar-top-30">
  65. <ATFActivityImage :type="item.activityType"></ATFActivityImage>
  66. <view class="font-color-C83732 flex-row-plus">
  67. <b>¥</b>
  68. <label class="fs28">{{ item.price }}</label>
  69. </view>
  70. <view
  71. v-if="item.originalPrice && item.originalPrice > item.price"
  72. class="mar-left-30 discountsPriceLine font-color-999"
  73. >
  74. ¥{{ item.originalPrice }}
  75. </view>
  76. </view>
  77. <view
  78. v-if="item.voucherId && item.voucherPrice"
  79. style="width: fit-content;margin-top: 4upx;padding: 6upx 12upx;background-color: #f0f0f0;font-size: 28upx;color: #fa5151;border-radius: 0 22upx 22upx 0;vertical-align: middle;"
  80. >
  81. 可使用{{ item.voucherPrice }}代金券抵扣
  82. </view>
  83. <view
  84. v-if="item.presenterVoucher"
  85. style="width: fit-content;margin-top: 4upx;padding: 6upx 12upx;background-color: #f0f0f0;font-size: 28upx;color: #fa5151;border-radius: 0 22upx 22upx 0;vertical-align: middle;"
  86. >
  87. 赠送 {{ item.presenterVoucher }} 代金券
  88. </view>
  89. <!-- <view class="flex-display flex-sp-between flex-row mar-top-20 flex-items shopName">
  90. <label class="fs22 font-color-FFEBC4">{{ item.shopName }}</label>
  91. </view> -->
  92. </view>
  93. </view>
  94. </view>
  95. </view>
  96. </view>
  97. <view style="padding-bottom: 45upx;">
  98. <LoadingMore
  99. :status="!isEmpty && !goodsList.length
  100. ? 'loading' : !isEmpty && goodsList.length && (goodsList.length >= goodsTotal) ? 'no-more' : ''"
  101. >
  102. </LoadingMore>
  103. <tui-no-data v-if="isEmpty" :fixed="false" style="margin-top: 60upx;">暂无数据</tui-no-data>
  104. </view>
  105. </view>
  106. </template>
  107. <script>
  108. import { getClaasifyProductsApi, getSearchProductsApi } from '../../../api/anotherTFInterface'
  109. export default {
  110. name: 'GoodsList',
  111. data() {
  112. return {
  113. source: 2,
  114. sortIndex: 1,
  115. isEmpty: false,
  116. goodsList: [],
  117. goodsTotal: 0,
  118. queryInfo: {
  119. page: 1,
  120. pageSize: 20,
  121. search: '',
  122. classifyId: '',
  123. type: 0, // 价格排序条件
  124. volume: 0 // 销量排序条件
  125. }
  126. }
  127. },
  128. onLoad(option) {
  129. if (option.keyWord) {
  130. this.queryInfo.search = option.keyWord
  131. }
  132. if (option.classifyId) {
  133. this.queryInfo.classifyId = option.classifyId
  134. }
  135. this.getGoodsSearchList()
  136. },
  137. methods: {
  138. handleSortTap(index) {
  139. this.sortIndex = index
  140. this.goodsList = []
  141. this.queryInfo.page = 1
  142. if (index === 1) {
  143. this.queryInfo.type = 0
  144. this.queryInfo.volume = 0
  145. } else if (index === 2) {
  146. this.queryInfo.volume = 0
  147. if (this.queryInfo.type === 0) {
  148. this.queryInfo.type = 1
  149. } else {
  150. this.queryInfo.type = this.queryInfo.type != 1 ? 1 : 2
  151. }
  152. } else if (index === 3) {
  153. this.queryInfo.type = 0
  154. if (this.queryInfo.volume === 0) {
  155. this.queryInfo.volume = 1
  156. } else {
  157. this.queryInfo.volume = this.queryInfo.volume != 1 ? 1 : 2
  158. }
  159. }
  160. this.getGoodsSearchList()
  161. },
  162. getGoodsSearchList(isLoadmore) {
  163. let api
  164. if (this.queryInfo.classifyId) {
  165. api = getClaasifyProductsApi
  166. } else {
  167. api = getSearchProductsApi
  168. }
  169. uni.showLoading()
  170. api(this.queryInfo).then((res) => {
  171. this.goodsTotal = res.data.total
  172. if (isLoadmore) {
  173. this.goodsList.push(...res.data.list)
  174. } else {
  175. this.goodsList = res.data.list
  176. }
  177. this.isEmpty = this.goodsList.length === 0
  178. uni.hideLoading()
  179. })
  180. .catch((e) => {
  181. uni.hideLoading()
  182. })
  183. }
  184. },
  185. onReachBottom() {
  186. if (this.goodsList.length < this.goodsTotal) {
  187. ++this.queryInfo.page
  188. this.getGoodsSearchList(true)
  189. }
  190. }
  191. }
  192. </script>
  193. <style lang="less" scoped>
  194. input {
  195. padding-left: 80upx;
  196. }
  197. .goods-list-container {
  198. position: relative;
  199. min-height: 100%;
  200. background-color: #f8f8f8;
  201. box-sizing: border-box;
  202. .search {
  203. padding: 20rpx;
  204. background: #FFFFFF;
  205. border-top: 2rpx solid #F3F4F5;
  206. position: relative;
  207. z-index: 2;
  208. }
  209. .searchImg-box {
  210. position: relative;
  211. }
  212. .searchBg {
  213. width: 100%;
  214. display: flex;
  215. background-color: #F7F7F7;
  216. align-items: center;
  217. height: 78rpx;
  218. justify-content: space-between;
  219. padding: 0 20rpx;
  220. label {
  221. font-weight: 400;
  222. color: #333333;
  223. }
  224. }
  225. .search-box {
  226. width: 400upx;
  227. height: 66upx;
  228. }
  229. .searchboxPlace {
  230. font-size: 26upx;
  231. color: #A9A9A9;
  232. padding-right: 30upx;
  233. }
  234. .goodsDetails-box {
  235. background: #FFFFFF;
  236. margin-top: 20rpx;
  237. .spikeList {
  238. border-bottom: 1upx solid #EDEDED;
  239. padding-top: 30rpx;
  240. padding-bottom: 30upx;
  241. position: relative;
  242. .listItem {
  243. display: flex;
  244. border-bottom: 1upx solid #EEEEEE;
  245. padding-left: 30rpx;
  246. &:last-child {
  247. border-bottom: none;
  248. }
  249. .itemBox {
  250. width: 220upx;
  251. height: 220upx;
  252. margin-right: 30upx;
  253. img {
  254. width: 100%;
  255. height: 100%;
  256. }
  257. }
  258. .itemInfo {
  259. flex: 1;
  260. p {
  261. font-size: 26upx;
  262. color: #333333;
  263. line-height: 40upx;
  264. margin-bottom: 30upx;
  265. text-overflow: -o-ellipsis-lastline;
  266. overflow: hidden;
  267. text-overflow: ellipsis;
  268. display: -webkit-box;
  269. -webkit-line-clamp: 2;
  270. line-clamp: 2;
  271. -webkit-box-orient: vertical;
  272. }
  273. .number {
  274. color: #999999;
  275. font-size: 26upx;
  276. display: flex;
  277. align-items: center;
  278. .numText {
  279. padding: 0 10rpx;
  280. height: 40rpx;
  281. line-height: 40rpx;
  282. border: 2rpx solid #E4E5E6;
  283. color: #C5AA7B;
  284. font-size: 20rpx;
  285. margin-right: 10rpx;
  286. }
  287. }
  288. }
  289. }
  290. .shopName {
  291. position: absolute;
  292. left: 0;
  293. top: 0;
  294. height: 50rpx;
  295. background: #333333;
  296. opacity: 1;
  297. border-radius: 0 20rpx 20rpx 0;
  298. padding: 10rpx 15rpx;
  299. }
  300. }
  301. }
  302. .listBox {
  303. padding: 0 24rpx;
  304. }
  305. }
  306. .shop-list-nav {
  307. background: #fff;
  308. .mlr-20 {
  309. margin: 0 20rpx;
  310. display: flex;
  311. flex-direction: row;
  312. align-items: center;
  313. height: 80rpx;
  314. line-height: 76rpx;
  315. }
  316. }
  317. .active {
  318. color: #C5AA7B;
  319. }
  320. .nav-item-sort {
  321. flex: 1;
  322. font-size: 24rpx;
  323. color: #222;
  324. display: flex;
  325. flex-direction: row;
  326. align-items: center;
  327. justify-content: center;
  328. height: 80rpx;
  329. line-height: 80rpx;
  330. }
  331. .nav-item-sort .r {
  332. display: flex;
  333. flex-direction: column;
  334. align-items: center;
  335. justify-content: center;
  336. margin-left: 5rpx;
  337. .arrowDown {
  338. width: 0;
  339. height: 0;
  340. border-width: 10rpx;
  341. border-style: solid;
  342. border-color: #CCCCCC transparent transparent transparent;
  343. margin-top: 2rpx;
  344. }
  345. .arrowUp {
  346. margin-bottom: 2rpx;
  347. width: 0;
  348. height: 0;
  349. border-width: 10rpx;
  350. border-style: solid;
  351. border-color: transparent transparent #CCCCCC transparent;
  352. }
  353. .activeDown {
  354. border-color: #C5AA7B transparent transparent transparent;
  355. }
  356. .activeUp {
  357. border-color: transparent transparent #C5AA7B transparent;
  358. }
  359. }
  360. .search {
  361. padding-top: 20rpx;
  362. }
  363. </style>