| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161 |
- <template>
- <view class="common-page">
- <!-- <view class="search-box" @click="toSearchList">
- </view> -->
- <u-search v-model="search" bgColor="#fff" placeholder="请输入关键词"></u-search>
- <FilterBar :currentCateId="cateid" @change="handleFilter"/>
- <view class="list-box">
- <CommercePart :data="data"></CommercePart>
- </view>
- <tabbarCom current="2"></tabbarCom>
- </view>
- </template>
- <script>
- import tabbarCom from "@/components/tabbar/tabbar.vue"
- import CommercePart from "@/components/CommercePart.vue";
- import FilterBar from "./filterBar.vue";
- import {
- getGoodList
- } from "@/common/api/good.js";
- export default {
- components: {
- tabbarCom,
- CommercePart,
- FilterBar
- },
- data() {
- return {
- page: 1,
- pageSize: 10,
- total: 0,
- search: "",
- sort: "",
- cateid: "",
- subCateId: '',
- sortType: "",
- data: [],
- };
- },
- onShow() {
- const currentCateid = uni.getStorageSync('currentCateid')
- if (currentCateid) {
- this.cateid = currentCateid
- } else {
- this.cateid = ""
- this.$nextTick(() => {
- this._getGoodList(true);
- })
- }
- },
- onReachBottom() {
- this._getGoodList();
- },
- onShareAppMessage(res) {
- if (res.from === 'button') { // 来自页面内分享按钮
- console.log(res.target)
- }
- let userInfo = uni.getStorageSync('userInfo')
- userInfo = userInfo && JSON.parse(userInfo) || {}
- let params = {}
- if (userInfo.id) {
- params = {
- id: userInfo.id
- }
- }
- let configs = uni.getStorageSync('configs') || {}
- return {
- title: configs.shop_share_title,
- imageUrl: configs.shop_share_img,
- path: `/pages/productCenter/productCenter${this.$stringPageOptions(params)}`
- }
- },
- onShareTimeline(res) {
- if (res.from === 'button') { // 来自页面内分享按钮
- console.log(res.target)
- }
- let userInfo = uni.getStorageSync('userInfo')
- userInfo = userInfo && JSON.parse(userInfo) || {}
- let params = {}
- if (userInfo.id) {
- params = {
- id: userInfo.id
- }
- }
- let configs = uni.getStorageSync('configs') || {}
- return {
- title: configs.shop_share_title,
- imageUrl: configs.shop_share_img,
- path: `/pages/productCenter/productCenter${this.$stringPageOptions(params)}`
- }
- },
- computed: {
- getGoodListParam() {
- return {
- cateid: this.cateid,
- subCateId: this.subCateId,
- sort: this.sort,
- sortType: this.sortType,
- name: this.search,
- }
- }
- },
- watch: {
- getGoodListParam() {
- this._getGoodList(true);
- },
- },
- methods: {
- _getGoodList(initFlag) {
- if (!initFlag) {
- if (this.page * this.pageSize < this.total) {
- this.page++
- } else {
- return
- }
- } else {
- this.page = 1
- this.total = 0
- this.data = []
- }
- let params = {
- cateid: this.cateid && this.subCateId ? this.subCateId : this.cateid,
- sort: this.sort,
- sortType: this.sortType,
- page: this.page,
- pageSize: this.pageSize,
- goods_kind: "线上商品",
- name: this.search,
- }
- getGoodList(params).then(({
- data = {}
- }) => {
- this.data = this.data.concat(data.list)
- this.total = data.page.total
- });
- },
- handleFilter({
- sort,
- sortType,
- cateid,
- subCateId
- }) {
- console.log(cateid, subCateId)
- this.sort = sort;
- this.sortType = sortType;
- this.cateid = cateid || "";
- this.subCateId = subCateId || ''
- },
- },
- };
- </script>
- <style lang="scss" scoped>
- .common-page {
- padding: 25rpx20rpx;
- height: 100vh;
- background-color: $primary-bg-color;
- }
- </style>
|