cats.vue 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783
  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. :goodsLoading="goodsLoading"
  61. ></style-five>
  62. </view>
  63. <!-- 样式六 -->
  64. <view v-else-if="cat_style.cat_style === '6'" class="margin-fixed">
  65. <style-six
  66. :list="list"
  67. :setHeight="setHeight"
  68. :activeIndex="activeIndex"
  69. :goods="goods"
  70. :botHeight="botHeight"
  71. @active="activeThree"
  72. @route_advert="route_advert"
  73. :theme="getTheme"
  74. ></style-six>
  75. </view>
  76. <!-- 样式七 -->
  77. <view v-else-if="cat_style.cat_style === '7'" class="margin-fixed">
  78. <style-seven
  79. :list="list"
  80. :setHeight="setHeight"
  81. :activeIndex="activeIndex"
  82. :goods="goods"
  83. :botHeight="botHeight"
  84. :windowHeight="windowHeight"
  85. :windowWidth="windowWidth"
  86. @active="activeThree"
  87. @route_advert="route_advert"
  88. :theme="getTheme"
  89. ></style-seven>
  90. </view>
  91. <!-- 样式八 -->
  92. <view v-else-if="cat_style.cat_style === '8'" class="margin-fixed">
  93. <style-eight
  94. :list="list"
  95. :goods_list="goods_list"
  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. let cat_style = this.cat_style.cat_style;
  257. if (cat_style === '3' || cat_style === '1') return;
  258. if (this.page < this.page_count) {
  259. this.page++;
  260. this.$request({
  261. url: this.$api.default.goods_list,
  262. method: 'get',
  263. data: {
  264. page: this.page,
  265. cat_id: this.cat_id,
  266. }
  267. }).then(res => {
  268. if (res.code === 0) {
  269. if (cat_style === '8' || cat_style === '5') {
  270. this.goodsLoading = true;
  271. }
  272. this.goods_list.push(...res.data.list);
  273. }
  274. });
  275. } else {
  276. if (cat_style === '8' || cat_style === '5') {
  277. this.goodsLoading = false;
  278. }
  279. uni.showToast({
  280. title: '暂无更多商品',
  281. icon: 'none'
  282. });
  283. }
  284. },
  285. methods: {
  286. onAttr(data) {
  287. this.selectAttr = data;
  288. },
  289. attr({previewUrl, submitUrl, attr_groups, goods}) {
  290. this.previewUrl = previewUrl;
  291. this.submitUrl = submitUrl;
  292. this.attrGroup = attr_groups;
  293. this.item = goods;
  294. this.show = Math.random();
  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. this.list[i].active = false;
  311. }
  312. for (let i = 0; i < this.list.length; i++) {
  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.page_count = res.data.pagination.page_count;
  324. this.goodsLoading = this.page_count > 1;
  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. }
  352. for (let i = 0; i < this.list.length; i++) {
  353. if (this.list[i].id === item.id) {
  354. this.list[i].active = true;
  355. this.activeIndex = i;
  356. }
  357. }
  358. if (this.cat_style.cat_style === '5') this.goods_list = [];
  359. if (this.list[this.activeIndex].child.length === 0) {
  360. this.$request({
  361. url: `${this.$api.default.goods_list}&page=${this.page}&cat_id=${item.id}`
  362. }).then(res => {
  363. let { list, pagination } = res.data;
  364. this.goods_list = list;
  365. this.is_over_goods = true;
  366. this.page = 1;
  367. this.cat_id = item.id;
  368. this.select_cat_id = item.id;
  369. this.page_count = pagination.page_count;
  370. });
  371. } else {
  372. this.$request({
  373. url: `${this.$api.default.goods_list}&page=${this.page}&cat_id=${this.list[this.activeIndex].child[0].id}`
  374. }).then(res => {
  375. let { list, pagination } = res.data;
  376. this.goods_list = list;
  377. this.is_over_goods = true;
  378. this.page = 1;
  379. this.cat_id = this.list[this.activeIndex].child[0].id;
  380. this.select_cat_id = item.id;
  381. this.page_count = pagination.page_count;
  382. });
  383. }
  384. },
  385. async activeTwo({item, index}) {
  386. this.page = 1;
  387. this.activeIndexTwo = index;
  388. this.select_cat_id = item.id;
  389. this.cat_id = item.id;
  390. this.select_cat_id = item.id;
  391. this.is_over_goods = false;
  392. const res = await this.$request({
  393. url: this.$api.default.goods_list,
  394. method: 'get',
  395. data: {
  396. page: 1,
  397. cat_id: item.id
  398. }
  399. });
  400. if (res.code === 0) {
  401. let { list, pagination } = res.data;
  402. this.goods_list = [];
  403. this.goods_list = list;
  404. this.is_over_goods = true;
  405. this.page_count = pagination.page_count;
  406. }
  407. },
  408. activeThree(item) {
  409. this.cat_id = item.id;
  410. this.select_cat_id = item.id;
  411. for (let i = 0; i < this.list.length; i++) {
  412. if (this.list[i].active !== item.active) {
  413. this.list[i].active = false;
  414. }
  415. if (this.list[i].id === item.id) {
  416. this.list[i].active = true;
  417. this.activeIndex = i;
  418. }
  419. }
  420. },
  421. async catLower() {
  422. if (!this.againLower) return;
  423. this.againLower = false;
  424. let goods_list = this.goods_list[this.goods_list.length - 1];
  425. const res = await this.$request({
  426. url: this.$api.default.cat_goods,
  427. method: 'get',
  428. data: {
  429. cat_ids: JSON.stringify(this.cat_ids),
  430. cat_id: goods_list.id,
  431. offset: goods_list.offset
  432. }
  433. });
  434. if (res.code === 0) {
  435. if (res.data.list[0].id === goods_list.id && res.data.list[0].goods_list.length > 0) {
  436. this.goods_list[this.goods_list.length - 1].goods_list.push(...res.data.list[0].goods_list);
  437. this.goods_list[this.goods_list.length - 1].offset = res.data.list[0].offset;
  438. }
  439. for (let i = 1; i < res.data.list.length; i++) {
  440. this.goods_list.push(res.data.list[i]);
  441. }
  442. this.againLower = true;
  443. }
  444. },
  445. activeRequest({item}) {
  446. this.goods_list = [];
  447. console.log(item);
  448. if (item.child.length !== 0) {
  449. this.requestCatList({
  450. item: item.child[0], index: 0
  451. });
  452. }
  453. },
  454. async requestCatList({item, index}) {
  455. this.page = 1;
  456. this.cat_id = item.id;
  457. this.select_cat_id = item.id;
  458. this.activeIndexTwo = index;
  459. this.goods_list = [];
  460. if (item.child.length !== 0) {
  461. this.is_over_goods = false;
  462. this.cat_ids = [];
  463. for (let i = 0; i < item.child.length; i++) {
  464. this.cat_ids.push(item.child[i].id);
  465. }
  466. const res = await this.$request({
  467. url: this.$api.default.cat_goods,
  468. method: 'get',
  469. data: {
  470. cat_ids: JSON.stringify(this.cat_ids),
  471. cat_id: item.child[0].id,
  472. offset: 0
  473. }
  474. });
  475. if (res.code === 0) {
  476. this.is_over_goods = true;
  477. this.goods_list = res.data.list;
  478. }
  479. }
  480. },
  481. // 求情商品列表
  482. async requestGoods({item, index}) {
  483. this.page = 1;
  484. this.cat_id = item.id;
  485. this.select_cat_id = item.id;
  486. this.goods_list = [];
  487. this.is_over_goods = false;
  488. if (this.cat_style.cat_style === '10' && index !== undefined && this.list[index].child.length !== 0) {
  489. this.activeIndexTwo = 0;
  490. this.cat_id = this.list[index].child[0].id;
  491. }
  492. const res = await this.$request({
  493. url: this.$api.default.goods_list,
  494. method: 'get',
  495. data: {
  496. page: this.page,
  497. cat_id: this.cat_id
  498. }
  499. });
  500. if (res.code === 0) {
  501. this.is_over_goods = true;
  502. this.goods_list = res.data.list;
  503. this.goodsLoading = true;
  504. this.page_count = res.data.pagination.page_count;
  505. }
  506. },
  507. // 分页请求商品
  508. async lower(data) {
  509. if (this.page < this.page_count) {
  510. this.page++;
  511. const res = await this.$request({
  512. url: this.$api.default.goods_list,
  513. method: 'get',
  514. data: {
  515. page: this.page,
  516. cat_id: data.id
  517. }
  518. });
  519. if (res.code === 0) {
  520. this.goods_list.push(...res.data.list);
  521. }
  522. } else {
  523. uni.showToast({
  524. title: '暂无更多商品',
  525. icon: 'none'
  526. })
  527. }
  528. },
  529. // 处理数据
  530. dataProcessing(list) {
  531. for (let i = 0; i < list.length; i += 2) {
  532. if (i + 1 !== list.length) {
  533. this.goods_list.push([list[i], list[i + 1]]);
  534. } else {
  535. this.goods_list.push([list[i]]);
  536. }
  537. }
  538. },
  539. async requestCat(cat_id, select_cat_id) {
  540. this.loading = false;
  541. const res = await this.$request({
  542. url: this.$api.default.cat_list,
  543. method: 'get',
  544. data: {
  545. cat_id: cat_id ? cat_id : '',
  546. select_cat_id: select_cat_id ? select_cat_id : ''
  547. }
  548. });
  549. if (res.code === 0) {
  550. this.list = res.data.list;
  551. // 分类跳转
  552. if (this.cat_style.cat_style === '1' && this.list.length === 0) {
  553. this.search_bool = false;
  554. return;
  555. }
  556. if (this.cat_style.cat_style === '2' || this.cat_style.cat_style === '1') {
  557. return;
  558. }
  559. if (this.cat_style.cat_style === '3' && this.list.length === 0) {
  560. this.search_bool = false;
  561. return;
  562. }
  563. if (cat_id || select_cat_id) {
  564. if (this.cat_style.cat_style === '11') {
  565. this.cat_ids = [];
  566. this.list.map((item, index) => {
  567. if (item.active) {
  568. this.activeIndex = index;
  569. }
  570. });
  571. if (this.list[this.activeIndex].child.length === 0) return;
  572. for (let i = 0; i < this.list[this.activeIndex].child[0].child.length; i++) {
  573. this.cat_ids.push(this.list[this.activeIndex].child[0].child[i].id);
  574. }
  575. if (this.cat_ids.length === 0) return;
  576. const res = await this.$request({
  577. url: this.$api.default.cat_goods,
  578. method: 'get',
  579. data: {
  580. cat_ids: JSON.stringify(this.cat_ids),
  581. cat_id: this.cat_ids[0],
  582. offset: 0
  583. }
  584. });
  585. if (res.code === 0) {
  586. this.goods_list = res.data.list;
  587. }
  588. return;
  589. }
  590. if (this.cat_style.cat_style === '6' || this.cat_style.cat_style === '7') {
  591. this.list.map((item, index) => {
  592. if (item.active) {
  593. this.activeIndex = index;
  594. }
  595. });
  596. return;
  597. }
  598. if (this.list.length > 0) {
  599. for (let i = 0; i < this.list.length; i++) {
  600. if (this.list[i].active) {
  601. this.cat_id = this.list[i].id;
  602. }
  603. }
  604. }
  605. if ((this.cat_style.cat_style === '5' || this.cat_style.cat_style === '10') && this.list.length > 0 && this.list[0].child.length > 0) {
  606. for (let i = 0; i < this.list.length; i++) {
  607. if (this.list[i].active) {
  608. this.cat_id = this.list[i].child[0].id;
  609. }
  610. }
  611. }
  612. if (this.list.length === 0 && (this.cat_style.cat_style === '4')) {
  613. this.search_bool = false;
  614. return;
  615. }
  616. const res = await this.$request({
  617. url: this.$api.default.goods_list,
  618. method: 'get',
  619. data: {
  620. page: 1,
  621. cat_id: this.cat_id,
  622. }
  623. });
  624. if (res.code === 0) {
  625. this.goods_list = res.data.list;
  626. this.page_count = res.data.pagination.page_count;
  627. if (this.list.length === 0 && this.goods_list.length === 0) {
  628. this.search_bool = false;
  629. }
  630. }
  631. } else {
  632. if (this.list.length > 0) {
  633. if (this.cat_style.cat_style === '11') {
  634. this.cat_ids = [];
  635. if (this.list.length === 0 || this.list[0].child.length === 0) return;
  636. for (let i = 0; i < this.list[0].child[0].child.length; i++) {
  637. this.cat_ids.push(this.list[0].child[0].child[i].id);
  638. }
  639. if (this.cat_ids.length === 0) return;
  640. const res = await this.$request({
  641. url: this.$api.default.cat_goods,
  642. method: 'get',
  643. data: {
  644. cat_ids: JSON.stringify(this.cat_ids),
  645. cat_id: this.cat_ids[0],
  646. offset: 0
  647. }
  648. });
  649. if (res.code === 0) {
  650. this.goods_list = res.data.list;
  651. }
  652. return;
  653. }
  654. this.cat_id = this.list[0].id;
  655. if ((this.cat_style.cat_style === '5' || this.cat_style.cat_style === '10') && this.list[0].child.length > 0) {
  656. this.cat_id = this.list[0].child[0].id;
  657. }
  658. const res = await this.$request({
  659. url: this.$api.default.goods_list,
  660. method: 'get',
  661. data: {
  662. page: 1,
  663. cat_id: this.cat_id,
  664. }
  665. });
  666. if (res.code === 0) {
  667. this.goods_list = res.data.list;
  668. this.page_count = res.data.pagination.page_count;
  669. }
  670. } else {
  671. this.search_bool = false;
  672. }
  673. }
  674. }
  675. }
  676. },
  677. onLoad(options) { this.$commonLoad.onload(options);
  678. this.$commonLoad.onload();
  679. this.options = options;
  680. setTimeout(() => {
  681. this.tabbarbool = this.$children[0].tabbarbool;
  682. }, 500);
  683. this.cat_id = options.cat_id;
  684. this.first_id = options.cat_id;
  685. if (options.first_id && options.select_cat_id) {
  686. this.requestCat(options.first_id, options.select_cat_id).then(() => {
  687. this.loading = true;
  688. });
  689. } else if (!options.first_id && options.select_cat_id) {
  690. this.requestCat('', options.select_cat_id).then(() => {
  691. this.loading = true;
  692. });
  693. } else if (!options.first_id && !options.select_cat_id) {
  694. this.requestCat(options.cat_id).then(() => {
  695. this.loading = true;
  696. });
  697. }
  698. // #ifdef MP-WEIXIN
  699. wx.showShareMenu({
  700. menus: ['shareAppMessage', 'shareTimeline']
  701. });
  702. // #endif
  703. },
  704. // #ifdef MP
  705. onShareAppMessage() {
  706. return this.$shareAppMessage({
  707. path: '/pages/cats/cats',
  708. title: this.$children[0].navigationBarTitle,
  709. params: {
  710. cat_id: this.first_id,
  711. first_id: this.first_id,
  712. select_cat_id: this.select_cat_id
  713. }
  714. });
  715. },
  716. // #endif
  717. // #ifdef MP-WEIXIN
  718. onShareTimeline() {
  719. let { setting, name } = this.mall.setting;
  720. return this.$shareTimeline({
  721. title: setting.share_title ? setting.share_title : name,
  722. query: {
  723. cat_id: this.first_id,
  724. first_id: this.first_id,
  725. select_cat_id: this.select_cat_id
  726. }
  727. });
  728. },
  729. // #endif
  730. }
  731. </script>
  732. <style lang="scss" scoped>
  733. .app-search {
  734. position: fixed;
  735. top: 0;
  736. left: 0;
  737. z-index: 1500;
  738. }
  739. .empty-search {
  740. height: #{88upx};
  741. width: #{750upx};
  742. background: #f7f7f7;
  743. }
  744. .margin-fixed {
  745. margin-top: #{88upx};
  746. }
  747. .app-top {
  748. width: $screen-width;
  749. }
  750. </style>