界面完善

pull/7/head
左丹妮 2 years ago
parent 1ea5bb87dc
commit f767bd59d5

@ -4,15 +4,17 @@
<!-- <block wx:for="{{history}}"> <!-- <block wx:for="{{history}}">
<text class="his-item">{{index + 1}}. {{item}}</text> <text class="his-item">{{index + 1}}. {{item}}</text>
</block> --> </block> -->
<!-- <view wx:for="{{his}}"></view> -->
<text class="title1" >您共进行了{{his[0].index+1}}次彩妆试妆</text>
<view wx:for="{{his}}" wx:key="time" wx:for-item="item"> <view wx:for="{{his}}" wx:key="time" wx:for-item="item">
<text class="title">{{index+1}}: 您第{{item.index+1}}次化妆\n</text> <text class="title">{{index+1}}: 您第{{item.index+1}}次化妆\n</text>
<text class="text">时间:{{item.time}}\n场景#{{item.scene}}\n</text> <text class="text">时间:{{item.time}}\n场景#{{item.scene}}\n</text>
<image src="{{item.image}}"/> <image mode="widthFix" src="{{item.image}}"/>
<!-- 获取妆容图片、介绍 --> <!-- 获取妆容图片、介绍 -->
<text></text> <text class="title">适合彩妆</text>
</view> <image mode="widthFix" src="{{item.res}}"/>
<text>{{index}}</text> </view>
</view> </view>
</view> </view>
<!-- <view class="container log-list"> <!-- <view class="container log-list">
<block wx:for="{{logs}}" wx:key="timeStamp" wx:for-item="log"> <block wx:for="{{logs}}" wx:key="timeStamp" wx:for-item="log">

