Commit c2d6013b authored by June's avatar June

feat:订单管理,售后

parent 7705f22c
......@@ -65,4 +65,15 @@ export function getStoreInfo() {
url: 'zsxcx/shopDetail.htm',
method: 'post'
})
}
export function pay({order_sn, openid}) {
return request({
url: 'zsxcx/orderWxPay.htm',
method: 'post',
data: {
order_sn, openid
},
needMask: true
})
}
\ No newline at end of file
......@@ -76,7 +76,7 @@ export function remindOrder({order_id, order_sn}) {
/**
* @desc 取消订单
*/
export function cancelDetail1(order_sn) {
export function cancelOrder(order_sn) {
return request({
url: 'zsxcx/orderCancelXcx.htm',
method: 'post',
......@@ -87,6 +87,24 @@ export function cancelDetail1(order_sn) {
})
}
/**
* @desc 申请退款/退货退款/退货/取消订单等订单操作申请接口
* @param order_sn
* @param {type} apply_type 申请类型:1退款 2退货退款 3取消订单 4退货
*/
export function applyBack({order_sn, apply_type}) {
return request({
url: 'zsxcx/applyRrcXcx.htm',
method: 'post',
data: {
order_sn,
apply_type
},
needMask: true
})
}
/**
* @desc 确认收货
*/
......@@ -98,4 +116,49 @@ export function recieveOrder(order_sn) {
order_sn
}
})
}
/**
* @desc 撤销XXX
* @param {type} order_sn
* @param {type} cancel_type
*/
export function undoOrder({order_sn, cancel_type}) {
return request({
url: 'zsxcx/cancelRrcApplyXcx.htm',
method: 'post',
data: {
order_sn,
cancel_type
},
needMask: true
})
}
/**
* @desc 签收退款
*/
export function recieveOrderRefund(order_sn) {
return request({
url: 'zsxcx/confirmReceivedRefundXcx.htm',
method: 'post',
data: {
order_sn
},
needMask: true
})
}
/**
* @desc 延长退款时间
*/
export function addRefundTime(order_sn) {
return request({
url: 'zsxcx/extendReceivedRefundXcx.htm',
method: 'post',
data: {
order_sn
},
needMask: true
})
}
\ No newline at end of file
......@@ -29,6 +29,7 @@
index
}"
:max="~~item.inventory"
:min="~~item.origin_number_sku"
@change="numberChange"
/>
</view>
......@@ -96,7 +97,6 @@ export default {
return {
goods: null,
skuData: [],
// currentSku: null, // 一次只能提交一个规格到购物车: 0,
totalCounts: 0,
totalPrice: 0
}
......@@ -108,20 +108,6 @@ export default {
price
},
computed: {
// 总数
// totalCounts() {
// return this.skuData.reduce((pre, cur) => {
// return pre + cur.counts
// }, 0)
// },
// // 总价
// totalPrice() {
// return 1
// }
},
methods: {
...common,
...mapActions('cart', ['setCount']),
......@@ -136,16 +122,13 @@ export default {
async show(params) {
try{
this.goods = params.goodsInfo
this.skuData = params.skuData
this.skuData = JSON.parse(JSON.stringify(params.skuData))
this.skuData.forEach(item => {
item.tiered_pri = item.tiered_pri && typeof item.tiered_pri === 'string' ? JSON.parse(item.tiered_pri) : ''
item.counts = 0
item.counts = ~~item.origin_number_sku
})
console.log('-----------------------------------------------------------')
console.log(this.skuData)
console.log('-----------------------------------------------------------')
this.$refs.goodsPopup.open()
this.total()
this.$refs.goodsPopup.open()
}catch(e){
console.log(e)
this.$toast({title: e.msg || '程序错误'})
......@@ -154,47 +137,41 @@ export default {
hide() {
this.$refs.goodsPopup.close()
this.showSku = false
// this.showSku = false
this.detail = null
// this.currentSku = null
this.skuData = []
this.goods = null
},
numberChange(e) {
// const skuData = this.skuData
console.log(e)
const idx = e.params.index
const value = e.val
// this.currentSku = {
// goods_id: skuData[idx].goods_id,
// cart_number: value,
// sku_id: skuData[idx].sku_id
// }
this.$set(this.skuData[idx], 'counts', value)
this.total()
console.log(this.skuData)
},
total() {
const skuData = this.skuData
this.totalCounts = skuData.reduce((pre, cur) => { return pre + ~~cur.counts}, 0)
this.totalPrice = skuData.reduce((pre, cur) => {
const price = ~~cur.price
const price = +cur.price
const counts = ~~cur.counts
if(cur.is_tiered === '1') { // 阶梯价 询价不管,不展示,按固定价计算
const tiered_pri = cur.tiered_pri
// console.log(cur.tiered_pri.find(item => item.num < counts))
for(let i = 0, j = tiered_pri.length; i < j; i ++) {
if(counts >= tiered_pri[j-1].num) {
return pre + tiered_pri[j-1].price * counts
} else if(tiered_pri[i].num > counts) {
return pre + (i - 1 >= 0 ? tiered_pri[i - 1].price : ~~cur.price) * counts
return pre + (i - 1 >= 0 ? tiered_pri[i - 1].price : price) * counts
}
}
// return pre + cur.tiered_pri.find(item => item.num > counts).price * counts
} else {
return pre + price * counts
return pre + price * counts
}
}, 0)
}, 0).toFixed(2)
},
// 加入购物车
......
......@@ -56,7 +56,7 @@ export default {
const min = this.min
const newVal_number = ~~newVal
if(max && newVal_number >= max) return
if(newVal_number <= min) return
if(newVal_number < min) return
this.$emit('change', {
params: this.params,
val: newVal_number
......
......@@ -16,8 +16,6 @@ export default function Modal(options) {
confirmColor: '#FF661A',
success: res => {
if(res.confirm) {
console.log(options.cb)
options.cb && typeof options.cb === 'function' && options.cb()
}
}
......
import { cancelDetail1, remindOrder } from "@/apis/order.js"
import { cancelOrder, remindOrder, applyBack, undoOrder, recieveOrder, recieveOrderRefund, addRefundTime } from "@/apis/order.js"
import createOrder from '@/utils/modules/pay.js'
import { isFunction } from '@/utils/types.js'
// 详细看文档
const order_statsu = {
'0': '待接单',
'1': '待付款',
'2': '交易关闭',
'5': '交易完成',
'6': '待发货',
'7': '待收货',
'9': '退货退款中',
'10': '已收货',
'11': '退款退货审核'
}
const order_statsu_d = {
const cOrder_status = {
'os0_osd1': {
text: '待接单',
},
'os1_osd11': {
text: '待付款',
},
'os1_osd12': {
text: '待付款(已支付定金)',
},
'os6_osd61': {
text: '待发货',
},
'os7_osd71': {
text: '待收货',
},
'os10_osd101': {
text: '已收货',
},
'os11_osd111': {
text: '待发货退款审核',
},
'os11_osd112': {
text: '待收货退款审核',
},
'os11_osd113': {
text: '已收货退款审核',
},
'os11_osd114': {
text: '待收货退货审核',
},
'os11_osd115': {
text: '已收货退货审核',
},
'os11_osd116': {
text: '待收货退款退货审核',
},
'os11_osd117': {
text: '已收货退款退货审核',
},
'os9_osd91': {
text: '退款中',
},
'os9_osd93': {
text: '退货中',
},
'os9_osd92': {
text: '退货退款中',
},
'os5_osd53': {
text: '交易完成',
},
//2是关闭,osd(order_status_d) 看文档吧,2全部关闭
'os2_osd28': {
text: '交易关闭'
},
'os2_osd29': {
text: '交易关闭',
},
'os2_osd21': {
text: '交易关闭'
},
'os2_osd23': {
text: '交易关闭',
},
'os2_osd26': {
text: '交易关闭'
},
'os2_osd211': {
text: '交易关闭',
},
'os2_osd22': {
text: '交易关闭'
},
'os2_osd25': {
text: '交易关闭',
},
'os2_osd27': {
text: '交易关闭',
},
'os2_osd212': {
text: '交易关闭',
},
'os2_osd213': {
text: '交易关闭'
},
'os2_osd214': {
text: '交易关闭',
},
'os2_osd215': {
text: '交易关闭'
},
'os2_osd216': {
text: '交易关闭',
},
'os2_osd217': {
text: '交易关闭',
},
}
const order_mixin = {
filters: {
cOrderStatus(key) {
return cOrder_status[key].text || ''
}
},
methods: {
// 立即支付
orderPay() {
console.log('立即支付')
},
methods: {
// 取消订单
async orderCancel(order_sn, cb) {
try{
const { status, data } = await remindOrder(order_sn)
const { status, data } = await cancelOrder(order_sn)
if(status) {
cb && isFunction(cb) && cb()
this.$toast({title: '订单取消成功'})
......@@ -40,9 +129,9 @@ const order_mixin = {
},
// 提醒发货
async orderRemind() {
async orderRemind(order_sn, order_id, cb) {
try{
const { status, data } = await cancelDetail1(order_sn)
const { status, data } = await remindOrder({order_sn, order_id})
if(status) {
cb && isFunction(cb) && cb()
this.$toast({title: '提醒成功'})
......@@ -51,29 +140,86 @@ const order_mixin = {
this.$toast({title: '提醒失败'})
//TODO handle the exception
}
console.log('提醒发货')
},
// 撤销退款退货申请
async orderRefundAll () {
// 申请退款
async applyBack(order_sn, type, cb) {
try{
const { status, data } = await applyBack({order_sn, apply_type: type})
if(status) {
cb && isFunction(cb) && cb()
this.$toast({title: '申请成功'})
}
}catch(e){
this.$toast({title: '撤销失败'})
console.log(e)
this.$toast({title: '申请失败'})
//TODO handle the exception
}
console.log('撤销退款退货申请')
},
// 撤销退款申请
async orderRefund() {
// 支付
async orderPay(order_sn) {
await createOrder({
order_sn
})
},
// 撤销
async orderUndo(order_sn, type, cb) {
try{
const { status, data } = await undoOrder({order_sn, cancel_type: type})
if(status) {
cb && isFunction(cb) && cb()
this.$toast({title: '申请成功'})
}
}catch(e){
console.log(e)
this.$toast({title: e.msg || '申请失败'})
//TODO handle the exception
}
},
// 确认收货
async orderRecieve(order_sn, cb) {
try{
const { status, data } = await recieveOrder(order_sn)
if(status) {
cb && isFunction(cb) && cb()
this.$toast({title: '收货成功'})
}
}catch(e){
console.log(e)
this.$toast({title: e.msg || '申请失败'})
//TODO handle the exception
}
},
// 签收退款
async orderRefund(order_sn, cb) {
try{
const { status, data } = await recieveOrderRefund(order_sn)
if(status) {
cb && isFunction(cb) && cb()
this.$toast({title: '签收成功'})
}
}catch(e){
this.$toast({title:e.msg || '签收失败'})
//TODO handle the exception
}
},
// 签收退款
async orderAddRefund(order_sn, cb) {
try{
const { status, data } = await addRefundTime(order_sn)
if(status) {
cb && isFunction(cb) && cb()
this.$toast({title: '操作成功'})
}
}catch(e){
this.$toast({title: '撤销失败'})
this.$toast({title: e.msg || '操作失败'})
//TODO handle the exception
}
console.log('撤销退款申请')
}
}
}
......
......@@ -9,12 +9,17 @@
<template v-else>
<template v-if="!token">
<empty-view
iconSrc="/static/images/common/icon-empty.png"
text="啥都没有,快去逛逛吧~"
/>
<view class="login-btn" @click="handleLogin">登录</view>
<view
class="w-100 flex flex-column j-center a-center"
style="height: 100vh;"
>
<empty-view
iconSrc="/static/images/common/icon-empty.png"
text="啥都没有,快去逛逛吧~"
/>
<view class="login-btn" @click="handleLogin">登录</view>
</view>
</template>
<template v-else>
<template v-if="cartList.length === 0">
......@@ -323,6 +328,7 @@ export default {
<style lang="scss" scoped>
.wrap {
width: 100%;
min-height: 100vh;
.login-btn {
width: 520rpx;
height: 72rpx;
......
......@@ -157,7 +157,8 @@ export default {
computed: {
...mapState({
token: state => state.user.token,
isOverdue: state => state.user.isOverdue
isOverdue: state => state.user.isOverdue,
storeInfo: state => state.user.storeInfo
})
},
async created() {
......@@ -169,6 +170,11 @@ export default {
this.setCount()
}
},
onShareAppMessage() {
return {
title: this.storeInfo.shop_name || ''
}
},
methods: {
...mapActions('cart', ['setCount']),
async getCate() {
......
......@@ -190,7 +190,8 @@ export default {
computed: {
...mapState({
cart_count: state => state.cart.cart_count
cart_count: state => state.cart.cart_count,
storeInfo: state => state.user.storeInfo
}),
logisticsTab() {
......@@ -216,7 +217,14 @@ export default {
},
},
onShareAppMessage() {
const goods_thumb = this.detail.goods_thumb
const goods_name = this.detail.goods_name
return {
title: goods_name || '',
image: goods_thumb ? `${this.baseUrl}/${goods_thumb}` : ''
}
},
methods: {
// 富文本预览事件
preview(src, e) {
......
<template>
<view>
<!-- 店铺信息 -->
<view class="storeInfo-wrap w-100 flex j-start a-center">
<navigator
url="/subPages/storeInfo/index"
hover-class="none"
class="storeInfo-wrap w-100 flex j-start a-center"
>
<view class="logo">
<image
v-if="storeInfo.shop_img"
......@@ -15,8 +19,7 @@
<view class="intro-deatil font-24">简介: {{storeInfo.shop_intro || ''}}</view>
</view>
</view>
</navigator>
<view class="w-100">
<view class="menu pb-4 mb-1 w-100 flex j-around a-center flex-nowrap">
......@@ -252,7 +255,7 @@ export default {
onShareAppMessage() {
return {
title: this.storeInfo.shop_name
title: this.storeInfo.shop_name || ''
}
},
......
......@@ -36,8 +36,10 @@
/>
</view>
<view class="clearfix">
<view v-if="form.lgtype === 3" class="forget font-24 py-1" @click="handleForget">忘记密码</view>
<view
class="forget text-right font-24 flex j-end"
>
<text v-if="form.lgtype === 3" @click="handleForget">忘记密码</text>
</view>
<view
......@@ -117,6 +119,11 @@ export default {
return userPlachelderStr[this.form.lgtype]
}
},
onShareAppMessage() {
return {
title: this.storeInfo.shop_name || ''
}
},
methods: {
...common,
...mapActions('user', ['login']),
......@@ -223,8 +230,8 @@ export default {
}
}
.forget {
display: inline-block;
float: right;
height: 64rpx;
line-height: 74rpx;
color: $primary;
}
.login-btn {
......
<template>
<view class="order-info">
<slot name="total"></slot>
<!-- 2是交易关闭,5是交易完成,订单都已经结束,不展示按钮 -->
<view class="w-100 flex j-end a-center" v-if="!['0', '2', '5'].includes(item.order_status)">
<template v-if="item.order_status === '1'">
<slot name="time"></slot>
<view v-if="item.order_status_d === '11'" class="btn ml-2 pay" @click.stop="handlePay(item.order_sn, index)">待支付</view>
<view class="btn ml-2 cancle" @click.stop="handleCancle(item.order_sn, index)">取消订单</view>
</template>
<template v-else-if="item.order_status === '6'">
<view class="btn ml-2 cancle" @click.stop="handleBackMoney(item.order_sn, 1, index)">申请退款</view>
<view class="btn ml-2 pay" @click.stop="handleRemind(item.order_sn, item.order_id, index)">提醒发货</view>
</template>
<template v-else-if="item.order_status === '7'">
<view class="btn ml-2 cancle" @click.stop="handleBackMoney(item.order_sn, item.order_status_d === '71' ? 2 : 1, index)">申请退款</view>
<view class="btn ml-2 pay" @click.stop="handleRecieve(item.order_sn)">确认收货</view>
</template>
<template v-else-if="item.order_status === '11'">
<view
class="btn ml-2 cancle"
v-if="item.order_status_d === '111'"
@click.stop="handleUndo(item.order_sn, 1, index)"
>撤销退款申请</view>
<view
class="btn ml-2 cancle"
v-if="item.order_status_d === '112'"
@click.stop="handleUndo(item.order_sn, 1, index)"
>撤销退款申请</view>
<view
class="btn ml-2 cancle"
v-if="item.order_status_d === '113'"
@click.stop="handleUndo(item.order_sn, 1, index)"
>撤销退款申请</view>
<view
class="btn ml-2 cancle"
v-if="item.order_status_d === '114'"
@click.stop="handleUndo(item.order_sn, 4, index)"
>撤销退货申请</view>
<view
class="btn ml-2 cancle"
v-if="item.order_status_d === '115'"
@click.stop="handleUndo(item.order_sn, 4, index)"
>撤销退货申请</view>
<view
class="btn ml-2 cancle"
v-if="item.order_status_d === '116'"
@click.stop="handleUndo(item.order_sn, 2, index)"
>撤销退款退货申请</view>
<view
class="btn ml-2 cancle"
v-if="item.order_status_d === '117'"
@click.stop="handleUndo(item.order_sn, 2, index)"
>撤销退款退货申请</view>
</template>
<template v-else-if="item.order_status === '9'">
<view class="btn ml-2 cancle" @click.stop="handleAddRefund(item.order_sn)">延长收款时间</view>
<view class="btn ml-2 pay" @click.stop="handleRefundMoney(item.order_sn)">签收退款</view>
</template>
<template v-else-if="item.order_status === '10'">
<view class="btn ml-2 cancle" @click.stop="handleApplyRefund(item)">申请售后</view>
</template>
</view>
</view>
</template>
<script>
import order_mixin from '@/mixins/order_operation.js'
export default {
props: {
item: {
type: Object,
required: true
}
},
mixins: [order_mixin],
methods: {
timerEnd(e) {
const { index } = e
const tab_list = this.tab_list
const current_tab = this.current_tab
this.$set(tab_list[current_tab].data[index], 'countdownT', 0)
},
// 取消订单
handleCancle(orderSn, idx) {
this.$modal({
content: '您确定取消该订单吗?',
cb: () => {
this.orderCancel(orderSn, this.init)
}
})
},
// 提醒发货
async handleRemind(orderSn, orderId, idx) {
uni.showLoading()
await this.orderRemind(orderSn, orderId)
uni.hideLoading()
},
// 申请退款
handleBackMoney(orderSn, type, idx) {
this.$modal({
content: '您确定退款吗?',
cb: () => {
this.applyBack(orderSn, type, this.init)
}
})
},
// 支付
handlePay(orderSn, idx) {
this.orderPay(orderSn, this.init)
},
// 撤销
handleUndo(orderSn, type, idx) {
const cancle_type = {
1: {
text: '退款',
nextCode: '91'
},
2: {
text: '退货退款',
nextCode: '92'
},
3: {
text: '取消订单',
nextCode: '0' // ?、?
},
4: {
text: '退货',
nextCode: '93'
}
}
this.$modal({
content: `您确定撤销${cancle_type[type].text}吗?`,
cb: () => {
this.orderUndo(orderSn, type, this.init)
}
})
},
// 确认收货
handleRecieve(orderSn) {
this.$modal({
content: '您确定收货吗?',
cb: () => {
this.orderRecieve(orderSn, this.init)
}
})
},
handleRefundMoney(orderSn) {
this.$modal({
content: '您确定签收退款吗?',
cb: () => {
this.orderRefund(orderSn, this.init)
}
})
},
handleAddRefund(orderSn) {
this.$modal({
content: '您确定签收退款吗?',
cb: () => {
this.orderAddRefund(orderSn, this.init)
}
})
},
// 已收货申请售后
handleApplyRefund(item) {
uni.navigateTo({
url: '/subPages/afterSales/apply',
success: res => {
res.eventChannel.emit('acceptDataFromOpenerPage', item)
}
})
},
init() {
this.$emit('changeData')
}
}
}
</script>
<style lang="scss" scoped>
.order-info {
@include borderBox(20rpx, 30rpx);
.primary {
color: $primary;
}
.btn {
@include borderBox(16rpx, 34rpx);
border-radius: 8rpx;
}
.cancle {
border: 1rpx solid $line;
background-color: #fff;
}
.pay {
color: #fff;
background-color: $primary;
}
}
</style>
......@@ -13,7 +13,8 @@
>卖家自提或找物流</view>
</view>
<view class="address" v-show="current_tab === 1">
<!-- v-show="current_tab === 1" -->
<view class="address">
<view
v-if="orderDetail.address.length === 0"
class="font-32 font-bold"
......@@ -69,7 +70,7 @@
<view class="mb-2">单价:{{sku.cart_price + '/' + sku.unit}}</view>
<view class="flex j-between a-center">
<text>数量:{{sku.cart_number}}</text>
<text><text class="primaryColor">{{sku.is_inquiry === '1' ? '待确认' : sku.cart_subtotal}}</text></text>
<text><text class="primaryColor">{{sku.is_inquiry === '1' ? '待确认' : sku.cart_subtotal}}</text></text>
</view>
</view>
</block>
......@@ -161,11 +162,13 @@
<script>
import { preConfirmOrderData, confirmOrder } from '@/apis/order.js'
import { makePhoneCall, wxPay } from '@/utils/common.js'
import { makePhoneCall } from '@/utils/common.js'
import { baseUrl } from '@/config/index.js'
import Validator from '@/utils/validate.js'
import createOrder from '@/utils/modules/pay.js'
import { mapState } from 'vuex'
let params = null
export default {
data() {
return {
......@@ -192,12 +195,17 @@ export default {
this.form = Object.assign(this.form, params)
},
computed: {
...mapState({
openid: state => state.user.openid
})
},
onShow() {
if(params) {
this.getPreOrderData(params)
}
},
methods: {
......@@ -218,6 +226,7 @@ export default {
if(status) {
this.orderDetail = data
// 如果有默认地址,那么默认选中地址,如果没有默认地址,那么就选择第一个为选中地址
// find可能会在ios系统低版本出问题
const defaultAddress = data.address.find(item => item.is_default === '1')
const select_address = defaultAddress ? defaultAddress : data.address[0]
this.form.address_id = select_address.address_id || ''
......@@ -237,21 +246,80 @@ export default {
const form = this.form
const valiteErr = this.valiteForm()
if(valiteErr) return this.$toast({title: valiteErr})
const list = this.orderDetail.shop.cartList2
for(let i = 0, j = list.length; i < j; i ++) {
if(list[i].is_inquiry === '1') {
return this.confirm2Order(form, () => {
uni.redirectTo({
url: '/pages/order/order-list'
})
const good_list = this.orderDetail.shop.cartList2
for(let i = 0, j = good_list.length; i < j; i ++) {
if(good_list[i].is_inquiry === '1') {
return this.$modal({
title: '提示',
content: '订单包含询价商品,需商户确认下单,是否继续下单?',
cb: () => {
this.confirm2Order(form, () => {
uni.redirectTo({
url: '/pages/order/order-list'
})
})
}
})
}
} else {
console.log(good_list[i].list)
for(let h = 0, k = good_list[i].list.length; h < k; h ++) {
if(good_list[i].list[h].need_check === '1') {
return this.$modal({
title: '提示',
content: '订单包含需要审核商品,需商户确认下单,是否继续下单?',
success: () => {
this.confirm2Order(form, () => {
uni.redirectTo({
url: '/pages/order/order-list'
})
})
}
})
} else if(good_list[i].list[h].inventory === 0) {
return this.$modal({
title: '提示',
content: '订单包含缺货商品,需商户确认下单,是否继续下单?',
cb: () => {
this.confirm2Order(form, () => {
uni.redirectTo({
url: '/pages/order/order-list'
})
})
}
})
} else {
return this.confirm2Order(form, async order_sn => {
console.log('==============================')
console.log(order_sn)
if(!order_sn) return this.$toast({title: '下单失败,订单编号不能未空'})
createOrder({
order_sn,
successCb: () => uni.redirectTo({
url: `/subPages/pay_status/index?pay_status=true&order_sn=${order_sn}`
}),
failCb: () => uni.redirectTo({
url: `/subPages/pay_status/index?pay_status=false&order_sn=${order_sn}`
})
})
// const { status, data } = await pay({order_sn, openid: this.openid})
// if(status) {
// wxPay({
// params: data,
// successCb: () => uni.redirectTo({
// url: `/subPages/pay_status/index?pay_status=true&order_sn=${order_sn}`
// }),
// failCb: () => uni.redirectTo({
// url: `/subPages/pay_status/index?pay_status=false&order_sn=${order_sn}`
// })
// })
// }
})
}
}
}
}
this.confirm2Order(form, () => {
wxPay({params: {}, })
})
}catch(e){
console.log(e)
this.$toast({title: e.msg || '程序错误,订单提交失败'})
......@@ -262,9 +330,10 @@ export default {
valiteForm() {
const formValidator = new Validator()
const form = this.form
if(form.shipping_type === 1) {
formValidator.add(form.address_id, [{strategy: 'notEmpty', errorMsg: '请完善地址信息'}])
}
// if(form.shipping_type === 1) {
// formValidator.add(form.address_id, [{strategy: 'notEmpty', errorMsg: '请完善地址信息'}])
// }
formValidator.add(form.address_id, [{strategy: 'notEmpty', errorMsg: '请完善地址信息'}])
if(form.buy_type === 0) { // 购物车进去
formValidator.add(form.cart_ids, [{strategy: 'notEmpty', errorMsg: '购物车id不能为空'}])
} else if(form.buy_type === 1){
......@@ -281,7 +350,6 @@ export default {
// 选择弹窗的地址
handleAddressItem(item) {
console.log(item)
this.select_address = item
this.form.address_id = item.address_id
this.$refs.popup.close()
......@@ -296,7 +364,11 @@ export default {
try{
const { status, data } = await confirmOrder(form)
if(status) {
cb && typeof cb === 'function' && cb()
cb && typeof cb === 'function' && cb(data.order_sn)
console.log(data)
// const a = await pay({order_sn: data.order_sn, openid: this.openid})
// console.log(a)
// wxPay({params: a.data, })
}
}catch(e){
console.log(e)
......
......@@ -77,14 +77,27 @@
</view>
</view>
<view class="btn-wrap mt-2 flex j-end a-center">
<view class="btn cancle">111111</view>
<view class="mt-2 flex j-end a-center">
<order-btn :item="order_detail.order" @changeData='changeData'>
<countdown-t
slot="time"
v-if="order_detail.order.goods_before_pay === '0' && order_detail.order.countdownT > 0"
:countdownNum="order_detail.order.countdownT"
:pauseTimer="pauseTimer"
:params="{
index
}"
@timerEnd="timerEnd"
/>
</order-btn>
</view>
</view>
</template>
<script>
import orderBtn from './components/order-btn.vue'
import countdownT from './components/countdownT.vue'
import { orderDetail } from '@/apis/order.js'
import { makePhoneCall } from '@/utils/common.js'
import { baseUrl } from '@/config/index.js'
......@@ -113,6 +126,11 @@ export default {
}
},
components: {
countdownT,
orderBtn
},
onLoad(ops) {
order_sn = ops.order_sn
this.getDetail()
......@@ -127,12 +145,23 @@ export default {
methods: {
makePhoneCall,
changeData() {
this.getDetail()
},
async getDetail() {
try{
if(!order_sn) return
const { status, data } = await orderDetail(order_sn)
if(status) {
if(data.order.order_status === '1') {
// item.pay_endTime = item.confirm_time === '0' ? 0 : ~~item.confirm_time + 3600
data.order.countdownT = ~~data.order.confirm_time + 3600 - data.order.confirm_time
// item.last_payTime = ''
} else {
data.order.countdownT = 0
// item.last_payTime = ''
}
this.order_detail = {
goods: data.goods2 || [],
order: data.order || {},
......@@ -216,9 +245,7 @@ export default {
.btn-wrap {
box-sizing: border-box;
padding: 0 30rpx;
width: 100%;
height: 88rpx;
background-color: #fff;
.btn {
@include borderBox(16rpx, 34rpx);
......
<template>
<view class="w-100 order-wrap">
<!-- tabBar -->
<scroll-view class="tab-wrap w-100" scroll-x>
<scroll-view
class="tab-wrap w-100"
scroll-x
:scroll-into-view="'s'+current_tab"
scroll-with-animation
>
<view
class="tab-item mx-3"
class="tab-item mx-3"
:id="'s'+ index"
v-for="(item, index) in tab_list"
:key="index"
:class="current_tab === index ? 'tab_active' : ''"
......@@ -30,9 +36,13 @@
:key="item.order_sn"
>
<view class="w-100 item-inner">
<view>orderStatus=={{item.order_status}}————orderStatusD=={{item.order_status_d}}</view>
<view>{{item.order_sn}}</view>
<view class="flex j-between a-center">
<text class="order-item">{{item.add_time | parseTime}}</text>
<text class="order-status">{{item.order_status | orderStatus(item.goods_before_pay)}}</text>
<!-- <text class="order-status">{{item.order_status | orderStatus(item.goods_before_pay)}}</text> -->
<text v-if="item.goods_before_pay === '1' && item.order_statsu === 1"></text>
<text v-else class="order-status">{{'os' + item.order_status + '_osd' + item.order_status_d | cOrderStatus}}</text>
</view>
<view
class="w-100 mb-2"
......@@ -57,44 +67,24 @@
</view>
</view>
<view class="order-info">
<view class="w-100 flex j-end a-center mb-2">
<order-btn :item="item" @changeData='changeData'>
<view class="w-100 flex j-end a-center mb-2" slot="total">
<text class="mr-2"><text class="primary">{{item.sum_counts}}</text></text>
<text class="primary">{{item.sum_amount}}</text>
</view>
<!-- 2是交易关闭,5是交易完成,订单都已经结束,不展示按钮 -->
<view class="w-100 flex j-end a-center" v-if="!['0', '2', '5'].includes(item.order_status)">
<template v-if="item.order_status === '0'">
<countdown-t
v-if="item.goods_before_pay === '0' && item.countdownT > 0"
:countdownNum="item.countdownT"
:pauseTimer="pauseTimer"
:params="{
index
}"
@timerEnd="timerEnd"
/>
<view class="btn ml-2 cancle" @click.stop="handleCancel(item.order_sn, index)">取消订单</view>
</template>
<template v-else-if="item.order_status === '6'">
<view class="btn ml-2 cancle">申请退款</view>
<view class="btn ml-2 pay">提醒发货</view>
</template>
<template v-else-if="item.order_status === '7'">
<view class="btn ml-2 cancle">申请退款</view>
<view class="btn ml-2 pay">确认收货</view>
</template>
<template v-else-if="item.order_status === '9'">
<view class="btn ml-2 cancle">撤销退款申请</view>
</template>
<template v-else-if="item.order_status === '10'">
<view class="btn ml-2 cancle">申请售后</view>
</template>
<template v-else-if="item.order_status === '11'">
<view class="btn ml-2 cancle">撤销退货退款申请</view>
</template>
</view>
</view>
<countdown-t
slot="time"
v-if="item.goods_before_pay === '0' && item.countdownT > 0"
:countdownNum="item.countdownT"
:pauseTimer="pauseTimer"
:params="{
index
}"
@timerEnd="timerEnd"
/>
</order-btn>
</navigator>
</template>
</pull-list>
......@@ -105,6 +95,7 @@
<script>
import pullList from '@/components/pull-list/index.vue'
import countdownT from './components/countdownT.vue'
import orderBtn from './components/order-btn.vue'
import LoadMore from '@/utils/load-more.js'
import { baseUrl } from '@/config/index.js'
......@@ -116,20 +107,7 @@ const formParams = {
}
let timer = null
let serviceTime = 0
const order_statsu = {
'0': '待接单',
'1': '待付款',
'2': '交易关闭',
'5': '交易完成',
'6': '待发货',
'7': '待收货',
'9': '退货退款中',
'10': '已收货',
'11': '退款退货审核'
}
const order_statsu_d = {
}
export default {
data() {
return {
......@@ -174,21 +152,12 @@ export default {
},
components: {
pullList,
countdownT
countdownT,
orderBtn
},
created() {
this.loadMore = new LoadMore()
},
filters: {
// goods_before_pay 是否为先货后款:0否 1是
orderStatus(status, goods_before_pay) {
if(goods_before_pay === '1' && status === '1') {
return null
}
return order_statsu[status]
}
},
mixins: [order_mixin],
onLoad(options) {
console.log(options)
......@@ -222,9 +191,14 @@ export default {
if(status && data) {
// 计算总数
data.forEach(item => {
item.pay_endTime = item.confirm_time === '0' ? 0 : ~~item.confirm_time + 3600
item.countdownT = ~~item.confirm_time + 3600 - time
item.last_payTime = ''
if(item.order_status === '1') {
// item.pay_endTime = item.confirm_time === '0' ? 0 : ~~item.confirm_time + 3600
item.countdownT = ~~item.confirm_time + 3600 - time
// item.last_payTime = ''
} else {
item.countdownT = 0
// item.last_payTime = ''
}
item.sum_counts = item.goods.reduce((pre, cur) => { return pre + ~~cur.cart_number}, 0)
})
serviceTime = time
......@@ -233,6 +207,10 @@ export default {
}
},
changeData() {
this.init()
},
timerEnd(e) {
const { index } = e
const tab_list = this.tab_list
......@@ -240,20 +218,103 @@ export default {
this.$set(tab_list[current_tab].data[index], 'countdownT', 0)
},
// 取消订单
handleCancel(orderSn, idx) {
console.log(orderSn, idx)
this.$modal({
content: '您确定取消该订单吗?',
cb: () => {
this.orderCancel(orderSn, () => {
const tab_idx = this.current_tab
this.$set(this.tab_list[tab_idx].data[idx], 'order_status', '2')
this.$set(this.tab_list[tab_idx].data[idx], 'order_status_d', '29')
})
}
})
},
// // 取消订单
// handleCancle(orderSn, idx) {
// this.$modal({
// content: '您确定取消该订单吗?',
// cb: () => {
// this.orderCancel(orderSn, this.init)
// }
// })
// },
// // 提醒发货
// async handleRemind(orderSn, orderId, idx) {
// uni.showLoading()
// await this.orderRemind(orderSn, orderId)
// uni.hideLoading()
// },
// // 申请退款
// handleBackMoney(orderSn, type, idx) {
// this.$modal({
// content: '您确定退款吗?',
// cb: () => {
// this.applyBack(orderSn, type, this.init)
// }
// })
// },
// // 支付
// handlePay(orderSn, idx) {
// this.orderPay(orderSn, this.init)
// },
// // 撤销
// handleUndo(orderSn, type, idx) {
// const cancle_type = {
// 1: {
// text: '退款',
// nextCode: '91'
// },
// 2: {
// text: '退货退款',
// nextCode: '92'
// },
// 3: {
// text: '取消订单',
// nextCode: '0' // ?、?
// },
// 4: {
// text: '退货',
// nextCode: '93'
// }
// }
// this.$modal({
// content: `您确定撤销${cancle_type[type].text}吗?`,
// cb: () => {
// this.orderUndo(orderSn, type, this.init)
// }
// })
// },
// // 确认收货
// handleRecieve(orderSn) {
// this.$modal({
// content: '您确定收货吗?',
// cb: () => {
// this.orderRecieve(orderSn, this.init)
// }
// })
// },
// handleRefundMoney(orderSn) {
// this.$modal({
// content: '您确定签收退款吗?',
// cb: () => {
// this.orderRefund(orderSn, this.init)
// }
// })
// },
// handleAddRefund(orderSn) {
// this.$modal({
// content: '您确定签收退款吗?',
// cb: () => {
// this.orderAddRefund(orderSn, this.init)
// }
// })
// },
// // 已收货申请售后
// handleApplyRefund(item) {
// uni.navigateTo({
// url: '/subPages/afterSales/apply',
// success: res => {
// res.eventChannel.emit('acceptDataFromOpenerPage', item)
// }
// })
// },
// 下拉刷新
refresh(e) {
......
......@@ -12,11 +12,18 @@
confirm-type="search"
@confirm="search"
/>
<view
v-show="inputFocus"
class="cancleInput clear-btn"
@click="clearInput"
/>
<view class="cancleInput flex j-center a-center">
<view
v-show="val.length"
@click="clearInput"
>
<image
style="width: 34rpx;height: 34rpx;"
src="/static/images/common/icon-clear.png"
mode="aspectFit"
/>
</view>
</view>
<image
class="search-icon"
src="/static/images/common/icon-search.png"
......@@ -29,9 +36,14 @@
<!-- history -->
<view class="history-wrap w-100">
<view class="font-32 flex j-between w-100 font-bold py-2">
<view class="font-28 flex j-between a-center w-100 py-2">
<view class="title">历史记录</view>
<view class="del-btn" @click="clearHistory">删除</view>
<image
class="del-btn"
src="/static/images/common/icon-del.png"
mode="aspectFit"
@click="clearHistory"
/>
</view>
<view class="w-100 flex j-start a-center flex-wrap">
<view
......@@ -52,7 +64,6 @@ let cacheHistory = []
export default {
data() {
return {
inputFocus: false,
val: '',
list: [], // 在页面显示的历史
}
......@@ -118,7 +129,6 @@ export default {
</script>
<style lang="scss" scoped>
@import "./common/clear.css";
.search-bar {
position: relative;
@include borderBox(20rpx, 40rpx);
......@@ -166,7 +176,8 @@ export default {
color: $desc;
}
.del-btn {
color: $daner;
width: 30rpx;
height: 30rpx;
}
.history-item {
padding: 12rpx 20rpx;
......
......@@ -16,7 +16,19 @@
src="/static/images/common/icon-search.png"
mode="aspectFit"
/>
<view class="clearBtn clear-btn " @click.stop="clearInput" />
<view class="clearBtn flex a-center j-center">
<view
v-show="searchParams.keywords.length"
@click.stop="clearInput"
>
<image
style="width: 34rpx;height: 34rpx;"
src="/static/images/common/icon-clear.png"
mode="aspectFit"
/>
</view>
</view>
</view>
<image
class="nav-cart"
......@@ -277,7 +289,6 @@ export default {
width: 654rpx;
height: 88rpx;
border-radius: 8rpx;
background-color: yellow;
.input {
width: 500rpx;
padding-left: 70rpx;
......@@ -301,7 +312,7 @@ export default {
transform: translateY(-50%);
width: 88rpx;
height: 88rpx;
line-height: 88rpx;
background-color: $mainBg;
text-align: center;
}
}
......
......@@ -29,13 +29,13 @@
+ 2021/6/29,本日起的代码可能会引起不适,but all can run(效率和质量不会成正比关系)
#### 未完成
+ 下单
+ 支付
+ 订单管理
+ 订单详情
+ 购物车
+ 弹窗异步问题
+ 精度处理
#### unFinish, but not important
+ 自定义的导航栏的样式计算可以在vuex中处理(wxs计算)
+ 详情有个深拷贝的问题。暂时通过JSON.stringify()处理
+ 所有的价格都是通过toFixed会可能出现精度问题。一般发现不了
+ 确认订单页面要跳到地址列表页面选择
\ No newline at end of file
<template>
<view class="wrapper">
<goods-box />
<goods-box :goods="detail" />
<navigator
<view
class="mt-2 w-100 nav-box"
hover-class="none"
url="/subPages/afterSales/detail"
@click="nav(1)"
>
<view class="font-28 font-bold mb-2">我要退款(无需退货)</view>
<view class="font-24 desc">没有收到货物或与卖家协商同意不退货只退款</view>
</navigator>
<view class="font-24 desc">与卖家协商同意不退货只退款</view>
</view>
<navigator class="mt-2 w-100 nav-box">
<view class="font-28 font-bold mb-2">我要退款(无需退货)</view>
<view class="font-24 desc">没已收到货物需要退换收到的货物</view>
</navigator>
<view
class="mt-2 w-100 nav-box"
@click="nav(2)"
>
<view class="font-28 font-bold mb-2">我要退款退货</view>
<view class="font-24 desc">已收到货物,需退还收到的货物</view>
</view>
</view>
</template>
<script>
import goodsBox from './components/goods-box.vue'
export default {
data() {
return {
detail: {}
}
},
components: {
goodsBox
},
onLoad(ops) {
const eventChannel = this.getOpenerEventChannel()
eventChannel.on('acceptDataFromOpenerPage', data => {
this.detail = data
})
},
methods: {
nav(apply_type) {
uni.navigateTo({
url: '/subPages/afterSales/detail',
success: res => {
res.eventChannel.emit('acceptDataFromOpenerPage', {
apply_type,
data: this.detail
})
}
})
}
}
}
</script>
......
<template>
<view class="w-100 mt-2 goods-box">
<view class="flex j-start a-center">
<image
class="cover"
src="/static/images/common/bg.png"
mode="aspectFit"
/>
<view class="introduct flex j-between flex-column">
<view class="title">444</view>
<view class="desc">规格:444</view>
<viwe class="primaryColor">¥f444</viwe>
<template v-if="goods.goods">
<view class="flex j-start a-center" v-for="(item, index) in goods.goods" :key="index">
<image
class="cover"
:src="baseUrl + '/' + item.goods_thumb"
mode="aspectFit"
/>
<view class="introduct flex j-between flex-column">
<view class="title">{{item.goods_name}}</view>
<view class="desc">规格:{{item.specification}}</view>
<viwe class="primaryColor">{{item.goods_price}}</viwe>
</view>
</view>
</view>
</template>
<view class="w-100 flex j-end a-center">
<text class="mr-2"><text class="primaryColor">3</text></text>
<text >合计:<text class="primaryColor">222</text></text>
<text class="mr-2"><text class="primaryColor">{{goods.sum_counts || 0}}</text></text>
<text >合计:<text class="primaryColor">{{goods.sum_amount || 0}}</text></text>
</view>
</view>
</template>
<script>
import { baseUrl } from '@/config/index.js'
export default {
data() {
return {
baseUrl
}
},
props: {
goods: {
type: Object,
required: true
}
}
}
</script>
<style lang="scss" scoped>
......
<template>
<view class="wrap">
<goods-box />
<goods-box :goods="detail" />
<view class="price-box w-100 flex j-between a-center mt-2">
<text>退款金额</text>
<text class="primaryColor">33333333</text>
<text class="primaryColor">{{detail.sum_amount}}</text>
</view>
<view class="submit-btn">提交</view>
<view class="submit-btn" @click="submit">提交</view>
</view>
</template>
<script>
import { applyBack } from '@/apis/order.js'
import goodsBox from './components/goods-box.vue'
export default {
data() {
return {
detail: {},
form: {}
}
},
components: {
goodsBox
},
onLoad() {
const eventChannel = this.getOpenerEventChannel()
eventChannel.on('acceptDataFromOpenerPage', data => {
console.log(data)
this.detail = data.data
this.form = {
apply_type: data.apply_type,
order_sn: data.data.order_sn
}
})
},
methods: {
submit() {
applyBack(this.form)
.then(() => {
this.$toast({title: '申请成功', cb: () => uni.navigateBack()})
})
.catch(() => this.$toast({title: '申请失败'}))
}
}
}
</script>
......
<template>
<view class="wrapper flex flex-column j-start a-center">
<view
class="bg"
:class="pay_success ? 'success' : 'fail'"
<image
class="bg"
:class="pay_status ? 'success' : 'fail'"
/>
<text
class="text-center font-36"
:class="pay_success ? 'primaryColor' : 'descColor'"
>{{pay_success ? '支付成功' : '支付失败'}}</text>
<view class="nav-btn primaryColor">查看订单详情</view>
:class="pay_status ? 'primaryColor' : 'descColor'"
>{{pay_status ? '支付成功' : '支付失败'}}</text>
<navigator
open-type="redirect"
hover-class="none"
class="nav-btn primaryColor"
:url="'/pages/order/order-detail?order_sn=' + order_sn"
>查看订单详情</navigator>
</view>
</template>
......@@ -16,10 +21,16 @@
export default {
data() {
return {
pay_success: true,// 支付成功状态
order_id: null
pay_status: true,// 支付成功状态
order_sn: null
}
}
},
onLoad(ops) {
const { pay_status, order_sn } = ops
if(!order_sn) return this.$toast({title: '订单号不能未空', cb: () => uni.navigateBack()})
this.pay_status = pay_status === 'true' ? true : false
this.order_sn = order_sn
},
}
</script>
......
......@@ -50,7 +50,7 @@
import { mapState } from 'vuex'
import { baseUrl } from '@/config/index.js'
import dayjs from 'dayjs'
const weeks = {
let weeks = {
1: '周一',
2: '周二',
3: '周三',
......@@ -70,15 +70,21 @@ export default {
storeInfo: state => state.user.storeInfo
}),
startT() {
return weeks[this.storeInfo.business_week_start]
return weeks[this.storeInfo.business_week_start] || ''
},
endT() {
return weeks[this.storeInfo.business_week_end]
return weeks[this.storeInfo.business_week_end] || ''
},
createTime() {
return dayjs(this.storeInfo.add_time * 1000).format('YYYY-MM-DD')
return dayjs(this.storeInfo.add_time * 1000).format('YYYY-MM-DD') || ''
}
}
},
onShareAppMessage() {
const storeInfo = this.storeInfo
return {
title: storeInfo.shop_name || ''
}
},
}
</script>
......
......@@ -70,7 +70,6 @@ export function debounce(func, wait = 1000, immediate = true) {
}
}
/**
* 联系老板
*/
......@@ -90,44 +89,3 @@ export function makePhoneCall() {
})
}
}
/**
* @微信支付
* @param { Functiom } successCb 成功回调函数
* @param { Functiom } failCb 失败回调函数
* @param { Object } params 支付参数
*
timeStamp: '',
nonceStr: '',
package: '',
signType: 'RSA',
paySign: '',
*/
export function wxPay({
params,
successCb,
failCb
}) {
console.log(params, successCb,
failCb)
wx.requestPayment({
// provider: 'wxpay',
...Object.assign(params, {
signType: 'RSA'
}),
success: res => {
// do
successCb && isFunction(successCb) && successCb()
},
fail: err => {
console.log(err)
Toast({
title: err.errMsg || '支付失败',
cb: () => {
failCb && isFunction(failCb) && failCb()
}
})
}
})
}
\ No newline at end of file
import { pay } from '@/apis/common.js'
import store from '@/store/index.js'
import Toast from '@/lib/toast/index.js'
import { isFunction } from "@/utils/types.js"
/**
* @desc 生成订单(后端调用统一下单),返回拉起支付的参数
* @param { String } order_sn 订单编号 (此订单编号是我们后台生成的订单编号)
* @param { Function } successCb
* @param { Function } failCb
*/
export default async function createOrder({ order_sn, successCb, failCb
}) {
try{
const openid = store.state.user.openid
if(!openid || !order_sn) return
const { status, data } = await pay({order_sn, openid })
if(status) {
return wxPay({
params: data,
successCb,
failCb
})
}
}catch(e){
console.log(e)
Toast({title: e.msg || '支付失败'})
}
}
/**
* @微信支付
* @param { Functiom } successCb 成功回调函数
* @param { Functiom } failCb 失败回调函数
* @param { Object } params 支付参数
*
timeStamp: '',
nonceStr: '',
package: '',
signType: 'RSA',
paySign: '',
*/
function wxPay({
params,
successCb,
failCb
}) {
wx.requestPayment({
// provider: 'wxpay',
...Object.assign(params, {
signType: 'RSA'
}),
success: res => {
// do
console.log(res)
successCb && isFunction(successCb) && successCb()
},
fail: err => {
console.log(err)
failCb && isFunction(failCb) && failCb()
}
})
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment