select_photo.js
2.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/*
* @Author: your name
* @Date: 2022-02-16 14:34:42
* @LastEditTime: 2022-02-16 15:42:25
* @LastEditors: Please set LastEditors
* @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
* @FilePath: \MShopWeApp\packageB\pages\AI-test-skin\select_photo\select_photo.js
*/
// packageB/pages/AI-test-skin/select_photo/select_photo.js
const app = getApp();
const request = app.request;
const os = app.globalData;
const setting = os.setting;
const ut = require('../../../../utils/util');
Page({
/**
* 页面的初始数据
*/
data: {
iurl: setting.imghost,
gl_skin_img: null,
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
var img=getApp().globalData.skin_img;
this.setData({gl_skin_img:img})
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
},
//-- 完成选择 --
ok_select:function () {
var th=this;
app.request.uploadFile("/api/weshop/baidubce/face/uploadImg?uploadPath=faceimg&storeId="+setting.stoid, {
filePath: th.data.gl_skin_img,
name: "file",
success: function (e) {
if(e.data.code==0) {
getApp().globalData.face_img=e.data.data.img;
getApp().globalData.face_SourceImg=e.data.data.SourceImg;
let url = "/packageB/pages/AI-test-skin/analyse/analyse"; //跳到分析页
app.goto(url);
} else {
wx.showToast({
title: e.data.msg,
icon: 'none',
duration: 2000
});
};
}
});
},
//-- 重新从相册中选择图片 --
show_pai_pop:function () {
var th=this;
//选择和拍照一张图片
wx.chooseImage({
count: 1,
sizeType: ['original', 'compressed'],
sourceType: ['album', 'camera'],
success (res) {
let imgArr = res.tempFilePaths;
getApp().globalData.skin_img=imgArr[0];
th.setData({gl_skin_img:imgArr[0]})
}
})
},
})