Bläddra i källkod

upload and download imgs

StephenArk30 6 år sedan
förälder
incheckning
fcdc9ca8e0

+ 2 - 14
sourcecode/h5app/vue/src/components/addPhoto.vue

@@ -13,19 +13,9 @@
 <script>
     export default {
         name: "addPhoto",
-        data() {
-            return {
-                photoURL: require('../assets/camera.png')
-            }
-        },
-        model: {
-            prop: 'chosen',
-            event: 'onRead'
-        },
         props: {
-            chosen: {
-                type: Boolean,
-                default: false
+            photoURL: {
+                default: require('../assets/camera.png')
             }
         },
         methods: {
@@ -40,9 +30,7 @@
                     console.log(this.result);
                     that.photoURL = this.result;
                 };
-                this.chosen = true;
                 this.$emit('onRead', f);
-                // console.log(this.chosen);
             }
         }
     }

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

@@ -76,7 +76,8 @@
     p, h3 {
         color: #fd6740;
     }
-    p,h3 {
+
+    p, h3 {
         padding: 5px;
     }
     p {

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

@@ -5,7 +5,7 @@
                 <h3><strong>个人资料</strong></h3>
             </van-col>
             <van-col span="6" style="">
-                <p  @click="toggleReadOnly()">{{isReadonly ? "编辑" : "保存"}}</p>
+                <p @click="toggleReadOnly()">{{isReadonly ? "编辑" : "保存"}}</p>
             </van-col>
         </van-row>
         <p>昵称</p>
@@ -191,7 +191,7 @@
         color: #fd6740;
     }
 
-    p,h3 {
+    p, h3 {
         padding: 5px;
     }
 

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

@@ -20,7 +20,7 @@ var BasicFunction = new (function () {
         THRESHOLD: 1000,
         IS_LOADED: false,
         nowuse: 0, SVR_URL: "/server/",
-        TEST_URL:"smartAds/list",
+        TEST_URL: "smartAds/list",
         groupsCount: 0, groups: [],
         shouldStop: false,
         backup: ["/server/",

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

@@ -186,8 +186,8 @@ smartGoods/saveBatch
 "goodsNo":"A2",
 "modelId":"1",
 "ownerId":"18", // 货品所有者id
-"goodFirstKind":"1000", // 目标性别 男: 0,女: 1
-"goodSecondKind":"2000", // 标签 0~13
+"goodFirstKind":"0", // 目标性别 男: 0,女: 1
+"goodSecondKind":"6", // 标签 0~13
 "sellPrice":"0.0",
 "marketPrice":"0.0",
 "costPrice":"0.0",

+ 41 - 50
sourcecode/h5app/vue/src/views/PresentRegister.vue

@@ -50,15 +50,7 @@
             <p>上传礼物照片</p>
 
             <div style="margin-bottom: 10px">
-                <!--<form method="POST" enctype="multipart/form-data"-->
-                <!--action="https://gift-server.niimei.com/fileserver/upload?sign=abcdefg">-->
-                <!--<add-photo v-model="hasPhoto"/>-->
-                <!--<button type="submit" value="Upload"-->
-                <!--class="van-button van-button&#45;&#45;primary van-button&#45;&#45;large submit_button"-->
-                <!--@click="publishPresent">下一步-->
-                <!--</button>-->
-                <!--</form>-->
-                <add-photo v-model="photo"/>
+                <add-photo :photoURL="imgUrl" @onRead="onRead"/>
                 <van-button type="primary" class="submit_button" @click="publishPresent">下一步</van-button>
             </div>
         </div>
@@ -133,49 +125,51 @@
                 console.log(this.photo);
                 let formData = new FormData();
                 formData.append('file', this.photo);
+                let imgURL = '';
+                let that = this;
                 BasicFunction.get_data("fileserver/upload?sign=abcdefg", function (res) {
                     console.log('----- upload photo result -----');
                     console.log(res);
                     if (res.ret === '10000') {
-                        console.log('success');
+                        imgURL = res.model;
+                        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('index');
+                            } else {
+                                Toast.fail("上传失败,请检查网络");
+                            }
+                        }, present);
                     } else {
                         Toast.fail('上传图片失败,请检查网络');
                     }
                 }, formData);
 
-                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: this.photo.name,
-                    isDel: "0", content: "none", keywords: "none",
-                    description: this.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 that = this;
-                let url = "updateBatch";
-                if (this.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('index');
-                    } else {
-                        Toast.fail("上传失败,请检查网络");
-                    }
-                }, present);
             },
