jason.lu 6 سال پیش
والد
کامیت
dcae3a52f0

+ 2 - 1
sourcecode/h5app/vue/src/components/schoolidCard.vue

@@ -142,7 +142,8 @@
             },
             getIdentityInfo: function (obj) {
                 //this;
-                if (!localStorage.getItem('frontend-userid')) {
+                if (localStorage.getItem('frontend-userid') == undefined || localStorage.getItem('frontend-userid') == null) {
+                    localStorage.removeItem('frontend-userid');
                     this.$router.push('login');
                     return;
                 }

+ 13 - 13
sourcecode/h5app/vue/src/connector/basic-service.js

@@ -436,19 +436,19 @@ var BasicFunction = new (function () {
     };
 
     this.getSigned = function(apilist, func) {
-        let that = func;
-        this.get_data("!!/wxjs/signed.php?purl=" + encodeURIComponent(location.href),
-        function(ret){
-            wx.config({
-                debug: false,
-                appId: ret.appId,
-                timestamp: ret.timestamp,
-                nonceStr: ret.nonceStr,
-                signature: ret.signature,
-                jsApiList: apilist
-            });
-            that();
-        }, "");
+        // let that = func;
+        // this.get_data("!!/wxjs/signed.php?purl=" + encodeURIComponent(location.href),
+        // function(ret){
+        //     wx.config({
+        //         debug: false,
+        //         appId: ret.appId,
+        //         timestamp: ret.timestamp,
+        //         nonceStr: ret.nonceStr,
+        //         signature: ret.signature,
+        //         jsApiList: apilist
+        //     });
+        //     that();
+        // }, "");
     };
 
     this.gotoJsLogin = function() {

+ 162 - 136
sourcecode/h5app/vue/src/views/PresentRegister.vue

@@ -116,11 +116,138 @@
             }
         },
         methods: {
+            uploadNewPresent() {
+                let that = this;
+                let imgURL = this.imgUrl;
+                let tag = this.tag;
+                let gender = this.gender;
+                let userId = localStorage.getItem("frontend-userid");
+                imgURL = '/' + imgURL.split('/')[3] + '/' + imgURL.split('/')[4] + '/' + imgURL.split('/')[5];
+                let present = [{
+                    goodid: this.presentId,
+                    name: this.presentName,
+                    goodsNo: "0", modelId: "0",
+                    ownerId: userId.toString(),
+                    goodFirstKind: gender,
+                    goodSecondKind: tag.toString(),
+                    sellPrice: "0.0", marketPrice: "0.0", costPrice: "0.0",
+                    upTime: getNowFormatDate(), downTime: getNowFormatDate(), createTime: getNowFormatDate(),
+                    storeNums: "0",
+                    img: imgURL,
+                    isDel: "0", content: "none", keywords: "none",
+                    description: that.desc,
+                    searchWords: "", weight: "0.0", point: "0", unit: "0", brandId: "0",
+                    visit: "0", favorite: "0", sort: "0", listImg: "xx.jpg",
+                    smallImg: "xx.jpg", specArray: "{}", exp: "0"
+                }];
+                // console.log(present);
+                let url = "updateBatch";
+                if (that.presentId === '') url = "saveBatch";
+                BasicFunction.get_data("smartGoods/" + url, function (response) {
+                    // console.log("------ Data Rcvd in PresentReg --------");
+                    // console.log(response);
+                    if (response.ret === "10000") {
+                        Toast.success('上传成功!');
+                        that.$router.push('share');
+                    } else {
+                        Toast.fail("上传失败,请检查网络");
+                        that.loading = false;
+                    }
+                }, present);
+            },
+            compressImg: function () {
+                let that = this;
+                let fileObj = this.photo;
+                photoCompress(fileObj, {
+                    quality: 0.2
+                }, function (base64Codes) {
+                    let formData = new FormData();
+                    //console.log("压缩后:" + base.length / 1024 + " " + base);
+                    var bl = convertBase64UrlToBlob(base64Codes);
+                    // formData.append('file', fileObj);
+                    console.log(fileObj);
+                    formData.append("file", bl); // 文件对象
+                    console.log(bl);
+                    console.log("file_" + Date.parse(new Date()) + ".jpg");
+                    that.updateUploadPresent(formData);
+                });
+            },
+
+            saveOrUpdateGift: function (present) {
+                let that = this;
+                let url = "updateBatch";
+                if (that.presentId == undefined || that.presentId == null || that.presentId === '') url = "saveBatch";
+                BasicFunction.get_data("smartGoods/" + url, function (response) {
+                    // console.log("------ Data Rcvd in PresentReg --------");
+                    // console.log(response);
+                    if (response.ret === "10000") {
+                        Toast.success('上传成功!');
+                        that.$router.push('share');
+                    } else {
+                        Toast.fail("上传失败,请检查网络");
+                        that.loading = false;
+                    }
+                }, present);
+            }, updateUploadPresent: function (formData) {
+                let that = this;
+                let tag = this.tag;
+                let gender = this.gender;
+                let userId = localStorage.getItem("frontend-userid");
+                BasicFunction.get_data("fileserver/upload?sign=abcdefg", function (res) {
+                    try {
+                        let imgURL = res.model;
+                        if (res.ret === '10000' && res.model != undefined && imgURL.length > 0) {
+                            // console.log('img:' + imgURL);
+                            let present = [{
+                                goodid: that.presentId,
+                                name: that.presentName,
+                                goodsNo: "0",
+                                modelId: "0",
+                                ownerId: userId.toString(),
+                                goodFirstKind: gender,
+                                goodSecondKind: tag.toString(),
+                                sellPrice: "0.0",
+                                marketPrice: "0.0",
+                                costPrice: "0.0",
+                                upTime: getNowFormatDate(),
+                                downTime: getNowFormatDate(),
+                                createTime: getNowFormatDate(),
+                                storeNums: "0",
+                                img: imgURL,
+                                isDel: "0",
+                                content: "none",
+                                keywords: "none",
+                                description: that.desc,
+                                searchWords: "",
+                                weight: "0.0",
+                                point: "0",
+                                unit: "0",
+                                brandId: "0",
+                                visit: "0",
+                                favorite: "0",
+                                sort: "0",
+                                listImg: "xx.jpg",
+                                smallImg: "xx.jpg",
+                                specArray: "{}",
+                                exp: "0"
+                            }];
+                            that.saveOrUpdateGift(present);
+                        } else {
+                            Toast.fail('上传图片失败,请检查网络');
+                            that.loading = false;
+                        }
+                    } catch (e) {
+                        console.warn(e);
+                        Toast.fail('上传图片失败,请检查网络');
+                        that.loading = false;
+                    }
+                }, formData);
+            },
             publishPresent() {
                 Toast.loading({
                     mask: true,
-                    message: '图片上传较慢,请耐心等待...',
-                    duration: 3000
+                    message: '此过程大约需要15s,你的礼品正在拼命上传,请耐心等待...',
+                    duration: 20000
                 });
                 this.loading = true;
                 // 检验输入
@@ -153,9 +280,6 @@
                 }
                 // 上传礼物信息
                 let userId = localStorage.getItem("frontend-userid");
-                let tag = this.tag;
-                let gender = this.gender;
-
                 // console.log('------- photo -------');
                 // console.log(this.photo);
                 if(userId == null || userId === undefined){
@@ -166,141 +290,16 @@
                 let that = this;
                 // 如果没有改变图片,直接上传
                 if (this.imgUrl && this.imgUrl === this.photo) {
-                    let imgURL = this.imgUrl;
-                    imgURL = '/' + imgURL.split('/')[3] + '/' + imgURL.split('/')[4] + '/' + imgURL.split('/')[5];
-                    let present = [{
-                        goodid: this.presentId,
-                        name: this.presentName,
-                        goodsNo: "0", modelId: "0",
-                        ownerId: userId.toString(),
-                        goodFirstKind: gender,
-                        goodSecondKind: tag.toString(),
-                        sellPrice: "0.0", marketPrice: "0.0", costPrice: "0.0",
-                        upTime: getNowFormatDate(), downTime: getNowFormatDate(), createTime: getNowFormatDate(),
-                        storeNums: "0",
-                        img: imgURL,
-                        isDel: "0", content: "none", keywords: "none",
-                        description: that.desc,
-                        searchWords: "", weight: "0.0", point: "0", unit: "0", brandId: "0",
-                        visit: "0", favorite: "0", sort: "0", listImg: "xx.jpg",
-                        smallImg: "xx.jpg", specArray: "{}", exp: "0"
-                    }];
-                    // console.log(present);
-                    let url = "updateBatch";
-                    if (that.presentId === '') url = "saveBatch";
-                    BasicFunction.get_data("smartGoods/" + url, function (response) {
-                        // console.log("------ Data Rcvd in PresentReg --------");
-                        // console.log(response);
-                        if (response.ret === "10000") {
-                            that.$router.push('share');
-                        } else {
-                            Toast.fail("上传失败,请检查网络");
-                            that.loading = false;
-                        }
-                    }, present);
-                }
-                else {
-                    let formData = new FormData();
-                    // formData.append('file', this.photo);
-                    let fileObj = this.photo;
-
-                    if (fileObj.size / 1024 > 1025) { //大于1M,进行压缩上传
-                        photoCompress(fileObj, {
-                            quality: 0.2
-                        }, function (base64Codes) {
-                            //console.log("压缩后:" + base.length / 1024 + " " + base);
-                            var bl = convertBase64UrlToBlob(base64Codes);
-                            // formData.append('file', fileObj);
-                            console.log(fileObj);
-                            formData.append("file", bl); // 文件对象
-                            console.log(bl);
-                            console.log("file_" + Date.parse(new Date()) + ".jpg");
-                        });
-                    } else { //小于等于1M 原图上传
-                        formData.append('file', this.photo);
-                    }
-
-                    // 先上传图片
-                    BasicFunction.get_data("fileserver/upload?sign=abcdefg", function (res) {
-                        // console.log('----- upload photo result -----');
-                        // console.log(res);
-                        // if (res.model === undefined || res.model.length === 0) {
-                        //     Toast.fail('上传失败,请重试');
-                        //     return;
-                        // }
-                        try {
-                            let imgURL = res.model;
-                            if (res.ret === '10000') {
-                                // console.log('img:' + imgURL);
-                                let present = [{
-                                    goodid: that.presentId,
-                                    name: that.presentName,
-                                    goodsNo: "0",
-                                    modelId: "0",
-                                    ownerId: userId.toString(),
-                                    goodFirstKind: gender,
-                                    goodSecondKind: tag.toString(),
-                                    sellPrice: "0.0",
-                                    marketPrice: "0.0",
-                                    costPrice: "0.0",
-                                    upTime: getNowFormatDate(),
-                                    downTime: getNowFormatDate(),
-                                    createTime: getNowFormatDate(),
-                                    storeNums: "0",
-                                    img: imgURL,
-                                    isDel: "0",
-                                    content: "none",
-                                    keywords: "none",
-                                    description: that.desc,
-                                    searchWords: "",
-                                    weight: "0.0",
-                                    point: "0",
-                                    unit: "0",
-                                    brandId: "0",
-                                    visit: "0",
-                                    favorite: "0",
-                                    sort: "0",
-                                    listImg: "xx.jpg",
-                                    smallImg: "xx.jpg",
-                                    specArray: "{}",
-                                    exp: "0"
-                                }];
-                                // console.log(present);
-                                let url = "updateBatch";
-                                if (that.presentId === '') url = "saveBatch";
-                                BasicFunction.get_data("smartGoods/" + url, function (response) {
-                                    // console.log("------ Data Rcvd in PresentReg --------");
-                                    // console.log(response);
-                                    if (response.ret === "10000") {
-                                        that.$router.push('share');
-                                    } else {
-                                        Toast.fail("上传失败,请检查网络");
-                                        that.loading = false;
-                                    }
-                                }, present);
-                            } else {
-                                Toast.fail('上传图片失败,请检查网络');
-                                that.loading = false;
-                            }
-                        } catch (e) {
-                            console.warn(e);
-                            Toast.fail('上传图片失败,请检查网络');
-                            that.loading = false;
-                        }
-                    }, formData);
+                    that.uploadNewPresent();
+                } else {
+                    that.compressImg();
                 }
             },
             onRead: function (e) {
                 this.photo = e;
-            }
-        },
-        created: function () {
-            if (!localStorage.getItem('frontend-userid')) {
-                this.$router.push('login');
-                return;
-            }
-            if(this.$route.query.present) {
-                let present = this.$route.query.present;
+            },
+            onReadExisting(giftDo){
+                let present = giftDo;
                 // console.log('----- Present Info -----');
                 // console.log(present);
                 this.presentId = present.id;
@@ -311,6 +310,33 @@
                 this.imgUrl = present.imgUrl;
                 this.photo = present.imgUrl;
             }
+        },
+        created: function () {
+            if (!localStorage.getItem('frontend-userid')) {
+                this.$router.push('login');
+                return;
+            }
+            let presentId = this.$route.query.presentId;
+            if(presentId == null || presentId == undefined){
+                presentId = BasicFunction.utils_get_parm("presentId");
+            }
+            if(presentId == undefined || presentId == null){
+                Toast.fail('请重新进入礼物页哦');
+                this.$router.push('index');
+            }
+
+            let that = this;
+            BasicFunction.get_data('smartGoods/list?goodId=' + presentId, function (res) {
+                if (res.ret === '10000') {
+                    if(res.model === undefined || res.model == null || res.model.list == undefined || res.model.list.length <= 0){
+                        Toast.fail('礼物查看遇到问题,请稍等一下再试吧');
+                        that.$router.push('index');
+                        return;
+                    }
+                    that.giftDo = res.model.list[0];
+                    that.onReadExisting(that.giftDo);
+                }
+            }, {});
         }
     }
 

+ 1 - 45
sourcecode/h5app/vue/src/views/SecurityVerify.vue

@@ -302,7 +302,7 @@
                     that.userDo = res.model.list[0];
                 }
             }, {});
