mall views

image.png

cart

<template>
  <div class="cart">
    <div class="cart-list">
      <div
        class="cart-list-item"
        v-for="item in $store.state.cart.cart"
        :key="item.id"
      >
        <div class="cart-l center">
          <van-switch v-model="item.isShow" />
        </div>
        <van-card
          class="cart-c center"
          :price="item.price+'.00'"
          :title="item.title"
          :thumb="item.src"
        />
        <div class="cart-r center">
          <van-stepper
            v-model="item.count"
            theme="round"
          />
        </div>
      </div>
    </div>
    <van-submit-bar
      :price="getAllPrice*100"
      button-text="提交订单"
    />
  </div>
</template>
<script>
import { mapGetters } from 'vuex'
export default {
  data() {
    return {
    }
  },
  computed: {
    // ...mapState({
    //   cart: 'cart/cart'
    // }),
    ...mapGetters({
      getAllPrice: 'cart/getAllPrice'
    })
  }
}
</script>
<style lang="scss" scoped>
.cart {
  padding: 10px;
  .cart-list {
    .cart-list-item {
      display: flex;
      align-items: center;
      border: 1px solid #eee;
      padding: 6px;
      box-sizing: border-box;
      margin-bottom: 10px;
      .van-card {
        background-color: #fff;
      }
      .center {
        display: flex;
        justify-content: center;
      }
      .cart-l {
        flex: 1;
      }
      .cart-c {
        flex: 2;
        .van-card__price-integer {
          font-size: 12px;
        }
      }
      .cart-r {
        flex: 2;
      }
    }
  }
}
</style>

friends

<template>
  <div class="friends">
    this is friends page
  </div>
</template>
<script>
export default {
  data() {
    return {

    }
  }
}
</script>
<style lang="scss" scoped>
</style>

goodsinfo

<template>
  <div class="goods-info">
    <Swiper
      class="my-panel"
      :lunbolist="lunbolist"
    ></Swiper>

    <van-panel
      class="my-panel"
      :title="goodsinfo.title"
    >
      <div class="content">
        <p class="price">
          <span class="new">现价:¥{{goodsinfo.sell_price}}</span>
          <span class="old">原价:¥{{goodsinfo.market_price}}</span>
        </p>
        <p class="number">
          <span>购买数量:</span>
          <van-stepper v-model="value" />
        </p>
        <p class="btn-group">
          <van-button
            type="primary"
            size="small"
            class="pay"
          >立即购买</van-button>
          <van-button
            type="danger"
            size="small"
            @click="addCart"
          >加入购物车</van-button>
        </p>
      </div>
    </van-panel>
    <van-panel
      class="my-panel"
      title="商品信息"
    >
      <div class="content">
        <p>商品货号:{{goodsinfo.goods_no}}</p>
        <p>库存情况:{{goodsinfo.stock_quantity}}件</p>
        <p>上架时间:{{goodsinfo.add_time | datefmt}}</p>
      </div>
    </van-panel>

    <Comment :id="id"></Comment>
  </div>
</template>
<script>

import { getThumImages } from '@/api/photos'
import { getGoodsInfo } from '@/api/goods'
import Swiper from '@/components/Swiper'

