123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962 |
- <template>
- <view class="container">
- <!-- <image src="" mode=""></image> -->
- <!-- 顶部logo and 搜索 start-->
- <view class="index-top-wrap">
- <!-- <image src="../../static/index/index-top.png" mode="widthFix" class="index-top"></image> -->
- <view class="status_bar fud"></view>
- <view class="top-search flex fud">
- <view class="search-box flex" @click="clickSearch()">
- <image class="search" src="../../static/icon/search-h.png" mode=""></image>
- <view class="search-font">输入关键词搜索</view>
- </view>
- </view>
- <!-- 顶部logo and 搜索 end-->
- <!-- <view class="jg fud" style="background-color: #fff;"></view> -->
- <!-- 轮播图 start -->
- <swiper class="top-swiper fud" autoplay="true" duration="400" interval="5000" @change="swiperChange">
- <swiper-item v-for="(item, index) in carouselList" :key="index" class="carousel-item"
- @click="bannerNavToUrl(item)">
- <image :src="item.pic" />
- </swiper-item>
- </swiper>
- <!-- 轮播图 end -->
- </view>
- <!-- 分类 start -->
- <view class="cate-section flex">
- <view class="cate-item flex" @click="navto('/pages/category/category')">
- <view class="img-wrapper flex">
- <image src="../../static/index/in1.png" mode=""></image>
- </view>
- <view class="item-title">全部商品</view>
- </view>
- <view class="cate-item flex" @click="navto('/pages/index/artDetail?id=1')">
- <view class="img-wrapper flex">
- <image src="../../static/index/in2.png" mode=""></image>
- </view>
- <view class="item-title">公司介绍</view>
- </view>
- <!-- <view class="cate-item flex" @click="openKf">
- <view class="img-wrapper flex">
- <image src="../../static/index/in3.png" mode=""></image>
- </view>
- <view class="item-title">联系客服</view>
- </view> -->
- <!-- <view class="cate-item flex" @click="navto('/pages/integralGoods/integral_goods_list')">
- <view class="img-wrapper flex">
- <image src="../../static/index/in6.png" mode=""></image>
- </view>
- <view class="item-title">积分商品</view>
- </view> -->
- <!-- <view class="cate-item flex" @click="navto('/pages/user/shareQrCode',1)">
- <view class="img-wrapper flex">
- <image src="../../static/index/in4.png" mode=""></image>
- </view>
- <view class="item-title">邀请好友</view>
- </view> -->
- <view class="cate-item flex" @click="navto('/pages/index/artDetail?id=2')">
- <view class="img-wrapper flex">
- <image src="../../static/index/in7.png" mode=""></image>
- </view>
- <view class="item-title">加入我们</view>
- </view>
- </view>
- <view class="ins-item">
- <view class="type flex padding-b-30">
- <image class="indexHot margin-r-10" src="../../static/icon/indexhot.png" mode="widthFix"></image>
- <view class="title">
- 买商品送积分
- </view>
- </view>
- <view class="item flex" v-for="item in goodIn.list" @click="navTo('/pages/product/product?id=' + item.id)">
- <image class="goods-image" :src="item.image" mode="scaleToFill"></image>
- <view class="content">
- <view class="goods-title clamp2">
- {{item.store_name}}
- </view>
- <view class="flex padding-t-10">
- <view class="tip">
- 赠送{{item.give_integral}}积分
- </view>
- </view>
- <view class="money flex-start">
- <view class="newmoney padding-r-10">
- ¥{{+item.price }}
- </view>
- <view class="optmoney">
- {{+item.ot_price }}
- </view>
- </view>
- <view class="nav-bottom">
- 立即购买
- </view>
- </view>
- </view>
- </view>
- <!-- 商品列表 start -->
- <view class="product-box">
- <view class="product-tit flex">
- <view class="hx">
- </view>
- <view class="tit">
- 积分商品
- </view>
- <view class="hx">
- </view>
- </view>
- </view>
- <view class="good-list">
- <view class="good" v-for="item in inListData.list" @click="navTo('/pages/product/product?type=3&id=' + item.id)">
- <image :src="item.image" mode="" class="good-image"></image>
- <view class="good-name ">
- <view class="clamp">
- {{item.store_name}}
- </view>
- </view>
- <view class="good-key">
- <!-- 鸿运开来 为成功喝彩 -->
- </view>
- <view class="good-price">
- <view class="price">
- 积分{{item.min_integral}}
- </view>
- <!-- <view class="xl">
- 库存:{{item.sales}}
- </view> -->
- </view>
- </view>
- </view>
- <!-- 商品列表 ed-->
- <uni-popup ref="popupkf" type="center">
- <view class="popup-box">
- <view class="img">
- <image src="../../static/img/img009.png" mode=""></image>
- </view>
- <view class="mian">
- <view class="delivery">
- <view class="title">已经为您定制专属客服</view>
- <image src="../../static/img/img010.png" mode=""></image>
- </view>
- <view class="nocancel">客服VX:{{ text }}</view>
- <view class="comfirm-box">
- <view class="cancel" @click="cancel">取消</view>
- <view class="comfirm" @click="comfirm(text)">复制微信</view>
- </view>
- </view>
- </view>
- </uni-popup>
- </view>
- </template>
- <script>
- import {
- loadIndexs
- } from '@/api/index.js';
- import {
- getUserInfo
- } from '@/api/user.js';
- import {
- getInGoods,
- getIn,
- } from '@/api/new.js';
- import {
- saveUrl,
- interceptor
- } from '@/utils/loginUtils';
- import {
- mapState,
- mapMutations
- } from 'vuex';
- export default {
- data() {
- return {
- text: 'shxsophina', //客服微信
- current: 0,
- titleNViewBackground: '',
- swiperCurrent: 0,
- swiperLength: 0,
- carouselList: [], //轮播列表
- goodIn: {
- loadingType: 'more',
- page: 1,
- limit: 10,
- list: []
- },
- // 积分商品列表
- inListData: {
- loadingType: 'more',
- page: 1,
- limit: 10,
- list: []
- }
- };
- },
- computed: {
- ...mapState('user', ['hasLogin', 'userInfo'])
- },
- onShareAppMessage(options) {
- // 设置菜单中的转发按钮触发转发事件时的转发内容
- let pages = getCurrentPages(); //获取加载的页面
- let currentPage = pages[pages.length - 1]; //获取当前页面的对象
- let url = currentPage.route; //当前页面url
- let item = currentPage.options; //如果要获取url中所带的参数可以查看options
- let shareObj = {}
- if (this.userInfo.uid) {
- shareObj = {
- title: this.userInfo.nickname + '邀请您加入顺肠清', // 默认是小程序的名称(可以写slogan等)
- path: url + '?scene=' + this.userInfo.uid, // 默认是当前页面,必须是以‘/’开头的完整路径
- imageUrl: '',
- success: function(res) {
- // 转发成功之后的回调
- if (res.errMsg == 'shareAppMessage:ok') {}
- },
- fail: function() {
- // 转发失败之后的回调
- if (res.errMsg == 'shareAppMessage:fail cancel') {
- // 用户取消转发
- } else if (res.errMsg == 'shareAppMessage:fail') {
- // 转发失败,其中 detail message 为详细失败信息
- }
- }
- };
- } else {
- shareObj = {
- title: '顺肠清', // 默认是小程序的名称(可以写slogan等)
- path: url, // 默认是当前页面,必须是以‘/’开头的完整路径
- imageUrl: '',
- success: function(res) {
- // 转发成功之后的回调
- if (res.errMsg == 'shareAppMessage:ok') {}
- },
- fail: function() {
- // 转发失败之后的回调
- if (res.errMsg == 'shareAppMessage:fail cancel') {
- // 用户取消转发
- } else if (res.errMsg == 'shareAppMessage:fail') {
- // 转发失败,其中 detail message 为详细失败信息
- }
- }
- };
- }
- return shareObj;
- },
- onReachBottom() {
- console.log('到底')
- this.getGoodList()
- },
- onLoad: function(option) {
- // #ifndef MP
- if (option.spread) {
- // 存储其他邀请人
- uni.setStorageSync('spread', option.spread);
- }
- // #endif
- // #ifdef MP
- if (option.scene) {
- // 存储小程序邀请人
- uni.setStorage({
- key: 'spread_code',
- data: option.scene
- });
- }
- // #endif
- },
- onShow: function() {
- this.getGoodList()
- this.getIn()
- this.loadData();
- },
- methods: {
- getIn() {
- let obj = this;
- if (obj.goodIn.loadingType == 'loading' || obj.goodIn.loadingType == 'noMore') {
- return
- }
- obj.goodIn.loadingType = 'loading'
- getIn({
- page: obj.goodIn.page,
- limit: obj.goodIn.limit,
- }).then(res => {
- obj.goodIn.list = obj.goodIn.list.concat(res.data.list)
- // if (obj.goodIn.page == res.data.length) {
- // obj.goodIn.page++
- // obj.loadingType = 'more';
- // } else {
- obj.goodIn.loadingType = 'noMore'
- // }
- })
- },
- getGoodList() {
- let obj = this
- if (obj.inListData.loadingType == 'loading' || obj.inListData.loadingType == 'noMore') {
- return
- }
- obj.inListData.loadingType = 'loading'
- getInGoods({
- page: obj.inListData.page,
- limit: obj.inListData.limit,
- }).then(res => {
- obj.inListData.list = obj.inListData.list.concat(res.data.list)
- // if (obj.inListData.page == res.data.length) {
- // obj.inListData.page++
- // obj.inListData.loadingType = 'more';
- // } else {
- obj.inListData.loadingType = 'noMore'
- // }
- })
- },
- navto(url, type = 0) {
- if (type == 1) {
- if (!this.hasLogin) {
- // 保存地址
- saveUrl();
- // 登录拦截
- interceptor();
- } else {
- uni.navigateTo({
- url,
- fail() {
- uni.switchTab({
- url
- })
- }
- })
- }
- } else {
- uni.navigateTo({
- url,
- fail() {
- uni.switchTab({
- url
- })
- }
- })
- }
- },
- navTo(url) {
- if (url == '') {
- this.$api.msg('暂未开通,敬请期待');
- } else {
- this.navto(url)
- }
- },
- // 點擊搜索框
- clickSearch() {
- uni.navigateTo({
- url: '/pages/product/search'
- });
- },
- // 监听图片加载完成
- onImageError(key, index) {
- this[key][index].image = '/static/error/errorImage.jpg';
- },
- // 请求载入数据
- async loadData() {
- loadIndexs({})
- .then(({
- data
- }) => {
- let goods = data.info;
- console.log(goods, '商品信息');
- this.carouselList = data.banner;
- // this.swiperLength = this.carouselList.length;
- // this.bastList = data.giftInfo; //会员礼包
- // data.info.firstList.forEach(e => {
- // e.isVip = e.store_type ? "3" : "0"
- // })
- // this.firstList = data.info.firstList //首页商品
- uni.stopPullDownRefresh();
- })
- .catch(e => {
- uni.stopPullDownRefresh();
- });
- },
- //轮播图切换修改背景色
- swiperChange(e) {
- const index = e.detail.current;
- this.swiperCurrent = index;
- this.titleNViewBackground = this.carouselList[index].background;
- },
- // 轮播图跳转
- bannerNavToUrl(item) {
- // #ifdef H5
- console.log(item.wap_url.indexOf('http'), 'banner');
- if (item.wap_url.indexOf('http') >= 0) {
- window.location.href = item.wap_url;
- }
- // #endif
- //测试数据没有写id,用title代替
- uni.navigateTo({
- url: item.wap_url
- });
- },
- comfirm(text) {
- console.log(text);
- const result = this.uniCopy(text);
- if (result === false) {
- uni.showToast({
- title: '不支持'
- });
- } else {
- uni.showToast({
- title: '复制成功',
- icon: 'none'
- });
- }
- this.$refs.popupkf.close();
- },
- uniCopy(content) {
- /**
- * 小程序端 和 app端的复制逻辑
- */
- //#ifndef H5
- uni.setClipboardData({
- data: content,
- success: function() {
- console.log('success');
- return true;
- }
- });
- //#endif
- /**
- * H5端的复制逻辑
- */
- // #ifdef H5
- if (!document.queryCommandSupported('copy')) {
- //为了兼容有些浏览器 queryCommandSupported 的判断
- // 不支持
- return false;
- }
- let textarea = document.createElement('textarea');
- textarea.value = content;
- textarea.readOnly = 'readOnly';
- document.body.appendChild(textarea);
- textarea.select(); // 选择对象
- textarea.setSelectionRange(0, content.length); //核心
- let result = document.execCommand('copy'); // 执行浏览器复制命令
- textarea.remove();
- return result;
- // #endif
- },
- // 打开客服
- openKf() {
- this.$refs.popupkf.open();
- },
- // 关闭客服
- cancel() {
- this.$refs.popupkf.close();
- },
- }
- };
- </script>
- <style lang="scss">
- page {
- background: #ffff;
- min-height: 100%;
- height: auto;
- }
- // 顶部搜索
- .top-search {
- height: 80rpx;
- padding: 0 20rpx;
- margin-bottom: 20rpx;
- // background-color: #fff;
- .top-logo {
- width: 50rpx;
- // height: 50rpx;
- margin-right: 10rpx;
- image {
- width: 48rpx;
- }
- }
- .search-box {
- justify-content: center;
- width: 100%;
- height: 60rpx;
- background: #EEEEEE;
- // box-shadow: 0px 10rpx 20rpx 0px rgba(4, 114, 69, 0.22);
- border-radius: 30rpx;
- .search {
- width: 34rpx;
- height: 34rpx;
- }
- .search-font {
- margin-left: 14rpx;
- font-size: 28rpx;
- font-family: PingFang SC;
- font-weight: 500;
- color: #CBCBCB;
- }
- }
- }
- // 顶部轮播图
- .top-swiper {
- width: 690rpx;
- height: 365rpx;
- // margin: 20rpx 0 0;
- border-radius: 20rpx;
- margin: auto;
- image {
- width: 690rpx;
- height: 365rpx;
- border-radius: 20rpx;
- }
- }
- .swiper-btm {
- height: 60rpx;
- width: 750rpx;
- background-color: #fff;
- margin-bottom: 20rpx;
- font-size: 21rpx;
- font-weight: 500;
- color: #333333;
- .btm-item {
- flex-grow: 1;
- justify-content: center;
- image {
- width: 25rpx;
- height: 25rpx;
- margin-right: 14rpx;
- }
- }
- }
- .jg {
- height: 20rpx;
- background: #fff;
- }
- // 分类
- .cate-section {
- justify-content: space-around;
- background-color: #fff;
- padding: 0rpx 0 10rpx;
- margin-top: 20rpx;
- flex-wrap: wrap;
- .cate-item {
- flex-grow: 0;
- width: 33.3%;
- flex-direction: column;
- text-align: center;
- align-items: center;
- justify-content: center;
- padding-bottom: 20rpx;
- .img-wrapper {
- width: 90rpx;
- height: 90rpx;
- border-radius: 20rpx;
- position: relative;
- image {
- width: 90rpx;
- height: 90rpx;
- position: absolute;
- left: 50%;
- top: 50%;
- transform: translate(-50%, -50%);
- }
- }
- .item-title {
- margin-top: 15rpx;
- font-size: 26rpx;
- font-weight: 500;
- color: #6B4216;
- }
- }
- }
- .product-box {
- // margin-top: 20rpx;
- background: #ffffff;
- padding: 26rpx 0 20rpx;
- .product-tit {
- justify-content: center;
- .hx {
- width: 120rpx;
- height: 1rpx;
- background: #4A2723;
- }
- .tit {
- margin: 0 70rpx;
- font-size: 30rpx;
- font-weight: 500;
- color: #4A2723;
- }
- }
- }
- .hotgoods {
- margin-top: 38rpx;
- width: 100%;
- display: flex;
- flex-wrap: wrap;
- padding: 0 20rpx 30rpx;
- justify-content: space-between;
- .hotgoods-item {
- width: 345rpx;
- background-color: #ffffff;
- border-radius: 12rpx;
- box-shadow: 0 0 15rpx rgba(0, 0, 0, 0.2);
- margin-bottom: 15rpx;
- .image-wrapper {
- width: 345rpx;
- height: 345rpx;
- border-radius: 3px;
- overflow: hidden;
- position: relative;
- .image-bg {
- position: absolute;
- top: 0;
- left: 0;
- right: 0;
- bottom: 0;
- width: 100%;
- height: 100%;
- opacity: 1;
- border-radius: 12rpx 12rpx 0 0;
- z-index: 2;
- }
- .image {
- width: 100%;
- height: 100%;
- opacity: 1;
- border-radius: 12rpx 12rpx 0 0;
- }
- }
- .title {
- margin-top: 24rpx;
- padding: 0 20rpx;
- font-size: 28rpx;
- font-family: PingFang SC;
- font-weight: 500;
- color: #333333;
- }
- .hot-price {
- display: flex;
- justify-content: flex-start;
- align-items: center;
- // padding: 14rpx 0 30rpx;
- .hotPrice-box {
- padding: 2rpx 6rpx;
- background: linear-gradient(90deg, #c79a4c, #f9df7f);
- border-radius: 5rpx;
- text-align: center;
- line-height: 28rpx;
- font-size: 20rpx;
- font-family: Source Han Sans CN;
- font-weight: 400;
- color: #ffffff;
- }
- .price {
- margin-left: 10rpx;
- font-size: 40rpx;
- color: #ff0000;
- font-weight: 500;
- .jf {
- font-size: 20rpx;
- }
- }
- .yuanPrice {
- margin-left: 10rpx;
- font-size: 20rpx;
- font-family: PingFang SC;
- font-weight: 500;
- text-decoration: line-through;
- color: #999999;
- }
- .cart-icon {
- image {
- width: 44rpx;
- height: 44rpx;
- }
- }
- }
- }
- }
- .popup-box {
- width: 522rpx;
- height: 605rpx;
- background-color: #ffffff;
- border-radius: 20rpx;
- position: relative;
- .product-tit {
- justify-content: center;
- .hx {
- width: 120rpx;
- height: 1rpx;
- background: #989898;
- }
- .tit {
- margin: 0 70rpx;
- font-size: 30rpx;
- font-weight: 500;
- color: #4A2723;
- }
- }
- .img {
- position: relative;
- top: -56rpx;
- left: 0;
- width: 522rpx;
- height: 132rpx;
- display: flex;
- justify-content: center;
- image {
- border-radius: 20rpx 20rpx 0 0;
- width: 450rpx;
- height: 132rpx;
- }
- }
- .mian {
- margin-top: -44rpx;
- display: flex;
- flex-direction: column;
- align-items: center;
- // padding: 32rpx 32rpx;
- background-color: #ffffff;
- border-radius: 0 0 20rpx 20rpx;
- text-align: center;
- .delivery {
- font-size: 40rpx;
- color: #333333;
- display: flex;
- align-items: center;
- flex-direction: column;
- image {
- margin-top: 48rpx;
- width: 172rpx;
- height: 160rpx;
- }
- }
- .nocancel {
- font-size: 32rpx;
- color: #333333;
- margin-top: 14rpx;
- }
- .comfirm-box {
- margin-top: 52rpx;
- display: flex;
- // margin-bottom: 32rpx;
- // justify-content: space-around;
- .cancel {
- display: flex;
- align-items: center;
- justify-content: center;
- width: 197rpx;
- height: 74rpx;
- border: 1px solid #dcc786;
- border-radius: 38rpx;
- font-size: 32rpx;
- color: #605128;
- }
- .comfirm {
- margin-left: 32rpx;
- display: flex;
- align-items: center;
- justify-content: center;
- width: 197rpx;
- height: 74rpx;
- background: linear-gradient(-90deg, #d1ba77 0%, #f7e8ad 100%);
- border-radius: 38px;
- font-size: 32rpx;
- color: #605128;
- }
- }
- }
- }
- .good-list {
- display: flex;
- justify-content: space-between;
- flex-wrap: wrap;
- padding: 20rpx 28rpx;
- .good {
- width: 336rpx;
- height: 482rpx;
- background: #FFFFFF;
- box-shadow: 0px 0px 6rpx 0px rgba(0, 0, 0, 0.1);
- border-radius: 14rpx;
- margin-bottom: 20rpx;
- position: relative;
- .good-image {
- width: 336rpx;
- height: 336rpx;
- background-color: #eee;
- border-radius: 14rpx 14rpx 0 0;
- }
- .good-name {
- font-size: 28rpx;
- font-weight: bold;
- color: #333333;
- padding: 0 20rpx;
- }
- .good-key {
- font-size: 22rpx;
- font-weight: 500;
- color: #999999;
- padding-left: 20rpx
- }
- .good-price {
- display: flex;
- width: 336rpx;
- justify-content: space-between;
- font-size: 28rpx;
- font-weight: bold;
- color: #FF1A1A;
- position: absolute;
- bottom: 20rpx;
- padding: 0 20rpx;
- .xl {
- font-size: 20rpx;
- font-weight: bold;
- color: #999999;
- }
- }
- }
- }
- .index-top-wrap {
- position: relative;
- .index-top {
- width: 750rpx;
- position: absolute;
- }
- .fud {
- position: relative;
- }
- }
- .ins-item {
- padding: 30rpx;
- .type {
- justify-content: flex-start;
- .indexHot {
- width: 40rpx;
- }
- .title {
- font-size: $font-lg;
- font-weight: bold;
- }
- }
- .item {
- padding: 20rpx;
- box-shadow: 0rpx 0rpx 20rpx rgba(0, 0, 0, 0.2);
- border-radius: 20rpx;
- margin-bottom: 30rpx;
- position: relative;
- .goods-title {
- height: 2.5em;
- font-weight: bold;
- }
- .goods-image {
- width: 250rpx;
- height: 250rpx;
- border-radius: 20rpx;
- }
- .tip {
- font-size: 24rpx;
- color: rgb(253, 133, 62);
- line-height: 1;
- padding: 5rpx 10rpx;
- border: 1px solid rgb(253, 133, 62);
- border-radius: 5rpx;
- }
- .content {
- padding-left: 20rpx;
- align-self: stretch;
- flex-grow: 1;
- position: relative;
- }
- .money{
- position: absolute;
- bottom: 0rpx;
- left: 20rpx;
- .newmoney{
- font-size: $font-lg;
- color: $color-red;
- }
- .optmoney{
- font-size: $font-sm;
- color:$font-color-light;
- text-decoration:line-through ;
- }
- }
- }
- }
- .nav-bottom{
- position: absolute;
- bottom: 0rpx;
- right: 0rpx;
- color: #FFF;
- background-color:$color-red;
- line-height: 1;
- padding: 10rpx 20rpx;
- border-radius: 100rpx;
- }
- </style>
|