123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452 |
- <template>
- <view class="pages">
-
- <view class="scrollPage-header">
- <view :style="{height:statusBarHeight+'px'}"></view>
- <view class="header-title-box">
- <view class="header-left" @click="goBack">
- <uni-icons type="arrowleft" size="16"></uni-icons>
- <text>返回</text>
- </view>
- <view class="search-head" @click="goSearch">
- <uni-search-bar readonly radius="100" placeholder="请输入商品名称/产品编码/原厂编码" textColor="#666" clearButton="auto" cancelButton="none" />
- </view>
- <view></view>
- </view>
- <view class="header-title">
- <text :max-lines="1" overflow="ellipsis">{{title}}</text>
- </view>
- </view>
- <view class="search-result">
- <view class="tab-left" v-if="clzId&&categoryList.length>0">
- <scroll-view
- :style="{height: (screenHeight - statusBarHeight - 44 - 43) + 'px'}"
- scroll-y="true"
- :bounces="false"
- type="list"
- >
- <view class="item-clz"
- v-for="item in categoryList"
- :key="item.categorySn"
- :class="item.categorySn==categorySn?'active':''"
- @click="handleTab(item)">
- {{item.categoryName}}
- </view>
- </scroll-view>
- </view>
- <view class="right-box" :style="{width:clzId&&categoryList.length?'75%':'100%'}">
-
- <scroll-view
- class="scrollPage-body"
- :class="clzId&&categoryList.length?'right-item':''"
- :style="{height: (screenHeight - statusBarHeight - 44 - 43) + 'px'}"
- scroll-y="true"
- type="list"
- :bounces="false"
- :refresher-enabled="enableRefresh"
- :refresher-triggered="triggered"
- @refresherpulling="onPulling"
- @refresherrefresh="onRefresh"
- @refresherrestore="onRestore"
- @refresherabort="onAbort"
- @scrolltolower="reachBottom">
-
- <chooseProductItem
- v-for="(item, index) in list"
- :key="item.id"
- :index="index"
- :list="item"
- :isLogin="hasLogin"
- @toDetail="viewDetail"
- >
- </chooseProductItem>
-
- <view class="loading-bar" v-if="total>0 && (loading||loadEnd)">{{loadText}}</view>
- <view class="empty-bar" v-if="total==0&&!loading">
- <image mode="aspectFit" :src="empty.imgUrl"></image>
- <view>{{empty.tip}}</view>
- </view>
- </scroll-view>
- </view>
- </view>
- </view>
- </template>
- <script>
- import {
- mapState,
- mapMutations,
- } from 'vuex'
- import chooseProductItem from '@/pagesB/components/chooseProductItemSkline.vue'
- import { getShopCategory, getShopProductList } from '@/api/shop.js'
- export default {
- components:{
- chooseProductItem
- },
- data() {
- return {
- title: '',
- loadText: '加载中...',
- empty: {
- tip: '暂无商品',
- imgUrl: '/static/nodata.png'
- },
- queryWord:'',
- screenWidth: 325,
- screenHeight: 0,
- statusBarHeight: 44,
- safeAreaBottom: 0,
- pageSize: 10,
- pageNo:1,
- total:0,
- list: [],
- loading:false,
- loadEnd: false,
- focus: false,
- expend: false,
- clzId: null,
- categorySn: null ,
- categoryList: [],
- enableRefresh: true,
- triggered: false,
- pulling: false
- };
- },
- computed: {
- ...mapState(['hasLogin']),
-
- userInfo(){
- return this.$store.state.vuex_userInfo
- },
- },
- onLoad(opts) {
-
- this.statusBarHeight = uni.getSystemInfoSync().statusBarHeight
- this.screenWidth = uni.getSystemInfoSync().windowWidth
- this.screenHeight = uni.getSystemInfoSync().windowHeight
- this.safeAreaBottom = uni.getSystemInfoSync().safeAreaInsets.bottom
-
-
- this.clzId = opts.clzId
-
- this.title = opts.clzName
-
-
- if(opts.shopCategoryCount>0){
-
- this.getCategory()
- }
-
- if(opts.shopProductCount>0){
- this.categorySn = opts.clzId
-
- this.searchList()
- }
- },
- methods: {
-
- goBack(){
- uni.navigateBack()
- },
-
- goSearch(event){
- uni.navigateTo({
- url:'/pagesB/shopiing/searchProduct?queryWord='+event.value+'&clzId='
- })
- },
-
- getCategory(){
- getShopCategory({
- parentSn: this.clzId,
- categoryLevel: 2
- }).then(res => {
- if(res.status == 200){
-
- this.categoryList = res.data || []
-
- if(this.categoryList.length > 0){
-
- this.categorySn = this.categoryList[0].categorySn
-
- this.searchList()
- }
- }else{
- uni.showToast({
- title: res.message,
- icon: 'none'
- })
- }
- })
- },
-
- searchList(event) {
- this.loadEnd = false
- this.loadText = '加载中...'
- this.list = []
- this.pageNo = 1
- this.getList()
- },
-
- handleTab(item){
- this.categorySn = item.categorySn
- this.queryWord = ''
- this.searchList()
- },
-
- onPulling(e){
- console.log('onPulling')
- this.triggered = true
- this.pulling = true
- },
-
- onRefresh(e){
- console.log('onRefresh')
- setTimeout(() => {
- this.triggered = false
- }, 500);
- },
-
- onRestore(e){
- console.log('onRestore')
- this.queryWord = ''
- this.searchList()
- },
-
- onAbort(e){
- console.log('onAbort')
- this.triggered = false
- },
-
- reachBottom() {
- console.log('reachBottom',this.pulling)
- if(this.enableRefresh){
- if(!this.loading && !this.loadEnd && !this.pulling){
- this.pageNo++
- this.getList()
- }
- if(this.pulling){
- this.pulling = false
- }
- }
- },
-
- getList(){
- this.loading = true
- uni.showLoading({
- title: '加载中...',
- mask: true
- })
- const dealerSn = this.hasLogin && this.userInfo && this.userInfo.sysUserFlag == '1' ? this.$store.state.vuex_storeShelf.dealerSn : ''
- getShopProductList({
- pageNo: this.pageNo,
- pageSize: this.pageSize,
- queryWord: this.queryWord,
- categorySn: this.categorySn,
- dealerSn: dealerSn,
- status: 1
- }).then(res => {
- if(res.status == 200){
- this.total = Number(res.data.count)
- if(this.total){
- const list = res.data.list || []
-
- const ret = list.map(k => {
- return {
- id: k.id,
- price: k.price,
- productCode: k.productCode,
- productSn: k.productSn,
- productImage: k.productMsg,
- productName: k.productName,
- productOrigCode: k.productOrigCode,
- categorySn: k.categorySn,
- hotFlag: k.hotFlag,
- productSn: k.productSn,
- priceType: k.priceType,
- shopProductSn: k.shopProductSn,
- status: k.status,
- statusDictValue: k.statusDictValue,
- dealerScopeFlag: k.dealerScopeFlag
- }
- })
-
- this.list.push(ret)
-
- const maxPages = Math.ceil(this.total / this.pageSize)
- if(this.pageNo >= maxPages){
- this.loadEnd = true
- this.loadText = '没有更多了'
- }
- }else{
- this.loadEnd = false
- this.loadText = '没有找到相关产品'
- }
- }else{
- this.loadEnd = false
- this.loadText = res.message
- }
- uni.hideLoading()
- this.loading = false
- }).catch(err => {
- this.loading = false
- })
- },
-
- viewDetail(item){
- uni.navigateTo({
- url:'/pagesB/shopiing/productDetail?sn='+item.shopProductSn
- })
- }
- }
- }
- </script>
- <style lang="less">
- .pages{
- height: 100vh;
- display: flex;
- flex-direction: column;
- .scrollPage-header{
- z-index: 1;
- .header-title-box{
- display: flex;
- align-items: center;
- padding: 0 10px;
- height: 44px;
- background-color: #FFFFFF;
- border-bottom: 1px solid #e8e8e8;
- .search-head{
- flex-grow: 1;
- /deep/ .uni-searchbar{
- padding: 0 6px;
- }
- /deep/ .uni-searchbar .uni-searchbar__box{
- height: 30px;
- }
- }
- .header-left{
- display: flex;
- align-items: center;
- text{
- font-size: 14px;
- color: #333333;
- margin-left: 5px;
- }
- }
- .header-right{
- width: 50px;
- }
- }
- }
- .header-title{
- background-color: #FFFFFF;
- color: #333333;
- padding: 10px;
- text-align: center;
- }
- .search-result{
- flex-grow: 1;
- display: flex;
- justify-content: space-between;
- .tab-left{
- width: 25%;
- flex-grow: 1;
- background: #FFFFFF;
- .item-clz{
- font-size: 14px;
- padding: 8px 10px;
- line-height: 30px;
- }
- .active{
- border-left: 3px solid #00aaff;
- background: #f8f8f8;
- }
- }
- .right-box{
- width: 75%;
- .scrollPage-body{
- width:100%;
- .uni-searchbar{
- background-color: #FFFFFF;
- }
- /deep/ .choose-product-item{
- background-color: #FFFFFF;
- margin: 6px 10px;
- border-radius: 6px;
- }
- .loading-bar{
- text-align: center;
- padding: 10px 0;
- color: #999999;
- }
- .empty-bar{
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- padding: 20px 0;
- image{
- width: 100px;
- height: 100px;
- }
- view{
- font-size: 12px;
- color: #999999;
- }
- }
- .search-history{
- padding: 0 1.5rem;
- .search-history-title{
- display: flex;
- align-items: center;
- justify-content: space-between;
- padding: 6px 0;
- font-size: 14px;
- color: #333333;
- border-bottom: 1px solid #E6E6E6;
- }
- .search-history-right{
- display: flex;
- align-items: center;
- }
- .search-history-expend{
- display: flex;
- align-items: center;
- font-size: 12px;
- margin-right: 15px;
- }
- .search-history-body{
- display: flex;
- flex-wrap: wrap;
- align-items: center;
- justify-content: space-between;
- padding: 10px 10px;
- .item{
- padding: 6px 0;
- background-color: #f8f8f8;
- border-radius: 20px;
- font-size: 12px;
- color: #333333;
- width: 46%;
- }
- }
- }
- }
- .right-item{
- /deep/ .choose-product-item{
- margin: 5px 8px;
- .choose-product-item-img{
- height: 130rpx;
- }
- .choose-product-item-img .choose-product-item-left-info-code{
- font-size:12px;
- }
- .choose-product-item-info .choose-product-item-left-info-name{
- font-weight: normal;
- }
- }
- }
- }
- }
- }
- </style>
|