sort.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671
  1. <template>
  2. <view>
  3. <view :class="'top' + (isScroll ? ' top-background' : '')" :style="'height:' + systems.barHeight + 'rpx;'">
  4. <view class="top-nav ddflex" :style="'height:' + systems.navigationHeight + 'rpx;top:' + systems.ktxStatusHeight + 'rpx;'">
  5. <navigator open-type="navigateBack" hover-class="none" class="back ddflex"><image :src="picUrlss + 'back_black.png'"></image></navigator>
  6. <view class="top-nav-title fflex" :style="'line-height:' + systems.navigationHeight + 'rpx;'" v-if="isScroll">产品</view>
  7. </view>
  8. </view>
  9. <view class="top-con">
  10. <image :src="merchant.mainGraph" class="top-bg"></image>
  11. <view class="shop">
  12. <view class="shop-info ddflex">
  13. <view class="fflex">
  14. <view class="shop-name tover">{{ merchant.title }}</view>
  15. <view class="shop-datas">
  16. {{ merchant.range ? '距您' + (merchant.mDistance < 1000 ? merchant.mDistance + 'm · ' : merchant.range + 'km · ') : ''
  17. }}{{ merchant.buyPerson }}位朋友买过
  18. </view>
  19. </view>
  20. <view class="shop-pic"><image :src="merchant.logo" mode="aspectFill" class="shop-logo"></image></view>
  21. </view>
  22. <view class="discount ddflex">
  23. <view class="ddflex fflex">
  24. <view class="li ddflex" v-for="(item, indexl) in label" :key="indexl">{{ item }}</view>
  25. </view>
  26. </view>
  27. </view>
  28. </view>
  29. <block v-if="sort">
  30. <!-- #ifndef H5 -->
  31. <scroll-view scroll-y="true" class="sort-left" :style="'bottom:' + (bottomBlankHeignt + 115) + 'rpx;'">
  32. <block v-for="(item, index) in sortCategorys" :key="index">
  33. <view :class="'li ' + (selectTab == index ? 'active' : '')" :data-index="index" @tap="toScrollView" :data-id="item.id">{{ item.title }}</view>
  34. </block>
  35. </scroll-view>
  36. <!-- #endif -->
  37. <!-- #ifdef H5 -->
  38. <scroll-view scroll-y="true" class="sort-left" :style="'bottom:' + (bottomBlankHeignt + 115) + 'rpx;' + 'top: 43px'">
  39. <block v-for="(item, index) in sortCategorys" :key="index">
  40. <view :class="'li ' + (selectTab == index ? 'active' : '')" :data-index="index" @tap="toScrollView" :data-id="item.id">{{ item.title }}</view>
  41. </block>
  42. </scroll-view>
  43. <!-- #endif -->
  44. <scroll-view
  45. scroll-y="true"
  46. class="sort-right"
  47. :style="'height:' + scrollHeight + 'px;'"
  48. :scroll-into-view="toView"
  49. scroll-top="0"
  50. @scroll="scrollTo"
  51. scroll-with-animation="true"
  52. >
  53. <view class="rcon">
  54. <view v-for="(cats, idx) in sortCategorys" :key="idx" :id="'position' + idx">
  55. <view class="tit" @tap="goUrl" :data-id="cats.id" :data-title="cats.title">{{ cats.title }}</view>
  56. <view class="list dflex">
  57. <view v-for="(item, index) in cats.nodes" :key="index" class="li" @tap="goUrl" :data-id="item.id" :data-title="item.title">
  58. <image :src="item.icon" v-if="item.icon" lazy-load="true"></image>
  59. <view class="litext" :data-key="key" :style="'background-color:' + item.colors" v-else>{{ item.first }}</view>
  60. {{ item.title }}
  61. </view>
  62. </view>
  63. </view>
  64. </view>
  65. </scroll-view>
  66. </block>
  67. <view class="ddflex" style="align-items: flex-start;margin-top: 30rpx;" v-else>
  68. <!-- #ifndef H5 -->
  69. <scroll-view scroll-y="true" :class="'left savepadding' + (isFixed ? ' left-position' : '')" :style="'top:' + systems.barHeight + 'rpx;'">
  70. <block v-for="(item, index) in categorys" :key="index">
  71. <view :class="'li ' + (current == index ? 'active' : '')" :data-current="index" :data-id="item.id" @tap="cateTab">
  72. <view class="ddflex">{{ item.title }}</view>
  73. </view>
  74. </block>
  75. </scroll-view>
  76. <!-- #endif -->
  77. <!-- #ifdef H5 -->
  78. <scroll-view scroll-y="true" :class="'left' + (isFixed ? ' left-position' : '')" :style="'bottom:' + (bottomBlankHeignt + 115) + 'rpx;' + 'top: 43px;'">
  79. <block v-for="(item, index) in categorys" :key="index">
  80. <view :class="'li ' + (current == index ? 'active' : '')" :data-current="index" :data-id="item.id" @tap="cateTab">
  81. <view class="ddflex">{{ item.title }}</view>
  82. </view>
  83. </block>
  84. </scroll-view>
  85. <!-- #endif -->
  86. <view :class="'right' + (isFixed ? ' right-position' : '')">
  87. <view class="savepadding">
  88. <scroll-view scroll-X="true" :class="'tab' + (isFixed ? ' tab-position' : '')" :style="'top:' + systems.barHeight + 'rpx;'">
  89. <view :class="'li ' + (currents == -1 ? 'active' : '')" @tap="all">全部</view>
  90. <block v-for="(item, index) in cates" :key="index" v-if="!merchantId">
  91. <view :class="'li ' + (currents == index ? 'active' : '')" @tap="cateTabs" :data-currents="index" :data-id="item.id">
  92. {{ item.title }}{{ merchantId }}
  93. </view>
  94. </block>
  95. </scroll-view>
  96. <view class="sort">
  97. <block v-for="(item, index) in pageList" :key="index">
  98. <view class="li dflex">
  99. <view class="proimgs" @tap="toDetail" :data-id="item.id">
  100. <image :src="item.pic + '?x-oss-process=style/w160'" mode="aspectFit" class="proimg" lazy-load="true"></image>
  101. <image :src="picUrlss + 'shouqing.png'" class="shouqing" v-if="item.stock < 1"></image>
  102. </view>
  103. <view class="flex">
  104. <view class="proname" @tap="toDetail" :data-id="item.id">{{ item.title }}</view>
  105. <view :class="[item.brandName ? '' : 'nopronames', 'pronames']">{{ item.brandName ? item.brandName : '' }}</view>
  106. <view class="operate dflex">
  107. <view class="price">
  108. <text>{{ item.salePrice }}</text>
  109. <view class="vip-news ddflex" v-if="show_membership_price == 1 && item.actualPrice < item.salePrice">
  110. <text class="vip-sale">会员价</text>
  111. <text class="vip-members">¥{{ item.actualPrice }}</text>
  112. </view>
  113. <view class="vip-news ddflex" v-if="show_membership_price == 1 && item.membersPrice < item.salePrice">
  114. <text class="vip-sale">会员价</text>
  115. <text class="vip-members">¥{{ item.membersPrice }}</text>
  116. </view>
  117. <!-- <text class="vip" v-if="show_membership_price==1&&item.actualPrice < item.salePrice"><text class="sale">VIP</text><text class="members">{{item.actualPrice}}</text></text>
  118. <text class="vip"
  119. v-if="show_membership_price==1&&item.membersPrice<item.salePrice"><text
  120. class="sale">VIP</text><text
  121. class="members">{{item.membersPrice}}</text></text> -->
  122. <text class="del" v-if="show_membership_price != 1">
  123. <block v-if="item.marketPrice != 0 && item.marketPrice > item.salePrice">¥{{ item.marketPrice }}</block>
  124. </text>
  125. </view>
  126. <view class="add-cart">
  127. <!-- addShopCart -->
  128. <image
  129. src="/static/pages/images/jia.png"
  130. @tap="toDetail"
  131. :data-id="item.id"
  132. :data-skuid="item.skuId"
  133. :data-index="index"
  134. :data-state="item.state"
  135. ></image>
  136. </view>
  137. </view>
  138. </view>
  139. </view>
  140. </block>
  141. <view class="nodata nosp bgfff" v-if="show">
  142. <image :src="picUrlss + 'empty_sp.png'"></image>
  143. <text>暂无商品</text>
  144. </view>
  145. </view>
  146. </view>
  147. </view>
  148. </view>
  149. <cart :isUpdate="isUpdate"></cart>
  150. </view>
  151. </template>
  152. <script>
  153. // pages/sort/sort.js
  154. //获取应用实例
  155. const app = getApp();
  156. const req = require('../../utils/request.js');
  157. let scrollDdirection = 0; // 用来计算滚动的方向
  158. import foot from '../../components/nav-bar/index';
  159. import cart from '../../components/shopping-cart/index';
  160. export default {
  161. data() {
  162. return {
  163. isUpdate: false,
  164. picUrlss: req.public.picUrls,
  165. systems: {},
  166. topHeight: 0,
  167. isFixed: false,
  168. isScroll: false,
  169. bottomBlankHeignt: app.globalData.isIPhoneX ? 68 : 0,
  170. categorys: [],
  171. //产品一级分类列表
  172. cates: [],
  173. //产品二级分类列表
  174. current: 0,
  175. currents: -1,
  176. page: 1,
  177. sort: false,
  178. sortCategorys: [],
  179. //产品一级分类列表
  180. selectTab: 0,
  181. scrollTop: 0,
  182. scrollHeight: 0,
  183. // 滚动视图的高度
  184. toView: 'position0',
  185. // 滚动视图跳转的位置
  186. scrollInfo: [],
  187. isload: false,
  188. // 自定义自己喜欢的颜色
  189. colorArr: ['#e83fa0', '#0cd4c5', '#b146f4', '#18c88b', '#227bfe', '#e8a52f', '#f78d58'],
  190. // 存储随机颜色
  191. randomColorArr: [],
  192. isUpdate: false, // 是否更新消息
  193. merchantId: '',
  194. id: '',
  195. show_membership_price: 0,
  196. Is_Store_Price_Stock: 0,
  197. pageList: [],
  198. _key: '',
  199. show: Boolean,
  200. cateid: '',
  201. merchant: {},
  202. label: []
  203. };
  204. },
  205. components: {
  206. foot,
  207. cart
  208. },
  209. props: {},
  210. onLoad: async function(options) {
  211. // console.log(options);
  212. this.setData({
  213. current: options.current ? options.current : 0,
  214. merchantId: options.merchantId,
  215. id: options.id
  216. });
  217. this.merchant = req.getStorage('MERCHANT');
  218. if (this.merchant.label) {
  219. this.label = this.merchant.label.split(',');
  220. }
  221. await this.getConfig();
  222. uni.getSystemInfo({
  223. success: res => {
  224. this.setData({
  225. scrollHeight: res.windowHeight - (136 * res.windowWidth) / 750
  226. });
  227. }
  228. });
  229. if (this.sort) this.sortCategory();
  230. else this.category('0', 'categorys', options.id);
  231. console.log('this.topHeight?????', this.topHeight);
  232. },
  233. onShow() {
  234. this.setData({
  235. isUpdate: !this.isUpdate
  236. });
  237. },
  238. onReachBottom() {
  239. this.page++;
  240. if (this.currents > -1) {
  241. this.getList(this.cateid);
  242. } else {
  243. this.getList(this.id);
  244. }
  245. },
  246. methods: {
  247. getConfig() {
  248. var _this = this;
  249. return new Promise((resolve, reject) => {
  250. req.getRequest('/api/config', {}, function(res) {
  251. if (res && res.Product_Sort_ico == 1)
  252. _this.setData({
  253. sort: true
  254. });
  255. if (res && res.show_membership_price == 1) {
  256. _this.setData({
  257. show_membership_price: 1
  258. });
  259. }
  260. if (res && res.Is_Store_Price_Stock == 1) {
  261. _this.setData({
  262. Is_Store_Price_Stock: 1
  263. });
  264. }
  265. resolve();
  266. });
  267. });
  268. },
  269. category(id, dataName, listId) {
  270. //产品分类
  271. let that = this;
  272. // console.log(id, dataName, listId);
  273. let from = {
  274. page: 1,
  275. size: 1000,
  276. pid: id
  277. };
  278. if (this.Is_Store_Price_Stock == 1) {
  279. if (req.getStorage('smallShop')) {
  280. from.merchantId = req.getStorage('smallShop').merchantDTO.id;
  281. } else if (req.getStorage('MERCHANT')) {
  282. from.merchantId = req.getStorage('MERCHANT').id;
  283. }
  284. }
  285. req.getRequest('/api/category/list', from, res => {
  286. // console.log(res);
  287. let data = {};
  288. data[dataName] = res;
  289. if (id == 0) {
  290. if (listId) {
  291. this.getList(listId); // this.initCate(listId, 'cates');
  292. } else {
  293. this.getList(res[0].id);
  294. this.initCate(res[0].id, 'cates');
  295. that.setData({
  296. id: res[0].id
  297. });
  298. }
  299. }
  300. that.setData(data);
  301. // console.log(data);
  302. });
  303. },
  304. async initCate(id, dataName) {
  305. await this.category(id, dataName); // if(this.data.merchantId){
  306. // return false
  307. // }
  308. this.getList(id);
  309. },
  310. cateTab(e) {
  311. let current = e.currentTarget.dataset.current;
  312. let id = e.currentTarget.dataset.id;
  313. this.categoryId = id; // this.category(id, 'cates')
  314. // this.getList(id)
  315. this.setData({
  316. current: current,
  317. currents: -1,
  318. id: id,
  319. page: 1,
  320. pageList: []
  321. });
  322. this.initCate(id, 'cates');
  323. },
  324. getList(id) {
  325. // console.log("====================")
  326. //产品列表
  327. let that = this;
  328. var startTime = new Date().getTime();
  329. // console.log(id);
  330. let from = {
  331. page: that.page,
  332. limit: 6,
  333. categoryId: id
  334. };
  335. if (this.Is_Store_Price_Stock == 1) {
  336. if (req.getStorage('MERCHANT')) {
  337. if (req.getStorage('MERCHANT').isDefault != 1) {
  338. from.merchantId = req.getStorage('MERCHANT').id;
  339. } else {
  340. delete from.merchantId;
  341. }
  342. }
  343. } // if (!that.data.isLoad) return false;
  344. // that.data.isLoad = false;
  345. req.getRequest('/api/product/list', from, res => {
  346. // console.log(new Date().getTime() - startTime);
  347. if (res && res.length >= 10) that.isLoad = true;
  348. if (that.page > 1) res = that.pageList.concat(res);
  349. if (res.length <= 0) {
  350. that.setData({
  351. show: true
  352. });
  353. } else {
  354. that.setData({
  355. show: false
  356. });
  357. }
  358. that.setData({
  359. pageList: res
  360. });
  361. });
  362. },
  363. cateTabs(e) {
  364. let current = e.currentTarget.dataset.currents;
  365. let id = e.currentTarget.dataset.id;
  366. this.setData({
  367. currents: current,
  368. page: 1,
  369. pageList: [],
  370. cateid: id
  371. });
  372. this.getList(id);
  373. },
  374. all() {
  375. // console.log(this.id); // this.getList(this.data.id)
  376. this.setData({
  377. currents: -1
  378. });
  379. this.initCate(this.id, 'cates');
  380. },
  381. toDetail(e) {
  382. let id = e.currentTarget.dataset.id; // let merchant = e.currentTarget.dataset.merchant
  383. // let shopId = e.currentTarget.dataset.shopid
  384. if (this.Is_Store_Price_Stock == 1) {
  385. if (req.getStorage('smallShop')) {
  386. var merchantId = req.getStorage('smallShop').merchantDTO.id;
  387. var shopId = req.getStorage('smallShop').id;
  388. app.globalData.openPage('product/detail/detail?id=' + id + '&merchantId=' + merchantId + '&shopId=' + shopId);
  389. } else if (req.getStorage('MERCHANT')) {
  390. if (req.getStorage('MERCHANT').isDefault != 1) {
  391. merchantId = req.getStorage('MERCHANT').id;
  392. app.globalData.openPage('product/detail/detail?id=' + id + '&merchantId=' + merchantId);
  393. } else {
  394. app.globalData.openPage('product/detail/detail?id=' + id);
  395. }
  396. }
  397. } else {
  398. app.globalData.openPage('product/detail/detail?id=' + id);
  399. } // if (!shopId) {
  400. // app.openPage("product/detail/detail?id=" + id + "&merchantId=" + merchantId)
  401. // } else {
  402. // app.openPage("product/detail/detail?id=" + id + "&merchantId=" + merchantId + "&shopId=" + shopId)
  403. // }
  404. // app.openPage("product/detail/detail?id=" + id)
  405. },
  406. addShopCart(e) {
  407. let that = this;
  408. let skuId = e.currentTarget.dataset.skuid;
  409. let id = e.currentTarget.dataset.id;
  410. let index = e.currentTarget.dataset.index;
  411. let pageList = that.pageList;
  412. let state = e.currentTarget.dataset.state; // let merchant = req.getStorage('MERCHANT');
  413. req.isLogin().then(success => {
  414. if (success) {
  415. let params = {
  416. skuId: skuId,
  417. quantity: 1,
  418. productId: id
  419. };
  420. if (req.getStorage('smallShop')) {
  421. params.merchantId = req.getStorage('smallShop').merchantDTO.id;
  422. params.shopId = req.getStorage('smallShop').id;
  423. } else if (req.getStorage('MERCHANT')) {
  424. params.merchantId = req.getStorage('MERCHANT').id;
  425. } // if(state!=1){
  426. // return req.msg('您来晚了,商品已经下架')
  427. // }
  428. req.postRequest('/api/purchase/cart', params, res => {
  429. that.setData({
  430. isUpdate: !that.isUpdate
  431. });
  432. req.msg('加入购物车成功');
  433. });
  434. }
  435. });
  436. },
  437. sortCategory() {
  438. //产品分类
  439. let that = this;
  440. let params = {
  441. page: 1,
  442. size: 1000
  443. };
  444. if (this.Is_Store_Price_Stock == 1) {
  445. if (req.getStorage('smallShop')) {
  446. params.merchantId = req.getStorage('smallShop').merchantDTO.id; // params.shopId= req.getStorage('smallShop').id
  447. } else if (req.getStorage('MERCHANT')) {
  448. if (req.getStorage('MERCHANT').isDefault != 1) {
  449. params.merchantId = req.getStorage('MERCHANT').id;
  450. }
  451. }
  452. }
  453. req.getRequest('/api/category/list', params, res => {
  454. if (res) {
  455. let array = res
  456. .filter(it => it.pid == 0)
  457. .map(item => {
  458. item.nodes = res
  459. .filter(ite => ite.pid == item.id)
  460. .map(mp => {
  461. mp.first = mp.title.substr(0, 1);
  462. let random = that.colorArr[Math.floor(Math.random() * that.colorArr.length)];
  463. mp.colors = random;
  464. return mp;
  465. });
  466. return item;
  467. });
  468. that.setData({
  469. sortCategorys: array
  470. });
  471. setTimeout(() => {
  472. that.lisenerScroll();
  473. }, 100);
  474. }
  475. });
  476. },
  477. goUrl(e) {
  478. let id = e.currentTarget.dataset.id;
  479. let title = e.currentTarget.dataset.title;
  480. if (this.Is_Store_Price_Stock == 1) {
  481. if (req.getStorage('smallShop')) {
  482. var merchantId = req.getStorage('smallShop').merchantDTO.id;
  483. app.globalData.openPage('product/list/list?id=' + id + '&smallShop=true' + '&title=' + title);
  484. } else if (req.getStorage('MERCHANT')) {
  485. if (req.getStorage('MERCHANT').isDefault != 1) {
  486. merchantId = req.getStorage('MERCHANT').id;
  487. app.globalData.openPage('product/list/list?id=' + id + '&merchantId=' + merchantId + '&title=' + title);
  488. } else {
  489. app.globalData.openPage('product/list/list?id=' + id + '&title=' + title);
  490. }
  491. }
  492. } else {
  493. app.globalData.openPage('product/list/list?id=' + id + '&title=' + title);
  494. } // app.openPage(e.currentTarget.dataset.url)
  495. },
  496. toScrollView(e) {
  497. const { index } = e.currentTarget.dataset;
  498. this.setData({
  499. selectTab: index,
  500. toView: `position${index}`
  501. });
  502. },
  503. /**
  504. * 获取右边每个分类的头部偏移量
  505. */
  506. lisenerScroll() {
  507. // var _ts=this;
  508. /* setTimeout(() => {
  509. _ts.setHeight(0);
  510. }, 10000);*/
  511. // 获取各分类容器距离顶部的距离
  512. new Promise(resolve => {
  513. let query = uni.createSelectorQuery();
  514. var clength = this.sortCategorys.length;
  515. for (var k = 0; k < clength; k++) {
  516. query.select(`#position${k}`).boundingClientRect();
  517. }
  518. query.exec(function(res) {
  519. resolve(res);
  520. });
  521. }).then(res => {
  522. var categorys = this.sortCategorys;
  523. if (res.length == categorys.length) {
  524. categorys.forEach((item, index) => {
  525. item.offsetTop = res[index].top;
  526. });
  527. this.setData({
  528. scrollInfo: res,
  529. sortCategorys: categorys
  530. });
  531. }
  532. });
  533. },
  534. setHeight(k) {
  535. var _ts = this;
  536. if (_ts.isload) {
  537. return;
  538. }
  539. _ts.isload = false;
  540. let query = uni.createSelectorQuery();
  541. query.select(`#position${k}`).boundingClientRect();
  542. query.exec(function(res) {
  543. var _key = 'categorys[' + k + '].offsetTop';
  544. _ts.setData({
  545. [_key]: res[0].top
  546. });
  547. _ts.isload = true;
  548. });
  549. },
  550. /**
  551. * 监听滚动条滚动事件
  552. */
  553. scrollTo(e) {
  554. const scrollTop = e.detail.scrollTop; //滚动的Y轴
  555. const { selectTab, sortCategorys } = this;
  556. if (scrollDdirection < scrollTop) {
  557. // 向上滑动
  558. scrollDdirection = scrollTop; // 计算偏移位置
  559. // console.log(current, scrollTop,categorys[current + 1].offsetTop);
  560. if (selectTab < sortCategorys.length - 1 && scrollTop >= sortCategorys[selectTab + 1].offsetTop) {
  561. // console.log("chua");
  562. this.setData({
  563. selectTab: selectTab + 1
  564. });
  565. }
  566. } else {
  567. // 向下滑动
  568. scrollDdirection = scrollTop; // 计算偏移位置
  569. if (selectTab > 0 && scrollTop < sortCategorys[selectTab].offsetTop && scrollTop > 0) {
  570. this.setData({
  571. selectTab: selectTab - 1
  572. });
  573. }
  574. }
  575. }
  576. },
  577. created() {
  578. const systemInfo = uni.getSystemInfoSync();
  579. // px转换到rpx的比例
  580. let pxToRpxScale = 750 / systemInfo.windowWidth;
  581. let systems = {
  582. ktxStatusHeight: systemInfo.statusBarHeight * pxToRpxScale, // 状态栏的高度
  583. navigationHeight: 44 * pxToRpxScale // 导航栏的高度
  584. };
  585. systems.barHeight = systems.ktxStatusHeight + systems.navigationHeight;
  586. this.systems = systems;
  587. },
  588. mounted: function(e) {
  589. let that = this;
  590. const query = wx.createSelectorQuery();
  591. query
  592. .select('.top-con')
  593. .boundingClientRect(function(res) {
  594. console.log('top-con==', res);
  595. that.topHeight = res.height;
  596. console.log('that.topHeight==', that.topHeight);
  597. })
  598. .exec();
  599. },
  600. onPageScroll(e) {
  601. const systemInfo = uni.getSystemInfoSync();
  602. let height = systemInfo.statusBarHeight + 44;
  603. if (e.scrollTop > height) {
  604. this.isScroll = true;
  605. } else {
  606. this.isScroll = false;
  607. }
  608. console.log('this.topHeight=======', this.topHeight);
  609. if (e.scrollTop > this.topHeight - 15) {
  610. this.isFixed = true;
  611. } else {
  612. this.isFixed = false;
  613. }
  614. }
  615. };
  616. </script>
  617. <style>
  618. @import './sort.css';
  619. </style>