Browse Source

上传

hfll
前端-胡立永 3 months ago
parent
commit
c78ced3aaf
7 changed files with 131 additions and 20 deletions
  1. +19
    -0
      api/model/index.js
  2. +3
    -2
      components/user/productList.vue
  3. +15
    -0
      mixins/order.js
  4. +62
    -11
      pages/index/category.vue
  5. +13
    -3
      pages/index/index.vue
  6. +18
    -3
      pages/index/order.vue
  7. +1
    -1
      store/store.js

+ 19
- 0
api/model/index.js View File

@ -46,6 +46,17 @@ const api = {
url: '/index_common/getCategoryList', url: '/index_common/getCategoryList',
method: 'GET', method: 'GET',
}, },
// 新查询分类以及商品数据接口
getCategoryPidList: {
url: '/index_common/getCategoryPidList',
method: 'GET',
debounce : 250,
},
// 查询一级分类接口
getPidList: {
url: '/index_common/getCategoryPidList',
method: 'GET',
},
// 获取分类分页商品列表接口 // 获取分类分页商品列表接口
getClassShopPageList: { getClassShopPageList: {
url: '/index_common/getClassShopPageList', url: '/index_common/getClassShopPageList',
@ -112,6 +123,14 @@ const api = {
limit: 1000, limit: 1000,
showLoading: true, showLoading: true,
}, },
// 取消订单
cancelOrder: {
url: '/index_common/cancelOrder',
method: 'GET',
auth: true,
limit: 1000,
showLoading: true,
},
// 获取首页广告列表 // 获取首页广告列表
getRiceProductList: { getRiceProductList: {
url: '/index_common/getRiceAdList', url: '/index_common/getRiceAdList',


+ 3
- 2
components/user/productList.vue View File

@ -31,7 +31,9 @@
</view> </view>
</view> </view>
<uv-empty mode="list" v-if="list.length == 0"></uv-empty>
<view style="width: 700rpx;">
<uv-empty mode="list" v-if="list.length == 0"></uv-empty>
</view>
</view> </view>
</template> </template>
@ -71,7 +73,6 @@
.list { .list {
display: flex; display: flex;
flex-wrap: wrap; flex-wrap: wrap;
.item { .item {
position: relative; position: relative;
width: 345rpx; width: 345rpx;


+ 15
- 0
mixins/order.js View File

@ -51,5 +51,20 @@ export default {
} }
}) })
}, },
// 取消订单
cancelOrder(item){
uni.showModal({
title: '确认取消订单吗?',
success : e => {
if(e.confirm){
this.$api('cancelOrder', {
orderId : item.id,
}, res => {
this.getData()
})
}
}
})
},
} }
} }

+ 62
- 11
pages/index/category.vue View File

