第一次提交

This commit is contained in:
gxwebsoft
2023-08-04 13:04:21 +08:00
commit 7a73b38bd5
764 changed files with 166417 additions and 0 deletions

566
pages/order/comment/index.vue Executable file
View File

@@ -0,0 +1,566 @@
<template>
<view v-if="!isLoading" class="container" :style="appThemeStyle">
<view class="goods-list">
<view class="goods-item" v-for="(item, index) in goodsList" :key="index">
<!-- 商品详情 -->
<view class="goods-main">
<!-- 商品图片 -->
<view class="goods-image">
<image class="image" :src="item.goodsImage" mode="scaleToFill"></image>
</view>
<!-- 商品信息 -->
<view class="goods-content">
<view class="goods-title"><text class="twoline-hide">{{ item.goodsName }}</text></view>
<view class="goods-props clearfix">
<view class="goods-props-item" v-for="(props, idx) in item.goodsProps" :key="idx">
<text>{{ props.value.name }}</text>
</view>
</view>
</view>
<!-- 交易信息 -->
<view class="goods-trade">
<view class="goods-price">
<text class="unit"></text>
<text class="value">{{ item.goodsPrice }}</text>
</view>
<view class="goods-num">
<text>×{{ item.totalNum }}</text>
</view>
</view>
</view>
<!-- 选择评价 -->
<view class="score-row">
<view class="score-item score-praise" :class="{ active: formData[index].score == 10 }" @click="setScore(index, 10)">
<view class="score">
<text class="score-icon iconfont icon-haoping"></text>
<text class="score-text">好评</text>
</view>
</view>
<view class="score-item score-review" :class="{ active: formData[index].score == 20 }" @click="setScore(index, 20)">
<view class="score">
<text class="score-icon iconfont icon-zhongping"></text>
<text class="score-text">中评</text>
</view>
</view>
<view class="score-item score-negative" :class="{ active: formData[index].score == 30 }" @click="setScore(index, 30)">
<view class="score">
<text class="score-icon iconfont icon-chaping"></text>
<text class="score-text">差评</text>
</view>
</view>
</view>
<!-- 评价内容 -->
<view class="form-content">
<textarea class="textarea" v-model="formData[index].content" maxlength="500" placeholder="请输入评价内容 (留空则不评价)"></textarea>
</view>
<!-- 图片列表 -->
<view class="image-list">
<view class="image-preview" v-for="(image, imageIndex) in formData[index].imageList" :key="imageIndex">
<text class="image-delete iconfont icon-shanchu" @click="deleteImage(index, imageIndex)"></text>
<image class="image" mode="aspectFill" :src="image.path"></image>
</view>
<view v-if="!formData[index].imageList || formData[index].imageList.length < maxImageLength" class="image-picker"
@click="chooseImage(index)">
<text class="choose-icon iconfont icon-camera"></text>
<text class="choose-text">上传图片</text>
</view>
</view>
</view>
</view>
<!-- 底部操作按钮 -->
<view class="footer-fixed">
<view class="btn-wrapper">
<view class="btn-item btn-item-main" :class="{ disabled }" @click="handleSubmit()">确认提交</view>
</view>
</view>
</view>
</template>
<script>
import * as UploadApi from '@/api/upload'
import * as OrderCommentApi from '@/api/order/comment'
const maxImageLength = 6
export default {
data() {
return {
// 正在加载
isLoading: true,
// 当前订单ID
orderId: null,
// 待评价商品列表
goodsList: [],
// 表单数据
formData: [],
// 最大图片数量
maxImageLength,
// 按钮禁用
disabled: false
}
},
/**
* 生命周期函数--监听页面加载
*/
onLoad({ orderId }) {
this.orderId = orderId
// 获取待评价商品列表
// this.getGoodsList()
},
methods: {
// 获取待评价商品列表
getGoodsList() {
const app = this
app.isLoading = true
OrderCommentApi.list(app.orderId)
.then(result => {
app.goodsList = result.data.goodsList
app.initFormData()
app.isLoading = false
})
},
// 初始化form数据
initFormData() {
const { goodsList } = this
const formData = goodsList.map(item => {
return {
goods_id: item.goods_id,
order_goods_id: item.order_goods_id,
score: 10,
content: '',
imageList: [],
uploaded: []
}
})
this.formData = formData
},
// 设置评分
setScore(index, score) {
this.formData[index].score = score
},
// 选择图片
chooseImage(index) {
const app = this
const oldImageList = app.formData[index].imageList
// 选择图片
uni.chooseImage({
count: maxImageLength - oldImageList.length,
sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图,默认二者都有
sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有
success({ tempFiles }) {
// tempFiles = [{path:'xxx', size:100}]
app.formData[index].imageList = oldImageList.concat(tempFiles)
}
});
},
// 删除图片
deleteImage(index, imageIndex) {
this.formData[index].imageList.splice(imageIndex, 1)
},
// 表单提交
handleSubmit() {
const app = this
// 判断是否重复提交
if (app.disabled === true) return false
// 按钮禁用
app.disabled = true
// 判断是否需要上传图片
const imagesLength = app.getImagesLength()
if (imagesLength > 0) {
app.uploadFile()
.then(() => {
console.log('then')
app.onSubmit()
})
.catch(err => {
console.log('catch')
app.disabled = false
if (err.statusCode !== 0) {
app.$toast(err.errMsg)
}
console.log('err', err)
})
} else {
app.onSubmit()
}
},
// 统计图片数量
getImagesLength() {
const { formData } = this
let imagesLength = 0
formData.forEach(item => {
if (item.content.trim()) {
imagesLength += item.imageList.length
}
})
return imagesLength
},
// 提交到后端
onSubmit() {
const app = this
OrderCommentApi.submit(app.orderId, app.formData)
.then(result => {
app.$toast(result.message)
setTimeout(() => {
app.disabled = false
uni.navigateBack()
}, 1500)
})
.catch(err => app.disabled = false)
},
// 上传图片
uploadFile() {
const app = this
const { formData } = app
// 整理上传文件路径
const files = []
formData.forEach((item, index) => {
if (item.content.trim() && item.imageList.length) {
const images = item.imageList.map(image => image)
files.push({ formDataIndex: index, images })
}
})
// 批量上传
return new Promise((resolve, reject) => {
Promise.all(files.map((file, index) => {
return new Promise((resolve, reject) => {
UploadApi.image(file.images)
.then(fileIds => {
app.formData[index].uploaded = fileIds
resolve(fileIds)
})
.catch(reject)
})
}))
.then(resolve, reject)
})
}
}
}
</script>
<style lang="scss" scoped>
.container {
// 设置ios刘海屏底部横线安全区域
padding-bottom: calc(constant(safe-area-inset-bottom) + 140rpx);
padding-bottom: calc(env(safe-area-inset-bottom) + 140rpx);
}
.goods-list {
font-size: 28rpx;
padding-top: 30rpx;
}
.goods-item {
width: 94%;
background: #fff;
padding: 24rpx 24rpx;
box-shadow: 0 1rpx 5rpx 0px rgba(0, 0, 0, 0.05);
margin: 0 auto 30rpx auto;
border-radius: 20rpx;
.goods-detail {
padding: 24rpx 20rpx;
.left {
.goods-image {
display: block;
width: 150rpx;
height: 150rpx;
}
}
.right {
padding-left: 20rpx;
}
}
.score-row {
display: flex;
justify-content: space-around;
padding: 24rpx 20rpx;
.score-item {
display: flex;
justify-content: center;
align-items: center;
&.score-praise {
color: $main-bg;
.score-icon {
background: $main-bg;
}
}
&.score-review {
color: $vice-bg;
.score-icon {
background: $vice-bg;
}
}
&.score-negative {
color: #9b9b9b;
.score-icon {
background: #9b9b9b;
}
}
.score {
padding: 10rpx 20rpx 10rpx 10rpx;
border-radius: 30rpx;
.score-icon {
margin-right: 10rpx;
padding: 10rpx;
border-radius: 50%;
font-size: 30rpx;
color: #fff;
}
}
&.active {
.score {
color: #fff;
}
&.score-praise {
.score {
background: $main-bg;
}
}
&.score-review {
.score {
background: $vice-bg;
}
}
&.score-negative {
.score {
background: #9b9b9b;
}
}
}
}
}
// 评价内容
.form-content {
padding: 14rpx 10rpx;
.textarea {
width: 100%;
height: 220rpx;
padding: 12rpx;
border: 1rpx solid #e8e8e8;
border-radius: 5rpx;
box-sizing: border-box;
font-size: 26rpx;
}
}
.image-list {
padding: 0 20rpx;
margin-top: 20rpx;
margin-bottom: -20rpx;
&:after {
clear: both;
content: " ";
display: table;
}
.image {
display: block;
width: 100%;
height: 100%;
}
.image-picker,
.image-preview {
width: 184rpx;
height: 184rpx;
margin-right: 30rpx;
margin-bottom: 30rpx;
float: left;
&:nth-child(3n+0) {
margin-right: 0;
}
}
.image-picker {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
border: 1rpx dashed #ccc;
color: #ccc;
.choose-icon {
font-size: 48rpx;
margin-bottom: 6rpx;
}
.choose-text {
font-size: 24rpx;
}
}
.image-preview {
position: relative;
.image-delete {
position: absolute;
top: -15rpx;
right: -15rpx;
height: 42rpx;
width: 42rpx;
background: rgba(0, 0, 0, 0.64);
border-radius: 50%;
color: #fff;
font-weight: bolder;
font-size: 22rpx;
z-index: 10;
display: flex;
justify-content: center;
align-items: center;
}
}
}
}
// 商品项
.goods-main {
display: flex;
margin-bottom: 20rpx;
// 商品图片
.goods-image {
width: 180rpx;
height: 180rpx;
.image {
display: block;
width: 100%;
height: 100%;
border-radius: 8rpx;
}
}
// 商品内容
.goods-content {
flex: 1;
padding-left: 16rpx;
padding-top: 16rpx;
.goods-title {
font-size: 26rpx;
max-height: 76rpx;
}
.goods-props {
margin-top: 14rpx;
height: 40rpx;
color: #ababab;
font-size: 24rpx;
overflow: hidden;
.goods-props-item {
display: inline-block;
margin-right: 14rpx;
padding: 4rpx 16rpx;
border-radius: 12rpx;
background-color: #F5F5F5;
width: auto;
}
}
}
// 交易信息
.goods-trade {
padding-top: 16rpx;
width: 150rpx;
text-align: right;
color: $uni-text-color-grey;
font-size: 26rpx;
.goods-price {
vertical-align: bottom;
margin-bottom: 16rpx;
.unit {
margin-right: -2rpx;
font-size: 24rpx;
}
}
}
}
// 底部操作栏
.footer-fixed {
position: fixed;
bottom: var(--window-bottom);
left: 0;
right: 0;
z-index: 11;
// 设置ios刘海屏底部横线安全区域
padding-bottom: constant(safe-area-inset-bottom);
padding-bottom: env(safe-area-inset-bottom);
.btn-wrapper {
height: 140rpx;
display: flex;
align-items: center;
padding: 0 20rpx;
}
.btn-item {
flex: 1;
font-size: 28rpx;
height: 80rpx;
color: #fff;
border-radius: 50rpx;
display: flex;
justify-content: center;
align-items: center;
}
.btn-item-main {
background: linear-gradient(to right, $main-bg, $main-bg2);
color: $main-text;
// 禁用按钮
&.disabled {
opacity: 0.6;
}
}
}
</style>

