<template>
	<view class="page-container">
		<view class="container-box">
			<swiper indicator-dots style="height: 120rpx;" autoplay indicator-active-color="#fff">
				<swiper-item>
					<image :src="globalData.locImg+'/banner_1.png'" style="width: 100vw;height: 120rpx;"></image>
				</swiper-item>
				<swiper-item>
					<image :src="globalData.locImg+'/banner_2.png'" style="width: 100vw;height: 120rpx;"></image>
				</swiper-item>
			</swiper>
			<view class="info-box">
				<rich-text
					nodes="<span style='font-size:16px;font-weight:bold;'>系统全称</span><span style='font-size:12px;'> (软著名称)</span>"></rich-text>
				<textarea :value="projectName" @input="inputProjectName" class="info-value"
					placeholder="请输入系统全称(注:建议以'软件''平台''系统'等字眼结尾)" placeholder-style="font-size:14px;"></textarea>
				<view class="info-btn" @click="doCommendProjectName">推荐</view>
			</view>
			<view class="content-box">
				<!-- 第一部分 -->
				<text style="box-title">基本信息</text>
				<view class="item">
					<text class="item-title star">产权联系人</text>
					<view class="item-content">
						<picker style="flex:1;" mode="selector" :range="contactList" range-key="name"
							@change="doChangeContact">
							<view style="display: flex;flex-direction: row;align-items: center;">
								<view class="icon-user-default-blue size-48"></view>
								<view style="display: flex;flex-direction: column;margin-left: 15rpx;flex:1;">
									<text style="font-size: 24rpx;color:$text-color;">{{selectContact.name}}</text>
									<text
										style="font-size: 22rpx;margin-top: 5rpx;">{{phoneNum(selectContact.phone,3,4,'****')}}</text>
								</view>
								<view class="icon-arrow-solid mr-20"></view>
							</view>
						</picker>
						<view style="display: flex;flex-direction: row;align-items: center;" @click="doCreateContact">
							<view class="icon-add-circle-blue size-32"></view>
							<view class="link ml-10">新建</view>
						</view>
					</view>
				</view>
				<view class="item">
					<text class="item-title star">系统版本</text>
					<input class="item-content" :class="version != '' ? 'v-select':''" placeholder="v1.0"
						style="flex:1;" :value="version" @input="inputVersion" />
				</view>
				<view class="item">
					<text class="item-title star">系统语言</text>
					<view class="item-content">
						<view class="language-sel" :class="selectLang != ''? 'v-select':''" @click="doShowLang">
							{{selectLang}}
						</view>
						<view class="icon-arrow-solid"></view>
					</view>
				</view>
				<view class="item">
					<text class="item-title">开发完成时间</text>
					<view class="item-content">
						<picker mode="date" style="flex:1;" :value="completeDate" start="2010-01-01" end="2050-01-01"
							@change="bindDateChange">
							<view class="select-time" :class="completeDate ==''? 'value-hint':''">
								{{completeDate != ''? completeDate:'请选择开发完成时间'}}
							</view>
						</picker>
						<view style="display: flex;flex-direction: row;">
							<view v-if="completeDate !=''" @click="clearTime" class="icon-clear"
								style="height: 32rpx;width: 32rpx;margin-right: 10rpx;">
							</view>
							<view v-if="completeDate==''" class="icon-calendar-ind"
								style="height: 32rpx;width: 32rpx;margin-right: 10rpx;">
							</view>
						</view>
					</view>
				</view>
			</view>
			<view class="content-box">
				<text class="box-title">套餐与优惠</text>
				<view class="item" v-if="canSelPackage">
					<text class="item-title">套餐包</text>
					<view class="item-content">
						<text :class="!isEmpty(selectPackage) ? 'v-select':'v-normal'" style="flex: 1;"
							@click="doShowPackage">{{selectPackage.packageName?selectPackage.packageName:'请选择套餐包'}}</text>
						<view class="icon-arrow-solid mr-20"></view>
						<text v-if="!isEmpty(selectPackage)" class="link" @click="clearSelectPackageOrCoupons">取消</text>
					</view>
				</view>
				<view class="item" v-if="canSelCoupons">
					<text class="item-title">优惠券</text>
					<view class="item-content">
						<text @click="doShowCoupons" style="flex: 1;"
							:class="!isEmpty(selectCoupons)? 'v-select':'v-normal'">{{selectCoupons.couponId? selectCoupons.coupon.title : '请选择优惠券'}}</text>
						<view class="icon-arrow-solid mr-20"></view>
						<text class="link" v-if="!isEmpty(selectCoupons)" @click="clearSelectPackageOrCoupons">取消</text>
					</view>
				</view>
			</view>
		</view>
		<view class="bottom-fixed-footer">
			<view class="money">
				<view>金额:<text class="price">{{price/100}}元</text></view>
				<checkbox-group @change="doUrgent" v-if="isShowUrgent">
					<checkbox :checked="isUrgent" color="#FFA900" class="round yellow"
						style="transform: scale(0.7);transform-origin: left center;margin-left: 8rpx;"
						:disabled="isUrgentDisable">
						<text
							style="color: $text-brown-color;padding-left: 8rpx;font-size:30rpx;">加急办理{{urgent/100}}元</text>
					</checkbox>
				</checkbox-group>
			</view>
			<view class="bottom-btn-green" @click="doCreateProject">保存并付款</view>
		</view>
		<view>
			<!-- 推荐项目名称 -->
			<uni-popup ref="commendDialog" type="bottom" background-color="#fff" border-radius="15rpx 15rpx 0rpx 0rpx">
				<view class="bottom-dialog-container">
					<view class="dialog-title-box">
						<view class="icon-close size-48" @click="closeCommendDialog"></view>
						<view class="dialog-title-txt has-icon">项目名称</view>
					</view>
					<textarea @input="inputProjectName" placeholder="请简单介绍您想创建的系统，我们会根据您的描述为您推荐系统全称"
						class="commend-text-area"></textarea>
					<scroll-view scroll-y style="height: 300rpx;">
						<view class="project-box">
							<block v-for="(item,index) in projectNameList" :key="index">
								<view class="project-item" @click="doSelectProjectName" :data-value="item">{{item}}
								</view>
							</block>
						</view>
					</scroll-view>
					<view class="bottom-btn-green" @click="doCreateFullName">生成</view>
				</view>
			</uni-popup>
			<!-- 新建联系人 -->
			<uni-popup ref="createContactDialog" type="bottom" background-color="#fff"
				border-radius="15rpx 15rpx 0rpx 0rpx">
				<view class="bottom-dialog-container">
					<view class="dialog-title-box">
						<view class="icon-close size-48" @click="closeCreateContact"></view>
						<view class="dialog-title-txt has-icon">新建联系人</view>
					</view>
					<view class="form-box">
						<view class="form-item">
							<view class="form-item-title star">姓&emsp;&emsp;名</view>
							<input :adjust-position="true" :cursor-spacing="50" :value="contactName" placeholder="请输入姓名"
								class="form-item-content" @input="inputContactName" />
						</view>
						<view class="form-item">
							<view class="form-item-title star">联系电话</view>
							<input :adjust-position="true" :cursor-spacing="50" :value="contactPhone"
								placeholder="请输入联系电话" class="form-item-content" @input="inputContactPhone" />
						</view>
						<view class="form-item">
							<view class="form-item-title">联系邮箱</view>
							<input :adjust-position="true" :cursor-spacing="50" :value="contactEmail"
								placeholder="请输入联系邮箱" class="form-item-content" @input="inputContactEmail" />
						</view>
						<view class="form-item">
							<view class="form-item-title">公&emsp;&emsp;司</view>
							<input :adjust-position="true" :cursor-spacing="50" :value="contactCompany"
								placeholder="请输入公司名称" class="form-item-content" @input="inputContactCompany" />
						</view>
					</view>
					<view class="bottom-btn-green" @click="doSaveContact">保存</view>
				</view>
			</uni-popup>
			<!-- 语言选择 -->
			<uni-popup ref="selectLangDialog" type="bottom" background-color="#fff"
				border-radius="15rpx 15rpx 0rpx 0rpx">
				<view class="bottom-dialog-container">
					<view class="dialog-title-box">
						<view class="icon-close size-48" @click="closeLangDialog"></view>
						<view class="dialog-title-txt has-icon">系统语言</view>
					</view>
					<view class="coupons-list-box">
						<scroll-view scroll-y style="height: 400rpx;">
							<radio-group style="display: flex;flex-direction: column;width: 100vw;"
								@change="changeLang">
								<block v-for="(item,index) in langList" :key="index">
									<radio style="margin-top: 10rpx;" :checked="selectLang==item" :value="item">
										<view style="margin-left: 20rpx;text-align: center;padding: 15rpx 0rpx;">
											{{item}}
										</view>
									</radio>
								</block>
							</radio-group>
						</scroll-view>
					</view>
					<view class="bottom-btn-green" @click="doConfirmLang">确定</view>
				</view>
			</uni-popup>
			<!-- 套餐包弹窗 -->
			<uni-popup ref="selPackageDialog" type="bottom" background-color="#fff"
				border-radius="15rpx 15rpx 0rpx 0rpx">
				<view class="bottom-dialog-container">
					<view class="dialog-title-box">
						<view class="icon-close size-48" @click="closePackage"></view>
						<view class="dialog-title-txt has-icon">套餐包</view>
					</view>
					<view style="display: flex;flex-direction: column;padding: 20rpx;">
						<scroll-view scroll-y style="height: 500rpx;">
							<view class="coupons-list-box">
								<radio-group @change="radioSelPackage">
									<block v-for="(item,index) in packageList" :key="index">
										<view class="tickets" @click="choosePackage" :data-value="item">
											<view class="l-tickets">
												<view class="ticket-title">
													<view>套餐包</view>
													<view>剩余{{item.packageTotalSurplusCount}}件</view>
												</view>
												<view class="ticket-content">{{item.packageInfoAppDTO.packageName}}
												</view>
												<view class="ticket-desc">{{item.packageInfoAppDTO.packageDescription}}
												</view>
											</view>
											<view class="r-tickets">
												<radio style="margin-left: 5px;" :value="index+''"
													:checked="tempPackage.packageInfoId==item.packageInfoId">
												</radio>
											</view>
										</view>
									</block>
								</radio-group>
							</view>
						</scroll-view>
					</view>
					<view class="bottom-btn-green" @click="doConfirmPackage">确定</view>
				</view>
			</uni-popup>

			<!-- 优惠卷弹窗 -->
			<uni-popup ref="selCouponsDialog" type="bottom" background-color="#fff"
				border-radius="15rpx 15rpx 0rpx 0rpx">
				<view class="bottom-dialog-container">
					<view class="dialog-title-box">
						<view class="icon-close size-48" @click="closeCoupons"></view>
						<view class="dialog-title-txt has-icon">优惠卷</view>
					</view>
					<view style="display: flex;flex-direction: column;padding: 20rpx;">
						<scroll-view scroll-y style="height: 500rpx;">
							<view class="coupons-list-box">
								<radio-group @change="radioSelCoupons">
									<block v-for="(item,index) in couponsList" :key="index">
										<view class="tickets" @click="chooseCoupons" :data-value="item">
											<view class="l-tickets">
												<view class="ticket-title">
													<view
														style="display: flex;flex-direction: row;justify-content: center;align-items: center;">
														<view class="coupons-icon" style="width: 24px;height: 24px;">
														</view>
														<text>优惠卷</text>
													</view>
													<view>减{{item.coupon.amount/100}}元</view>
												</view>
												<view class="ticket-content">{{item.coupon.title}}</view>
												<view class="ticket-desc">
													有效期:{{item.coupon.useGmtStart}}至{{item.coupon.useGmtEnd}}</view>
											</view>
											<view class="r-tickets">
												<radio style="margin-left: 5px;" :value="index+''"
													:checked="tempCoupons.couponId==item.couponId">
												</radio>
											</view>
										</view>
									</block>
								</radio-group>
							</view>
						</scroll-view>
					</view>
					<view class="bottom-btn-green" @click="doConfirmCoupons">确定</view>
				</view>
			</uni-popup>
			<uni-popup type="message" ref="msg">
				<uni-popup-message :type="msgType" :message="msgTxt" :duration="2000"></uni-popup-message>
			</uni-popup>
		</view>
	</view>
