parent
1ea5bb87dc
commit
f767bd59d5
Before Width: | Height: | Size: 265 KiB |
@ -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…
Reference in new issue