jf.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387
  1. <template>
  2. <view class="content">
  3. <view class="dddd" style="height: 10rpx;"></view>
  4. <view class="hotgoods">
  5. <view class="hotgoods-item" v-for="bditem in list" :key="bditem.id"
  6. @click="navto('/pages/product/product?id=' + bditem.id + '&isjf=1')" style="height: 520rpx;">
  7. <view class="image-wrapper">
  8. <image class="image" :src="bditem.image" mode="scaleToFill"></image>
  9. </view>
  10. <view class="flex" style="flex-direction: column;justify-content: space-between;align-items: flex-start;height: 170rpx;">
  11. <view class="title clamp2">{{bditem.store_name}}</view>
  12. <view class="hot-price">
  13. <view class="price">
  14. <text class="font-size-sm"></text>
  15. <text>{{ bditem.integral * 1 }}积分</text>
  16. <!-- <text class="give-jf" v-if="bditem.give_consumption*1">赠{{bditem.give_consumption*1}}消费余额</text> -->
  17. <text class="ot-pirce">¥{{bditem.ot_price}}</text>
  18. </view>
  19. </view>
  20. </view>
  21. </view>
  22. </view>
  23. <uni-load-more :status="loadingType"></uni-load-more>
  24. </view>
  25. </template>
  26. <script>
  27. import { getCategoryList,getProducts } from '@/api/product.js';
  28. export default {
  29. data() {
  30. return {
  31. sizeCalcState: false,
  32. tabScrollTop: 0,
  33. currentId: 9,
  34. flist: [],
  35. height: '',
  36. currentIndex: 0,
  37. list: [],
  38. page: 1,
  39. limit: 20,
  40. loadingType: 'more',
  41. loaded: false,
  42. };
  43. },
  44. onLoad() {
  45. this.loadData();
  46. },
  47. // 监听导航栏输入框点击事件
  48. onNavigationBarSearchInputClicked(e) {
  49. uni.navigateTo({
  50. url: '/pages/product/search'
  51. });
  52. },
  53. onReady(res) {
  54. },
  55. onReachBottom() {
  56. this.getProducts()
  57. },
  58. methods: {
  59. leftClick(index) {
  60. this.currentIndex = index
  61. this.getProducts('reload')
  62. },
  63. getProducts(type) {
  64. if(type == 'reload') {
  65. this.list = []
  66. this.page = 1
  67. this.loadingType = 'more'
  68. this.loaded = false
  69. }
  70. if(this.loadingType == 'loading' || this.loadingType == 'noMore') {
  71. return
  72. }
  73. this.loadingType = 'loading'
  74. getProducts({
  75. // cid: index,
  76. page: this.page,
  77. limit: this.limit,
  78. mall_type: 3
  79. }).then(res => {
  80. this.list = this.list.concat(res.data)
  81. this.page++
  82. if(this.limit == res.data.length) {
  83. this.loadingType = 'more'
  84. }else {
  85. this.loadingType = 'noMore'
  86. }
  87. this.loaded = true
  88. })
  89. },
  90. // 载入数据
  91. async loadData() {
  92. let obj = this;
  93. obj.getProducts()
  94. // getCategoryList({})
  95. // .then(({ data }) => {
  96. // obj.flist = data.map(function(s) {
  97. // return s;
  98. // });
  99. // obj.getProducts()
  100. // })
  101. // .catch(err => {
  102. // console.log(err);
  103. // });
  104. },
  105. //一级分类点击
  106. tabtap(item) {
  107. console.log(item);
  108. // 判断有没有初始化页面高度对象数据
  109. if (!this.sizeCalcState) {
  110. this.calcSize();
  111. }
  112. // 获取当前点击的id
  113. this.currentId = item.id;
  114. console.log(item.top);
  115. this.tabScrollTop = item.top;
  116. console.log(this.tabScrollTop);
  117. },
  118. //右侧栏滚动
  119. asideScroll(e) {
  120. // 判断有没有初始化页面高度对象数据
  121. if (!this.sizeCalcState) {
  122. this.calcSize();
  123. }
  124. let scrollTop = e.detail.scrollTop;
  125. let box = 0; //列表包裹框高度初始化
  126. let bottom = 10; //距离页面底部多少像素左侧列表切换到最后一个一级分类
  127. // 查询当前页面对象
  128. let view = uni.createSelectorQuery().select('.content');
  129. view.fields(
  130. {
  131. id: true,
  132. dataset: true,
  133. rect: true,
  134. size: true,
  135. scrollOffset: true
  136. },
  137. function(e) {
  138. // 保存包裹框高度
  139. box = e.height;
  140. }
  141. ).exec();
  142. // 获取所有距离顶部大于滚轮距离页面高度的所有分类
  143. let tabs = this.flist.filter(item =>( item.top-10) <= scrollTop).reverse();
  144. if (tabs.length > 0) {
  145. // 判断是否已经到达滚轮底部
  146. if (box + scrollTop + bottom >= e.detail.scrollHeight) {
  147. this.currentId = this.flist[this.flist.length - 1].id;
  148. } else {
  149. this.currentId = tabs[0].id;
  150. }
  151. }
  152. },
  153. //计算右侧栏每个tab的高度等信息
  154. calcSize() {
  155. let h = 0;
  156. this.flist.forEach(item => {
  157. let view = uni.createSelectorQuery().select('#main-' + item.id);
  158. view.fields(
  159. {
  160. size: true
  161. },
  162. data => {
  163. item.top = h;
  164. h += data.height;
  165. item.bottom = h;
  166. }
  167. ).exec();
  168. });
  169. this.sizeCalcState = true;
  170. },
  171. navToList(sid, tid) {
  172. // 点击导航跳转到详细页面
  173. uni.navigateTo({
  174. url: '/pages/product/list?fid='+this.currentId+'&sid='+sid+'&tid='+tid
  175. });
  176. },
  177. navto(url) {
  178. uni.navigateTo({
  179. url
  180. })
  181. }
  182. }
  183. };
  184. </script>
  185. <style lang="scss">
  186. .cate-wrap {
  187. width:750rpx;
  188. .left-wrap {
  189. width: 180rpx;
  190. flex-shrink: 0;
  191. background-color: #f2f2f2;
  192. .left-item {
  193. width: 180rpx;
  194. height: 100rpx;
  195. line-height: 100rpx;
  196. font-size: 28rpx;
  197. font-weight: 500;
  198. color: #666666;
  199. text-align: center;
  200. }
  201. .action-item {
  202. background-color: #fff;
  203. font-weight: bold;
  204. position: relative;
  205. &::before {
  206. content: '';
  207. position: absolute;
  208. top: 0;
  209. left: 0;
  210. width: 3rpx;
  211. height: 100rpx;
  212. background: #FF7144;
  213. }
  214. }
  215. }
  216. .right-wrap {
  217. flex-wrap: 1;
  218. background-color: #fff;
  219. .right-item {
  220. width: 520rpx;
  221. height: 240rpx;
  222. padding: 30rpx 0;
  223. margin: 0 auto ;
  224. border-bottom: 1px solid #eee;
  225. display: flex;
  226. justify-content: flex-start;
  227. align-items: center;
  228. .good-img {
  229. width: 180rpx;
  230. height: 180rpx;
  231. border-radius: 20rpx;
  232. }
  233. .good-info {
  234. flex-direction: column;
  235. justify-content: space-between;
  236. align-items: flex-start;
  237. height: 100%;
  238. padding-left: 25rpx;
  239. .good-name {
  240. font-size: 30rpx;
  241. font-weight: bold;
  242. color: #333333;
  243. }
  244. .good-price {
  245. font-size: 34rpx;
  246. font-weight: bold;
  247. color: #FF4C4C;
  248. }
  249. }
  250. }
  251. }
  252. }
  253. .hotgoods {
  254. margin-top: 20rpx;
  255. width: 100%;
  256. display: flex;
  257. flex-wrap: wrap;
  258. padding: 0 20rpx 30rpx;
  259. justify-content: space-between;
  260. .hotgoods-item {
  261. width: 345rpx;
  262. background-color: #ffffff;
  263. border-radius: 12rpx;
  264. box-shadow: 0 0 15rpx rgba(0, 0, 0, 0.2);
  265. margin-bottom: 15rpx;
  266. .image-wrapper {
  267. width: 345rpx;
  268. height: 345rpx;
  269. border-radius: 3px;
  270. overflow: hidden;
  271. position: relative;
  272. .image-bg {
  273. position: absolute;
  274. top: 0;
  275. left: 0;
  276. right: 0;
  277. bottom: 0;
  278. width: 100%;
  279. height: 100%;
  280. opacity: 1;
  281. border-radius: 12rpx 12rpx 0 0;
  282. z-index: 2;
  283. }
  284. .image {
  285. width: 100%;
  286. height: 100%;
  287. opacity: 1;
  288. border-radius: 12rpx 12rpx 0 0;
  289. }
  290. }
  291. .title {
  292. margin-top: 24rpx;
  293. padding: 0 20rpx;
  294. font-size: 32rpx;
  295. font-weight: 500;
  296. color: #333333;
  297. }
  298. .hot-price {
  299. display: flex;
  300. justify-content: flex-start;
  301. align-items: center;
  302. // padding: 14rpx 0 30rpx;
  303. .hotPrice-box {
  304. padding: 2rpx 6rpx;
  305. background: linear-gradient(90deg, #c79a4c, #f9df7f);
  306. border-radius: 5rpx;
  307. text-align: center;
  308. line-height: 28rpx;
  309. font-size: 20rpx;
  310. font-family: Source Han Sans CN;
  311. font-weight: 400;
  312. color: #ffffff;
  313. }
  314. .price {
  315. margin-left: 10rpx;
  316. font-size: 36rpx;
  317. color: #ff0000;
  318. font-weight: 500;
  319. display: flex;
  320. justify-content: flex-start;
  321. align-items: center;
  322. .jf {
  323. font-size: 20rpx;
  324. }
  325. .give-jf {
  326. display: inline-block;
  327. padding: 8rpx;
  328. background: linear-gradient(90deg, #FF834D, #FF2600);
  329. border-radius: 12rpx 0px 12rpx 0px;
  330. font-size: 22rpx;
  331. font-weight: 500;
  332. color: #FFFFFF;
  333. margin-left: 22rpx;
  334. }
  335. .ot-pirce {
  336. margin-left:10rpx;
  337. font-size: 26rpx;
  338. font-weight: 500;
  339. text-decoration: line-through;
  340. color: #999999;
  341. align-self: flex-end;
  342. }
  343. }
  344. .yuanPrice {
  345. margin-left: 10rpx;
  346. font-size: 20rpx;
  347. font-family: PingFang SC;
  348. font-weight: 500;
  349. text-decoration: line-through;
  350. color: #999999;
  351. }
  352. .cart-icon {
  353. image {
  354. width: 44rpx;
  355. height: 44rpx;
  356. }
  357. }
  358. }
  359. }
  360. }
  361. .ot-pirce {
  362. margin-left: 7rpx;
  363. font-size: 26rpx;
  364. font-weight: 500;
  365. text-decoration: line-through;
  366. color: #999999;
  367. align-self: flex-end;
  368. }
  369. </style>