123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227 |
- <template>
- <!-- 首页 -->
- <view v-if="pageShow" class="page"
- :class="bgTabVal==2?'fullsize noRepeat':bgTabVal==1?'repeat ysize':'noRepeat ysize'"
- :style="'background-color:'+bgColor+';background-image: url('+bgPic+');min-height:'+windowHeight+'px;'">
- <view v-if="!errorNetwork" :style="colorStyle">
- <skeleton :show="showSkeleton" :isNodes="isNodes" ref="skeleton" loading="chiaroscuro" selector="skeleton"
- bgcolor="#FFF"></skeleton>
- <view class="index skeleton" :style="{visibility: showSkeleton ? 'hidden' : 'visible'}">
- <!-- #ifdef H5 -->
- <view v-for="(item, index) in styleConfig" :key="index">
- <component :is="item.name" :index="index" :dataConfig="item" @changeBarg="changeBarg"
- @changeTab="changeTab" :tempArr="tempArr" :iSshowH="iSshowH" @detail="goDetail"
- :isSortType="isSortType" @bindSortId="bindSortId" @bindHeight="bindHeight" :isFixed="isFixed"
- :addressInfo="addressInfo" @getAddress="getAddress">
- </component>
- </view>
- <!-- #endif -->
- <!-- #ifdef MP || APP-PLUS -->
- <!-- 自定义样式 -->
- <block v-for="(item, index) in styleConfig" :key="index">
- <shortVideo v-if="item.name == 'shortVideo'" :dataConfig="item" :isSortType="isSortType">
- </shortVideo>
- <userInfor v-if="item.name == 'userInfor'" :dataConfig="item" :isSortType="isSortType">
- </userInfor>
- <newVip v-if="item.name == 'newVip'" :dataConfig="item" :isSortType="isSortType">
- </newVip>
- <activeParty v-if="item.name == 'activeParty'" :dataConfig="item" :isSortType="isSortType">
- </activeParty>
- <!-- 文章列表 -->
- <articleList v-if="item.name == 'articleList'" :dataConfig="item" :isSortType="isSortType">
- </articleList>
- <bargain v-if="item.name == 'bargain'" :dataConfig="item" @changeBarg="changeBarg"
- :isSortType="isSortType"></bargain>
- <blankPage v-if="item.name == 'blankPage'" :dataConfig="item" :isSortType="isSortType"></blankPage>
- <combination v-if="item.name == 'combination'" :dataConfig="item" :isSortType="isSortType">
- </combination>
- <!-- 优惠券 -->
- <coupon v-if="item.name == 'coupon'" :dataConfig="item" :isSortType="isSortType"></coupon>
- <!-- 客户服务 -->
- <customerService v-if="item.name == 'customerService'" :dataConfig="item" :isSortType="isSortType">
- </customerService>
- <!-- 商品列表 -->
- <goodList v-if="item.name == 'goodList'" :dataConfig="item" @detail="goDetail"
- :isSortType="isSortType"></goodList>
- <guide v-if="item.name == 'guide'" :dataConfig="item" :isSortType="isSortType"></guide>
- <!-- 顶部搜索框 -->
- <headerSerch v-if="item.name == 'headerSerch'" :dataConfig="item" :addressInfo="addressInfo"
- @getAddress="getAddress"></headerSerch>
- <!-- 直播模块 -->
- <liveBroadcast v-if="item.name == 'liveBroadcast'" :dataConfig="item" :isSortType="isSortType">
- </liveBroadcast>
- <menus v-if="item.name == 'menus'" :dataConfig="item" :isSortType="isSortType"></menus>
- <!-- 实时消息 -->
- <news v-if="item.name == 'news'" :dataConfig="item" :isSortType="isSortType"></news>
- <!-- 图片库 -->
- <pictureCube v-if="item.name == 'pictureCube'" :dataConfig="item" :isSortType="isSortType">
- </pictureCube>
- <!-- 促销列表 -->
- <promotionList v-if="item.name == 'promotionList'" :dataConfig="item" @changeTab="changeTab"
- :tempArr="tempArr" :iSshowH="iSshowH" @detail="goDetail" :isSortType="isSortType">
- </promotionList>
- <richText v-if="item.name == 'richText'" :dataConfig="item" :isSortType="isSortType"></richText>
- <seckill v-if="item.name == 'seckill'" :dataConfig="item" :isSortType="isSortType"></seckill>
- <!-- 轮播图-->
- <swiperBg v-if="item.name == 'swiperBg'" :dataConfig="item" :isSortType="isSortType"></swiperBg>
- <swipers v-if="item.name == 'swipers'" :dataConfig="item" :isSortType="isSortType"></swipers>
- <!-- 顶部选项卡 -->
- <tabNav v-if="item.name == 'tabNav'" :dataConfig="item" @bindHeight="bindHeighta"
- @bindSortId="bindSortId" :isFixed="isFixed"></tabNav>
- <!-- 标题 -->
- <titles v-if="item.name == 'titles'" :dataConfig="item" :isSortType="isSortType"></titles>
- </block>
- <!-- #endif -->
- <!-- 分类商品模块 -->
- <!-- #ifdef APP-PLUS -->
- <view class="sort-product" v-if="isSortType == 1" style="margin-top: 0;">
- <scroll-view scroll-x="true" class="sort-scroll">
- <view class="sort-box" v-if="sortList.children && sortList.children.length">
- <view class="sort-item" v-for="(item, index) in sortList.children" :key="index"
- @click="changeSort(item, index)" :class="{ on: curSort == index }">
- <image :src="item.pic" mode="" v-if="item.pic"></image>
- <image src="/static/images/sort-img.png" mode="" v-else></image>
- <view class="txt">{{ item.cate_name }}</view>
- </view>
- </view>
- </scroll-view>
- <!-- 首页商品列表 -->
- <view class="product-list" v-if="goodList.length">
- <view class="product-item" v-for="(item, index) in goodList" @click="goGoodsDetail(item)">
- <lazyLoad :src="item.image" width="100%" height="100%"></lazyLoad>
- <span class="pictrue_log_big pictrue_log_class"
- v-if="item.activity && item.activity.type === '1'">秒杀</span>
- <span class="pictrue_log_big pictrue_log_class"
- v-if="item.activity && item.activity.type === '2'">砍价</span>
- <span class="pictrue_log_big pictrue_log_class"
- v-if="item.activity && item.activity.type === '3'">拼团</span>
- <view class="info">
- <view class="title line1">{{ item.store_name }}</view>
- <view class="price-box">
- <text>¥</text>
- {{ item.price }}
- </view>
- </view>
- </view>
- </view>
- <Loading :loaded="loaded" :loading="loading"></Loading>
- <view v-if="goodList.length == 0 && loaded" class="sort-scroll">
- <view class="empty-box">
- <image :src="imgHost + '/statics/images/no-thing.png'"></image>
- <view class="tips">暂无商品,去看点别的吧</view>
- </view>
- <recommend :hostProduct="hostProduct"></recommend>
- </view>
- </view>
- <!-- #endif -->
- <!-- #ifndef APP-PLUS -->
- <!-- 商品排序 -->
- <view class="sort-product" v-if="isSortType == 1" :style="{ marginTop: sortMpTop + 'px' }">
- <scroll-view scroll-x="true" class="sort-scroll">
- <view class="sort-box" v-if="sortList.children && sortList.children.length">
- <view class="sort-item" v-for="(item, index) in sortList.children" :key="index"
- @click="changeSort(item, index)" :class="{ on: curSort == index }">
- <image :src="item.pic" mode="" v-if="item.pic"></image>
- <image src="/static/images/sort-img.png" mode="" v-else></image>
- <view class="txt">{{ item.cate_name }}</view>
- </view>
- </view>
- </scroll-view>
- <!-- 首页底部商品列表 -->
- <view class="product-list" v-if="goodList.length">
- <view class="product-item" v-for="(item, index) in goodList" @click="goGoodsDetail(item)">
- <!-- <image :src="item.image"></image> -->
- <lazyLoad :src="item.image" width="344rpx" height="344rpx"></lazyLoad>
- <span class="pictrue_log_big pictrue_log_class"
- v-if="item.activity && item.activity.type === '1'">秒杀</span>
- <span class="pictrue_log_big pictrue_log_class"
- v-if="item.activity && item.activity.type === '2'">砍价</span>
- <span class="pictrue_log_big pictrue_log_class"
- v-if="item.activity && item.activity.type === '3'">拼团</span>
- <view class="info">
- <view class="title line1">{{ item.store_name }}</view>
- <view class="price-box">
- <text>¥</text>
- {{ item.price }}
- </view>
- </view>
- </view>
- </view>
- <Loading :loaded="loaded" :loading="loading"></Loading>
- <view class="" v-if="goodList.length == 0 && loaded" class="sort-scroll">
- <view class="empty-box">
- <image :src="imgHost + '/statics/images/no-thing.png'"></image>
- <view class="tips">暂无商品,去看点别的吧</view>
- </view>
- <recommend :hostProduct="hostProduct"></recommend>
- </view>
- </view>
- <!-- #endif -->
- <!-- <indexComponents ref="mapStoreList"></indexComponents> -->
- <!-- <couponWindow :window="isCouponShow" @onColse="couponClose" :couponImage="couponObj.image"
- :couponList="couponObj.list"></couponWindow> -->
- <view class="uni-p-b-98" v-if="footerStatus"></view>
- <view v-if="site_config" class="site-config" @click="goICP">{{ site_config }}</view>
- <pageFooter></pageFooter>
- </view>
- </view>
- <view v-else>
- <view class="error-network">
- <image :src="imgHost + '/statics/images/error-network.png'"></image>
- <view class="title">网络连接断开</view>
- <view class="con">
- <view class="label">请检查情况:</view>
- <view class="item">· 在设置中是否已开启网络权限</view>
- <view class="item">· 当前是否处于弱网环境</view>
- <view class="item">· 版本是否过低,升级试试吧</view>
- </view>
- <view class="btn" @click="reconnect">重新连接</view>
- </view>
- </view>
- </view>
- </template>
- <script>
- const app = getApp();
- import colors from "@/mixins/color";
- import permision from "@/js_sdk/wa-permission/permission.js"
- import {
- getCouponV2,
- getCouponNewUser,
- copyRight
- } from '@/api/api.js';
- import {
- getShare
- } from '@/api/public.js';
- // #ifdef H5
- import mConfig from './components/index.js';
- import {
- silenceAuth
- } from '@/api/public.js';
- // #endif
- // #ifdef MP || APP-PLUS
- // import indexComponents from "./components/indexComponents.vue"
- import userInfor from './components/userInfor';
- import newVip from './components/newVip';
- import shortVideo from './components/shortVideo';
- import activeParty from './components/activeParty';
- import headerSerch from './components/headerSerch';
- import swipers from './components/swipers';
- import coupon from './components/coupon';
- import articleList from './components/articleList';
- import bargain from './components/bargain';
- import blankPage from './components/blankPage';
- import combination from './components/combination';
- import customerService from './components/customerService';
- import goodList from './components/goodList';
- import guide from './components/guide';
- import liveBroadcast from './components/liveBroadcast';
- import menus from './components/menus';
- import news from './components/news';
- import pictureCube from './components/pictureCube';
- import promotionList from './components/promotionList';
- import richText from './components/richText';
- import seckill from './components/seckill';
- import swiperBg from './components/swiperBg';
- import tabNav from './components/tabNav';
- import titles from './components/titles';
- import {
- getTemlIds
- } from '@/api/api.js';
- import {
- SUBSCRIBE_MESSAGE,
- TIPS_KEY
- } from '@/config/cache';
- // #endif
- import {
- mapGetters
- } from 'vuex';
- import {
- getDiy,
- getIndexData
- } from '@/api/api.js';
- import {
- getGeocoder
- } from '@/api/user.js';
- import {
- getGroomList,
- getCategoryList,
- getProductslist,
- getProductHot,
- diyProduct
- } from '@/api/store.js';
- import {
- goShopDetail
- } from '@/libs/order.js';
- import {
- toLogin
- } from '@/libs/login.js';
- import {
- HTTP_REQUEST_URL
- } from '@/config/app';
- import pageFooter from '@/components/pageFooter/index.vue';
- import Loading from '@/components/Loading/index.vue';
- import recommend from '@/components/recommend';
- import lazyLoad from '@/components/muqian-lazyLoad/muqian-lazyLoad.vue'
- export default {
- computed: mapGetters(['isLogin', 'uid', 'cartNum']),
- mixins: [colors],
- components: {
- recommend,
- Loading,
- pageFooter,
- // couponWindow,
- // indexComponents,
- lazyLoad,
- // #ifdef H5
- ...mConfig,
- // #endif
- // #ifdef MP || APP-PLUS
- newVip,
- userInfor,
- shortVideo,
- activeParty,
- headerSerch,
- swipers,
- coupon,
- articleList,
- bargain,
- blankPage,
- combination,
- customerService,
- goodList,
- guide,
- liveBroadcast,
- menus,
- pictureCube,
- news,
- promotionList,
- richText,
- seckill,
- swiperBg,
- tabNav,
- titles
- // #endif
- },
- data() {
- return {
- showSkeleton: true, //骨架屏显示隐藏
- isNodes: 0, //控制什么时候开始抓取元素节点,只要数值改变就重新抓取
- styleConfig: [],
- tempArr: [],
- goodType: 3,
- loading: false,
- loadend: false,
- loadTitle: '下拉加载更多', //提示语
- page: 1,
- limit: this.$config.LIMIT,
- iSshowH: false,
- numConfig: 0,
- code: '',
- isCouponShow: false,
- couponObj: {},
- couponObjs: {
- show: false
- },
- shareInfo: {},
- footConfig: {},
- isSortType: 0,
- sortList: '',
- sortAll: [],
- goodPage: 1,
- goodList: [],
- sid: 0,
- curSort: 0,
- sortMpTop: 0,
- loaded: false,
- loading: false,
- hostProduct: [],
- hotScroll: false,
- hotPage: 1,
- hotLimit: 10,
- domOffsetTop: 50,
- // #ifdef APP-PLUS || MP
- isFixed: true,
- // #endif
- // #ifdef H5
- isFixed: false,
- // #endif
- site_config: '',
- errorNetwork: false, // 是否断网
- footerStatus: false,
- isHeaderSerch: false,
- bgColor: '',
- bgPic: '',
- bgTabVal: '',
- pageShow: true,
- windowHeight: 0,
- imgHost: HTTP_REQUEST_URL,
- addressInfo: '选择地址'
- };
- },
- onLoad(options) {
- let that = this
- that.getOptions(options);
- this.$nextTick(function() {
- uni.getSystemInfo({
- success: function(res) {
- that.windowHeight = res.windowHeight;
- }
- });
- })
- const {
- state,
- scope
- } = options;
- // #ifdef MP
- uni.getLocation({
- type: 'wgs84',
- success: function(res) {
- try {
- uni.setStorageSync('user_latitude', res.latitude);
- uni.setStorageSync('user_longitude', res.longitude);
- that.getGeocoderCity(res.latitude, res.longitude);
- // that.$refs.mapStoreList.getlist();
- } catch {}
- }
- });
- // #endif
- // #ifdef APP-PLUS
- uni.getSystemInfo({
- success(res) {
- if (res.model.indexOf('iPhone') !== -1) {
- // iOS上是否给予位置权限,有权限返回true,否则返回false
- if (!permision.judgeIosPermission('location')) {
- uni.getLocation({
- type: 'wgs84',
- success: (res) => {
- try {
- uni.setStorageSync('user_latitude', res.latitude);
- uni.setStorageSync('user_longitude', res.longitude);
- that.getGeocoderCity(res.latitude, res.longitude);
- // that.$refs.mapStoreList.getlist();
- } catch {}
- }
- });
- }
- } else {
- // 安卓手机 1 已获取授权 0 未获取授权 -1 被永久拒绝授权
- // 注意:Android是动态权限,请求权限状态时会触发弹框询问是否赋权(如果已经同意或永久禁止则不会询问),所以必须使用异步方式来处理
- permision.requestAndroidPermission('android.permission.ACCESS_FINE_LOCATION').then(res => {
- if (res != 0) {
- uni.getLocation({
- type: 'wgs84',
- success: (res) => {
- try {
- uni.setStorageSync('user_latitude', res.latitude);
- uni.setStorageSync('user_longitude', res
- .longitude);
- that.getGeocoderCity(res.latitude, res.longitude);
- // that.$refs.mapStoreList.getlist();
- } catch {}
- }
- });
- }
- })
- }
- }
- });
- // #endif
- // #ifdef H5
- if (this.$wechat.isWeixin()) {
- this.$wechat.location().then(res => {
- uni.setStorageSync('user_latitude', res.latitude);
- uni.setStorageSync('user_longitude', res.longitude);
- that.getGeocoderCity(res.latitude, res.longitude);
- })
- } else {
- uni.getLocation({
- type: 'wgs84',
- success: function(res) {
- try {
- uni.setStorageSync('user_latitude', res.latitude);
- uni.setStorageSync('user_longitude', res.longitude);
- that.getGeocoderCity(res.latitude, res.longitude);
- // that.$refs.mapStoreList.getlist();
- } catch {}
- }
- });
- }
- // #endif
- this.diyData();
- this.getIndexData();
- // #ifdef H5
- this.setOpenShare();
- // #endif
- // #ifdef MP
- this.getTemlIds();
- // #endif
- getShare().then(res => {
- this.shareInfo = res.data;
- });
- // #ifndef APP-PLUS
- this.getCopyRight();
- // #endif
- // this.$refs.mapStoreList.getlist();
- },
- watch: {
- isLogin: {
- deep: true, //深度监听设置为 true
- handler: function(newV, oldV) {
- // 优惠券弹窗
- var newDates = new Date().toLocaleDateString();
- if (newV) {
- try {
- var oldDate = uni.getStorageSync('oldDate') || '';
- } catch {}
- if (oldDate != newDates) {
- // this.getCoupon();
- }
- }
- }
- }
- },
- onShow() {
- if (this.cartNum > 0) {
- uni.setTabBarBadge({
- index: 3,
- text: this.cartNum + ''
- })
- } else {
- uni.hideTabBarRedDot({
- index: 3
- })
- }
- uni.removeStorageSync('form_type_cart');
- // 优惠券弹窗
- // if (this.isLogin) {
- // this.getCoupon();
- // }
- this.getdiyProduct()
- },
- onReady() {},
- methods: {
- // 获取地址
- getAddress(e) {
- this.addressInfo = e.address;
- this.$nextTick(()=>{
- // this.$refs.mapStoreList.getlist(e);
- })
- },
- getGeocoderCity(latitude, longitude) {
- getGeocoder({
- lat: latitude,
- long: longitude
- }).then(res => {
- let address = res.address_component;
- this.addressInfo = address.city + address.district + (address.street ? address.street : '') ||
- '选择地址';
- })
- },
- // div商品详情
- getdiyProduct() {
- diyProduct().then(res => {
- // console.log(JSON.stringify(res.data.product_detail))
- uni.setStorageSync('diyProduct', JSON.stringify(res.data.product_detail))
- })
- },
- getCopyRight() {
- copyRight().then(res => {
- let data = res.data;
- this.site_config = data.record_No;
- uni.setStorageSync('copyNameInfo', data.copyrightContext);
- uni.setStorageSync('copyImageInfo', data.copyrightImage);
- }).catch(err => {
- return this.$util.Tips({
- title: err.msg
- });
- });
- },
- getOptions(options) {
- let that = this;
- // #ifdef MP
- if (options.scene) {
- let value = that.$util.getUrlParams(decodeURIComponent(options.scene));
- //记录推广人uid
- if (value.pid) app.globalData.spid = value.pid;
- }
- // #endif
- if (options.pid) app.globalData.spid = options.pid;
- },
- // 重新链接
- reconnect() {
- uni.showLoading({
- title: '加载中'
- })
- this.diyData();
- this.getIndexData();
- getShare().then(res => {
- this.shareInfo = res.data;
- });
- },
- goICP() {
- // #ifdef H5
- window.open('http://beian.miit.gov.cn/');
- // #endif
- // #ifdef MP
- uni.navigateTo({
- url: `/pages/annex/web_view/index?url=https://beian.miit.gov.cn/`
- });
- // #endif
- },
- bindHeighta(data) {
- // #ifdef APP-PLUS
- this.sortMpTop = data.top + data.height;
- // #endif
- },
- bindHeight(data) {
- uni.hideLoading();
- this.domOffsetTop = data.top;
- },
- // 去商品详情
- goGoodsDetail(item) {
- goShopDetail(item, this.uid).then(res => {
- uni.navigateTo({
- url: `/pages/goods_details/index?id=${item.id}`
- });
- });
- },
- /**
- * 获取我的推荐
- */
- get_host_product: function() {
- let that = this;
- if (that.hotScroll) return;
- getProductHot(that.hotPage, that.hotLimit).then(res => {
- that.hotPage++;
- that.hotScroll = res.data.length < that.hotLimit;
- that.hostProduct = that.hostProduct.concat(res.data);
- // that.$set(that, 'hostProduct', res.data)
- });
- },
- // 分类点击
- changeSort(item, index) {
- if (this.curSort == index) return;
- this.curSort = index;
- this.sid = item.id;
- this.goodList = [];
- this.goodPage = 1;
- this.loaded = false;
- this.getGoodsList();
- },
- // 获取分类id
- bindSortId(data) {
- this.isSortType = data == -99 ? 0 : 1;
- this.getProductList(data);
- if (this.hostProduct.length == 0) {
- this.get_host_product();
- }
- },
- getProductList(data) {
- let tempObj = '';
- this.curSort = 0;
- this.loaded = false;
- if (this.sortAll.length > 0) {
- this.sortAll.forEach((el, index) => {
- if (el.id == data) {
- this.$set(this, 'sortList', el);
- this.sid = el.children.length ? el.children[0].id : '';
- }
- });
- this.goodList = [];
- this.goodPage = 1;
- this.$nextTick(() => {
- if (this.sortList != '') this.getGoodsList();
- });
- } else {
- getCategoryList().then(res => {
- this.sortAll = res.data;
- res.data.forEach((el, index) => {
- if (el.id == data) {
- this.sortList = el;
- this.sid = el.children.length ? el.children[0].id : '';
- }
- });
- this.goodList = [];
- this.goodPage = 1;
- this.$nextTick(() => {
- if (this.sortList != '') this.getGoodsList();
- });
- });
- }
- },
- // 商品列表
- getGoodsList() {
- if (this.loading || this.loaded) return;
- this.loading = true;
- getProductslist({
- sid: this.sid,
- keyword: '',
- priceOrder: '',
- salesOrder: '',
- news: 0,
- page: this.goodPage,
- limit: 10,
- cid: this.sortList.id
- }).then(res => {
- this.loading = false;
- this.loaded = res.data.length < 10;
- this.goodPage++;
- this.goodList = this.goodList.concat(res.data);
- });
- },
- // 新用户优惠券
- // getNewCoupon() {
- // const oldUser = uni.getStorageSync('oldUser') || 0;
- // if (!oldUser) {
- // getCouponNewUser().then(res => {
- // const {
- // data
- // } = res;
- // if (data.show) {
- // if (data.list.length) {
- // // this.isCouponShow = true;
- // this.couponObj = data;
- // uni.setStorageSync('oldUser', 1);
- // }
- // } else {
- // uni.setStorageSync('oldUser', 1);
- // }
- // });
- // }
- // },
- // 优惠券弹窗
- // getCoupon() {
- // const tagDate = uni.getStorageSync('tagDate') || '',
- // nowDate = new Date().toLocaleDateString();
- // if (tagDate === nowDate) {
- // this.getNewCoupon();
- // } else {
- // getCouponV2().then(res => {
- // const {
- // data
- // } = res;
- // if (data.list.length) {
- // this.isCouponShow = true;
- // this.couponObj = data;
- // uni.setStorageSync('tagDate', new Date().toLocaleDateString());
- // } else {
- // this.getNewCoupon();
- // }
- // });
- // }
- // },
- // 优惠券弹窗关闭
- // couponClose() {
- // this.isCouponShow = false;
- // if (!uni.getStorageSync('oldUser')) {
- // this.getNewCoupon();
- // }
- // },
- onLoadFun() {},
- // #ifdef H5
- // 获取url后面的参数
- getQueryString(name) {
- var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i');
- var reg_rewrite = new RegExp('(^|/)' + name + '/([^/]*)(/|$)', 'i');
- var r = window.location.search.substr(1).match(reg);
- var q = window.location.pathname.substr(1).match(reg_rewrite);
- if (r != null) {
- return unescape(r[2]);
- } else if (q != null) {
- return unescape(q[2]);
- } else {
- return null;
- }
- },
- // #endif
- // #ifdef MP
- getTemlIds() {
- let messageTmplIds = wx.getStorageSync(SUBSCRIBE_MESSAGE);
- if (!messageTmplIds) {
- getTemlIds().then(res => {
- if (res.data) wx.setStorageSync(SUBSCRIBE_MESSAGE, JSON.stringify(res.data));
- });
- }
- },
- // #endif
- // 对象转数组
- objToArr(data) {
- let obj = Object.keys(data);
- let m = obj.map(key => data[key]);
- return m;
- },
- diyData() {
- let that = this;
- getDiy(0).then(res => {
- setTimeout(() => {
- this.isNodes++;
- }, 0);
- this.errorNetwork = false
- let data = res.data;
- if (data.is_bg_color) {
- this.bgColor = data.color_picker
- }
- if (data.is_bg_pic) {
- this.bgPic = data.bg_pic
- this.bgTabVal = data.bg_tab_val
- }
- this.pageShow = data.is_show
- uni.setNavigationBarTitle({
- title: res.data.title
- });
- let temp = [];
- let lastArr = that.objToArr(res.data.value);
- lastArr.forEach((item, index, arr) => {
- if (item.name == 'headerSerch') {
- this.isHeaderSerch = true
- }
- if (item.name == 'pageFoot') {
- arr.splice(index, 1);
- }
- if (item.name == 'promotionList') {
- that.numConfig = item.numConfig.val;
- that.goodType = item.tabConfig.list[0].link.activeVal;
- that.getGroomList();
- }
- if (item.name == 'tabNav') {
- // #ifndef APP-PLUS
- // uni.showLoading({
- // title: '加载中',
- // mask: true,
- // });
- // #endif
- // setTimeout(function() {
- // uni.hideLoading();
- // }, 8000);
- }
- temp = arr;
- });
- function sortNumber(a, b) {
- return a.timestamp - b.timestamp;
- }
- temp.sort(sortNumber)
- that.styleConfig = temp;
- setTimeout(() => {
- this.showSkeleton = false
- }, 1000)
- }).catch(error => {
- // #ifdef APP-PLUS
- if (error.status) {
- uni.hideLoading()
- if (that.errorNetwork) {
- uni.showToast({
- title: '连接失败',
- icon: 'none',
- duration: 2000
- })
- }
- this.errorNetwork = true
- this.showSkeleton = false;
- }
- // #endif
- });
- },
- getIndexData() {},
- changeBarg(item) {
- if (!this.isLogin) {
- toLogin();
- } else {
- uni.navigateTo({
- url: `/pages/activity/goods_bargain_details/index?id=${item.id}&bargain=${this.$store.state.app.uid}`
- });
- }
- },
- // 促销列表的点击事件;
- changeTab(type) {
- this.goodType = type;
- this.tempArr = [];
- this.page = 1;
- this.loadend = false;
- let onloadH = true;
- this.getGroomList(onloadH);
- },
- // 精品推荐
- getGroomList(onloadH) {
- let that = this;
- let type = that.goodType;
- if (that.loadend) return false;
- if (that.loading) return false;
- if (onloadH) {
- that.$set(that, 'iSshowH', true);
- }
- getGroomList(type, {
- page: that.page,
- limit: this.numConfig
- })
- .then(({
- data
- }) => {
- that.$set(that, 'iSshowH', false);
- let maxPage = Math.ceil(this.numConfig / this.limit);
- let list = data.list,
- loadend = list.length < that.limit || that.page >= maxPage;
- let tempArr = that.$util.SplitArray(list, that.tempArr);
- that.$set(that, 'tempArr', tempArr.slice(0, this.numConfig));
- that.loadend = loadend;
- that.loadTitle = loadend ? '没有更多内容啦~' : '加载更多';
- that.page = that.page + 1;
- that.loading = false;
- })
- .catch(res => {
- that.loading = false;
- that.loadTitle = '加载更多';
- });
- },
- goDetail(item) {
- goShopDetail(item, this.$store.state.app.uid).then(res => {
- uni.navigateTo({
- url: `/pages/goods_details/index?id=${item.id}`
- });
- });
- },
- // #ifdef H5
- // 微信分享;
- setOpenShare: function() {
- let that = this;
- let uid = this.uid ? this.uid : 0;
- if (that.$wechat.isWeixin()) {
- getShare().then(res => {
- let data = res.data;
- let configAppMessage = {
- desc: data.synopsis,
- title: data.title,
- link: location.href + '?pid=' + uid,
- imgUrl: data.img
- };
- that.$wechat.wechatEvevt(['updateAppMessageShareData', 'updateTimelineShareData',
- 'onMenuShareAppMessage', 'onMenuShareTimeline'
- ],
- configAppMessage);
- });
- }
- }
- // #endif
- },
- onReachBottom: function() {
- if (this.isSortType == 0) {
- // this.getGroomList();
- } else {
- this.getGoodsList();
- }
- },
- onPageScroll(e) {
- // #ifdef H5
- if (this.isHeaderSerch) {
- if (e.scrollTop > this.domOffsetTop) {
- this.isFixed = true;
- }
- if (e.scrollTop < this.domOffsetTop) {
- this.$nextTick(() => {
- this.isFixed = false;
- });
- }
- } else {
- this.isFixed = false
- }
- // #endif
- },
- //#ifdef MP
- onShareAppMessage() {
- let uid = this.uid ? this.uid : 0;
- return {
- title: this.shareInfo.title,
- path: '/pages/index/index?pid=' + uid
- };
- },
- //分享到朋友圈
- onShareTimeline: function() {
- return {
- title: this.shareInfo.title,
- path: '/pages/index/index'
- // imageUrl: this.shareInfo.img
- };
- }
- //#endif
- };
- </script>
- <style lang="scss">
- // page {
- // padding-bottom: 50px;
- // }
- .pictrue_log_class {
- background-color: var(--view-theme);
- }
- .page {
- padding-bottom: 50px;
- }
- .ysize {
- background-size: 100%;
- }
- .fullsize {
- background-size: 100% 100%;
- }
- .repeat {
- background-repeat: repeat;
- }
- .noRepeat {
- background-repeat: no-repeat;
- }
- .privacy-wrapper {
- z-index: 999;
- position: fixed;
- left: 0;
- top: 0;
- width: 100%;
- height: 100%;
- background: #7F7F7F;
- .privacy-box {
- position: absolute;
- left: 50%;
- top: 50%;
- transform: translate(-50%, -50%);
- width: 560rpx;
- padding: 50rpx 45rpx 0;
- background: #fff;
- border-radius: 20rpx;
- .title {
- text-align: center;
- font-size: 32rpx;
- text-align: center;
- color: #333;
- font-weight: 700;
- }
- .content {
- margin-top: 20rpx;
- line-height: 1.5;
- font-size: 26rpx;
- color: #666;
- navigator {
- display: inline-block;
- color: #E93323;
- }
- }
- .btn-box {
- margin-top: 40rpx;
- text-align: center;
- font-size: 30rpx;
- .btn-item {
- height: 82rpx;
- line-height: 82rpx;
- background: linear-gradient(90deg, #F67A38 0%, #F11B09 100%);
- color: #fff;
- border-radius: 41rpx;
- }
- .btn {
- padding: 30rpx 0;
- }
- }
- }
- }
- .error-network {
- position: fixed;
- left: 0;
- top: 0;
- display: flex;
- flex-direction: column;
- align-items: center;
- width: 100%;
- height: 100%;
- padding-top: 40rpx;
- background: #fff;
- image {
- width: 414rpx;
- height: 336rpx;
- }
- .title {
- position: relative;
- top: -40rpx;
- font-size: 32rpx;
- color: #666;
- }
- .con {
- font-size: 24rpx;
- color: #999;
- .label {
- margin-bottom: 20rpx;
- }
- .item {
- margin-bottom: 20rpx;
- }
- }
- .btn {
- display: flex;
- align-items: center;
- justify-content: center;
- width: 508rpx;
- height: 86rpx;
- margin-top: 100rpx;
- border: 1px solid #D74432;
- color: #E93323;
- font-size: 30rpx;
- border-radius: 120rpx;
- }
- }
- .sort-scroll {
- background-color: #fff;
- }
- .sort-product {
- margin-top: 20rpx;
- .sort-box {
- display: flex;
- width: 100%;
- border-radius: 16rpx;
- padding: 30rpx 0;
- .sort-item {
- width: 20%;
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- flex-shrink: 0;
- image {
- width: 90rpx;
- height: 90rpx;
- border-radius: 50%;
- }
- .txt {
- color: #272727;
- font-size: 24rpx;
- margin-top: 10rpx;
- overflow: hidden;
- white-space: nowrap;
- text-overflow: ellipsis;
- width: 140rpx;
- text-align: center;
- }
- .pictrues {
- width: 90rpx;
- height: 90rpx;
- background: #f8f8f8;
- border-radius: 50%;
- margin: 0 auto;
- }
- .icon-gengduo1 {
- color: #333;
- }
- &.on {
- .txt {
- color: #fc4141;
- }
- image {
- border: 1px solid #fc4141;
- }
- }
- }
- }
- .product-list {
- display: flex;
- flex-wrap: wrap;
- justify-content: space-between;
- margin-top: 30rpx;
- padding: 0 20rpx;
- .product-item {
- position: relative;
- width: 344rpx;
- background: #fff;
- border-radius: 10rpx;
- margin-bottom: 20rpx;
- image {
- width: 100%;
- height: 344rpx;
- border-radius: 10rpx 10rpx 0 0;
- }
- .info {
- padding: 14rpx 16rpx;
- .title {
- font-size: 28rpx;
- }
- .price-box {
- font-size: 34rpx;
- font-weight: 700;
- margin-top: 8px;
- color: #fc4141;
- text {
- font-size: 26rpx;
- }
- }
- }
- }
- }
- }
- .empty-box {
- text-align: center;
- .tips {
- color: #aaa;
- font-size: 26rpx;
- }
- image {
- width: 414rpx;
- height: 304rpx;
- }
- }
- .site-config {
- margin: 40rpx 0;
- font-size: 24rpx;
- text-align: center;
- color: #666;
- &.fixed {
- position: fixed;
- bottom: 69px;
- left: 0;
- width: 100%;
- }
- }
- </style>
|