</template>

<script>
	import ProApi from '@/common/js/net/projectApi.js'
	import UserApi from '@/common/js/net/UserApi.js'
	import {
		formatDate
	} from '@/common/js/util.js'
	import {
		isEmpty,
		objIsEmpty,
		phoneNum
	} from '@/common/js/conver.js'
	import {
		isValidPhone,
		isValidEmail
	} from '@/common/js/validator.js'
	import {
		inject
	} from 'vue'
	export default {
		setup() {
			const globalData = inject('globalData')
			return {
				globalData
			}
		},
		data() {
			return {
				msgType: 'info',
				msgTxt: '',
				completeDate: '', //开发完成时间
				version: "v1.0", //系统版本
				type: 'ALL', //默认全托管  上级页面传递type参数   all全托管  material写材料  
				languageList: ['JAVA'],
				currentLanguage: 'JAVA', //当前选中的语言
				price: 0,
				packageList: [], //套餐包
				tempPackage: {}, //临时选中的优惠卷,没有点击确定按钮前
				selectPackage: {}, //选中的套餐包
				couponsList: [], //优惠卷
				selectCoupons: {}, //选中的优惠卷
				tempCoupons: {}, //临时选中的优惠卷,没有点击确定按钮
				contactList: [], //联系人
				selectContact: {}, //当前选中的联系人
				contactPhone: '', //联系人电话
				contactName: '', //联系人姓名
				contactEmail: '', //联系人邮箱
				contactCompany: '', //联系人公司
				csaNo: '', //客服NO
				projectName: '',
				projectNameList: [],
				isUrgent: false, //是否加急
				canSelCoupons: true, //是否可以使用优惠卷
				canSelPackage: true, //是否可以使用套餐包
				langList: [], //项目语言
				showLang: false, //显示选择语言
				tempLang: '', //临时选中的语言
				selectLang: '',
				isShowUrgent: true, //是否加急
				urgent: 0, //加急费用
				isUrgentDisable: false, //是否禁用加急
				proPrice: 0, //价格
				transmitPId: '', //传递过来的套餐包ID
			}
		},
		onLoad(options) {
			uni.setNavigationBarTitle({
				title: '创建软著',
			})
			uni.setNavigationBarColor({
				frontColor: '#000000', // 必写项，字体颜色仅支持#ffffff和#000000
				backgroundColor: '#F0F0F0', // 传递的颜色值，仅支持十六进制颜色
				animation: { // 可选项
					duration: 500,
					timingFunc: 'easeIn'
				}
			})
			const typeParams = options.type //类型
			const priceParams = options.price //价格
			const isUrgentParams = options.isUrgent //是否加急
			const pId = options.pId //套餐包ID
			console.log(priceParams)
			if (priceParams && priceParams > 0) {
				this.price = priceParams
				this.proPrice = priceParams
				this.type = typeParams
				this.isUrgent = isUrgentParams
				this.transmitPId = pId
			} else {
				this.msgType = 'error'
				this.msgTxt = '数据有误,请稍后重试'
				this.$refs.msg.open()
				setTimeout(() => {
					uni.navigateBack()
				}, 1500);
			}
			if (this.type == 'ALL') {
				this.isShowUrgent = true
				this.isUrgent = false
			} else {
				this.isShowUrgent = false
			}
			console.log('是否加急:', this.isUrgent);
			//获取项目联系人
			this.doGetContactList()
			//获取套餐包
			this.doGetPackage()
			//获取优惠卷
			this.doGetCoupons()
			//获取客服ID
			this.doGetCsaNo(false)
			//获取可选语言
			this.doGetProLangList()
			//获取加急等费用
			this.doGetPrice()
		},
		methods: {
			// 导入的方法
			isEmpty,
			phoneNum,
			isValidPhone,
			isValidEmail,
			// 关闭dialog
			closeCommendDialog() {
				this.$refs.commendDialog.close()
			},
			closeCreateContact() {
				this.$refs.crateContactDialog.close()
			},
			closeLangDialog() {
				this.$refs.selectLangDialog.close()
			},
			//关闭dialog  End
			//获取产权联系人
			doGetContactList() {
				uni.showLoading({
					title: '加载中...',
				})
				const _self = this
				ProApi.doGetContactList()
					.then(res => {
						uni.hideLoading()
						_self.contactList = res
						_self.selectContact = res[0]
					})
					.catch(err => {
						uni.hideLoading()
					})
			},
			//获取套餐包
			doGetPackage() {
				const _self = this
				const data = {
					page: 1,
					rows: 100,
					packageType: _self.type,
					keyong: 1,
				}
				ProApi.doGetPackageList(data)
					.then(res => {
						_self.packageList = res.rows
						if (_self.transmitPId != '' && _self.transmitPId != 'undefined') {
							res.rows.map(item => {
								if (item.packageInfoId == _self.transmitPId) {
									_self.selectPackage = item
									_self.showPackage = false
									_self.tempPackage = {}
									_self.canSelCoupons = false
									_self.selectCoupons = {}
									_self.tempCoupons = {}
									_self.isUrgent = false //取消加急
									_self.isUrgentDisable = true //加急不能选择
									_self.price = 0
								}
							})
						}
					})
					.catch(err => {
						_self.packageList = []
					})
			},
			//获取优惠卷
			doGetCoupons() {
				const _self = this
				const data = {
					page: 1,
					rows: 100,
					isEffective: 1,
					isUsed: 0
				}
				ProApi.doGetCouponseList(data)
					.then(res => {
						_self.couponsList = res.rows
					})
					.catch(err => {
						_self.couponsList = []
					})
			},
			//获取客服NO,用于创建联系人
			doGetCsaNo(isShow) {
				const _self = this
				UserApi.doGetCsaNo()
					.then(res => {
						_self.csaNo = res.csaNo
						if (isShow) {
							//TODO 显示创建联系人弹窗
						}
					})
					.catch(err => {
						_self.msgTxt = '获取客服失败,请稍后重试'
						_self.msgType = 'error'
						_self.$refs.msg.open()
					})
			},
			//获取可选语言
			doGetProLangList() {
				const _self = this
				ProApi.doGetProLangList()
					.then(res => {
						_self.langList = res
						_self.selectLang = res[0]
					})
					.catch(err => {
						console.log(err)
					})
			},
			//获取单价
			doGetPrice() {
				uni.showLoading({
					title: '加载中...',
				})
				const _self = this
				ProApi.doGetPrice()
					.then(res => {
						console.log(res)
						_self.urgent = res.additional.urgent //加急办理
					})
					.catch(err => {
						_self.msgTxt = '数据有误,请稍后重试'
						_self.msgType = 'error'
						_self.$refs.msg.open()
						setTimeout(() => {
							uni.navigateBack()
						}, 1500)
					})
			},
			//项目名称输入
			inputProjectName(e) {
				var value = e.detail.value;
				var hasSingle = value.includes("'");
				this.projectName = value
				if (hasSingle) {
					this.projectName = value.replace(/'/g, '')
					this.msgTxt = '项目名称中不能存在英文单引号,请去除'
					this.msgType = 'error'
					this.$refs.msg.open()
				}
			},
			//选中推荐的系统名称
			doSelectProjectName(e) {
				this.projectName = e.currentTarget.dataset.value
				this.projectNameList = []
				this.$refs.commendDialog.close()
			},
			//显示推荐项目名称
			doCommendProjectName() {
				this.$refs.commendDialog.open()
			},
			//获取推荐的项目名称
			doCreateFullName() {
				const _self = this
				uni.showLoading({
					title: '生成中...',
				})
				const data = {
					prompt: _self.projectName
				}
				ProApi.doGetCommendProjectName(data)
					.then(res => {
						uni.hideLoading()
						console.log(res)
						if (res && res.length > 0) {
							_self.projectNameList = res
						} else {
							_self.msgTxt = '未查询到相关推荐的系统名称,请重新输入'
							_self.msgType = 'error'
							_self.$refs.msg.open()
						}
					}, err => {
						uni.hideLoading()
						_self.msgTxt = '未查询到相关推荐的系统名称,请重新输入'
						_self.msgType = 'error'
						_self.$refs.msg.open()
					})
			},
			//选中项目联系人
			doChangeContact(e) {
				this.selectContact = this.contactList[e.detail.value]
			},
			//显示新建联系人弹窗
			doCreateContact() {
				this.$refs.createContactDialog.open()
			},
			//监听输入版本
			inputVersion(e) {
				this.version = e.detail.value
			},
			//显示系统语言弹窗
			doShowLang() {
				this.$refs.selectLangDialog.open()
			},
			//切换系统语言
			changeLang(e) {
				this.tempLang = e.detail.value
			},
			//确定选中系统语言
			doConfirmLang() {
				const _self = this
				if (_self.tempLang != '') {
					_self.selectLang = _self.tempLang
					_self.tempLang = ''
				}
				_self.$refs.selectLangDialog.close()
			},
			//时间切换
			bindDateChange(e) {
				this.completeDate = e.detail.value
			},
			//清除完成时间
			clearTime() {
				console.log('清除时间');
				this.completeDate = ''
			},
			//显示套餐包弹窗
			doShowPackage() {
				const _self = this
				if (_self.packageList.length > 0) {
					_self.tempPackage = _self.selectPackage
					_self.$refs.selPackageDialog.open()
				} else {
					_self.msgTxt = '您暂时没有可以使用的套餐包'
					_self.msgType = 'error'
					_self.$refs.msg.open()
				}
			},
			//关闭套餐包弹窗
			closePackage() {
				this.$refs.selPackageDialog.close()
			},
			//点击选择套餐包
			choosePackage(e) {
				this.tempPackage = e.currentTarget.dataset.value
			},
			//点击radio
			radioSelPackage(e) {
				this.tempPackage = this.packageList[e.detail.value]
			},
			//确定选中的套餐包
			doConfirmPackage() {
				this.selectPackage = this.tempPackage
				this.tempPackage = {}
				this.canSelCoupons = false
				this.selectCoupons = {}
				this.tempCoupons = {}
				this.isUrgent = false //取消加急
				this.isUrgentDisable = true //加急不能选择
				this.countPrice()
				this.$refs.selPackageDialog.close()
			},
			//请空选中的套餐包或优惠卷
			clearSelectPackageOrCoupons() {
				this.selectCoupons = {}
				this.selectPackage = {}
				this.tempCoupons = {}
				this.tempPackage = {}
				this.canSelCoupons = true
				this.canSelPackage = true
				this.isUrgent = false //取消加急
				this.isUrgentDisable = false //加急可以选择
				this.countPrice()
			},
			//显示优惠卷弹窗
			doShowCoupons() {
				if (this.couponsList.length <= 0) {
					this.msgType = 'error'
					this.msgTxt = '您暂时没有可以使用的优惠卷'
					this.$refs.msg.open()
				} else {
					this.$refs.selCouponsDialog.open()
				}
			},
			//关闭优惠卷弹窗
			closeCoupons() {
				this.$refs.selCouponsDialog.close()
			},
			//确定选中的优惠卷
			doConfirmCoupons() {
				const _self = this
				_self.selectCoupons = _self.tempCoupons
				_self.tempCoupons = {}
				_self.canSelPackage = false
				_self.selectPackage = {}
				_self.tempPackage = {}
				_self.countPrice()
				this.$refs.selCouponsDialog.close()
			},
			//切换优惠卷
			chooseCoupons(e) {
				this.tempCoupons = e.currentTarget.dataset.value
			},
			//radio点击
			radioSelCoupons(e) {
				this.tempCoupons = this.couponsList[e.detail.value]
			},
			//是否加急
			doUrgent() {
				const _self = this
				_self.isUrgent = !_self.isUrgent
				_self.countPrice()
			},
			//新建联系人姓名监听
			inputContactName(e) {
				this.contactName = e.detail.value
			},
			//新建联系人电话监听
			inputContactPhone(e) {
				console.log(e)
				this.contactPhone = e.detail.value
			},
			//新建联系人公司监听
			inputContactCompany(e) {
				this.contactCompany = e.detail.value
			},
			//新建联系人邮箱监听
			inputContactEmail(e) {
				this.contactEmail = e.detail.value
			},
			//保存新建联系人
			doSaveContact() {
				const _self = this
				if (_self.contactName == '') {
					_self.msgTxt = '请输入联系人姓名'
					_self.msgType = 'error'
					_self.$refs.msg.open()
					return
				}
				if (_self.contactPhone == '' || !isValidPhone(_self.contactPhone)) {
					_self.msgTxt = '请输入正确的联系电话'
					_self.msgType = 'error'
					_self.$refs.msg.open()
					return
				}
				if (_self.contactEmail != '') {
					if (!isValidEmail(_self.contactEmail)) {
						_self.msgTxt = '请输入正确的邮箱'
						_self.msgType = 'error'
						_self.$refs.msg.open()
						return
					}
				}
				const data = {
					company: _self.contactCompany,
					csaNo: _self.csaNo,
					name: _self.contactName,
					phone: _self.contactPhone,
					email: _self.contactEmail
				}
				uni.showLoading({
					title: '创建中...'
				})
				UserApi.doCreateContact(data)
					.then(res => {
						uni.hideLoading()
						_self.msgTxt = '新建成功'
						_self.msgType = 'success'
						_self.$refs.msg.open()
						_self.$refs.createContactDialog.close()
						_self.contactEmail = ''
						_self.contactPhone = ''
						_self.contactName = ''
						_self.contactCompany = ''
						//获取一遍联系人
						_self.doGetContactList()
					})
					.catch(err => {
						console.log(err)
						uni.hideLoading()
						_self.msgTxt = err.msg ? err.msg : '新建失败,请稍后重试'
						_self.msgType = 'error'
						_self.$refs.msg.open()
						// _self.$refs.crateContactDialog.close()
					})
			},
			//计算价格
			countPrice() {
				const _self = this;
				const trPrice = Number(_self.proPrice);
				let newPrice;

				if (!objIsEmpty(_self.selectPackage)) {
					newPrice = 0;
				} else {
					const isAllType = _self.type === 'ALL';
					const hasCoupon = !objIsEmpty(_self.selectCoupons);
					const isUrgent = _self.isUrgent;

					const couponAmount = hasCoupon ? Number(_self.selectCoupons.coupon.amount) : 0;
					const urgentFee = isAllType && isUrgent ? Number(_self.urgent) : 0;

					newPrice = trPrice + urgentFee - couponAmount;
				}
				_self.price = Math.max(0, newPrice);
			},
			//校验参数
			doCheckProjectParams() {
				const _self = this
				if (_self.projectName == '') {
					_self.msgTxt = '请输入项目名称'
					_self.msgType = 'error'
					_self.$refs.msg.open()
					return false
				}
				if (_self.projectName.includes("'")) {
					_self.msgTxt = '请去除项目名称中的英文单引号'
					_self.msgType = 'error'
					_self.$refs.msg.open()
					return false
				}
				if (Object.keys(_self.selectContact).length <= 0) {
					_self.msgTxt = '请选中产权联系人'
					_self.msgType = 'error'
					_self.$refs.msg.open()
					return false
				}
				return true
			},
			//提交新建项目信息
			doCreateProject() {
				//校验参数
				const _self = this
				const isLegal = _self.doCheckProjectParams()
				if (isLegal) {
					uni.showLoading({
						title: '创建中...',
					})
					//构建参数
					var list = []
					if (_self.isUrgent != '' && _self.isUrgent) {
						list = ['URGENT']
					}
					const data = {
						applyContactCsaNo: _self.selectContact.csaNo, //	联系人客服编号
						applyContactId: _self.selectContact.projContactId, //联系人ID
						applyContactName: _self.selectContact.name, //联系人姓名
						applyContactPhone: _self.selectContact.phone, //联系人手机
						projDevCompleteDate: _self.completeDate, //开发完成日期
						projName: _self.projectName, //项目简称
						projVersion: _self.version, //项目版本
						backendCodeLang: _self.selectLang,
						projChargeType: _self.type, //项目收费类型 ALL,FREE,MATERIAL,MATERIAL_AGENT,MATERIAL_AGENT_URGENT
						listProjChargeAdditional: list,
						packageOrderId: _self.selectPackage.packageOrderId ? _self.selectPackage.packageOrderId :
						'', //套餐包ID
						couponId: _self.selectCoupons.couponId ? _self.selectCoupons.couponId : '', //优惠卷ID
					}
					ProApi.doCreateProject(data)
						.then(res => {
							console.log(res)
							uni.hideLoading()
							_self.msgType = 'success'
							_self.msgTxt = '项目创建流程圆满完成，系统正在生成配套材料，请您耐心等候。'
							_self.$refs.msg.open()
							setTimeout(() => {
								uni.navigateBack()
							}, 1500);
						})
						.catch(err => {
							uni.hideLoading()
							console.log(err)
							_self.msgTxt = err.msg ? err.msg : '网络错误,请稍后重试'
							_self.msgType = 'error'
							_self.$refs.msg.open()
						})
				}
			}
		}
	}
</script>

<style lang="scss">
	.create-container {
		display: flex;
		flex-direction: column;
		justify-content: flex-start;
	}

	.container-box {
		display: flex;
		flex-direction: column;
		justify-content: flex-start;
		padding-bottom: 200rpx;
	}

	.create-title {
		height: 80rpx;
		background-color: blanchedalmond;
	}

	.commend-text-area {
		padding: 10px;
		height: 50px;
		align-self: center;
		width: 85vw;
		margin-top: 20rpx;
		font-size: 28rpx;
		background-color: $bg-gray-input-color;
		border-radius: 15rpx;
	}

	.info-box {
		display: flex;
		flex-direction: column;
		margin-top: 20rpx;
		background-color: $white-color;
		border-radius: 15rpx;
		padding: 20rpx;
	}

	.info-title {
		font-size: 36rpx;
		font-weight: bold;
	}

	.info-value {
		margin-top: 20rpx;
		font-size: 24rpx;
		line-height: 16px;
		background-color: $bg-gray-input-color;
		height: 65rpx;
		width: auto;
		padding: 15px;
		border-radius: 15rpx;
	}

	.info-btn {
		align-self: flex-end;
		background-color: #FFA900;
		margin-top: 20rpx;
		padding: 5rpx 40rpx;
		color: white;
		border-radius: 10rpx;
		font-size: 28rpx;
	}

	.content-box {
		display: flex;
		flex-direction: column;
		padding: 20rpx;
		background-color: $white-color;
		border-radius: 15rpx;
		margin-top: 20rpx;
	}

	.box-title {
		font-size: 32rpx;
		font-weight: $black-color;
		color: $text-color;
	}



	.item {
		display: flex;
		flex-direction: column;
		margin-top: 15rpx;
		margin-left: 15rpx;
	}

	.item-title {
		font-size: 28rpx;
		color: $text-color;
	}

	.item-content {
		display: flex;
		flex-direction: row;
		align-items: center;
		background-color: $bg-gray-input-color;
		margin-top: 10rpx;
		padding: 15rpx;
		border-radius: 15rpx;
	}

	.label {
		color: black;
		font-weight: bold;
	}

	.desc {
		flex: 1;
		color: #999;
		text-align: left;
		padding-left: 20rpx;
		display: flex;
		flex-direction: row;
		justify-content: space-between;
		padding-right: 10px;
		align-items: center;
	}

	.select-time {
		color: #000000;
		flex: 1;
		font-size: 14px;
		text-align: left;
	}

	.clear-icon {
		width: 20px;
		height: 20px;
		margin-right: 20rpx;
	}

	.desc .icon {
		width: 32rpx;
		height: 32rpx;
	}

	.value {
		color: #9A9A9A;
		flex: 1;
	}


	.value-hint {
		color: $text-gray-hint-color;
	}

	.v-select {
		font-size: 28rpx;
		color: $text-color;
	}

	.v-normal {
		font-size: 28rpx;
		color: $text-gray-hint-color;
	}


	.language-sel {
		font-size: 14px;
		flex: 1;
	}


	.link {
		font-size: 28rpx;
		color: #007AFF;
	}

	.flex-1 {
		display: flex;
		flex-direction: row;
		flex: 1;
	}

	.selection-box {
		position: relative;
		flex: 1;
	}

	.language-options {
		position: absolute;
		top: 100%;
		left: -20rpx;
		padding: 10rpx 20rpx;
		border: 1px solid #f2f2f2;
		border-top: none;
		background-color: white;
		box-shadow: 0rpx 0rpx 10rpx 10rpx #f2f2f2;
	}

	.option {
		padding: 15rpx;
		cursor: pointer;
		border-bottom: 1rpx solid #f2f2f2;
	}

	.option:hover {
		background-color: #f0f0f0;
	}

	.weui-half-screen-dialog__ft {
		padding: 0rpx 0rpx 40rpx;
	}

	.bottom-box {
		position: fixed;
		left: 0;
		bottom: 0;
		text-align: center;
		width: 100vw;
		line-height: 100rpx;
		border-radius: 20rpx;
		background-color: white;
		display: flex;
		flex-direction: column;
		align-items: center;
	}

	.money {
		color: $text-brown-color;
		font-size: 20px;
		display: flex;
		flex-direction: row;
		align-items: center;
		justify-content: center;
	}

	.price {
		color: rgb(250, 0, 0);
	}

	.form-box {
		display: flex;
		flex-direction: column;
		justify-content: center;
		font-size: 28rpx;
		padding: 40rpx 0rpx;
	}

	.form-item {
		display: flex;
		flex-direction: row;
		align-items: center;
	}

	.form-item:nth-of-type(n+2) {
		margin-top: 15rpx;
	}

	.form-item-title {
		flex: .3;
		color: black;
		text-align: left;
	}


	.form-item-content {
		flex: .7;
		text-align: right;
		padding: 15rpx;
		border-radius: 15rpx;
		background-color: $bg-gray-input-color;
	}

	.project-box {
		display: flex;
		flex-direction: row;
		flex-wrap: wrap;
		margin-top: 10rpx;
	}

	.project-item {
		font-size: 24rpx;
		background-color: #ffaa0034;
		text-align: center;
		color: #804002;
		text-align: center;
		margin: 10rpx;
		padding: 5rpx 20rpx;
		border-radius: 4rpx;
	}

	.confirm-btn {
		font-size: 28rpx;
		height: 48rpx;
		line-height: 48rpx;
		border-radius: 10rpx;
		padding: 10rpx;
		text-align: center;
		width: 85vw !important;
		background-color: rgba(57, 154, 35, 1);
		color: rgba(255, 255, 255, 1);
		align-self: center;
	}

	.confirm-btn:active {
		background-color: rgba(57, 154, 35, 0.7);
		color: rgba(255, 255, 255, 1);
	}



	.coupons-list-box {
		display: flex;
		flex-direction: column;
		padding: 20rpx;
	}

	.tickets {
		display: flex;
		padding: 5px;
		box-sizing: border-box;
		height: 210rpx;
	}

	.l-tickets {
		flex: 0.7;
		position: relative;
		padding: 10px;
		display: flex;
		flex-direction: column;
		justify-content: space-between;
		background: radial-gradient(circle at right top, transparent 16rpx, #ffaa0017 0) right top / 100% 50% no-repeat,
			radial-gradient(circle at right bottom, transparent 16rpx, #ffaa0017 0) right bottom / 100% 50% no-repeat;
	}


	.l-tickets::after {
		content: '';
		position: absolute;
		height: 100%;
		width: 8rpx;
		top: 0;
		left: -8rpx;
		background: radial-gradient(circle at left center, transparent 8rpx, #ffaa0017 0) left center / 8rpx 20rpx;
	}



	.r-tickets {
		flex: 0.3;
		position: relative;
		background: radial-gradient(circle at left top, transparent 16rpx, #ffaa0017 0, #ffaa0017 100%) right top / 100% 50% no-repeat,
			radial-gradient(circle at left bottom, transparent 16rpx, #ffaa0017 0, #ffaa0017 100%) right bottom / 100% 50% no-repeat;
		display: flex;
		flex-direction: row;
		justify-content: center;
		align-items: center;
		font-size: 14px;
		font-weight: 500;
		color: #5D3900;
	}

	.r-tickets::after {
		content: '';
		position: absolute;
		height: 100%;
		width: 8rpx;
		top: 0;
		right: -8rpx;
		background: radial-gradient(circle at right center, transparent 8rpx, #ffaa0017 0) right center / 8rpx 20rpx;
	}

	.r-tickets::before {
		content: '';
		width: 1rpx;
		background: linear-gradient(to top, #fff 0%, #fff 50%, transparent 50%) top left / 1rpx 20rpx repeat-y;
		position: absolute;
		left: 0;
		top: 16rpx;
		bottom: 16rpx;
	}

	.ticket-container:nth-last-of-type(n+1) {
		margin-top: 10px;
	}


	.ticket-title {
		display: flex;
		flex-direction: row;
		justify-content: space-between;
		align-items: center;
		font-size: 14px;
		color: #5D3900;
		font-weight: 400;
	}

	.ticket-content {
		font-size: 18px;
		color: #5D3900;
		text-align: center;
		font-weight: bold;
	}

	.ticket-desc {
		font-size: 12px;
		color: #5D3900;
		margin-top: 10px;
		font-weight: 400;
	}


	.coupons-item {
		display: flex;
		flex-direction: row;
		justify-content: flex-start;
		align-items: center;
		background-color: #ffaa0017;
		border-radius: 10px;
		width: 85vw;
		padding: 10px 5px;
	}

	.coupons-item:nth-last-of-type(n+1) {
		margin-top: 10px;
	}

	.coupons-item-content {
		display: flex;
		flex-direction: row;
		justify-content: space-between;
		align-items: center;
		flex: 1;
	}

	.coupons-desc {
		display: flex;
		flex-direction: column;
		justify-content: space-between;
		align-items: flex-start;
		margin-left: 7px;
	}

	.coupons-desc .title {
		font-size: 16px;
		color: red;
	}

	.coupons-desc .dd {
		font-size: 12px;
		color: red;
	}

	.counpons-check {
		display: flex;
		flex-direction: row;
		justify-content: center;
		align-items: center;
	}

	.counpons-check .txt {
		font-size: 16px;
		color: red;
		font-weight: 600;
	}

	.coupons-icon {
		background-image: url('data:image/png;base64, ');
		background-size: contain;
		background-repeat: no-repeat;
	}
</style>