select_photo.js 2.57 KB
/*
 * @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]})
            }
        })

    },




})