123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438 |
- <template>
- <view class="order-search">
- <tui-skeleton v-if="isRequest" loadingType="2"></tui-skeleton>
- <!-- 搜索框 -->
- <view class="order-top">
- <cm-search
- v-model="keyword"
- @search="handleSearch"
- placeholder="请输入搜索关键字"
- :keywordVisible="keywordVisible"
- :keywordList="keywordList"
- @focus="keywordVisible = true"
- @clear="keywordVisible = true"
- @remove="removeKeywordModal = true"
- ></cm-search>
- </view>
- <!-- orderList.length === 0 -->
- <view class="order-empty" v-if="orderList.length === 0">
- <cm-empty :image="emptyInfo.image" :message="emptyInfo.message" :offset="100"></cm-empty>
- </view>
- <view class="order-list" v-else>
- <template v-for="(orderInfo, orderIndex) in orderList">
- <view class="grid" :key="orderIndex"></view>
- <view class="order-section" :key="orderIndex" @click="handleToDetail(orderInfo)">
- <!-- 订单信息 -->
- <view class="order-info">
- <view class="order-num">
- <text class="label">订单编号:</text>
- <text>{{ orderInfo.orderNo }}</text>
- </view>
- <view class="order-time">
- <text class="label">下单时间:</text>
- <text>{{ orderInfo.orderTime }}</text>
- </view>
- <view class="status">{{ stateExpFormat(orderInfo.status) }}</view>
- </view>
- <view class="line"></view>
- <view
- class="shop-order"
- v-for="(shopOrder, shopOrderIndex) in orderInfo.shopOrderList"
- :key="shopOrderIndex"
- >
- <!-- 供应商 -->
- <view class="origin">
- <image class="cover" :src="shopOrder.shopLogo"></image>
- <view class="name">{{ shopOrder.shopName }}</view>
- </view>
- <!-- 商品列表 -->
- <view class="goods-list">
- <!-- 商品信息 -->
- <view
- class="order-goods"
- v-for="goods in shopOrder.orderProductList"
- :key="goods.productId"
- >
- <cm-order-prodcut :goods-data="goods"></cm-order-prodcut>
- </view>
- </view>
- </view>
- <!-- 统计 -->
- <view class="total">
- <view class="count">共{{ orderInfo.productCount }}件商品</view>
- <view class="status">
- <template v-if="['31', '32', '33'].includes(orderInfo.status)">
- <text class="label">已支付:</text>
- <text>¥{{ orderInfo.receiptAmount | formatPrice }}</text>
- </template>
- <template v-else>
- <text class="label">待付总额:</text>
- <text>¥{{ orderInfo.pendingPayments | formatPrice }}</text>
- </template>
- </view>
- </view>
- <!-- 操作 -->
- <cm-order-control-nav
- v-if="orderInfo.userId == userId"
- :orderInfo="orderInfo"
- @confirm="handleConfirmClick"
- ></cm-order-control-nav>
- </view>
- </template>
- </view>
- <!-- loading -->
- <view class="loading-more" v-if="orderList.length > 0">
- <tui-loadmore :index="3" :visible="loadmore"></tui-loadmore>
- <tui-nomore :text="loadMoreText" :visible="!loadmore" backgroundColor="#f7f7f7"></tui-nomore>
- </view>
- <!-- 操作弹窗 -->
- <tui-modal
- :show="modal"
- :content="modalText"
- :size="32"
- :maskClosable="false"
- color="#333"
- shape="circle"
- @click="handleModalConfirm"
- ></tui-modal>
- <!-- 加载框 -->
- <cm-loading :visible="isSubLoading" :text="loadingText"></cm-loading>
- <!-- 失效商品列表 -->
- <cm-order-invalid-modal
- :goodsList="invalidList"
- :visible="buyAgainModal"
- @confirm="buyAgainModalClick"
- @cancel="buyAgainModalHide"
- ></cm-order-invalid-modal>
- <!-- 操作弹窗 -->
- <tui-modal
- :show="removeKeywordModal"
- content="确认清空搜索历史记录?"
- :size="32"
- :maskClosable="false"
- color="#333"
- shape="circle"
- @click="clearSearchRecord"
- ></tui-modal>
- </view>
- </template>
- <script>
- import CmOrderProdcut from '@/components/cm-module/cm-order-prodcut/cm-order-prodcut.vue'
- import CmOrderControlNav from '@/components/cm-module/cm-order-control-nav/cm-order-control-nav.vue'
- import CmOrderInvalidModal from '@/components/cm-module/cm-order-invalid-modal/cm-order-invalid-modal.vue'
- import CmLoading from '@/components/cm-module/cm-loading/cm-loading.vue'
- import CmEmpty from '@/components/cm-module/cm-empty/cm-empty.vue'
- import CmSearch from '@/components/cm-module/cm-search/cm-search.vue'
- import { debounce } from '@/common/common.js'
- import orderMixins from './mixins/orderList.js'
- import wechatPay from './mixins/wechatPay.js'
- import { mapGetters } from 'vuex'
- export default {
- mixins: [orderMixins, wechatPay],
- components: {
- CmSearch,
- CmOrderProdcut,
- CmOrderControlNav,
- CmOrderInvalidModal,
- CmEmpty,
- CmLoading
- },
- data() {
- return {
- isRequest: false,
- keywordVisible: true,
- keywordList: [],
- keyword: '',
- pageNum: 1,
- hasMore: false,
- loadmore: false, // 正在加载更多
- orderList: [],
- refresh: false,
- removeKeywordModal: false
- }
- },
- computed: {
- ...mapGetters(['userId', 'userIdentity']),
- // 当前用户是否为协销
- isDealer() {
- return this.userIdentity === 2
- },
- // 上拉加载文案
- loadMoreText() {
- if (this.orderList.length === 0) return '没有更多了'
- return this.hasMore ? '上拉加载更多' : '没有更多了'
- },
- // 列表为空
- emptyInfo() {
- const info = {}
- info.image = `${this.$Static}icon-empty-address.png`
- info.message = '未找到相关订单~_~'
-
- if(this.keywordList.length <= 0){
- info.message = '暂无任何搜索历史记录~_~'
- }
-
- return info
- }
- },
- watch: {
- keywordVisible(nVal){
- if(!nVal) return
- this.fetchSerachRecord()
- this.orderList = []
- }
- },
- onReachBottom() {
- if (!this.hasMore) return
- this.fetchOrderData()
- },
- onLoad() {
- this.fetchSerachRecord()
- this.$on('orderAction', () => {
- this.resetOrderList()
- })
- },
- beforeDestroy() {
- this.$off('orderAction')
- },
- methods: {
- handleSearch() {
- this.keywordVisible = false
- this.isRequest = true
- this.resetOrderList()
- },
- // 跳转详情
- handleToDetail(orderInfo) {
- this.$api.navigateTo('/pages/order/order-detail?orderId=' + orderInfo.orderId)
- },
- // 获取订单列表 使用防抖函数封装
- fetchOrderData: debounce(function() {
- this.loadmore = true
- const params = {
- searchWord: this.keyword,
- // orderState: 0,
- // orderType: 0,
- userId: this.userId,
- pageNum: this.pageNum,
- pageSize: 10
- }
- // if (this.isDealer) {
- // this.queryOrderDealerList(params)
- // } else {
- // this.queryOrderList(params)
- // }
- this.searchOrderInfo(params)
-
- }, 500),
- // 普通用户获取订单列表
- // queryOrderList(params) {
- // this.OrderService.QueryOrderList(params)
- // .then(res => {
- // if (this.refresh) this.orderList = []
- // this.updateOrderList(res)
- // })
- // .catch(err => {
- // console.log(err)
- // })
- // .finally(() => {
- // this.refresh = false
- // this.loadmore = false
- // this.isRequest = false
- // })
- // },
- // 分销者获取订单列表
- // queryOrderDealerList(params) {
- // this.OrderService.QueryOrderDealerList(params)
- // .then(res => {
- // if (this.refresh) this.orderList = []
- // this.updateOrderList(res)
- // })
- // .catch(err => {
- // console.log(err)
- // })
- // .finally(() => {
- // this.refresh = false
- // this.loadmore = false
- // this.isRequest = false
- // })
- // },
-
- // 机构搜索订单列表
- searchOrderInfo(params){
- this.OrderService.SearchOrderInfo(params)
- .then(res => {
- if (this.refresh) this.orderList = []
- this.updateOrderList(res)
- })
- .catch(err => {
- console.log(err)
- })
- .finally(() => {
- this.refresh = false
- this.loadmore = false
- this.isRequest = false
- })
- },
-
- // 更新订单列表
- updateOrderList(response) {
- this.pageNum++
- this.orderList = this.orderList.concat(response.data.list)
- this.hasMore = response.data.hasNextPage
- },
- // 重置订单列表
- resetOrderList() {
- this.refresh = true
- this.pageNum = 1
- this.fetchOrderData()
- },
- // 获取搜索历史
- async fetchSerachRecord() {
- try {
- const res = await this.OrderService.SearchOrderHistory({ userId: this.userId })
- this.keywordList = res.data
- } catch (error) {
- this.$util.msg(error.msg, 2000)
- }
- },
- // 清空搜索历史
- async clearSearchRecord(e) {
- if (!e.index) return (this.removeKeywordModal = false)
- try {
- await this.OrderService.ClearOrderHistory({ userId: this.userId })
- await this.fetchSerachRecord()
- this.removeKeywordModal = false
- this.$util.msg('已清空搜索历史记录', 2000)
- } catch (error) {
- this.$util.msg(error.msg, 2000)
- }
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .order-search {
- min-height: 100vh;
- background: #f7f7f7;
- overflow: hidden;
- padding-top: 90rpx;
- box-sizing: border-box;
- }
- .order-top {
- position: fixed;
- top: 0;
- left: 0;
- width: 100%;
- z-index: 100000;
- }
- .grid {
- height: 20rpx;
- background: #f7f7f7;
- }
- .order-section {
- padding: 38rpx 0;
- background-color: #fff;
- .line {
- width: 702rpx;
- height: 1px;
- background: #f7f7f7;
- }
- .order-info {
- position: relative;
- padding: 0 24rpx;
- margin-bottom: 32rpx;
- line-height: 1.6;
- .order-num,
- .order-time {
- font-size: 26rpx;
- color: #333333;
- .label {
- color: #999999;
- }
- }
- .status {
- position: absolute;
- font-size: 26rpx;
- color: #ff457b;
- right: 24rpx;
- bottom: 0;
- }
- }
- .origin {
- padding: 0 24rpx;
- margin-top: 24rpx;
- margin-bottom: 16rpx;
- display: flex;
- justify-content: flex-start;
- align-items: center;
- .cover {
- width: 56rpx;
- height: 56rpx;
- border-radius: 4rpx;
- border: 1px solid #f7f7f7;
- box-sizing: border-box;
- }
- .name {
- margin-left: 16rpx;
- font-size: 30rpx;
- color: #333333;
- font-weight: bold;
- }
- }
- .goods-list {
- .order-goods {
- padding-top: 32rpx;
- &:first-child {
- padding-top: 0;
- }
- }
- }
- .total {
- display: flex;
- justify-content: space-between;
- align-items: center;
- padding: 0 24rpx;
- margin: 32rpx 0;
- font-size: 26rpx;
- color: #333333;
- .count {
- font-weight: bold;
- }
- .status {
- color: #ff457b;
- .label {
- color: #333333;
- }
- }
- }
- }
- </style>
|