-            onRead: function () {
-                this.hasPhoto = true;
+            onRead: function (e) {
+                this.photo = e;
             }
         },
         created: function () {
@@ -185,17 +179,14 @@
             }
             if(this.$route.query.present) {
                 let present = this.$route.query.present;
+                console.log('----- Present Info -----');
                 console.log(present);
                 this.presentId = present.id;
                 this.radio = present.gender.toString();
-                this.presentName = present.presentName;
-                this.desc = present.presentDesc;
-                let tags = present.tags;
-                let j = 13;
-                for (let i = tags.length - 1; i >= 0; i--) {
-                    if (tags.charAt(i) === '1') this.result.push(j);
-                    j--;
-                }
+                this.presentName = present.name;
+                this.desc = present.desc_long;
+                this.tag = present.tags;
+                this.imgUrl = present.imgUrl;
             }
         }
     }

+ 68 - 34
sourcecode/h5app/vue/src/views/SecurityVerify.vue

@@ -35,6 +35,16 @@
                         :error="usernameError"
                         @click="usernameError=false"
                 />
+                <van-field
+                        v-model="wechat"
+                        required
+                        clearable
+                        label="微信号"
+                        placeholder="请输入微信号"
+                        maxlength="20"
+                        :error="wechatError"
+                        @click="wechatError=false"
+                />
             </van-cell-group>
 
             <p>性别</p>
@@ -57,15 +67,7 @@
         <div class="card" style="margin-bottom: 70px">
             <p>上传校卡照片</p>
             <div style="margin-bottom: 10px">
-                <!--<form method="POST" enctype="multipart/form-data"-->
-                <!--action="https://gift-server.niimei.com/fileserver/upload?sign=abcdefg">-->
-                <!--<add-photo v-model="hasPhoto"/>-->
-                <!--<button type="submit" value="Upload"-->
-                <!--class="van-button van-button&#45;&#45;primary van-button&#45;&#45;large submit_button"-->
-                <!--@click="next">下一步-->
-                <!--</button>-->
-                <!--</form>-->
-                <add-photo v-model="photo"/>
+                <add-photo @onRead="onRead"/>
                 <van-button class="submit_button" type="primary" @click="next">下一步</van-button>
             </div>
             <p>活动仅允许深大学生参与,请上传正面校卡照片审核~</p>
@@ -105,6 +107,8 @@
                 sms: '',
                 username: '',
                 usernameError: false,
+                wechat: '',
+                wechatError: false,
                 radio: '0',
                 show: false,
                 dormitory: '点击选择宿舍区',
@@ -127,6 +131,10 @@
                 } else if (this.username.length < 1) {
                     this.usernameError = true;
                     return;
+                } else if (this.wechat.length < 6) {
+                    this.wechatError = true;
+                    Toast.fail('请输入正确格式的微信号');
+                    return;
                 } else if (this.dorId === -1) {
                     Toast.fail('请选择宿舍区');
                     return;
@@ -135,6 +143,7 @@
                     return;
                 }
 
+                let that = this;
                 console.log('------- photo -------');
                 console.log(this.photo);
                 let formData = new FormData();