@ -3,6 +3,13 @@
width:auto; width:auto;
height: auto; height: auto;
background-color: #ddcfc3; background-color: #ddcfc3;
display: flex;
flex-direction: column;
align-items: center;
}
.title1{
font-size: larger;
font-weight: bolder;
} }
.title { .title {
/* 字体大小 */ /* 字体大小 */

Binary file not shown.

Before

Width:  |  Height:  |  Size: 265 KiB

@ -2,9 +2,9 @@
<view class="container"> <view class="container">
<view class="home"> <view class="home">
<!-- <wxs module="now" ></wxs> --> <!-- <wxs module="now" ></wxs> -->
<view>{{filter.day(1621409888000)}}</view> <!-- <view>{{filter.day(1621409888000)}}</view> -->
<text>{{date()}}</text> <!-- <text>{{new Date()}}</text> -->
<text>选择一个妆容开始美好的一天吧!</text> <text>选择一个妆容开始美好的一天吧!</text>
</view> </view>
<view class="mainrec"> <view class="mainrec">

@ -162,32 +162,8 @@ Page({
this_.setData({ this_.setData({
user:wx.getStorageSync('msg').gender=="female"?"小美":"小帅" user:wx.getStorageSync('msg').gender=="female"?"小美":"小帅"
}) })
// if(wx.getStorageSync('msg').gender=="female"){
// this_.setData({
// user:"小美"
// })
// }else if(wx.getStorageSync('msg').gender=="male"){
// this_.setData({
// user:"小帅"
// })
// }else{
// wx.showModal({
// title: 'error',
// content: '请重新上传照片',
// success: function(res) {
// if (res.confirm||res.cancel) {
// console.log('用户点击')
// wx.navigateBack({
// delta: 1
// });
// } //else if (res.cancel) {
// console.log('用户点击取消')
// }
// }
// })
// }
}, },
/** /**
* 生命周期函数--监听页面初次渲染完成 * 生命周期函数--监听页面初次渲染完成
*/ */
@ -200,10 +176,8 @@ Page({
* 获取日期给history * 获取日期给history
*/ */
onShow() { onShow() {
const hisImg = wx.setStorageSync('hisImg',this.imgFilePath) ||[] // const hisImg = wx.setStorageSync('hisImg',this.imgFilePath) ||[]
const hisSce = wx.setStorageSync('hisSce', this.scene)||[] // const hisSce = wx.setStorageSync('hisSce', this.scene)||[]
//history.unshift(Date.now())//?
// wx.setStorageSync('history', history)
}, },
/** /**

@ -1,4 +1,5 @@
// pages/match/result.js // pages/match/result.js
const makeup = require("../../utils/makeup")
Page({ Page({
/** /**
@ -8,13 +9,17 @@ Page({
index:0, index:0,
his:[], his:[],
gongxi:"../images/恭喜.webp", gongxi:"../images/恭喜.webp",
face:wx.getStorageSync('camFilePath'),
result:"../images/test2.jpg"
}, },
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad(options) { onLoad(options) {
// makeup.callMakeupAPI(this.data.face,function(result){
// console.log(result)
// })
}, },
/** /**
@ -32,6 +37,7 @@ Page({
var img=wx.getStorageSync('imgFilePath'); var img=wx.getStorageSync('imgFilePath');
var sce=wx.getStorageSync('scene'); var sce=wx.getStorageSync('scene');
var time=wx.getStorageSync('matchTime'); var time=wx.getStorageSync('matchTime');
var result = this.data.result;//改!
// console.log(time); // console.log(time);
if(!wx.getStorageSync('his')) if(!wx.getStorageSync('his'))
@ -40,7 +46,7 @@ Page({
if(!wx.getStorageSync('index')) if(!wx.getStorageSync('index'))
wx.setStorageSync('index', this_.data.index); wx.setStorageSync('index', this_.data.index);
var i=wx.getStorageSync('index'); var i=wx.getStorageSync('index');
let his_={"index":i,"time":time,"image":img,"scene":sce}; let his_={"index":i,"time":time,"image":img,"scene":sce,"res":result};
if(!_his){ if(!_his){
_his=[his_]; _his=[his_];
}else{ }else{

@ -3,10 +3,10 @@
<view class="res_main" src="{{index}}"> <view class="res_main" src="{{index}}">
<view class="row"> <view class="row">
<image class="icon" src="{{gongxi}}" mode="widthFix"/> <image class="icon" src="{{gongxi}}" mode="widthFix"/>
<text class="text" style="text-align: center;">恭喜您!!这是您第{{index}}次完成妆容~</text> <text class="text" style="text-align: center;font-size: larger;">恭喜您!!这是您第{{index}}次完成妆容~</text>
</view> </view>
<view class="res"> <view class="res">
<image src="{{result}}" mode="widthFix"/>
</view> </view>
</view> </view>

@ -1,134 +0,0 @@
// pages/setting/setting.js
Page({
/**
* 页面的初始数据
*/
data: {
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})
// pages/index/setting/setting.js
const util = require('../../../utils/util.js')
Page({
/**
* 页面的初始数据
*/
data: {
info:["头像","名称","收货地址","当前版本","关于"],
tx:"",
name:"",
currentDate:util.formatTime(new Date(), '-', false),
phone:""
},
bindDateChange: function (e) {
console.log(e.detail.value)
this.setData({
currentDate:e.detail.value
}) },
chooseAddress() {
wx.chooseAddress({
success (res) {
console.log(res.userName)
}
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
var useInfo = wx.getStorageSync('userInfo')
var that = this;
that.setData({
tx:useInfo.avatarUrl,
name:useInfo.nickName,})
},
about(){
wx.navigateTo({
url: '/pages/index/setting/about/about',
})
},
houtai(){
wx.navigateTo({
url: '',
})
},
version(){
wx.showToast({
title: '当前已是最新版本~',
})
},
logout:function() {
wx.removeStorage({
key: 'userInfo',
success (res) {
wx.showModal({
title: '提示',
content: '真的要退出了吗',
cancelText:'我骗你的',
confirmText:'是的没错',
confirmColor:'#000000',
cancelColor:'#576b95',
success (res) {
if (res.confirm) {
wx.reLaunch({
url: '/pages/index/index',
})
} else if (res.cancel) {
console.log('用户点击取消')
}
}
})
}
})
}
})

@ -1,3 +0,0 @@
{
"usingComponents": {}
}

@ -1,93 +0,0 @@
<!--pages/setting/setting.wxml-->
<text>pages/setting/setting.wxml</text>
<view class="info">
<view class="info_more1"><view class="tx1">头像</view>
<view><image src="{{tx}}" class="tx"/></view>
</view>
<view class="hr"></view>
<view class="info_more">昵称
<view class="icon">{{name}}</view>
</view>
<view class="hr"></view>
<view class="info_more" >手机号
<view class="icon">198****5052</view>
</view>
<view class="hr"></view>
<view class="info_more">生日
<view class="icon"><picker class="picker" mode="date" value="{{date}}"end="{{endDate}}" bindchange="bindDateChange">
<view class="picker-date ">
{{currentDate}}
</view>
</picker></view>
</view>
<view class="hr"></view>
<view class="info_more" bindtap="chooseAddress">收货地址
<view class="icon">>></view>
</view>
<view class="hr"></view>
<view class="info_more" bindtap="version">当前版本
<view class="icon">v1.0</view>
</view>
<view class="hr"></view>
<view class="info_more" bindtap="about">关于
<view class="icon">>></view>
</view>
<view class="hr"></view>
<view class="info_more" bindtap="houtai">后台登录入口
<view class="icon">>></view>
</view>
<view class="hr"></view>
</view>
<button bindtap="logout">退出登录</button>

@ -1,49 +0,0 @@
/* pages/setting/setting.wxss */
button{
background-color:rgb(255, 26, 26);
border: none;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display:block;
margin:60rpx auto;
font-size: 16px;
}
.hr{
height: 1rpx;
background-color: rgb(202, 202, 202);
}
.info{
display: flex;
flex-direction: column;
font-size: 30rpx;
margin-left: 30rpx;
margin-top: 10rpx;
}
.info_more1{
display:flex;
justify-content: space-between;
padding-bottom: 20rpx;
padding-top: 20rpx;
}
.info_more{
display:flex;
justify-content: space-between;
padding-bottom: 30rpx;
padding-top: 30rpx;
}
.tx{
width: 100rpx;
height: 100rpx;
border-radius: 50%;
margin-right: 10rpx;
}
.icon{
padding-right: 30rpx;
color: rgb(167, 164, 164);
}
.tx1{
padding-top: 30rpx;
}

@ -0,0 +1,77 @@
import CryptoJS from 'crypto-js';
// 参数说明:
// apiKey: 您的API Key
const apiKey = '0e3b9237c5374d7e91145edfcd893685';
// secretKey: 您的Secret Key
const secretKey = '982915da055446bba6d912d43c003ce4';
// callback: 结果的回调
function callMakeupAPI(base64_encoded_image, callback) {
const url = 'https://openapi.mtlab.meitu.com/v3/makeup';
const API_HTTP_METHOD = 'POST';
const timestamp = Math.floor(Date.now() / 1000).toString();
const request_ = {
media_info_list: [
{
media_data: base64_encoded_image,
//这里是经过base64编码的图片或者url
media_extra: {
// 包含对多媒体文件的描述,例如图片中的人脸点,五官属性等
},
media_profiles: {
media_data_type: 'jpg'
// 'jpg',表示 media_data 是经过 base64 压缩过的图片,默认'jpg'
//'url',表示 media_data 是图片 url 地址
}
}
],
parameter: {
makeupId: 1, // 妆容编号
makeupAlpha: 70, // 妆容透明度
beautyAlpha: 70, // 美颜透明度
hairMask: 0, // 是否染发
beautyLevel: 0, // 磨皮程度
rsp_media_type: 'base64' // 融合结果图像以base64编码方式返回
},
extra: {
// 网关处理额外信息
}
};
const requestData = JSON.stringify(request_);
const signature = generateSignature(API_HTTP_METHOD, url, requestData, apiKey, secretKey, timestamp);
//?
wx.request({
url: url,
method: 'POST',
header: {
'Content-Type': 'application/json',
'X-CurTime': timestamp,
'X-CheckSum': signature
},
data: requestData,
success: (result) => {
// 获取结果
return typeof callback === 'function' && callback(result.data);
},
fail: (error) => {
// 获取报错信息
return typeof callback === 'function' && callback(error.data);
}
});
}
// 生成签名
function generateSignature(method, url, body, apiKey, secretKey, timestamp) {
const content = method + '\n' + url + '\n' + timestamp + '\n' + apiKey + '\n' + CryptoJS.MD5(body).toString();
const hmac = CryptoJS.HmacSHA256(content, secretKey);
const signature = CryptoJS.enc.Base64.stringify(hmac);
return signature;
}
// 导出方法
module.exports = {
callMakeupAPI: callMakeupAPI
};
Loading…
Cancel
Save