hengmei-two/pagesA/pointsMall/pointsMall.vue

185 lines
5.8 KiB
Vue
Raw Normal View History

2021-10-22 03:07:32 +00:00
<template>
<view>
<!-- 状态栏 -->
<status-nav :titleVal="'积分商城'" :statusTitle="true"></status-nav>
<!-- 搜索输入框 -->
<view class="search-input-box bacf poszy jf-input-box" :style="{top: statusHNH+'px'}">
<view class="disac pad-zy30 mar-s20">
<!-- 输入框 -->
<input class="width100 fon34 radius10" @confirm="searchKey" type="text" v-model="searchVal" placeholder="请输入商品名称"/>
<!-- 搜索 -->
<view class="flexs mar-z30 radius10 pad-zy40 fon34 colf" @tap="searchKey" :style="{background:publicColor}">搜索</view>
</view>
<!-- 分类标题 -->
<view class="disjbac pad-zy20 pad-s20 bacf fon24">
<view v-for="(item,index) in shopCate" class="disjcac" @tap="chooseShopCate(index)" :class="activeIndex==index?'activecate':'shopMo'" :style="{background:activeIndex==index?publicColor:'#F2F2F2'}" :key="index">
<span>{{item}}</span>
<view class="disjcac fc mar-z10" v-if="index==2 || index==3">
<image src="/static/public/address-top.png" mode=""></image>
<image src="/static/public/address-down.png" mode=""></image>
</view>
</view>
</view>
</view>
<!-- 数据列表 -->
<view :style="{marginTop:statusHNH+titleHeight+'px'}">
2021-11-02 10:23:53 +00:00
<score-list id="myComponent" :dataList="dataList" v-if="dataList.length!=0"></score-list>
2021-10-22 03:07:32 +00:00
<nothing-page v-if="dataList.length==0" :content="`暂无更多${searchVal}积分商品`"></nothing-page>
</view>
<!-- 底部tab -->
<foot-tab :titleList="titleList" :imgList="imgList" :newcurrent='4'></foot-tab>
<!-- 购物车 -->
<navigator url="/pagesA/shopCart/shopCart?isScore=score" hover-class="none">
<view class="cart-box">
<view class="posir">
<image src="/static/public/cart.png" mode="aspectFill"></image>
2021-11-02 10:23:53 +00:00
<view class="posia" v-if="cartNum!=0"><view>{{cartNum}}</view></view>
2021-10-22 03:07:32 +00:00
</view>
</view>
</navigator>
2022-03-04 08:48:40 +00:00
<!-- 用户信息授权手机号授权 -->
<auth-userInfo-mobileInfo></auth-userInfo-mobileInfo>
2021-10-22 03:07:32 +00:00
</view>
</template>
<script>
2021-11-02 10:23:53 +00:00
import scoreList from '@/components/score-list.vue';
2021-10-22 03:07:32 +00:00
export default {
components:{
2021-11-02 10:23:53 +00:00
scoreList
2021-10-22 03:07:32 +00:00
},
data() {
return {
titleList:[],
imgList:[],
2022-03-04 08:48:40 +00:00
statusHNH:uni.getStorageSync('electric_nav_height'),
2021-10-22 03:07:32 +00:00
publicColor:uni.getStorageSync('publicColor'),
activeIndex:0,
shopCate:['综合','最新','兑换量','积分'],
titleHeight:'',//标题高度
dataList:[],
searchVal:'',//关键词搜索
type:'normal',//type=normal综合 newest=最新
sort_field:'',//排序字段 score=积分 num=兑换量
sort_value:'asc',//排序值 asc=升序 desc=降序
2021-11-02 10:23:53 +00:00
cishu:0,
2021-12-02 09:31:26 +00:00
cartNum:0,
2021-10-22 03:07:32 +00:00
}
},
onShow() {
2021-11-02 10:23:53 +00:00
this.$toolAll.tools.isLogin();
this.cartNumEv();
2021-10-22 03:07:32 +00:00
},
2021-12-02 09:31:26 +00:00
onLoad(options) {
2021-10-22 03:07:32 +00:00
// 缓存状态栏+标题栏的高度
const query = wx.createSelectorQuery()
query.select('.search-input-box').boundingClientRect((rect) => {
// console.log('状态栏+标题栏:',rect.height);
this.titleHeight = rect.height
}).exec()
2022-03-04 08:48:40 +00:00
this.titleList = uni.getStorageSync('footTitle')
this.imgList = uni.getStorageSync('footimg')
// 调用tools.js中的种植埋点事件
this.$toolAll.tools.plantPoint(12);
2022-03-21 01:44:07 +00:00
if(uni.getStorageSync('phone_active')!=0 && uni.getStorageSync('is_active')!=0){
2022-03-04 08:48:40 +00:00
this.checkList();
2022-01-18 02:43:26 +00:00
}
2021-10-22 03:07:32 +00:00
},
methods: {
2021-11-02 10:23:53 +00:00
cartNumEv(){//购物车数量
this.$requst.post('order/shopping-cart-count',{type:'score'}).then(res=>{
if(res.code==0){
this.cartNum = res.data.count;
}
})
},
2021-10-22 03:07:32 +00:00
checkList(){//查询列表事件
let params = {
keyword:this.searchVal,//商品关键字 支持模糊搜索
page:1,
size:10,
type:this.type,//type=normal综合 newest=最新
sort_field:this.sort_field,//排序字段 score=积分 num=兑换量
sort_value:this.sort_value//排序值 asc=升序 desc=降序
}
this.$requst.post('spu/score',params).then(res=>{
if(res.code==0){
this.dataList = [];
if(res.data.list.length!=0){
res.data.list.forEach(item=>{
let obj = {
id:item.id,
imgSrc: this.$http + item.cover,
saleable:item.saleable,//是否下架
stock:item.stock,//库存
title: item.name,
zhePrice:item.price,
yuanPrice:item.original_price,
integral:item.score,
isTuan:false,
isPing:false,
isXian:false,
isIntegral:true,
grade:item.level_id,
published_at:item.published_at,//发布时间
amount:item.amount,//销量
level_text:item.level_text//会员限制提示 如青铜会员可购买
}
this.dataList.push(obj)
})
} else {
this.$toolAll.tools.showToast('暂无更多积分商品')
}
}
})
},
searchKey(){//搜索事件
if(this.activeIndex==0) {
this.clearVal();
this.type = 'normal';
}
if(this.activeIndex==2 || this.activeIndex==3) this.sort_value = 'asc';
this.checkList();
},
chooseShopCate(index){//大分类选择事件
this.activeIndex = index;
this.type = '';
this.sort_field = '';
if(index==0) this.type = 'normal';
if(index==1) this.type = 'newest';
this.cishu++
if(index==2) {
this.sort_field = 'amount';
if(this.cishu%2==0) {
this.sort_value = 'asc';
} else this.sort_value = 'desc';
}
if(index==3) {
this.sort_field = 'score';
if(this.cishu%2==0) {
this.sort_value = 'asc';
} else this.sort_value = 'desc';
}
this.checkList();
},
clearVal(){
this.type = '';
this.sort_field = '';
}
}
}
</script>
<style>
page{background: #F5F5F5;}
2021-11-02 10:23:53 +00:00
.activecate,.shopMo{border-radius: 20rpx;text-align: center;background-color: #f2f2f2;color: #333333;padding: 16rpx 25rpx;width: 100rpx;}
2021-10-22 03:07:32 +00:00
.activecate{color: #FFFFFF;}
.activecate image{
-webkit-filter: invert(1); /* Chrome, Safari, Opera */
filter: invert(1);
}
</style>