@@ -143,41 +152,66 @@
                     console.log('----- upload photo result -----');
                     console.log(res);
                     if (res.ret === '10000') {
-                        console.log('success');
+                        let imgURL = res.model; // TODO: 把imgurl也加入用户信息
+                        let userId = localStorage.getItem('frontend-userid');
+                        let useridentity = {
+                            reviewId: "",
+                            userId: userId,
+                            userWxAccount: that.wechat,
+                            dormDistrict: that.dorId,
+                            userSex: parseInt(that.radio),
+                            userSchoolCard: 111111,
+                            userSchoolCardPic: imgURL,
+                            userReviewStatus: 0,
+                            reviewerId: 1,
+                            reviewerNote: "nmo",
+                            reviewerNoteToUser: "noo"
+                        };
+                        console.log('----- User Identity -----');
+                        BasicFunction.get_data("smartIdentity/saveBatch", function (response) {
+                            console.log(useridentity);
+                            console.log(response);
+                            if (response.ret === "10000") {
+                                console.log('----- User Info -----');
+                                BasicFunction.get_data('smartUsers/list?uid=' + userId, function (res) {
+                                    console.log(res);
+                                    if (res.ret === '10000') {
+                                        let user = res.model.list[0];
+                                        user.name = that.username;
+                                        user.phone = that.phone;
+                                        user.schoolDistrict = that.dorId;
+                                        console.log('----- Update User Info -----');
+                                        console.log(user);
+                                        BasicFunction.get_data('smartUsers/updateBatch', function (res) {
+                                            console.log(res);
+                                            if (res.ret === '10000') {
+                                                Toast.success("注册成功");
+                                                that.$router.push('presentRegister');
+                                            } else {
+                                                Toast.fail('注册失败')
+                                            }
+                                        }, [user]);
+                                    } else {
+                                        Toast.fail('获取用户信息失败');
+                                    }
+                                }, {});
+                            } else {
+                                Toast.fail("注册失败,请检查网络");
+                            }
+                        }, [useridentity]);
                     } else {
                         Toast.fail('上传图片失败,请检查网络');
                     }
                 }, formData);
