初始化代码

This commit is contained in:
2025-12-22 17:13:05 +08:00
parent ed0de08e3a
commit 1f7e9d401b
2947 changed files with 526137 additions and 0 deletions

View File

@@ -0,0 +1,476 @@
<template>
<view class="shop-order-detail" v-if="detail.id">
<uni-nav-bar :fixed="true" :shadow="false" :statusBar="true" color="#fff"
:backgroundColor="scrollTop < 20 ?``:primaryColor" :leftIcon="options.notice?'iconshouye':'icon-left'"
title="订单详情">
</uni-nav-bar>
<view :style="{height:`${configInfo.navBarHeight}px`}"></view>
<image mode="aspectFill" lazy-load class="common-bg abs" src="https://lbqny.migugu.com/admin/farm/bg-cash.png">
</image>
<view class="pl-lg pr-lg c-base" style="height: 120rpx;">
<view class="f-sm-title text-bold pt-md">{{statusType[detail.pay_type]}}</view>
<view class="f-caption" v-if="detail.pay_type == 1">请在<min-countdown :targetTime="over_time_text"
color="#fff" @callback="countEnd">
</min-countdown>内完成支付逾期未支付将自动取消</view>
</view>
<view class="order-text-info ml-md mr-md pd-lg fill-base f-paragraph c-title box-shadow radius-24"
v-if="detail.send_type == 2">
<view @tap.stop="toMap" class="flex-warp">
<i class="iconfont icon-dingwei mr-sm" style="font-size: 28rpx;margin-top: 6rpx;"></i>
<view class="flex-1">{{`${detail.address_info.address}${detail.address_info.address_info}`}}</view>
</view>
<view @tap.stop="$util.goUrl({url:detail.address_info.mobile,openType:'call'})"
class="flex-y-baseline c-caption" style="margin:5rpx 0 0 38rpx;">{{detail.address_info.user_name}}
<view class="ml-lg">
{{detail.address_info.mobile}}
</view>
</view>
</view>
<view class="order-text-info mt-md ml-md mr-md pl-lg pr-lg fill-base f-paragraph c-title box-shadow radius-24">
<view class="flex-between pt-lg pb-lg">
<view class="text c-desc">{{detail.send_type == 1 ? '自提时间':'配送时间'}}</view>
<view>{{detail.user_send_time}}</view>
</view>
<view class="pt-lg pb-lg b-1px-t" v-if="detail.text">
<view class="text c-desc">备注</view>
<view class="mt-sm">
<text decode="emsp" style="word-break:break-all;">{{detail.text}}</text>
</view>
</view>
</view>
<view class="mt-md ml-md mr-md pd-lg fill-base f-paragraph c-title box-shadow radius-24">
<view @tap="$util.goUrl({url:`/shop/pages/store?id=${detail.store_info.id}`})"
class="flex-y-center pb-lg b-1px-b">
<i class="iconfont icon-dianpu mr-sm"></i>
<view class="f-title c-title text-bold ellipsis">{{detail.store_info.title}}</view>
<i class="iconfont icon-right"></i>
</view>
<view class="order-item flex-center" :class="[{'mt-lg':index==0},{'mt-md':index!=0}]"
v-for="(item,index) in detail.order_goods" :key="index">
<image mode="aspectFill" lazy-load class="avatar box-shadow-mini radius-24" :src="item.goods_cover">
</image>
<view class="flex-1 ml-lg">
<view class="f-paragraph c-title text-bold max-490 ellipsis"> {{item.goods_name}}
</view>
<view class="f-caption c-title" :class="[{'flex-center':item.refund_num*1>0}]">
<view class="ellipsis" :style="{maxWidth:item.refund_num*1>0?'300rpx':'490rpx'}">
{{item.spe_name}}
</view>
<view class="flex-1 c-warning text-right" v-if="item.refund_num*1>0">已退x{{item.refund_num}}
</view>
</view>
<view class="flex-y-baseline mt-sm">
<view class="flex-1 f-paragraph c-warning">¥{{item.goods_price}} </view>
<view class="f-caption c-caption">x {{item.goods_num}} </view>
</view>
</view>
</view>
<view class="mt-lg pt-lg pb-lg f-paragraph c-title b-1px-tb">
<view class="flex-between">
<view>商品金额</view>
<view>¥{{detail.init_goods_price}}</view>
</view>
<block v-if="detail.send_type == 2">
<view class="flex-between mt-sm">
<view>配送费</view>
<view>¥{{detail.freight}}</view>
</view>
</block>
<view class="flex-between mt-sm" v-if="detail.kill_discount_price*1>0">
<view>秒杀优惠</view>
<view class="c-warning">-¥{{detail.kill_discount_price}}</view>
</view>
<view class="flex-between mt-sm" v-if="detail.integral_discount_price*1>0">
<view>积分抵扣</view>
<view class="c-warning">-¥{{detail.integral_discount_price}}</view>
</view>
<view class="flex-between mt-sm" v-if="detail.discount*1>0">
<view>卡券优惠</view>
<view class="c-warning">-¥{{detail.discount}}</view>
</view>
</view>
<view class="mt-lg f-paragraph c-title flex-between mt-sm">
<view>合计</view>
<view class="f-title c-warning text-bold">¥{{detail.pay_price}}</view>
</view>
</view>
<video class="item-video mt-md ml-md mr-md radius-24" style="overflow: hidden;" :loop="false" enable-play-gesture enable-progress-gesture
:src="detail.video" @waiting="onWaiting" @progress="onProgress" @loadedmetadata="onLoadedMetaData"
v-if="detail.video">
</video>
<view class="order-text-info mt-md ml-md mr-md pd-lg fill-base f-caption c-title box-shadow radius-24">
<view class="flex-warp pt-sm">
<view class="text c-caption">订单编号</view>
<view class="flex-1 flex-y-center">{{detail.order_code}}
<view @tap="$util.goUrl( {url:`${detail.order_code}`,openType:'copy'})"
class="copy-btn sm flex-center fill-body" :style="{color:primaryColor}">复制</view>
</view>
</view>
<block v-if="detail.send_type == 2">
<view class="flex-warp pt-md" v-if="detail.transaction_id">
<view class="text c-caption">付款单号</view>
<view class="flex-1 flex-y-center">{{detail.transaction_id}}
<view @tap="$util.goUrl( {url:`${detail.transaction_id}`,openType:'copy'})"
class="copy-btn sm flex-center fill-body" :style="{color:primaryColor}">复制</view>
</view>
</view>
<view class="flex-warp pt-md" v-if="detail.pay_type == -1 && detail.refund_code">
<view class="text c-caption">退款单号</view>
<view class="flex-1 flex-y-center">{{detail.refund_code}}
<view @tap="$util.goUrl( {url:`${detail.refund_code}`,openType:'copy'})"
class="copy-btn sm flex-center fill-body" :style="{color:primaryColor}">复制</view>
</view>
</view>
</block>
<view class="flex-warp pt-md">
<view class="text c-caption">下单时间</view>
<view class="flex-1">{{detail.create_time}}</view>
</view>
<block v-if="detail.send_type == 2">
<view class="flex-warp pt-md" v-if="detail.pay_time">
<view class="text c-caption">支付时间</view>
<view class="flex-1">{{detail.pay_time}}</view>
</view>
<view class="flex-warp pt-md">
<view class="text c-caption">支付方式</view>
<view class="flex-1">{{payType[detail.pay_model]}}</view>
</view>
</block>
</view>
<view class="order-text-info mt-md ml-md mr-md pd-lg fill-base f-caption c-title box-shadow radius-24"
v-if="detail.pay_type == 7">
<view class="flex-warp pt-sm" v-if="detail.hx_time">
<view class="text c-caption">收货时间</view>
<view class="flex-1">{{detail.hx_time}}</view>
</view>
<view class="flex-warp pt-md">
<view class="text c-caption">收货人</view>
<view class="flex-1">{{detail.hx_user_name}}</view>
</view>
</view>
<view class="space-max-footer"></view>
<view class="footer-btn fix fill-base pl-lg pr-lg"
v-if="detail.pay_type==1 || (detail.pay_type == 2 && detail.can_refund) || detail.pay_type == 3 || (detail.pay_type == 7 && (detail.can_refund || !detail.have_eva))">
<view class="flex-between">
<view></view>
<view class="flex-y-center" v-if="detail.pay_type == 1">
<view @tap.stop="toChangeOrder('cancel_item')"
class="common-btn disabled flex-center f-caption c-title radius">取消订单
</view>
<view @tap.stop="toPay" class="common-btn flex-center f-caption c-base radius ml-lg"
:style="{background:primaryColor}">去支付
</view>
</view>
<view class="flex-y-center" v-if="detail.pay_type == 2">
<view @tap.stop="toRefund" class="common-btn disabled flex-center f-caption c-title radius"
v-if="detail.can_refund">申请退款
</view>
</view>
<view class="flex-y-center" v-if="detail.pay_type == 3">
<view @tap.stop="toRefund" class="common-btn disabled flex-center f-caption c-title radius"
v-if="detail.can_refund">申请退款
</view>
<view @tap.stop="toChangeOrder('end_item')"
class="common-btn flex-center f-caption c-base radius ml-lg" :style="{background:primaryColor}">
确认收货
</view>
</view>
<view class="flex-y-center" v-if="detail.pay_type == 7 && (detail.can_refund || !detail.have_eva)">
<view @tap.stop="toRefund(index)" class="common-btn disabled flex-center f-caption c-title radius"
v-if="detail.can_refund">申请退款
</view>
<view @tap.stop="toEvaluate" class="common-btn flex-center f-caption c-base radius ml-lg"
:style="{background:primaryColor}" v-if="!detail.have_eva">去评价
</view>
</view>
</view>
<view class="space-safe"></view>
</view>
<common-popup @confirm="confirmUpdate" ref="cancel_item" type="CANCEL_ORDER" :info="popupInfo"></common-popup>
<common-popup @confirm="confirmUpdate" ref="end_item" type="END_ORDER" :info="popupInfo"></common-popup>
</view>
</template>
<script>
import {
mapState,
mapActions,
mapMutations
} from "vuex"
export default {
components: {},
data() {
return {
scrollTop: 0,
options: {},
detail: {},
payType: {
1: '微信支付',
2: '余额支付',
3: '支付宝支付'
},
statusType: {
'-1': '已取消',
1: '待支付',
2: '待发货',
3: '待收货',
7: '已完成',
},
sendType: {
1: '自提',
2: '快递'
},
param: {
page: 1,
},
list: {
data: []
},
loading: true,
popupInfo: {},
lockTap: false
}
},
computed: mapState({
primaryColor: state => state.config.configInfo.primaryColor,
subColor: state => state.config.configInfo.subColor,
configInfo: state => state.config.configInfo,
userInfo: state => state.user.userInfo,
haveOperItem: state => state.order.haveOperItem,
over_time_text() {
return new Date().getTime() + this.detail.over_time * 1000
}
}),
onLoad(options) {
let {
notice = 0
} = options
options.notice = notice
this.options = options
this.$util.showLoading()
this.updateOrderItem({
key: 'haveOperItem',
val: false
})
this.initIndex()
},
onUnload() {
if (!this.haveOperItem) return
this.$util.back()
},
onPageScroll(e) {
this.scrollTop = e.scrollTop
},
methods: {
...mapActions(['getConfigInfo']),
...mapMutations(['updateOrderItem']),
async initIndex() {
let {
id,
} = this.options
let data = await this.$api.shop.orderInfo({
id
})
this.detail = data
this.$util.hideAll()
},
initRefresh() {
this.initIndex()
},
countEnd() {
this.$util.log("倒计时完了")
setTimeout(() => {
this.initRefresh()
this.$util.back()
}, 1000)
},
onWaiting(e) {},
onProgress(e) {},
onLoadedMetaData(e) {},
async toMap() {
let {
lat,
lng,
address
} = this.detail
await this.$util.checkAuth({
type: 'userLocation'
})
await uni.getLocation({
type: 'gcj02',
})
await uni.openLocation({
latitude: lat * 1,
longitude: lng * 1,
name: address,
scale: 28
})
},
// 取消订单/确认收货
async toChangeOrder(key) {
let {
id,
order_code,
order_goods,
} = this.detail
let {
goods_cover: image,
} = order_goods[0]
this.popupInfo = {
id,
name: `订单编号:${order_code}`,
image,
refs_key: key,
}
this.$refs[key].open()
},
async confirmUpdate() {
let {
id,
refs_key,
} = this.popupInfo
if (this.lockTap) return;
this.lockTap = true;
this.$util.showLoading()
let methodModel = {
'cancel_item': {
method: 'cancelOrder',
pay_type: -1,
msg: '取消成功'
},
'end_item': {
method: 'endOrder',
pay_type: 7,
msg: '收货成功'
},
}
try {
let {
method,
pay_type,
msg
} = methodModel[refs_key]
await this.$api.shop[method]({
id
})
this.$util.hideAll()
this.$util.showToast({
title: msg
})
this.lockTap = false
this.initRefresh()
this.$refs[refs_key].close()
this.updateOrderItem({
key: 'haveOperItem',
val: true
})
} catch (e) {
setTimeout(() => {
this.lockTap = false
this.$util.hideAll()
}, 2000)
}
},
// 去支付
async toPay() {
if (this.lockTap) return;
this.lockTap = true;
this.$util.showLoading()
let {
id,
pay_model
} = this.detail
try {
let {
pay_list
} = await this.$api.shop.rePayOrder({
id
})
this.$util.hideAll()
if (pay_list) {
if (pay_model == 3) {
pay_list = {
orderInfo: pay_list,
provider: 'alipay'
}
}
try {
await this.$util.pay(pay_list)
this.lockTap = false;
this.detail.pay_type = 2
this.updateOrderItem({
key: 'haveOperItem',
val: true
})
} catch (e) {
this.lockTap = false;
return;
}
}
} catch (e) {
setTimeout(() => {
this.lockTap = false
this.$util.hideAll()
}, 2000)
}
},
// 申请退款
toRefund() {
let {
id
} = this.detail
let url = `/shop/pages/order/refund?id=${id}`
this.$util.goUrl({
url
})
},
// 去评价
toEvaluate() {
let {
id
} = this.detail
let url = `/mine/pages/evaluate/edit?id=${id}&type=shop`
this.$util.goUrl({
url
})
},
}
}
</script>
<style lang="scss">
.shop-order-detail {
.order-seed-item {
.seed-img {
width: 80rpx;
height: 80rpx;
box-shadow: 0px 0px 10px 0px rgba(0, 0, 0, 0.1);
}
}
.item-video {
width: 710rpx;
height: 380rpx;
display: block;
}
.footer-btn {
width: 100%;
bottom: 0;
.flex-between {
height: 98rpx;
}
}
}
</style>

