用户
 找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,登录网站

1

主题

1

帖子

8

积分

新手上路

Rank: 1

积分
8
2019-8-9 02:18:51 tanmax 新手上路 楼主 0286
[AppleScript] 纯文本查看 复制代码
function _defineProperty(e, t, a) {
    return t in e ? Object.defineProperty(e, t, {
        value: a,
        enumerable: !0,
        configurable: !0,
        writable: !0
    }) : e[t] = a, e;
}

var t, e = getApp();

Page({
    data: {
        photo: "../../images/photo111.jpg",
        multiIndex: [ 0, 0 ],
        multiArray: [],
        menus: "",
        menusid: 0,
        latitude: 0,
        longitude: 0,
        urlArr: [],
        fee: 0,
        imgsrc: "",
        mloading: 0
    },
    onLoad: function() {
        t = this, e.cfun.getuser(e.globalData.userinfo);
        for (var a = [], o = [], l = [], n = 0, s = 0, i = 0, r = e.globalData.menus; n < r.length; n++) if (r[n].twolevel) {
            for (a.push(r[n].title), i = r[n].twolevel.length, s = 0, o = []; s < i; s++) o.push(r[n].twolevel[s].name);
            l.push(o);
        }
        t.setData({
            multiArray: [ a, l[0] ],
            itemtwo: l,
            fee: e.globalData.appinfo.fee,
            mloading: 1
        }), e.util.getUserInfo();
    },
    chooseImg: function() {
        var o = e.util.url("entry/wxapp/uploadimgs", {
            m: "lshd_telbook"
        });
        wx.chooseImage({
            count: 1,
            sizeType: [ "compressed" ],
            sourceType: [ "album", "camera" ],
            success: function(e) {
                var a = e.tempFilePaths;
                wx.uploadFile({
                    url: o,
                    filePath: a[0],
                    name: "file",
                    success: function(e) {
                        console.log(e.data), "0" != e.data ? t.setData({
                          photo: a[0],
                            imgsrc: e.data.replace(/\"/g, "")
                        }) : t.setData({
                            photo: "../../images/photo111.jpg"
                        }), console.log(t.data.imgsrc);
                    }
                });
            }
        });
    },
    bindMultiPickerChange: function(a) {
        console.log("picker123发送选择改变,携带值为", a.detail.value), console.log(e.globalData.menus[a.detail.value[0]].twolevel[a.detail.value[1]].id), 
        t.setData({
            menusid: e.globalData.menus[a.detail.value[0]].twolevel[a.detail.value[1]].id,
            multiIndex: a.detail.value
        }), a.detail.value ? t.setData({
            inputchooseclass: !0
        }) : t.setData({
            inputchooseclass: !1
        });
    },
    bindMultiPickerColumnChange: function(e) {
        console.log("修改的列为", e.detail.column, ",值为", e.detail.value);
        var a = {
            multiArray: t.data.multiArray,
            multiIndex: t.data.multiIndex
        };
        switch (a.multiIndex[e.detail.column] = e.detail.value, e.detail.column) {
          case 0:
            switch (a.multiIndex[0]) {
              case 0:
              case 1:
              case 2:
              case 3:
              case 4:
              case 5:
              case 6:
              case 7:
              case 8:
              case 9:
              case 10:
                a.multiArray[1] = this.data.itemtwo[a.multiIndex[0]];
            }
            a.multiIndex[1] = 0;
        }
        t.setData(a);
    },
    getAddress: function() {
        wx.chooseLocation({
            success: function(e) {
                console.log(e), t.setData({
                    latitude: e.latitude,
                    longitude: e.longitude,
                    address: e.address
                });
            },
            fail: function() {},
            complete: function() {}
        });
    },
    upImg: function() {
        var l = this;
        t.setData({
            mloading: 0
        });
        var n = e.util.url("entry/wxapp/uploadimgs", {
            m: "lshd_telbook"
        });
        wx.chooseImage({
            count: 9,
            sizeType: [ "compressed" ],
            sourceType: [ "album", "camera" ],
            success: function(e) {
                var a = e.tempFilePaths, o = [];
                console.log(a[0]), wx.uploadFile({
                    url: n,
                    filePath: a[0],
                    name: "file",
                    success: function(e) {
                        "0" != e.data ? ((o = t.data.urlArr).push(e.data.replace(/\"/g, "")), console.log(e.data.replace(/\"/g, "")), 
                        l.setData({
                            urlArr: o
                        })) : l.setData({
                            photo: "../../images/photo111.png"
                        }), t.setData({
                            mloading: 1
                        }), console.log(t.data.urlArr);
                    }
                });
            }
        });
    },
    delete: function(e) {
        var a = e.currentTarget.dataset.index, o = t.data.urlArr;
        o.splice(a, 1), t.setData({
            urlArr: o
        }), console.log(t.data.urlArr);
    },
    registerSuccess: function(a) {
        console.log(a), e.cfun.setformid(a.detail.formId, e.globalData.userid);
        var o = a.detail.value;
        o.username ? o.usertel ? o.shopname ? o.shoptel ? t.data.menusid < 1 ? wx.showModal({
            content: "请选择分类",
            showCancel: !1,
            confirmColor: "#996600",
            confirmText: "我知道啦"
        }) : t.data.imgsrc ? o.shopaddress ? (t.setData({
            mloading: 0
        }), wx.request({
            url: e.util.url("entry/wxapp/upinfo"),
            data: {
                userid: e.globalData.userid,
                m: "lshd_telbook",
                opt: "insert",
                shophead: t.data.imgsrc,
                shopname: o.shopname,
                shoptel: o.shoptel,
                menusid: t.data.menusid,
                latitude: t.data.latitude,
                longitude: t.data.longitude,
                shopaddress: o.shopaddress,
                shopdes: o.shopdes,
                infoimg: t.data.urlArr,
                username: o.username,
                usertel: o.usertel
            },
            success: function(e) {
                console.log(e.data), 0 < e.data ? t.pays(e.data) : (t.setData({
                    mloading: 1
                }), wx.navigateTo({
                    url: "../telDetail/telDetail?itemid=" + event.currentTarget.dataset.id
                }));
            }
        })) : wx.showModal({
            content: "请选择地址",
            showCancel: !1,
            confirmColor: "#996600",
            confirmText: "我知道啦"
        }) : wx.showModal({
            content: "请上传照片",
            showCancel: !1,
            confirmColor: "#996600",
            confirmText: "我知道啦"
        }) : wx.showModal({
            content: "请输入电话",
            showCancel: !1,
            confirmColor: "#996600",
            confirmText: "我知道啦"
        }) : wx.showModal({
            content: "请输入名称",
            showCancel: !1,
            confirmColor: "#996600",
            confirmText: "我知道啦"
        }) : wx.showModal({
            content: "请输入电话",
            showCancel: !1,
            confirmColor: "#996600",
            confirmText: "我知道啦"
        }) : wx.showModal({
            content: "请输入姓名",
            showCancel: !1,
            confirmColor: "#996600",
            confirmText: "我知道啦"
        });
    },
    pays: function(l) {
        0 < e.globalData.appinfo.fee ? (e.util.getUserInfo(), e.util.request({
            url: "entry/wxapp/presult",
            data: {
                m: "lshd_telbook",
                fee: e.globalData.appinfo.fee
            },
            success: function(a) {
                console.log(a);
                var o = a.data;
                wx.requestPayment({
                    timeStamp: o.timeStamp,
                    nonceStr: o.nonceStr,
                    package: o.package,
                    signType: "MD5",
                    paySign: o.paySign,
                    success: function(e) {
                        console.log(e), t.ispay(o.package), t.setData({
                            mloading: 1
                        }), wx.navigateTo({
                            url: "../telDetail/telDetail?itemid=" + l
                        });
                    },
                    fail: function(a) {
                        e.cfun.delitem(l), t.setData({
                            mloading: 1
                        });
                    }
                });
            },
            fail: function(a) {
                return e.cfun.delitem(l), t.setData({
                    mloading: 1
                }), 0;
            }
        })) : (t.setData({
            mloading: 1
        }), wx.navigateTo({
            url: "../telDetail/telDetail?itemid=" + l
        }));
    },
    ispay: function(e) {
        var t;
        wx.request({
            url: app.util.url("entry/wxapp/reguser", {
                m: "lshd_qiandao"
            }),
            data: (t = {
                op: "ispay",
                userid: app.globalData.userid,
                prepay: e
            }, _defineProperty(t, "prepay", e), _defineProperty(t, "groups", app.globalData.groups), 
            t),
            success: function(e) {
                return console.log(e.data), app.globalData.ispayres = 1;
            }
        });
    },
    onReady: function() {},
    onShow: function() {},
    onShareAppMessage: function() {}
});



如何进行上传的图片压缩,谢谢
发新帖
您需要登录后才可以回帖 登录 | 立即注册