index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  1. <template>
  2. <app-layout :haveBackground="false">
  3. <view class="index-nav" v-if="nav_list.length > 0">
  4. <view class="app-index-nav dir-left-nowrap cross-center">
  5. <view class="app-search">
  6. <app-jump-button form open_type="navigate" url="/pages/search/search?sign=wholesale">
  7. <view class="app-icon"></view>
  8. </app-jump-button>
  9. </view>
  10. <view class="app-line"></view>
  11. <scroll-view :scroll-into-view="`scroll-${activeIndex}`" scroll-with-animation scroll-x class="app-scroll">
  12. <text class="app-item" :id="`scroll-${index}`" v-for="(item, index) in nav_list"
  13. :key="item.id"
  14. :style="{'background': cat_id == item.id && getTheme.key !== 'a' ? getTheme.background : ''}"
  15. :class="cat_id == item.id ? 'app-active-item default-item' : ''"
  16. @click="changeStatus(item.id, index)"
  17. >{{item.name}}</text>
  18. </scroll-view>
  19. </view>
  20. <view class="banner">
  21. <image :src="banner"></image>
  22. </view>
  23. </view>
  24. <view class="goods-style-one">
  25. <u-ordinary-list :theme="getTheme" :pagination="true" :isUnderLinePrice="false" v-if="list.length > 0 || first" buyBtn="text" :borderShow="1" :buyBtnStyle="3" buyBtnText="立即抢购" :list="list" :list-style="-1" :isBuy="false"></u-ordinary-list>
  26. </view>
  27. <view class="no-list" v-if="!loading && list.length === 0">
  28. <app-no-goods background="#f7f7f7"></app-no-goods>
  29. </view>
  30. </app-layout>
  31. </template>
  32. <script>
  33. import { mapState,mapGetters } from "vuex";
  34. import uOrdinaryList from '../../../components/page-component/u-goods-list/u-ordinary-list.vue';
  35. import appNoGoods from '../../../components/page-component/app-no-goods/app-no-goods.vue';
  36. export default {
  37. data() {
  38. return {
  39. list: [],
  40. nav_list: [],
  41. cat_id: -1,
  42. more: false,
  43. loading: false,
  44. first: false,
  45. page: 1,
  46. activityBg: '',
  47. banner: '',
  48. activeIndex: 0,
  49. style: -1
  50. }
  51. },
  52. components: {uOrdinaryList,appNoGoods},
  53. computed: {
  54. ...mapState({
  55. userInfo: state => state.user.info,
  56. compositionImg: state => state.mallConfig.__wxapp_img.composition
  57. }),
  58. ...mapGetters('mallConfig', {
  59. getTheme: 'getTheme',
  60. }),
  61. },
  62. onReachBottom() {
  63. if(this.more) {
  64. this.getMore();
  65. }
  66. },
  67. methods: {
  68. requestCats(cat_id) {
  69. this.$request({
  70. url: this.$api.wholesale.cats
  71. }).then(res => {
  72. if (res.code === 0) {
  73. this.nav_list = this.nav_list.concat(res.data.list);
  74. !cat_id && (this.cat_id = this.nav_list[0].id);
  75. this.getList(0);
  76. }
  77. });
  78. },
  79. changeStatus(id, index) {
  80. this.cat_id = id;
  81. this.page = 1;
  82. if(index < 2) {
  83. this.activeIndex = 0
  84. }else {
  85. this.activeIndex = index - 1
  86. }
  87. uni.showLoading({
  88. mask: true,
  89. title: '加载中...'
  90. });
  91. this.getList(id);
  92. },
  93. inputBlur() {
  94. let that = this;
  95. setTimeout(v => {
  96. that.getFocus = false;
  97. that.getList();
  98. }, 300)
  99. },
  100. tabShow() {
  101. this.style = this.style == 1 ? 4 : 1
  102. },
  103. jump(data) {
  104. uni.navigateTo({
  105. url: data.page_url
  106. });
  107. },
  108. getMore() {
  109. this.more = false;
  110. this.loading = true;
  111. uni.showLoading({
  112. mask: true,
  113. title: '加载更多...'
  114. });
  115. this.$request({
  116. url: this.$api.wholesale.index,
  117. data: {
  118. cat_id: this.cat_id,
  119. page: this.page
  120. }
  121. }).then(response=>{
  122. this.$hideLoading();
  123. uni.hideLoading();
  124. if(response.code === 0) {
  125. this.list = this.list.concat(response.data.list);
  126. this.loading = false;
  127. if(response.data.list.length == response.data.pagination.pageSize) {
  128. this.more = true;
  129. this.page++;
  130. }
  131. }else {
  132. uni.showToast({
  133. title: response.msg,
  134. icon: 'none',
  135. duration: 1000
  136. });
  137. }
  138. }).catch(() => {
  139. this.$hideLoading();
  140. });
  141. },
  142. getList(id) {
  143. this.more = false;
  144. this.loading = true;
  145. this.list = [];
  146. this.$request({
  147. url: this.$api.wholesale.index,
  148. data: {
  149. cat_id: id
  150. }
  151. }).then(response=>{
  152. this.first = false;
  153. this.$hideLoading();
  154. uni.hideLoading();
  155. if(response.code === 0) {
  156. this.list = response.data.list;
  157. this.banner = response.data.banner;
  158. this.loading = false;
  159. this.$forceUpdate();
  160. if(this.list.length == response.data.pagination.pageSize) {
  161. this.more = true;
  162. this.page++;
  163. }
  164. }else {
  165. uni.showToast({
  166. title: response.msg,
  167. icon: 'none',
  168. duration: 1000
  169. });
  170. }
  171. }).catch(() => {
  172. this.$hideLoading();
  173. });
  174. },
  175. },
  176. onLoad(option) { this.$commonLoad.onload(option);
  177. let that = this;
  178. that.$showLoading({
  179. type: 'global',
  180. text: '加载中...'
  181. });
  182. that.first = true;
  183. that.requestCats(option.cat_id);
  184. }
  185. }
  186. </script>
  187. <style scoped lang="scss">
  188. .index-nav {
  189. width: #{750rpx};
  190. height: #{348rpx};
  191. .app-index-nav {
  192. height: #{92rpx};
  193. background-color: white;
  194. width: #{750rpx};
  195. position: fixed;
  196. top: 0;
  197. left: 0;
  198. z-index: 1000;
  199. .app-search {
  200. width: #{108rpx};
  201. height: #{92rpx};
  202. .app-icon {
  203. width: #{60rpx};
  204. height: #{60rpx};
  205. background-image: url("../image/big-sarch.png");
  206. background-size: 100% 100%;
  207. background-repeat: no-repeat;
  208. }
  209. }
  210. .app-line {
  211. width: #{1rpx};
  212. height: #{40rpx};
  213. background-color: #e2e2e2;
  214. }
  215. .app-scroll {
  216. width: #{641rpx};
  217. height: #{92rpx};
  218. white-space: nowrap;
  219. padding-left: #{18rpx};
  220. .app-item {
  221. display: inline-block;
  222. font-size: #{28rpx};
  223. color: #666666;
  224. padding: 0 #{24rpx};
  225. box-sizing: border-box;
  226. height: #{56rpx};
  227. line-height: #{56rpx};
  228. border-radius: #{28rpx};
  229. margin: #{18rpx} #{32rpx};
  230. }
  231. .app-active-item {
  232. color: white;
  233. }
  234. .default-item {
  235. background: linear-gradient(140deg, #ffa360, #ff5c5c);
  236. }
  237. }
  238. }
  239. .banner {
  240. position: fixed;
  241. top: #{92rpx};
  242. left: 0;
  243. height: #{280rpx};
  244. width: 100%;
  245. z-index: 1000;
  246. image {
  247. width: 100%;
  248. height: #{280rpx};
  249. }
  250. }
  251. }
  252. .nav-area {
  253. height: 386rpx;
  254. position: fixed;
  255. top: 0;
  256. left: 0;
  257. width: 100%;
  258. z-index: 22;
  259. background-color: #fff;
  260. font-size: #{26rpx};
  261. .search-view {
  262. margin: 20rpx auto;
  263. width: #{702rpx};
  264. height: #{66rpx};
  265. background-color: #F7F7F7;
  266. border-radius: #{33rpx};
  267. .icon {
  268. width: #{20rpx};
  269. height: #{20rpx};
  270. margin-right: #{11rpx};
  271. }
  272. .text {
  273. color: #999999;
  274. }
  275. input {
  276. width: #{702rpx};
  277. height: #{66rpx};
  278. border-radius: #{28rpx};
  279. padding: #{0 70rpx 0 30rpx};
  280. box-sizing: border-box;
  281. font-size: #{26rpx};
  282. }
  283. .search-clear {
  284. position: absolute;
  285. right: #{15rpx};
  286. top: #{19rpx};
  287. width: #{30rpx};
  288. height: #{30rpx};
  289. z-index: 300;
  290. }
  291. }
  292. .banner {
  293. height: #{280rpx};
  294. width: 100%;
  295. image {
  296. width: 100%;
  297. height: #{280rpx};
  298. }
  299. }
  300. }
  301. .no-list {
  302. position: absolute;
  303. top: #{348rpx};
  304. left: 0;
  305. width: 100%;
  306. height: 100%;
  307. z-index: 50;
  308. background-color: #f7f7f7;
  309. }
  310. </style>