View File

@@ -0,0 +1,373 @@
<template>
<view class="shop-order-list">
<fixed>
<tab @change="handerTabChange" :list="tabList" :activeIndex="activeIndex" :activeColor="primaryColor"
:width="100/tabList.length + '%'" height="100rpx"></tab>
<view class="b-1px-b"></view>
</fixed>
<view @tap.stop="goDetail(index)" class="fill-base mt-md ml-md mr-md pd-lg box-shadow-mini radius-16"
v-for="(item,index) in list.data" :key="index">
<view class="flex-between pb-lg">
<view @tap.stop="goStore(index)" class="flex-y-center">
<i class="iconfont icon-dianpu mr-sm"></i>
<view class="f-title c-title text-bold max-446 ellipsis">{{item.store_info.title}}</view>
<i class="iconfont icon-right"></i>
</view>
<view class="f-paragraph c-title"
:class="[{'c-warning': item.pay_type < 3 && item.pay_type != -1},{'c-success': item.pay_type == 3}]">
{{statusType[item.pay_type]}}
</view>
</view>
<view class="order-item flex-center" :class="[{'mt-md':aindex!=0}]"
v-for="(aitem,aindex) in item.order_goods" :key="aindex">
<image mode="aspectFill" lazy-load class="avatar box-shadow-mini radius-24" :src="aitem.goods_cover">
</image>
<view class="flex-1 ml-lg">
<view class="f-paragraph c-title text-bold max-490 ellipsis"> {{aitem.goods_name}}
</view>
<view class="f-caption c-title" :class="[{'flex-center':aitem.refund_num*1>0}]">
<view class="ellipsis" :style="{maxWidth:aitem.refund_num*1>0?'300rpx':'490rpx'}">
{{aitem.spe_name}}
</view>
<view class="flex-1 c-warning text-right" v-if="aitem.refund_num*1>0">已退x{{aitem.refund_num}}
</view>
</view>
<view class="flex-y-baseline mt-sm">
<view class="flex-1 f-paragraph c-warning">¥{{aitem.goods_price}} </view>
<view class="f-caption c-caption">x {{aitem.goods_num}} </view>
</view>
</view>
</view>
<view class="flex-between mt-lg pt-md b-1px-t">
<view class="c-title ml-sm mr-sm"> {{`${item.all_goods_num}`}}</view>
<view class="flex-y-baseline f-desc c-title"> 实付
<view class="f-title c-warning">¥{{item.true_price}}</view>
</view>
</view>
<view class="flex-between mt-md"
v-if="item.pay_type==1 || (item.pay_type == 2 && item.can_refund ) || item.pay_type == 3 || (item.pay_type == 7 && (item.can_refund || !item.have_eva))">
<view></view>
<view class="flex-warp" v-if="item.pay_type == 1">
<view @tap.stop="toChangeOrder(index,'cancel_item')"
class="common-btn disabled flex-center f-caption c-title radius-4">取消订单
</view>
<view @tap.stop="toPay(index)" class="common-btn flex-center f-caption c-base radius-4 ml-lg"
:style="{background:primaryColor}">去支付
</view>
</view>
<view class="flex-warp" v-if="item.pay_type == 2">
<view @tap.stop="toRefund(index)" class="common-btn disabled flex-center f-caption c-title radius-4"
v-if="item.can_refund">申请退款
</view>
</view>
<view class="flex-warp" v-if="item.pay_type == 3">
<view @tap.stop="toRefund(index)" class="common-btn disabled flex-center f-caption c-title radius-4"
v-if="item.can_refund">申请退款
</view>
<view @tap.stop="toChangeOrder(index,'end_item')"
class="common-btn flex-center f-caption c-base radius-4 ml-lg"
:style="{background:primaryColor}">确认收货
</view>
</view>
<view class="flex-warp" v-if="item.pay_type == 7 && (item.can_refund || !item.have_eva)">
<view @tap.stop="toRefund(index)" class="common-btn disabled flex-center f-caption c-title radius-4"
v-if="item.can_refund">申请退款
</view>
<view @tap.stop="toEvaluate(index)" class="common-btn flex-center f-caption c-base radius-4 ml-lg"
:style="{background:primaryColor}" v-if="!item.have_eva">去评价
</view>
</view>
</view>
</view>
<load-more :noMore="list.current_page>=list.last_page&&list.data.length>0" :loading="loading" v-if="loading">
</load-more>
<abnor v-if="!loading&&list.data.length<=0&&list.current_page==1"></abnor>
<view class="space-footer"></view>
<common-popup @confirm="confirmUpdate" ref="cancel_item" type="CANCEL_ORDER" :info="popupInfo"></common-popup>
<common-popup @confirm="confirmUpdate" ref="end_item" type="END_ORDER" :info="popupInfo"></common-popup>
</view>
</template>
<script>
import {
mapState,
} from "vuex"
export default {
components: {},
data() {
return {
options: {},
activeIndex: 0,
tabList: [{
id: 0,
title: '全部'
}, {
id: 1,
title: '待支付',
number: 0
}, {
id: 2,
title: '待发货',
number: 0
}, {
id: 3,
title: '待收货',
number: 0
}, {
id: 7,
title: '已完成'
}],
statusType: {
'-1': '已取消',
1: '待支付',
2: '待发货',
3: '待收货',
7: '已完成',
},
param: {
page: 1,
},
list: {
data: []
},
loading: true,
popupInfo: {},
lockTap: false
}
},
computed: mapState({
primaryColor: state => state.config.configInfo.primaryColor,
subColor: state => state.config.configInfo.subColor,
configInfo: state => state.config.configInfo,
userInfo: state => state.user.userInfo,
}),
onLoad(options) {
this.$util.showLoading()
this.options = options
let {
tab = 0
} = options
this.activeIndex = tab
this.initIndex()
},
onPullDownRefresh() {
// #ifndef APP-PLUS
uni.showNavigationBarLoading()
// #endif
this.initRefresh()
uni.stopPullDownRefresh()
},
onReachBottom() {
if (this.list.current_page >= this.list.last_page || this.loading) return
this.param.page = this.param.page + 1
this.loading = true
this.getList()
},
methods: {
initIndex() {
this.getList()
},
initRefresh() {
this.param.page = 1
this.initIndex()
},
async getList() {
let {
list: oldList,
param,
tabList,
activeIndex
} = this
param.pay_type = tabList[activeIndex].id
let newList = await this.$api.shop.orderList(param);
if (this.param.page == 1) {
this.list = newList
} else {
newList.data = oldList.data.concat(newList.data)
this.list = newList
}
this.loading = false
this.tabList[1].number = newList.no_pay_count
this.tabList[2].number = newList.no_send_count
this.tabList[3].number = newList.have_send_count
this.$util.hideAll()
},
handerTabChange(index) {
this.activeIndex = index
this.$util.showLoading()
this.param.page = 1
this.list.data = []
this.getList()
},
// 取消订单/确认收货
async toChangeOrder(index, key) {
let {
id,
order_code,
order_goods,
} = this.list.data[index]
let {
goods_cover: image,
} = order_goods[0]
this.popupInfo = {
id,
name: `订单编号:${order_code}`,
image,
index,
refs_key: key,
}
this.$refs[key].open()
},
async confirmUpdate() {
let {
id,
index,
refs_key,
} = this.popupInfo
if (this.lockTap) return;
this.lockTap = true;
this.$util.showLoading()
let methodModel = {
'cancel_item': {
method: 'cancelOrder',
pay_type: -1,
msg: '取消成功',
ind: 1
},
'end_item': {
method: 'endOrder',
pay_type: 7,
msg: '收货成功',
ind: 3
}
}
try {
let {
method,
pay_type,
msg,
ind
} = methodModel[refs_key]
await this.$api.shop[method]({
id
})
this.$util.hideAll()
if (this.activeIndex == 0) {
this.list.data[index].pay_type = pay_type
if (pay_type == 7) {
this.list.data[index].can_refund = 1
}
} else {
this.list.data.splice(index, 1)
}
this.$util.showToast({
title: msg
})
this.lockTap = false
this.$refs[refs_key].close()
let {
number
} = this.tabList[ind]
this.tabList[ind].number = number - 1
} catch (e) {
setTimeout(() => {
this.lockTap = false
this.$util.hideAll()
}, 2000)
}
},
// 去支付
async toPay(index) {
if (this.lockTap) return;
this.lockTap = true;
this.$util.showLoading()
let {
id,
pay_model
} = this.list.data[index]
try {
let {
pay_list
} = await this.$api.shop.rePayOrder({
id
})
this.$util.hideAll()
if (pay_list) {
if (pay_model == 3) {
pay_list = {
orderInfo: pay_list,
provider: 'alipay'
}
}
try {
await this.$util.pay(pay_list)
this.lockTap = false;
if (this.activeIndex == 0) {
this.list.data[index].pay_type = 2
} else {
this.list.data.splice(index, 1)
}
} catch (e) {
this.lockTap = false;
return;
}
}
} catch (e) {
setTimeout(() => {
this.lockTap = false
this.$util.hideAll()
}, 2000)
}
},
// 申请退款
toRefund(index) {
let {
id
} = this.list.data[index]
let url = `/shop/pages/order/refund?id=${id}`
this.$util.goUrl({
url
})
},
// 去评价
toEvaluate(index) {
let {
id
} = this.list.data[index]
let url = `/mine/pages/evaluate/edit?id=${id}&type=shop`
this.$util.goUrl({
url
})
},
// 订单详情
goDetail(index) {
let {
id
} = this.list.data[index]
let url = `/shop/pages/order/detail?id=${id}`
this.$util.goUrl({
url
})
},
// 店铺详情
goStore(index) {
let {
id
} = this.list.data[index].store_info
let url = `/shop/pages/store?id=${id}`
this.$util.goUrl({
url
})
}
}
}
</script>
<style lang="scss">
</style>