323
pages/order/delivery.vue Executable file
View File

@@ -0,0 +1,323 @@
<template>
<view class="container" :style="appThemeStyle">
<view class="reject" v-if="form.apply_status == 10">
<u-alert-tips type="error" title="申请已提交:" description="请耐心等待工作人员的审核"></u-alert-tips>
</view>
<view class="reject" v-else-if="form.apply_status == 30">
<u-alert-tips type="error" title="您的申请已被驳回:" :description="form.reject_reason"></u-alert-tips>
</view>
<u-form :model="form" ref="uForm" label-width="140rpx">
<!-- 标题 -->
<view class="page-title">身份证信息</view>
<view class="form-wrapper">
<u-form-item label="正面" prop="img1">
<image :src="orderSourceData[0]" v-if="orderSourceData[0]" mode="aspectFill" style="width: 300rpx;height: 200rpx"></image>
<image src="../../static/not-dealer.png" v-else mode="aspectFill" style="width: 300rpx;height: 200rpx" @click="chooseImage(1)"></image>
</u-form-item>
<u-form-item label="反面" prop="img2">
<image :src="orderSourceData[1]" v-if="orderSourceData[1]" mode="aspectFill" style="width: 300rpx;height: 200rpx"></image>
<image src="../../static/not-dealer.png" v-else mode="aspectFill" style="width: 300rpx;height: 200rpx" @click="chooseImage(2)"></image>
</u-form-item>
</view>
<!-- 标题 -->
<view class="page-title">其他</view>
<!-- 表单组件 -->
<view class="form-wrapper">
<u-form-item label="人车合照" prop="img3">
<image :src="orderSourceData[2]" v-if="orderSourceData[2]" mode="aspectFill" style="width: 300rpx;height: 200rpx"></image>
<image src="../../static/not-dealer.png" v-else mode="aspectFill" style="width: 300rpx;height: 200rpx" @click="chooseImage(3)"></image>
</u-form-item>
<u-form-item label="车子照片" prop="img4">
<image :src="orderSourceData[3]" v-if="orderSourceData[3]" mode="aspectFill" style="width: 300rpx;height: 200rpx"></image>
<image src="../../static/not-dealer.png" v-else mode="aspectFill" style="width: 300rpx;height: 200rpx" @click="chooseImage(4)"></image>
</u-form-item>
<u-form-item label="安装照片" prop="img5">
<image :src="orderSourceData[4]" v-if="orderSourceData[4]" mode="aspectFill" style="width: 300rpx;height: 200rpx"></image>
<image src="../../static/not-dealer.png" v-else mode="aspectFill" style="width: 300rpx;height: 200rpx" @click="chooseImage(5)"></image>
</u-form-item>
</view>
</u-form>
<view class="btn">
<u-button type="primary" shape="circle" @click="handleSubmit()">
{{ submitText }}
</u-button>
</view>
<view class="btn">
<u-button shape="circle" @click="resetting">
重置
</u-button>
</view>
<view class="btn"></view>
</view>
</template>
<script>
import {
uploadFile
} from '@/websoft/api/upload.js'
import {
pageOrder,
removeOrder,
receiptOrder,
getOrder
} from '@/websoft/api/order.js'
import { fileUrl } from '@/config.js';
export default {
data() {
return {
order: {},
orderSourceData: [],
// 按钮禁用
disabled: false,
submitText: '证件已上传并确认收货',
}
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
const app = this
app.orderId = options.orderId
},
onShow() {
this.getData()
},
methods: {
// 加载订单
getData(){
const app = this
const { orderId } = this
getOrder(orderId).then(res => {
console.log("res: ",res);
app.order = res.data
if(res.data.orderSourceData.length > 0){
app.orderSourceData = JSON.parse(res.data.orderSourceData)
}
})
},
// 重置
resetting(){
const app = this
const { orderId } = app
receiptOrder({
orderId,
orderSourceData: ''
}).then(result => {
app.$success("重置成功")
app.orderSourceData = []
// 刷新订单列表
app.getData()
})
},
// 表单提交
handleSubmit() {
const app = this
this.$navTo('pages/order/index')
},
// 上传图片
chooseImage(id) {
const app = this
const { orderId } = this
const type = 'photo' + id
// 选择图片
uni.chooseImage({
count: 1,
sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图,默认二者都有
sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有
success(chooseImageRes) {
const tempFilePaths = chooseImageRes.tempFilePaths;
uploadFile({
filePath: tempFilePaths[0],
fileType: 'image',
name: 'file'
}).then(res => {
console.log("res: ", res);
app.orderSourceData.push(fileUrl + res.data.path)
receiptOrder({
orderId,
orderSourceData: JSON.stringify(app.orderSourceData)
}).then(result => {
app.$success("上传成功")
// 刷新订单列表
app.getData()
})
})
}
});
},
}
}
</script>
<style>
page {
background: #f7f8fa;
}
</style>
<style lang="scss" scoped>
.page-title {
width: 94%;
margin: 0 auto;
padding-top: 40rpx;
font-size: 28rpx;
color: rgba(69, 90, 100, 0.6);
}
.form-wrapper {
margin: 20rpx auto 20rpx auto;
padding: 0 40rpx;
width: 94%;
box-shadow: 0 1rpx 5rpx 0px rgba(0, 0, 0, 0.05);
border-radius: 16rpx;
background: #fff;
}
/* 底部操作栏 */
.footer {
margin-top: 80rpx;
.btn-wrapper {
height: 100%;
// display: flex;
// align-items: center;
padding: 0 20rpx;
}
.btn-item {
flex: 1;
font-size: 28rpx;
height: 86rpx;
color: #fff;
border-radius: 50rpx;
display: flex;
justify-content: center;
align-items: center;
}
.btn-item-wechat {
background: #0ba90b;
margin-bottom: 26rpx;
}
.btn-item-main {
background: linear-gradient(to right, $main-bg, $main-bg2);
// 禁用按钮
&.disabled {
opacity: 0.6;
}
}
}
// 上传凭证
.row-voucher {
padding: 24rpx 20rpx;
.image-list {
padding: 0 20rpx;
margin-top: 20rpx;
margin-bottom: -20rpx;
&:after {
clear: both;
content: " ";
display: table;
}
.image {
display: block;
width: 100%;
height: 100%;
}
.image-picker,
.image-preview {
width: 184rpx;
height: 184rpx;
margin-right: 30rpx;
margin-bottom: 30rpx;
float: left;
&:nth-child(3n+0) {
margin-right: 0;
}
}
.image-picker {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
border: 1rpx dashed #ccc;
color: #ccc;
.choose-icon {
font-size: 48rpx;
margin-bottom: 6rpx;
}
.choose-text {
font-size: 24rpx;
}
}
.image-preview {
position: relative;
.image-delete {
position: absolute;
top: -15rpx;
right: -15rpx;
height: 42rpx;
width: 42rpx;
background: rgba(0, 0, 0, 0.64);
border-radius: 50%;
color: #fff;
font-weight: bolder;
font-size: 22rpx;
z-index: 10;
display: flex;
justify-content: center;
align-items: center;
}
}
}
}
.form-license {
padding: 20rpx;
}
.pops-content {
padding: 20rpx;
}
.sfz,
.sfz1,
.sfz2,
.yyzz {
width: 140rpx;
padding-top: 20rpx;
padding-right: 10rpx;
}
.btn {
width: 700rpx;
margin: 20rpx auto;
height: 100rpx;
}
.reject {
width: 700rpx;
margin: 20rpx auto;
}
</style>