import Comment from '@/components/Comment'
export default {
  props: ['id'],
  data() {
    return {
      lunbolist: [],
      goodsinfo: {},
      value: 1
    }
  },
  methods: {
    async getThumImages() {
      const res = await getThumImages(this.id)
      this.lunbolist = res.data.message
    },
    async getGoodsInfo() {
      const res = await getGoodsInfo(this.id)
      this.goodsinfo = res.data.message
    },
    addCart() {
      const goodsInfo = {
        id: this.id,
        title: this.goodsinfo.title,
        src: this.lunbolist[0].src,
        isShow: true,
        price: this.goodsinfo.sell_price,
        count: this.value,
        timer: null
      }
      this.$store.dispatch('cart/addCart', goodsInfo)
    }
  },
  created() {
    this.getThumImages()
    this.getGoodsInfo()
  },
  mounted() {

  },
  components: {
    Swiper,
    Comment
  }
}
</script>
<style lang="scss" >
.goods-info {
  padding: 10px;
  .my-swipe {
    height: 150px;
    text-align: center;
    img {
      width: 50%;
      height: 100%;
    }
  }

  .my-panel {
    border: 1px solid #ddd;
    margin-bottom: 10px;
    .content {
      margin-left: 15px;
      font-size: 12px;
      .price {
        display: flex;
        .new {
          margin-right: 20px;
          color: red;
        }
        .old {
          text-decoration: line-through;
        }
      }
      .number {
        display: flex;
        align-items: center;
      }
      .btn-group {
        .pay {
          margin-right: 20px;
        }
      }
    }
    .van-cell__title {
      font-size: 14px;
      font-weight: 600;
    }
  }
}
</style>

goodslist

<template>
  <div>
    <van-list
      v-model="loading"
      :finished="finished"
      finished-text="没有更多了"
      @load="onLoad"
      class="goods-list"
      offset="0"
    >
      <div
        class="goods-list-item"
        v-for="(good,index) in goods"
        :key="index"
        @click="goDetail('/home/goodsinfo',good.id)"
      >
        <div class="img-box">
          <img v-lazy="good.img_url">
        </div>
        <h2 class="title">
          {{good.title}}
        </h2>
        <div class="info">
          <p class="price">
            <span
              class="new"
              v-price="'现价:¥'"
            >{{good.sell_price}}</span>
            <span
              class="old"
              v-price="'原价:¥'"
            >{{good.market_price}}</span>
          </p>
          <p class="sell">
            <span>热卖中</span>
            <span>剩余{{good.stock_quantity}}件</span>
          </p>
        </div>
      </div>
    </van-list>
  </div>
</template>
<script>
import { getGoods } from '@/api/goods'
// import mixins from '@/mixins'
export default {
  // mixins: [mixins],
  data() {
    return {
      page: 0,
      limit: 6,
      goods: [],
      loading: false,
      finished: false,
      count: 0
    }
  },
  methods: {
    async getGoods() {
      ++this.page
      const res = await getGoods({ page: this.page, limit: this.limit })
      this.goods = this.goods.concat(res.data.message)
      this.count = res.data.count
    },
    async onLoad() {
      // 异步更新数据
      // setTimeout 仅做示例,真实场景中一般为 ajax 请求
      setTimeout(async () => {
        await this.getGoods()

        // 加载状态结束
        this.loading = false

        console.log(this.count)
        // 数据全部加载完成
        if (this.goods.length >= this.count) {
          this.finished = true
        }
      }, 500)
    }
  }
}
</script>
<style lang="scss">
.goods-list {
  padding: 10px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  .goods-list-item {
    width: 48%;
    border: 1px solid #ddd;
    padding: 10px 10px 0 10px;
    box-sizing: border-box;
    margin-bottom: 10px;
    .img-box {
      width: 149px;
      height: 149px;
      img {
        width: 100%;
      }
    }
    .title {
      font-size: 16px;
    }
    .info {
      font-size: 12px;
      .price {
        display: flex;
        justify-content: space-between;
        .new {
          color: red;
        }
        .old {
          text-decoration: line-through;
        }
      }
      .sell {
        display: flex;
        justify-content: space-between;
      }
    }
  }

  .van-list__error-text,
  .van-list__finished-text,
  .van-list__loading {
    width: 100%;
  }
}
</style>

newsinfo

<template>
  <div class="news-info">
    <van-panel
      :title="newsinfo.zhaiyao"
      :status="'阅读'+newsinfo.click+'次'"
    >
      <div class="content">{{newsinfo.content}}</div>
    </van-panel>
    <Comment :id="id"></Comment>
  </div>