-
-                let userId = localStorage.getItem('frontend-userid');
-                let useridentity = [{
-                    reviewId: "",
-                    userId: userId,
-                    dormDistrict: this.dorId,
-                    userSex: parseInt(this.radio),
-                    userSchoolCard: 201233222,
-                    userReviewStatus: 0,
-                    reviewerId: 1,
-                    reviewerNote: "nmo",
-                    reviewerNoteToUser: "noo"
-                }];
-                console.log(useridentity);
-                let that = this;
-                BasicFunction.get_data("smartIdentity/saveBatch", function (response) {
-                    console.log(response);
-                    if (response.ret === "10000") {
-                        Toast.success("注册成功");
-                        that.$router.push('presentRegister');
-                    } else {
-                        Toast.fail("注册失败,请检查网络");
-                    }
-                }, useridentity);
             },
             onSelect(item) {
                 // 点击选项时默认不会关闭菜单,可以手动关闭
                 this.show = false;
                 this.dormitory = item.name;
                 this.dorId = item.id;
+            },
+            onRead(e) {
+                this.photo = e;
             }
         },
         created: function () {

+ 21 - 16
sourcecode/h5app/vue/src/views/giftDetail.vue

@@ -3,8 +3,9 @@
         <nav-bar path="index"/>
         <gift-card
                 v-if="myPresent.status===2"
-                :present-name="recievedPresent.presentName"
-                :present-desc="recievedPresent.presentDesc"
+                :present-img="recievedPresent.imgUrl"
+                :present-name="recievedPresent.name"
+                :present-desc="recievedPresent.desc"
                 :owner="1"
                 :placeId="recievedPresent.placeId"
                 :gender="recievedPresent.gender"
@@ -16,8 +17,9 @@
             <p>{{recievedPresent.comment}}</p>
         </div>
         <gift-card
-                :present-name="myPresent.presentName"
-                :present-desc="myPresent.presentDesc"
+                :present-img="myPresent.imgUrl"
+                :present-name="myPresent.name"
+                :present-desc="myPresent.desc"
                 :owner="0"
                 :placeId="myPresent.placeId"
                 :gender="myPresent.gender"
@@ -77,8 +79,8 @@
             return {
                 myPresent: {
                     placeId: 1,
-                    wechat: 'wx_id',
-                    comment: ''
+                    comment: '',
+
                 },
                 recievedPresent: {
                     comment: ''
@@ -95,7 +97,6 @@
                     message: '确认删除礼物吗?'
                 }).then(() => {
                     // on confirm
-                    // delete_present(this.presentId())
                     // TODO: 考虑 updateBatch, 就是需要 将isDel设为1, 配合首页查找进行过滤
                     let that = this;
                     BasicFunction.get_data("smartGoods/list?goodid=" + this.myPresent.id, function (response) {
@@ -132,15 +133,19 @@
                 this.$router.push('login');
                 return;
             }
-            this.myPresent.id = this.$route.query.presentId;
-            this.myPresent.presentName = this.$route.query.name;
-            this.myPresent.presentDesc = this.$route.query.desc;
-            this.myPresent.status = parseInt(this.$route.query.status);
-            let gender_tags = this.$route.query.gender_tags;
-            console.log(gender_tags);
-            this.myPresent.gender = parseInt(gender_tags.charAt(gender_tags.length - 1));
-            this.myPresent.tags = gender_tags.substring(0, gender_tags.length - 1);
-            console.log(this.myPresent.tags);
+            let present = this.$route.query.present;
+            let userid = localStorage.getItem('frontend-userid');
+            let that = this;
+            present.comment = '';
+            BasicFunction.get_data('smartIdentity/list?userId=' + userid, function (res) {
+                console.log(res);
+                if (res.ret === '10000') {
+                    present.placeId = res.model.list[0].dormDistrict;
+                    present.wechat = res.model.list[0].userWxAccount;
+                    that.myPresent = present;
+                    console.log(that.myPresent);
+                }
+            }, {});
         }
     }
 

+ 5 - 8
sourcecode/h5app/vue/src/views/index.vue

@@ -20,6 +20,7 @@
                     is="index-present"
                     v-for="(present, index) in presents"
                     :key="present.id"
+                    :present-img="present.imgUrl"
                     :present-name="present.name"
                     :present-desc="present.desc"
                     :publish-time="present.time"
@@ -72,13 +73,7 @@
             toDetail(i) {
                 let present = this.presents[i];
                 this.$router.push({
-                    path: 'giftDetail', query: {
-                        presentId: present.id,
-                        name: present.name,
-                        desc: present.desc_long,
-                        status: present.status,
-                        gender_tags: present.gender_tags
-                    }
+                    path: 'giftDetail', query: {present: present}
                 });
             }
         },
@@ -100,6 +95,7 @@
                     list.forEach(gift => {
                         let temp = {};
                         temp.id = gift.goodid;
+                        temp.imgUrl = 'http://gift.fogice.com' + gift.img;
                         temp.name = gift.name;
                         if (gift.description.length > 45) {
                             temp.desc = gift.description.substring(0, 30);
@@ -109,7 +105,8 @@
                         temp.desc_long = gift.description;
                         temp.time = gift.createTime.substring(0, 9);
                         temp.status = gift.sort;
-                        temp.gender_tags = gift.goodFirstKind.toString(2);
+                        temp.gender = gift.goodFirstKind;
+                        temp.tags = gift.goodSecondKind;
                         presentList.push(temp);
                     });
                 } else {

+ 16 - 13
sourcecode/h5app/vue/src/views/share.vue

@@ -1,4 +1,4 @@
-<template >
+<template>
     <div class="note" :style="note">
         <!--分享页面-->
         <div class="card">
@@ -17,8 +17,9 @@
 </template>
 
 <script>
-  //  import wx from 'weixin-js-sdk';
-    import {Row, Col,
+    //  import wx from 'weixin-js-sdk';
+    import {
+        Row, Col,
         Button
     } from 'vant'
     export default {
@@ -65,7 +66,7 @@
                 return;
             }
 
-            BasicFunction.getSigned(['onMenuShareTimeline', 'onMenuShareAppMessage',], function(){
+            BasicFunction.getSigned(['onMenuShareTimeline', 'onMenuShareAppMessage',], function () {
                 wx.ready(function () {      //需在用户可能点击分享按钮前就先调用
                     wx.onMenuShareTimeline({
                         title: '用一份礼物,邂逅一段故事', // 分享标题
@@ -90,14 +91,14 @@
             });
 
 
-          /*  wx.config({
-                debug: true, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
-                appId: '', // 必填,公众号的唯一标识
-                timestamp:, // 必填,生成签名的时间戳
-                nonceStr: '', // 必填,生成签名的随机串
-                signature: '',// 必填,签名
-                jsApiList: [] // 必填,需要使用的JS接口列表
-            });*/
+            /*  wx.config({
+                  debug: true, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
+                  appId: '', // 必填,公众号的唯一标识
+                  timestamp:, // 必填,生成签名的时间戳
+                  nonceStr: '', // 必填,生成签名的随机串
+                  signature: '',// 必填,签名
+                  jsApiList: [] // 必填,需要使用的JS接口列表
+              });*/
 
         }
     }
@@ -110,12 +111,14 @@
         margin: 10px 0 10px;
         width: 55%;
     }
+
     .card {
         margin: 20px 20px;
         padding: 15px;
         text-align: left;
     }
-    .van-row{
+
+    .van-row {
 
         font-size: 0.3em;
     }