commodityList.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525
  1. <template>
  2. <view>
  3. <view class="tui-tabs">
  4. <scroll-view id="tab-bar" scroll-with-animation class="tui-scroll-h" :scroll-x="true"
  5. :show-scrollbar="false" style="border-bottom: 2upx solid #F8F8F8;">
  6. <view style="display: flex;">
  7. <view v-for="(tab, index) in tabBars" :id="tab.id" :data-current="index" @tap='tabSlect(tab)'>
  8. <view class="tui-tab-item-title" style="margin-left: 130upx;"
  9. :class="{ 'tui-tab-item-title-active': tabIndex == tab.id }">{{ tab.name }}</view>
  10. </view>
  11. </view>
  12. </scroll-view>
  13. </view>
  14. <view style="display: flex;flex-wrap: wrap;margin-top: 80upx;">
  15. <view
  16. style="width: 345upx;height: 550upx;background-color: #FFFFFF; border-radius: 20upx;margin:20upx 0 0upx 20upx; padding-bottom: 10upx; box-shadow: rgba(183, 183, 183, 0.3) 1px 1px 10px 1px;"
  17. @tap='goDetail(item.id)' v-for="(item,index) in list" :key='index' v-if="list.length > 0">
  18. <image :src="item.coverImg" lazy-load="true"
  19. style="width: 345upx;height: 340upx;border-top-left-radius:20upx;border-top-right-radius:20upx;">
  20. </image>
  21. <view style="padding: 16upx 2upx 16upx 16upx;">
  22. <view style="width: 100%;height: 60upx;">
  23. <text class="limapboxqing2"><text class="indexr"
  24. style=""><text>自营</text></text>{{ item.title }}</text>
  25. </view>
  26. </view>
  27. <view>
  28. <view style="padding: 0rpx 15rpx;display: flex;margin:60rpx 0">
  29. <view
  30. style="width: 40%;font-size: 38upx;color: #05C25C;font-weight: 700;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;">
  31. ¥{{item.price}}</view>
  32. <view
  33. style="width: 60%;font-size: 24upx;color: #999999;margin-top: 10upx;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;text-align: right;">
  34. {{item.sales}}人已购买</view>
  35. </view>
  36. </view>
  37. </view>
  38. <!-- 悬浮上拉 -->
  39. <view class="scroll_top" @tap="topScrollTap" v-bind:class="[scrollTop ? 'active' : '','']"
  40. style="bottom: 56px;">
  41. <text class="iconfont icon-shangla"></text>
  42. </view>
  43. <!-- 加载更多提示 -->
  44. <view class="s-col is-col-24" v-if="list.length > 0">
  45. <load-more :loadingType="loadingType" :contentText="contentText"></load-more>
  46. </view>
  47. <!-- 加载更多提示 -->
  48. <!-- <empty v-if="list.length === 0" des="暂无数据" show="false"></empty> -->
  49. </view>
  50. </view>
  51. </template>
  52. <script>
  53. export default {
  54. data() {
  55. return {
  56. tabIndex: '0',
  57. tabStatus: 'createAt',
  58. list: [],
  59. relation: false,
  60. isEnable: '否',
  61. //综合createAt 销量sales 佣金比例commissionPrice 超低价price
  62. tabBars: [{
  63. name: '综合',
  64. id: '0',
  65. status: 'createAt'
  66. },
  67. {
  68. name: '销量',
  69. id: '1',
  70. status: 'sales'
  71. },
  72. // {
  73. // name: '佣金',
  74. // id: '2',
  75. // status: 'commissionPrice'
  76. // },
  77. {
  78. name: '超低价',
  79. id: '2',
  80. status: 'price'
  81. }
  82. ],
  83. page: 0,
  84. size: 10,
  85. loadingType: 0,
  86. type: 1,
  87. barTitleName: '',
  88. scrollTop: false,
  89. contentText: {
  90. contentdown: '上拉显示更多',
  91. contentrefresh: '正在加载...',
  92. contentnomore: '没有更多数据了'
  93. }
  94. }
  95. },
  96. onLoad(d) {
  97. let relation_id = this.$queue.getData('relation_id');
  98. if (relation_id && relation_id !== 'undefined') {
  99. this.relation = true;
  100. } else {
  101. this.relation = false;
  102. }
  103. if (d.name) {
  104. this.barTitleName = d.name;
  105. uni.setNavigationBarTitle({
  106. title: d.name
  107. })
  108. if (d.name === '精选好物') {
  109. this.getSelectGoods('', this.tabStatus);
  110. } else if (d.name === '热卖榜单') {
  111. this.getSellingList('', this.tabStatus);
  112. } else if (d.name === '每日上新') {
  113. this.getNews('', this.tabStatus);
  114. } else if (d.name === '推荐商品') {
  115. this.getmrsc('', this.tabStatus);
  116. }
  117. }
  118. },
  119. onShow() {
  120. let a = this.$queue.getData("isEnable")
  121. if (a === '是') {
  122. let b = this.$queue.getData('isLieBiaoEnable');
  123. if (b) {
  124. this.isEnable = b;
  125. } else {
  126. this.isEnable = a;
  127. }
  128. } else {
  129. this.isEnable = a;
  130. }
  131. },
  132. methods: {
  133. getmrsc(type, sort) {
  134. this.loadingType = 1;
  135. uni.showLoading({
  136. title: '加载中...'
  137. });
  138. this.$Request.getT('/app/goods/recommend?page=' + this.page + '&size=' + this.size + '&sort=' + sort).then(
  139. res => {
  140. if (res.status === 0) {
  141. if (this.page === 0 || res.status) {
  142. this.list = [];
  143. }
  144. let grade = this.$queue.getData('grade');
  145. res.data.content.forEach(d => {
  146. d.descrition = '';
  147. // if (d.commissionPrice != 0) {
  148. // if (grade) {
  149. // if (this.relation) {
  150. // d.descrition = ((parseFloat(d.memberPrice) * parseFloat(d
  151. // .commissionPrice)) * parseFloat(grade)).toFixed(
  152. // 2);
  153. // } else {
  154. // d.descrition = ((parseFloat(d.price) * parseFloat(d
  155. // .commissionPrice)) * parseFloat(grade)).toFixed(2);
  156. // }
  157. // } else {
  158. // if (this.relation) {
  159. // d.descrition = ((parseFloat(d.memberPrice) * parseFloat(d
  160. // .commissionPrice)) * parseFloat(this.$queue
  161. // .minMoney()))
  162. // .toFixed(2);
  163. // } else {
  164. // d.descrition = ((parseFloat(d.price) * parseFloat(d
  165. // .commissionPrice)) * parseFloat(this.$queue
  166. // .minMoney()))
  167. // .toFixed(2);
  168. // }
  169. // }
  170. // }
  171. d.sales = d.sales > 10000 ? (d.sales / 10000).toFixed(1) + '万' : d.sales;
  172. this.list.push(d);
  173. });
  174. if (res.data.content.length === this.size) {
  175. this.loadingType = 0;
  176. } else {
  177. this.loadingType = 3;
  178. }
  179. } else {
  180. this.loadingType = 2;
  181. }
  182. uni.hideLoading();
  183. if (type === 'Refresh') {
  184. uni.stopPullDownRefresh(); // 停止刷新
  185. }
  186. });
  187. },
  188. getNews(type, sort) {
  189. this.loadingType = 1;
  190. uni.showLoading({
  191. title: '加载中...'
  192. });
  193. this.$Request.getT('/app/goods/news?page=' + this.page + '&size=' + this.size + '&sort=' + sort).then(res => {
  194. if (res.status === 0) {
  195. if (this.page === 0 || res.status) {
  196. this.list = [];
  197. }
  198. let grade = this.$queue.getData('grade');
  199. res.data.content.forEach(d => {
  200. d.descrition = '';
  201. // if (d.commissionPrice != 0) {
  202. // if (grade) {
  203. // if (this.relation) {
  204. // d.descrition = ((parseFloat(d.memberPrice) * parseFloat(d
  205. // .commissionPrice)) * parseFloat(grade)).toFixed(
  206. // 2);
  207. // } else {
  208. // d.descrition = ((parseFloat(d.price) * parseFloat(d
  209. // .commissionPrice)) * parseFloat(grade)).toFixed(2);
  210. // }
  211. // } else {
  212. // if (this.relation) {
  213. // d.descrition = ((parseFloat(d.memberPrice) * parseFloat(d
  214. // .commissionPrice)) * parseFloat(this.$queue
  215. // .minMoney()))
  216. // .toFixed(2);
  217. // } else {
  218. // d.descrition = ((parseFloat(d.price) * parseFloat(d
  219. // .commissionPrice)) * parseFloat(this.$queue
  220. // .minMoney()))
  221. // .toFixed(2);
  222. // }
  223. // }
  224. // }
  225. this.list.push(d);
  226. });
  227. if (res.data.content.length === this.size) {
  228. this.loadingType = 0;
  229. } else {
  230. this.loadingType = 3;
  231. }
  232. } else {
  233. this.loadingType = 2;
  234. }
  235. uni.hideLoading();
  236. if (type === 'Refresh') {
  237. uni.stopPullDownRefresh(); // 停止刷新
  238. }
  239. });
  240. },
  241. getSelectGoods(type, sort) {
  242. this.loadingType = 1;
  243. uni.showLoading({
  244. title: '加载中...'
  245. });
  246. this.$Request.getT('/app/goods/selectGoods?page=' + this.page + '&size=' + this.size + '&sort=' + sort).then(
  247. res => {
  248. if (res.status === 0) {
  249. if (this.page === 0 || res.status) {
  250. this.list = [];
  251. }
  252. let grade = this.$queue.getData('grade');
  253. res.data.content.forEach(d => {
  254. d.descrition = '';
  255. // if (d.commissionPrice != 0) {
  256. // if (grade) {
  257. // if (this.relation) {
  258. // d.descrition = ((parseFloat(d.memberPrice) * parseFloat(d
  259. // .commissionPrice)) * parseFloat(grade)).toFixed(
  260. // 2);
  261. // } else {
  262. // d.descrition = ((parseFloat(d.price) * parseFloat(d
  263. // .commissionPrice)) * parseFloat(grade)).toFixed(2);
  264. // }
  265. // } else {
  266. // if (this.relation) {
  267. // d.descrition = ((parseFloat(d.memberPrice) * parseFloat(d
  268. // .commissionPrice)) * parseFloat(this.$queue
  269. // .minMoney()))
  270. // .toFixed(2);
  271. // } else {
  272. // d.descrition = ((parseFloat(d.price) * parseFloat(d
  273. // .commissionPrice)) * parseFloat(this.$queue
  274. // .minMoney()))
  275. // .toFixed(2);
  276. // }
  277. // }
  278. // }
  279. this.list.push(d);
  280. });
  281. if (res.data.content.length === this.size) {
  282. this.loadingType = 0;
  283. } else {
  284. this.loadingType = 3;
  285. }
  286. } else {
  287. this.loadingType = 2;
  288. }
  289. uni.hideLoading();
  290. if (type === 'Refresh') {
  291. uni.stopPullDownRefresh(); // 停止刷新
  292. }
  293. });
  294. },
  295. getSellingList(type, sort) {
  296. this.loadingType = 1;
  297. uni.showLoading({
  298. title: '加载中...'
  299. });
  300. this.$Request.getT('/app/goods/selling?page=' + this.page + '&size=' + this.size + '&sort=' + sort).then(
  301. res => {
  302. if (res.status === 0) {
  303. if (this.page === 0 || res.status) {
  304. this.list = [];
  305. }
  306. let grade = this.$queue.getData('grade');
  307. res.data.content.forEach(d => {
  308. d.descrition = '';
  309. // if (d.commissionPrice != 0) {
  310. // if (grade) {
  311. // if (this.relation) {
  312. // d.descrition = ((parseFloat(d.memberPrice) * parseFloat(d
  313. // .commissionPrice)) * parseFloat(grade)).toFixed(
  314. // 2);
  315. // } else {
  316. // d.descrition = ((parseFloat(d.price) * parseFloat(d
  317. // .commissionPrice)) * parseFloat(grade)).toFixed(2);
  318. // }
  319. // } else {
  320. // if (this.relation) {
  321. // d.descrition = ((parseFloat(d.memberPrice) * parseFloat(d
  322. // .commissionPrice)) * parseFloat(this.$queue
  323. // .minMoney()))
  324. // .toFixed(2);
  325. // } else {
  326. // d.descrition = ((parseFloat(d.price) * parseFloat(d
  327. // .commissionPrice)) * parseFloat(this.$queue
  328. // .minMoney()))
  329. // .toFixed(2);
  330. // }
  331. // }
  332. // }
  333. this.list.push(d);
  334. });
  335. if (res.data.content.length === this.size) {
  336. this.loadingType = 0;
  337. } else {
  338. this.loadingType = 3;
  339. }
  340. } else {
  341. this.loadingType = 2;
  342. }
  343. uni.hideLoading();
  344. if (type === 'Refresh') {
  345. uni.stopPullDownRefresh(); // 停止刷新
  346. }
  347. });
  348. },
  349. getList() {
  350. this.$Request.getT('/app/goods/list?page=' + this.page + '&size=' + this.size + '&status=' + 1).then(res => {
  351. if (res.status === 0) {
  352. if (this.page === 0 || res.status) {
  353. this.list = [];
  354. }
  355. res.data.content.forEach(d => {
  356. this.list.push(d);
  357. });
  358. }
  359. });
  360. },
  361. goDetail(id) {
  362. uni.navigateTo({
  363. url: './commoditydetail?ordersId=' + id
  364. });
  365. },
  366. tabSlect(item) {
  367. this.switchTab(item.id);
  368. },
  369. switchTab(index) {
  370. this.page = 0;
  371. this.tabIndex = index;
  372. this.tabStatus = this.tabBars[index].status;
  373. this.list = [];
  374. this.getList1('switch', this.tabStatus);
  375. },
  376. topScrollTap: function() {
  377. uni.pageScrollTo({
  378. scrollTop: 0,
  379. duration: 300
  380. });
  381. },
  382. getList1(type, sort) {
  383. if (this.barTitleName === '精选好物') {
  384. this.getSelectGoods(type, sort);
  385. } else if (this.barTitleName === '热卖榜单') {
  386. this.getSellingList(type, sort);
  387. } else if (this.barTitleName === '每日上新') {
  388. this.getNews(type, sort);
  389. } else if (this.barTitleName === '推荐商品') {
  390. this.getmrsc('', this.tabStatus);
  391. }
  392. }
  393. },
  394. onPageScroll: function(e) {
  395. this.scrollTop = e.scrollTop > 200;
  396. },
  397. onReachBottom: function() {
  398. this.page = this.page + 1;
  399. this.getList1('', this.tabStatus);
  400. },
  401. onPullDownRefresh: function() {
  402. this.page = 0;
  403. this.getList1('Refresh', this.tabStatus);
  404. }
  405. }
  406. </script>
  407. <style lang="less">
  408. @import '../../../../static/less/index.less';
  409. @import '../../../../static/css/index.css';
  410. page {
  411. background: #F8F8F8;
  412. }
  413. .limapboxqing2 {
  414. font-size: 28upx;
  415. color: #333333;
  416. overflow: hidden;
  417. text-overflow: ellipsis;
  418. display: -webkit-box;
  419. -webkit-line-clamp: 2;
  420. -webkit-box-orient: vertical;
  421. }
  422. .indexr {
  423. color: #FFFFFF;
  424. background: #05C25C;
  425. font-size: 22upx;
  426. padding-left: 12upx;
  427. display: inline-block;
  428. padding-right: 13upx;
  429. border-radius: 8upx;
  430. margin-right: 8upx;
  431. padding-top: 4upx;
  432. padding-bottom: 2upx;
  433. }
  434. .tui-tabs {
  435. flex: 1;
  436. flex-direction: column;
  437. overflow: hidden;
  438. background-color: #fafafa;
  439. /* #ifdef MP-ALIPAY || MP-BAIDU */
  440. height: 100vh;
  441. /* #endif */
  442. }
  443. .tui-scroll-h {
  444. width: 750rpx;
  445. height: 80rpx;
  446. background-color: #ffffff;
  447. flex-direction: row;
  448. /* #ifndef H5 */
  449. position: fixed;
  450. top: 0;
  451. left: 0;
  452. z-index: 999;
  453. /* #endif */
  454. /* #ifndef APP-PLUS */
  455. white-space: nowrap;
  456. /* #endif */
  457. /* #ifdef H5 */
  458. position: fixed;
  459. top: 44px;
  460. left: 0;
  461. z-index: 999;
  462. /* #endif */
  463. }
  464. .tui-line-h {
  465. /* #ifdef APP-PLUS */
  466. height: 1rpx;
  467. background-color: #cccccc;
  468. /* #endif */
  469. position: relative;
  470. }
  471. /* #ifndef APP-PLUS*/
  472. .tui-line-h::after {
  473. content: '';
  474. position: absolute;
  475. border-bottom: 1rpx solid #cccccc;
  476. -webkit-transform: scaleY(0.5);
  477. transform: scaleY(0.5);
  478. bottom: 0;
  479. right: 0;
  480. left: 0;
  481. }
  482. /* #endif */
  483. .tui-tab-item {
  484. /* #ifndef APP-PLUS */
  485. display: flex;
  486. /* #endif */
  487. // flex-wrap: nowrap;
  488. // padding-left: 34rpx;
  489. // padding-right: 34rpx;
  490. }
  491. .tui-tab-item-title {
  492. color: #555;
  493. font-size: 30rpx;
  494. height: 80rpx;
  495. line-height: 80rpx;
  496. flex-wrap: nowrap;
  497. /* #ifndef APP-PLUS */
  498. white-space: nowrap;
  499. /* #endif */
  500. }
  501. .tui-tab-item-title-active {
  502. color: #05C25C;
  503. font-size: 32upx;
  504. font-weight: bold;
  505. border-bottom-width: 6upx;
  506. text-align: center;
  507. }
  508. </style>