229 lines
7.0 KiB
Vue
229 lines
7.0 KiB
Vue
<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'}">
|
|
<score-list id="myComponent" :dataList="dataList" v-if="dataList.length!=0"></score-list>
|
|
<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>
|
|
<view class="posia" v-if="cartNum!=0"><view>{{cartNum}}</view></view>
|
|
</view>
|
|
</view>
|
|
</navigator>
|
|
<!-- 弹框授权 -->
|
|
<empower @buttonH="buttonH" :vision="vision" :isWhere="2"></empower>
|
|
<!-- 弹框 -->
|
|
<auth-phone v-if="isShowP"></auth-phone>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
import scoreList from '@/components/score-list.vue';
|
|
export default {
|
|
components:{
|
|
scoreList
|
|
},
|
|
data() {
|
|
return {
|
|
titleList:[],
|
|
imgList:[],
|
|
statusHNH:uni.getStorageSync('statusHNH'),
|
|
publicColor:uni.getStorageSync('publicColor'),
|
|
activeIndex:0,
|
|
shopCate:['综合','最新','兑换量','积分'],
|
|
titleHeight:'',//标题高度
|
|
dataList:[],
|
|
searchVal:'',//关键词搜索
|
|
type:'normal',//type=normal综合 newest=最新
|
|
sort_field:'',//排序字段 score=积分 num=兑换量
|
|
sort_value:'asc',//排序值 asc=升序 desc=降序
|
|
cishu:0,
|
|
cartNum:0,
|
|
vision:false,
|
|
isShowP:false,
|
|
}
|
|
},
|
|
onShow() {
|
|
this.$toolAll.tools.isLogin();
|
|
this.cartNumEv();
|
|
},
|
|
onShareAppMessage() {
|
|
var shareObj = {
|
|
path: `/pagesA/pointsMall/pointsMall?invite_code=${uni.getStorageSync('invite_code')}`, // 默认是当前页面,必须是以‘/’开头的完整路径
|
|
};
|
|
return shareObj;
|
|
},
|
|
onLoad(options) {
|
|
if(uni.getStorageSync('is_active')!=1){this.vision = true;}
|
|
if(options.invite_code!='' && options.invite_code!=undefined){
|
|
this.loginEv(options.invite_code);
|
|
} else if(options.source_code!='' && options.source_code!=undefined){
|
|
this.loginEv('',options.source_code,options.channel);
|
|
}
|
|
this.titleList = uni.getStorageSync('footTitle')
|
|
this.imgList = uni.getStorageSync('footimg')
|
|
// 缓存状态栏+标题栏的高度
|
|
const query = wx.createSelectorQuery()
|
|
query.select('.search-input-box').boundingClientRect((rect) => {
|
|
// console.log('状态栏+标题栏:',rect.height);
|
|
this.titleHeight = rect.height
|
|
}).exec()
|
|
this.checkList();
|
|
let maiOjb = {
|
|
e:12,//进入商城
|
|
t:new Date().getTime()//当前时间戳
|
|
}
|
|
this.$toolAll.tools.maiDian(maiOjb)
|
|
},
|
|
methods: {
|
|
loginEv(invite_code='',source='',channel=''){
|
|
uni.login({
|
|
provider: 'weixin',
|
|
success: (res)=> {
|
|
if (res.code) {
|
|
var params = {
|
|
code:res.code,
|
|
invite_code:invite_code,//用户邀请码
|
|
source_code:source,
|
|
channel:channel
|
|
}
|
|
this.$requst.post('user/login',params).then(res => {
|
|
if(res.data.token!=''){
|
|
if(res.data.is_active==0) {
|
|
this.haveImg = false;
|
|
this.vision = true;
|
|
}
|
|
}
|
|
},error => {})
|
|
}
|
|
},
|
|
});
|
|
},
|
|
buttonH(e){//授权成功
|
|
this.haveImg = e
|
|
if(e) {
|
|
this.vision = false
|
|
this.isShowP = true
|
|
}
|
|
},
|
|
cartNumEv(){//购物车数量
|
|
this.$requst.post('order/shopping-cart-count',{type:'score'}).then(res=>{
|
|
if(res.code==0){
|
|
this.cartNum = res.data.count;
|
|
}
|
|
})
|
|
},
|
|
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;}
|
|
.activecate,.shopMo{border-radius: 20rpx;text-align: center;background-color: #f2f2f2;color: #333333;padding: 16rpx 25rpx;width: 100rpx;}
|
|
.activecate{color: #FFFFFF;}
|
|
.activecate image{
|
|
-webkit-filter: invert(1); /* Chrome, Safari, Opera */
|
|
filter: invert(1);
|
|
}
|
|
</style>
|