123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460 |
- <template>
- <view class="container">
- <!-- 背景 -->
- <view class="bg"><image src="../../static/img/index-bg.png" mode="widthFix"></image></view>
- <!-- 商品1 -->
- <view class="good-wrap">
- <view class="good-tit">
- <view class="good-tit-bg"><image src="../../static/img/index-title.png" mode=""></image></view>
- <view class="good-tit-font">美盟汇·盟主礼包</view>
- </view>
- <view class="item-wrap" v-for="(item, index) in productList">
- <view class="item-wrap-bg"><image src="../../static/img/index-product.png" mode=""></image></view>
- <view class="item-title">{{ item.store_name }}</view>
- <view class="item-img"><image :src="item.image" mode=""></image></view>
- <view class="item-btm">
- <view class="item-price flex">
- <view class="price-tit">特惠价</view>
- <view class="price-logo">¥</view>
- <view class="price-val">{{ item.price }}</view>
- </view>
- <view class="item-btn" @click="navToLevelDetailPage(item)">立刻购买</view>
- </view>
- </view>
- </view>
- </view>
- </template>
- <script>
- import seckill from '../../components/seckill/seckill.vue';
- import { getUserInfo } from '@/api/user.js';
- import { upgrade } from '@/api/product.js';
- import { interceptor } from '@/utils/loginUtils';
- import { mapState } from 'vuex';
- import weixinObj from '@/plugin/jweixin-module/index.js';
- // #ifdef H5
- import { weixindata, weixinlocation, shareLoad } from '@/utils/wxAuthorized';
- // #endif
- export default {
- components: {
- seckill
- },
- watch: {
- //自适应swiper高度
- checkid(newValue, oldValue) {
- let obj = this;
- if (newValue == 0) {
- let bHeight = Math.ceil(obj.bastList.length / 2);
- obj.swiperHeight = Math.ceil(obj.pageProportion * 520 * bHeight);
- }
- if (newValue == 1) {
- let bHeight = Math.ceil(obj.goodsList.length / 2);
- obj.swiperHeight = Math.ceil(obj.pageProportion * 520 * bHeight);
- }
- if (newValue == 2) {
- let bHeight = Math.ceil(obj.bastBanner.length / 2);
- obj.swiperHeight = Math.ceil(obj.pageProportion * 520 * bHeight);
- }
- }
- },
- data() {
- return {
- productList: [], //常规商品
- shareShow: false, //分享海报
- pageProportion: 0, //保存页面基于750宽度的比例
- swiperHeight: 0,
- checkid: 0,
- titleNViewBackground: '',
- swiperCurrent: 0,
- swiperLength: 0,
- carouselList: [], //轮播列表
- page: 1,
- limit: 5,
- userServant: [
- {
- image: ''
- }
- ], //用户推广服务
- actTime: new Date()
- };
- },
- computed: {
- ...mapState(['loginInterceptor', 'baseURL']),
- ...mapState('user', ['hasLogin', 'userInfo'])
- },
- 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() {
- // 判断是否强制登录
- if (this.loginInterceptor && !this.hasLogin) {
- // 登录拦截
- interceptor();
- }
- weixinObj.hideAllNonBaseMenuItem();
- this.getProducts();
- if (this.userInfo) {
- weixinObj.showAllNonBaseMenuItem();
- console.log('fx');
- this.IndexShare();
- }
- },
- //下拉刷新
- onPullDownRefresh() {
- this.loadData();
- },
- methods: {
- IndexShare() {
- let obj = this;
- let pages = getCurrentPages();
- // 获取当前页面
- let page = pages[pages.length - 1];
- let path = '/#/pages/index/index' + '?';
- // 保存传值
- // for (let i in page.options) {
- // path += i + '=' + page.options[i] + '&';
- // }
- // console.log(obj.Path)
- // 保存邀请人
- path += 'spread=' + this.userInfo.uid;
- let data = {
- link: this.baseURL + path,
- title: this.userInfo.nickname + '邀请您进入科粉社',
- desc: '欢迎加入科粉社',
- imgUrl: this.baseURL + '/static/icon/logo.jpg'
- };
- console.log(data, '分享数据');
- shareLoad(data);
- },
- getProducts() {
- upgrade({ pages: 1, limit: 10 }).then(({ data }) => {
- this.productList = data;
- });
- },
- openSubscribe: function(e) {
- let page = e;
- // #ifndef MP
- uni.navigateTo({
- url: page
- });
- // #endif
- // #ifdef MP
- uni.showLoading({
- title: '正在加载'
- });
- openBargainSubscribe()
- .then(res => {
- uni.hideLoading();
- uni.navigateTo({
- url: page
- });
- })
- .catch(err => {
- uni.hideLoading();
- });
- // #endif
- },
- Mask() {
- this.MaskShow = false;
- this.shareShow = true;
- uni.setStorage({
- key: 'FirstEntry',
- data: true,
- success: function() {
- console.log(uni.getStorageSync('FirstEntry'), 'Mask');
- }
- });
- },
- Toshare() {
- if (this.userInfo == '') {
- getUserInfo({})
- .then(({ data }) => {
- this.setUserInfo(data);
- this.userInfo = data;
- })
- .catch(e => {});
- } else {
- this.shareShow = false;
- uni.navigateTo({
- url: '/pages/user/shareQrCode?spread=' + this.userInfo.uid
- });
- }
- },
- Tocancel() {
- this.shareShow = false;
- },
- // 监听切换事件
- listChange(e) {
- this.checkid = e.detail.current;
- },
- // 點擊搜索框
- clickSearch() {
- uni.navigateTo({
- url: '/pages/product/search'
- });
- },
- // 请求载入数据
- async loadData() {
- loadIndexs({})
- .then(({ data }) => {
- let goods = data.info;
- this.carouselList = data.banner;
- this.swiperLength = this.carouselList.length;
- this.menusList = data.menus;
- this.goodsList = goods.firstList; //最新商品
- this.bastList = goods.bastList; //精品推荐
- this.bastBanner = data.benefit; //促销单品
- this.$set(this, 'couponArray', data.couponList); //保存卡包券
- uni.stopPullDownRefresh();
- })
- .catch(e => {
- uni.stopPullDownRefresh();
- });
- },
- //详情页
- navToDetailPage(item) {
- let id = item.id;
- uni.navigateTo({
- url: '/pages/product/product?id=' + id
- });
- },
- navToGiftDetailPage(item) {
- let id = item.id;
- console.log(item);
- uni.navigateTo({
- url: '/pages/product/product?id=' + id + '>ype=0'
- });
- },
- navToLevelDetailPage(item) {
- let id = item.id;
- console.log(item);
- uni.navigateTo({
- url: '/pages/product/product?id=' + id + '>ype=1'
- });
- },
- // 轮播图跳转
- bannerNavToUrl(item) {
- // #ifdef H5
- if (item.wap_url.indexOf('http') > 0) {
- window.location.href = item.wap_url;
- }
- // #endif
- //测试数据没有写id,用title代替
- uni.navigateTo({
- url: item.wap_url
- });
- }
- }
- };
- </script>
- <style lang="scss">
- .Mask {
- width: 100%;
- height: 100vh;
- position: fixed;
- z-index: 99999;
- background-color: rgba(0, 0, 0, 0.7);
- top: 0;
- image {
- width: 100%;
- height: 100vh;
- }
- }
- .bg {
- position: absolute;
- top: 0;
- left: 0;
- right: 0;
- width: 750rpx;
- height: 1654rpx;
- image {
- width: 100%;
- height: 100%;
- }
- }
- page {
- background: #9e7457;
- }
- .m-t {
- margin-top: 16rpx;
- }
- /*公用边框样式*/
- %icon {
- margin-right: 10rpx;
- display: inline-block;
- padding: 2rpx 10rpx;
- border: 1rpx solid $color-yellow;
- color: $color-yellow;
- line-height: 1;
- font-size: $font-base;
- border-radius: 10rpx;
- }
- .f-header {
- display: flex;
- align-items: center;
- height: 92rpx;
- padding: 6rpx 30rpx 8rpx;
- image {
- flex-shrink: 0;
- width: 80rpx;
- height: 80rpx;
- margin-right: 20rpx;
- }
- .tit-box {
- @extend %font-title-box;
- }
- .tit {
- @extend %font-title;
- }
- .iconenter {
- font-size: $font-lg + 2rpx;
- color: $font-color-light;
- }
- .f-left-icon {
- @extend %f-left-icon;
- }
- .iconfont {
- font-size: $font-sm - 2rpx;
- }
- }
- // 列表
- .list-box-h {
- height: 1550rpx;
- }
- .good-wrap {
- padding-top: 898rpx;
- .good-tit {
- position: relative;
- .good-tit-bg {
- position: absolute;
- top: 0;
- left: 0;
- right: 0;
- width: 750rpx;
- height: 86rpx;
- image {
- width: 100%;
- height: 100%;
- }
- }
- .good-tit-font {
- text-align: center;
- line-height: 86rpx;
- position: relative;
- z-index: 2;
- font-size: 36rpx;
- font-family: Source Han Serif SC;
- font-weight: 800;
- color: #fff4e5;
- }
- }
- .item-wrap {
- margin: 20rpx auto;
- width: 708rpx;
- height: 606rpx;
- border-radius: 12rpx;
- padding: 26rpx;
- position: relative;
- z-index: 2;
- .item-wrap-bg {
- position: absolute;
- top: 0;
- left: 0;
- right: 0;
- width: 708rpx;
- height: 606rpx;
- image {
- width: 100%;
- height: 100%;
- }
- }
- .item-title {
- padding-top: 20rpx;
- text-align: center;
- position: relative;
- z-index: 2;
- font-size: 36rpx;
- font-family: Source Han Serif SC;
- font-weight: 600;
- color: #653600;
- text-shadow: 0px 2rpx 2rpx rgba(206, 173, 129, 0.75);
- }
- .item-img {
- position: relative;
- z-index: 2;
- margin-top: 20rpx;
- width: 665rpx;
- height: 339rpx;
- background: #f0d4ac;
- border-radius: 6rpx 6rpx 6rpx 6rpx;
- display: flex;
- justify-content: center;
- align-items: center;
- image {
- width: 98%;
- height: 96%;
- border-radius: 6rpx 6rpx 6rpx 6rpx;
- }
- }
- .item-btm {
- position: relative;
- z-index: 2;
- display: flex;
- height: 100rpx;
- justify-content: space-between;
- align-items: center;
- // position: relative;
- .item-price {
- font-size: 27rpx;
- font-family: Source Han Serif SC;
- font-weight: bold;
- color: rgba(153, 0, 0, 1);
- justify-content: flex-start;
- align-items: flex-end;
- .price-tit {
- color: rgba(84, 50, 11, 1);
- }
- .price-logo {
- display: inline-block;
- padding: 0 5rpx 0 15rpx;
- }
- .price-val {
- font-size: 54rpx;
- position: relative;
- top: 8rpx;
- }
- }
- .item-btn {
- width: 154rpx;
- height: 50rpx;
- background: #910704;
- border-radius: 25rpx;
- text-align: center;
- line-height: 50rpx;
- font-size: 22rpx;
- font-family: Source Han Sans CN;
- font-weight: 400;
- color: #ffffff;
- }
- }
- }
- }
- </style>
|