module.exports = {

	//新物业图片预览type值为图片类型键名。001视频002图片
	imgClick(index, list, type) {
		let imgArr = JSON.parse(JSON.stringify(list));
		// console.log(imgArr)
		// console.log(this.$fileHost)
		let arr = [];
		let current = index;
		imgArr.map(item => {
			if (type && type != '') {
				if (item[type] == '002') {
					if (item.url) {
						arr.push(item.url)
					} else {
						arr.push(item)
					}
				}
			} else {
				arr.push(item)
			}

		})

		for (let i = 0; i < index + 1; i++) {
			if (imgArr[i][type] == '001') {
				current--
			}
		}
		console.log(arr)
		uni.previewImage({
			current: current,
			urls: arr
		});
	},

	//新物业图片预览type值为图片类型键名。002视频001图片
	videoList(index, list, type) {
		console.log(imgArr, list)
		let imgArr = JSON.parse(JSON.stringify(list));

		let arr = [];
		let current = index;
		// imgArr.map(item => {
		// 	if (item[type] == '002') {
		// 		if (item.url) {
		// 			let obj = {
		// 				faceImg: item.faceImg,
		// 				url: item.url,
		// 				resourceType: '002'
		// 			}
		// 			arr.push(obj)
		// 		} else {
		// 			let obj = {
		// 				faceImg: item.faceImg,
		// 				url: item,
		// 				resourceType: '002'
		// 			}
		// 			arr.push(obj)
		// 		}
		// 	}
		// })

		// for (let i = 0; i < index + 1; i++) {
		// 	if (imgArr[i][type] == '001') {
		// 		current--
		// 	}
		// }
		// console.log(arr)
		uni.setStorageSync("previewList", imgArr)
		uni.setStorageSync("previewIndex", index)
		uni.navigateTo({
			url: `/pages/swiperPreview/swiperPreview`
		})
		// return msg
	},

	formatPhone(e) {
		if (e == '') return
		var tel = e;
		tel = "" + tel;
		var newTel = tel.substr(0, 3) + "****" + tel.substr(7)
		return newTel
	},
	formatName(e) {
		if (e == '') return
		var name = e;
		name = "" + name;
		var newName = name.substr(0, 1) + "*" + name.substr(name.length - 1)
		return newName
	}
}