1577
pages/order/detail.vue Executable file

File diff suppressed because it is too large Load Diff

266
pages/order/express/index.vue Executable file
View File

@@ -0,0 +1,266 @@
<template>
<view v-if="!isLoading && express.length" class="container">
<!-- 标签栏 -->
<u-tabs v-show="tabs.length > 1" class="my-tabs" :list="tabs" :isScroll="true" :current="curTab"
:active-color="appTheme.mainBg" :duration="0.2" bar-width="60" @change="onChangeTab"></u-tabs>
<!-- 商品列表 -->
<view v-show="tabs.length > 1" class="deliver-goods-list i-card clearfix">
<view class="goods-item" v-for="(goods, idx) in express[curTab].goods" :key="idx">
<image class="goods-img" :src="goods.goods.goods_image" alt="商品图片" />
<view class="title">{{ goods.delivery_num }}</view>
</view>
</view>
<!-- 物流信息 -->
<view class="express i-card">
<view class="info-item">
<view class="item-lable">物流公司</view>
<view class="item-content">
<text v-if="express[curTab].delivery_method == 20">无需物流</text>
<text v-else>{{ express[curTab].express ? express[curTab].express.express_name : '--' }}</text>
</view>
</view>
<view class="info-item">
<view class="item-lable">物流单号</view>
<view class="item-content">
<text>{{ express[curTab].express_no ? express[curTab].express_no : '--' }}</text>
<view v-show="express[curTab].express_no" class="act-copy"
@click.stop="handleCopy(express[curTab].express_no)">
<text>复制</text>
</view>
</view>
</view>
</view>
<!-- 物流轨迹 -->
<view class="logis-detail" v-if="express[curTab].traces && express[curTab].traces.length">
<view class="logis-item" :class="{ first: index === 0 }" v-for="(item, index) in express[curTab].traces"
:key="index">
<view class="logis-item-content">
<view class="logis-item-content__describe">
<text class="f-26">{{ item.context }}</text>
</view>
<view class="logis-item-content__time">
<text class="f-22">{{ item.time }}</text>
</view>
</view>
</view>
</view>
</view>
</template>
<script>
import * as OrderApi from '@/api/order'
export default {
data() {
return {
// 正在加载
isLoading: true,
// 当前标签索引
curTab: 0,
// 当前订单ID
orderId: null,
// 物流信息
express: {}
}
},
computed: {
tabs() {
if (this.express && this.express.length) {
return this.express.map((item, index) => {
return { name: `包裹${index + 1}` }
})
}
return []
}
},
/**
* 生命周期函数--监听页面加载
*/
onLoad({ orderId }) {
this.orderId = orderId
// 获取当前订单的物流信息
this.getExpress()
},
methods: {
// 获取当前订单的物流信息
getExpress() {
const app = this
app.isLoading = true
OrderApi.express(app.orderId)
.then(result => {
app.express = result.data.express
app.isLoading = false
})
},
// 复制指定内容
handleCopy(value) {
const app = this
uni.setClipboardData({
data: value,
success() {
app.$toast('复制成功')
}
})
},
// 切换标签项
onChangeTab(index) {
this.curTab = index
},
}
}
</script>
<style lang="scss" scoped>
.my-tabs {
margin-bottom: 20rpx;
}
// 通栏卡片
.i-card {
background: #fff;
padding: 24rpx 24rpx;
}
// 物流公司
.express {
margin-bottom: 20rpx;
.info-item {
display: flex;
margin-bottom: 24rpx;
&:last-child {
margin-bottom: 0;
}
.item-lable {
display: flex;
align-items: center;
font-size: 24rpx;
color: #999;
margin-right: 6rpx;
}
.item-content {
flex: 1;
display: flex;
align-items: center;
font-size: 26rpx;
color: #333;
.act-copy {
margin-left: 20rpx;
padding: 2rpx 20rpx;
font-size: 22rpx;
color: #666;
border: 1rpx solid #c1c1c1;
border-radius: 16rpx;
}
}
}
}
// 商品列表
.deliver-goods-list {
margin-bottom: -30rpx;
.goods-item {
position: relative;
border-radius: 8rpx;
overflow: hidden;
width: 130rpx;
height: 130rpx;
float: left;
margin-right: 30rpx;
margin-bottom: 30rpx;
}
.goods-img {
display: block;
width: 100%;
height: 100%;
}
.title {
position: absolute;
bottom: 0;
width: 100%;
text-align: center;
background: rgba(0, 0, 0, 0.6);
color: #fff;
padding: 4rpx 0;
font-size: 24rpx;
}
}
// 物流轨迹
.logis-detail {
padding: 30rpx;
background-color: #fff;
.logis-item {
position: relative;
padding: 10px 0 10px 25px;
box-sizing: border-box;
border-left: 2px solid #ccc;
&.first {
border-left: 2px solid #f40;
&:after {
background: #f40;
}
.logis-item-content {
background: #ff6e39;
color: #fff;
&:after {
border-bottom-color: #ff6e39;
}
}
}
&:after {
content: ' ';
display: inline-block;
position: absolute;
left: -6px;
top: 30px;
width: 6px;
height: 6px;
border-radius: 10px;
background: #bdbdbd;
border: 2px solid #fff;
}
.logis-item-content {
position: relative;
background: #f9f9f9;
padding: 10rpx 20rpx;
box-sizing: border-box;
color: #666;
&:after {
content: '';
display: inline-block;
position: absolute;
left: -10px;
top: 18px;
border-left: 10px solid #fff;
border-bottom: 10px solid #f3f3f3;
}
}
}
}
</style>