</template>
<script>
import { getNewsInfo } from '@/api/news'
import Comment from '@/components/Comment'
export default {
  props: ['id'],
  data() {
    return {
      newsinfo: {}
    }
  },
  methods: {
    async getNewsInfo() {
      const res = await getNewsInfo(this.id)
      this.newsinfo = res.data.message
    }
  },
  created() {
    this.getNewsInfo()
  },
  components: {
    Comment
  }
}
</script>
<style lang="scss">
.news-info {
  padding: 0 10px;
  .van-cell__title {
    font-size: 16px;
    font-weight: 600;
    flex: 2;
  }
  .content {
    text-indent: 2em;
  }
}
</style>

newslist

<template>
  <div class="news-list">
    <van-card
      v-for="item in newslist"
      :key="item.id"
      :title="item.title"
      :thumb="item.img_url"
      :thumb-link="'#/home/newsinfo/'+item.id"
    >
      <template #bottom>
        <div class="btn-group">
          <span class="add-time">{{item.add_time}}</span>
          <span>点击{{item.click}}次</span>
        </div>
      </template>
    </van-card>
  </div>
</template>
<script>
// @ 相当于 绝对路径src
import { getNewsList } from '@/api/news'
export default {
  name: 'NewsList',
  data() {
    return {
      newslist: []
    }
  },
  methods: {
    async getNewsList() {
      const res = await getNewsList()
      this.newslist = res.data.message
    }
  },
  created() {
    this.getNewsList()
    console.log(this.$route.meta.keepAlive)
  }
}
</script>
<style lang="scss" scoped>
.news-list {
  .van-card__content {
    min-height: 55px;
  }
  .van-card__thumb {
    height: 55px;
  }

  .van-card__title {
    // overflow: hidden;
    // text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
  }
  .btn-group {
    display: flex;
    justify-content: space-between;
    .add-time {
      font-size: 12px;
      color: red;
    }
  }
}
</style>

photosinfo

<template>
  <div class="photo-info">
    <van-panel
      :title="photoInfo.title"
      :status="'阅读'+photoInfo.click+'次'"
    >
      <div class="img-box">
        <img
          v-for="(item,index) in thumImages"
          :key="item.id"
          :src="item.src"
          @click="imagePreview(index)"
        >
      </div>
      <div class="content">{{photoInfo.content}}</div>
    </van-panel>
    <Comment :id="id"></Comment>
  </div>
</template>
<script>
import { getImageInfo, getThumImages } from '@/api/photos'
import { ImagePreview } from 'vant'
import Comment from '@/components/Comment'
export default {
  props: ['id'],
  data() {
    return {
      photoInfo: {},
      thumImages: []
    }
  },
  methods: {
    async getImageInfo() {
      const res = await getImageInfo(this.id)
      this.photoInfo = res.data.message
    },

    async getThumImages() {
      const res = await getThumImages(this.id)
      this.thumImages = res.data.message
    },
    imagePreview(startPosition) {
      const images = []
      this.thumImages.forEach(item => {
        images.push(item.src)
      })
      ImagePreview({
        images,
        startPosition
      })
    }
  },
  created() {
    this.getImageInfo()
    this.getThumImages()
  },
  components: {
    Comment
  }
}
</script>
<style lang="scss" scoped>
.photo-info {
  padding: 0 10px;
  .van-cell__title {
    font-size: 16px;
    font-weight: 600;
    flex: 2;
  }
  .content {
    text-indent: 2em;
  }
  .img-box {
    display: flex;
    justify-content: space-between;
    margin: 10px 0;
    img {
      width: 100px;
      height: 100px;
    }
  }
}
</style>

photolist

<template>
  <div class="photo-list">
    <!-- <van-tabs animated> -->
    <van-tabs>
      <van-tab
        v-for="cate in cates"
        :key="cate.id"
      >
        <template #title>
          <span @click="getImages(cate.id)">
            {{cate.title}}
          </span>
        </template>
        <div
          class="image-list"
          v-if="images.length > 0"
        >
          <img
            v-for="image in images"
            :key="image.id"
            v-lazy="image.img_url"
            @click="goDetail('/home/photoinfo',image.id)"
          >
        </div>
        <div v-else>
          暂无数据
        </div>
      </van-tab>
    </van-tabs>
  </div>
