123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768 |
- <template>
- <view class="container">
- <!-- 兼容小程序搜索 -->
- <!-- 顶部logo and 搜索 start-->
- <view class="top-search flex">
- <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-->
- <!-- 轮播图 start -->
- <swiper class="top-swiper" autoplay="true" duration="400" interval="5000" @change="swiperChange">
- <!-- <view class="carousel-item"><image src="../../static/img/index.png" /></view> -->
- <swiper-item v-for="(item, index) in carouselList" :key="index" class="carousel-item"><image :src="item.pic" /></swiper-item>
- </swiper>
- <!-- 轮播图 end -->
- <!-- <view class="swiper-btm flex">
- <view class="btm-item flex">
- <image src="../../static/icon/index-gou.png" mode=""></image>
- <view class="">自用购物返利</view>
- </view>
- <view class="btm-item flex">
- <image src="../../static/icon/index-gou.png" mode=""></image>
- <view class="">分享好友赚钱</view>
- </view>
- <view class="btm-item flex">
- <image src="../../static/icon/index-gou.png" mode=""></image>
- <view class="">超值正品优惠</view>
- </view>
- </view> -->
- <!-- 预约 start-->
- <view class="yuyue-wrap">
- <view class="yuyue-top flex"><image src="../../static/img/yuyue-top.png" mode="heightFix"></image></view>
- <view class="yuyue-item" v-for="item in list" @click="navToDetailPage(item)">
- <view class="share" @click.stop="share(item)">
- <image class="share-img" src="../../static/img/share.png" mode=""></image>
- <view class="share-font">分享</view>
- </view>
- <!-- <button class="share" open-type="share">
- <image class="share-img" src="../../static/img/share.png" mode=""></image>
- <view class="share-font">分享</view>
- </button> -->
- <view class="yuyue-item-left">
- <view class="yuyue-item-left-bg"><image src="../../static/img/index-bg.png" mode=""></image></view>
- <image class="yuyue-item-left-image" :src="item.image" mode=""></image>
- </view>
- <view class="yuyue-item-right">
- <view class="yuyue-item-title clamp2">{{ item.store_name }}</view>
- <view class="yuyue-item-bottom-box">
- <view class="yuyue-item-price">¥{{ item.price }}</view>
- <view class="yuyue-item-btn">立即拼团</view>
- </view>
- </view>
- </view>
- </view>
- <uni-popup ref="popupshare" type="center">
- <view class="share-box"><image :src="shareimg" mode="" class="box-img" @longpress="saveImg()"></image></view>
- </uni-popup>
- <!-- 预约 end-->
- <u-tabbar
- v-if="userInfo.user_rule == 'leader' || userInfo.user_rule == 'admin'"
- v-model="current"
- :list="tabbar"
- active-color="#FF4C4C"
- inactive-color="#666666"
- ></u-tabbar>
- <u-tabbar v-else v-model="current" :list="tabbar1" active-color="#FF4C4C" inactive-color="#666666"></u-tabbar>
- </view>
- </template>
- <script>
- import { loadIndexs } from '@/api/index.js';
- import { getProducts, poster } from '@/api/product.js';
- import { mapState, mapMutations } from 'vuex';
- import { saveUrl, interceptor } from '@/utils/loginUtils.js';
- import { tabbar, tabbar1 } from '@/utils/tabbar.js';
- export default {
- // #ifdef MP
- onShareAppMessage: function(res) {
- console.log(res);
- console.log('是否从按钮进入');
- if (res.from === 'button' || res.from === 'menu') {
- // 来自页面内分享按钮
- let pages = getCurrentPages();
- // 获取当前页面
- let page = pages[pages.length - 1];
- let path = '/' + page.route + '?';
- // 保存传值
- for (let i in page.options) {
- path += i + '=' + page.options[i] + '&';
- }
- // 保存邀请人
- path += 'spread=' + this.userInfo.uid;
- let data = {
- path: path,
- imageUrl: 'http://zhibo.liuniu946.com/uploads/attach/2021/06/20210621/f24e2d3028d95db57944e1816ec464fc.jpg',
- title: this.userInfo.nickname + '邀请您进入城攻闪拓项目'
- };
- return data;
- } else {
- console.log('else');
- }
- },
- // #endif
- data() {
- return {
- shareimg: '',
- imging: 1, //生成海报中1没有2正在运行
- tabbar: tabbar,
- tabbar1: tabbar1,
- current: 0,
- carouselList: [],
- list: [],
- swiperLength: 0,
- swiperCurrent: 0,
- goodsObjact: {
- percent: 1
- } //保存商品数据
- };
- },
- onShow() {
- let pages = getCurrentPages(); //获取加载的页面
- let currentPage = pages[pages.length - 1]; //获取当前页面的对象
- let url = currentPage.route; //当前页面url
- let item = currentPage.options; //如果要获取url中所带的参数可以查看options
- this.url = this.$store.state.baseURL + '/index/#/' + url + '?id=' + item.id + '&spread=' + this.userInfo.uid;
- },
- onReady() {
- let obj = this;
- let query = uni.createSelectorQuery();
- // 获取页面比例
- query
- .select('.container')
- .fields(
- {
- size: true
- },
- e => {
- // 保存比例
- this.ratio = e.width / 750;
- }
- )
- .exec();
- },
- onLoad(option) {
- let res = uni.getSystemInfoSync();
- if (option.spread) {
- // 存储邀请人
- this.spread = option.spread;
- uni.setStorageSync('spread', option.spread);
- }
- if (option.scene) {
- // 存储邀请人
- this.spread = option.scene;
- uni.setStorageSync('spread_code', option.scene);
- }
- this.loadData();
- },
- computed: {
- ...mapState(['userInfo', 'baseURL', 'hasLogin', 'urlFile'])
- },
- methods: {
- // 获取首页数据
- loadData() {
- loadIndexs({}).then(({ data }) => {
- this.carouselList = data.banner;
- });
- getProducts({ pages: 1, limit: 1000 }).then(({ data }) => {
- this.list = data;
- });
- },
- //轮播图跳转页面
- nav(item) {
- if (!this.hasLogin) {
- uni.showModal({
- title: '登录',
- content: '您未登录,是否马上登陆?',
- success: e => {
- if (e.confirm) {
- interceptor();
- }
- },
- fail: e => {
- console.log(e);
- }
- });
- return;
- }
- console.log(item);
- if (item.url != '/') {
- console.log('11111');
- uni.navigateTo({
- url: '/' + item.url,
- fail(error) {
- console.log(error);
- }
- });
- }
- },
- // 保存海报
- saveImg(w) {
- let obj = this;
- console.log(w, obj.shareimg);
- uni.downloadFile({
- //下载图片
- url: obj.shareimg,
- success: res => {
- console.log(res.tempFilePath);
- uni.saveImageToPhotosAlbum({
- //将图片保存在手机
- filePath: res.tempFilePath, //保存的位置
- success: res => {
- uni.showToast({
- title: '保存成功',
- icon: 'none'
- });
- }
- });
- }
- });
- },
- // 分享海报
- share(item) {
- let obj = this;
- if (obj.imging == 2) {
- return;
- }
- uni.showLoading({
- title: '生成海报中'
- });
- obj.imging = 2;
- // #ifdef H5
- let fromname = 'wechat';
- // #endif
- // #ifdef MP
- let fromname = 'routine';
- // #endif
- poster({
- productId: item.id,
- from: fromname
- })
- .then(({ data }) => {
- console.log(data.url);
- obj.shareimg = data.url;
- obj.imging = 1;
- uni.hideLoading();
- this.$refs.popupshare.open();
- })
- .catch(err => {
- obj.imging = 1;
- });
- },
- // 点击跳转页面
- navTo(url) {
- if (!this.hasLogin) {
- uni.showModal({
- title: '登录',
- content: '您未登录,是否马上登陆?',
- success: e => {
- if (e.confirm) {
- interceptor();
- }
- },
- fail: e => {
- console.log(e);
- }
- });
- return;
- }
- uni.navigateTo({
- url,
- fail(error) {
- uni.switchTab({
- url
- });
- }
- });
- },
- // 监听导航栏输入框点击事件
- onNavigationBarSearchInputClicked(e) {
- //跳转到搜索页面
- this.clickSearch();
- },
- // 點擊搜索框
- clickSearch() {
- uni.navigateTo({
- url: '/pages/product/search'
- });
- },
- //轮播图切换修改背景色
- swiperChange(e) {
- const index = e.detail.current;
- this.swiperCurrent = index;
- this.titleNViewBackground = this.carouselList[index].background;
- },
- // 跳转普通商品
- navToDetailPage(item) {
- uni.navigateTo({
- url: '/pages/product/product?id=' + item.id
- });
- },
- IndexShare() {
- let obj = this;
- let data = obj.onShareAppMessage();
- let item = {
- link: data.path, // 分享链接
- imgUrl: data.imgUrl,
- title: data.title
- };
- console.log('分享加', item);
- weixindata(item);
- }
- }
- };
- </script>
- <style lang="scss">
- /* #ifdef MP || APP-PLUS*/
- .input-box {
- padding: 25rpx;
- /* #ifdef APP-PLUS */
- margin-top: var(--status-bar-height);
- /* #endif */
- background-color: #fe8119;
- height: 44px;
- .iconsearch {
- font-size: 50rpx;
- }
- .input-content {
- border-radius: 99rpx;
- flex-grow: 1;
- padding: 5rpx 30rpx;
- // background-color: rgba(231, 231, 231, 0.7);
- background: #ffffff;
- .input {
- flex-grow: 1;
- input {
- font-size: $font-base;
- }
- }
- }
- .input-button {
- padding-left: 20rpx;
- font-size: $font-base;
- height: 100%;
- }
- }
- /* #endif */
- .top-search {
- height: 80rpx;
- padding: 0 20rpx;
- background-color: #fff;
- .top-logo {
- width: 50rpx;
- // height: 50rpx;
- margin-right: 10rpx;
- image {
- width: 48rpx;
- }
- }
- .search-box {
- justify-content: center;
- width: 698rpx;
- 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: 750rpx;
- height: 360rpx;
- // margin: 20rpx 0 0;
- image {
- width: 750rpx;
- height: 360rpx;
- }
- }
- .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;
- }
- }
- }
- /* 分类 */
- .cate-section {
- display: flex;
- justify-content: space-around;
- align-items: center;
- flex-wrap: wrap;
- padding: 30rpx 22rpx;
- background-color: #ffffff;
- .cate-item {
- display: flex;
- flex-direction: column;
- align-items: center;
- font-size: $font-sm + 2rpx;
- color: $font-color-dark;
- }
- /* 原图标颜色太深,不想改图了,所以加了透明度 */
- image {
- width: 88rpx;
- height: 88rpx;
- margin-bottom: 14rpx;
- border-radius: 50%;
- opacity: 0.7;
- }
- }
- // 为你推荐
- .recommend-box {
- background: linear-gradient(180deg, #ffffff, #f8f8f8);
- width: 100%;
- padding: 0 32rpx;
- }
- .f-header {
- display: flex;
- align-items: center;
- height: 92rpx;
- padding: 6rpx 30rpx 8rpx;
- border-radius: 12rpx 12rpx 0 0;
- color: #ffffff;
- background: linear-gradient(180deg, #fd4646, #ff3535);
- .tit-box {
- @extend %font-title-box;
- font-size: 20rpx;
- color: #ffffff;
- margin-left: 20rpx;
- }
- .iconenter {
- font-size: $font-lg + 2rpx;
- color: #ffffff;
- }
- .f-left-icon {
- font-size: 34rpx;
- border-right: 1rpx solid #ffffff;
- padding-right: 18rpx;
- }
- .iconfont {
- font-size: 26rpx;
- }
- }
- .guess-section {
- width: 100%;
- display: flex;
- flex-direction: column;
- background-color: #ffffff;
- border-radius: 0 0 12rpx 12rpx;
- .guess-item {
- display: flex;
- width: 100%;
- padding: 24rpx;
- border-bottom: 1rpx solid #f0f0f0;
- &:nth-last-child(1) {
- border-bottom: none;
- }
- }
- .image-wrapper {
- width: 168rpx;
- height: 168rpx;
- border-radius: 3px;
- image {
- width: 168rpx;
- height: 168rpx;
- opacity: 1;
- }
- }
- .info-wrapper {
- width: 100%;
- display: flex;
- flex-direction: column;
- margin-left: 20rpx;
- }
- .title {
- font-size: 32rpx;
- color: $font-color-dark;
- word-break: break-all;
- display: -webkit-box;
- -webkit-line-clamp: 1;
- -webkit-box-orient: vertical;
- overflow: hidden;
- }
- .price-box {
- margin-top: 10rpx;
- display: flex;
- justify-content: space-between;
- .price-left {
- display: flex;
- flex-direction: column;
- .price {
- margin-top: 8rpx;
- line-height: 30rpx;
- color: #ff0000;
- font-size: 40rpx;
- font-weight: 700;
- .price-tip {
- font-size: 28rpx;
- }
- }
- .ot_price {
- margin-top: 50rpx;
- line-height: 24rpx;
- font-size: 28rpx;
- margin-left: 4rpx;
- text-decoration: line-through;
- color: #aaaaaa;
- .price-tip {
- font-size: 22rpx;
- }
- }
- }
- .price-right {
- display: flex;
- flex-direction: column;
- .people {
- margin-top: 32rpx;
- font-weight: 700;
- color: #999999;
- font-size: 22rpx;
- text-align: right;
- margin-right: 4rpx;
- }
- .buyNow {
- margin-top: 68rpx;
- background: linear-gradient(180deg, #fd4646, #ff3535);
- border-radius: 26rpx;
- padding: 6rpx 18rpx;
- font-size: 26rpx;
- font-weight: 400;
- color: #ffffff;
- }
- }
- }
- }
- // 热销产品
- .hotgoodsheader {
- width: 100%;
- display: flex;
- justify-content: center;
- align-items: center;
- padding: 32rpx 0 24rpx;
- image {
- width: 374rpx;
- height: 34rpx;
- }
- }
- .hotgoods {
- width: 100%;
- display: flex;
- flex-wrap: wrap;
- padding: 0 32rpx 108rpx;
- .hotgoods-item {
- width: 48%;
- background-color: #ffffff;
- border-radius: 12rpx;
- margin-bottom: 24rpx;
- &:nth-child(2n + 1) {
- margin-right: 24rpx;
- }
- .image-wrapper {
- width: 100%;
- height: 330rpx;
- border-radius: 3px;
- overflow: hidden;
- image {
- width: 100%;
- height: 100%;
- opacity: 1;
- border-radius: 12rpx 12rpx 0 0;
- }
- }
- .title {
- font-size: $font-base;
- color: $font-color-dark;
- font-weight: bold;
- line-height: 80rpx;
- }
- .hot-price {
- display: flex;
- justify-content: space-between;
- padding: 0 16rpx 12rpx;
- .price {
- font-size: 40rpx;
- color: #ff0000;
- font-weight: 500;
- }
- .cart-icon {
- image {
- width: 44rpx;
- height: 44rpx;
- }
- }
- }
- }
- }
- .award-box {
- width: 100%;
- padding: 24rpx 24rpx 0;
- background: #ffffff;
- image {
- width: 100%;
- height: 170rpx;
- }
- }
- .yuyue-wrap {
- background-color: #fff;
- .yuyue-top {
- height: 117rpx;
- justify-content: center;
- image {
- display: inline-block;
- height: 31rpx;
- margin: auto;
- }
- }
- .yuyue-item {
- width: 710rpx;
- background: #ffffff;
- box-shadow: 0px 0px 20rpx 0px rgba(50, 50, 52, 0.06);
- border-radius: 10rpx;
- margin: 20rpx auto 0;
- padding: 20rpx 30rpx 20rpx 14rpx;
- position: relative;
- display: flex;
- justify-content: flex-start;
- .share {
- position: absolute;
- top: 0;
- right: 30rpx;
- width: 72rpx;
- height: 96rpx;
- background: linear-gradient(0deg, #fc773a, #ffa934);
- border-bottom-left-radius: 50rpx;
- border-bottom-right-radius: 50rpx;
- padding: 10rpx 16rpx 14rpx;
- line-height: 1;
- display: flex;
- flex-direction: column;
- justify-content: center;
- align-items: center;
- .share-img {
- width: 32rpx;
- height: 32rpx;
- }
- .share-font {
- margin-top: 8rpx;
- font-size: 20rpx;
- font-family: PingFang SC;
- font-weight: 500;
- color: #ffffff;
- }
- }
- .yuyue-item-left {
- position: relative;
- .yuyue-item-left-bg {
- position: absolute;
- z-index: 2;
- top: 0;
- right: 0;
- left: 0;
- width: 236rpx;
- height: 236rpx;
- image {
- width: 100%;
- height: 100%;
- }
- }
- .yuyue-item-left-image {
- width: 236rpx;
- height: 236rpx;
- }
- }
- .yuyue-item-right {
- margin-left: 22rpx;
- padding: 10rpx 0;
- display: flex;
- flex-direction: column;
- justify-content: space-between;
- width: 100%;
- .yuyue-item-title {
- width: 320rpx;
- font-size: 32rpx;
- font-family: PingFang SC;
- font-weight: bold;
- color: #333333;
- }
- .yuyue-item-bottom-box {
- display: flex;
- justify-content: space-between;
- .yuyue-item-price {
- font-size: 36rpx;
- font-family: PingFang SC;
- font-weight: bold;
- color: #ff4c4c;
- }
- .yuyue-item-btn {
- width: 138rpx;
- height: 52rpx;
- background: linear-gradient(90deg, #fe6f61 0%, #ff4343 100%);
- border-radius: 26rpx;
- font-size: 26rpx;
- font-family: PingFang SC;
- font-weight: 500;
- color: #ffffff;
- line-height: 52rpx;
- text-align: center;
- }
- }
- }
- }
- }
- .share-box {
- width: 600rpx;
- height: 1000rpx;
- background: red;
- .box-img {
- width: 600rpx;
- height: 1000rpx;
- }
- }
- </style>
|