835
pages/order/extract/check.vue Executable file
View File

@@ -0,0 +1,835 @@
<template>
<view v-if="!isLoading" class="container" :style="appThemeStyle">
<view class="header">
<!-- 订单状态 -->
<view class="order-status">
<view class="status-icon">
<!-- 进行中的订单 -->
<block v-if="order.order_status == OrderStatusEnum.NORMAL.value">
<!-- 待支付 -->
<block v-if="order.pay_status == PayStatusEnum.PENDING.value">
<image class="image" src="/static/order/status/wait_pay.png" mode="aspectFit"></image>
</block>
<!-- 待发货 -->
<block v-else-if="order.delivery_status == DeliveryStatusEnum.NOT_DELIVERED.value">
<image class="image" src="/static/order/status/wait_deliver.png" mode="aspectFit"></image>
</block>
<!-- 待收货 -->
<block v-else-if="order.receipt_status == ReceiptStatusEnum.NOT_RECEIVED.value">
<image class="image" src="/static/order/status/wait_receipt.png" mode="aspectFit"></image>
</block>
</block>
<!-- 已完成 -->
<block v-if="order.order_status == OrderStatusEnum.COMPLETED.value">
<image class="image" src="/static/order/status/received.png" mode="aspectFit"></image>
</block>
<!-- 已取消/待取消 -->
<block v-if="order.order_status == OrderStatusEnum.CANCELLED.value || order.order_status == OrderStatusEnum.APPLY_CANCEL.value">
<image class="image" src="/static/order/status/close.png" mode="aspectFit"></image>
</block>
</view>
<view class="status-text">
<text>{{ order.state_text }}</text>
</view>
</view>
</view>
<!-- 快递配送配送地址 -->
<view v-if="order.delivery_type == DeliveryTypeEnum.EXPRESS.value" class="delivery-address i-card">
<view class="link-man">
<text class="name">{{ order.address.name }}</text>
<text class="phone">{{ order.address.phone }}</text>
</view>
<view class="address">
<text class="region" v-for="(region, idx) in order.address.region" :key="idx">{{ region }}</text>
<text class="detail">{{ order.address.detail }}</text>
</view>
</view>
<!-- 快递配送门店自提 -->
<view v-if="order.delivery_type == DeliveryTypeEnum.EXTRACT.value" class="delivery-extract i-card"
@click="handleTargetExtract(order.extract_shop.shop_id)">
<view class="extract-top">
<text class="title">自提门店</text>
<text class="subtitle">您须到该自提点取货</text>
</view>
<view class="shop-info">
<view class="icon-location">
<text class="iconfont icon-dingwei"></text>
</view>
<view class="shop-content">
<view class="shop-name">
<text>{{ order.extract_shop.shop_name }}</text>
</view>
<view class="shop-describe">
<text class="item-text">{{ order.extract_shop.region.province }}</text>
<text class="item-text">{{ order.extract_shop.region.city }}</text>
<text class="item-text">{{ order.extract_shop.region.region }}</text>
<text class="item-text">{{ order.extract_shop.address }}</text>
</view>
</view>
<view class="icon-arrow">
<text class="iconfont icon-arrow-right"></text>
</view>
</view>
</view>
<!-- 物流信息 -->
<view v-if="order.delivery_type == DeliveryTypeEnum.EXPRESS.value && order.delivery_status == DeliveryStatusEnum.DELIVERED.value && order.express"
class="express i-card" @click="handleTargetExpress()">
<view class="main">
<view class="info-item">
<view class="item-lable">物流公司</view>
<view class="item-content">
<text>{{ order.express.express_name }}</text>
</view>
</view>
<view class="info-item">
<view class="item-lable">物流单号</view>
<view class="item-content">
<text>{{ order.express_no }}</text>
<view class="act-copy" @click.stop="handleCopy(order.express_no)">
<text>复制</text>
</view>
</view>
</view>
</view>
<view class="right-arrow">
<text class="iconfont icon-arrow-right"></text>
</view>
</view>
<!-- 商品列表 -->
<view class="goods-list i-card">
<view class="goods-item" v-for="(goods, idx) in order.goods" :key="idx">
<view class="goods-main" @click="handleTargetGoods(goods.goods_id)">
<!-- 商品图片 -->
<view class="goods-image">
<image class="image" :src="goods.goods_image" mode="scaleToFill"></image>
</view>
<!-- 商品信息 -->
<view class="goods-content">
<view class="goods-title"><text class="twoline-hide">{{ goods.goods_name }}</text></view>
<view class="goods-props clearfix">
<view class="goods-props-item" v-for="(props, idx) in goods.goods_props" :key="idx">
<text>{{ props.value.name }}</text>
</view>
</view>
</view>
<!-- 交易信息 -->
<view class="goods-trade">
<view class="goods-price">
<text class="unit"></text>
<text class="value">{{ goods.goods_price }}</text>
</view>
<view class="goods-num">
<text>×{{ goods.total_num }}</text>
</view>
</view>
</view>
<!-- 商品售后 -->
<view class="goods-refund">
<text v-if="goods.refund" class="stata-text">已申请售后</text>
</view>
</view>
</view>
<!-- 订单信息 -->
<view class="order-info i-card">
<view class="info-item">
<view class="item-lable">订单编号</view>
<view class="item-content">
<text>{{ order.order_no }}</text>
<view class="act-copy" @click="handleCopy(order.order_no)">
<text>复制</text>
</view>
</view>
</view>
<view class="info-item">
<view class="item-lable">下单时间</view>
<view class="item-content">
<text>{{ order.create_time }}</text>
</view>
</view>
<view class="info-item">
<view class="item-lable">买家留言</view>
<view class="item-content">
<text>{{ order.buyer_remark ? order.buyer_remark : '--' }}</text>
</view>
</view>
</view>
<!-- 结算信息 -->
<view class="trade-info i-card">
<view class="info-item">
<view class="item-lable">订单金额</view>
<view class="item-content">
<text>{{ order.total_price }}</text>
</view>
</view>
<view v-if="order.coupon_money > 0" class="info-item">
<view class="item-lable">优惠券抵扣</view>
<view class="item-content">
<text>-{{ order.coupon_money }}</text>
</view>
</view>
<view v-if="order.points_money > 0" class="info-item">
<view class="item-lable">{{ setting.points_name }}抵扣</view>
<view class="item-content">
<text>-{{ order.points_money }}</text>
</view>
</view>
<view class="info-item">
<view class="item-lable">运费</view>
<view class="item-content">
<text>+{{ order.express_price }}</text>
</view>
</view>
<view v-if="order.update_price.value != '0.00'" class="info-item">
<view class="item-lable">后台改价</view>
<view class="item-content">
<text>{{ order.update_price.symbol }}</text>
<text>{{ order.update_price.value }}</text>
</view>
</view>
<view class="divider"></view>
<view class="trade-total">
<text class="lable">实付款</text>
<view class="goods-price">
<text class="unit"></text>
<text class="value">{{ order.pay_price }}</text>
</view>
</view>
</view>
<!-- 底部操作按钮 -->
<view v-if="order.order_status != OrderStatusEnum.CANCELLED.value" class="footer-fixed">
<view class="btn-wrapper">
<!-- 已申请取消 -->
<view v-if="order.order_status == OrderStatusEnum.APPLY_CANCEL.value" class="f-28 col-8">取消申请中</view>
<!-- 确认核销 -->
<block v-else-if="order.pay_status == PayStatusEnum.SUCCESS.value && order.delivery_type == DeliveryTypeEnum.EXTRACT.value
&& order.delivery_status == DeliveryStatusEnum.NOT_DELIVERED.value">
<view class="btn-item active" @click="onConfirmExtract()">确认核销</view>
</block>
</view>
</view>
</view>
</template>
<script>
import { getSceneData } from '@/core/app'
import {
DeliveryStatusEnum,
DeliveryTypeEnum,
OrderStatusEnum,
PayStatusEnum,
ReceiptStatusEnum
} from '@/common/enum/order'
import * as OrderApi from '@/api/shop/order'
import { wxPayment } from '@/core/app'
export default {
data() {
return {
// 枚举类
DeliveryStatusEnum,
DeliveryTypeEnum,
OrderStatusEnum,
PayStatusEnum,
ReceiptStatusEnum,
// 当前订单ID
orderId: null,
// 加载中
isLoading: true,
// 当前订单详情
order: {},
// 当前设置
setting: {}
}
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
// 记录query参数
this.onRecordQuery(options)
// 获取当前订单信息
this.getOrderDetail()
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
methods: {
// 记录query参数
onRecordQuery(query) {
const scene = getSceneData(query)
this.orderId = query.orderId ? parseInt(query.orderId) : parseInt(scene.oid)
},
// 获取当前订单信息
getOrderDetail() {
const app = this
app.isLoading = true
OrderApi.detail(app.orderId)
.then(result => {
app.order = result.data.order
app.setting = result.data.setting
app.isLoading = false
})
},
// 复制指定内容
handleCopy(value) {
const app = this
uni.setClipboardData({
data: value,
success() {
app.$toast('复制成功')
}
})
},
// 跳转到门店详情页
handleTargetExtract(shopId) {
this.$navTo('pages/shop/detail', { shopId })
},
// 跳转到物流跟踪页面
handleTargetExpress() {
this.$navTo('pages/order/express/index', { orderId: this.orderId })
},
// 跳转到商品详情页面
handleTargetGoods(goodsId) {
this.$navTo('pages/goods/detail', { goodsId })
},
// 确认核销订单
onConfirmExtract() {
const app = this
uni.showModal({
title: '友情提示',
content: '确认要核销该订单吗?请确认买家已取到货~',
success(o) {
if (o.confirm) {
OrderApi.extract(app.orderId)
.then(result => {
// 显示成功信息
app.$success(result.message)
setTimeout(() => {
// 刷新当前订单数据
app.getOrderDetail()
}, 1500)
})
}
}
});
}
},
}
</script>
<style>
page {
background: #f4f4f4;
}
</style>
<style lang="scss" scoped>
.container {
// 设置ios刘海屏底部横线安全区域
padding-bottom: calc(constant(safe-area-inset-bottom) + 106rpx + 6rpx);
padding-bottom: calc(env(safe-area-inset-bottom) + 106rpx + 6rpx);
}
// 页面顶部
.header {
display: flex;
justify-content: space-between;
background-color: #e8c269;
height: 280rpx;
padding: 56rpx 30rpx 0 30rpx;
.order-status {
display: flex;
align-items: center;
height: 128rpx;
.status-icon {
width: 128rpx;
height: 128rpx;
.image {
display: block;
width: 100%;
height: 100%;
}
}
.status-text {
padding-left: 20rpx;
color: #fff;
font-size: 38rpx;
font-weight: bold;
}
}
.next-action {
display: flex;
align-items: center;
height: 128rpx;
.action-btn {
min-width: 152rpx;
height: 56rpx;
padding: 0 30rpx;
background-color: #fff;
border-radius: 28rpx;
border-color: rgb(102, 102, 102);
cursor: pointer;
user-select: none;
color: #c7a157;
display: flex;
justify-content: center;
align-items: center;
}
}
}
// 通栏卡片
.i-card {
background: #fff;
padding: 24rpx 24rpx;
width: 94%;
box-shadow: 0 1rpx 5rpx 0px rgba(0, 0, 0, 0.05);
margin: 0 auto 20rpx auto;
border-radius: 20rpx;
}
// 自提门店
.delivery-extract {
margin-top: -50rpx;
.extract-top {
margin-bottom: 20rpx;
.title {
font-size: 28rpx;
margin-right: 30rpx;
}
.subtitle {
font-size: 24rpx;
color: #888;
}
}
.shop-info {
display: flex;
align-items: center;
}
.icon-location {
font-size: 34rpx;
}
.shop-content {
flex: 1;
margin-left: 26rpx;
font-size: 24rpx;
.shop-name {
font-size: 28rpx;
margin-bottom: 8rpx;
}
.shop-describe {
color: #777;
.item-text {
margin-right: 8rpx;
}
}
}
}
// 收货地址
.delivery-address {
margin-top: -50rpx;
.link-man {
line-height: 46rpx;
color: #333;
.name {
margin-right: 10rpx;
}
}
.address {
margin-top: 12rpx;
color: #999;
font-size: 24rpx;
.detail {
margin-left: 6rpx;
}
}
}
// 物流公司
.express {
display: flex;
align-items: center;
.main {
flex: 1;
}
.info-item {
display: flex;
margin-bottom: 24rpx;
&:last-child {
margin-bottom: 0;
}
.item-lable {
display: flex;
align-items: center;
font-size: 24rpx;
color: #999;
margin-right: 30rpx;
}
.item-content {
flex: 1;
display: flex;
align-items: center;
font-size: 26rpx;
color: #333;
.act-copy {
margin-left: 20rpx;
padding: 2rpx 20rpx;
font-size: 22rpx;
color: #666;
border: 1rpx solid #c1c1c1;
border-radius: 16rpx;
}
}
}
// 右侧箭头
.right-arrow {
margin-left: 16rpx;
// color: #777;
font-size: 26rpx;
}
}
// 商品列表
.goods-list {
// 商品项
.goods-item {
margin-bottom: 40rpx;
&:last-child {
margin-bottom: 0;
}
// 商品信息
.goods-main {
display: flex;
}
// 商品图片
.goods-image {
width: 180rpx;
height: 180rpx;
.image {
display: block;
width: 100%;
height: 100%;
border-radius: 8rpx;
}
}
// 商品内容
.goods-content {
flex: 1;
padding-left: 16rpx;
padding-top: 16rpx;
.goods-title {
font-size: 26rpx;
max-height: 76rpx;
}
.goods-props {
margin-top: 14rpx;
height: 40rpx;
color: #ababab;
font-size: 24rpx;
overflow: hidden;
.goods-props-item {
display: inline-block;
margin-right: 14rpx;
padding: 4rpx 16rpx;
border-radius: 12rpx;
background-color: #F5F5F5;
width: auto;
}
}
}
// 交易信息
.goods-trade {
padding-top: 16rpx;
width: 150rpx;
text-align: right;
color: $uni-text-color-grey;
font-size: 26rpx;
.goods-price {
vertical-align: bottom;
margin-bottom: 16rpx;
.unit {
margin-right: -2rpx;
font-size: 24rpx;
}
}
}
// 商品售后
.goods-refund {
display: flex;
justify-content: flex-end;
.stata-text {
font-size: 24rpx;
color: #999;
}
.action-btn {
border-radius: 28rpx;
padding: 8rpx 26rpx;
font-size: 24rpx;
color: #383838;
border: 1rpx solid #a8a8a8;
}
}
}
}
// 订单信息
.order-info {
.info-item {
display: flex;
margin-bottom: 24rpx;
&:last-child {
margin-bottom: 0;
}
.item-lable {
display: flex;
align-items: center;
font-size: 24rpx;
color: #999;
margin-right: 30rpx;
}
.item-content {
flex: 1;
display: flex;
align-items: center;
font-size: 26rpx;
color: #333;
.act-copy {
margin-left: 20rpx;
padding: 2rpx 20rpx;
font-size: 22rpx;
color: #666;
border: 1rpx solid #c1c1c1;
border-radius: 16rpx;
}
}
}
}
// 交易信息
.trade-info {
.info-item {
display: flex;
margin-bottom: 24rpx;
.item-lable {
font-size: 24rpx;
color: #999;
margin-right: 24rpx;
}
.item-content {
flex: 1;
font-size: 26rpx;
color: #333;
text-align: right;
}
}
.divider {
height: 1rpx;
background: #f1f1f1;
margin-bottom: 24rpx;
}
.trade-total {
display: flex;
justify-content: flex-end;
.goods-price {
margin-left: 12rpx;
vertical-align: bottom;
color: $main-bg;
.unit {
margin-right: -2rpx;
font-size: 24rpx;
}
}
}
}
// 底部操作栏
.footer-fixed {
position: fixed;
bottom: var(--window-bottom);
left: 0;
right: 0;
z-index: 11;
box-shadow: 0 -4rpx 40rpx 0 rgba(151, 151, 151, 0.24);
background: #fff;
// 设置ios刘海屏底部横线安全区域
padding-bottom: constant(safe-area-inset-bottom);
padding-bottom: env(safe-area-inset-bottom);
.btn-wrapper {
height: 106rpx;
display: flex;
align-items: center;
justify-content: flex-end;
padding: 0 30rpx;
}
.btn-item {
min-width: 180rpx;
border-radius: 30rpx;
padding: 12rpx 26rpx;
font-size: 28rpx;
color: #383838;
text-align: center;
border: 1rpx solid #a8a8a8;
margin-left: 24rpx;
&.active {
border: none;
background: linear-gradient(to right, $main-bg, $main-bg2);
color: $main-text;
}
}
}
// 弹出层-支付方式
.pay-popup {
padding: 24rpx;
.title {
font-size: 30rpx;
margin-bottom: 50rpx;
font-weight: bold;
text-align: center;
}
.pop-content {
min-height: 260rpx;
padding: 0 10rpx;
.pay-item {
padding: 20rpx 35rpx;
font-size: 28rpx;
border-bottom: 1rpx solid #f1f1f1;
&:last-child {
border-bottom: none;
}
.item-left_icon {
margin-right: 20rpx;
font-size: 32rpx;
&.wechat {
color: #00c800;
}
&.balance {
color: #ff9700;
}
}
}
}
}
// 弹出层 - 核销二维码
.qrcode-popup {
padding: 36rpx 30rpx;
.title {
font-size: 30rpx;
margin-bottom: 26rpx;
font-weight: bold;
text-align: center;
}
.pop-content {
min-height: 260rpx;
padding: 0 10rpx;
.image {
display: block;
width: 510rpx;
height: 510rpx;
}
}
}
</style>

811
pages/order/index.vue Executable file
View File

@@ -0,0 +1,811 @@
<template>
<view class="container" :style="appThemeStyle">
<mescroll-body ref="mescrollRef" :sticky="true" @init="mescrollInit" :down="{ native: true }"
@down="downCallback" :up="upOption" @up="upCallback">
<!-- tab栏 -->
<u-tabs :list="tabs" :is-scroll="false" :current="curTab" :active-color="appTheme.mainBg" :duration="0.2"
@change="onChangeTab" />
<!-- 订单列表 -->
<view class="order-list">
<view class="order-item" v-for="(item, index) in list" :key="index" v-if="item.equipmentGoods">
<view class="item-top">
<view class="item-top-left">
<text class="order-time">{{ item.merchantName }}</text>
</view>
<view class="item-top-right">
<text class="state-text" v-if="item.payStatus == 10">待支付</text>
<text class="state-text" v-if="item.payStatus == 20 && item.receiptStatus == 10">待绑定</text>
<text class="state-text" v-if="item.orderStatus == 30 && item.receiptStatus == 20">已完成</text>
<text class="state-text" v-if="item.receiptStatus == 30">已退租</text>
</view>
</view>
<!-- 商品列表 -->
<view class="goods-list" @click="handleTargetDetail(item.orderId)">
<view class="goods-item">
<!-- 商品图片 -->
<view class="goods-image">
<image v-if="item.image" :src="item.image" class="equipment-image" mode="aspectFit">
</image>
<image v-else class="image" src="/static/goods/battery.png" mode="scaleToFill"></image>
</view>
<!-- 商品信息 -->
<view class="goods-content">
<view class="goods-title">
<text class="twoline-hide">
下单类型
<span v-if="item.equipmentGoods.equipmentCategory == 10">销售</span>
<span v-if="item.equipmentGoods.equipmentCategory == 20">分期</span>
<span v-if="item.equipmentGoods.equipmentCategory == 30">以租代购</span>
<span v-if="item.equipmentGoods.equipmentCategory == 40">租赁</span>
</text>
<text class="twoline-hide">订单编号{{ item.orderNo }}</text>
<text class="twoline-hide"
v-if="item.orderStatus == 30">到期时间{{ item.expirationTime }}</text>
<text class="twoline-hide" v-else>下单时间{{ item.payTime }}</text>
<text class="twoline-hide"
v-if="item.orderStatus == 30">设备编号{{ item.equipment.equipmentCode }}</text>
<text class="twoline-hide">设备名称{{ item.equipmentGoods.goodsName }}</text>
<text class="twoline-hide">设备型号{{ item.equipmentGoods.batteryModel }}</text>
<text class="twoline-hide yuqi-text" v-if="item.expirationDay < 0">逾期状态: (已逾期{{ Math.abs(item.expirationDay) }})</text>
<text class="twoline-hide yuqi-text" v-if="item.expirationDay < 7 && item.expirationDay > 0">逾期状态: 即将过期</text>
</view>
<view class="goods-props clearfix">
<!-- <view class="goods-props-item">
<text>props.value.name</text>
</view> -->
</view>
</view>
<!-- 交易信息 -->
<!-- <view class="goods-trade">
<view class="goods-price">
<text class="unit"></text>
<text class="value">{{ item.batteryRent }}</text>
</view>
<view class="goods-num">
<text>x1</text>
</view>
</view> -->
</view>
</view>
<!-- 订单合计 -->
<view class="order-total">
<!-- <text>押金{{ item.batteryDeposit }}, 保险{{ item.batteryInsurance }}, 订单金额</text> -->
<text>合计</text>
<text class="unit" style="color: #ff0000;"></text>
<text class="money">{{ item.totalPrice }}</text>
</view>
<!-- 订单操作 -->
<view v-if="item.orderStatus != OrderStatusEnum.CANCELLED.value" class="order-handle">
<view class="btn-group clearfix">
<!-- 未支付取消订单 -->
<block v-if="item.payStatus == PayStatusEnum.PENDING.value">
<view class="btn-item" @click="onCancel(item.orderId)">取消</view>
</block>
<!-- 已支付进行中的订单 -->
<block v-if="item.orderStatus != OrderStatusEnum.APPLY_CANCEL.value">
<!-- <block v-if="item.payStatus == PayStatusEnum.SUCCESS.value && item.deliveryStatus == DeliveryStatusEnum.NOT_DELIVERED.value">
<view class="btn-item" @click="onCancel(item.orderId)">申请取消</view>
</block> -->
<!-- 订单核销码 -->
<block v-if="item.payStatus == PayStatusEnum.SUCCESS.value && item.deliveryType == DeliveryTypeEnum.EXTRACT.value
&& item.deliveryStatus == DeliveryStatusEnum.NOT_DELIVERED.value">
<view class="btn-item active" @click="onExtractQRCode(item.orderId)">
<text class="iconfont icon-qr-extract"></text>
<text class="m-l-10">核销码</text>
</view>
</block>
</block>
<!-- 已申请取消 -->
<view v-else class="f-28 col-8">取消申请中</view>
<!-- 未支付的订单 -->
<block v-if="item.payStatus == PayStatusEnum.PENDING.value">
<view class="btn-item active" @click="onPay(item.orderId)">去支付</view>
</block>
<!-- 确认收货 -->
<block
v-if="item.payStatus == PayStatusEnum.SUCCESS.value && item.deliveryStatus == DeliveryStatusEnum.NOT_DELIVERED.value && item.receiptStatus == ReceiptStatusEnum.NOT_RECEIVED.value">
<view class="btn-item active" v-if="(item.orderSourceData && JSON.parse(item.orderSourceData).length == 5) || item.equipmentGoods.equipmentCategory == '10'" @click="onBind(item)">绑定设备</view>
<view class="btn-item active" v-else @click="chooseImage(item.orderId)">确认收货</view>
</block>
<!-- 订单评价 -->
<block v-if="item.orderStatus == OrderStatusEnum.COMPLETED.value && item.isComment == 0">
<view class="btn-item" v-if="item.equipmentGoods.equipmentCategory == '40'"
@click="handleChangeEquipment(item.orderId,item.equipment.equipmentId)">换电</view>
<!-- <view class="btn-item" v-if="item.equipmentGoods.equipmentCategory == '锂电池租赁' || item.equipmentGoods.equipmentCategory == '电动车租赁'" @click="handleTargetDetail(item.orderId)">续费</view> -->
<view class="btn-item" @click="handleTargetDetail(item.orderId)">详情</view>
</block>
</view>
</view>
</view>
</view>
</mescroll-body>
<!-- 核销二维码弹窗 -->
<u-popup v-model="showQRCodePopup" mode="center" border-radius="26" :closeable="true">
<view class="qrcode-popup">
<view class="title">自提核销二维码</view>
<view class="pop-content">
<image v-if="qrcodeImage" class="image" :src="qrcodeImage"></image>
</view>
</view>
</u-popup>
<!-- 绑定设备码 -->
<u-popup v-model="showQRCodeBind" mode="center" border-radius="26" :closeable="true">
<view class="qrcode-bind">
<view class="title">请核对要绑定的设备编号是否正确</view>
<view class="bind-content">
<input v-model="bindValue" class="input" @confirm="onSearch" focus="true" placeholder="请输入设备编号"
type="text"></input>
</view>
<view class="submit">
<u-button type="error" @click="doBind">立即绑定</u-button>
</view>
</view>
</u-popup>
<!-- 换电 -->
<u-popup v-model="showQRCodeBindChange" mode="center" border-radius="26" :closeable="true">
<view class="qrcode-bind">
<view class="title">请输入更换的新电池编号</view>
<view class="bind-content">
<input v-model="bindValue" class="input" @confirm="onSearch" focus="true" placeholder="请输入设备编号"
type="text"></input>
</view>
<view class="submit">
<u-button type="error" @click="doEquipment(true)">确定更换电池</u-button>
</view>
</view>
</u-popup>
</view>
</template>
<script>
import {
DeliveryStatusEnum,
DeliveryTypeEnum,
OrderStatusEnum,
PayStatusEnum,
ReceiptStatusEnum
} from '@/common/enum/order'
import store from '@/store/index.js'
import MescrollBody from '@/components/mescroll-uni/mescroll-body.vue'
import MescrollMixin from '@/components/mescroll-uni/mescroll-mixins'
import {
getEmptyPaginateObj,
getMoreListData
} from '@/core/app'
import * as OrderApi from '@/api/order'
import {
wxPayment
} from '@/core/app'
import * as EquipmentApi from '@/websoft/api/equipment.js'
import {
pageOrder,
removeOrder,
receiptOrder
} from '@/websoft/api/order.js'
import {
bindEquipment
} from '@/websoft/api/equipment.js'
import {
uploadFile
} from '@/websoft/api/upload.js'
import { fileUrl } from '@/config.js';
// 每页记录数量
const pageSize = 15
// tab栏数据
const tabs = [{
name: `全部`,
value: 'all'
}, {
name: `待支付`,
value: 'payment'
}, {
name: `待绑定`,
value: 'delivery'
}, {
name: `已完成`,
value: 'comment'
}]
export default {
components: {
MescrollBody
},
mixins: [MescrollMixin],
data() {
return {
// 枚举类
DeliveryStatusEnum,
DeliveryTypeEnum,
OrderStatusEnum,
PayStatusEnum,
ReceiptStatusEnum,
// 当前页面参数
options: {
dataType: 'all'
},
// tab栏数据
tabs,
// 当前标签索引
curTab: 0,
// 订单列表数据
list: [],
// 上拉加载配置
upOption: {
// 首次自动执行
auto: true,
// 每页数据的数量; 默认10
page: {
size: pageSize
},
// 数量要大于4条才显示无更多数据
noMoreSize: 4,
// 空布局
empty: {
tip: '亲,暂无订单记录'
}
},
// 控制onShow事件是否刷新订单列表
canReset: false,
// 核销二维码弹窗
showQRCodePopup: false,
// 核销二维码图片url (通过后端获取)
qrcodeImage: '',
where: {},
showQRCodeBind: false,
bindValue: '',
// 选择的设备
equipment: {},
equipmentId: null,
showQRCodeBindChange: false
}
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
// 初始化当前选中的标签
this.initCurTab(options)
// 注册全局事件订阅: 是否刷新订单列表
uni.$on('syncRefreshOrder', canReset => {
this.canReset = canReset
})
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
this.canReset && this.onRefreshList()
this.canReset = false
},
/**
* 生命周期函数--监听页面的卸载
*/
onUnload() {
// 卸载全局事件订阅
uni.$off('syncRefreshOrder')
},
methods: {
// 初始化当前选中的标签
initCurTab(options) {
const app = this
if (options.dataType) {
const index = app.tabs.findIndex(item => item.value == options.dataType)
app.curTab = index > -1 ? index : 0
}
},
/**
* 上拉加载的回调 (页面初始化时也会执行一次)
* 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10
* @param {Object} page
*/
upCallback(page) {
const app = this
// 设置列表数据
app.getOrderList(page.num)
// .then(list => {
// console.log("list: ",list);
// const curPageLen = list.data.length
// const totalSize = list.data.total
// app.mescroll.endBySize(curPageLen, totalSize)
// })
// .catch(() => app.mescroll.endErr())
},
// 获取订单列表
getOrderList(pageNo = 1) {
const app = this
const {
curTab
} = this
// app.where.userId = uni.getStorageSync('userId')
console.log("curTab: ", curTab);
app.where = {}
if (curTab == 0) {
app.where = {}
}
if (curTab == 1) {
app.where.payStatus = 10;
}
if (curTab == 2) {
app.where.payStatus = 20;
app.where.receiptStatus = 10;
}
if (curTab == 3) {
app.where.payStatus = 20;
app.where.receiptStatus = 20;
}
if (curTab == 4) {
app.where.receiptStatus = 20;
app.where.isComment = 0;
}
app.where.userId = uni.getStorageSync('userId');
app.where.isRenew = 0;
pageOrder(app.where).then(res => {
app.list = res.data.list
const curPageLen = res.data.list.length
const totalSize = res.data.count
console.log("totalSize: ", totalSize);
app.mescroll.endBySize(curPageLen, totalSize)
app.list.map((d,index) => {
const setTime = new Date(d.expirationTime);
const nowTime = new Date();
const restSec = setTime.getTime() - nowTime.getTime();
// 剩余天数
const day = parseInt(restSec / (60*60*24*1000));
console.log("逾期天数: ",Math.abs(day));
app.list[index].expirationDay = day
})
})
// return new Promise((resolve, reject) => {
// OrderApi.list({ dataType: app.getTabValue(), page: pageNo }, { load: false })
// .then(result => {
// // 合并新数据
// const newList = app.initList(result.data.list)
// app.list.data = getMoreListData(newList, app.list, pageNo)
// resolve(newList)
// })
// })
},
// 初始化订单列表数据
initList(newList) {
newList.data.forEach(item => {
item.totalNum = 0
item.goods.forEach(goods => {
item.totalNum += goods.totalNum
})
})
return newList
},
// 获取当前标签项的值
getTabValue() {
return this.tabs[this.curTab].value
},
// 切换标签项
onChangeTab(index) {
const app = this
// 设置当前选中的标签
app.curTab = index
// 刷新订单列表
app.onRefreshList()
},
// 刷新订单列表
onRefreshList() {
this.list = getEmptyPaginateObj()
setTimeout(() => {
this.mescroll.resetUpScroll()
}, 120)
},
// 取消订单
onCancel(orderId) {
const app = this
uni.showModal({
title: '友情提示',
content: '确认要取消该订单吗?',
success(o) {
if (o.confirm) {
removeOrder(orderId)
.then(result => {
// 显示成功信息
app.$toast(result.message)
// 刷新订单列表
app.onRefreshList()
})
}
}
});
},
// 确认收货
onReceipt(orderId) {
const app = this
uni.showModal({
title: '友情提示',
content: '确认收到商品了吗?',
success(o) {
if (o.confirm) {
OrderApi.receipt(orderId)
.then(result => {
// 显示成功信息
app.$success(result.message)
// 刷新订单列表
app.onRefreshList()
})
}
}
});
},
// 上传图片
chooseImage(orderId) {
const app = this
this.$navTo('pages/order/delivery', {
orderId
})
return;
// 选择图片
uni.chooseImage({
count: 1,
sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图,默认二者都有
sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有
success(chooseImageRes) {
const tempFilePaths = chooseImageRes.tempFilePaths;
uploadFile({
filePath: tempFilePaths[0],
fileType: 'image',
name: 'file'
}).then(res => {
console.log("res: ", res);
const orderSourceData = JSON.stringify({
orderId,
photo: fileUrl + res.data.path
})
receiptOrder({
orderId,
orderSourceData
}).then(result => {
app.$success(result.message)
// 刷新订单列表
app.onRefreshList()
})
})
// uni.uploadFile({
// url: 'http://127.0.0.1:9090/api/open/file/upload', //仅为示例,非真实的接口地址
// filePath: tempFiles,
// name: 'file',
// formData: {
// 'authorization': 'eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJ7XCJ1c2VybmFtZVwiOlwiMjA4ODIwMjk1OTA0NDIwNVwiLFwidGVuYW50SWRcIjo2fSIsImV4cCI6MTY3ODUwNDc1NSwiaWF0IjoxNjc4NDE4MzU1fQ.M-8RB724jmHmhMKut-AFW9i79vJVNdBDqoq-EInDses'
// },
// success: (uploadFileRes) => {
// console.log(uploadFileRes.data);
// }
// });
// tempFiles = [{path:'xxx', size:100}]
// app.imageList = oldImageList.concat(tempFiles)
}
});
},
// 绑定设备
onBind(item) {
const app = this
const {
equipment
} = item
app.showQRCodeBind = true
app.equipment = item
// app.bindValue = equipment.equipmentCode
},
// 执行绑定
doBind() {
const app = this
const {
equipment,
bindValue
} = this
bindEquipment({
equipmentCode: bindValue,
orderId: equipment.orderId
}).then(result => {
app.$success(result.message)
app.showQRCodeBind = false
// 刷新订单列表
app.onRefreshList()
}).catch(err => {
app.$error(err.message)
})
console.log("this.bindValue: ", this.bindValue);
},
// 获取核销二维码
onExtractQRCode(orderId) {
const app = this
OrderApi.extractQrcode(orderId, {
channel: app.platform
})
.then(result => {
app.qrcodeImage = result.data.qrcode
app.showQRCodePopup = true
})
},
// 点击去支付
onPay(orderId) {
this.$navTo('pages/checkout/cashier/index', {
orderId
})
},
// 跳转到订单详情页
handleTargetDetail(orderId) {
this.$navTo('pages/order/detail', {
orderId
})
},
// 跳转到订单评价页
handleTargetComment(orderId) {
this.$navTo('pages/order/comment/index', {
orderId
})
},
handleChangeEquipment(orderId, equipmentId) {
const app = this
app.orderId = orderId
app.equipmentId = equipmentId
app.showQRCodeBindChange = true
},
// 换电
doEquipment(canReset = false) {
const app = this
const {
orderId,
bindValue,
equipmentId
} = this
EquipmentApi.changeEquipment({
equipmentCode: bindValue,
orderId,
equipmentId
}).then(result => {
app.$success(result.message)
app.showQRCodeBindChange = false
app.bindValue = ''
// 刷新订单列表
app.onRefreshList()
}).catch(err => {
app.$error(err.message)
})
console.log("this.bindValue: ", this.bindValue);
}
},
}
</script>
<style lang="scss" scoped>
// 项目内容
.order-item {
margin: 20rpx auto 20rpx auto;
padding: 30rpx 30rpx;
width: 94%;
box-shadow: 0 1rpx 5rpx 0px rgba(0, 0, 0, 0.05);
border-radius: 16rpx;
background: #fff;
}
// 项目顶部
.item-top {
display: flex;
justify-content: space-between;
font-size: 26rpx;
margin-bottom: 40rpx;
.order-time {
color: #333333;
font-weight: bold;
}
.state-text {
color: $main-bg;
}
}
// 商品列表
.goods-list {
// 商品项
.goods-item {
display: flex;
margin-bottom: 40rpx;
// 商品图片
.goods-image {
width: 100rpx;
height: 100rpx;
.image {
display: block;
width: 100rpx;
height: 100rpx;
border-radius: 8rpx;
}
}
// 商品内容
.goods-content {
flex: 1;
padding-left: 16rpx;
padding-top: 16rpx;
.goods-title {
width: 420rpx;
font-size: 26rpx;
max-height: 76rpx;
line-height: 36rpx;
}
.goods-props {
margin-top: 14rpx;
height: 40rpx;
color: #ababab;
font-size: 24rpx;
overflow: hidden;
.goods-props-item {
display: inline-block;
margin-right: 14rpx;
padding: 4rpx 16rpx;
border-radius: 12rpx;
background-color: #F5F5F5;
width: auto;
}
}
}
// 交易信息
.goods-trade {
padding-top: 16rpx;
width: 200rpx !important;
text-align: right;
color: $uni-text-color-grey;
font-size: 26rpx;
.goods-price {
vertical-align: bottom;
margin-bottom: 16rpx;
.unit {
margin-right: -2rpx;
font-size: 24rpx;
}
}
}
}
}
// 订单合计
.order-total {
font-size: 26rpx;
vertical-align: bottom;
text-align: right;
height: 50rpx;
padding-top: 20rpx;
margin-bottom: 30rpx;
.unit {
margin-left: 8rpx;
margin-right: -2rpx;
font-size: 26rpx;
}
.money {
font-size: 28rpx;
color: #ff0000;
}
}
// 订单操作
.order-handle {
.btn-group {
.btn-item {
border-radius: 10rpx;
padding: 8rpx 20rpx;
margin-left: 15rpx;
font-size: 26rpx;
float: right;
color: #383838;
border: 1rpx solid #a8a8a8;
&:last-child {
margin-left: 0;
}
&.active {
color: $main-bg;
border: 1rpx solid $main-bg;
}
}
}
}
// 弹出层 - 核销二维码
.qrcode-popup {
padding: 36rpx 30rpx;
.title {
font-size: 30rpx;
margin-bottom: 26rpx;
font-weight: bold;
text-align: center;
}
.pop-content {
min-height: 260rpx;
padding: 0 10rpx;
.image {
display: block;
width: 510rpx;
height: 510rpx;
}
}
}
// 弹出层 - 绑定设备码
.qrcode-bind {
width: 550rpx;
height: 300rpx;
padding: 36rpx 30rpx;
.title {
font-size: 30rpx;
margin-bottom: 26rpx;
font-weight: bold;
text-align: center;
}
.bind-content {
padding: 0 10rpx;
border: 1rpx solid #eee;
font-size: 24rpx;
.image {
display: block;
width: 510rpx;
height: 510rpx;
}
}
.submit {
margin-top: 30rpx;
}
}
.yuqi-text{
color: #ff0000;
}
</style>