You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

419 lines
11 KiB

3 months ago
  1. <template>
  2. <view :data-theme="theme">
  3. <view class='productList'>
  4. <view class='search bg_color acea-row row-between-wrapper'>
  5. <!-- #ifdef H5 -->
  6. <view class="iconfont icon-xiangzuo" @click="goback()"></view>
  7. <!-- #endif -->
  8. <view class='input acea-row row-between-wrapper'><text class='iconfont icon-sousuo'></text>
  9. <input placeholder='搜索商品名称' placeholder-class='placeholder' confirm-type='search' name="search"
  10. :value='where.keyword' @confirm="searchSubmit" maxlength="20"></input>
  11. </view>
  12. <view class='iconfont' :class='is_switch==true?"icon-pailie":"icon-tupianpailie"' @click='Changswitch'>
  13. </view>
  14. </view>
  15. <view class='nav acea-row row-middle'>
  16. <view class='item' :class='title ? "font_color":""' @click='set_where(1)'>{{title ? title:'默认'}}</view>
  17. <view class='item' @click='set_where(2)'>
  18. 价格
  19. <image v-if="price==1" :src="urlDomain+'crmebimage/perset/staticImg/up.png'"></image>
  20. <image v-else-if="price==2" :src="urlDomain+'crmebimage/perset/staticImg/down.png'"></image>
  21. <image v-else :src="urlDomain+'crmebimage/perset/staticImg/horn.png'"></image>
  22. </view>
  23. <view class='item' @click='set_where(3)'>
  24. 销量
  25. <image v-if="stock==1" :src="urlDomain+'crmebimage/perset/staticImg/up.png'"></image>
  26. <image v-else-if="stock==2" :src="urlDomain+'crmebimage/perset/staticImg/down.png'"></image>
  27. <image v-else :src="urlDomain+'crmebimage/perset/staticImg/horn.png'"></image>
  28. </view>
  29. <!-- down -->
  30. <view class='item' :class='nows ? "font_color":""' @click='set_where(4)'>新品</view>
  31. </view>
  32. <view :class='is_switch==true?"":"listBox"' v-if="productList.length>0">
  33. <view class='list acea-row row-between-wrapper' :class='is_switch==true?"":"on"'>
  34. <view class='item' :class='is_switch==true?"":"on"' hover-class='none'
  35. v-for="(item,index) in productList" :key="index" @click="godDetail(item)">
  36. <view class='pictrue' :class='is_switch==true?"":"on"'>
  37. <image :src='item.image' :class='is_switch==true?"":"on"'></image>
  38. <view :style="{ backgroundImage: `url(${item.activityStyle})` }" class="border-picture"></view>
  39. <span class="pictrue_log_class"
  40. :class="is_switch === true ? 'pictrue_log_big' : 'pictrue_log'"
  41. v-if="item.activityH5 && item.activityH5.type === '1'">秒杀</span>
  42. <span class="pictrue_log_class"
  43. :class="is_switch === true ? 'pictrue_log_big' : 'pictrue_log'"
  44. v-if="item.activityH5 && item.activityH5.type === '2'">砍价</span>
  45. <span class="pictrue_log_class"
  46. :class="is_switch === true ? 'pictrue_log_big' : 'pictrue_log'"
  47. v-if="item.activityH5 && item.activityH5.type === '3'">拼团</span>
  48. </view>
  49. <view class='text' :class='is_switch==true?"":"on"'>
  50. <view class='name line1'>{{item.storeName}}</view>
  51. <view class='x-money' :class='is_switch==true?"":"on"'><text
  52. class='num'>{{item.price}}</text></view>
  53. <view class='vip acea-row row-between-wrapper' :class='is_switch==true?"":"on"'>
  54. <view class='vip-money' v-if="item.vip_price && item.vip_price > 0">{{item.vip_price}}
  55. <image :src="urlDomain+'crmebimage/perset/staticImg/vip.png'"></image>
  56. </view>
  57. <view>已售{{Number(item.sales)}}{{item.unitName}}</view>
  58. </view>
  59. </view>
  60. </view>
  61. </view>
  62. <view class='loadingicon acea-row row-center-wrapper' v-if='productList.length > 0'>
  63. <text class='loading iconfont icon-jiazai' :hidden='loading==false'></text>{{loadTitle}}
  64. </view>
  65. </view>
  66. </view>
  67. <view class='noCommodity' v-if="productList.length==0 && where.page > 1">
  68. <view class='pictrue'>
  69. <image :src="urlDomain+'crmebimage/perset/staticImg/noShopper.png'"></image>
  70. </view>
  71. <recommend ref="recommendIndex"></recommend>
  72. </view>
  73. </view>
  74. </template>
  75. <script>
  76. import {getProductslist,getProductHot} from '@/api/store.js';
  77. import recommend from '@/components/recommend';
  78. import {mapGetters} from "vuex";
  79. import {goShopDetail} from '@/libs/order.js'
  80. import animationType from '@/utils/animationType.js'
  81. let app = getApp();
  82. export default {
  83. computed: mapGetters(['uid']),
  84. components: {
  85. recommend
  86. },
  87. data() {
  88. return {
  89. urlDomain: this.$Cache.get("imgHost"),
  90. productList: [],
  91. is_switch: true,
  92. where: {
  93. keyword: '',
  94. priceOrder: '',
  95. salesOrder: '',
  96. news: 0,
  97. page: 1,
  98. limit: 20,
  99. cid: '',
  100. },
  101. price: 0,
  102. stock: 0,
  103. nows: false,
  104. loadend: false,
  105. loading: false,
  106. loadTitle: '加载更多',
  107. title: '',
  108. theme:app.globalData.theme
  109. };
  110. },
  111. onLoad: function(options) {
  112. this.$set(this.where, 'cid', options.cid || '');
  113. this.title = options.title || '';
  114. this.$set(this.where, 'keyword', options.searchValue || '');
  115. this.get_product_list();
  116. },
  117. methods: {
  118. goback() {
  119. // #ifdef H5
  120. return history.back();
  121. // #endif
  122. // #ifndef H5
  123. return uni.navigateBack({
  124. delta: 1,
  125. })
  126. // #endif
  127. },
  128. // 去详情页
  129. godDetail(item) {
  130. goShopDetail(item, this.uid).then(res => {
  131. uni.navigateTo({
  132. animationType: animationType.type, animationDuration: animationType.duration,
  133. url: `/pages/goods/goods_details/index?id=${item.id}`
  134. })
  135. })
  136. },
  137. Changswitch: function() {
  138. let that = this;
  139. that.is_switch = !that.is_switch
  140. },
  141. searchSubmit: function(e) {
  142. let that = this;
  143. that.$set(that.where, 'keyword', e.detail.value);
  144. that.loadend = false;
  145. that.$set(that.where, 'page', 1)
  146. this.get_product_list(true);
  147. },
  148. //点击事件处理
  149. set_where: function(e) {
  150. switch (e) {
  151. case 1:
  152. return;
  153. break;
  154. case 2:
  155. if (this.price == 0) this.price = 1;
  156. else if (this.price == 1) this.price = 2;
  157. else if (this.price == 2) this.price = 0;
  158. this.stock = 0;
  159. break;
  160. case 3:
  161. if (this.stock == 0) this.stock = 1;
  162. else if (this.stock == 1) this.stock = 2;
  163. else if (this.stock == 2) this.stock = 0;
  164. this.price = 0
  165. break;
  166. case 4:
  167. this.nows = !this.nows;
  168. break;
  169. }
  170. this.loadend = false;
  171. this.$set(this.where, 'page', 1);
  172. this.get_product_list(true);
  173. },
  174. //设置where条件
  175. setWhere: function() {
  176. if (this.price == 0) this.where.priceOrder = '';
  177. else if (this.price == 1) this.where.priceOrder = 'asc';
  178. else if (this.price == 2) this.where.priceOrder = 'desc';
  179. if (this.stock == 0) this.where.salesOrder = '';
  180. else if (this.stock == 1) this.where.salesOrder = 'asc';
  181. else if (this.stock == 2) this.where.salesOrder = 'desc';
  182. this.where.news = this.nows ? 1 : 0;
  183. },
  184. //查找产品
  185. get_product_list: function(isPage) {
  186. let that = this;
  187. that.setWhere();
  188. if (that.loadend) return;
  189. if (that.loading) return;
  190. if (isPage === true) that.$set(that, 'productList', []);
  191. that.loading = true;
  192. that.loadTitle = '';
  193. getProductslist(that.where).then(res => {
  194. let list = res.data.list;
  195. let productList = that.$util.SplitArray(list, that.productList);
  196. let loadend = list.length < that.where.limit;
  197. that.loadend = loadend;
  198. that.loading = false;
  199. that.loadTitle = loadend ? '已全部加载' : '加载更多';
  200. that.$set(that, 'productList', productList);
  201. that.$set(that.where, 'page', that.where.page + 1);
  202. if (that.productList.length === 0) {
  203. this.get_host_product();
  204. }
  205. }).catch(err => {
  206. that.loading = false;
  207. that.loadTitle = '加载更多';
  208. });
  209. },
  210. },
  211. onReachBottom() {
  212. if (this.productList.length > 0) {
  213. this.get_product_list();
  214. } else {
  215. this.$refs.recommendIndex.get_host_product();
  216. }
  217. }
  218. }
  219. </script>
  220. <style scoped lang="scss">
  221. .bg_color{
  222. @include main_bg_color(theme);
  223. }
  224. .font_color{
  225. @include main_color(theme);
  226. }
  227. .x-money{
  228. @include price_color(theme);
  229. }
  230. .iconfont {
  231. color: #fff;
  232. }
  233. .listBox{
  234. padding: 20px 15px;
  235. margin-top: 154rpx;
  236. }
  237. .productList .search {
  238. width: 100%;
  239. height: 86rpx;
  240. padding-left: 23rpx;
  241. box-sizing: border-box;
  242. position: fixed;
  243. left: 0;
  244. top: 0;
  245. z-index: 9;
  246. }
  247. .productList .search .input {
  248. // width: 640rpx;
  249. height: 60rpx;
  250. background-color: #fff;
  251. border-radius: 50rpx;
  252. padding: 0 20rpx;
  253. box-sizing: border-box;
  254. }
  255. .productList .search .input input {
  256. /* #ifdef H5 */
  257. width: 528rpx;
  258. /* #endif */
  259. /* #ifndef H5 */
  260. width: 548rpx;
  261. /* #endif */
  262. height: 100%;
  263. font-size: 26rpx;
  264. }
  265. .productList .search .input .placeholder {
  266. color: #999;
  267. }
  268. .productList .search .input .iconfont {
  269. font-size: 35rpx;
  270. color: #555;
  271. }
  272. .productList .search .icon-pailie,
  273. .productList .search .icon-tupianpailie {
  274. color: #fff;
  275. width: 62rpx;
  276. font-size: 40rpx;
  277. height: 86rpx;
  278. line-height: 86rpx;
  279. }
  280. .productList .nav {
  281. height: 86rpx;
  282. color: #454545;
  283. position: fixed;
  284. left: 0;
  285. width: 100%;
  286. font-size: 28rpx;
  287. background-color: #fff;
  288. margin-top: 86rpx;
  289. top: 0;
  290. z-index: 9;
  291. }
  292. .productList .nav .item {
  293. width: 25%;
  294. text-align: center;
  295. }
  296. .productList .nav .item.font-color {
  297. font-weight: bold;
  298. }
  299. .productList .nav .item image {
  300. width: 15rpx;
  301. height: 19rpx;
  302. margin-left: 10rpx;
  303. }
  304. .productList .list {
  305. padding: 0 30rpx;
  306. margin-top: 192rpx;
  307. }
  308. .productList .list.on {
  309. border-radius: 14rpx;
  310. margin-top: 0 !important;
  311. background-color: #fff;
  312. padding: 40rpx 0 0 0;
  313. // margin: 20rpx 0;
  314. // background-color: #fff;
  315. }
  316. .productList .list .item {
  317. width: 335rpx;
  318. background-color: #fff;
  319. border-radius: 14rpx;
  320. margin-bottom: 20rpx;
  321. }
  322. .productList .list .item.on {
  323. width: 100%;
  324. display: flex;
  325. padding: 0 24rpx 50rpx 24rpx;
  326. margin: 0;
  327. border-radius: 14rpx;
  328. }
  329. .productList .list .item .pictrue {
  330. position: relative;
  331. width: 100%;
  332. height: 335rpx;
  333. }
  334. .productList .list .item .pictrue.on {
  335. width: 180rpx;
  336. height: 180rpx;
  337. }
  338. .productList .list .item .pictrue image {
  339. width: 100%;
  340. height: 100%;
  341. border-radius: 20rpx 20rpx 0 0;
  342. }
  343. .productList .list .item .pictrue image.on {
  344. border-radius: 6rpx;
  345. }
  346. .productList .list .item .text {
  347. padding: 18rpx 20rpx;
  348. font-size: 30rpx;
  349. color: #222;
  350. }
  351. .productList .list .item .text.on {
  352. width: 456rpx;
  353. padding: 0 0 0 20rpx;
  354. }
  355. .productList .list .item .text .money {
  356. font-size: 26rpx;
  357. font-weight: bold;
  358. margin-top: 8rpx;
  359. }
  360. .productList .list .item .text .money.on {
  361. margin-top: 50rpx;
  362. }
  363. .productList .list .item .text .money .num {
  364. font-size: 34rpx;
  365. }
  366. .productList .list .item .text .vip {
  367. font-size: 22rpx;
  368. color: #aaa;
  369. margin-top: 7rpx;
  370. }
  371. .productList .list .item .text .vip.on {
  372. margin-top: 12rpx;
  373. }
  374. .productList .list .item .text .vip .vip-money {
  375. font-size: 24rpx;
  376. color: #282828;
  377. font-weight: bold;
  378. }
  379. .productList .list .item .text .vip .vip-money image {
  380. width: 46rpx;
  381. height: 21rpx;
  382. margin-left: 4rpx;
  383. }
  384. .noCommodity {
  385. background-color: #fff;
  386. padding-bottom: 30rpx;
  387. margin-top: 172rpx;
  388. }
  389. </style>