list.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344
  1. <template>
  2. <view class="container">
  3. <view class="dataList">
  4. <scroll-view class="navscroll" scroll-y="true">
  5. <view class="nav acea-row row-middle">
  6. <block v-for="(item, index) in cateList" :key="index">
  7. <view :class="'item ' + (cid==item.id ? 'font-color':'')" @tap="set_where"
  8. :data-cid="item.id">{{item.title}}</view>
  9. </block>
  10. </view>
  11. </scroll-view>
  12. <view class="list acea-row row-between-wrapper on">
  13. <navigator v-for="(item, index) in dataList" :key="index" class="item on"
  14. hover-class="none" :url="'/pages/article/detail?id=' + item.id">
  15. <view class="text on">
  16. <view class="name line1">{{item.title}}</view>
  17. </view>
  18. </navigator>
  19. <view class="loadingicon acea-row row-center-wrapper" v-if="dataList.length > 0">
  20. <text class="loading iconfont icon-jiazai" :hidden="loading==false"></text>
  21. </view>
  22. </view>
  23. </view>
  24. <tui-tabbar :current="current">
  25. </tui-tabbar>
  26. </view>
  27. </template>
  28. <script>
  29. var app = getApp();
  30. export default {
  31. data() {
  32. return {
  33. current: '',
  34. cateList: [],
  35. dataList: [],
  36. navH: "",
  37. where: {
  38. cid: 0,
  39. keyword: '',
  40. priceOrder: '',
  41. salesOrder: '',
  42. news: 0,
  43. page: 1,
  44. limit: 10,
  45. cid: 0
  46. },
  47. price: 0,
  48. stock: 0,
  49. nows: false,
  50. loadend: false,
  51. loading: false,
  52. bottommenulist: [],
  53. host_product: "",
  54. title: "",
  55. cid: ""
  56. };
  57. },
  58. components: {},
  59. props: {},
  60. /**
  61. * 生命周期函数--监听页面加载
  62. */
  63. onLoad: function(options) {
  64. this.cid = options.cid || ''
  65. const _this = this; //位置授权
  66. // #ifdef MP-WEIXIN
  67. this.current = "/" + this.__route__;
  68. // #endif
  69. //#ifdef H5
  70. this.current = this.$route.path;
  71. //#endif
  72. this.get_cate_list();
  73. this.get_data_list();
  74. },
  75. /**
  76. * 生命周期函数--监听页面显示
  77. */
  78. onShow: function() {},
  79. /**
  80. * 页面相关事件处理函数--监听用户下拉动作
  81. */
  82. onPullDownRefresh: function() {
  83. this.where.page = 1;
  84. this.loadend = false;
  85. this.dataList = [];
  86. this.get_data_list();
  87. uni.stopPullDownRefresh();
  88. },
  89. /**
  90. * 页面上拉触底事件的处理函数
  91. */
  92. onReachBottom: function() {
  93. this.get_data_list();
  94. },
  95. methods: {
  96. //点击事件处理
  97. set_where: function(e) {
  98. var dataset = e.target.dataset;
  99. this.cid = dataset.cid;
  100. this.loadend = false;
  101. this.where.page = 1;
  102. this.get_data_list(true);
  103. },
  104. //设置where条件
  105. setWhere: function() {
  106. this.where.salesOrder = 'asc';
  107. if (this.cid) {
  108. this.where.cid = this.cid;
  109. }
  110. },
  111. get_cate_list: function() {
  112. var that = this;
  113. that.$request.get('articlecategory.list').then(res => {
  114. var cateList = res.data;
  115. that.cateList = cateList;
  116. });
  117. },
  118. get_data_list: function(isPage) {
  119. var that = this;
  120. this.setWhere();
  121. if (that.loadend) return;
  122. if (that.loading) return;
  123. if (isPage === true)
  124. {
  125. that.dataList = [];
  126. that.where.page =1;
  127. }
  128. that.where.showLoading = true;
  129. //console.log(that.where);
  130. that.$request.post('article.list', that.where).then(res => {
  131. var dataList = res.data;
  132. var loadend = dataList.length < that.where.limit;
  133. that.where.page = that.where.page + 1;
  134. that.loadend = loadend;
  135. that.loading = false;
  136. that.dataList = dataList;
  137. });
  138. }
  139. }
  140. };
  141. </script>
  142. <style>
  143. page {
  144. font-size: 28rpx;
  145. background-color: #f5f5f5;
  146. color: #333;
  147. }
  148. .dataList .search {
  149. width: 100%;
  150. height: 86rpx;
  151. padding-left: 23rpx;
  152. box-sizing: border-box;
  153. position: fixed;
  154. display: flex;
  155. left: 0;
  156. }
  157. .dataList .bg-color {
  158. background-color: #e41f19;
  159. }
  160. .dataList .search .input {
  161. flex: 1;
  162. display: flex;
  163. width: 570rpx;
  164. height: 60rpx;
  165. background-color: #fff;
  166. border-radius: 50rpx;
  167. padding: 0 20rpx;
  168. box-sizing: border-box;
  169. }
  170. .dataList .search .input input {
  171. width: 478rpx;
  172. height: 100%;
  173. font-size: 26rpx;
  174. }
  175. .dataList .search .input .placeholder {
  176. color: #999;
  177. }
  178. .dataList .search .input .iconfont {
  179. font-size: 35rpx;
  180. color: #555;
  181. }
  182. .dataList .search .icon-pailie,
  183. .dataList .search .icon-tupianpailie {
  184. color: #fff;
  185. width: 62rpx;
  186. font-size: 40rpx;
  187. height: 86rpx;
  188. line-height: 86rpx;
  189. }
  190. .navscroll {
  191. height: 86rpx;
  192. position: fixed;
  193. display: flex;
  194. white-space: nowrap;
  195. left: 0;
  196. }
  197. .dataList .nav {
  198. width: 1000rpx;
  199. display: flex;
  200. color: #454545;
  201. font-size: 28rpx;
  202. background-color: #fff;
  203. }
  204. .dataList .nav .item {
  205. text-align: center;
  206. height: 100%;
  207. margin: 25rpx;
  208. }
  209. .dataList .nav .item.font-color {
  210. font-weight: bold;
  211. }
  212. .dataList .nav .item image {
  213. width: 15rpx;
  214. height: 19rpx;
  215. margin-left: 10rpx;
  216. }
  217. .dataList .list {
  218. padding: 0 20rpx;
  219. padding-top: 80rpx;
  220. margin-top: 6rpx;
  221. }
  222. .dataList .list.on {
  223. background-color: #fff;
  224. border-top: 1px solid #f6f6f6;
  225. }
  226. .dataList .list .item {
  227. width: 345rpx;
  228. margin-top: 20rpx;
  229. background-color: #fff;
  230. border-radius: 10rpx;
  231. }
  232. .dataList .list .item.on {
  233. width: 100%;
  234. display: flex;
  235. border-bottom: 1rpx solid #f6f6f6;
  236. padding: 30rpx 0;
  237. margin: 0;
  238. }
  239. .dataList .list .item .pictrue {
  240. width: 100%;
  241. height: 345rpx;
  242. }
  243. .dataList .list .item .pictrue.on {
  244. width: 180rpx;
  245. height: 180rpx;
  246. }
  247. .dataList .list .item .pictrue image {
  248. width: 100%;
  249. height: 100%;
  250. border-radius: 10rpx 10rpx 0 0;
  251. }
  252. .dataList .list .item .pictrue image.on {
  253. border-radius: 6rpx;
  254. }
  255. .dataList .list .item .text {
  256. padding: 20rpx 17rpx 26rpx 17rpx;
  257. font-size: 28rpx;
  258. color: #373333;
  259. }
  260. .dataList .list .item .text.on {
  261. width: 508rpx;
  262. padding: 0 0 0 22rpx;
  263. }
  264. .dataList .list .item .text .money {
  265. font-size: 23rpx;
  266. margin-top: 8rpx;
  267. }
  268. .dataList .list .item .text .money.on {
  269. margin-top: 50rpx;
  270. }
  271. .dataList .list .item .text .money .num {
  272. font-size: 32rpx;
  273. }
  274. .dataList .list .item .text .vip {
  275. font-size: 22rpx;
  276. color: #aaa;
  277. margin-top: 7rpx;
  278. }
  279. .dataList .list .item .text .vip.on {
  280. margin-top: 12rpx;
  281. }
  282. .dataList .list .item .text .vip .vip-money {
  283. font-size: 24rpx;
  284. color: #282828;
  285. font-weight: bold;
  286. }
  287. .dataList .list .item .text .vip .vip-money image {
  288. width: 46rpx;
  289. height: 21rpx;
  290. margin-left: 4rpx;
  291. }
  292. .noCommodity {
  293. background-color: #fff;
  294. }
  295. .store-star {
  296. margin-top: 10rpx;
  297. }
  298. .store-star image {
  299. width: 28rpx;
  300. height: 28rpx;
  301. }
  302. </style>