|
|
@ -1,5 +1,6 @@
|
|
|
|
// pages/match/photo.js
|
|
|
|
// pages/match/photo.js
|
|
|
|
const client = require("../../utils/client");
|
|
|
|
const client = require("../../utils/client");
|
|
|
|
|
|
|
|
const makeup = require("../../utils/makeup")
|
|
|
|
const util = require("../../utils/util.js");
|
|
|
|
const util = require("../../utils/util.js");
|
|
|
|
|
|
|
|
|
|
|
|
Page({
|
|
|
|
Page({
|
|
|
@ -10,9 +11,10 @@ Page({
|
|
|
|
data: {
|
|
|
|
data: {
|
|
|
|
imgFilePath:"",
|
|
|
|
imgFilePath:"",
|
|
|
|
camFilePath:"",
|
|
|
|
camFilePath:"",
|
|
|
|
|
|
|
|
result:"",
|
|
|
|
// src:"",
|
|
|
|
// src:"",
|
|
|
|
scene:"",
|
|
|
|
scene:"",
|
|
|
|
imgid:wx.getStorageSync('imgid'),
|
|
|
|
imgid:0,
|
|
|
|
msg:{},
|
|
|
|
msg:{},
|
|
|
|
user:"",
|
|
|
|
user:"",
|
|
|
|
//这个是实际发送给阿里云的图片链接,到时候需要开发自己将本地或者拍照的照片转换成oss链接
|
|
|
|
//这个是实际发送给阿里云的图片链接,到时候需要开发自己将本地或者拍照的照片转换成oss链接
|
|
|
@ -32,6 +34,51 @@ Page({
|
|
|
|
})
|
|
|
|
})
|
|
|
|
wx.setStorageSync('matchTime', util.formatTime(new Date()))
|
|
|
|
wx.setStorageSync('matchTime', util.formatTime(new Date()))
|
|
|
|
console.log(wx.getStorageSync('matchTime'));
|
|
|
|
console.log(wx.getStorageSync('matchTime'));
|
|
|
|
|
|
|
|
this.MakeupApi();
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
tipwindow(){
|
|
|
|
|
|
|
|
var _this=this;
|
|
|
|
|
|
|
|
wx.showActionSheet({
|
|
|
|
|
|
|
|
itemList: ['从手机相册选择', '拍照'],
|
|
|
|
|
|
|
|
success: function(res) {
|
|
|
|
|
|
|
|
let sourceType="";
|
|
|
|
|
|
|
|
if(res.tapIndex==0){
|
|
|
|
|
|
|
|
sourceType="album";
|
|
|
|
|
|
|
|
_this.img_w_show(sourceType);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if(res.tapIndex==1){
|
|
|
|
|
|
|
|
_this.sccamera();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
console.log(res.tapIndex)
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
fail: function(res) {
|
|
|
|
|
|
|
|
console.log(res.errMsg)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
img_w_show(sourceType){
|
|
|
|
|
|
|
|
var _this=this;
|
|
|
|
|
|
|
|
wx.chooseMedia({
|
|
|
|
|
|
|
|
count: 1, // 默认9
|
|
|
|
|
|
|
|
mediaType:['image'],//仅照片
|
|
|
|
|
|
|
|
sourceType: [sourceType], // 来源是相册or相机
|
|
|
|
|
|
|
|
success: function (res) {
|
|
|
|
|
|
|
|
// 返回选定照片的本地文件路径列表,tempFilePath可以作为img标签的src属性显示图片
|
|
|
|
|
|
|
|
console.log(res);
|
|
|
|
|
|
|
|
var tempFilePaths = res.tempFiles['0']['tempFilePath'];
|
|
|
|
|
|
|
|
// var size = res.tempFiles['0']['size'];
|
|
|
|
|
|
|
|
console.log(wx.getStorageSync('imgid'))
|
|
|
|
|
|
|
|
_this.setData({
|
|
|
|
|
|
|
|
camFilePath: (tempFilePaths?tempFilePaths:"")
|
|
|
|
|
|
|
|
//无法赋值-路径获取问题
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
wx.setStorageSync('camFilePath', _this.data.src);//存入缓存,实现数据转移
|
|
|
|
|
|
|
|
wx.pageScrollTo({//滚动到目标位置
|
|
|
|
|
|
|
|
scrollTop: 1200,
|
|
|
|
|
|
|
|
duration:100
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
})
|
|
|
|
},
|
|
|
|
},
|
|
|
|
takePhoto() {
|
|
|
|
takePhoto() {
|
|
|
|
var _this=this;
|
|
|
|
var _this=this;
|
|
|
@ -58,9 +105,9 @@ Page({
|
|
|
|
scope: 'scope.camera',
|
|
|
|
scope: 'scope.camera',
|
|
|
|
success () {
|
|
|
|
success () {
|
|
|
|
//用户允许授权,进行下一步操作
|
|
|
|
//用户允许授权,进行下一步操作
|
|
|
|
const cameraContext = wx.createCameraContext();//获取相机上下文?
|
|
|
|
// const cameraContext = wx.createCameraContext();//获取相机上下文?
|
|
|
|
wx.pageScrollTo({//滚动到目标位置
|
|
|
|
wx.pageScrollTo({//滚动到目标位置
|
|
|
|
scrollTop: 700,
|
|
|
|
scrollTop: 500,
|
|
|
|
duration:300
|
|
|
|
duration:300
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -95,15 +142,19 @@ Page({
|
|
|
|
var message;
|
|
|
|
var message;
|
|
|
|
var msg = {age:"",gender:"",uppercolor:"",upperwear:"",lowercolor:"",lowerwear:"",glasses:"",handbag:"",shoulderbag:"",hat:""}
|
|
|
|
var msg = {age:"",gender:"",uppercolor:"",upperwear:"",lowercolor:"",lowerwear:"",glasses:"",handbag:"",shoulderbag:"",hat:""}
|
|
|
|
var flag=0;
|
|
|
|
var flag=0;
|
|
|
|
|
|
|
|
var id=wx.getStorageSync('imgid');
|
|
|
|
|
|
|
|
this.setData({
|
|
|
|
|
|
|
|
imgid:id
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
console.log("imgid")
|
|
|
|
console.log(this_.data.imgid)
|
|
|
|
console.log(this_.data.imgid)
|
|
|
|
if(this_.data.imgid==3){
|
|
|
|
if(this_.data.imgid==3){
|
|
|
|
this_.setData({
|
|
|
|
this_.setData({
|
|
|
|
msg:{age:"Age18-60",gender:"female",uppercolor:"白",upperwear:"LongSleeve",lowercolor:"白",lowerwear:"Skirt&Dress",glasses:"No",handbag:"No",shoulderbag:"No",hat:"No"}
|
|
|
|
msg:{age:"Age18-60",gender:"female",uppercolor:"白",upperwear:"LongSleeve",lowercolor:"白",lowerwear:"Skirt&Dress",glasses:"No",handbag:"No",shoulderbag:"No",hat:"No"}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
wx.setStorageSync('msg', this_.data.msg);
|
|
|
|
wx.setStorageSync('msg', this_.data.msg);
|
|
|
|
console.log("test:")
|
|
|
|
// console.log("test:")
|
|
|
|
console.log(msg)
|
|
|
|
// console.log(msg)
|
|
|
|
}else{
|
|
|
|
}else{
|
|
|
|
if(this_.data.imgid==1){
|
|
|
|
if(this_.data.imgid==1){
|
|
|
|
this_.setData({
|
|
|
|
this_.setData({
|
|
|
@ -128,18 +179,11 @@ Page({
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
// this_.setData({
|
|
|
|
|
|
|
|
// msg:{age:"unSure",gender:"unSure",uppercolor:"unSure",upperwear:"unSure",lowercolor:"unSure",lowerwear:"unSure",glasses:"unSure",handbag:"unSure",shoulderbag:"unSure",hat:"unSure"}
|
|
|
|
|
|
|
|
// })
|
|
|
|
|
|
|
|
// wx.setStorageSync('msg', this_.data.msg)
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(flag==1){
|
|
|
|
if(flag==1){
|
|
|
|
client.callRecognizePersonFace(wx, this.data.imgUrl,function(result) {
|
|
|
|
client.callRecognizePersonFace(wx, this.data.imgUrl,function(result) {
|
|
|
|
console.log(result)
|
|
|
|
console.log(result)
|
|
|
|
message=result.Data.Attributes[0]
|
|
|
|
message=result.Data.Attributes[0]
|
|
|
|
// console.log(message);
|
|
|
|
|
|
|
|
// console.log(msg);
|
|
|
|
|
|
|
|
// console.log(message.UpperColor.Name);
|
|
|
|
|
|
|
|
msg.age=message.Age.Name;
|
|
|
|
msg.age=message.Age.Name;
|
|
|
|
msg.gender=message.Gender.Name;
|
|
|
|
msg.gender=message.Gender.Name;
|
|
|
|
msg.uppercolor=message.UpperColor.Name;
|
|
|
|
msg.uppercolor=message.UpperColor.Name;
|
|
|
@ -163,6 +207,21 @@ Page({
|
|
|
|
user:wx.getStorageSync('msg').gender=="female"?"小美":"小帅"
|
|
|
|
user:wx.getStorageSync('msg').gender=="female"?"小美":"小帅"
|
|
|
|
})
|
|
|
|
})
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
MakeupApi:function(){
|
|
|
|
|
|
|
|
// console.log(this.data.face);
|
|
|
|
|
|
|
|
makeup.callMakeupAPI(this.data.face,function(result){
|
|
|
|
|
|
|
|
// console.log(result);
|
|
|
|
|
|
|
|
if(result.media_info_list)
|
|
|
|
|
|
|
|
console.log(result.media_info_list[0].media_data)
|
|
|
|
|
|
|
|
// this.setData({
|
|
|
|
|
|
|
|
// result:result
|
|
|
|
|
|
|
|
// })
|
|
|
|
|
|
|
|
this.data.result=result.media_info_list[0].media_data;
|
|
|
|
|
|
|
|
console.log("(photo.js)result:")
|
|
|
|
|
|
|
|
console.log(this.data.result);
|
|
|
|
|
|
|
|
wx.setStorageSync("facres", this.data.result);
|
|
|
|
|
|
|
|
}.bind(this))
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
|
|