123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447 |
- <template>
- <view>
- <!-- #ifdef MP-ALIPAY -->
- <u-navbar title="我的订单" :border="true" :placeholder="true" :autoBack="true" bgColor="#fff" leftIconSize="0"/>
- <!-- #endif -->
- <!-- #ifndef MP-ALIPAY -->
- <u-navbar title="我的订单" :border="true" :placeholder="true" :autoBack="true" bgColor="#fff" />
- <!-- #endif -->
- <view class="order">
- <!-- 订单导航 -->
- <view class="flex order-state-search">
- <u-tabs @change="changeTab" :scrollable="false" :list="statusArr" lineWidth="20" lineHeight="4"
- lineColor="#E96737" :activeStyle="{
- color: '#333',
- transform: 'scale(1.1)',
- width: '50px',
-
- }" :inactiveStyle="{
- color: '#666666',
- transform: 'scale(1)',
- width: '50px'
- }" itemStyle="padding-left: 15px; padding-right: 15px; height: 44px;text-align: center;">
- </u-tabs>
- </view>
- <!-- 订单列表 -->
- <view class="order-list">
- <view class="order-list-item" v-for="(item, index) in list" :key="index">
- <view class="order-list-item__state">
- <text class="success" v-if="item.status.value == -1 || item.status.value == 3">{{ item.status && item.status.desc }}</text>
- <text v-else>{{ item.status && item.status.desc }}</text>
- </view>
- <view class="order-list-item__goods" @click="toDetail(item)">
- <view class="order-list-item__goods-item" v-for="(items, indexs) in item.items" :key="indexs">
- <image :src="items.picUrl" mode="aspectFit"></image>
- <view class="info">
- <view class="info-title ells">{{ items.title }}</view>
- <view class="info-num flex">
- <view class="info-num-price">¥{{ $numberFormat(items.price) }}</view>
- <view class="info-num-goods">x{{ items.goodsNum }}</view>
- </view>
- </view>
- </view>
- </view>
- <view class="order-list-item-price flex">
- <view class="order-list-item-price__num">共计<text>{{ item.orderNum }}</text>商品,</view>
- <view class="order-list-item-price__total">总金额:<text>¥</text><text>{{ $numberFormat(item.payAmt) }}</text></view>
- </view>
- <view class="order-list-item-btn flex">
- <view class="order-list-item-btn-item flex logistics" v-if="item.status.value == 2 || item.status.value == 3 && item.type === 1" @click="toLogistics(item)"><text>查看物流</text></view>
- <view class="order-list-item-btn-item flex cancel" v-if="item.status.value == 0" @click="cancelOrder(item.orderId)"><text>取消订单</text></view>
- <view class="order-list-item-btn-item flex detail" @click="toDetail(item)"><text>查看详情</text></view>
- <view class="order-list-item-btn-item flex pay"v-if="item.status.value == 0" @click="payOrder(item)"><text>去支付</text></view>
- </view>
- </view>
- <u-loadmore :line="true" v-if="list.length>3" :status="statusNomore" :loading-text="'努力加载中'" :nomore-text="'已经到底了'" />
- </view>
- <view class="flex empty" v-if="!list.length && !loading">
- <view class="center">
- <image class="center-img" src="https://mp-public-1310078123.cos.ap-shanghai.myqcloud.com/v2/nodata_4.png" mode="scaleToFill"></image>
- <view class="center-font">暂无相关订单...</view>
- </view>
- <!-- <u-empty text="还没有订单" mode="order" /> -->
- </view>
- </view>
-
- <auth :auth-show="authShow" @close="authShow = false" />
- </view>
- </template>
- <script>
- import env from '../../config/env.js'
- import $http from '@/utils/request.js'
- import appId from '@/config/appId.js'
- import Auth from '../../components/auth/auth.vue'
- export default {
- components: {
- Auth
- },
- data() {
- return {
- statusNomore: 'nomore',//上拉刷新状态
- loading: false,
- pageNum: 1,
- total: 100,
- list: [],
- status: null,
- statusArr: [{
- name: '全部'
- }, {
- name: '待付款',
- }, {
- name: '待发货'
- }, {
- name: '待收货'
- }, {
- name: '已完成'
- }, ],
- authShow: false,
- };
- },
- onLoad(opthios) {},
- onShow() {
- this.pageList()
- },
- methods: {
- getList() {
- this.loading = true
- $http.post(`/api/v1/mp/user/deliver/order/list?pageNum=${ this.pageNum }&pageSize=20`, {
- status: this.status
- }).then(res => {
- this.loading = false
- if (res.code == 0) {
- res.rows.forEach(item => {
- let items = item.items
- items.forEach(item => {
- let picUrlArr = item.picUrl.split(',')
- item.picUrl = env.filePublic + picUrlArr[0] + '?imageView2/2/w/170'
- })
- item.status = JSON.parse(item.status)
- })
- this.total = res.total
- this.list = this.list.concat(res.rows)
- }
- }).catch(() => {
- this.loading = false
- })
- },
- pageList() {
- this.pageNum = 1
- this.list = []
- this.getList()
- },
- cancelOrder(id) {
- let _this = this
- uni.showModal({
- title: '提示',
- content: '您确认要取消订单吗?',
- success(res) {
- if (res.confirm) {
- $http.post('/api/v1/mp/user/deliver/order/cancel', {
- orderId: id
- }).then(res => {
- if (res.code == 0) {
- uni.$u.toast('订单取消成功');
- _this.pageList()
- }
- })
- }
- }
- })
- },
-
- toDetail(item) {
- uni.navigateTo({
- url: `/packageGoods/order/detail?id=${ item.orderId }`
- })
- },
-
- // 查看物流
- toLogistics(item) {
- uni.navigateTo({
- url: `/packageGoods/order/logistics?id=${ item.orderId }`
- });
- },
- payOrder(item) {
- let _this = this
- let payIng = false
- if (payIng) return
- uni.showLoading({
- title: '加载中'
- });
- // #ifdef MP-ALIPAY
- let data = {
- orderId: item.orderId,
- payType: 1,
- appSource: appId
- }
- // #endif
- // #ifndef MP-ALIPAY
- let data = {
- orderId: item.orderId,
- payType: 2,
- appSource: appId
- }
- // #endif
- $http.post('/api/v1/mp/user/deliver/order/pay', data).then(ele => {
- uni.hideLoading();
- payIng = true
- if (ele.code == 0) {
- // #ifdef MP-ALIPAY
- my.tradePay({
- tradeNO: ele.data.pay_info,
- success(resu) {
- if(resu.resultCode == '9000'){
- uni.showToast({
- title: '支付成功',
- icon: 'success',
- duration: 2000
- })
- _this.pageList()
- }else {
- payIng = false
- }
- },
- fail() {
- payIng = false
- }
- })
- // #endif
- // #ifndef MP-ALIPAY
- uni.requestPayment({
- timeStamp: ele.data.timeStamp,
- nonceStr: ele.data.nonceStr,
- package: ele.data.package,
- signType: ele.data.signType,
- paySign: ele.data.paySign,
- success() {
- uni.showToast({
- title: '支付成功',
- icon: 'success',
- duration: 2000
- })
- _this.pageList()
- },
- fail() {
- payIng = false
- }
- })
- // #endif
- } else if (ele.code == 1005) {
- _this.authShow = true
- } else if (ele.code == 1026) {
- _this.authShow = true
- } else {
- payIng = false
- uni.$u.toast(res.msg);
- }
- }).catch(() => {
- payIng = false
- uni.$u.toast('订单创建失败');
- uni.hideLoading();
- })
- },
- changeTab(e) {
- if (e.index == 0) {
- this.status = null
- } else if (e.index == 1) {
- this.status = '0'
- } else if (e.index == 2) {
- this.status = '1,4'
- } else if (e.index == 3) {
- this.status = '2'
- } else if (e.index == 4) {
- this.status = '3'
- }
- this.pageList()
- },
- },
- onReachBottom() {
- if(this.total < this.pageNum * 20) return ;
- this.statusNomore = 'loading';
- ++this.pageNum
- if(this.total < this.pageNum * 20) this.statusNomore = 'nomore';
- else this.statusNomore = 'loading';
- this.getList()
- },
- }
- </script>
- <style lang="scss" scoped>
- .order {
- padding-bottom: 40rpx;
-
- // 订单导航
- &-state-search {
- position: relative;
- width: 100%;
- position: fixed;
- z-index: 100;
- background-color: #FFFFFF;
- box-shadow: 0 5rpx 5rpx #ececec;
- }
- // 订单列表
- &-list {
- margin: 0rpx 34rpx 0;
- padding-top: 110rpx;
- &-item {
- background: #FFFFFF;
- border-radius: 6rpx;
- margin-bottom: 22rpx;
- padding: 20rpx 34rpx;
-
- // 订单状态
- &__state {
- font-size: 30rpx;
- line-height: 30rpx;
- margin-bottom: 22rpx;
- color: #F9822C;
-
- .success {
- color: #999;
- }
- }
-
- // 商品列表
- &__goods {
- &-item{
- display: flex;
- padding: 20rpx 20rpx;
- border-radius: 4rpx;
- border-bottom: 1px solid rgba(102, 102, 102, 0.12);
-
- image {
- width: 220rpx;
- height: 200rpx;
- border-radius: 12rpx;
- margin-right: 24rpx;
- }
-
- .info {
- display: flex;
- flex-direction: column;
- justify-content: space-between;
- flex: 1;
- padding-bottom: 34rpx;
-
- &-title {
- font-weight: bold;
- line-height: 40rpx;
- }
-
- &-num {
- justify-content: space-between;
-
- &-price {
- font-size: 24rpx;
- }
-
- &-goods {
- color: #999999;
- }
- }
- }
- }
-
- &-item:last-child {
- margin-bottom: 0;
- border: none;
- }
- }
-
- // 订单价格
- &-price {
- justify-content: flex-end;
- padding-bottom: 18rpx;
- border-bottom: 1px solid #E5E5E5;
- margin-bottom: 22rpx;
-
- &__total {
- text:first-child {
- font-size: 24rpx;
- font-weight: normal;
- }
-
- text {
- font-size: 30rpx;
- font-weight: bold;
- color: #F9822C;
- }
- }
- }
-
- // 操作按钮
- &-btn {
- justify-content: flex-end;
-
- &-item {
- width: 200rpx;
- height: 66rpx;
- font-size: 30rpx;
- border-radius: 33rpx;
- margin-left: 44rpx;
-
- text {
- line-height: 30rpx;
- }
- }
-
- .logistics {
- border: 1px solid #F9822C;
- color: #F9822C;
- }
-
- .detail {
- background-color: rgb(249, 130, 44);
- color: #FFFFFF;
- }
-
- .cancel {
- border: 1px solid #c4c6c9;
- color: #c4c6c9;
- }
-
- .pay {
- background-color: #5ac725;
- color: #fff;
- }
-
- &-item:first-child {
- margin-left: 0;
- }
- }
- }
-
- &-item:last-child {
- margin-bottom: 0;
- }
- }
- // 空状态
- .empty {
- height: 60vh;
- .center {
- text-align: center;
-
- &-img {
- width: 228rpx;
- height: 320rpx;
- }
-
- &-font {
- font-size: 30rpx;
- font-weight: 400;
- color: #999999;
- margin-bottom: 250rpx;
- }
- }
- }
- }
- </style>
|