productList.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417
  1. <template>
  2. <view class="container">
  3. <navbar :config="config" backColor="#666"></navbar>
  4. <view class="zdtopbox" :style="{ top: tabTop + 'px' }">
  5. <!-- <view class="" style="display: flex;align-items: center;">
  6. <text class="iconfont position-ab u-mt15 u-ml30 u-D1D9D4">&#xe7a6;</text>
  7. <input placeholder="请输入搜索关键字" @confirm="confirmSubmit" v-model="value" placeholder-class="pc" />
  8. <text style="color: #FFFFFF;font-size: 28rpx; font-weight: 500;margin-left: 20rpx;align-items: center;" @click="SearchContent">搜索</text>
  9. </view> -->
  10. <div class="search-box">
  11. <div class="search-wap">
  12. <text class="iconfont search-icon">&#xe7a6;</text>
  13. <input type="text" class="sput" placeholder-style="color: #ddd;" confirm-type="search" v-model="value"
  14. placeholder="请输入搜索关键字" @confirm="confirmSubmit" />
  15. </div>
  16. <div class="word" @click="SearchContent">搜索</div>
  17. </div>
  18. <view class="u-flex-center-sa u-mt30 u-font28 tabs">
  19. <view class="u-flex screen" @click="screening(1)">
  20. <view :class="screeningIndex == 1 ? 'activeColors' : ''">综合</view>
  21. </view>
  22. <view class="u-flex-center screen" @click="screening(4)">
  23. <view :class="screeningIndex == 4 ? 'activeColors' : ''">销量</view>
  24. <!-- <view class="u-flex-column-center ">
  25. <view class="iconfont u-font24 linge" :class="screeningIndex==2&&!selfNum?'activeColors':''">&#xeb20;</view>
  26. <view class="iconfont u-font24 linge" :class="screeningIndex==2&&selfNum?'activeColors':''">&#xeb1f;</view>
  27. </view> -->
  28. </view>
  29. <view class="u-flex-center screen" @click="screening(3)">
  30. <view :class="screeningIndex == 3 ? 'activeColors' : ''">价格</view>
  31. <view class="linge-box">
  32. <view class="iconfont u-font24 linge" :class="screeningIndex == 3 && !price ? 'activeColors' : ''">&#xe648;
  33. </view>
  34. <view class="iconfont u-font24 linge" :class="screeningIndex == 3 && price ? 'activeColors' : ''">&#xe645;
  35. </view>
  36. </view>
  37. </view>
  38. <view class="u-flex screen" @click="screening(2)">
  39. <view :class="screeningIndex == 2 ? 'activeColors' : ''">新品</view>
  40. </view>
  41. </view>
  42. </view>
  43. <view class="u-plr30 u-mt30 pt80">
  44. <view class="productItme">
  45. <view class="itemp u-flex-center-sb u-mt20" @click="goProductDetails(item, item.authorize_shop_id)"
  46. v-for="(item, index) in goodsList" :key="item.id">
  47. <view class="pImgs u-mr20">
  48. <image class="u-goods226" :src="item.cover" mode=""></image>
  49. <!-- <view class="tipsImg u-flex-center">
  50. <image src="../../../static/disbg.png" mode=""></image>
  51. <view class="u-FFF u-font24 textpiv">4.5折</view>
  52. </view> -->
  53. </view>
  54. <view class="u-flex1 u-flex-column-start">
  55. <view class="u-text2 proWidth u-flex1">
  56. <view class="tipsStatus" v-if="item.platform_store">自营</view>
  57. <text class="u-font28 u-181818">{{ item.title }}</text>
  58. </view>
  59. <view class="u-font20 u-999 u-mt5">
  60. 已售
  61. <text class="u-FF0000">{{ item.result_sale_num }}</text>
  62. </view>
  63. <view class="u-font32 u-bold u-flex-center u-flex1 u-FF0000" style="margin-top: 8rpx;">
  64. <rich-text :nodes="$mUtil.priceBigSmall(item.min_sale_price)"></rich-text>
  65. <text class="u-del u-999 u-font22 u-bold-normal u-ml20">¥{{ item.max_market_price }}</text>
  66. </view>
  67. <view class="good-praise" style="font-size: 20rpx; color: #999999;margin-top: 30rpx; ">
  68. <text style="color: #FF4E15;">{{ item.comment_num }}</text>
  69. 条评论 评分:
  70. <text style="color: #FF4E15;margin-left: 2rpx;" v-if="item.average % 1 === 0">{{ item.average }}.0</text>
  71. <text v-else style="color: #FF4E15; margin-left: 2rpx;">{{ item.average }}</text>
  72. </view>
  73. <view></view>
  74. <view class="store" @click.stop="goTobusiness(item.shop_id)"
  75. style="color: #999999;font-size: 24rpx;font-weight: 500;align-items: center; margin-top: 5rpx; align-items: center;">
  76. {{ item.shop_name }}
  77. <text class="iconfont" style="font-size: 20rpx;">&#xe6c7;</text>
  78. </view>
  79. </view>
  80. </view>
  81. <nodata v-if="noData" :config="{ top: 20, content: '暂无商品~' }"></nodata>
  82. <loadMore v-if="goodsList.length > 0" :status="status"></loadMore>
  83. </view>
  84. </view>
  85. <!--页面加载动画-->
  86. <ldLoading isFullScreen :active="loading"></ldLoading>
  87. </view>
  88. </template>
  89. <script>
  90. var app = getApp();
  91. export default {
  92. data() {
  93. return {
  94. config: {
  95. back: true, //false是tolbar页面 是则不写
  96. title: '商品列表',
  97. color: '#1a1a1a',
  98. //背景颜色;参数一:透明度(0-1);参数二:背景颜色(array则为线性渐变,string为单色背景)
  99. backgroundColor: [1, '#fff'],
  100. // statusBarFontColor: '#FFFFFF'
  101. },
  102. goodsList: [],
  103. score: null,
  104. loading: true,
  105. noData: false,
  106. value: '',
  107. status: 'more', //more|loading|noMore
  108. screeningIndex: 1,
  109. price: false,
  110. selfNum: false,
  111. tabTop: 0,
  112. params: {
  113. limit: 10,
  114. page: 1,
  115. order_type: 1, //1是综合(按发布时间),2是新品,3价格,4销量
  116. order_mode: '' //asc 或 desc
  117. }
  118. };
  119. },
  120. onLoad(options) {
  121. this.tabTop = app.globalData.barHeight + 44;
  122. if (options.keyword) {
  123. this.params.title = options.keyword;
  124. this.value = options.keyword || '';
  125. }
  126. // if (options.category_id) {
  127. // this.params.category_id = options.category_id;
  128. // }
  129. this.getShopList();
  130. console.log(options)
  131. },
  132. onReachBottom(e) {
  133. this.status = 'loading';
  134. this.params.page++;
  135. this.getShopList();
  136. },
  137. onPullDownRefresh() {
  138. this.rest();
  139. this.getShopList();
  140. },
  141. methods: {
  142. //跳转商家店面
  143. goTobusiness(id) {
  144. console.log(id);
  145. uni.navigateTo({
  146. url: '/pages/convenienceService/shopDetails?shopId=' + id
  147. });
  148. },
  149. //普通商品详情页
  150. goProductDetails(item, shopid) {
  151. uni.navigateTo({
  152. url: `/pages/product/goods/goods?id=${item.id}`
  153. })
  154. // 积分商品
  155. // if (item.point_goods) {
  156. // uni.navigateTo({
  157. // url: `/pages/product/goods/IntegralGood?id=${item.id}`
  158. // })
  159. // // 免费商品
  160. // } else if (item.free) {
  161. // uni.navigateTo({
  162. // url: `/pages/product/goods/freeGoods?id=${item.id}`
  163. // })
  164. // // 普通商品
  165. // } else {
  166. // uni.navigateTo({
  167. // url: `/pages/product/goods/goods?id=${item.id}`
  168. // })
  169. // }
  170. },
  171. screening(e) {
  172. this.loading = true;
  173. this.params.order_type = e;
  174. this.screeningIndex = e;
  175. // if(e==2){
  176. // this.selfNum =!this.selfNum
  177. // if(this.selfNum){
  178. // this.params.order_mode='asc'
  179. // }else{
  180. // this.params.order_mode='desc'
  181. // }
  182. // }else
  183. if (e == 3) {
  184. this.price = !this.price;
  185. if (this.price) {
  186. this.params.order_mode = 'asc';
  187. } else {
  188. this.params.order_mode = 'desc';
  189. }
  190. } else if (e == 4) {
  191. this.params.order_mode = 'desc';
  192. } else {
  193. this.params.order_mode = '';
  194. }
  195. this.rest();
  196. this.getShopList();
  197. },
  198. //搜索返回的数据
  199. confirmSubmit(e) {
  200. this.params.title = e.detail.value;
  201. this.value = e.detail.value;
  202. this.rest();
  203. this.getShopList();
  204. },
  205. SearchContent() {
  206. this.params.title = this.value;
  207. this.rest();
  208. this.getShopList();
  209. },
  210. rest() {
  211. this.params.page = 1;
  212. this.goodsList = [];
  213. },
  214. getShopList() {
  215. let shop = uni.getStorageSync('shop');
  216. let shopid = shop.id ? shop.id : '';
  217. this.$http.get(`/goods/all/pages`, this.params).then(res => {
  218. uni.stopPullDownRefresh();
  219. this.loading = false;
  220. this.triggered = false;
  221. if (res && res.code == 200) {
  222. if (res.page.list.length > 0) {
  223. if (this.params.title) {
  224. this.reset(this.params.title);
  225. }
  226. }
  227. this.goodsList = this.goodsList.concat(res.page.list);
  228. if (this.goodsList.length == 0) {
  229. this.noData = true;
  230. } else {
  231. this.noData = false;
  232. }
  233. if (res.page.totalPage <= res.page.currPage) {
  234. this.status = 'noMore';
  235. } else {
  236. this.status = 'more';
  237. }
  238. }
  239. });
  240. },
  241. reset(text) {
  242. let recordList = uni.getStorageSync('history') ? uni.getStorageSync('history') : [];
  243. recordList.unshift(text);
  244. let arr = JSON.parse(JSON.stringify(recordList));
  245. let newArr = Array.from(new Set(arr));
  246. recordList = newArr;
  247. uni.setStorageSync('history', JSON.parse(JSON.stringify(recordList)));
  248. }
  249. }
  250. };
  251. </script>
  252. <style lang="scss">
  253. page {
  254. background-color: #f5f5f5;
  255. }
  256. .search-box {
  257. // height: 85rpx;
  258. // padding: 0 30rpx;
  259. width: 100%;
  260. display: flex;
  261. // align-items: center;
  262. .search-wap {
  263. width: 600rpx;
  264. height: 60rpx;
  265. display: flex;
  266. align-items: center;
  267. background: #fff;
  268. border: 1px solid rgba(0, 0, 0, 0.42);
  269. border-radius: 30rpx;
  270. position: relative;
  271. .search-icon {
  272. font-size: 18px;
  273. margin-left: 30rpx;
  274. // color: #fff;
  275. }
  276. .sput {
  277. margin-left: 25rpx;
  278. font-size: 22rpx;
  279. // color: #ffffff;
  280. width: 100%;
  281. }
  282. }
  283. .word {
  284. font-size: 28rpx;
  285. // color: #ffffff;
  286. margin-left: 24rpx;
  287. line-height: 60rpx;
  288. }
  289. }
  290. .linge-box {
  291. display: flex;
  292. flex-direction: column;
  293. justify-content: space-between;
  294. height: 28rpx;
  295. }
  296. .linge {
  297. line-height: 14rpx;
  298. font-size: 15rpx;
  299. }
  300. .position-ab {
  301. position: absolute;
  302. }
  303. .pt80 {
  304. padding-top: 120rpx;
  305. }
  306. .zdtopbox {
  307. background-color: #fff;
  308. padding: 8rpx 30rpx 10rpx;
  309. position: fixed;
  310. left: 0;
  311. width: 100%;
  312. z-index: 66;
  313. box-sizing: border-box;
  314. // input {
  315. // flex: 1;
  316. // height: 60rpx;
  317. // line-height: 60rpx;
  318. // border-radius: 50rpx;
  319. // background-color: rgba($color: #abc5b5, $alpha: 0.4);
  320. // color: #fff;
  321. // padding-left: 78rpx;
  322. // box-sizing: border-box;
  323. // }
  324. .pc {
  325. font-size: 22rpx;
  326. color: #abc5b5 !important;
  327. }
  328. .wt-ht8 {
  329. width: 16rpx;
  330. height: 16rpx;
  331. }
  332. }
  333. .oval {
  334. background-color: #f5f5f5;
  335. padding: 18rpx 38rpx;
  336. border-radius: 50rpx;
  337. margin-top: 30rpx;
  338. margin-right: 22rpx;
  339. }
  340. .itemp {
  341. padding: 30rpx 20rpx;
  342. border-radius: 10rpx;
  343. background-color: #fff;
  344. }
  345. .pImgs {
  346. position: relative;
  347. width: 226rpx;
  348. height: 226rpx;
  349. .tipsImg {
  350. width: 96rpx;
  351. height: 44rpx;
  352. position: absolute;
  353. left: 0;
  354. bottom: 0;
  355. image {
  356. width: 96rpx;
  357. height: 44rpx;
  358. position: absolute;
  359. z-index: 0;
  360. }
  361. .textpiv {
  362. width: 96rpx;
  363. text-align: center;
  364. position: relative;
  365. z-index: 1;
  366. }
  367. }
  368. }
  369. .proWidth {
  370. .tipsStatus {
  371. display: inline-block;
  372. padding: -0 10rpx;
  373. background: #ff0000;
  374. border-radius: 10rpx 0px 10rpx 0px;
  375. line-height: 40rpx;
  376. text-align: center;
  377. margin-right: 10rpx;
  378. color: #fff;
  379. font-size: 20rpx;
  380. }
  381. }
  382. .activeColors {
  383. color: #FA6138;
  384. font-weight: bold;
  385. }
  386. .tabs{
  387. padding-bottom: 10rpx;
  388. }
  389. </style>