cats.vue 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776
  1. <template>
  2. <app-layout>
  3. <template v-if="loading">
  4. <view class="app-search" v-if="search_bool">
  5. <app-search-for></app-search-for>
  6. </view>
  7. <!-- 样式一 -->
  8. <view v-if="cat_style.cat_style === '1'" class="margin-fixed">
  9. <style-one
  10. :list="list"
  11. :goods_list="goods_list"
  12. ></style-one>
  13. </view>
  14. <!-- 样式二 -->
  15. <view v-else-if="cat_style.cat_style === '2'" class="margin-fixed">
  16. <style-two
  17. :list="list"
  18. :windowHeight="windowHeight"
  19. :windowWidth="windowWidth"
  20. :botHeight="botHeight"
  21. :setHeight="setHeight"
  22. :activeIndex="activeIndex"
  23. @active="activeThree"
  24. @route_advert="route_advert"
  25. :theme="getTheme"
  26. ></style-two>
  27. </view>
  28. <!-- 样式三 -->
  29. <view v-else-if="cat_style.cat_style === '3'" class="margin-fixed">
  30. <style-three
  31. :list="list"
  32. :goods_list="goods_list"
  33. ></style-three>
  34. </view>
  35. <!-- 样式四 -->
  36. <view v-else-if="cat_style.cat_style === '4'" class="margin-fixed">
  37. <style-four
  38. :list="list"
  39. :windowHeight="windowHeight"
  40. :windowWidth="windowWidth"
  41. :botHeight="botHeight"
  42. :setHeight="setHeight"
  43. :activeIndex="activeIndex"
  44. @active="activeThree"
  45. @route_advert="route_advert"
  46. :theme="getTheme"
  47. ></style-four>
  48. </view>
  49. <!-- 样式五 -->
  50. <view v-else-if="cat_style.cat_style === '5'" class="margin-fixed">
  51. <style-five
  52. :list="list"
  53. @active="activeOne"
  54. @setNav="activeTwo"
  55. :activeIndex="activeIndex"
  56. :activeIndexTwo="activeIndexTwo"
  57. :goods_list="goods_list"
  58. :theme="getTheme"
  59. :is_over_goods="is_over_goods"
  60. ></style-five>
  61. </view>
  62. <!-- 样式六 -->
  63. <view v-else-if="cat_style.cat_style === '6'" class="margin-fixed">
  64. <style-six
  65. :list="list"
  66. :setHeight="setHeight"
  67. :activeIndex="activeIndex"
  68. :goods="goods"
  69. :botHeight="botHeight"
  70. @active="activeThree"
  71. @route_advert="route_advert"
  72. :theme="getTheme"
  73. ></style-six>
  74. </view>
  75. <!-- 样式七 -->
  76. <view v-else-if="cat_style.cat_style === '7'" class="margin-fixed">
  77. <style-seven
  78. :list="list"
  79. :setHeight="setHeight"
  80. :activeIndex="activeIndex"
  81. :goods="goods"
  82. :botHeight="botHeight"
  83. :windowHeight="windowHeight"
  84. :windowWidth="windowWidth"
  85. @active="activeThree"
  86. @route_advert="route_advert"
  87. :theme="getTheme"
  88. ></style-seven>
  89. </view>
  90. <!-- 样式八 -->
  91. <view v-else-if="cat_style.cat_style === '8'" class="margin-fixed">
  92. <style-eight
  93. :list="list"
  94. :goods_list="goods_list"
  95. theme="default"
  96. @active="active"
  97. :theme="getTheme"
  98. :is_over_goods="is_over_goods"
  99. :goodsLoading="goodsLoading"
  100. ></style-eight>
  101. </view>
  102. <!-- 样式九 -->
  103. <view v-else-if="cat_style.cat_style === '9'" class="margin-fixed">
  104. <style-nine
  105. :list="list"
  106. :setHeight="setHeight"
  107. :activeIndex="activeIndex"
  108. :goods_list="goods_list"
  109. @active="activeThree"
  110. @lower="lower"
  111. @requestGoods="requestGoods"
  112. @attr="attr"
  113. @route_advert="route_advert"
  114. :theme="getTheme"
  115. :is_over_goods="is_over_goods"
  116. ></style-nine>
  117. </view>
  118. <!-- 样式十 -->
  119. <view v-else-if="cat_style.cat_style === '10'" class="margin-fixed">
  120. <style-ten
  121. :list="list"
  122. :setHeight="setHeight"
  123. :activeIndex="activeIndex"
  124. :goods_list="goods_list"
  125. :activeIndexTwo="activeIndexTwo"
  126. @active="activeThree"
  127. @lower="lower"
  128. @requestGoods="requestGoods"
  129. @setNav="activeTwo"
  130. @attr="attr"
  131. @route_advert="route_advert"
  132. :theme="getTheme"
  133. :is_over_goods="is_over_goods"
  134. ></style-ten>
  135. </view>
  136. <!-- 样式十一 -->
  137. <view v-else-if="cat_style.cat_style === '11'" class="margin-fixed">
  138. <style-eleven
  139. :list="list"
  140. :setHeight="setHeight"
  141. :activeIndex="activeIndex"
  142. :goods_list="goods_list"
  143. :activeIndexTwo="activeIndexTwo"
  144. @active="activeThree"
  145. @lower="catLower"
  146. @requestCatList="activeRequest"
  147. @setNav="requestCatList"
  148. @attr="attr"
  149. @route_advert="route_advert"
  150. :theme="getTheme"
  151. :is_over_goods="is_over_goods"
  152. ></style-eleven>
  153. </view>
  154. <app-attr
  155. ref="attr"
  156. :goods="item"
  157. :select-attr="selectAttr"
  158. :attr-group-list="attrGroup"
  159. :show="show"
  160. @attrtap="onAttr"
  161. :previewUrl="previewUrl"
  162. :submitUrl="submitUrl"
  163. :theme="getTheme"
  164. ></app-attr>
  165. </template>
  166. </app-layout>
  167. </template>
  168. <script>
  169. import { mapGetters, mapState } from 'vuex';
  170. import styleOne from './style-one.vue';
  171. import styleTwo from './style-two';
  172. import styleThree from './style-three.vue';
  173. import styleFour from './style-four.vue';
  174. import styleFive from './style-five.vue';
  175. import styleSix from './style-six.vue';
  176. import styleSeven from './style-seven.vue';
  177. import styleEight from './style-eight.vue';
  178. import styleNine from './style-nine.vue';
  179. import styleTen from './style-ten.vue';
  180. import styleEleven from './style-eleven.vue';
  181. import appSearchFor from '../../components/page-component/app-search-for/app-search-for.vue';
  182. import routeJump from '../../core/routeJump.js';
  183. import appAttr from '../../components/page-component/app-attr/app-attr.vue';
  184. export default {
  185. components: {
  186. 'app-search-for': appSearchFor,
  187. 'style-one': styleOne,
  188. 'style-two': styleTwo,
  189. 'style-three': styleThree,
  190. 'style-four': styleFour,
  191. 'style-five': styleFive,
  192. 'style-six': styleSix,
  193. 'style-seven': styleSeven,
  194. 'style-eight': styleEight,
  195. 'style-nine': styleNine,
  196. 'style-ten': styleTen,
  197. 'style-eleven': styleEleven,
  198. 'app-attr': appAttr
  199. },
  200. data() {
  201. return {
  202. search_bool: true,
  203. list: [],
  204. goods: [],
  205. request: true,
  206. page: 1,
  207. classId: 0,
  208. activeIndex: 0,
  209. activeIndexTwo: 0,
  210. over: false,
  211. scrollHeight: 0,
  212. tabbarbool: true,
  213. cat_id: 0,
  214. cat_ids: [],
  215. againLower: true,
  216. goods_list: [],
  217. page_count: 1,
  218. select_cat_id: 0,
  219. first_id: 0,
  220. loading: false,
  221. selectAttr: {},
  222. previewUrl: '',
  223. submitUrl: '',
  224. show: 0,
  225. attrGroup: [],
  226. item: {},
  227. is_over_goods: true,
  228. options: {},
  229. goodsLoading: false
  230. }
  231. },
  232. computed: {
  233. ...mapGetters('mallConfig', {
  234. cat_style: 'getCatStyle',
  235. getTheme: 'getTheme'
  236. }),
  237. ...mapState('gConfig', {
  238. windowHeight: state => state.systemInfo.windowHeight,
  239. windowWidth: state => state.systemInfo.windowWidth
  240. }),
  241. ...mapGetters('iPhoneX', {
  242. botHeight: 'getBotHeight'
  243. }),
  244. ...mapState('mallConfig', {
  245. mall: state => state.mall,
  246. }),
  247. setHeight() {
  248. let bottom = 0;
  249. if (this.tabbarbool) {
  250. bottom = this.botHeight;
  251. }
  252. return (this.windowHeight * (750 / this.windowWidth)) - bottom - 88;
  253. }
  254. },
  255. onReachBottom() {
  256. if (this.cat_style.cat_style === '3' || this.cat_style.cat_style === '1') return;
  257. if (this.page < this.page_count) {
  258. this.page++;
  259. this.$request({
  260. url: this.$api.default.goods_list,
  261. method: 'get',
  262. data: {
  263. page: this.page,
  264. cat_id: this.cat_id,
  265. }
  266. }).then(res => {
  267. if (res.code === 0) {
  268. if (this.cat_style.cat_style === '8') {
  269. this.goodsLoading = true;
  270. }
  271. this.goods_list.push(...res.data.list);
  272. }
  273. });
  274. } else {
  275. if (this.cat_style.cat_style === '8') {
  276. this.goodsLoading = false;
  277. }
  278. uni.showToast({
  279. title: '暂无更多商品',
  280. icon: 'none'
  281. })
  282. }
  283. },
  284. methods: {
  285. onAttr(data) {
  286. this.selectAttr = data;
  287. },
  288. attr(previewUrl, submitUrl, attr_groups, goods) {
  289. this.previewUrl = previewUrl;
  290. this.submitUrl = submitUrl;
  291. this.attrGroup = attr_groups;
  292. this.item = goods;
  293. this.show = Math.random();
  294. console.log(this.show);
  295. },
  296. route_advert(data) {
  297. routeJump({
  298. open_type: data.advert_open_type,
  299. params: data.advert_params,
  300. page_url: data.advert_url
  301. });
  302. },
  303. // 点击导航栏
  304. active(item) {
  305. this.page = 1;
  306. this.goods_list = [];
  307. this.cat_id = item.id;
  308. this.select_cat_id = item.id;
  309. for (let i = 0; i < this.list.length; i++) {
  310. if (this.list[i].active !== item.active) {
  311. this.list[i].active = false;
  312. }
  313. if (this.list[i].id === item.id) {
  314. this.list[i].active = true;
  315. }
  316. }
  317. this.is_over_goods = false;
  318. this.$request({
  319. url: `${this.$api.default.goods_list}&page=${this.page}&cat_id=${item.id}`
  320. }).then(res => {
  321. if (res.code === 0) {
  322. this.goods_list.push(...res.data.list);
  323. this.goodsLoading = true;
  324. this.page_count = res.data.pagination.page_count;
  325. this.is_over_goods = true;
  326. }
  327. });
  328. },
  329. // 下拉分页请求
  330. req() {
  331. this.$request({
  332. url: `${this.$api.default.goods_list}&page=${this.page}&cat_id=${this.classId}`
  333. }).then(response => {
  334. if (response.data.list.length > 0) {
  335. this.goods.push(...response.data.list);
  336. } else {
  337. this.over = true;
  338. }
  339. });
  340. },
  341. activeOne(item) {
  342. this.page = 1;
  343. this.activeIndexTwo = 0;
  344. this.cat_id = item.id;
  345. this.select_cat_id = item.id;
  346. this.is_over_goods = false;
  347. for (let i = 0; i < this.list.length; i++) {
  348. if (this.list[i].active !== item.active) {
  349. this.list[i].active = false;
  350. }
  351. if (this.list[i].id === item.id) {
  352. this.list[i].active = true;
  353. this.activeIndex = i;
  354. }
  355. }
  356. if (this.cat_style.cat_style === '5') this.goods_list = [];
  357. if (this.list[this.activeIndex].child.length === 0) {
  358. this.$request({
  359. url: `${this.$api.default.goods_list}&page=${this.page}&cat_id=${item.id}`
  360. }).then(res => {
  361. let { list, pagination } = res.data;
  362. this.goods_list = list;
  363. this.is_over_goods = true;
  364. this.page = 1;
  365. this.cat_id = item.id;
  366. this.select_cat_id = item.id;
  367. this.page_count = pagination.page_count;
  368. });
  369. } else {
  370. this.$request({
  371. url: `${this.$api.default.goods_list}&page=${this.page}&cat_id=${this.list[this.activeIndex].child[0].id}`
  372. }).then(res => {
  373. let { list, pagination } = res.data;
  374. this.goods_list = list;
  375. this.is_over_goods = true;
  376. this.page = 1;
  377. this.cat_id = this.list[this.activeIndex].child[0].id;
  378. this.select_cat_id = item.id;
  379. this.page_count = pagination.page_count;
  380. });
  381. }
  382. },
  383. async activeTwo(item, index) {
  384. this.page = 1;
  385. this.activeIndexTwo = index;
  386. this.select_cat_id = item.id;
  387. this.cat_id = item.id;
  388. this.select_cat_id = item.id;
  389. this.is_over_goods = false;
  390. const res = await this.$request({
  391. url: this.$api.default.goods_list,
  392. method: 'get',
  393. data: {
  394. page: 1,
  395. cat_id: item.id
  396. }
  397. });
  398. if (res.code === 0) {
  399. let { list, pagination } = res.data;
  400. this.goods_list = [];
  401. this.goods_list = list;
  402. this.is_over_goods = true;
  403. this.page_count = pagination.page_count;
  404. }
  405. },
  406. activeThree(item) {
  407. this.cat_id = item.id;
  408. this.select_cat_id = item.id;
  409. for (let i = 0; i < this.list.length; i++) {
  410. if (this.list[i].active !== item.active) {
  411. this.list[i].active = false;
  412. }
  413. if (this.list[i].id === item.id) {
  414. this.list[i].active = true;
  415. this.activeIndex = i;
  416. }
  417. }
  418. },
  419. async catLower() {
  420. if (!this.againLower) return;
  421. this.againLower = false;
  422. let goods_list = this.goods_list[this.goods_list.length - 1];
  423. const res = await this.$request({
  424. url: this.$api.default.cat_goods,
  425. method: 'get',
  426. data: {
  427. cat_ids: JSON.stringify(this.cat_ids),
  428. cat_id: goods_list.id,
  429. offset: goods_list.offset
  430. }
  431. });
  432. if (res.code === 0) {
  433. if (res.data.list[0].id === goods_list.id && res.data.list[0].goods_list.length > 0) {
  434. this.goods_list[this.goods_list.length - 1].goods_list.push(...res.data.list[0].goods_list);
  435. this.goods_list[this.goods_list.length - 1].offset = res.data.list[0].offset;
  436. }
  437. for (let i = 1; i < res.data.list.length; i++) {
  438. this.goods_list.push(res.data.list[i]);
  439. }
  440. this.againLower = true;
  441. }
  442. },
  443. activeRequest(data) {
  444. this.goods_list = [];
  445. if (data.child.length !== 0) {
  446. this.requestCatList(data.child[0], 0);
  447. }
  448. },
  449. async requestCatList(data, index) {
  450. this.page = 1;
  451. this.cat_id = data.id;
  452. this.select_cat_id = data.id;
  453. this.activeIndexTwo = index;
  454. this.goods_list = [];
  455. if (data.child.length !== 0) {
  456. this.is_over_goods = false;
  457. this.cat_ids = [];
  458. for (let i = 0; i < data.child.length; i++) {
  459. this.cat_ids.push(data.child[i].id);
  460. }
  461. const res = await this.$request({
  462. url: this.$api.default.cat_goods,
  463. method: 'get',
  464. data: {
  465. cat_ids: JSON.stringify(this.cat_ids),
  466. cat_id: data.child[0].id,
  467. offset: 0
  468. }
  469. });
  470. if (res.code === 0) {
  471. this.is_over_goods = true;
  472. this.goods_list = res.data.list;
  473. }
  474. }
  475. },
  476. // 求情商品列表
  477. async requestGoods(data, index) {
  478. this.page = 1;
  479. this.cat_id = data.id;
  480. this.select_cat_id = data.id;
  481. this.goods_list = [];
  482. this.is_over_goods = false;
  483. if (this.cat_style.cat_style === '10' && index !== undefined && this.list[index].child.length !== 0) {
  484. this.activeIndexTwo = 0;
  485. this.cat_id = this.list[index].child[0].id;
  486. }
  487. const res = await this.$request({
  488. url: this.$api.default.goods_list,
  489. method: 'get',
  490. data: {
  491. page: this.page,
  492. cat_id: this.cat_id
  493. }
  494. });
  495. if (res.code === 0) {
  496. this.is_over_goods = true;
  497. this.goods_list = res.data.list;
  498. this.goodsLoading = true;
  499. this.page_count = res.data.pagination.page_count;
  500. }
  501. },
  502. // 分页请求商品
  503. async lower(data) {
  504. if (this.page < this.page_count) {
  505. this.page++;
  506. const res = await this.$request({
  507. url: this.$api.default.goods_list,
  508. method: 'get',
  509. data: {
  510. page: this.page,
  511. cat_id: data.id
  512. }
  513. });
  514. if (res.code === 0) {
  515. this.goods_list.push(...res.data.list);
  516. }
  517. } else {
  518. uni.showToast({
  519. title: '暂无更多商品',
  520. icon: 'none'
  521. })
  522. }
  523. },
  524. // 处理数据
  525. dataProcessing(list) {
  526. for (let i = 0; i < list.length; i += 2) {
  527. if (i + 1 !== list.length) {
  528. this.goods_list.push([list[i], list[i + 1]]);
  529. } else {
  530. this.goods_list.push([list[i]]);
  531. }
  532. }
  533. },
  534. async requestCat(cat_id, select_cat_id) {
  535. this.loading = false;
  536. const res = await this.$request({
  537. url: this.$api.default.cat_list,
  538. method: 'get',
  539. data: {
  540. cat_id: cat_id ? cat_id : '',
  541. select_cat_id: select_cat_id ? select_cat_id : ''
  542. }
  543. });
  544. if (res.code === 0) {
  545. this.list = res.data.list;
  546. // 分类跳转
  547. if (this.cat_style.cat_style === '1' && this.list.length === 0) {
  548. this.search_bool = false;
  549. return;
  550. }
  551. if (this.cat_style.cat_style === '2' || this.cat_style.cat_style === '1') {
  552. return;
  553. }
  554. if (this.cat_style.cat_style === '3' && this.list.length === 0) {
  555. this.search_bool = false;
  556. return;
  557. }
  558. if (cat_id || select_cat_id) {
  559. if (this.cat_style.cat_style === '11') {
  560. this.cat_ids = [];
  561. this.list.map((item, index) => {
  562. if (item.active) {
  563. this.activeIndex = index;
  564. }
  565. });
  566. if (this.list[this.activeIndex].child.length === 0) return;
  567. for (let i = 0; i < this.list[this.activeIndex].child[0].child.length; i++) {
  568. this.cat_ids.push(this.list[this.activeIndex].child[0].child[i].id);
  569. }
  570. if (this.cat_ids.length === 0) return;
  571. const res = await this.$request({
  572. url: this.$api.default.cat_goods,
  573. method: 'get',
  574. data: {
  575. cat_ids: JSON.stringify(this.cat_ids),
  576. cat_id: this.cat_ids[0],
  577. offset: 0
  578. }
  579. });
  580. if (res.code === 0) {
  581. this.goods_list = res.data.list;
  582. }
  583. return;
  584. }
  585. if (this.cat_style.cat_style === '6' || this.cat_style.cat_style === '7') {
  586. this.list.map((item, index) => {
  587. if (item.active) {
  588. this.activeIndex = index;
  589. }
  590. });
  591. return;
  592. }
  593. if (this.list.length > 0) {
  594. for (let i = 0; i < this.list.length; i++) {
  595. if (this.list[i].active) {
  596. this.cat_id = this.list[i].id;
  597. }
  598. }
  599. }
  600. if ((this.cat_style.cat_style === '5' || this.cat_style.cat_style === '10') && this.list.length > 0 && this.list[0].child.length > 0) {
  601. for (let i = 0; i < this.list.length; i++) {
  602. if (this.list[i].active) {
  603. this.cat_id = this.list[i].child[0].id;
  604. }
  605. }
  606. }
  607. if (this.list.length === 0 && (this.cat_style.cat_style === '4')) {
  608. this.search_bool = false;
  609. return;
  610. }
  611. const res = await this.$request({
  612. url: this.$api.default.goods_list,
  613. method: 'get',
  614. data: {
  615. page: 1,
  616. cat_id: this.cat_id,
  617. }
  618. });
  619. if (res.code === 0) {
  620. this.goods_list = res.data.list;
  621. this.page_count = res.data.pagination.page_count;
  622. if (this.list.length === 0 && this.goods_list.length === 0) {
  623. this.search_bool = false;
  624. }
  625. }
  626. } else {
  627. if (this.list.length > 0) {
  628. if (this.cat_style.cat_style === '11') {
  629. this.cat_ids = [];
  630. if (this.list.length === 0 || this.list[0].child.length === 0) return;
  631. for (let i = 0; i < this.list[0].child[0].child.length; i++) {
  632. this.cat_ids.push(this.list[0].child[0].child[i].id);
  633. }
  634. if (this.cat_ids.length === 0) return;
  635. const res = await this.$request({
  636. url: this.$api.default.cat_goods,
  637. method: 'get',
  638. data: {
  639. cat_ids: JSON.stringify(this.cat_ids),
  640. cat_id: this.cat_ids[0],
  641. offset: 0
  642. }
  643. });
  644. if (res.code === 0) {
  645. this.goods_list = res.data.list;
  646. }
  647. return;
  648. }
  649. this.cat_id = this.list[0].id;
  650. if ((this.cat_style.cat_style === '5' || this.cat_style.cat_style === '10') && this.list[0].child.length > 0) {
  651. this.cat_id = this.list[0].child[0].id;
  652. }
  653. const res = await this.$request({
  654. url: this.$api.default.goods_list,
  655. method: 'get',
  656. data: {
  657. page: 1,
  658. cat_id: this.cat_id,
  659. }
  660. });
  661. if (res.code === 0) {
  662. this.goods_list = res.data.list;
  663. this.page_count = res.data.pagination.page_count;
  664. }
  665. } else {
  666. this.search_bool = false;
  667. }
  668. }
  669. }
  670. }
  671. },
  672. onLoad(options) {
  673. this.options = options;
  674. setTimeout(() => {
  675. this.tabbarbool = this.$children[0].tabbarbool;
  676. }, 500);
  677. this.cat_id = options.cat_id;
  678. this.first_id = options.cat_id;
  679. if (options.first_id && options.select_cat_id) {
  680. this.requestCat(options.first_id, options.select_cat_id).then(() => {
  681. this.loading = true;
  682. });
  683. } else if (!options.first_id && options.select_cat_id) {
  684. this.requestCat('', options.select_cat_id).then(() => {
  685. this.loading = true;
  686. });
  687. } else if (!options.first_id && !options.select_cat_id) {
  688. this.requestCat(options.cat_id).then(() => {
  689. this.loading = true;
  690. });
  691. }
  692. // #ifdef MP-WEIXIN
  693. wx.showShareMenu({
  694. menus: ['shareAppMessage', 'shareTimeline']
  695. });
  696. // #endif
  697. },
  698. onShareAppMessage() {
  699. return this.$shareAppMessage({
  700. path: '/pages/cats/cats',
  701. title: this.$children[0].navigationBarTitle,
  702. params: {
  703. cat_id: this.first_id,
  704. first_id: this.first_id,
  705. select_cat_id: this.select_cat_id
  706. }
  707. });
  708. },
  709. // #ifdef MP-WEIXIN
  710. onShareTimeline() {
  711. return this.$shareTimeline({
  712. title: this.mall.setting.share_title ? this.mall.setting.share_title : this.mall.name,
  713. query: {
  714. cat_id: this.first_id,
  715. first_id: this.first_id,
  716. select_cat_id: this.select_cat_id
  717. }
  718. });
  719. },
  720. // #endif
  721. }
  722. </script>
  723. <style lang="scss" scoped>
  724. .app-search {
  725. position: fixed;
  726. top: var(--window-top);
  727. left: 0;
  728. z-index: 1000;
  729. }
  730. .empty-search {
  731. height: #{88upx};
  732. width: #{750upx};
  733. background: #f7f7f7;
  734. }
  735. .margin-fixed {
  736. margin-top: #{88upx};
  737. }
  738. .app-top {
  739. width: $screen-width;
  740. }
  741. </style>