123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368 |
- <template>
- <view class="pages index">
- <view class="search-wrap">
- <view class="search">
- <view class="searchTxt">
-
- <uni-search-bar @confirm="search" ></uni-search-bar>
- </view>
- </view>
- </view>
-
- <view class="appAdv nomal-bottom">
- <swiper class="swiper" @change="swiperchange" :indicator-dots="swiper.indicatorDots" :previous-margin="swiper.previousmargin" :next-margin="swiper.nextmargin" :autoplay="swiper.autoplay" :interval="swiper.interval" :duration="swiper.duration">
- <swiper-item v-for="(item,index) in advertiseList" :key="index">
- <view class="adv-item" :class="{active:index==currentswiper}" @click="jumLink(item.url)">
- <image :src="$getimg+item.pic|miniImg(75)+'/thumbnail/600x300'" class="pic" mode="scaleToFill"></image>
- </view>
- </swiper-item>
- </swiper>
- </view>
-
- <view class="quick-links wrap write-radius nomal-bottom">
- <navigator class="quick-links-item" url="/pages/supplier/supplier">
- <view class="quick-links-item-til">供应商</view>
- <view class="quick-links-item-subtil">保供稳价</view>
- <view class="quick-links-item-img"><image src="/static/img/quick-links-04.png" mode="scaleToFill"></image></view>
- </navigator>
-
- <navigator class="quick-links-item" url="/pages/inbuild/inbuild">
- <view class="quick-links-item-til">产品溯源</view>
- <view class="quick-links-item-subtil">低价货源</view>
- <view class="quick-links-item-img"><image src="/static/img/quick-links-02.png" mode="scaleToFill"></image></view>
- </navigator>
-
- <navigator class="quick-links-item" url="/pages/inbuild/inbuild">
- <view class="quick-links-item-til">基地展示</view>
- <view class="quick-links-item-subtil">轻松卖货</view>
- <view class="quick-links-item-img"><image src="/static/img/quick-links-03.png" mode="scaleToFill"></image></view>
- </navigator>
-
- <navigator class="quick-links-item" url="/pages/inbuild/inbuild">
- <view class="quick-links-item-til">价格行情</view>
- <view class="quick-links-item-subtil">全国走货</view>
- <view class="quick-links-item-img"><image src="/static/img/quick-links-01.png" mode="scaleToFill"></image></view>
- </navigator>
- </view>
-
- <view class="category nomal-bottom">
- <view class="category-item category-item-all" @click="category()" :class="{active:categoryall==true}">全部</view>
- <scroll-view scroll-x="true" class="scroll-X category-scroll-view">
- <view v-for="(item,index) in categorylink" :key="index" @click="categoryclick(index)" :class="{active:index==ins && notall==true}" class="category-item">{{item.name}}</view>
- </scroll-view>
- <navigator class="category-item category-item-more" url="/pages/productcategory/productcategory">更多</navigator>
- {{item}}
- </view>
-
- <mescroll-body class="wrap" ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback" :down="downOption" :up="upOption">
- <view class="indexproduct">
- <view class="item-wrap" v-for="(item,index) in mescrollList" :key="index">
- <view class="item" :data-id="item.id" @click="jumpDetails(item.id)">
- <view class="item-img-wrap">
- <image :src="$getimg+item.pic|miniImg(60)+'/thumbnail/358x354'||'/static/img/inbuild.png'" class="item-img" mode="aspectFit"></image>
- </view>
- <view class="item-text-wrap">
- <view class="merchant f-ellipsis">
- {{item.brandName}}
-
- </view>
- <view class="item-til f-ellipsis">{{item.name}}</view>
- <view class="item-addr f-ellipsis">{{item.umsCompanyInfo}}</view>
- <view class="item-price-info">
- <text class="rmb" v-if="item.price">¥</text>
- <text class="price" :class="!item.price?'noprice':''">{{item.price||"暂无价格"}}</text>
- <text class="unit" v-if="item.unit">/{{item.unit}}</text>
- </view>
- </view>
- </view>
- </view>
-
- </view>
- </mescroll-body>
-
-
-
-
- </view>
- </template>
- <script>
-
- import { mapMutations } from 'vuex';
-
- import uniSearchBar from '@/components/uni-search-bar/uni-search-bar.vue'
-
- import MescrollMixin from "@/components/mescroll-uni/mescroll-mixins.js";
-
- import MescrollBody from "@/components/mescroll-uni/mescroll-body.vue";
- export default {
- mixins: [MescrollMixin],
- components: {
- MescrollBody,
- uniSearchBar,
- },
- data() {
- return {
- params:{
- token:'',
- tokenhead:'',
- keyword:'',
- productCategoryId:'',
-
- },
-
- advertiseList:[],
- swiper: {
- indicatorDots: true,
- autoplay: false,
- interval: 9000,
- duration: 500,
- previousmargin:'55rpx',
- nextmargin:'55rpx'
- },
- currentswiper:0,
- categorylink:[],
- mescroll: null,
-
- downOption: {
-
- },
-
- upOption: {
- page: {
- size: 10
- },
- noMoreSize: 5,
- empty: {
- tip: '暂无相关数据'
- }
- },
-
- mescrollList:[],
-
- ins:null,
-
- categoryall:true,
- notall:false,
- thispage:'',
-
- }
- },
- onLoad() {
- let serf = this;
-
-
-
-
- let locationLocaturl = window.location.search;
- function getUrlParams(url) {
- if (decodeURIComponent(url).indexOf('?') > -1) {
- var result = [];
- var urlParamsArr = decodeURIComponent(url).split('?');
- urlParamsArr.shift();
- let newUrlParamsArr = urlParamsArr.join('&').split('&');
- for (var i = 0; i < newUrlParamsArr.length; i++) {
- var paramKey = newUrlParamsArr[i].split('=')[0];
- var paramValue = newUrlParamsArr[i].split('=')[1];
- result.push({
- key: paramKey,
- value: paramValue
- });
- }
- return result;
- } else {
- console.log('该URL中不含参数');
- }
- };
- this.thispage = `/pages/index/index`;
- let locationArr = getUrlParams(locationLocaturl);
- if(!locationArr){
- window.location.replace(this.config.loginUrl);
- return
- };
- let itemtoken = locationArr.find(function(locationArr) {
- return locationArr.key === 'token';
- });
- let itemtokenHead = locationArr.find(function(locationArr) {
- return locationArr.key === 'tokenHead';
- });
- if (itemtoken) {
- this.params.token = itemtoken.value;
- }
- if (itemtokenHead) {
- this.params.tokenhead = itemtokenHead.value;
- }
- if(this.params.tokenhead&&this.params.token){
- let thetoken = this.params.tokenhead+this.params.token;
- this.$api.http.get(this.config.apiBaseurl+'/wechat/h5/info', {header: {Authorization:thetoken}}).then(res => {
- let userInfo = res.data;
- userInfo.accessToken = this.params.token;
- userInfo.tokenhead = this.params.tokenhead;
- this.setLogin(userInfo);
- }).catch(err => {
- if(err.data.message =='暂未登录或token已经过期'){
- let loginurl = `${this.config.apiBaseurl}/wechat/h5/authorize?returnUrl=${this.thispage}`
- console.log('loginurl',loginurl);
- window.location.replace(loginurl);
- return
- }
- console.log(err)
- });
- };
-
- this.$api.http.get(this.config.apiBaseurl+'/home/content', {header: {Authorization:this.params.tokenhead+this.params.token}}).then(res => {
- console.log('content',res)
- this.advertiseList = res.data.data.advertiseList;
- }).catch(err => {
- console.log(err)
- });
-
- this.$api.http.get(this.config.apiBaseurl+'/product/categorySearch', {header: {Authorization:this.params.tokenhead+this.params.token}}).then(res => {
- console.log('产品分类',res)
- this.categorylink = res.data.data;
- }).catch(err => {
- console.log(err)
- });
-
- },
- onShow() {
-
-
-
- },
- methods: {
-
- ...mapMutations(['setLogin']),
-
-
-
- search(e) {
- console.log(e);
-
- uni.navigateTo({
- url:`/pages/searchresults/searchresults?keyword=${e.value}`
- })
- },
-
-
- mescrollInit(mescroll) {
- this.mescroll = mescroll;
- },
-
- downCallback(){
-
-
- this.mescroll.resetUpScroll();
- },
-
- upCallback(page) {
- let pageNum = page.num;
- let pageSize = page.size;
- this.params = Object.assign(this.params,{pageNum:pageNum,pageSize:pageSize});
- this.$api.http.get(this.config.apiBaseurl+'/product/search',{params: this.params}).then(data => {
- if(data.data.code=='1001'){
-
-
-
- };
- console.log(data);
-
- let curPageData = data.data.data.list;
-
-
- let curPageLen = curPageData.length;
-
- let totalPage = data.data.data.totalPage;
-
- let totalSize = data.data.data.total;
-
-
-
-
-
- if(page.num == 1) this.mescrollList = [];
- this.mescrollList = this.mescrollList.concat(curPageData);
-
- console.log('this.mescrollList',JSON.parse(JSON.stringify(this.mescrollList)));
-
-
-
-
- this.mescroll.endBySize(curPageLen, totalSize);
- console.log('pageSize',pageSize,'curPageLen',curPageLen,'totalSize',totalSize);
-
-
-
-
-
- }).catch(err => {
- this.mescroll.endErr()
- console.log(err)
-
- });
-
- },
-
- categoryclick(num){
- this.categoryall = false;
- this.notall = true;
- this.ins=num;
- this.nowtype = this.categorylink[num].name;
-
- this.params.productCategoryId = this.categorylink[this.ins].id;
-
- console.log('this.params',this.params);
- this.downCallback();
- },
-
- category(){
- this.categoryall = true;
- this.notall = false;
- this.params.productCategoryId = '';
- this.downCallback();
- },
-
-
- jumLink(url){
- function handleBrowsingItemLink(link){
- const browsingItemLinkHttp = link.substr(0, 7).toLowerCase();
- const browsingItemLinkHttps = link.substr(0, 8).toLowerCase();
- if (browsingItemLinkHttp === "http://" || browsingItemLinkHttps === "https://") {
- return link
- }
- return `http://${link}`
- }
- url = handleBrowsingItemLink(url);
- if(!url){uni.showToast({
- title:'地址无效'
- })}
- window.location.assign(url);
-
-
-
-
-
-
- },
-
- jumpDetails(id){
- uni.navigateTo({
- url:`/pages/product/product?id=${id}`,
- fail(err) {
- console.log(err)
- }
- })
- },
-
- swiperchange(e){
- this.currentswiper = e.detail.current;
- }
- }
- }
- </script>
- <style scoped>
- @import url("./index.css");
- </style>
|