Browse Source

修改商品详情跳转错误的问题

zyh
anhaogxs 4 years ago
parent
commit
fa00b519ce
  1. 70
      pages/shop/GoodsList/index.vue

70
pages/shop/GoodsList/index.vue

@ -27,8 +27,7 @@
<view class="item" :class="nows ? 'font-color-red' : ''" @click="set_where(3)">新品</view>
</view>
<view class="list acea-row row-between-wrapper" :class="Switch === true ? '' : 'on'" ref="container" v-if="!isIntegral">
<view @click="goGoodsCon(item)" class="item" :class="Switch === true ? '' : 'on'" v-for="(item, productListIndex) in productList"
:key="productListIndex" :title="item.storeName">
<view @click="goGoodsCon(item)" class="item" :class="Switch === true ? '' : 'on'" v-for="(item, productListIndex) in productList" :key="productListIndex" :title="item.storeName">
<view class="pictrue" :class="Switch === true ? '' : 'on'">
<image :src="item.image" :class="Switch === true ? '' : 'on'" />
</view>
@ -46,8 +45,7 @@
</view>
</view>
<view class="list acea-row row-between-wrapper" :class="Switch === true ? '' : 'on'" ref="container" v-if="isIntegral == 'true'">
<view @click="goGoodsCon(item)" class="item" :class="Switch === true ? '' : 'on'" v-for="(item, productListIndex) in productList"
:key="productListIndex" :title="item.storeName">
<view @click="goIntegralGoodsCon(item)" class="item" :class="Switch === true ? '' : 'on'" v-for="(item, productListIndex) in productList" :key="productListIndex" :title="item.storeName">
<view class="pictrue" :class="Switch === true ? '' : 'on'">
<image :src="item.image" :class="Switch === true ? '' : 'on'" />
</view>
@ -69,26 +67,22 @@
<image src="@/static/images/noGood.png" class="image" />
</view>
</view>
<Recommend v-if="productList.length === 0 && where.page > 1" :recommendLoading="recommendLoading"
@changeRecommendLoading="changeRecommendLoading"></Recommend>
<Recommend v-if="productList.length === 0 && where.page > 1" :recommendLoading="recommendLoading" @changeRecommendLoading="changeRecommendLoading"></Recommend>
</view>
</template>
<script>
import Recommend from '@/components/Recommend'
import {
getProducts,
getProductsIntegral
} from '@/api/store'
import Loading from '@/components/Loading'
import Recommend from '@/components/Recommend'
import { getProducts, getProductsIntegral } from '@/api/store'
import Loading from '@/components/Loading'
export default {
export default {
name: 'GoodsList',
components: {
Recommend,
Loading,
},
props: {},
data: function() {
data: function () {
// const { s = "", id = 0, title = "" } = this.$yroute.query;
const s = '',
id = 0,
@ -126,14 +120,13 @@
isIntegral() {
if (this.isIntegral) {
uni.setNavigationBarTitle({
title: '积分商品'
});
title: '积分商品',
})
} else {
uni.setNavigationBarTitle({
title: '商品列表'
});
title: '商品列表',
})
}
},
$yroute(to) {
// if (to.name !== "GoodsList") return;
@ -153,10 +146,8 @@
// }
},
},
mounted: function() {
const {
s = '', id = 0, title = '', isIntegral = false
} = this.$yroute.query;
mounted: function () {
const { s = '', id = 0, title = '', isIntegral = false } = this.$yroute.query
this.where.keyword = s
this.where.isIntegral = isIntegral == 'true' ? 1 : 0
@ -165,7 +156,7 @@
this.getProductList()
},
onReachBottom() {
this.recommendLoading = true;
this.recommendLoading = true
!this.loading && this.getProductList()
},
onHide() {
@ -193,6 +184,15 @@
this.recommendLoading = recommendLoading
},
goGoodsCon(item) {
this.$yrouter.push({
path: '/pages/shop/GoodsCon/index',
query: {
id: item.id,
isIntegral: this.isIntegral,
},
})
},
goIntegralGoodsCon(item) {
this.$yrouter.push({
path: '/pages/shop/IntegralGoodsCon/index',
query: {
@ -203,17 +203,15 @@
},
updateTitle() {
uni.setNavigationBarTitle({
title: this.title
});
title: this.title,
})
// document.title = this.title || this.$yroute.meta.title;
},
getProductList() {
var that = this
this.setWhere()
// if (to.name !== "GoodsList") return;
const {
s = '', id = 0, title = ''
} = this.$yroute.query
const { s = '', id = 0, title = '' } = this.$yroute.query
if (s !== this.where.keyword || id !== this.where.sid) {
this.loadend = false
this.loading = false
@ -240,7 +238,7 @@
that.where.page = that.where.page + 1
})
},
submitForm: function() {
submitForm: function () {
this.$set(this, 'productList', [])
this.where.page = 1
this.loadend = false
@ -248,7 +246,7 @@
this.getProductList()
},
//
set_where: function(index) {
set_where: function (index) {
let that = this
switch (index) {
case 0:
@ -281,7 +279,7 @@
that.getProductList()
},
//where
setWhere: function() {
setWhere: function () {
let that = this
if (that.price === 0) {
that.where.priceOrder = ''
@ -299,16 +297,16 @@
}
that.where.news = that.nows ? '1' : '0'
},
switchTap: function() {
switchTap: function () {
let that = this
that.Switch = !that.Switch
},
},
}
}
</script>
<style scoped lang="less">
.noCommodity {
.noCommodity {
border-top: 3px solid #f5f5f5;
padding-bottom: 1px;
}
}
</style>

Loading…
Cancel
Save