commonCell.vue 3.3 KB
<template>
	<view class="box">
		<u-cell-group v-if="headTitle !== ''" :border="false">
			<u-cell :title="headTitle" :titleStyle="{color: '#333', fontSize: '24rpx'}">
				<text slot="right-icon" style="font-size: 24rpx;font-weight: 500;" :style="{color: colorState(state)}">{{ orderState(state) }}</text>
			</u-cell>
		</u-cell-group>
		<view class="orderInfo">
			<view class="order_line" :class="{isBorder: border}" v-for="(item, index) in lineInfo" :key="index">
				<text class="left_text">{{ item.title }}</text>
				<u-avatar v-if="item.type === 'avatar'" :src="userInfo[item.valueName]"></u-avatar>
				<text v-if="item.type === 'text'">{{ item.valueName }}</text>
				<u--input
					v-if="item.type === 'input'"
					:customStyle="{border: 0, width: '200rpx'}"
					:placeholder="userInfo[item.valueName]"
					v-model="userInfo[item.valueName]"
					inputAlign="right"
					color="#333"
					fontSize="13px"
					border="surround"
					@blur="UpdataInfo"
				/>
			</view>
		</view>
		<u-cell-group v-if="rightTitle !== ''" :border="false">
			<u-cell :title="rightTitle" :titleStyle="{color: '#666', fontSize: '24rpx'}">
				<MyButton v-show="state === 2"  slot="right-icon" title="立即支付" size="small"></MyButton>
				<MyButton v-show="state === 1" slot="right-icon" title="取消/退款" size="small" color="#666666" bgColor="#F6F6F6"></MyButton>
				<MyButton v-show="state === 3" slot="right-icon" size="small" title="去评价"></MyButton>
				<MyButton v-show="state === 6" slot="right-icon" size="small" title="亮核销码" @comfirn="showQR"></MyButton>
			</u-cell>
		</u-cell-group>
	</view>
</template>

<script>
	import MyButton from '@/components/myButton.vue'
	import ThemeColor from '@/utils/themeColor'
	export default {
		props: {
			lineInfo: {
				type: Array,
				require: true
			},
			border: {
				type: Boolean,
				default: false
			},
			headTitle: {
				type: String,
				default: ''
			},
			rightTitle: {
				type: String,
				default: ''
			},
			state: {
				type: Number,
				default: 0
			}
		},
		components: { MyButton },
		data(){
			return {
				userInfo: {
					avatar: 'https://cdn.uviewui.com/uview/album/1.jpg',
					nickname: 'CLOOL',
					sex: '男',
					phoneNum: '13336668888',
					Birthday: '1999-12-26'
				},
			}
		},
		computed: {
			orderState(){
				return (index) => {
					let orderObj ={
						1: '已完成',
						2: '待支付',
						3: '待评价',
						4: '已取消',
						5: '退款/售后',
						6: '待使用'
					}
					return orderObj[index]
				}
			},
			colorState(){
				return (index) => {
					let colorObj ={
						1: ThemeColor.PrimaryColor,
						2: '#F33B10',
						3: ThemeColor.PrimaryColor,
						4: '#999999',
						5: '#F33B10',
						6: '#999999'
					}
					return colorObj[index]
				}
			}
		},
		methods: {
			UpdataInfo(value){
				this.$emit('updataInfo', this.userInfo)
			},
			showQR(){
				this.$emit('showQRcode', true)
			}
		}
	}
</script>

<style lang="scss" scoped>
	.box{
		background: #FFFFFF;
		border-radius: 12rpx;
		box-sizing: border-box;
	}
	.orderInfo{
		padding: 0 30rpx;
		.order_line{
			display: flex;
			align-items: center;
			justify-content: space-between;
			height: 90rpx;
			font-size: 26rpx;
			color: #333;
			&.isBorder {
				border-bottom: 2rpx solid #E1E1E1;
			}
			&:last-child{
				border-bottom: 0;
			}
			.left_text{ 
				color: #666;
			}
		}
	}
</style>