searchList.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. <template>
  2. <view class="app-page">
  3. <u-sticky offset-top="0" customStyle="width:100%">
  4. <view class="top-view"
  5. :style="'height:' + topData.height + 'px;' + 'padding-top:' + topData.top + 'px;padding-bottom:20rpx'">
  6. <u-icon name="arrow-left" color="#000000" size="34rpx" customStyle="padding: 16rpx" @click="toBack()">
  7. </u-icon>
  8. <u-search class="serchTitle" placeholder="请输入关键词搜索" v-model="keyWord" bg-color="#dfdfdf"
  9. border-color="#ffffff" margin="0 200rpx 0 0" placeholder-color="#959595" :show-action="false"
  10. @search="toSearchKeyWord" @clear="toSearchKeyWord"></u-search>
  11. </view>
  12. </u-sticky>
  13. <view class="good-list">
  14. <template v-for="(item,index) in mList">
  15. <view class="good-item" @click="toDetails(item)">
  16. <u--image width='160rpx' height='160rpx' radius="10rpx" mode="widthFix" :src="item.cover"
  17. :fade="true" duration="450" customStyle="margin-top:32rpx;margin-bottom:32rpx;flex-shrink: 0" />
  18. <view class="good-item-content ml10">
  19. <view class="text-overflow-single mb20">{{item.goods_name}}</view>
  20. <view class="display-flex-between">
  21. <text class="fs13 fw600 color-red">¥{{item.price_selling}}<text
  22. class="color-2c">起</text></text>
  23. </view>
  24. </view>
  25. </view>
  26. <u-line :color="index !== (mList && mList.length - 1) ? '#E9E9E9' : '#00000000'" length="calc(100%)"
  27. customStyle="margin-bottom:4rpx;"></u-line>
  28. </template>
  29. </view>
  30. <Empty v-if="mList && mList.length == 0"></Empty>
  31. </view>
  32. </template>
  33. <script>
  34. import Empty from "@/components/Empty/index.vue"
  35. import CommercePart from '@/components/CommercePart'
  36. import { getGoodList } from "@/common/api/good.js";
  37. export default {
  38. components: {
  39. Empty,
  40. CommercePart
  41. },
  42. data() {
  43. return {
  44. topData: {
  45. top: 0,
  46. height: 0
  47. },
  48. keyWord: '',
  49. page: 1,
  50. mList: undefined
  51. }
  52. },
  53. computed: {
  54. searchData() {
  55. return {
  56. pageSize: 20,
  57. page: this.page,
  58. name: this.keyWord
  59. }
  60. }
  61. },
  62. created() {
  63. const topData = uni.getMenuButtonBoundingClientRect()
  64. this.topData.top = topData.top
  65. this.topData.height = topData.height
  66. },
  67. onLoad(options) {},
  68. onReachBottom() {
  69. this.page++;
  70. this.getTaskList()
  71. },
  72. methods: {
  73. toBack() {
  74. uni.navigateBack()
  75. },
  76. toDetails(item) {
  77. uni.navigateTo({
  78. url: `/subPages/goodsDetail/goodsDetail?code=${item.code}&type=common`
  79. })
  80. },
  81. toSearchKeyWord(val) {
  82. console.log(val);
  83. this.page = 1;
  84. if (this.keyWord != '') {
  85. this.mList = [];
  86. this.getTaskList();
  87. } else {
  88. this.mList = [];
  89. this.mList = undefined;
  90. }
  91. },
  92. getTaskList(cateids) {
  93. const data = this.searchData;
  94. getGoodList(data)
  95. .then((res) => {
  96. if (res.data) {
  97. if (this.page === 1) {
  98. this.mList = res.data.list;
  99. } else {
  100. this.mList = this.mList.concat(res.data.list);
  101. }
  102. } else {
  103. if (this.page != 1) {
  104. this.page;
  105. } else {
  106. this.mList = []
  107. }
  108. }
  109. })
  110. .catch(() => {
  111. if (this.page != 1) {
  112. this.page--;
  113. }
  114. uni.hideLoading();
  115. });
  116. },
  117. }
  118. }
  119. </script>
  120. <style lang="scss" scoped>
  121. .app-page {
  122. width: 100vw;
  123. display: flex;
  124. background: white;
  125. align-items: center;
  126. flex-direction: column;
  127. }
  128. .top-view {
  129. display: flex;
  130. width: 100%;
  131. flex-direction: row;
  132. align-items: flex-end;
  133. }
  134. .top-view image {
  135. height: 60rpx;
  136. margin-left: 30rpx;
  137. width: 80rpx;
  138. }
  139. .top-view text {
  140. font-size: 26rpx;
  141. margin-bottom: 10rpx;
  142. margin-left: 10rpx;
  143. }
  144. .good-list {
  145. background: white;
  146. display: flex;
  147. flex-basis: 0;
  148. flex-direction: column;
  149. width: 100%;
  150. box-sizing: border-box;
  151. padding: 40rpx;
  152. align-items: center;
  153. }
  154. .good-item {
  155. width: calc(100% - 40rpx);
  156. display: flex;
  157. flex-direction: row;
  158. align-items: center;
  159. }
  160. .good-item-content {
  161. // flex: 1;
  162. // margin-left: 20rpx;
  163. // display: flex;
  164. // flex-direction: column;
  165. }
  166. .good-name-box {
  167. display: flex;
  168. margin-top: 28rpx;
  169. flex-direction: row;
  170. align-items: center;
  171. image {
  172. width: 30rpx;
  173. height: 30rpx;
  174. display: block;
  175. }
  176. text {
  177. font-size: 32rpx;
  178. font-family: PingFang SC-Bold, PingFang SC;
  179. font-weight: bold;
  180. color: #1D161F;
  181. // margin-left: 10rpx;
  182. overflow: hidden;
  183. text-overflow: ellipsis;
  184. -webkit-line-clamp: 1;
  185. display: -webkit-box;
  186. -webkit-box-orient: vertical;
  187. }
  188. }
  189. .good-desc {
  190. font-size: 22rpx;
  191. font-family: PingFang SC-Medium, PingFang SC;
  192. font-weight: 500;
  193. color: #2C2C2C;
  194. margin-top: 8rpx;
  195. }
  196. .good-tags {
  197. display: flex;
  198. flex-direction: row;
  199. margin-top: 15rpx;
  200. align-items: center;
  201. .good-tag1 {
  202. font-size: 22rpx;
  203. font-family: PingFang SC-Medium, PingFang SC;
  204. font-weight: 500;
  205. margin-right: 10rpx;
  206. color: #765AEE;
  207. padding: 3rpx 12rpx;
  208. background: #F3F1FF;
  209. border-radius: 5rpx 5rpx 5rpx 5rpx;
  210. opacity: 1;
  211. }
  212. .good-tag2 {
  213. font-size: 22rpx;
  214. font-family: PingFang SC-Medium, PingFang SC;
  215. font-weight: 500;
  216. color: #5E5E5E;
  217. margin-right: 10rpx;
  218. padding: 3rpx 12rpx;
  219. background: #F8F8F8;
  220. border-radius: 5rpx 5rpx 5rpx 5rpx;
  221. opacity: 1;
  222. }
  223. }
  224. .good-bottom {
  225. display: flex;
  226. flex-direction: row;
  227. align-items: center;
  228. margin-top: 32rpx;
  229. justify-content: space-between;
  230. .good-time {
  231. font-size: 22rpx;
  232. font-family: PingFang SC-Medium, PingFang SC;
  233. font-weight: 500;
  234. color: #B7B7B7;
  235. }
  236. .good-view-box {
  237. display: flex;
  238. flex-direction: row;
  239. align-items: center;
  240. image {
  241. height: 16rpx;
  242. width: 22rpx;
  243. display: block;
  244. }
  245. text {
  246. font-size: 22rpx;
  247. font-family: PingFang SC-Medium, PingFang SC;
  248. font-weight: 500;
  249. color: #B7B7B7;
  250. margin-left: 6rpx;
  251. }
  252. }
  253. }
  254. </style>