View File

@@ -0,0 +1,386 @@
<template>
<view class="user-order-refund" v-if="detail.id">
<view class="fill-base mt-md ml-md mr-md pd-lg radius-34">
<view class="flex-between pb-lg b-1px-b">
<view class="flex-y-center">
<i class="iconfont icon-dianpu mr-sm"></i>
<view class="f-title c-title text-bold max-446 ellipsis">{{detail.store_info.title}}</view>
</view>
<view class="f-paragraph c-title"
:class="[{'c-warning': detail.pay_type < 3 && detail.pay_type != -1},{'c-success': detail.pay_type == 3}]">
{{statusType[detail.pay_type]}}
</view>
</view>
<block v-for="(item,index) in detail.order_goods" :key="index">
<view @tap="handerRadioChange(index)" class="item-child flex-warp"
:class="[{'mt-lg':index==0},{'mt-md':index!=0}]">
<i class="iconfont flex-y-center mr-md"
:class="[{'icon-xuanze':!item.checked},{'icon-xuanze-fill':item.checked}]"
:style="{color:item.checked ? primaryColor : ''}"></i>
<image mode="aspectFill" lazy-load class="goods-img box-shadow-mini radius-16"
:src="item.goods_cover">
</image>
<view class="flex-1 ml-lg">
<view class="f-paragraph c-title text-bold ellipsis"> {{item.goods_name}} </view>
<view class="f-caption c-title ellipsis"> {{item.spe_name}} </view>
<view class="f-caption c-warning mt-sm" v-if="item.integral_id">{{item.integral}}积分</view>
<view class="flex-y-baseline mt-sm">
<view class="flex-1 f-paragraph c-warning">¥{{item.singe_pay_price}} </view>
<view class="flex-warp" v-if="item.can_refund_num > 1">
<view class="add-remove-item flex-center">
<i @tap.stop="changeNum(index,-1)"
class="iconfont icon-remove-circle c-caption"></i>
<view class="number flex-center f-desc pl-sm pr-sm">{{item.apply_num}}
</view>
<i @tap.stop="changeNum(index,1)" class="iconfont icon-add-circle"
:style="{color:primaryColor}"></i>
</view>
</view>
<block v-else>
<view class="c-paragraph">x{{item.apply_num}}</view>
</block>
</view>
</view>
</view>
</block>
<view class="mt-lg pt-lg pb-lg f-paragraph c-title b-1px-tb">
<view class="flex-between">
<view>商品金额</view>
<view>¥{{detail.can_refund_price}}</view>
</view>
<block v-if="detail.send_type == 2">
<view class="flex-between mt-sm">
<view class="flex-y-baseline">配送费<view class="f-icontext c-warning ml-sm">发货前全部商品退款将退还</view>
</view>
<view>¥{{detail.freight}}</view>
</view>
</block>
</view>
<view class="mt-lg f-paragraph c-title flex-between mt-sm">
<view>合计</view>
<view class="f-title c-warning text-bold">
{{total_refund_integral?`${total_refund_integral}积分+${total_refund_price}`:`${total_refund_price}`}}
</view>
</view>
</view>
<view class="item-child mg-big pd-lg fill-base radius-34">
<view class="f-title c-title text-bold pb-lg">退款原因</view>
<view class="fill-body f-paragraph c-title radius-34">
<textarea v-on:input="subForm.text = subForm.text.length>200?subForm.text.substring(0,200):subForm.text"
v-model="subForm.text" class="pd-lg f-paragraph" style="width: 580rpx;" maxlength="200"
placeholder="请输入退款原因" placeholder-class="c-title" />
<view class="text-right pb-lg pr-lg">{{`${subForm.text.length}/200`}}
</view>
</view>
</view>
<view class="item-child mg-big pd-lg fill-base radius-34">
<view class="f-title c-title text-bold">上传图片</view>
<view class="mt-sm">
<upload @del="imgUpload" @upload="imgUpload" :imagelist="subForm.imgs" imgtype="imgs" text="添加照片"
:imgsize="5"></upload>
</view>
</view>
<view class="space-max-footer"></view>
<view class="refund-bottom-info fill-base fix pl-lg pr-lg">
<view class="flex-between">
<view @tap="selectAllItem" class="flex-y-center"><i class="iconfont mr-sm"
:class="[{'icon-xuanze':!selectAll},{'icon-xuanze-fill':selectAll}]"
:style="{color:selectAll?primaryColor : ''}"></i>
全选
</view>
<view class="text-right flex-center">
<view class="flex-y-center">
<view class="f-caption c-caption mr-sm">{{total_refund_num}}</view>
退款金额<view class="flex-y-baseline f-caption c-warning">¥<view class="f-title text-bold">
{{total_refund_price}}
</view>
</view>
</view>
<view @tap.stop="toSubmit" class="common-btn flex-center ml-lg f-paragraph c-base radius"
:style="{background:primaryColor}">提交申请</view>
</view>
</view>
<view class="space-safe"></view>
</view>
</view>
</template>
<script>
import {
mapState,
mapMutations
} from "vuex"
export default {
components: {},
data() {
return {
options: {},
detail: {},
statusType: {
'-1': '已取消',
1: '待支付',
2: '待发货',
3: '待收货',
7: '已完成',
},
total_refund_num: 0,
total_refund_integral: 0,
total_refund_price: 0,
selectAll: false,
selectAdd: false,
subForm: {
text: '',
imgs: []
},
lockTap: false
}
},
computed: mapState({
primaryColor: state => state.config.configInfo.primaryColor,
subColor: state => state.config.configInfo.subColor,
configInfo: state => state.config.configInfo,
}),
onLoad(options) {
this.options = options
this.initIndex()
},
onUnload() {
this.$util.back()
},
methods: {
...mapMutations(['updateOrderItem']),
async initIndex() {
let {
id
} = this.options
let data = await this.$api.shop.orderInfo({
id
})
let arr = []
let can_refund_price = 0
data.order_goods.map(item => {
item.apply_num = item.can_refund_num
if (item.apply_num == 0) return
can_refund_price += item.singe_pay_price * item.apply_num
arr.push(item)
})
data.can_refund_price = can_refund_price.toFixed(2)
data.order_goods = arr
this.detail = data
},
initRefresh() {
this.initIndex()
},
imgUpload(e) {
let {
imagelist,
imgtype
} = e;
this.subForm[imgtype] = imagelist;
},
handerRadioChange(index) {
let item = this.detail.order_goods[index];
let newChecked = !item.checked;
this.detail.order_goods[index].checked = newChecked;
this.checkIsSelectAll();
},
handerAddRadioChange() {
this.selectAdd = !this.selectAdd
this.checkIsSelectAll()
},
async changeNum(index, mod) {
let item = this.detail.order_goods[index];
let num = item.apply_num + mod;
if (num < 1) {
this.$util.showToast({
title: `此商品最少可退1件`
})
return;
}
if (num > item.can_refund_num) {
this.$util.showToast({
title: `此商品最多可退${item.can_refund_num}`
})
return;
}
this.detail.order_goods[index].apply_num = num;
this.countPrice();
},
selectAllItem() {
this.detail.order_goods.map((item) => {
item.checked = !this.selectAll
})
this.checkIsSelectAll();
},
checkIsSelectAll() {
let list = []
this.detail.order_goods.map(item => {
list.push(item)
})
this.selectAll = list.every((item) => {
return item.checked
})
this.countPrice();
},
countPrice() {
let price = 0
let num = 0
let integral = 0
let list = []
this.detail.order_goods.map(item => {
list.push(item)
})
list.map(item => {
if (item.checked) {
num += item.apply_num
integral += item.integral * item.apply_num
price += item.singe_pay_price * item.apply_num
}
})
let {
freight,
pay_type,
all_goods_num
} = this.detail
let freight_price = all_goods_num == num && pay_type == 2 ? freight * 1 : 0
this.total_refund_num = num
this.total_refund_integral = integral
this.total_refund_price = price.toFixed(2) * 1 + freight_price
},
// 提交申请
async toSubmit() {
let {
id: order_id,
order_goods
} = this.detail
let list = []
order_goods.filter(item => {
if (item.checked) {
list.push({
id: item.id,
num: item.apply_num
})
}
})
if (list.length < 1) {
this.$util.showToast({
title: `请选择商品`,
});
return
}
let param = this.$util.deepCopy(this.subForm)
if (!param.text) {
this.$util.showToast({
title: `请输入退款原因`,
});
return
}
param.imgs = param.imgs.length > 0 ? param.imgs.map(item => {
return item.path
}) : []
param = Object.assign({}, param, {
order_id,
list
})
if (this.lockTap) return
this.lockTap = true
this.$util.showLoading()
try {
await this.$api.shop.applyOrder(param)
this.$util.hideAll()
this.$util.showToast({
title: `提交成功`,
});
this.updateOrderItem({
key: 'haveOperItem',
val: true
})
setTimeout(() => {
this.$util.back()
this.$util.goUrl({
url: 1,
openType: `navigateBack`
})
this.lockTap = false
}, 1000)
} catch (e) {
setTimeout(() => {
this.lockTap = false
this.$util.hideAll()
}, 2000)
}
},
}
}
</script>
<style lang="scss">
.user-order-refund {
.item-child {
.icon-xuanze,
.icon-xuanze-fill {
font-size: 38rpx;
height: 130rpx;
}
.goods-img {
width: 130rpx;
height: 130rpx;
}
.ellipsis {
max-width: 412rpx;
}
.goods-spe {
height: 44rpx;
line-height: 44rpx;
background: #F7F7F7;
}
.goods-num {
width: 200rpx;
}
.textarea-info {
background: #F7F7F7;
.input-textarea {
width: 570rpx;
height: 300rpx;
}
}
}
.refund-bottom-info {
bottom: 0;
min-height: 110rpx;
.iconfont {
font-size: 38rpx;
}
.text-right {
height: 110rpx;
.order {
margin-top: 0;
}
}
}
}
</style>