123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278 |
- <template>
- <view class="order-search">
- <!-- 搜索区域 -->
- <view class="order-top sticky-top">
- <cm-search
- v-model="listQuery.searchWord"
- @search="handleSearch"
- placeholder="请输入搜索关键字"
- :keywordVisible="keywordVisible"
- :keywordList="keywordList"
- @focus="keywordVisible = true"
- @clear="keywordVisible = true"
- @remove="removeKeywordModal = true"
- ></cm-search>
- </view>
- <view class="order-list">
- <!-- 订单列表为空 -->
- <template v-if="orderList.length <= 0 && !isLoading">
- <tui-no-data :imgUrl="emptyInfo.image" :imgHeight="230" :imgWidth="290">
- <view class="empty-tip" v-text="emptyInfo.message"></view>
- </tui-no-data>
- </template>
- <template v-else>
- <view
- class="section"
- v-for="orderInfo in orderList"
- :key="orderInfo.orderId"
- @click="handleToDetail(orderInfo)"
- >
- <!-- 订单信息 -->
- <view class="order-info">
- <view class="order-no">
- <text class="label">订单编号:</text> <text>{{ orderInfo.orderNo }}</text>
- </view>
- <view class="order-time">
- <text class="label">下单时间:</text> <text>{{ orderInfo.orderTime }}</text>
- </view>
- <view class="order-status">{{ stateExpFormat(orderInfo.status) }}</view>
- </view>
- <tui-divider :height="48"></tui-divider>
- <!-- 商品列表 -->
- <view class="shop-list">
- <view
- class="shop-section"
- v-for="shopInfo in orderInfo.shopOrderList"
- :key="shopInfo.shopOrderId"
- >
- <order-supplier-area :shopInfo="shopInfo"></order-supplier-area>
- </view>
- </view>
- <!-- 商品统计 -->
- <view class="total">
- <view class="count">共{{ orderInfo.productCount }}件商品</view>
- <view class="price">
- <template v-if="['31', '32', '33', '81', '82', '83'].includes(orderInfo.status)">
- <text class="label">已支付:</text>
- <text>¥{{ orderInfo.receiptAmount | priceFormat }}</text>
- </template>
- <template v-else>
- <text class="label">待付总额:</text>
- <text>¥{{ orderInfo.pendingPayments | priceFormat }}</text>
- </template>
- </view>
- </view>
- <!-- 操作订单 -->
- <view class="control">
- <order-contror
- v-if="orderInfo.userId == userId"
- :orderInfo="orderInfo"
- @confirm="handleConfirmClick"
- ></order-contror>
- </view>
- </view>
- <cm-loadmore :hasMore="hasNextPage" :isLoading="isLoading" :visiable="visiable"></cm-loadmore>
- </template>
- </view>
- <!-- 失效商品列表 -->
- <order-invalid-modal
- :goodsList="invalidList"
- :visible="buyAgainModal"
- @confirm="buyAgainModalClick"
- @cancel="buyAgainModalHide"
- ></order-invalid-modal>
- <!-- 操作弹窗 -->
- <tui-modal :show="removeKeywordModal" content="确认清空搜索历史记录?" @click="clearSearchRecord"></tui-modal>
- </view>
- </template>
- <script>
- import { searchOrderList, fetchOrderSearchHistory, clearOrderSearchHistory } from '@/services/api/order.js'
- import { debounce } from '@/common/utils.js'
- import { mapGetters } from 'vuex'
- import orderList from '@/pages/views/order/mixins/orderList.js'
- import wechatPay from '@/pages/views/order/mixins/wechatPay.js'
- export default {
- mixins: [orderList, wechatPay],
- data() {
- return {
- isLoading: false,
- keywordVisible: true,
- removeKeywordModal: false,
- keywordList: [],
- listQuery: {
- searchWord: '',
- userId: 0,
- pageNum: 1,
- pageSize: 10
- },
- orderList: [],
- total: 0,
- hasNextPage: true,
- isRefresh: true
- }
- },
- watch: {
- keywordVisible(nVal) {
- if (!nVal) return
- this.fetchSearchHistory()
- this.orderList = []
- }
- },
- computed: {
- ...mapGetters(['userId']),
- // 列表为空
- emptyInfo() {
- const info = {}
- info.image = `${this.staticUrl}icon-empty-address.png`
- info.message = '未找到相关订单~_~'
- if (this.keywordList.length <= 0) {
- info.message = '暂无任何搜索历史记录~_~'
- }
- return info
- },
- visiable() {
- return this.orderList.length > this.listQuery.pageSize
- }
- },
- onReachBottom() {
- this.fetchOrderList()
- },
- onLoad() {
- this.fetchSearchHistory()
- },
- methods: {
- handleSearch() {
- this.keywordVisible = false
- this.isRefresh = true
- this.hasNextPage = true
- this.listQuery.pageNum = 1
- this.listQuery.userId = this.userId
- this.fetchOrderList()
- },
- // 获取订单列表
- fetchOrderList: debounce(async function() {
- if (!this.hasNextPage) return
- this.isLoading = true
- try {
- const res = await searchOrderList(this.listQuery)
- if (this.isRefresh) {
- this.orderList = res.data.list
- } else {
- this.orderList = [...this.orderList, ...res.data.list]
- }
- this.total = res.data.total
- this.hasNextPage = res.data.hasNextPage
- this.listQuery.pageNum++
- } catch (e) {
- console.log(e)
- } finally {
- this.isLoading = false
- this.isRefresh = false
- }
- }),
- // 获取搜索历史记录
- async fetchSearchHistory() {
- try {
- const res = await fetchOrderSearchHistory({ userId: this.userId })
- this.keywordList = res.data
- return res
- } catch (e) {
- console.log(e)
- }
- },
- // 清空搜索历史记录
- async clearSearchRecord(e) {
- if (!e.index) return (this.removeKeywordModal = false)
- try {
- await clearOrderSearchHistory({ userId: this.userId })
- await this.fetchSearchHistory()
- this.removeKeywordModal = false
- this.$toast('已清空搜索历史记录')
- } catch (e) {
- console.log(e)
- }
- },
- // 订单详情
- handleToDetail(order) {
- this.$router.navigateTo('order/order-detail?orderId=' + order.orderId)
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .order-list {
- .section {
- padding: 24rpx;
- margin-bottom: 24rpx;
- background-color: #fff;
- .order-info {
- position: relative;
- line-height: 1.6;
- .order-no,
- .order-time {
- font-size: 26rpx;
- color: #333333;
- .label {
- color: #999999;
- }
- }
- .order-status {
- position: absolute;
- font-size: 26rpx;
- color: #ff457b;
- right: 0;
- bottom: 0;
- }
- }
- .shop-list {
- .shop-section {
- margin-bottom: 24rpx;
- &:last-child {
- margin-bottom: 0;
- }
- }
- }
- .total {
- display: flex;
- justify-content: space-between;
- align-items: center;
- margin-top: 24rpx;
- font-size: 26rpx;
- color: #333333;
- .count {
- font-weight: bold;
- }
- .price {
- color: #ff457b;
- .label {
- color: #333333;
- }
- }
- }
- .control {
- margin-top: 32rpx;
- }
- }
- }
- </style>
|