<template>
	<Layout :index="-1" :banner="0"  :img="'/static/img/about.jpg'" :titles="'个人中心'" :title_content="'个人中心'">
		<view class="bg ptm-80">
			<view class="content">
				<view class="content_left">
					<memberleft :index="'2'"></memberleft>
				</view>
				<view class="content_right">
					<view class="mtitle">
						<span>新增装备道具资产确权</span>
						<view class="goback" @tap="goBack()">
							返回
						<i class="el-icon-back"></i>
						</view>
					</view>
					<view class="lines"></view>
					<view class="content_r">
				<el-form label-position="right" :model="form" :rules="rules" ref="ruleForm" class="ruleForm" label-width="100px" >
					<!-- 基本信息 -->
					<view class="asset_content" >
						<view class="asset_title">资产基本信息</view>
						
						<el-row>
							<view class="d-b-c">
								<el-col :span="24">
									  <el-form-item label="数字资产类型：" :label-width="formLabelWidth" prop="base_info.type" :rules="[{required: true,message: '请选择数字资产类型', trigger: 'blur'}]">
										 <el-radio-group v-model="form.base_info.type"  fill="#F78A30" text-color="#F78A30">
											<el-radio :label="'equipment'">游戏装备</el-radio>
											<el-radio :label="'item'" >游戏道具</el-radio>
											<el-radio :label="'cdk'">游戏CDK</el-radio>
											<el-radio :label="'account'">游戏账号</el-radio>
										  </el-radio-group> 
									  </el-form-item>
								</el-col>
						   </view>
						</el-row>
						
						<el-row>
							<view class="d-b-c">
								<el-col :span="12">
									<el-form-item label="资产名称：" :label-width="formLabelWidth" prop="base_info.name" :rules="[{required: true,message: '请输入资产名称', trigger: 'blur'}]">
									<el-input v-model="form.base_info.name" placeholder="请输入资产名称"></el-input>
									 </el-form-item>
								</el-col>
						   </view>
						</el-row>
						
					
						
						<el-form-item label="数字资产简介：" :label-width="formLabelWidth" prop="base_info.intro" :rules="[{required: true,message: '请输入数字资产简介', trigger: 'blur'}]">
						    <el-input type="textarea" v-model="form.base_info.intro" placeholder="请输入数字资产简介" maxlength="500"
  show-word-limit :autosize="{ minRows: 4, maxRows: 10}"></el-input>
						  </el-form-item>
						  <!-- prop="base_info.pic" :rules="[{required: true,message: '请上传数字资产图片', trigger: 'blur'}]" -->
						  <el-form-item label="数字资产图片：" :label-width="formLabelWidth" prop="base_info.pic" :rules="[{required: true,message: '请上传数字资产图片', trigger: 'blur'}]" >
						  	<el-upload
						  	  class="uploads"
							  list-type="picture"
						  	    action=""
						  		:before-upload="beforeUploadimg"
						  		:http-request="customUpload"
						  		multiple
						  		:limit="5"
						  		:on-exceed="handleExceed1"
						  	  :file-list="fileList1"
						  	  :on-remove="handleRemove1"
						  	  >
						  	  <el-button size="small" type="primary" class="xzfile" @tap="select(1)" v-loading.fullscreen.lock="save_loading">选择文件</el-button>
						  	 
						  	</el-upload>
						  	
						   </el-form-item>
						  
						  <el-row>
								<view class="d-b-c">
									<el-col :span="12">
									<el-form-item label="数字资产份数：" prop="base_info.share" :label-width="formLabelWidth" :rules="[{required: true,message: '请输入数字资产份数', trigger: 'blur'}]">
									<el-input  v-model="form.base_info.share" type="number"  placeholder="请输入数字资产份数"></el-input>
									</el-form-item>
									</el-col>
									<el-col :span="12">
										  <el-form-item label="资产销售定价：" :label-width="formLabelWidth" prop="base_info.price" :rules="[{required: true,message: '请输入资产销售定价', trigger: 'blur'}]">
											   <el-input placeholder="请输入资产销售定价" type="number" v-model="form.base_info.price">
											      <template slot="append">元</template>
											    </el-input>
										  </el-form-item>
									</el-col>
								 
								 
								 
								 </view>
						   </el-row>
						  
						  <el-form-item label="资产权力出售类型：" :label-width="formLabelWidth" prop="base_info.sell_type" :rules="[{required: true,message: '请选择资产权力出售类型', trigger: 'blur'}]">
									 <el-radio-group v-model="form.base_info.sell_type"  fill="#F78A30" text-color="#F78A30">
										<el-radio :label="'license'" >许可使用</el-radio>
										<el-radio :label="'transfer'" >转让</el-radio>
									  </el-radio-group>
						  </el-form-item>
						  <el-row>
						  	<view class="d-b-c">
						  		<el-col :span="24">
						  			  <el-form-item label="资产确权类型：" :label-width="formLabelWidth" prop="base_info.ownership" :rules="[{required: true,message: '请选择资产确权类型', trigger: 'blur'}]">
						  				 <el-radio-group v-model="form.base_info.ownership"  fill="#F78A30" text-color="#F78A30">
						  					<el-radio :label="'usage'" >使用权</el-radio>
						  					<el-radio :label="'ownership'" >所有权</el-radio>
						  				  </el-radio-group>
						  			  </el-form-item>
						  		</el-col>
						  	 
						  	 
						     </view>
						  </el-row>
						  
						  
							<el-form-item label="其他补充材料：" :label-width="formLabelWidth" >
							 <el-upload
							   class="uploads"
							     action=""
								 list-type="picture"
							 	:before-upload="beforeUploadimg"
							 	:http-request="customUpload"
							 	multiple
							 	:limit="5"
							 	:on-exceed="handleExceed2"
								:on-remove="handleRemove2"
							   :file-list="fileList2">
							   <el-button size="small" type="primary" class="xzfile" @tap="select(2)" v-loading.fullscreen.lock="save_loading">选择文件</el-button>
							 </el-upload>
							</el-form-item>
						<view class="asset_title">出售人信息</view>
						
						 <el-form-item label="出售人类别：" :label-width="formLabelWidth" prop="owner_info.seller_type" :rules="[{required: true,message: '请选择出售人类别', trigger: 'blur'}]">
								<el-radio-group v-model="form.owner_info.seller_type" fill="#F78A30" text-color="#F78A30" @change="handleSellerTypeChange">
									<el-radio :label="'company'">企业</el-radio>
									<el-radio :label="'person'">个人</el-radio>
								</el-radio-group>
						</el-form-item>
						<el-form-item label="出售人名称：" :label-width="formLabelWidth" prop="owner_info.seller_name" :rules="[{required: true,message: '请输入出售人名称', trigger: 'blur'}]">
							<el-input type="text" v-model="form.owner_info.seller_name" placeholder="请输入出售人名称"></el-input>
						</el-form-item>
						<el-form-item label="证件类型：" :label-width="formLabelWidth" prop="owner_info.id_type" :rules="[{required: true,message: '请选择证件类型', trigger: 'blur'}]">
							<el-radio-group v-model="form.owner_info.id_type" fill="#F78A30" text-color="#F78A30">
								<el-radio :label="'idcard'" :disabled="form.owner_info.seller_type === 'person'">身份证</el-radio>
								<el-radio :label="'business_license'" :disabled="form.owner_info.seller_type === 'person'">营业执照</el-radio>
							</el-radio-group>
						</el-form-item>
						<el-form-item label="证件号码：" :label-width="formLabelWidth" prop="owner_info.id_no" :rules="[{required: true,message: '请输入证件号码', trigger: 'blur'}]">
							<el-input type="text" v-model="form.owner_info.id_no" placeholder="请输入证件号码"></el-input>
						</el-form-item>
						<!-- prop="owner_info.id_pic" :rules="[{required: true,message: '请上传证件图片', trigger: 'blur'}]" -->
						<el-form-item label="证件图片：" :label-width="formLabelWidth" prop="owner_info.id_pic" :rules="[{required: true,message: '请上传证件图片', trigger: 'blur'}]">
						<el-upload
						  class="uploads"
						    action=""
							list-type="picture"
							:before-upload="beforeUploadimg"
							:http-request="customUpload"
							multiple
							:limit="5"
							:on-exceed="handleExceed3"
														:on-remove="handleRemove3"
						  :file-list="fileList3">
						  <el-button size="small" type="primary" class="xzfile" @tap="select(3)" v-loading.fullscreen.lock="save_loading">选择文件</el-button>
						</el-upload>
						</el-form-item>
						<el-form-item label="资产来源：" :label-width="formLabelWidth" prop="owner_info.asset_source" :rules="[{required: true,message: '请输入资产所属的游戏名称', trigger: 'blur'}]">
						    <el-input type="text" v-model="form.owner_info.asset_source" placeholder="请输入资产所属的游戏名称" @input="form.owner_info.asset_source = $event.trim()"></el-input>
						  </el-form-item>
					</view>
				
					</el-form>
					
					<view class="login_checks" >
						<label class="radio"><radio value="r1" :checked="checked" @tap="select111()" activeBackgroundColor="#F78B32" borderColor="#F78B32" color="#F78B32" style="transform:scale(0.65);border-radius: 100%;" /></label>
						上链需要同意并接受<text style="color: #F6773C;cursor: pointer;" @tap="goUrl('https://cogapi.scszsj.com/service.html')">《平台用户协议》</text>
														  </view>
					<view class="dialog-footer">
					
					  <!-- <el-button @tap="gosteps(steps-1)" v-if="steps>0">上一步</el-button> -->
					 <!-- <el-button @tap="addAsset('bc')" v-if="id==0" v-loading.fullscreen.lock="save_loading">保存</el-button>
					  <el-button @tap="editAsset('bc')" v-if="id>0" v-loading.fullscreen.lock="save_loading">保存</el-button> -->
					  <!-- <el-button type="primary" @tap="gosteps(steps+1)" v-if="steps<3">下一步</el-button> -->
					  <el-button type="primary" @tap="addAsset()" v-if="id==0" :loading="loading" >确认资产上链</el-button>
					 <el-button type="primary" @tap="editAsset()" v-if="auth_status=='reject'" :loading="loading" >重新提交</el-button>
					</view>
					</view>	
				</view>
			</view>
			
		</view>
	</Layout>