-            BasicFunction.get_data("smartIdentity/list?userId=" + userId, function (res) {
+            BasicFunction.get_data("smartIdentity/list?userId=" + userid, function (res) {
                 try {
                     if (res.ret === '10000' && res.model !== undefined && res.model.list !== undefined && res.model.list.length > 0) {
                         that.identityDo = res.model.list[0];
@@ -430,50 +430,6 @@
         return new Blob([u8arr], {type: mime});
     }
 
-
-    //上传文件方法
-    function UpladFile() {
-        var fileObj = document.getElementById("file").files[0]; // js 获取文件对象
-        var url = "后台图片上传接口"; // 接收上传文件的后台地址
-
-        var form = new FormData(); // FormData 对象
-
-        if (fileObj.size / 1024 > 1025) { //大于1M,进行压缩上传
-            photoCompress(fileObj, {
-                quality: 0.2
-            }, function (base64Codes) {
-                //console.log("压缩后:" + base.length / 1024 + " " + base);
-                var bl = convertBase64UrlToBlob(base64Codes);
-                form.append("file", bl, "file_" + Date.parse(new Date()) + ".jpg"); // 文件对象
-                xhr = new XMLHttpRequest();  // XMLHttpRequest 对象
-                xhr.open("post", url, true); //post方式,url为服务器请求地址,true 该参数规定请求是否异步处理。
-                xhr.onload = uploadComplete; //请求完成
-                xhr.onerror = uploadFailed; //请求失败
-
-                xhr.upload.onprogress = progressFunction;//【上传进度调用方法实现】
-                xhr.upload.onloadstart = function () {//上传开始执行方法
-                    ot = new Date().getTime();   //设置上传开始时间
-                    oloaded = 0;//设置上传开始时,以上传的文件大小为0
-                };
-
-                xhr.send(form); //开始上传,发送form数据
-            });
-        } else { //小于等于1M 原图上传
-            form.append("file", fileObj); // 文件对象
-            xhr = new XMLHttpRequest();  // XMLHttpRequest 对象
-            xhr.open("post", url, true); //post方式,url为服务器请求地址,true 该参数规定请求是否异步处理。
-            xhr.onload = uploadComplete; //请求完成
-            xhr.onerror = uploadFailed; //请求失败
-
-            xhr.upload.onprogress = progressFunction;//【上传进度调用方法实现】
-            xhr.upload.onloadstart = function () {//上传开始执行方法
-                ot = new Date().getTime();   //设置上传开始时间
-                oloaded = 0;//设置上传开始时,以上传的文件大小为0
-            };
-
-            xhr.send(form); //开始上传,发送form数据
-        }
-    }
 </script>
 
 <style scoped>