<template>
	<view>
		<shmily-drag-image :number="9" v-model="list"></shmily-drag-image>
		<view class="save" @tap="updateCard()">保存</view>
	</view>
</template>

<script>
const app = getApp();
const req = require('../../utils/request.js');
const api = require('../../utils/api.js');
import shmilyDragImage from "../../card/components/shmily-drag-image/components/shmily-drag-image/shmily-drag-image.vue";
export default {
	components:{
		shmilyDragImage
	},
  data() {
	return {
	  list: [],
	  id: ''
	}
  },
  onLoad(opt) {
  	this.id = opt.id;
  	let pages = getCurrentPages();
  	let prevPage = pages[pages.length - 2];
  	if(prevPage && prevPage.$vm.cardInfo.pictures){
		console.log('图片',prevPage.$vm.cardInfo.pictures)
  		this.list = prevPage.$vm.cardInfo.pictures.split(',');
  	}
  },
  
  methods: {
  	/**
  	 * @param {Object} type 1图片 2、视频
  	 * @param {Object} url 资源地址
  	 */
  	updateCard() {
  		var dataP = {};
  		dataP.id = this.id;
		dataP.pictures = this.list.join(',');
  		req.postRequest(api.card_saveOrUpdate, dataP, json => {
			uni.navigateBack()
  		});
  	},
  // 	save() {
  // 		if(!this.brief) return req.msg('输入个人简介内容')
  // 		let pages = getCurrentPages(); //获取所有页面栈实例列表
  // 		let prevPage = pages[pages.length - 2]; //上一页页面实例
  // 		prevPage.$vm.brief = this.brief;
  // 		uni.navigateBack({
  // 			//uni.navigateTo跳转的返回，默认1为返回上一级
  // 			delta: 1
  // 		});
  // 	}
  }
}
</script>

<style>
	@import './index.css';
</style>