</template>

<script>

import Layout from './part/layouts.vue';
	import memberleft from './part/member_left.vue';
	export default {
		components:{
			Layout,
			memberleft
		},
		data(){
			return {
				/*是否正在提交保存*/
				save_loading: false,
				page: 1,
				list_rows: 10,
				listData: [],
				total: 0,
				steps:0,
				loading:false,
				form:{
				  base_info: {
					  type:'equipment',
					  name:'',
					  asset_type:'数字资产',
					  pic:'',
					  intro: '',
					  other: '',
					  ownership: 'usage',
					  channel: '新版链',
					  sell_type: 'license',
					  price:'',
					  share:''
				  },
				  owner_info: {
					  seller_type: 'company',//company
					  seller_name: '',
					  id_type: 'idcard',//business_license
					  id_no: '',
					  id_pic: '',
					  asset_source: '',
				  },
				 
				  ptype:[],
				  ptypes:[],
				},
				formLabelWidth: '150px',
				rules: {
				          name: [
				            { required: true, message: '请输入资产名称', trigger: 'blur' },
				            { min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' }
				          ],
				          region: [
				            { required: true, message: '请选择活动区域', trigger: 'change' }
				          ],
				          date1: [
				            { type: 'date', required: true, message: '请选择日期', trigger: 'change' }
				          ],
				          date2: [
				            { type: 'date', required: true, message: '请选择时间', trigger: 'change' }
				          ],
				          type: [
				            { type: 'array', required: true, message: '请至少选择一个活动性质', trigger: 'change' }
				          ],
				          resource: [
				            { required: true, message: '请选择活动资源', trigger: 'change' }
				          ],
				          desc: [
				            { required: true, message: '请填写活动形式', trigger: 'blur' }
				          ]
				},
				  fileList1: [],
				  fileList2: [],
				  fileList3: [],
                  credit_report_img:'',
				  file_num:0,
				  id:0,
				  checked:true,
				  auth_status:''
			}
		},
		created(){
			const width = window.innerWidth;
			const height = window.innerHeight;
			const mobileWidth = 768; // 可以根据需要调整这个值
			const isMobile = width <= mobileWidth || height <= mobileWidth;
			if(isMobile){
				this.list_rows = 30;
			}
			this.steps = 0;
			
		},
		onShow() {
			let obj = this.$Route.query;
			if(obj.hasOwnProperty('id')){
				this.id = Number(obj.id);
			}
			if(this.id>0){
				this.getdetail()
			}
			//如果当前勾选的是企业，那么勾选营业执照
			if(this.form.owner_info.seller_type=='company'){
				this.form.owner_info.id_type = 'business_license';
			}else{
				this.form.owner_info.id_type = 'idcard';
			}
		},
		mounted() {
			
		},
		methods:{
			handleSellerTypeChange(){
				if(this.form.owner_info.seller_type=='company'){
					this.form.owner_info.id_type = 'business_license';
				}else{
					this.form.owner_info.id_type = 'idcard';
				}
			},
			select111(){
				if(this.checked==true){
					this.checked=false;
				}else{
					this.checked=true;
				}
			},
			getdetail(){
				this.form.base_info = {};
				this.form.owner_info = {};
				this._get('gameasset.GameAsset/detail',{
					id: this.id,
				},
				res=>{
						console.log(res.data,3333)
						this.form.base_info = res.data.base_info;
						this.form.owner_info = res.data.owner_info;
						this.auth_status = res.data.auth_status;
						// 优化图片和文件处理逻辑
						// 处理数字资产图片，支持多张图片逗号分隔
						if (this.form.base_info&&this.form.base_info.pic) {
							this.fileList1 = this.form.base_info.pic
								.split(',')
								.filter(url => !!url)
								.map(url => ({
									name: url.substring(url.lastIndexOf('/') + 1),
									url
								}));
						} else {
							this.fileList1 = [];
						}

						// 处理其他补充材料，支持多文件逗号分隔
						if (this.form.base_info&&this.form.base_info.other) {
							this.fileList2 = this.form.base_info.other
								.split(',')
								.filter(url => !!url)
								.map(url => ({
									name: url.substring(url.lastIndexOf('/') + 1),
									url
								}));
						} else {
							this.fileList2 = [];
						}

						// 处理证件图片，支持多文件逗号分隔
						if (this.form.owner_info&&this.form.owner_info.id_pic) {
							this.fileList3 = this.form.owner_info.id_pic
								.split(',')
								.filter(url => !!url)
								.map(url => ({
									name: url.substring(url.lastIndexOf('/') + 1),
									url
								}));
						} else {
							this.fileList3 = [];
						}
						
					}
					,err=>{
						uni.showToast({
							icon:'none',
							title: err.data.msg,
							duration:1500
						})
						// this.$message(err.data.msg);
						setTimeout(() => {
						   uni.reLaunch({
						           url: '/pages/digital_assets' // 替换为你实际的首页路径
						       });
						}, 1500);
						return;
					}
				);
			},
			goUrl(e){
				window.open(e, '_blank');
				// uni.showModal({
				//     title: '温馨提示', 
				//     content: '请先保存表单信息哦~', 
				//     showCancel: true, 
				//     cancelText: '取消', 
				//     cancelColor: '#cccccc', 
				//     confirmText: '确定', 
				//     confirmColor: '#F78A30', 
				//     success: function (res) {
				//         if (res.confirm) {
				//             window.open(e, '_blank');
				//         } else if (res.cancel) {
				//             console.log('用户点击取消');
				//         }
				//     },
				//     fail: function (err) {
				//         console.log('调用失败：', err);
				//     },
				//     complete: function () {
				//     }
				// });
			},
			change(e) {
					this.form.operation_info.online_time = e;
					console.log(this.form.operation_info.online_time,222);
				},
			// 优化删除图片逻辑
			handleRemove1(file, fileList) {
				// 只移除被删除的图片，fileList为剩余图片
				this.fileList1 = fileList;
				// 如果没有图片了，清空表单字段
				if (fileList.length === 0) {
					this.form.base_info.pic = '';
				} else {
					// 取剩余图片的url数组，拼接为字符串（如只允许一张则取第一张）
					const urls = fileList.map(f => f.url || (f.response && f.response.url) || '').filter(Boolean);
					this.form.base_info.pic = urls.length > 0 ? urls[0] : '';
				}
			},
			handleRemove2(file, fileList) {
				// 只移除被删除的文件，fileList为剩余文件
				this.fileList2 = fileList;
				// 如果没有文件了，清空表单字段
				if (fileList.length === 0) {
					this.form.title_info.other = '';
				} else {
					// 取剩余文件的url数组，拼接为字符串（如只允许一份则取第一份）
					const urls = fileList.map(f => f.url || (f.response && f.response.url) || '').filter(Boolean);
					this.form.title_info.other = urls.length > 0 ? urls[0] : '';
				}
			},
			handleRemove3(file, fileList) {
				// 只移除被删除的图片，fileList为剩余图片
				this.fileList3 = fileList;
				// 如果没有图片了，清空表单字段
				if (fileList.length === 0) {
					this.form.owner_info.id_pic = '';
				} else {
					// 取剩余图片的url数组，拼接为字符串（如只允许一张则取第一张）
					const urls = fileList.map(f => f.url || (f.response && f.response.url) || '').filter(Boolean);
					this.form.owner_info.id_pic = urls.length > 0 ? urls[0] : '';
				}
			},
		
			
			 handleExceed1(files, fileList1) {
				 this.save_loading = false;
				//  当前限制选择 5 个文件，本次选择了 ${files.length} 个文件，共选择了 ${files.length + fileList1.length} 个文件
			        this.$message.warning(`图片最多只能上传5张`);
			  },
			handleExceed2(files, fileList2) {
				this.save_loading = false;
			       this.$message.warning(`图片最多只能上传5张`);
			 },
			handleExceed3(files, fileList3) {
				this.save_loading = false;
			       this.$message.warning(`图片最多只能上传5张`);
			 },

			beforeUpload(file) {
					      // const isImage = file.type.startsWith('image/');
					      // if (!isImage) {
					      //   this.$message.error('只能上传图片文件!');
					      //   return false;
					      // }
					      const isLt2M = file.size / 1024 / 1024 < 5;
					      if (!isLt2M) {
							this.save_loading = false;
					        this.$message.error('上传的图片大小不能超过 5MB!');
					        return false;
					      }
					      return true;
			},
			beforeUploadFile(file) {
					     const allowedTypes = [
					          'application/msword',
					          'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
					          'application/pdf',
					        ];
					        if (!allowedTypes.includes(file.type)) {
					          this.$message.error('只能上传 Word 或 PDF 文件!');
					          return false;
					        }
					        const isLt2M = file.size / 1024 / 1024 < 5;
					        if (!isLt2M) {
					          this.$message.error('上传的文件大小不能超过 5MB!');
					          return false;
					        }
					    
					        return true;
			},
			beforeUploadimg(file) {
					      const isImage = file.type.startsWith('image/');
					      if (!isImage) {
							  this.save_loading = false;
					        this.$message.error('只能上传图片文件!');
					        return false;
					      }
					      const isLt2M = file.size / 1024 / 1024 < 5;
					      if (!isLt2M) {
							  this.save_loading = false;
					        this.$message.error('上传的图片大小不能超过 5MB!');
					        return false;
					      }
					      return true;
			},
			select(e){
				this.file_num = e;
			},	
			customUpload({ file, onSuccess, onError }) {
				          let filetype = "image"
						  if(this.file_num==8||this.file_num==1){
							  filetype = "pdf"
						  }
					      const formData = new FormData();
					      formData.append('iFile', file);
					      formData.append('type', filetype);
						  formData.append('app_id', '10001');
						   formData.append('token', uni.getStorageSync('token') || '');
						   this.save_loading = true;
					      // 替换成你的上传接口地址
					      const url = this.config.app_url+'/api/file.upload/image';
					      fetch(url, {
					        method: 'POST',
					        body: formData
					      })
					      .then(response => {
							  return response.json();
						  })
					      .then(data => {
					        if (data.code==1) {
								console.log(this.file_num,2222)
								if(this.file_num==1){
									// 处理多张图片，逗号分隔
									if (this.form.base_info.pic) {
										this.form.base_info.pic += ',' + data.data.file_path;
									} else {
										this.form.base_info.pic = data.data.file_path;
									}
								}else if(this.file_num==2){
									if (this.form.base_info.other) {
										this.form.base_info.other += ',' + data.data.file_path;
									} else {
										this.form.base_info.other = data.data.file_path;
									}
								}
								else if(this.file_num==3){
									if (this.form.owner_info.id_pic) {
										this.form.owner_info.id_pic += ',' + data.data.file_path;
									} else {
										this.form.owner_info.id_pic = data.data.file_path;
									}
								}
								
								this.save_loading = false;
								this.$message.success('上传成功');
					        } else {
								console.log(this.file_num,222)
								if(this.file_num==1){
									this.fileList1 = [];
								}else if(this.file_num==2){
									this.fileList2 = [];
								}
								else if(this.file_num==3){
									this.fileList3 = [];
								}
								this.save_loading = false;
								 this.$message.error(data.msg);
					        }
					      })
					      .catch(err => {
					        onError(err);
					      });
			},
			gosteps(e){
				// if(e==1){
				// 	this.clearFormErrors();
				// }
				this.steps = e;
			},
			clearFormErrors() {
			      this.$refs.ruleForm.clearValidate();
			    },
			goBack(){
				uni.navigateTo({
				  url: '/digital_assets'
				});
			},
			objectToKeyValueArray(obj) {
			    return Object.keys(obj).map(key => ({ key, value: obj[key] }));
			},
		    addAsset(e){
				//请勾选协议
				if (!this.checked) {
					this.$message.error('请勾选平台用户协议');
					return false;
				}
				// this.save_loading = true;
				if(uni.getStorageSync('apply_status')==3){
					this.$message.error('用户认证审核中');
					return false;
				}
				if(uni.getStorageSync('apply_status')==2){
					this.$message.error('用户认证失败，请重新提交审核');
					return false;
				}
				
				
				// if(uni.getStorageSync('third_auth_status')==0){
				// 	this.$message.error('请提交实名认证');
				// 	return false;
				// }
				// if(uni.getStorageSync('third_auth_status')==2){
				// 	this.$message.error('未注册天府信用通账号，请联系管理员');
				// 	return false;
				// }
				if(e=='bc'){
					this._post('gameasset.GameAsset/add',{
							base_info: JSON.stringify(this.form.base_info),
							owner_info:JSON.stringify(this.form.owner_info),
							action:'',
				},res=>{
						console.log(res,3333)
						// this.save_loading = false;
						uni.showToast({
							icon:'none',
							title: '保存成功',
							duration:1500
						})
						setTimeout(() => {
						   uni.reLaunch({
						           url: '/pages/digital_assets' // 替换为你实际的首页路径
						       });
						}, 1500);
					}
					,err=>{
						// uni.showToast({
						// 	icon:'none',
						// 	title: err.data.msg
						// })
						// this.save_loading = false;
						this.$message(err.data.msg);
						return;
					}
					);
					
				}else{
					// if (this.form.ptype.length==0&&this.steps>0){
					// 	this.$message.error('请选择产品形态');
					// 	return false;
					// }
					this.$refs.ruleForm.validate((valid) => { // 表单验证通过后执行保存操作
						
						if (valid) {
							//数字资产份数：资产销售定价：必须为数字
						if (!/^\d+(\.\d+)?$/.test(this.form.base_info.share)) {
							this.$message.error('数字资产份数：：必须为数字');
							return false;
						}
						if (this.form.base_info.share<=0) {
							this.$message.error('数字资产份数错误');
							return false;
						}
						//资产销售定价：必须为数字必要大于0
						if (this.form.base_info.price<=0) {
							this.$message.error('资产销售定价错误');
							return false;
						}
						if (!/^\d+(\.\d+)?$/.test(this.form.base_info.price)) {
							this.$message.error('资产销售定价：：必须为数字');
							return false;
						}
						//证件号码：字母和数字
						if (!/^[a-zA-Z0-9]+$/.test(this.form.owner_info.id_no)) {
							this.$message.error('证件号码：：只能包含字母和数字');
							return false;
						}
						this._post('gameasset.GameAsset/add',{
							name: this.form.base_info.name,
							type: this.form.base_info.type,
							share: this.form.base_info.share,
							base_info: JSON.stringify(this.form.base_info),
							owner_info:JSON.stringify(this.form.owner_info),
							action:'add',
						},res=>{
								console.log(res,3333)
								uni.showToast({
									icon:'none',
									title: '新增成功',
									duration:1500
								})
								// this.save_loading = false;
								setTimeout(() => {
								   uni.reLaunch({
								           url: '/pages/digital_assets' // 替换为你实际的首页路径
								       });
								}, 1500);
							}
							,err=>{
								// this.save_loading = false;
								// uni.showToast({
								// 	icon:'none',
								// 	title: err.data.msg
								// })
								this.$message(err.data.msg);
								return;
							}
							);
					  } else {
						  // this.save_loading = false;
						console.log('表单验证失败');
						this.$message.error('请完善必填项!');
						return false; // 阻止默认行为，即不进行页面跳转或其他操作
					  }
					});
				}
				 
				
			},
			
			editAsset(e){
				// this.save_loading = true;
				if(uni.getStorageSync('apply_status')==3){
					this.$message.error('用户认证审核中');
					return false;
				}
				if(uni.getStorageSync('apply_status')==2){
					this.$message.error('用户认证失败，请重新提交审核');
					return false;
				}
				// if(uni.getStorageSync('third_auth_status')==0){
				// 	this.$message.error('请提交实名认证');
				// 	return false;
				// }
				// if(uni.getStorageSync('third_auth_status')==2){
				// 	this.$message.error('未注册天府信用通账号，请联系管理员');
				// 	return false;
				// }
				if(e=='bc'){
					if (this.form.ptypes.includes('已接入COG运营发行中枢，授权获取数据')) {
					 this.form.operation_info.is_access=true
					}
					else{
						 this.form.operation_info.is_access=false
					}
					if (this.form.ptype.includes('电脑')) {
					 this.form.develop_info.pc=true
					}else{
						this.form.develop_info.pc=false
					}
					if (this.form.ptype.includes('移动')) {
					 this.form.develop_info.mobile=true
					}
					else{
						this.form.develop_info.mobile=false
					}
					if (this.form.ptype.includes('游戏机')) {
					 this.form.develop_info.console=true
					}
					else{
						this.form.develop_info.console=false
					}
					this._post('asset.asset/edit',{
					base_info: JSON.stringify(this.form.base_info),
					develop_info:JSON.stringify(this.form.develop_info),
					title_info: JSON.stringify(this.form.title_info),
					operation_info:JSON.stringify(this.form.operation_info),
					action:'',
					id:this.id
				},res=>{
						console.log(res,3333)
						// this.save_loading = false;
						uni.showToast({
							icon:'none',
							title: '保存成功',
							duration:1500
						})
						setTimeout(() => {
						   uni.reLaunch({
						           url: '/pages/asset_list' // 替换为你实际的首页路径
						       });
						}, 1500);
					}
					,err=>{
						// uni.showToast({
						// 	icon:'none',
						// 	title: err.data.msg
						// })
						// this.save_loading = false;
						this.$message(err.data.msg);
						return;
					}
					);
					
				}else{
					
					this.$refs.ruleForm.validate((valid) => { // 表单验证通过后执行保存操作
					  if (valid) {
						  //数字资产份数：资产销售定价：必须为数字
						  if (!/^\d+(\.\d+)?$/.test(this.form.base_info.share)) {
						  	this.$message.error('数字资产份数：：必须为数字');
						  	return false;
						  }
						  if (this.form.base_info.share<=0) {
						  	this.$message.error('数字资产份数错误');
						  	return false;
						  }
						  //资产销售定价：必须为数字必要大于0
						  if (this.form.base_info.price<=0) {
						  	this.$message.error('资产销售定价错误');
						  	return false;
						  }
						  if (!/^\d+(\.\d+)?$/.test(this.form.base_info.price)) {
						  	this.$message.error('资产销售定价：：必须为数字');
						  	return false;
						  }
						  //证件号码：字母和数字
						  if (!/^[a-zA-Z0-9]+$/.test(this.form.owner_info.id_no)) {
						  	this.$message.error('证件号码：：只能包含字母和数字');
						  	return false;
						  }
						// 执行保存操作，例如提交表单数据到服务器或更新本地状态等
						//判断类型
						// if (this.form.ptypes.includes('已接入COG运营发行中枢，授权获取数据')) {
						//  this.form.operation_info.is_access=true
						// }
						// else{
						// 	 this.form.operation_info.is_access=false
						// }
						// if (this.form.ptype.includes('电脑')) {
						//  this.form.develop_info.pc=true
						// }else{
						// 	this.form.develop_info.pc=false
						// }
						// if (this.form.ptype.includes('移动')) {
						//  this.form.develop_info.mobile=true
						// }
						// else{
						// 	this.form.develop_info.mobile=false
						// }
						// if (this.form.ptype.includes('游戏机')) {
						//  this.form.develop_info.console=true
						// }
						// else{
						// 	this.form.develop_info.console=false
						// }
						this._post('gameasset.GameAsset/edit',{
							name: this.form.base_info.name,
							type: this.form.base_info.type,
							share: this.form.base_info.share,
							base_info: JSON.stringify(this.form.base_info),
							owner_info:JSON.stringify(this.form.owner_info),
							id:this.id
						},res=>{
								console.log(res,3333)
								uni.showToast({
									icon:'none',
									title: '提交成功',
									duration:1500
								})
								// this.save_loading = false;
								setTimeout(() => {
								   uni.reLaunch({
								           url: '/pages/digital_assets' // 替换为你实际的首页路径
								       });
								}, 1500);
							}
							,err=>{
								// uni.showToast({
								// 	icon:'none',
								// 	title: err.data.msg
								// })
								this.save_loading = false;
								this.$message(err.data.msg);
								return;
							}
							);
					  } else {
						  // this.save_loading = false;
						console.log('表单验证失败');
						this.$message.error('请完善必填项!');
						return false; // 阻止默认行为，即不进行页面跳转或其他操作
					  }
					});
				}
				 
				
			}
		
		
		}
	}
</script>

<style lang="scss">
	.login_checks{
		margin-left: 11.5%;
		font-size: 14px;
	}
	.bg{
		width: 100%;
		background: #F1F1F1;
		min-height: 800px;
	}
	.content{
		width: 1290px;
		margin: 0 auto;
		padding-top: 14px;
		display: flex;
		justify-content: space-between;
	}
	.content_left{
		width: 245px;
		min-height: 789px;
		background: #FFFFFF;
		box-shadow: 0px 4px 10px 0px rgba(78,89,105,0.06);
		border-radius: 0px 0px 0px 0px;
	}
	.content_right{
		width: 1024px;
		min-height: 789px;
		background: #FFFFFF;
		box-shadow: 0px 4px 10px 0px rgba(78,89,105,0.06);
		border-radius: 0px 0px 0px 0px;
	}
	.mtitle{
		font-weight: 500;
		font-size: 16px;
		color: #3D3D3D;
		width: 985px;
		margin:0 auto;
		height: 48px;
		display: flex;
		align-items: center;
		justify-content: space-between;
	}
	.lines{
		width: 985px;
		height: 0px;
		border: 1px solid #D8D8D8;
		opacity: 0.6;
		margin:0 auto;
	}
	.mimg{
		width: 20px;
		height: 20px;
		margin-right: 10px;
		margin-left: 23px;
	}
	.content_r{
		padding: 34px 22px;
	}
	.goback{
		font-weight: 400;
		font-size: 14px;
		color: #F6773C;
		cursor: pointer;
	}
	.el-icon-back{
		margin-left: 4px;
	}
	.step_one{
		width: 170px;
		display: flex;
		cursor: pointer;
	}
	.step{
		width: 460px;
		margin: 0 auto;
	}
	.el-icon-d-arrow-right{
		color: #d4d4d4;	
	}
	.active-step{
		color: #ffc69b !important;
		width: 16px;
		height: 16px;
	}
	.step_num{
		width: 28px;
		height: 28px;
		background: #F2F3F5;
		border-radius:28px;
		font-weight: 400;
		font-size: 16px;
		color: #5B5B5B;
		text-align: center;
		line-height: 28px;
		// margin-right: 12px;
	}
	.step_num_active{
		background: #F6773C !important;
		font-weight: 500 !important;
		color: #FFFFFF !important;
	}
	.step_num_actives{
		background: #FFEFE3 !important;
		font-weight: 500 !important;
		color: #F6773C !important;
	}
	.step_title{
		font-weight: 400;
		font-size: 16px;
		color: #1D2129;
		margin-left: 12px;
	}
	.asset_content{
		margin-top: 44px;
		padding: 0 48px;
	}
	.asset_title{
		font-weight: 400;
		font-size: 16px;
		color: #767676;
		margin-bottom: 20px;
	}
	.el-textarea__inner {
	  height: 64px; 
	  width: 100%;
	  font-size: 14px;
	}
	::v-deep .el-input__inner {
	    background-color: #f0f0f0;
		width: 244px;
		height: 32px;
		background: #F2F3F5;
		border: none;
		font-size: 14px;
	}
	::v-deep .el-radio__input.is-checked .el-radio__inner{
		border-color: #F78A30;
		 background: #F78A30;
	}
	::v-deep .el-radio__input.is-checked+.el-radio__label{
		color: #F78A30;
	}
	::v-deep .el-form-item__label{
		line-height: unset;
		margin-top: 14px;
		font-size: 14px;
	}
	.uploads{
		display: flex;
		    align-items: baseline;
		    flex-direction: column;
	}
	.lans{
		color: #3C77FF;
		cursor: pointer;
	}
	.el-upload__tip{
		margin-left: 30px;
	}
	.xzfile{
		background: #F78A30;
		border-radius: 2px 2px 2px 2px;
		border: none;
	}
	.dialog-footer{
		margin: 0 auto;
		display: flex;
		justify-content: center;
		margin-top: 64px;
	}
	.el-button+.el-button{
		margin-left: 36px !important
	}
	.push-t-40{
		margin-top: 40px !important;
	}
	::v-deep .el-checkbox__input.is-checked .el-checkbox__inner, ::v-deep .el-checkbox__input.is-indeterminate .el-checkbox__inner{
		background-color: #F6773C;
		border-color: #F6773C;
	}
	::v-deep .el-checkbox__input.is-checked+.el-checkbox__label {
	    color: #F6773C;
		font-size: 14px;
	}
	::v-deep .el-button--primary:focus, .el-button--primary:hover {
	    background: #F78A30;
	    border-color: #F78A30;
	    color: #FFF;
	}
	::v-deep .el-button--primary {
	    color: #FFF;
	    background-color: #F78A30;
	    border-color: #F78A30;
		font-size: 14px;
	}
	::v-deep .el-textarea__inner{
		width: 94%;
		font-size: 14px;
	}
	::v-deep .el-date-table td.today span {
      color: #F78A30;
    }
	.uni-date{
		width: 180px;
	}
	.online_times{
		float: left;
	}
	.tips{
		font-weight: 400;
		font-size: 14px;
		color: #A1A1A1;
		width: 30%;
		float: left;
		margin-left: 20px;
	}
	::v-deep .uni-calendar-item__weeks-box .uni-calendar-item--checked{
		background-color: #F78A30;
	}
	
	::v-deep.el-input-group__append, .el-input-group__prepend {
	    background-color: #f2f3f5;
	    border: none;
	}
	::v-deep.el-textarea .el-input__count {
	    color: #909399;
	    background: none;
	    position: absolute;
	    font-size: 12px;
	    bottom: -5px;
	    right: 50px;
	}
	::v-deep.el-upload-list--picture .el-upload-list__item-status-label{
		background: #f78a30;
	}
	@media screen and (max-width: 768px) {
	
	}
</style>
