list.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. <template>
  2. <app-layout>
  3. <view class="sort-rule">
  4. <app-sort-rule @sort="setSort" :theme="getTheme" @setStyle="setStyle"></app-sort-rule>
  5. </view>
  6. <view class="product-list" v-if="goods_list.length > 0">
  7. <app-product-list :isShowAttr="false" :theme="getTheme" @routeGo="routeGo" :listStyle="listStyle" :goods_list="goods_list"></app-product-list>
  8. </view>
  9. <view class="u-loading-list" v-show="loading">加载中...</view>
  10. <view class="no-goods dir-left-nowrap cross-center main-center" v-if="noGoods">
  11. <view class="symbol"></view>
  12. <view class="u-no-icon"></view>
  13. <text class="u-text">暂无更多商品</text>
  14. <view class="symbol"></view>
  15. </view>
  16. <view class="app-no-goods" v-if="goods_list.length === 0 && !first_req">
  17. <app-no-goods background="#f7f7f7"></app-no-goods>
  18. </view>
  19. <view class="quick-box dir-top-nowrap" :style="{bottom: tabbarbool ? '180rpx' : '40rpx'}">
  20. <app-jump-button url="/pages/cart/cart" open_type="redirect" v-if="isShowCartFly == 1">
  21. <image class="quick-btn" src="https://shop.9026.com/web/statics/img/mall/goods/goods-list-card.png"></image>
  22. </app-jump-button>
  23. <app-jump-button v-if="isShowScoreTop == 1">
  24. <image @click="backTop" class="quick-btn" src="https://shop.9026.com/web/statics/img/mall/goods/back-top.png"></image>
  25. </app-jump-button>
  26. </view>
  27. </app-layout>
  28. </template>
  29. <script>
  30. import {mapGetters, mapState} from 'vuex';
  31. import appProductList from '../../components/page-component/app-product-list/app-product-list.vue';
  32. import appSortRule from '../../components/page-component/app-sort-rule/app-sort-rule.vue';
  33. import appNoGoods from '../../components/page-component/app-no-goods/app-no-goods.vue';
  34. export default {
  35. name: "list",
  36. data() {
  37. return {
  38. goods_list: [],
  39. page_count: 1,
  40. coupon_id: 0,
  41. page: 1,
  42. cat_id: 0,
  43. sort: 1,
  44. sort_type: 1,
  45. first_req: true,
  46. listStyle: false,
  47. noGoods: false,
  48. loading: false,
  49. sign: '',
  50. mch_id:'',
  51. dk_estate_id: 0,
  52. }
  53. },
  54. onLoad(options) { this.$commonLoad.onload(options);
  55. if(options.cat_id > 0) {
  56. this.cat_id = options.cat_id;
  57. }
  58. 'mch_id' in options ?this.mch_id=options.mch_id:''
  59. if(options.coupon_id > 0) {
  60. this.coupon_id = options.coupon_id
  61. }
  62. if(uni.getStorageSync('dk_estate_id')){
  63. this.dk_estate_id = uni.getStorageSync('dk_estate_id');
  64. }else{
  65. this.dk_estate_id = 0;
  66. }
  67. this.sign = options.sign ? options.sign : '';
  68. this.request().then(() => {
  69. this.first_req = false;
  70. if (this.page < this.page_count) {
  71. this.loading = true;
  72. }
  73. });
  74. },
  75. computed: {
  76. ...mapGetters('mallConfig', {
  77. getVideo: 'getVideo',
  78. getTheme: 'getTheme',
  79. }),
  80. ...mapState({
  81. isShowCartFly: state => state.mallConfig.mall.setting.is_show_cart_fly,
  82. isShowScoreTop: state => state.mallConfig.mall.setting.is_show_score_top,
  83. platform: function(state) {
  84. return state.gConfig.systemInfo.platform;
  85. }
  86. })
  87. },
  88. onReachBottom() {
  89. if (this.page < this.page_count) {
  90. this.page++;
  91. this.noGoods = false;
  92. this.request();
  93. } else {
  94. this.loading = false;
  95. this.noGoods = true;
  96. }
  97. },
  98. methods: {
  99. routeGo(e) {
  100. if (e.video_url && this.getVideo == 1) {
  101. // #ifdef MP
  102. uni.navigateTo({
  103. url: `/pages/goods/video?goods_id=${e.id}`
  104. });
  105. // #endif
  106. // #ifdef H5
  107. uni.navigateTo({
  108. url: e.page_url
  109. });
  110. // #endif
  111. } else {
  112. uni.navigateTo({
  113. url: e.page_url
  114. });
  115. }
  116. },
  117. // 数据请求
  118. async request(status) {
  119. const res = await this.$request({
  120. url: this.$api.default.goods_list,
  121. method: 'get',
  122. data: {
  123. page: this.page,
  124. cat_id: this.cat_id,
  125. sort: this.sort,
  126. sort_type: this.sort_type,
  127. keyword: '',
  128. coupon_id: this.coupon_id,
  129. sign: this.sign,
  130. mch_id:this.mch_id,
  131. estate_id: this.dk_estate_id,
  132. }
  133. });
  134. if (res.code === 0) {
  135. this.page_count = res.data.pagination.page_count;
  136. if (status === 0) {
  137. this.goods_list= res.data.list;
  138. } else {
  139. this.goods_list.push(...res.data.list);
  140. }
  141. if (this.page === 1 && this.page_count === 1) {
  142. this.noGoods = true;
  143. }
  144. } else {
  145. uni.showModal({
  146. title: '提示',
  147. content: res.msg,
  148. })
  149. }
  150. },
  151. setSort({data, type}) {
  152. this.first_req = true;
  153. this.sort = data;
  154. this.page = 1;
  155. this.sort_type = type;
  156. this.goods_list=[];
  157. this.request(0).then(() => {
  158. this.first_req = false;
  159. this.backTop();
  160. if (this.page_count > 1) {
  161. this.loading = true;
  162. } else {
  163. this.loading = false;
  164. }
  165. });
  166. },
  167. backTop() {
  168. uni.pageScrollTo({
  169. scrollTop: 0,
  170. duration: 300
  171. });
  172. },
  173. setStyle(data) {
  174. this.listStyle = data;
  175. },
  176. splitData() {
  177. if (!this.compList.length) return;
  178. this.goods_list.push.apply(this.goods_list, this.compList.splice(0, 10));
  179. if (this.compList.length) {
  180. this.compTime = setTimeout(() => {
  181. this.splitData();
  182. }, 200);
  183. }
  184. }
  185. },
  186. components: {
  187. 'app-product-list': appProductList,
  188. 'app-sort-rule': appSortRule,
  189. 'app-no-goods': appNoGoods,
  190. },
  191. // #ifdef MP
  192. onShareAppMessage() {
  193. return this.$shareAppMessage({
  194. path: '/pages/goods/list',
  195. params: {
  196. cat_id: this.cat_id,
  197. }
  198. });
  199. }
  200. // #endif
  201. }
  202. </script>
  203. <style scoped lang="scss">
  204. .sort-rule {
  205. width: #{750upx};
  206. position: fixed;
  207. top: 0;
  208. left: 0;
  209. z-index: 1500;
  210. }
  211. .product-list {
  212. margin-top: #{188upx};
  213. }
  214. .quick-box {
  215. position: fixed;
  216. bottom: #{40rpx};
  217. right: #{48rpx};
  218. z-index: 100;
  219. }
  220. .quick-btn {
  221. width: #{80rpx};
  222. height: #{80rpx};
  223. margin-top: #{32rpx};
  224. }
  225. .app-no-goods {
  226. margin-top: 200upx;
  227. }
  228. .no-goods {
  229. width: 750upx;
  230. margin: 20upx 0;
  231. }
  232. .u-no-icon {
  233. width: 18upx;
  234. height: 20upx;
  235. background-image: url("https://shop.9026.com/web/statics/img/mall/goods/no.png");
  236. background-repeat: no-repeat;
  237. background-size: 100% 100%;
  238. margin: 0 10upx 0 15upx;
  239. }
  240. .symbol {
  241. width: 30upx;
  242. height: 2upx;
  243. background-color: #d2d2d2;
  244. }
  245. .u-text {
  246. font-size: 24upx;
  247. color: #b0b0b0;
  248. margin-right: 15upx;
  249. }
  250. .u-loading-list {
  251. height: 64upx;
  252. line-height: 64upx;
  253. text-align: center;
  254. color: #b0b0b0;
  255. font-size: 24upx;
  256. }
  257. </style>