123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452 |
- <template>
- <view>
- <!-- <view class="product_box">
- <view class="to_bottom" v-if="!productList.length"> -----还没有积分产品-----</view>
- <view class="product_list" >
- <!-- Vue3 项目部分小程序端事件延迟或调用失败 在执行事件的元素上添加 data-eventsync="true" 属性以解决此问题
- <view @click="toDetail(item)" data-eventsync="true" class="product_item" v-for="(item,index) in productList" :key="index" >
- <image class="product_image" :src="item.thumb" mode=""></image>
- <view class="product_name"><text>{{item.name}}</text></view>
- <view class="stock_price">
- <view class="product_price">
- <text>{{item.score}} 积分</text>
- </view>
- </view>
- </view>
- </view>
- </view>
- <view class="search_fixed" >
- <view class="search_box">
- <input class="search_input" type="text" v-model="requestParam.name" @input="searchChange" placeholder="请输入产品名称搜索" />
- <button class="search_btn" @click.stop="searchOpen()" data-eventsync="true"> 搜索</button>
- </view>
- </view>
- <view class="to_bottom" v-if="isLast"> -----到底了-----</view>-->
- <view class="product_box">
- <!-- <view class="to_bottom" v-if="!productList.length"> -----还没有积分产品-----</view> -->
- <view class="product_list" >
- <!-- Vue3 项目部分小程序端事件延迟或调用失败 在执行事件的元素上添加 data-eventsync="true" 属性以解决此问题 -->
- <view @click="toDetail(item)" data-eventsync="true" class="product_item" v-for="(item,index) in productList" :key="index" >
- <image class="product_image" :src="item.thumb" mode=""></image>
- <view class="product_name"><text>{{item.name}}</text></view>
- <view class="stock_price">
- <view class="product_price">
- <text>{{item.score}} 积分</text>
- </view>
- </view>
- </view>
- </view>
- </view>
- <view class="header_fixed" >
- <view class="user_title">
- <view class="user_prc">
- <image src="../../static/logo2.jpg" ></image>
- </view>
- <view class="title">
- <view class="">
- 王先生
- </view>
- <view class="">
- 5000积分
- </view>
- </view>
- </view>
- <view class="search">
- <view class="search_box">
- <view class="search_input">
- <input type="text" placeholder="一年级系统班" />
- </view>
- <view class="search_icon">
- <uni-icons type="search" size="20"></uni-icons>
- </view>
- </view>
- </view>
- <view class="course_option">
- <view class="option_name">
- 综合
- </view>
- <view class="option_name">
- 我可兑换
- </view>
- <view class="option_name">
- 销量
- </view>
- <view class="option_name">
- 积分
- </view>
- </view>
- </view>
- <view class="to_bottom" > -----到底了-----</view>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- // 产品列表
- productList:[],
- // 请求参数
- requestParam:{
- name:"",
- page:1,
- },
- // 是否最后一页
- isLast:false,
- // 是否请求中
- isReqing:false,
- }
- },
- onLoad() {
-
- },
- onShow() {
- // 没有数据的话,或者请求中,不允许刷新
- if( this.isReqing ) return ;
- // 请求参数
- this.requestParam.name = "";
- // 请求参数
- this.requestParam.page = 1;
- // 是否是最后一页
- this.isLast = false;
- // 设置请求中
- this.isReqing = true;
- // 请求
- this.$http.request('api/score_product/get_list',this.requestParam).then((re)=>{
- // 设置非请求中
- this.isReqing = false;
- // 成功结果
- if( re.code == 'success' ){
- if(re.data.last_page <= this.requestParam.page ) this.isLast = true;
- this.productList = re.data.data;
- }
- });
- },
- onPullDownRefresh() {
- // 如果请求中,不允许请求,
- if( this.isReqing ) return uni.stopPullDownRefresh();
- // 初始化页码为1
- this.requestParam.page = 1;
- // 是否是最后一页
- this.isLast = false;
- // 设置请求中
- this.isReqing = true;
- // 请求列表
- this.$http.request('api/score_product/get_list',this.requestParam).then((re)=>{
- // 设置非请求中
- this.isReqing = false;
- // 成功结果
- if( re.code == 'success' ){
- if(re.data.last_page <= this.requestParam.page ) this.isLast = true;
- this.productList = re.data.data;
- }
- });
- uni.stopPullDownRefresh();
- },
- onReachBottom() {
- // 如果页码是0,避免第一页重复
- if( this.requestParam.page < 1 ) return;
- // 最后一页不再请求
- if( this.isLast ) return;
- // 请求中,不再请求
- if( this.isReqing ) return;
- // 增加一页
- this.requestParam.page = this.requestParam.page+1;
- // 设置请求中
- this.isReqing = true;
- // 请求列表
- this.$http.request('api/score_product/get_list',this.requestParam).then((re)=>{
- // 设置非请求中
- this.isReqing = false;
- // 成功结果
- if( re.code == 'success' ){
- // 最后一页
- if(re.data.last_page <= this.requestParam.page ) this.isLast = true;
- // 追加数据
- this.productList.push(...re.data.data);
- }
- });
- },
- methods: {
- searchChange(e){
- // 如果没有搜索词
- if( !this.requestParam.name ){
- this.searchOpen();
- }
- },
- searchOpen(){
- // 请求中,不再请求
- if( this.isReqing ) return;
- // 是否是最后一页
- this.isLast = false;
- // 初始化页码为1
- this.requestParam.page = 1;
- // 设置请求中
- this.isReqing = true;
- // 请求列表
- this.$http.request('api/score_product/get_list',this.requestParam).then((re)=>{
- // 设置非请求中
- this.isReqing = false;
- // 成功结果
- if( re.code == 'success' ){
- this.productList = re.data.data;
- if( re.data.data.length && re.data.last_page >= this.requestParam.page ) this.isLast = true;
- }
- });
- },
- toDetail(item){
- uni.navigateTo({
- url:"/pages/score/product?id="+item.id,
- })
- }
- }
- }
- </script>
- <style lang="less">
- // .search_fixed{
- // top: var(--window-top);
- // left: 0rpx;
- // width: 750rpx;
- // display: block;
- // position: fixed;
- // margin: 0rpx auto;
- // padding: 20rpx 0rpx;
- // background-color: #FFFFFF;
- // .search_box{
- // width: 750rpx;
- // height: 60rpx;
- // display: block;
- // position: relative;
- // .search_input{
- // z-index: 0;
- // width: 590rpx;
- // height: 56rpx;
- // display: block;
- // font-size: 24rpx;
- // position: relative;
- // border-top-left-radius: 40rpx;
- // border-bottom-left-radius: 40rpx;
- // padding-left: 20rpx;
- // margin-left: 35rpx;
- // border: 2rpx solid #dddddd;
- // }
- // .search_btn{
- // top: 0rpx;
- // z-index: 9;
- // left: 610rpx;
- // color: #FFFFFF;
- // position: absolute;
- // display: block;
- // width: 120rpx;
- // height: 60rpx;
- // font-size: 24rpx;
- // margin: 0rpx 0rpx;
- // padding: 0rpx 0rpx;
- // line-height: 60rpx;
- // border-radius: 40rpx;
- // background-color: #E03519;
- // }
- // }
- // }
- // .product_box{
- // display: block;
- // overflow: hidden;
- // margin: 0rpx auto;
- // margin-top: 120rpx;
- // padding: 0rpx 35rpx;
- // .product_list{
- // display: block;
- // overflow: hidden;
- // margin: 0rpx auto;
- // .product_item{
- // float: left;
- // width: 320rpx;
- // display: block;
- // overflow: hidden;
- // margin: 20rpx 0rpx;
- // margin-right: 20rpx;
- // background-color: #FFFFFF;
- // border-radius: 20rpx;
- // .product_image{
- // width: 320rpx;
- // height: 320rpx;
- // }
- // .product_name{
- // height: 80rpx;
- // font-size: 26rpx;
- // line-height: 40rpx;
- // overflow: hidden;
- // padding: 10rpx 10rpx;
- // }
- // .product_spec{
- // color: #999999;
- // font-size: 22rpx;
- // line-height: 30rpx;
- // padding: 0rpx 10rpx;
- // }
- // .stock_price{
- // color: #dddddd;
- // font-size: 20rpx;
- // overflow: hidden;
- // line-height: 30rpx;
- // padding: 0rpx 10rpx;
- // .product_price{
- // float: left;
- // color: red;
- // font-size: 30rpx;
- // line-height: 60rpx;
- // .product_market{
- // font-size: 24rpx;
- // color: #999999;
- // line-height: 30rpx;
- // vertical-align: top;
- // text-decoration: line-through;
- // }
- // }
- // .product_stock{
- // float: right;
- // font-size: 20rpx;
- // line-height: 60rpx;
- // }
- // }
- // }
- // .product_item:nth-child(even){
- // margin-right: 0rpx;
- // }
- // }
- // }
-
- .header_fixed{
- width: 750rpx;
- position: fixed;
- top: 0rpx;
- background-color: #fff;
- .user_title{
- width: 690rpx;
- margin: 30rpx auto;
- display: flex;
- .user_prc{
- width: 100rpx;
- height: 100rpx;
- border-radius: 50%;
- image{
- border-radius: 50%;
- width: 100%;
- height: 100%;
- }
- }
- .title{
- margin-left: 30rpx;
- }
- }
- .search{
- width: 690rpx;
- margin: 30rpx auto;
- padding-top: 1rpx;
- .search_box{
- width: 690rpx;
- height: 70rpx;
- border: 2rpx solid #c2c2c2;
- position: relative;
- border-radius: 60rpx;
- .search_input{
- position: absolute;
- width: 600rpx;
- right: 0rpx;
- top: 10rpx;
- }
- .search_icon{
- position: absolute;
- width: 90rpx;
- left: 0rpx;
- top: 15rpx;
- text-align: center;
- }
- }
- }
- .course_option{
- display: flex;
- width: 690rpx;
- margin: 0rpx auto;
- justify-content: space-between;
- .option_name{
- text-align: center;
- width: 150rpx;
- height: 50rpx;
- line-height: 50rpx;
- font-size: 24rpx;
- border-radius: 60rpx;
- margin: 20rpx 0rpx;
- background-color: #e2e2e2;
- }
- }
- }
- .product_box{
- display: block;
- overflow: hidden;
- margin: 0rpx auto;
- margin-top: 380rpx;
- padding: 0rpx 35rpx;
- .product_list{
- display: block;
- overflow: hidden;
- margin: 0rpx auto;
- .product_item{
- float: left;
- width: 320rpx;
- display: block;
- overflow: hidden;
- margin: 20rpx 0rpx;
- margin-right: 20rpx;
- background-color: #FFFFFF;
- border-radius: 20rpx;
- .product_image{
- width: 320rpx;
- height: 320rpx;
- }
- .product_name{
- height: 80rpx;
- font-size: 26rpx;
- line-height: 40rpx;
- overflow: hidden;
- padding: 10rpx 10rpx;
- }
- .product_spec{
- color: #999999;
- font-size: 22rpx;
- line-height: 30rpx;
- padding: 0rpx 10rpx;
- }
- .stock_price{
- color: #dddddd;
- font-size: 20rpx;
- overflow: hidden;
- line-height: 30rpx;
- padding: 0rpx 10rpx;
- .product_price{
- float: left;
- color: red;
- font-size: 30rpx;
- line-height: 60rpx;
- .product_market{
- font-size: 24rpx;
- color: #999999;
- line-height: 30rpx;
- vertical-align: top;
- text-decoration: line-through;
- }
- }
- .product_stock{
- float: right;
- font-size: 20rpx;
- line-height: 60rpx;
- }
- }
- }
- .product_item:nth-child(even){
- margin-right: 0rpx;
- }
- }
- }
- </style>
|