</template>
<script>
import { getImageCategory, getImages } from '@/api/photos'
// import mixins from '@/mixins'
export default {
  // mixins: [mixins],
  data() {
    return {
      cates: [],
      images: []
    }
  },
  methods: {
    async getImageCategory() {
      const res = await getImageCategory()
      res.data.message.unshift({
        id: 0,
        title: '全部'
      })
      this.cates = res.data.message
    },
    async getImages(id) {
      const res = await getImages(id)
      this.images = res.data.message
    }
  },
  created() {
    this.getImageCategory()
    // 默认显示全部
    this.getImages(0)
  }
}
</script>
<style lang="scss" scoped>
.photo-list {
  padding: 10px;
  .image-list {
    img {
      width: 100%;
      padding: 4px;
      box-sizing: border-box;
    }
  }
}
</style>

home index

<template>
  <div class="home">
    <Swiper
      :lunbolist="lunbolist"
      :autoplay="3000"
    >
    </Swiper>

    <!-- grid -->
    <van-grid :column-num="3">
      <van-grid-item
        v-for="grid in grids"
        :key="grid.id"
        :icon="grid.src"
        :text="grid.title"
        :to="grid.to"
      />
    </van-grid>
  </div>
</template>
<script>
import { getLunbo, getGrids } from '../../api/home'
import Swiper from '@/components/Swiper'
export default {
  data() {
    return {
      lunbolist: [],
      grids: []
    }
  },
  created() {
    this.getLunbo()
    this.getGrids()
  },
  methods: {
    async getLunbo() {
      const res = await getLunbo()
      this.lunbolist = res.data.message
    },
    async getGrids() {
      const res = await getGrids()
      this.grids = res.data.message
    }
  },
  components: {
    Swiper
  }
}
</script>

<style lang="scss" >
// lang 使用指定的预编译语言
// scoped 限制样式只能在当前组件使用
.home {
  .my-swipe {
    height: 200px;
    img {
      width: 100%;
      height: 100%;
      display: block;
    }
  }

  .van-grid-item__icon {
    font-size: 60px;
  }
}
</style>

search

<template>
  <div class="search">
    this is search page
  </div>
</template>
<script>
export default {
  data() {
    return {

    }
  }
}
</script>
<style lang="scss" scoped>
</style>
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 216,496评论 6 501
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 92,407评论 3 392
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 162,632评论 0 353
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 58,180评论 1 292
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 67,198评论 6 388
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 51,165评论 1 299
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 40,052评论 3 418
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 38,910评论 0 274
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 45,324评论 1 310
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 37,542评论 2 332
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 39,711评论 1 348
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 35,424评论 5 343
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 41,017评论 3 326
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 31,668评论 0 22
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,823评论 1 269
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 47,722评论 2 368
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 44,611评论 2 353

推荐阅读更多精彩内容

  • 黑马商城实战项目 项目搭建 利用HBuilder X创建基本项目结构 运行项目 整理基本项目结构,并修改窗口外观"...
    Neo_duan阅读 2,828评论 0 0
  • Vue -渐进式JavaScript框架 介绍 vue 中文网 vue github Vue.js 是一套构建用户...
    桂_3d6b阅读 817评论 0 0
  • 页面命名规范 如: 首页:index/home 关于我们:about_us 联系我们:contact_us ...
    吴乐要奋斗阅读 1,779评论 0 4
  • 页面命名规范如: 首页:index/home关于我们:about_us联系我们:contact_us产品中心:pr...
    d724eb5603f7阅读 627评论 0 4
  • 此文项目代码:https://github.com/bei-yang/I-want-to-be-an-archit...
    LM林慕阅读 335评论 0 1