Commit 68fbca67 by 李伟康

Merge branch 'v1.0.0' of http://192.168.3.233:8090/glsx/simgle_app into v1.0.0

2 parents 58c1eaa6 70060cee
......@@ -441,5 +441,18 @@ module.exports = {
projectName: 'pad',
...data
})
}
},
// 获取订单分页列表
getOrderPage(data) {
console.log(data)
return http.shukeRequest('linkwe-gateway/open/weSubstitute/customer/order', data, 'GET', true)
},
// 新增订单
addOrder(data) {
return http.shukeRequest('linkwe-gateway/open/weSubstitute/customer/order', data, 'POST', true)
},
// 商品列表
getProductList(data) {
return http.shukeRequest('linkwe-gateway/open/product/page/list', data, 'GET', true)
},
}
......@@ -3,8 +3,8 @@
<view v-for="(items, boxIdx) in formList" :key="boxIdx">
<view class="cell-box">
<template v-for="(item, idx) in items">
<view v-if="!item.hidden">
<view class="cell-row" :key="idx">
<template v-if="!item.hidden">
<view :class="['cell-row', item.fullRow ? 'full' : 'half']" :key="idx">
<view class="cell" @click="onCellClick(item)" :class="[item.noBorder ? '' : 'border', item.onlyLabel ? 'small-height' : '', item.class]">
<view :class="['cell-label', { 'only-label': item.onlyLabel }]">
<view v-if="item.labellIcon" :class="['sprite-icon', `icon-${item.labellIcon}`]"></view>
......@@ -52,11 +52,14 @@
<template v-else-if="item.type === 'textarea'">
<textarea class="textarea" v-model="formData[item.value]" :placeholder="item.placeholder || '请输入'" placeholder-class="textarea-placeholder" confirm-type="done" auto-height :maxlength="item.maxlength"></textarea>
</template>
<template v-else>
<view class="value">{{ formData[item.value] }}</view>
</template>
</view>
</view>
<slot v-if="item.addHtml" :name="item.addHtml"></slot>
</view>
</view>
</template>
</template>
</view>
</view>
......@@ -117,14 +120,24 @@ export default {
<style scoped lang="scss">
.cell-box {
background-color: #fff;
border-radius: toRpx(16);
overflow: hidden;
margin-bottom: toRpx(18);
overflow: visible;
margin: toRpx(64) 0;
display: flex;
flex-wrap: wrap;
gap: toRpx(24) toRpx(48);
}
.cell-row {
background-color: #fff;
border-radius: toRpx(16);
padding-left: toRpx(32);
box-sizing: border-box;
}
.cell-row.half {
width: calc((100% - #{toRpx(48)}) / 2);
}
.cell-row.full {
width: 100%;
}
.cell {
......@@ -222,6 +235,8 @@ export default {
height: 100%;
text-align: right;
width: 100%;
border: none;
}
.input-bottom {
......
......@@ -68,6 +68,11 @@ export default {
icon: "home",
name: 'HomeSlot'
},
{
label: "订单",
icon: "scene",
name: 'Order'
}
]
return tabs
}
......
<template>
<view>
<view class="study-right">
<view class="data-container">
<view :class="['type-box']">
<view class="tab-item" v-for="(i, index) in typeList" :key="index" @click="changeType(index)"
:class="{ active: firstIndex == index }">
<view class="label">{{ i.tabName }}</view>
<view class="count">{{ i.num() }}</view>
</view>
</view>
<template v-if="list.length > 0">
<scroll-view scroll-y class="content-scroll" @scrolltolower="loadMore" lower-threshold="60">
<view class="card-list">
<view v-for="(i, index) in list" :key="index" class="card">
<view class="card-left">
<view class="title">{{ maskName(i.purchaser) }}</view>
<view class="model">{{ i.productName }}</view>
<view class="row">
<view class="label">商品数量</view>
<view class="value">{{ i.amount || '--' }}</view>
</view>
<view class="row">
<view class="label">下单时间</view>
<view class="value">{{ i.orderTime || '--' }}</view>
</view>
<view class="row total">
<view class="label">订单价格</view>
<view class="value amount">¥{{ formatPrice(i.totalPrice) }}</view>
</view>
</view>
<view class="card-right">
<image class="preview-img" :src="i.productUrl" />
</view>
</view>
</view>
<view class="list-footer">
<view v-if="loading" class="loading">加载中...</view>
<view v-else-if="!hasMore">没有更多了</view>
</view>
</scroll-view>
</template>
<template v-else>
<view class="nothing flex">
<image class="icon" src="../../../../assets/images/boutique/nothing.png" />
暂无数据
</view>
</template>
</view>
</view>
</view>
</template>
<script>
import tag from 'uview-ui/libs/config/props/tag';
export default {
components: {
},
data() {
return {
firstIndex: 0,
firstLeft: ['first', 'second'],
firstClass: ['short-first-nav', 'short-second-nav'],
typeList: [
{ tabName: '全部', num: () => '' },
{ tabName: '已支付', num: () => '' },
{ tabName: '待支付', num: () => '' }
],
page: {
pageNum: 1,
pageSize: 12
},
list: [],
loading: false,
hasMore: true
}
},
mounted() {
this.getOrderPage()
uni.$on('ORDER_LIST_REFRESH', this.reload)
},
beforeDestroy() {
uni.$off('ORDER_LIST_REFRESH', this.reload)
},
methods: {
reload() {
this.page.pageNum = 1
this.hasMore = true
this.list = []
this.getOrderPage()
},
async getOrderPage(orderStatus) {
if (this.loading) return
const { pageNum, pageSize } = this.page
const params = { pageNum, pageSize }
if (orderStatus) params.orderStatus = orderStatus
this.loading = true
try {
const res = await uni.$api.commonApi.getOrderPage(params)
if (res.code == 200) {
const rows = Array.isArray(res.rows) ? res.rows : []
if (this.page.pageNum === 1) {
this.list = rows
} else {
this.list = this.list.concat(rows)
}
this.hasMore = rows.length === pageSize
}
} finally {
this.loading = false
}
},
changeType(index) {
this.firstIndex = index
this.page.pageNum = 1
this.hasMore = true
this.list = []
const statusMap = { 1: '已支付', 2: '待支付' }
this.getOrderPage(statusMap[index])
},
// 脱敏显示姓名,如“张*”
maskName(name) {
if (!name) return '--'
const first = name[0]
return `${first}*`
},
// 金额格式化为两位小数
formatPrice(val) {
const num = Number(val)
if (isNaN(num)) return '--'
return num.toFixed(2)
},
loadMore() {
if (!this.hasMore || this.loading) return
this.page.pageNum += 1
const statusMap = { 1: '已支付', 2: '待支付' }
this.getOrderPage(statusMap[this.firstIndex])
}
}
}
</script>
<style scoped lang="scss">
.study-right {
flex: 1;
background-color: rgba(255, 255, 255, 0.35);
backdrop-filter: blur(16px);
box-shadow: inset 0 0 16px 0 #ffffff;
border-radius: toRpx(48);
margin-right: toRpx(48);
position: relative;
.data-container {
margin-top: toRpx(48);
// background: #ffffff;
border-radius: toRpx(48);
height: calc(100vh - #{toRpx(136)});
box-shadow: inset 0 0 toRpx(16) 0 #ffffff;
border: toRpx(2) solid #fff;
box-sizing: border-box;
position: relative;
overflow: hidden;
padding: toRpx(40) toRpx(48);
display: flex;
flex-direction: column;
.type-box {
position: relative;
display: flex;
align-items: center;
width: 100%;
// background-color: #eef4fe;
height: toRpx(72);
border-radius: toRpx(48) toRpx(48) 0 0;
z-index: 0;
.tab-item {
display: inline-flex;
align-items: center;
height: 100%;
width: toRpx(164);
padding: 0 toRpx(24);
background: #fff;
border-radius: toRpx(16);
font-weight: 500;
font-size: toRpx(28);
color: #596170;
margin-right: toRpx(16);
.label {
width: 100%;
text-align: center;
font-size: toRpx(28);
}
.count {
margin-left: toRpx(8);
font-size: toRpx(26);
color: #8B97A3;
}
&.active {
background: linear-gradient(90deg, #5AA2FF 0%, #3B73FF 100%);
color: #FFFFFF;
.count {
color: rgba(255, 255, 255, 0.9);
}
}
}
}
}
}
.content-scroll {
flex: 1;
height: calc(100% - #{toRpx(136)});
margin-top: toRpx(48);
}
.list-footer {
margin-top: toRpx(24);
padding: toRpx(16) 0;
text-align: center;
color: #8B97A3;
font-size: toRpx(26);
}
.list-footer .loading {
color: #3773F8;
}
.nothing {
width: 100%;
flex-direction: column;
margin-top: toRpx(350);
font-size: toRpx(28);
color: #999999;
.icon {
width: toRpx(678);
height: toRpx(284);
margin-bottom: toRpx(24);
}
}
.card-list {
// margin-top: toRpx(48);
display: flex;
flex-wrap: wrap;
gap: toRpx(24);
width: 100%;
}
.card {
width: calc((100% - #{toRpx(52)}) / 3);
display: flex;
justify-content: space-between;
align-items: center;
// padding: toRpx(32);
background: rgba(255, 255, 255, 0.9);
border-radius: toRpx(32);
box-shadow: 0 toRpx(8) toRpx(24) rgba(59, 115, 255, 0.08);
margin-bottom: 0;
}
.card-left {
flex: 1;
padding: toRpx(32);
}
.title {
font-size: toRpx(28);
font-weight: 600;
color: #596170;
}
.model {
margin-top: toRpx(8);
font-size: toRpx(28);
color: #3773F8;
}
.row {
display: flex;
align-items: center;
margin-top: toRpx(10);
font-size: toRpx(26);
}
.row .label {
width: toRpx(140);
color: #8B97A3;
}
.row .value {
flex: 1;
color: #596170;
}
.row.total .amount {
color: #21C060;
font-weight: 600;
}
.card-right {
width: toRpx(252);
height: 100%;
border-radius: 0 toRpx(24) toRpx(24) 0;
overflow: hidden;
}
.preview-img {
width: 100%;
height: 100%;
object-fit: contain;
mask: linear-gradient(to left, #fff 20%, transparent);
}
</style>
<template>
<view class="order-container" :class="{ 'flip-out': isFlipping }">
<view class="create-order" @click="createOrder">
<view class="sprite-icon icon-addEvaluationFrom"></view>
</view>
<OrderList />
</view>
</template>
<script>
import OrderList from './OrderList.vue'
export default {
components: {
OrderList
},
data() {
return {
isFlipping: false,
navLock: false
}
},
methods: {
createOrder() {
if (this.navLock) return
this.navLock = true
this.isFlipping = true
setTimeout(() => {
uni.navigateTo({
url: '/pages/equity/createOrder',
animationType: 'slide-in-right',
animationDuration: 300
})
setTimeout(() => {
this.isFlipping = false
this.navLock = false
}, 400)
}, 280)
}
}
}
</script>
<style scoped lang="scss">
.order-container {
position: relative;
transform-style: preserve-3d;
perspective: toRpx(1200);
will-change: transform, opacity;
}
.flip-out {
animation: pageFlipOut 300ms ease both;
}
@keyframes pageFlipOut {
0% { transform: rotateY(0deg); opacity: 1; }
100% { transform: rotateY(-12deg) translateX(-12%); opacity: 0; }
}
.create-order {
position: absolute;
right: toRpx(24);
top: toRpx(504);
width: toRpx(128);
height: toRpx(128);
border-radius: toRpx(24);
border: toRpx(2) solid #ffffffe6;
background: linear-gradient(0deg, #2c66f7 0%, #48a6ff 100%);
box-shadow: 0 toRpx(4) toRpx(16) 0 #8f9eb380;
z-index: 2;
}
</style>
\ No newline at end of file
......@@ -24,9 +24,9 @@
class="start"
@click="start"
>
<template v-if="sceneType != 7">
<!-- <template v-if="sceneType != 7">
<view class="sprite-icon icon-start-text"></view>
</template>
</template> -->
</view>
<view class="right-content-box flex">
<view class="content-left">
......@@ -49,18 +49,18 @@
</template>
</view>
</view>
<view class="tool-box box-class">
<!-- <view class="tool-box box-class">
<view class="common-title">展业工具</view>
<view class="content-box">
<Entrance @entranceClick="entranceClick"></Entrance>
</view>
</view>
</view> -->
</view>
<view class="content-right box-class">
<!-- <view class="content-right box-class">
<view class="common-title">服务中心</view>
<view class="content-box">
</view>
</view>
</view> -->
</view>
</view>
<view :class="['app-content-box right-content', { 'show-content-box': tabIndex == 99 }]">
......@@ -160,6 +160,7 @@
</view>
</template>
<script>
import Order from './components/Order/index.vue'
import SceneMarket from './components/SceneMarket/index.vue'
// import myClick from '@/mixin/click'
import timeout from '@/mixin/timeout'
......@@ -175,7 +176,7 @@ import mediaResourceManager from '@/utils/mediaResourceManager/mediaResourceMana
import { interceptionMixin } from '@/mixin/index'
export default {
mixins: [recorder, uploader, timeout, versionCheck, merge, interceptionMixin],
components: { SceneMarket, LeftSide, SwiperComponent, Entrance },
components: { SceneMarket, LeftSide, SwiperComponent, Entrance, Order },
props: {
id: [String, Number],
finishDoneText: String,
......@@ -299,12 +300,13 @@ export default {
this.$emit(name)
},
start () {
const { sceneType } = this
if (sceneType == 7) return //二手车无接待功能
uni.$track.add({
eventCode: 'app_reception_begins'
})
this.$emit('start')
return
// const { sceneType } = this
// if (sceneType == 7) return //二手车无接待功能
// uni.$track.add({
// eventCode: 'app_reception_begins'
// })
// this.$emit('start')
},
async updateApp (requested = false) {
if (!requested) await uni.$api.systemApi.getMockData(true)
......@@ -479,7 +481,8 @@ export default {
}
.right-content-box {
width: 100%;
height: calc(100% - #{toRpx(232)});
// height: calc(100% - #{toRpx(232)});
height: 100%;
gap: toRpx(48);
box-sizing: border-box;
padding: toRpx(32) 0 toRpx(80);
......@@ -504,9 +507,9 @@ export default {
flex-shrink: 0;
}
.content-left {
width: toRpx(1210);
width: calc(100% - #{toRpx(48)});
.module-box {
height: toRpx(664);
height: calc(100% - #{toRpx(235)});
margin-bottom: toRpx(48);
}
.tool-box {
......
const target = ['ip', 'dev', 'uat', 'prod', 'beta']
const index = 1
const index = 2
/**
*
0本地
......
......@@ -23,6 +23,13 @@
}
},
{
"path": "pages/equity/createOrder",
"style": {
"navigationStyle": "custom",
"disableSwipeBack": true
}
},
{
"path": "pages/common/nothing",
"style": {
"navigationBarTitleText": "提示"
......
<template>
<view v-if="show" class="product-list">
<view v-for="(item, index) in list" :key="index" class="product-card">
<view class="delete-btn">
<view class="sprite-icon icon-blue-delete" @click="handleDelete(item)"></view>
</view>
<view class="info">
<view class="name">商品名称:{{ item.describe }}</view>
<view class="price">¥{{ formatPrice(item.price) }} * {{number}}</view>
</view>
<view class="total-price">总价:¥{{ formatPrice(item.price * number) }}</view>
</view>
</view>
</template>
<script>
export default {
props: {
show: {
type:Boolean,
default: false
},
list: {
type: Array,
default: () => []
}
},
data() {
return {
number: 1
}
},
methods: {
formatPrice(val) {
const num = Number(val)
if (isNaN(num)) return '--'
return num.toFixed(2)
},
handleDelete(item) {
console.log(item)
this.$emit('delete', item)
}
}
}
</script>
<style scoped lang="scss">
.product-list {
display: flex;
flex-wrap: wrap;
margin-bottom: toRpx(24);
gap: toRpx(24) toRpx(24);
}
.product-card {
display: flex;
align-items: center;
width: calc((100% - #{toRpx(48)}) / 2);
background: #F5F7FA;
border-radius: toRpx(16);
padding: toRpx(24);
box-sizing: border-box;
}
.delete-btn {
display: flex;
height: 100%;
align-items: center;
margin-right: toRpx(26);
}
.name {
font-size: toRpx(28);
font-weight: 600;
color: #FF781F;
}
.info {
margin-top: toRpx(12);
font-size: toRpx(26);
color: #596170;
}
.total-price {
margin-left: auto;
font-size: toRpx(28);
font-weight: 600;
color: #333;
}
.price {
color: #666;
margin-top: toRpx(14);
}
</style>
<template>
<view class="order-popup">
<popup :position="position" :animation="animation" ref="popup" @onConfirm="confirm" @onCancel="cancel">
<view class="popup-title flex">
{{ title }}
<view class="popup-close flex" @click="close">
<uni-icons type="closeempty" size="16"></uni-icons>
</view>
</view>
<template v-if="hideSearch">
<view class="popup-search">
<input class="input" type="text" placeholder="请输入" placeholder-class="placeholder" v-model="searchValue" confirm-type="search" @confirm="handleSearch" />
<view class="clear flex" @click="clear">
<uni-icons type="closeempty" size="16" v-if="searchValue"></uni-icons>
</view>
</view>
</template>
<view :class="['popup-body', { 'hide-search': hideSearch }]">
<scroll-view scroll-y :class="['popup-scroll-view', { show: loadComplete }]" @scrolltolower="loadMore" lower-threshold="60">
<template>
<view class="shop-list">
<view class="shop-item" v-for="(shop, idx) in renderList" :key="shop.id || idx" @click="selectShop(shop)">
<view class="sprite-icon icon-tag-checked" v-if="isSelected(shop)"></view>
<view class="info-box">
<view class="name">{{ shop.describe }}</view>
<view class="price">¥{{ shop.price }}</view>
</view>
</view>
</view>
</template>
<template v-if="noData">
<view class="nothing flex">暂无数据</view>
</template>
</scroll-view>
<image v-if="!loadComplete" class="loading" src="@/assets/images/common/loadding.gif" />
</view>
</popup>
</view>
</template>
<script>
import Popup from '@/components/Popup.vue'
export default {
components: {
Popup,
},
props: {
title: {
type: String,
default: ''
},
position: {
type: String,
default: 'bottom'
},
animation: {
type: Boolean,
default: true
},
hideSearch: {
type: Boolean,
default: true
},
loadComplete: {
type: Boolean,
default: true
},
shopList: {
type: Array,
default: () => [
// {
// "id": 1,
// "picture": "https://example.com/phone1.jpg",
// "describe": "智能手机A",
// "productSn": "PHONE001",
// "price": "29.99",
// "orderNum": 100,
// "orderTotalAmount": "2999.00",
// "createBy": "admin",
// "updateTime": "2023-10-15 14:30:00"
// },
// {
// "id": 2,
// "picture": "https://example.com/phone2.jpg",
// "describe": "智能手机B",
// "productSn": "PHONE002",
// "price": "19.99",
// "orderNum": 50,
// "orderTotalAmount": "999.50",
// "createBy": "admin",
// "updateTime": "2023-10-14 10:20:00"
// }
]
},
selectList: {
type: Array,
default: () => []
},
api: {
type: String,
default: ''
},
hasPage: {
type: Boolean,
default: false
}
},
data() {
return {
searchValue: '',
tempSelect: [],
renderList: [],
loading: false,
finished: false,
page: {
current: 1,
size: 10,
total: 0
},
noData: false
}
},
methods: {
// 搜索
handleSearch() {
this.$emit('handleSearch', this.searchValue)
this.getList(true, 'name')
},
clear() {
this.searchValue = ''
this.handleSearch()
},
selectShop() {
},
// 弹窗确定
confirm() {
if (this.tempSelect.length === 0) {
uni.showToast({
title: '请选择商品',
icon: 'none'
})
return
}
this.$refs.popup.close()
this.$emit('onConfirm', this.tempSelect)
},
// 弹窗取消
cancel() {
console.log('quxiao')
this.searchValue = ''
// this.$emit('cancel')
this.close()
},
// 弹窗打开
open () {
this.tempSelect = Array.isArray(this.selectList) ? [...this.selectList] : []
if (this.tempSelect.length > 1) this.tempSelect = [this.tempSelect[0]]
this.getList(true)
this.$refs.popup.open()
},
// 弹窗关闭
close () {
this.noData = false
this.$refs.popup.close()
this.$emit('close')
},
selectShop(shop) {
if (!shop) return
// 多选
// const idx = this.tempSelect.findIndex(s => (((s || {}).id) || s) === (((shop || {}).id) || shop))
// if (idx !== -1) {
// this.tempSelect.splice(idx, 1)
// } else {
// this.tempSelect.push(shop)
// }
// 单选
const selected = this.tempSelect[0]
const isSame = (((selected || {}).id) || selected) === (((shop || {}).id) || shop)
this.tempSelect = isSame ? [] : [shop]
},
isSelected(shop) {
return this.tempSelect.some(s => (((s || {}).id) || s) === (((shop || {}).id) || shop))
},
async getList(reset = false, searchKey = 'keyword') {
if (!this.api || !uni.$api || !uni.$api.commonApi || typeof uni.$api.commonApi[this.api] !== 'function') return
const params = {}
if (this.hasPage) {
if (reset) this.page.current = 1
params.pageNum = this.page.current
params.pageSize = this.page.size
}
if (this.searchValue) params[searchKey] = this.searchValue
this.loading = true
try {
const res = await uni.$api.commonApi[this.api](params)
let rows = []
if (Array.isArray(res)) {
rows = res
} else if (Array.isArray(res?.rows)) {
rows = res.rows
this.page.total = Number(res.total || 0)
} else if (Array.isArray(res?.data)) {
rows = res.data
this.page.total = Number(res.total || res.dataTotal || 0)
}
if (this.hasPage && this.page.current > 1 && !reset) {
this.renderList = this.renderList.concat(rows)
} else {
this.renderList = rows
}
this.noData = this.renderList.length === 0
if (this.hasPage) {
const size = this.page.size
this.finished = rows.length < size
}
} finally {
this.loading = false
}
},
loadMore() {
if (!this.hasPage || this.loading || this.finished) return
this.page.current += 1
this.getList(false)
}
}
}
</script>
<style scoped lang="scss">
.popup-title {
height: toRpx(104);
justify-content: center;
position: relative;
color: #333333;
font-size: toRpx(36);
font-weight: 500;
.popup-close {
position: absolute;
height: 100%;
top: 0;
right: 0;
padding: 0 toRpx(48);
font-weight: 400;
color: #1a1a1a;
}
}
.popup-search {
height: toRpx(80);
border-radius: toRpx(40);
background: #f5f7fa;
margin: 0 toRpx(48);
position: relative;
.input {
height: 100%;
width: 100%;
text-align: center;
color: #333;
font-size: toRpx(32);
}
.placeholder {
height: 100%;
color: #999ea8;
font-family: uniicons;
display: flex;
align-items: center;
justify-content: center;
&::after {
display: block;
content: '\e654';
margin-left: toRpx(8);
height: 100%;
display: flex;
align-items: center;
font-size: toRpx(36);
}
}
.clear {
position: absolute;
right: 0;
top: 0;
height: 100%;
padding: 0 toRpx(48);
}
}
.popup-body {
height: calc(100% - #{toRpx(392)});
position: relative;
.popup-scroll-view {
height: 100%;
padding-top: toRpx(32);
opacity: 0;
}
.loading {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: toRpx(64);
height: toRpx(64);
}
.show {
opacity: 1;
}
}
.shop-list {
display: flex;
flex-wrap: wrap;
gap: 0 toRpx(32);
padding: toRpx(24) toRpx(48);
.shop-item {
position: relative;
display: flex;
align-items: center;
justify-content: center;
width: toRpx(538);
height: toRpx(72);
border: 1px solid #DCE0E6;
border-radius: toRpx(8);
margin-bottom: toRpx(24);
.sprite-icon {
position: absolute;
top: 0;
right: 0;
}
}
.info-box {
display: flex;
justify-content: space-between;
width: 100%;
padding: 0 toRpx(24);
}
}
.nothing {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 2;
justify-content: center;
}
</style>
\ No newline at end of file
<template>
<view class="detail-box">
<view class="nav-bar">
<view class="back" @click="backPage">
<uni-icons type="left" :size="20" color="#000"></uni-icons>
</view>
<view class="title">{{ title }}</view>
</view>
<view class="detail-content">
<GlCell :formList="formList" :formData="orderObj" @handleCell="handleCell">
<template slot="shop">
<Product :show="!!orderObj.shopList.length" @delete="onDelete" :list="orderObj.shopList"></Product>
</template>
</GlCell>
<view @click="submit" class="btn">直接下单</view>
</view>
<ShopPopup ref="shopPopup" :title="shopTitle" api="getProductList" :hasPage="true" :selectList="orderObj.shopList" @onConfirm="onConfirm"></ShopPopup>
</view>
</template>
<script>
import GlCell from '@/components/Form/GlCell.vue'
import ShopPopup from './components/ShopPopup.vue'
import Product from './components/Product.vue'
import dayjs from 'dayjs';
export default {
components: {
GlCell,
ShopPopup,
Product
},
data() {
return {
title: '新建工单',
shopTitle: '商品列表',
orderObj: {
purchaser: '胡悦',
phone: '13800000000',
shopList: [],
totaPrice: 0
// {
// "id": 1,
// "picture": "https://example.com/phone1.jpg",
// "describe": "智能手机A",
// "productSn": "PHONE001",
// "price": "29.99",
// "orderNum": 100,
// "orderTotalAmount": "2999.00",
// "createBy": "admin",
// "updateTime": "2023-10-15 14:30:00"
// },
// {
// "id": 2,
// "picture": "https://example.com/phone2.jpg",
// "describe": "智能手机B",
// "productSn": "PHONE002",
// "price": "19.99",
// "orderNum": 50,
// "orderTotalAmount": "999.50",
// "createBy": "admin",
// "updateTime": "2023-10-14 10:20:00"
// }
// ]
},
formList: [
[
{
label: '购买人',
value: 'purchaser',
type: 'input',
required: true,
},
{
label: '联系方式',
value: 'phone',
type: 'input',
inputType: 'number',
required: true,
maxlength: 11
},
{
label: '选择商品',
value: 'shopList',
type: 'select',
required: true,
fullRow: true,
addHtml: 'shop',
noBorder: true
},
{
label: '商品总价',
value: 'totaPrice',
// addHtml: 'totaPrice',
fullRow: true,
hidden: true
},
]
]
}
},
methods: {
backPage() {
console.log('back')
uni.navigateBack({
delta: 1
})
},
handleCell(e) {
console.log(e)
if (e.value === 'shopList') {
this.$refs.shopPopup.open()
}
},
onConfirm(val) {
this.orderObj.shopList = val
this.getTotalPrice()
this.$set(this.formList[0][3], 'hidden', false)
},
// 删除商品
onDelete(item) {
console.log(item.id)
this.orderObj.shopList = this.orderObj.shopList.filter(shop => shop.id != item.id)
console.log(this.orderObj.shopList)
if (this.orderObj.shopList.length == 0) {
this.$set(this.formList[0][3], 'hidden', true)
}
this.getTotalPrice()
},
// 计算总价
getTotalPrice() {
let total = 0
const number = 1
this.orderObj.shopList.forEach(shop => {
total += Number(shop.price) * number
})
this.orderObj.totaPrice = this.formatPrice(total)
},
formatPrice(val) {
const num = Number(val)
if (isNaN(num)) return '--'
return num.toFixed(2)
},
async submit() {
// 校验购买人
if (!this.orderObj.purchaser) {
uni.showToast({
title: '请完善购买人信息',
icon: 'none'
})
return
}
// 校验联系方式
if (!this.orderObj.phone) {
uni.showToast({
title: '请完善联系方式',
icon: 'none'
})
return
}
// 校验商品信息
if (!this.orderObj.shopList || this.orderObj.shopList.length === 0) {
uni.showToast({
title: '请选择商品',
icon: 'none'
})
return
}
// 手机号格式校验
if (!/^1[3-9]\d{9}$/.test(this.orderObj.phone)) {
uni.showToast({
title: '请输入正确的手机号',
icon: 'none'
})
return
}
const params = {
orderTime: dayjs().format('YYYY-MM-DD HH:mm:ss'),
orderStatus: '已支付',
purchaser: this.orderObj.purchaser,
phone: this.orderObj.phone,
deptId: 1001,
userId: 10086,
source: 'pad',
productName: this.orderObj.shopList[0].describe,
productUrl: this.orderObj.shopList[0].picture,
productUnitPrice: this.orderObj.shopList[0].price,
amount: 1, // 默认1
totalPrice: this.orderObj.totaPrice,
actualPayment: this.orderObj.totaPrice,
returnedMoneyType: '微信支付',
returnedMoney: this.orderObj.totaPrice,
returnedDate: dayjs().format('YYYY-MM-DD HH:mm:ss'),
payer: this.orderObj.purchaser,
status: 1,
externalUserid: 'woAJ2GCAAAXtWyujaWJHDDGi0mACAAA'
}
const res = await uni.$api.commonApi.addOrder(params)
if (res.code == 200) {
uni.showToast({
title: '提交成功',
icon: 'success'
})
uni.$emit('ORDER_LIST_REFRESH')
setTimeout(() => {
uni.navigateBack({
delta: 1
})
}, 1500)
} else {
uni.showToast({
title: res.msg,
icon: 'none'
})
}
}
}
}
</script>
<style scoped lang="scss">
.detail-content {
width: 100%;
height: calc(100% - #{toRpx(64)});
border-radius: toRpx(48);
box-sizing: border-box;
overflow: hidden;
background: #f1f4ff;
backdrop-filter: blur(toRpx(16));
box-shadow: inset 0 0 toRpx(16) 0 #ffffff;
padding: 0 toRpx(48);
box-sizing: border-box;
position: relative;
&::after {
content: '';
position: absolute;
left: 0;
top: 0;
z-index: -2;
width: 100%;
height: toRpx(120);
background: linear-gradient(0deg, #94c2ff00 0%, #5294ff 100%);
opacity: 0.15;
}
}
.btn {
position: fixed;
bottom: toRpx(48);
display: flex;
align-items: center;
justify-content: center;
margin: toRpx(88) auto 0;
width: calc(100% - #{toRpx(96)});
height: toRpx(80);
color: #fff;
border-radius: toRpx(48);
background: linear-gradient(0deg, #2c66f7 0%, #48a6ff 100%);
}
</style>
\ No newline at end of file
......@@ -51,7 +51,7 @@ export default {
},
sceneType () {
const { sceneType } = uni.$storage.get('userInfo')
return sceneType
return 1
}
},
onBackPress (options) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!