合并代码

This commit is contained in:
sx 2025-01-19 22:56:45 +08:00
parent d56e2e6666
commit 5f802e60ac
9 changed files with 386 additions and 235 deletions

View File

@ -292,6 +292,19 @@ const shop = {
}) })
}, },
/**
* 获取用户订单列表
* @param {Object} param
*/
getOrderList(param) {
return util.request({
url: `/shopify/appOrder/getOrderList`,
query: param.query,
method: 'GET',
load: true,
})
},
/** /**
* 获取订单详情 * 获取订单详情
* @param {Object} param * @param {Object} param
@ -304,6 +317,33 @@ const shop = {
load: true, load: true,
}) })
}, },
/**
* 订单支付
* @param {Object} param
*/
orderPay(param) {
return util.request({
url: `/shopify/appOrder/payOrder`,
query: param.query,
data: param.data,
method: 'POST',
load: true,
})
},
/**
* 订单取消
* @param {Object} param
*/
orderCancel(param) {
return util.request({
url: `/shopify/appOrder/cancelOrder`,
query: param.query,
method: 'PUT',
load: true,
})
},
} }
export default shop export default shop

View File

@ -8,16 +8,17 @@ const config = {
host: 'https://539c1514.r24.cpolar.top', host: 'https://539c1514.r24.cpolar.top',
// host: 'http://gfjds5.natappfree.cc', // host: 'http://gfjds5.natappfree.cc',
// #endif // #endif
// 上传文件二级路径 // 支付方式配置
uploadFilePath: "/homecommon/file/preview?fileName=", payType: {
// 上传视频二级路径 score: {
uploadVideoPath: '/homecommon/file/play?fileName=', name: '积分',
// 图片大小 单位m img: '/static/images/pay/wechat.png',
img_size: 5, },
// 视频限制大小 单位m balance: {
video_size: 300, name: '余额',
// h5路径 img: '/static/images/pay/wechat.png',
h5: '', },
},
// 腾讯im聊天 // 腾讯im聊天
TChat: { TChat: {
// appid // appid

34
jiuyi2/common/js/order.js Normal file
View File

@ -0,0 +1,34 @@
// 工具库
import util from '@/common/js/util.js'
// api
import api from '@/api/index.js'
const order = {
/**
* 订单支付
* @param {Object} event 事件对象
*/
orderPay: (event) => {
return new Promise((resolve, reject) => {
api.shop.orderPay({
query: {
...event.query,
},
data: [
event.orderId,
],
}).then(rs => {
if (res.code == 200) {
resolve(res.data)
return
}
util.alert({
content: res.msg,
showCancel: false,
})
})
})
}
}
export default order

View File

@ -8,7 +8,8 @@
computed, computed,
watch, watch,
onMounted, onMounted,
onUnmounted onUnmounted,
defineEmits,
} from 'vue' } from 'vue'
const props = defineProps({ const props = defineProps({
@ -21,6 +22,8 @@
default: () => ({}) default: () => ({})
} }
}) })
//
const emit = defineEmits(['update:address'])
onMounted(() => { onMounted(() => {
// //
@ -36,7 +39,8 @@
function addListener() { function addListener() {
// //
uni.$on('selectAddress', (event) => { uni.$on('selectAddress', (event) => {
emit('update:value', event.target.value); console.log('selectAddress', event)
emit('update:address', event);
}) })
} }
@ -74,7 +78,7 @@
</view> </view>
<!-- 选择地址 --> <!-- 选择地址 -->
<view v-if="shopEdit" class="btn ti warmHollow plr20 ml20" @click="link('/pages/mine/address/index')"> <view v-if="shopEdit" class="btn ti warmHollow plr20 ml20" @click="link('/pages/mine/address/index?select=1')">
<text class="cFF9B27">选择地址</text> <text class="cFF9B27">选择地址</text>
</view> </view>
</view> </view>

View File

@ -33,10 +33,8 @@
<view class="header line rows ptb20 f28"> <view class="header line rows ptb20 f28">
<!-- 店铺 --> <!-- 店铺 -->
<view class="store df aic thd f1" v-if="mode == 'mine'"> <view class="store df aic thd f1" v-if="mode == 'mine'">
<image class="wh50 br10" <image class="wh50 br10" :src="item.merImg" mode="aspectFill" />
src="https://img13.360buyimg.com/n1/jfs/t1/117234/35/34799/82687/6449f2b4Fd6e2eef9/a754c5e178c9e9be.jpg.avif" <view class="name ml10 c333">{{item.merName}}</view>
mode="aspectFill" />
<view class="name ml10 c333">家纺专营店</view>
</view> </view>
<!-- 购买用户 --> <!-- 购买用户 -->
<view class="store df aic thd f1" v-else-if="mode == 'shop'"> <view class="store df aic thd f1" v-else-if="mode == 'shop'">
@ -53,24 +51,22 @@
<!-- 商品信息 --> <!-- 商品信息 -->
<view class="product line df ptb20"> <view class="product line df ptb20">
<view class="poster wh160"> <view class="poster wh160">
<image class="wh160 br10" <image class="wh160 br10" :src="item.productImage" mode="aspectFill" />
src="https://img13.360buyimg.com/n1/jfs/t1/117234/35/34799/82687/6449f2b4Fd6e2eef9/a754c5e178c9e9be.jpg.avif"
mode="aspectFill" />
</view> </view>
<!-- 产品名称 购买的规格 --> <!-- 产品名称 购买的规格 -->
<view class="info mlr20 f1"> <view class="info mlr20 f1">
<view class="name c333 f28">靠枕 纯棉靠枕 车载居家 纯棉100% 卡通靠枕 人体工学</view> <view class="name t2hd c333 f28">{{item.productName}}</view>
<view class="spec mt10 c999 f26">款式普通款 小熊</view> <view class="spec mt10 thd c999 f26">款式{{item.sku}}</view>
</view> </view>
<!-- 单价 数量 --> <!-- 单价 数量 -->
<view class="tar"> <view class="tar">
<view class="price c666"> <view class="price c666">
<text class="f20"></text> <text class="f20"></text>
<text class="f26">89</text> <text class="f26">{{item.productPrice}}</text>
</view> </view>
<view class="number f24 c999">x 1</view> <view class="number f24 c999">x {{item.totalNum}}</view>
</view> </view>
</view> </view>
@ -80,7 +76,7 @@
<text v-if="mode == 'mine'">应付</text> <text v-if="mode == 'mine'">应付</text>
<text v-else-if="mode == 'shop'">实收</text> <text v-else-if="mode == 'shop'">实收</text>
<text class="cFF9B27 f20"></text> <text class="cFF9B27 f20"></text>
<text class="cFF9B27">89</text> <text class="cFF9B27">{{item.totalPrice}}</text>
</view> </view>
</view> </view>

View File

@ -1,113 +0,0 @@
const menu = {
// '1 待付款'
// '2 待发货'
// '3 待收货'
// '4 待评价'
// '5 售后/退款'
// '6 已完成'
// '7 已取消'
//
user: [{
name: '取消订单',
type: 'black',
value: 'cancel_order',
status: [2]
},
{
name: '继续付款',
type: 'orange',
value: 'continue_paying',
status: [2]
},
{
name: '申请退款',
type: 'black',
value: 'refund',
status: [3, 4, 5]
},
{
name: '崔发货',
type: 'orange',
status: [3]
},
{
name: '查看物流',
type: 'black',
status: [4]
}, {
name: '确认收货',
type: 'orange',
status: [4]
}, {
name: '评价',
type: 'orange',
status: [5]
}, {
name: '删除记录',
type: 'black',
status: [6]
}, {
name: '售后详情',
type: 'black',
status: [6]
}, {
name: '钱款去向',
type: 'black',
value: 'money_whereabouts',
status: [6]
}, {
name: '平台介入',
type: 'orange',
status: [6]
}
],
shop: [{
name: '改价',
type: 'orange',
value: 'change_price',
status: [2]
}, {
name: '发货',
type: 'orange',
value: 'delivery',
status: [3]
}, {
name: '拒绝退款',
type: 'black',
value: 'refund_refund',
status: [5]
}, {
name: '同意退款',
type: 'black',
value: 'agree_refund',
status: [5]
}, {
name: '联系用户',
type: 'orange',
value: 'contact_users',
status: [5]
}],
manage: [{
name: '上架',
type: 'black',
value: 'grounding',
status: [1]
}, {
name: '下架',
type: 'black',
value: 'discontinue',
status: [1]
}, {
name: '编辑',
type: 'orange',
value: 'edit',
status: [1]
}]
}
export default {
// 功能菜单
menu,
}

View File

@ -1,6 +1,8 @@
<script setup> <script setup>
import { import {
ref, ref,
reactive,
getCurrentInstance,
} from 'vue' } from 'vue'
import { import {
onReachBottom, onReachBottom,
@ -19,36 +21,53 @@
import api from '@/api/index.js' import api from '@/api/index.js'
// util // util
import util from '@/common/js/util'; import util from '@/common/js/util';
//
import order from '@/common/js/order.js'
//
import secondPwd from '@/components/mine/payPwd.vue'
const {
proxy
} = getCurrentInstance()
// id // id
const orderId = ref('') const orderId = ref('')
// //
const paytype = ref('1') const paytype = ref('')
//
const detail = reactive({
createTime: '',
coutDownTime: '',
orderDetailList: [],
})
// //
// const paytypeList = reactive([])
const paytypeList = [{ //
name: '微信支付', const date = reactive(new Date())
value: '1',
icon: '/static/shop-weixin-pay.png'
},
{
name: '支付宝支付',
value: '2',
icon: '/static/shop-alipay-payment.png'
},
{
name: '余额支付',
value: '3',
icon: '/static/shop-apply-pay.png'
}
]
onLoad((option) => { onLoad((option) => {
if (option.orderId) orderId.value = option.orderId if (option.orderId) orderId.value = option.orderId
//
getPaymentOrder()
// //
getDetail() getDetail()
}) })
//
function getPaymentOrder() {
api.mine.getPaymentOrder({}).then(res => {
if (res.code == 200) {
Object.assign(paytypeList, res.data.map(item => {
item.name = util.config.payType[item.paymentMethod].name
return item
}))
return
}
util.alert({
content: res.msg,
showCancel: false,
})
})
}
// //
function getDetail() { function getDetail() {
api.shop.getOrderDetail({ api.shop.getOrderDetail({
@ -57,19 +76,95 @@
} }
}).then(res => { }).then(res => {
if (res.code == 200) { if (res.code == 200) {
const result = res.data
let time = new Date(result.createTime)
// //
} else { result.createTime = new Date(result.createTime).valueOf()
uni.showToast({ result.coutDownTime = time.setMinutes(time.getMinutes() + 30).valueOf()
title: res.msg, //
icon: 'none' if (date.valueOf() < result.coutDownTime) {
}) let timeDiff = timeDifference(new Date(), result.coutDownTime)
result.hours = timeDiff.hours
result.minutes = timeDiff.minutes
result.seconds = timeDiff.seconds
}
Object.assign(detail, {}, result)
return
} }
util.alert({
content: res.msg,
showCancel: false,
})
}) })
} }
/**
* 相差时间
* @param {Object} startTimeStr 开始时间
* @param {Object} endTimeStr 结束时间
*/
function timeDifference(startTimeStr, endTimeStr) {
// Date
let startDate = new Date(startTimeStr);
let endDate = new Date(endTimeStr);
//
let timeDiff = endDate - startDate;
//
let hours = Math.floor(timeDiff / (1000 * 60 * 60));
let minutes = Math.floor((timeDiff % (1000 * 60 * 60)) / (1000 * 60));
let seconds = Math.floor((timeDiff % (1000 * 60)) / 1000);
return {
hours,
minutes,
seconds
}
}
// //
function handlePayment(ev) { function handlePayment(ev) {
// let value = ev.detail.value
if (value == paytype.value) return
paytype.value = value
}
//
function handleSubmit() {
api.shop.orderPay({
query: {
payType: paytype.value,
addrId: detail.address.id,
},
data: [
orderId.value,
],
}).then(res => {
if (res.code == 200) {
//
uni.$off('updateOrderList')
uni.$off('updateOrderDetail')
uni.navigateBack()
return
}
util.alert({
content: res.msg,
showCancel: false,
})
})
}
//
function showPwd() {
if (!paytype.value) {
util.alert('请选择支付方式')
return
}
//
proxy.$refs.secondPwd.open()
} }
</script> </script>
@ -77,94 +172,90 @@
<view class="app"> <view class="app">
<view class="bfff p25"> <view class="bfff p25">
<!-- 地址 --> <!-- 地址 -->
<JyCommodityAddress></JyCommodityAddress> <JyCommodityAddress v-model:address="detail.address" />
</view> </view>
<!-- 店铺和商家信息 --> <!-- 店铺和商家信息 -->
<view class="detail oh mtb20 plr30 bfff"> <view class="detail oh mtb20 plr30 bfff">
<!-- 店铺 --> <!-- 店铺 -->
<view class="store mtb20 plr10 df aic"> <view class="store mtb20 plr10 df aic">
<image class="avaar wh60 cir" src="/static/qq.png" mode="aspectFill" /> <image class="avaar wh60 br10" :src="detail.merImg" mode="aspectFill" />
<view class="name ml10 c333 f28">店铺名称</view> <view class="name ml20 c333 f28">{{detail.merName}}</view>
</view> </view>
<!-- 商品信息 --> <!-- 商品信息 -->
<view class="goods mtb20 plr10 df"> <view class="goods mtb20 plr10 df" v-for="(item,index) in detail.orderDetailList">
<!-- 产品图 --> <!-- 产品图 -->
<image class="wh180 br10" <image class="wh180 br10" :src="item.productInfo.sliderImage.split(',')[0]" mode="aspectFill" />
src="https://img13.360buyimg.com/n1/jfs/t1/117234/35/34799/82687/6449f2b4Fd6e2eef9/a754c5e178c9e9be.jpg.avif"
mode="aspectFill"></image>
<!-- 产品信息 --> <!-- 产品信息 -->
<view class="f1 mlr10"> <view class="f1 ml20 mr10">
<view class="name f30">靠枕 纯棉靠枕 车载居家 纯棉100% 卡通靠枕 人体工学</view> <view class="name f30 t2hd">{{item.productName}}</view>
<view class="spec mt10 c999 f26">升级款 小熊</view> <view class="spec mt10 c999 f26">升级款 {{item.sku}}</view>
</view> </view>
<!-- 其他 --> <!-- 其他 -->
<view class=" tar"> <view class="tar">
<view class="price"> <view class="price">
<text class="f20"></text> <text class="f20"></text>
<text class="f30">5.48</text> <text class="f30">{{item.price}}</text>
</view> </view>
<view class="c999 f28">x1</view> <view class="c999 f28">x{{item.payNum}}</view>
</view> </view>
</view> </view>
<!-- 积分抵扣 -->
<view class="line df jcr aic ptb20 plr10">
<text class="c333 f28">积分抵扣</text>
<text class="price f20 cFF9B27">-</text>
<text class="price f32 cFF9B27">5.00</text>
</view>
<!-- 应付 --> <!-- 应付 -->
<view class="line df jcr aic ptb20 plr10"> <view class="line df jcr aic ptb20 plr10">
<text class="c333 f28">应付</text> <text class="c333 f28">应付</text>
<text class="price f20 cFF9B27"></text> <text class="price f20 cFF9B27"></text>
<text class="price f32 cFF9B27">5.00</text> <text class="price f32 cFF9B27">{{detail.totalPrice}}</text>
</view> </view>
</view> </view>
<!-- 支付方式选择 --> <!-- 支付方式选择 -->
<radio-group class="payType mtb20 plr20 bfff" @change="handlePayment"> <radio-group class="payType mtb20 plr20 bfff" @change="handlePayment">
<label class="item rows ptb20 plr10" v-for="(item, index) in paytypeList" :key="item.value"> <label class="item rows ptb20 plr10" v-for="(item, index) in paytypeList" :key="item.paymentMethod">
<image :src="item.icon" class="wh60" mode="aspectFit" /> <image :src="item.icon" class="wh60" mode="aspectFit" />
<view class="f1 mlr20 c333 f28">{{item.name}}</view> <view class="f1 mlr20 c333 f28">{{item.name}}</view>
<radio class="radio" color="#4cd964" :value="item.value" :checked="item.value === paytype" /> <radio class="radio" color="#4cd964" :value="item.paymentMethod"
</label> :checked="item.paymentMethod === paytype" />
<label class="item rows ptb20 plr10">
<image src="/static/shop-bank-payment.png" class="wh60" mode="aspectFit" />
<view class="f1 mlr20 c333 f28">添加银行卡</view>
<uni-icons type="right" />
</label> </label>
</radio-group> </radio-group>
<!-- 订单备注 --> <!-- 订单备注 -->
<view class="remark mtb20 ptb20 plr20 bfff"> <view class="remark mtb20 ptb20 plr20 bfff" v-if="0">
<view class="title f30">订单备注</view> <view class="title f30">订单备注</view>
<view class="txtarea mt10"> <view class="txtarea mt10">
<uni-easyinput :inputBorder="false" type="textarea" placeholder="选填" /> <uni-easyinput :inputBorder="false" type="textarea" placeholder="选填" />
</view> </view>
</view> </view>
<view class="fill" style="height: 210rpx;"></view> <view class="fill" style="height: 210rpx;" />
<!-- 提交订单 --> <!-- 提交订单 -->
<view class="footer df jcr plr20 bfff"> <view class="footer df jcr plr20 bfff" v-if="detail.id">
<view class="df aic"> <view class="df aic">
<text class="c333 f28">应付</text> <text class="c333 f28">应付</text>
<text class="price f20 cFF9B27"></text> <text class="price f20 cFF9B27"></text>
<text class="price f36 cFF9B27">5.48</text> <text class="price f36 cFF9B27">{{detail.totalPrice}}</text>
</view> </view>
<view class="btn ti primary ml20 plr60"> <template v-if="date.valueOf() < detail.coutDownTime">
<text class="cfff f24">继续付款</text> <view class="btn ti primary ml20 plr60" @click="showPwd">
<view class="df cfff aic f20"> <text class="cfff f24">继续付款</text>
<text class="">剩余</text> <view class="df cfff aic f20">
<uni-countdown splitorColor="#fff" color="#fff" :show-day="false" :hour="12" :minute="12" <text class="">剩余</text>
:second="12" /> <uni-countdown splitorColor="#fff" color="#fff" :show-day="false" :hour="detail.hours"
:minute="detail.minutes" :second="detail.seconds" @timeup="getDetail" />
</view>
</view> </view>
</view> </template>
<template v-else>
<view class="btn disabled ml20 plr60">订单已过期</view>
</template>
</view> </view>
</view> </view>
<!-- 二级密码 -->
<secondPwd ref="secondPwd" :check="true" @confirm="handleSubmit" />
</template> </template>
<style lang="scss" scoped> <style lang="scss" scoped>

View File

@ -6,6 +6,9 @@
} from 'vue' } from 'vue'
import { import {
onLoad, onLoad,
onUnload,
onReachBottom,
onPullDownRefresh,
onPageScroll onPageScroll
} from '@dcloudio/uni-app'; } from '@dcloudio/uni-app';
// //
@ -17,71 +20,129 @@
import orderItem from '@/components/shop/order/item.vue'; import orderItem from '@/components/shop/order/item.vue';
// //
import util from '@/common/js/util'; import util from '@/common/js/util';
// api
import api from '@/api/index.js';
// tabs // tabs
const tabs = reactive([{ const tabs = reactive([{
id: '', id: '',
name: '全部' name: '全部'
}, },
{ {
id: 2, id: 0,
name: '待付款' name: '待付款'
}, },
{ {
id: 3, id: 1,
name: '待发货' name: '待发货'
}, },
{ {
id: 4, id: 4,
name: '收货' name: '收货'
}, },
{ {
id: 5, id: 5,
name: '待评价' name: '待收货'
}, { },
{
id: 6, id: 6,
name: '售后/退款' name: '已完成'
}, {
id: 9,
name: '已取消'
} }
]) ])
//
const list = reactive({
data: [{
status: 1,
status_text: '待付款',
}, {
status: 2,
status_text: '待发货',
}, {
status: 3,
status_text: '待收货',
}, {
status: 4,
status_text: '已完成',
}, {
status: 5,
status_text: '已取消',
}, {
status: 6,
status_text: '售后中',
}],
})
// //
const params = reactive({ const params = reactive({
currentTab: 0, currentTab: 0,
search: '' search: ''
}) })
//
const list = reactive({
data: [],
pageSize: 10,
pageNum: 1,
total: 0,
})
// //
const apexBgColor = ref('#ffffff00') const apexBgColor = ref('#ffffff00')
onLoad((options) => { onLoad((options) => {
// this.params.currentTab = options.currentTab / 1 // this.params.currentTab = options.currentTab / 1
//
getList()
//
addListener()
})
onUnload(() => {
//
removeListener()
}) })
onPageScroll((ev) => { onPageScroll((ev) => {
apexBgColor.value = ev.scrollTop > 44 ? '#fff' : '#ffffff00' apexBgColor.value = ev.scrollTop > 44 ? '#fff' : '#ffffff00'
}) })
onReachBottom(() => {
//
getMoreList()
})
onPullDownRefresh(() => {
//
refreshList()
})
//
function addListener() {
uni.$on('updateOrderList', (data) => {
//
refreshList()
})
}
//
function removeListener() {
uni.$off('updateOrderList')
}
//
function refreshList() {
list.pageNum = 1
getList()
}
//
function getMoreList() {
if (listlist.data.length >= list.total) return
list.pageNum++
getList()
}
//
function getList() {
api.shop.getOrderList({
query: {
pageNum: list.pageNum,
pageSize: list.pageSize,
},
}).then(res => {
if (res.code == 200) {
if (list.pageNum == 1) list.data.length = 0
list.data.push(...res.rows.map(item => {
item.status = Number(item.status)
return item
}))
list.total = res.total
return
}
util.alert({
content: rs.msg,
showCancel: false
})
})
}
/** /**
* 点击订单列表项 * 点击订单列表项
* @param {Object} ev 订单列表项 * @param {Object} ev 订单列表项
@ -91,6 +152,27 @@
url: util.setUrl('/pages/shop/order/detail') url: util.setUrl('/pages/shop/order/detail')
}) })
} }
/**
* 点击tab
* @param {Object} ev
*/
function itemClick(ev) {
//
refreshList()
}
/**
* 支付
* @param {Object} item 订单
*/
function handlePay(item) {
uni.navigateTo({
url: util.setUrl('/pages/shop/commodity/payment', {
orderId: item.id,
})
})
}
</script> </script>
<template> <template>
@ -118,12 +200,13 @@
<view class="mtb30"> <view class="mtb30">
<orderItem :item="item" mode="mine" @item="handleItem"> <orderItem :item="item" mode="mine" @item="handleItem">
<template #menu="scope"> <template #menu="scope">
<view class="menu ptb20 df jcr" v-if="[1,2,3,4,6].includes(scope.item.status)"> <view class="menu ptb20 df jcr" v-if="[0,1,4,5,6].includes(scope.item.status)">
<template v-if="scope.item.status == 1"> <template v-if="scope.item.status == 0">
<view class="btn bar closeHollow plr30">取消订单</view> <view class="btn bar closeHollow plr30">取消订单</view>
<view class="btn bar warmHollow plr30">继续付款</view> <view class="btn bar warmHollow plr30" @click.stop="handlePay(scope.item)">继续付款
</view>
</template> </template>
<template v-if="scope.item.status == 2"> <template v-if="scope.item.status == 1">
<view class="btn bar closeHollow plr30">申请退款</view> <view class="btn bar closeHollow plr30">申请退款</view>
<view class="btn bar warmHollow plr30">催发货</view> <view class="btn bar warmHollow plr30">催发货</view>
</template> </template>

View File

@ -60,6 +60,9 @@ collectsVideo 收藏夹视频端
commentVideo 视频评论 commentVideo 视频评论
deleteVideo 删除视频 deleteVideo 删除视频
selectAddress 选择地址 selectAddress 选择地址
updateOrderList 更新订单列表
updateOrderDetail 更新订单详情
缓存 缓存
--- ---
@ -374,3 +377,15 @@ likeType
7 商家和用户进行交流 7 商家和用户进行交流
用户订单状态
订单状态
0待支付
1待发货
4待收货
5已收货
6已完成
9已取消
1737292587952
1737378810000