@ -9,23 +9,41 @@
<!-- 搜索栏 --> <!-- 搜索栏 -->
<view class="search"> <view class="search">
<uv-search placeholder="搜你喜欢的产品" bgColor="#fff" @search="getData" @custom="getData"
v-model="queryParams.title"></uv-search>
<uv-search placeholder="搜你喜欢的产品" bgColor="#fff"
@search="search"
@change="search"
@custom="search"
v-model="queryParams.title"></uv-search>
</view>
<!-- 商品列表 -->
<view style="position: 20rpx;"
v-if="queryParams.title">
<productList :list="list" />
</view> </view>
<!-- 分类商品列表 --> <!-- 分类商品列表 -->
<view class="category">
<view class="category"
v-else>
<uv-vtabs <uv-vtabs
:list="category" :list="category"
:current="current" :current="current"
keyName="title"
keyName="name"
@change="change"> @change="change">
<view class="list"> <view class="list">
<uv-vtabs-item> <uv-vtabs-item>
<productItem v-for="(item, index) in list" :key="index" :item="item"
@click="$utils.navigateTo(`/pages_order/product/productDetail?id=${item.id}`)" />
<view class="category-item"
v-for="(item, index) in category[current].children" :key="index">
<view class="category-title">
{{ item.name }}
</view>
<productItem :item="pro"
v-for="(pro, i) in item.shopList" :key="i"
@click="$utils.navigateTo(`/pages_order/product/productDetail?id=${pro.id}`)" />
</view>
<uv-empty mode="list" v-if="list.length == 0"></uv-empty>
<uv-empty mode="list" v-if="category[current].children.length == 0"></uv-empty>
</uv-vtabs-item> </uv-vtabs-item>
</view> </view>
</uv-vtabs> </uv-vtabs>
@ -43,11 +61,13 @@
mapState mapState
} from 'vuex' } from 'vuex'
import tabber from '@/components/base/tabbar.vue' import tabber from '@/components/base/tabbar.vue'
import productList from '@/components/user/productList.vue'
export default { export default {
mixins: [mixinsList], mixins: [mixinsList],
components: { components: {
productItem, productItem,
tabber, tabber,
productList,
}, },
data() { data() {
return { return {
@ -65,21 +85,28 @@
if (search) { if (search) {
this.queryParams.title = search this.queryParams.title = search
} }
this.$store.commit('getCategoryList')
// this.$store.commit('getCategoryList')
if(this.category.length > 0 && cid){ if(this.category.length > 0 && cid){
this.category.forEach((n, i) => { this.category.forEach((n, i) => {
if(n.id == cid){ if(n.id == cid){
this.current = i this.current = i
} }
}) })
this.queryParams.classId = cid
// this.queryParams.classId = cid
}else if (this.category.length > 0) { }else if (this.category.length > 0) {
this.queryParams.classId = this.category[0].id
// this.queryParams.classId = this.category[0].id
} }
}, },
methods: { methods: {
change(e) { change(e) {
this.queryParams.classId = this.category[e].id
// this.queryParams.classId = this.category[e].id
this.current = e
},
search(){
for(let i = 0;i < 10;i++){
delete this.queryParams[i]
}
this.queryParams.pageSize = 10
this.getData() this.getData()
}, },
} }
@ -126,6 +153,30 @@
.category { .category {
font-size: 30rpx; font-size: 30rpx;
color: #333; color: #333;
.category-title{
position: relative;
display: flex;
justify-content: center;
align-items: center;
height: 120rpx;
&::before,
&::after {
position: absolute;
top: 50%;
content: '';
width: 10%;
border-top: 2rpx solid black;
}
&::before {
left: 25%;
}
&::after {
right: 25%;
}
}
&::v-deep .uv-vtabs { &::v-deep .uv-vtabs {
width: 750rpx; width: 750rpx;


+ 13
- 3
pages/index/index.vue View File

@ -19,11 +19,11 @@
<!-- 首页-分类菜单 --> <!-- 首页-分类菜单 -->
<view class="home-menu"> <view class="home-menu">
<uv-grid :border="false" :col="5"> <uv-grid :border="false" :col="5">
<uv-grid-item v-for="(item,index) in category"
<uv-grid-item v-for="(item, index) in categoryList"
:key="index" :key="index"
@click="$utils.navigateTo(`/pages/index/category?cid=${item.id}`)"> @click="$utils.navigateTo(`/pages/index/category?cid=${item.id}`)">
<image :src="item.image" mode="aspectFill"></image> <image :src="item.image" mode="aspectFill"></image>
<text class="menu-text">{{item.title}}</text>
<text class="menu-text">{{item.name}}</text>
</uv-grid-item> </uv-grid-item>
</uv-grid> </uv-grid>
</view> </view>
@ -131,7 +131,8 @@
riceProductList: [], // riceProductList: [], //
newList: [], // newList: [], //
mixinsListApi: 'getClassShopPageList', mixinsListApi: 'getClassShopPageList',
adList: []
adList: [],
categoryList : [],
} }
}, },
computed: { computed: {
@ -146,6 +147,7 @@
this.getBanner() this.getBanner()
this.getRiceNoticeList() this.getRiceNoticeList()
this.getRiceIconList() this.getRiceIconList()
this.getCategoryList()
this.getRiceAdList() this.getRiceAdList()
if(uni.getStorageSync('token')){ if(uni.getStorageSync('token')){
this.$store.commit('getRiceInfo') this.$store.commit('getRiceInfo')
@ -164,6 +166,14 @@
}) })
this.keyword = '' this.keyword = ''
}, },
//
getCategoryList() {
this.$api('getPidList', res => {
if (res.code == 200) {
this.categoryList = res.result
}
})
},
// //
getBanner() { getBanner() {


+ 18
- 3
pages/index/order.vue View File

@ -6,8 +6,8 @@
<!-- 订单筛选 --> <!-- 订单筛选 -->
<view class="tabs"> <view class="tabs">
<uv-tabs :list="tabs" :activeStyle="{color : '#fff', fontWeight : 600}" lineColor="#fff" <uv-tabs :list="tabs" :activeStyle="{color : '#fff', fontWeight : 600}" lineColor="#fff"
:inactiveStyle="{color: 'rgba(255,255,255,.8)'}" lineHeight="8rpx" lineWidth="50rpx" :current="current"
:scrollable="false" @click="clickTabs"></uv-tabs>
:inactiveStyle="{color: 'rgba(255,255,255,.8)'}" lineHeight="8rpx" lineWidth="50rpx" :current="current"
@click="clickTabs"></uv-tabs>
</view> </view>
<view class="list"> <view class="list">
@ -55,6 +55,10 @@
立即付款 立即付款
</view> </view>
<view @click.stop="cancelOrder(item)" class="btn" v-if="item.state == 0">
取消订单
</view>
<view class="btn" @click.stop="confirmOrder(item)" v-if="item.state == 2"> <view class="btn" @click.stop="confirmOrder(item)" v-if="item.state == 2">
确认收货 确认收货
</view> </view>
@ -65,6 +69,11 @@
</view> </view>
</view> </view>
<view style="
margin-top: 20rpx;
min-width: 700rpx;">
<uv-empty mode="list" v-if="list.length == 0"></uv-empty>
</view>
</view> </view>
<customerServicePopup ref="customerServicePopup" /> <customerServicePopup ref="customerServicePopup" />
@ -86,7 +95,7 @@
mixins: [mixinsList, mixinsOrder], mixins: [mixinsList, mixinsOrder],
components: { components: {
tabber, tabber,
customerServicePopup
customerServicePopup,
}, },
computed: {}, computed: {},
data() { data() {
@ -97,6 +106,12 @@
{ {
name: '待付款' name: '待付款'
}, },
{
name: '待发货'
},
{
name: '待收货'
},
{ {
name: '已完成' name: '已完成'
}, },


+ 1
- 1
store/store.js View File

@ -134,7 +134,7 @@ const store = new Vuex.Store({
}, },
// 查询分类接口 // 查询分类接口
getCategoryList(state) { getCategoryList(state) {
api('getCategoryList', res => {
api('getCategoryPidList', res => {
if (res.code == 200) { if (res.code == 200) {
state.category = res.result state.category = res.result
} }


Loading…
Cancel
Save