Sfoglia il codice sorgente

add Base64toBlob functions in addPhoto

StephenArk30 6 anni fa
parent
commit
bc8126d865

+ 33 - 1
sourcecode/h5app/vue/src/components/addPhoto.vue

@@ -32,9 +32,41 @@
             onRead(file) {
                 this.photo= file;
                 this.uploaded = true;
+                console.log('----------photo obj----------');
+                console.log(this.photo);
                 this.$emit('uploadPhoto', this.photo);
-            }
+                let blob = convertImgDataToBlob(this.photo.content, this.photo.file.type);
+                console.log(blob);
+                blobToDataURL(blob, res => {
+                    console.log(res);
+                });
+            },
+        }
+    }
+
+    function convertImgDataToBlob(base64, type) {
+        console.log('----------converting base64 to blob----------');
+        let base64Str = base64.substring(base64.indexOf(',') + 1);
+        let bString = atob(base64Str);
+        let n = bString.length;
+        let u8arr = new Uint8Array(n);
+        while (n--) {
+            u8arr[n] = bString.charCodeAt(n);
         }
+        let blob;
+        blob = new Blob([u8arr], {
+            type: type
+        });
+        return blob;
+    }
+
+    function blobToDataURL(blob, callback) {
+        console.log('----------converting blob to base64----------');
+        let a = new FileReader();
+        a.onload = function (e) {
+            callback(e.target.result);
+        };
+        a.readAsDataURL(blob);
     }
 </script>
 

+ 50 - 7
sourcecode/h5app/vue/src/connector/simple-demo.js

@@ -133,7 +133,7 @@ BasicFunction.get_data("smartIdentity/updateBatch", function (response) {
 
 基本格式
 
-
+szuhuanhuan2018
 登录  转义密码 就是 encodeURIComponent("实际密码")
 BasicFunction.get_data("ajaxloginu=手机号&p=(转义密码)", 回调函数, {})
 
@@ -152,6 +152,30 @@ BasicFunction.get_data("数据接口名称/updateBatch", 回调函数, 数据列
 搜索(获取)
 BasicFunction.get_data("数据接口名称/list?条件1=数据1&条件2=数据2&.....", 回调函数, {})
 
+用户数据:
+smartUsers/list
+[{
+"uid":3,
+"usn":"cell_13520583918",
+"pss":"64e604787cbf194841e7b68d7cd28786f6c9a0a3ab9f8b0a0e87cb4387ab0107",
+"name":"HelloWorld",
+"title":"",
+"priv":"view,order,deliver,pay",
+"state":0,
+"sess":"iOgxGPkFIV3JxBlBfCv",
+"phone":"13520583918",
+"schoolDistrict":null,
+"userExpPts":null,
+"userGroup":null,
+"userVcoin":null,
+"registerTime":null,
+"lastLoginTime":null,
+"wxUnionid":null,
+"wxEngineid":null,
+"wxOpenid":null,
+"note":null
+},
+
 新建货品:
 smartGoods/saveBatch
 [{
@@ -160,20 +184,20 @@ smartGoods/saveBatch
 "goodsNo":"A2",
 "modelId":"1",
 "ownerId":"18", // 货品所有者id
-"goodFirstKind":"1000", // 前14位是tag,15位是性别
+"goodFirstKind":"1000", // 前14位是tag,15位是性别,男: 0,女: 1,int,需要转为二进制字符串
 "goodSecondKind":"2000",
 "sellPrice":"0.0",
 "marketPrice":"0.0",
 "costPrice":"0.0",
 "upTime":"2018-12-10 01:01:01",
 "downTime":"2018-12-10 01:01:01",
-"createTime":"2018-12-10 01:01:01",
+"createTime":"2018-12-10 01:01:01", // 货品注册时间
 "storeNums":"1",
-"img":"attachment/simple/acsac089e1nnsaxx72190dm.jpg",
+"img":"attachment/simple/acsac089e1nnsaxx72190dm.jpg", // 图片名
 "isDel":"0",
 "content":"none",
 "keywords":"none",
-"description":"绒毛玩具或填充玩具,中国大陆较常用“毛绒玩具”、香港为“毛公仔”,是",
+"description":"绒毛玩具或填充玩具,中国大陆较常用“毛绒玩具”、香港为“毛公仔”,是...", // 货品描述
 "searchWords":"毛绒,玩具",
 "weight":"0.4",
 "point":"4",
@@ -199,12 +223,31 @@ smartGoodPool/saveBatch
 
 新建评论
 smartOrderFeedback/saveBatch
-[{"feedbackId":"","orderId":"13","goodId":"3","ratingStatus":"1000","ratingMajor":"5000","ratingMinor":"4500","content":"还不错,5颗星","ratingTime":"2018-12-10 01:01:01"}]
+[{
+"feedbackId":"",
+"orderId":"13",
+"goodId":"3",
+"ratingStatus":"1000",
+"ratingMajor":"5000",
+"ratingMinor":"4500",
+"content":"还不错,5颗星",
+"ratingTime":"2018-12-10 01:01:01"
+}]
 
 
 新建用户身份审核单(校园卡审核)
 smartIdentity/saveBatch
-{"reviewId":"","userId":18,"dormDistrict":10,"userSex":1,"userSchoolCard":20123333222,"userReviewStatus":1000,"reviewerId":1,"reviewerNote":"nmo","reviewerNoteToUser":"noo"}]
+[{
+"reviewId":"",
+"userId":18, // 用户id
+"dormDistrict":10, // 宿舍区 0: 斋区, 1: 西南, 2: 南区, 3: 西丽
+"userSex":1, // 用户性别
+"userSchoolCard":20123333222,
+"userReviewStatus":1000,
+"reviewerId":1,
+"reviewerNote":"nmo",
+"reviewerNoteToUser":"noo"
+}]
 
 
 新建订单(配对成功)

+ 6 - 3
sourcecode/h5app/vue/src/views/SecurityVerify.vue

@@ -2,7 +2,7 @@
     <div>
         <div class='card'>
             <h3><strong>个人资料</strong></h3>
-            <van-cell-group>
+            <van-cell-group :border="false">
                 <van-field
                         v-model="phone"
                         required
@@ -158,7 +158,7 @@
                 } else if (this.password !== this.passverify) {
                     this.passVerifyError = true;
                     return;
-                } else if (this.username .length< 3) {
+                } else if (this.username.length < 1) {
                     this.usernameError = true;
                     return;
                 } else if (this.dorId === -1) {
@@ -209,7 +209,6 @@
             },
             onReadPhoto(file) {
                 this.photo = file;
-                console.log(this.photo);
             },
             onSelect(item) {
                 // 点击选项时默认不会关闭菜单,可以手动关闭
@@ -242,4 +241,8 @@
         margin: 10px 0 10px;
         width: 85%;
     }
+
+    /*.van-field {*/
+    /*border-top: 0;*/
+    /*}*/
 </style>

+ 1 - 1
sourcecode/h5app/vue/src/views/login.vue

@@ -125,7 +125,7 @@
 
 <style scoped>
     .card {
-        margin: 20px;
+        margin: 20px 20px 130px;
         border: solid 1px #e4e4e4;
     }
     .login {