123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301 |
- <template>
- <view>
- <ujp-navbar :title="title"></ujp-navbar>
- <!-- 广告-->
- <!-- <view class="banner">
-
-
- </view> -->
-
- <view class="banner">
-
- <u-swiper bg-color="#fff" v-if="bannerList.length"
- :img-mode="'scaleToFill'" :list="bannerList" @click="clickBanner"
- :name="'picUrl'">
- </u-swiper>
- </view>
- <!-- 标签 -->
- <!-- <view class="banner2">
-
-
-
- <u-tabs :list="list" :is-scroll="false" :current="current" @change="change" >
-
- </u-tabs>
- </view> -->
-
- <!-- 商品 -->
- <view class="commodity">
- <view class="item" v-for="(item,i) in mallList"
- @click="gotoUrl('pages/store/commodityDetails?id='+item.id)"
- :key="i">
- <!--图片 -->
- <view class="picture">
- <u-image v-if="item.pic"
- width="308"
- height="308"
- :src="item.pic" mode="scaleToFill" ></u-image>
- <u-image v-else
- width="308"
- height="308"
- src="@/assets/img/chargesite_default.png" ></u-image>
-
- </view>
- <!-- 商品名 -->
- <view class="title">
- <view class="tag" v-if="item.own">
- <img src="@/assets/img/commodityTag.png" alt="">
- </view>{{item.name}}
- </view>
- <view class="price">
- <view class="number" v-if="item.price">
- <text>¥</text>{{item.price}}
- </view>
- <view class="number2" v-else >
- 来电咨询
- </view>
-
- <view class="buy" v-if="item.price">
- <img src="@/assets/img/antOutline-shopping-cart@3x.png" alt="">
- </view>
- <view class="buy" v-else>
-
- <img src="@/assets/img/arcoDesign-phone@3x.png"
- alt="">
- </view>
- </view>
- </view>
-
-
- </view>
- </view>
- </template>
- <script>
- import * as API from '@/apis/mall.js'
- import * as newsApi from '@/apis/news.js'
- export default {
- data() {
- return {
- mallList:[],
- title:"",
- bannerList: [],
- pageIndex: 1,
- recordsTotal: 0,
- }
- },
- onLoad() {
- this.title=process.car.branchParameter=="youdian"?'优电商城':'51商城'
- },
- onReady() {
- this.getList()
- this.getBannerInfo("store");
-
-
- },
- onReachBottom() {
- if (this.mallList.length < this.recordsTotal) {
- this.myLoadmore();
- }
- },
- methods: {
- clickBanner(index, bl, modout) {
- var uurl = "";
- var mod = {}
- if (modout) {
- mod = modout;
- }else{
- mod =this.bannerList[index]
- }
- mod.clickUrl = mod.linkUrl
-
- if (mod.linkPicUrl && !bl) {
-
- this.showOss = true;
- this.showOssImg = mod.linkPicUrl;
- this.showOssIndex = index;
-
- } else if (mod.clickUrl == null) {
-
- } else if (mod.clickUrl.indexOf('http') == 0) {
-
- window.location = mod.clickUrl + uurl;
- } else if (mod.clickUrl.slice(-5) == 'login' && this.userId) {
-
- } else if (mod.clickUrl.indexOf('#/') == 0) {
- if (mod.clickUrl.indexOf("?") == -1) {
- mod.clickUrl += '?';
- }
- var url = mod.clickUrl.split("#")[1]
- //window.location = mod.clickUrl;
- uni.navigateTo({
- url: url + uurl
- })
- } else if (mod.clickUrl == '#' || mod.clickUrl == '') {
-
- } else {
- uni.navigateTo({
- url: mod.clickUrl + uurl
- })
- }
- },
- getBannerInfo(code, list) {
-
- newsApi.getBannerInfo(code).then((res) => {
- if (list) {
- this[list] = res.data;
- } else {
- this.bannerList = res.data;
- }
-
- //uni.hideLoading()
- //document.getElementsByClassName("uni-swiper-wrapper")[0].parentNode.style="background-color: rgb(255, 255, 255); height: 120px;"
- }).catch(error => {
- uni.showToast({
-
- title: error,
- icon: "none"
- })
- })
- },
- myLoadmore(){
- this.pageIndex += 1;
- this.getList()
- },
- getList(){
- uni.showLoading({
- title: "加载中",
- mask: true,
- })
- API.mallList({
- pageIndex: this.pageIndex,
- pageSize: 20,
- }).then((res) => {
-
- if(this.pageIndex==1){
- this.mallList = res.data.data;
- }else{
- this.mallList = [
- ...this.mallList,
- ...res.data.data
- ];
- }
- uni.hideLoading();
-
- this.recordsTotal = res.data.recordsTotal;
- }).catch(error => {
- uni.showToast({
- title: error,
- icon: "none"
- })
- })
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- page{
- padding-bottom: 50px;
- }
- // 广告
- .banner{
- margin: 24rpx 32rpx;
- border-radius: 16rpx;
-
- img{
-
- width: 100%;
- height: 100%;
- }
- }
-
- .banner2{
- padding: 24rpx 32rpx 0 32rpx;
- border-radius: 16rpx;
- background-color: #fff;
- img{
-
- width: 100%;
- height: 100%;
- }
- }
-
- // 商品
- .commodity{
- background-color: #fff;
- margin: 24rpx 32rpx;
- padding: 24rpx;
- display: flex;
- justify-content: space-between;
- flex-wrap: wrap;
- .item{
- width: 48%;
- margin-bottom: 32rpx;
- // 图片
- .picture{
- width: 308rpx;
- height: 308rpx;
- img{
- width: 100%;
- height: 100%;
- }
- }
- // 商品名
- .title{
- color: rgba(16, 16, 16, 1);
- line-height: 40rpx;
-
- margin-top: 16rpx;
- .tag{
- display: inline-block;
-
- margin-right: 8rpx;
- vertical-align: middle;
- img{
- width: 104rpx;
- height: 32rpx;
- }
- }
- }
- // 价格
- .price{
- display: flex;
- justify-content: space-between;
- align-items: center;
- margin-top: 12rpx;
- .number{
- color: rgba(255, 40, 0, 1);
- font-size: 40rpx;
- text{
- font-size: 24rpx
- }
- }
- .number2{
- color: rgba(255, 40, 0, 1);
- font-size: 32rpx;
- text{
- font-size: 24rpx
- }
- }
- .buy{
- width: 64rpx;
- height: 64rpx;
-
- border-radius: 999px;
- display: flex;
- justify-content: center;
- align-items: center;
- background: linear-gradient(180deg, rgba(255,98,0,1) 0%,rgba(255,40,0,1) 100%);
- img{
- width: 40rpx;
- height: 40rpx;
-
- }
- }
- }
- }
- }
- </style>
|