Quellcode durchsuchen

basic uploaded present and get presents

StephenArk30 vor 6 Jahren
Ursprung
Commit
d0d4b57f03

Datei-Diff unterdrückt, da er zu groß ist
+ 237 - 237
sourcecode/h5app/vue/package-lock.json


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

@@ -33,7 +33,7 @@
                 </van-row>
             </van-col>
         </van-row>
-        <p style="text-align: left; font-size: 110%"><strong>{{presentName}}</strong></p>
+        <p style="text-align: left; font-size: 100%"><strong>{{presentName}}</strong></p>
         <p style="text-align: left">{{presentDesc}}</p>
     </div>
 </template>
@@ -107,6 +107,7 @@
     }
     p {
         margin: 0;
+        font-size: 80%;
     }
     .gift_card {
         margin: 20px 20px;

+ 83 - 11
sourcecode/h5app/vue/src/views/PresentRegister.vue

@@ -62,7 +62,8 @@
         Picker,
         Button,
         Toast
-    } from 'vant'
+    } from 'vant';
+    import {BasicFunction} from "../connector/basic-service";
     import AddPhoto from "../components/addPhoto";
     export default {
         name: "PresentRegister",
@@ -78,6 +79,7 @@
         data() {
             return {
                 radio: '0',
+                presentId: '',
                 presentName: '',
                 pnError: false,
                 desc: '',
@@ -108,25 +110,59 @@
                     return;
                 }
                 // post_present()
-                let present = {
-                    name: this.presentName,
-                    gender: parseInt(this.radio),
-                    desc: this.desc,
-                    tags: this.result,
-                    photo: this.photo
-                };
+                let userId = localStorage.getItem("frontend-userid");
+                // tags
+                let gender_tags = '';
+                this.result = this.result.sort(function (a, b) {
+                    if (a > b) return 1;
+                    else if (a < b) return -1;
+                    else return 0;
+                });
+                console.log(this.result);
+                let i = 0;
+                this.result.forEach(res => {
+                    for (i; i < res; i++) gender_tags += '0';
+                    gender_tags += '1';
+                    i++;
+                });
+                for (i; i < 14; i++) gender_tags += '0';
+                gender_tags += this.radio;
+                console.log(gender_tags);
+                gender_tags = parseInt(gender_tags, 2);
+                console.log(gender_tags);
+                console.log(this.photo);
+
+                let present = [{
+                    "goodid": this.presentId,
+                    "name": this.presentName,
+                    "goodsNo": "A2", "modelId": "1",
+                    "ownerId": userId.toString(),
+                    "goodFirstKind": gender_tags.toString(),
+                    "goodSecondKind": "2000", "sellPrice": "0.0", "marketPrice": "0.0", "costPrice": "0.0",
+                    "upTime": getNowFormatDate(), "downTime": getNowFormatDate(), "createTime": getNowFormatDate(),
+                    "storeNums": "1",
+                    "img": this.photo.file.name,
+                    "isDel": "0", "content": "none", "keywords": "none",
+                    "description": this.desc,
+                    "searchWords": "", "weight": "0.4", "point": "4", "unit": "10", "brandId": "1",
+                    "visit": "1", "favorite": "1", "sort": "1", "listImg": "xx.jpg",
+                    "smallImg": "xx.jpg", "specArray": "{}", "exp": "0"
+                }];
                 console.log(present);
-                BasicFunction.get_data("ajaxpostpresent", function (response) {
+                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"){
                         // 不需要 设置 SessionID, 已经自动保存在jSessionID中
-                        this.$router.push('index');
+                        that.$router.push('index');
                     } else {
                         // 注册失败的处理
                         Toast.fail("上传失败,请检查网络");
                     }
-                }, {});
+                }, JSON.stringify(present));
                 // this.$router.push('index');
             },
             onReadPhoto(file) {
@@ -137,12 +173,48 @@
             if(this.$route.query.present) {
                 let present = this.$route.query.present;
                 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--;
+                }
             }
         }
     }
+
+    function getNowFormatDate() {
+        let date = new Date();
+        let seperator = "-";
+        let year = date.getFullYear();
+        let month = date.getMonth() + 1;
+        let strDate = date.getDate();
+        let hour = date.getHours();
+        let minutes = date.getMinutes();
+        let seconds = date.getSeconds();
+        if (month >= 1 && month <= 9) {
+            month = "0" + month;
+        }
+        if (strDate >= 0 && strDate <= 9) {
+            strDate = "0" + strDate;
+        }
+        if (hour >= 0 && hour <= 9) {
+            hour = "0" + hour;
+        }
+        if (minutes >= 0 && minutes <= 9) {
+            minutes = "0" + minutes;
+        }
+        if (seconds >= 0 && seconds <= 9) {
+            seconds = "0" + seconds;
+        }
+        let currentdate = year + seperator + month + seperator + strDate;
+        currentdate = currentdate + ' ' + hour + ':' + minutes + ':' + seconds;
+        return currentdate;
+    }
 </script>
 
 <style scoped>

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

@@ -176,7 +176,8 @@
                     photo: this.photo
                 };
                 console.log(user);
-                BasicFunction.get_data("ajaxregister?user=" + JSON.stringify(user), function (response) {
+                // BasicFunction.get_data("ajaxregister?u=手机号&p=转义密码", 回调函数, {})
+                BasicFunction.get_data("ajaxregister?u=" + this.phone + '&p=' + this.password, function (response) {
                     console.log("------ Data Rcvd in Reg --------");
                     console.log(response);
                     if(response.ret === "10000"){

+ 16 - 8
sourcecode/h5app/vue/src/views/beTest.vue

@@ -3,13 +3,13 @@
         <!--测试-->
         <div style="position: relative;">
             {{testresult}}
-            <div @click="testSaveGoods"> 点击测试货品保存 </div>
-            <div @click="testReadGoods"> 点击测试货品数据读取 </div>
-            <div @click="testSaveReview"> 点击测试货品数据读取 </div>
-            <div @click="testSaveWxid"> 点击测试货品数据读取 </div>
-            <div @click="testReadWxid"> 点击测试WxID读取</div>
-            <div @click="testSaveStorage"> 点击写入frontend-userid</div>
-            <div @click="testReadStorage"> 点击读取frontend-userid</div>
+            <div @click="testSaveGoods"> 点击测试货品保存testSaveGoods</div>
+            <div @click="testReadGoods"> 点击测试货品数据读取 testReadGoods</div>
+            <div @click="testSaveReview"> 点击测试货品数据读取testSaveReview</div>
+            <div @click="testSaveWxid"> 点击测试货品数据读取testSaveWxid</div>
+            <div @click="testReadWxid"> 点击测试WxID读取testReadWxid</div>
+            <div @click="testSaveStorage"> 点击写入frontend-userid testSaveStorage</div>
+            <div @click="testReadStorage"> 点击读取frontend-userid testReadStorage</div>
         </div>
         <van-button size="large" type="primary" @click="Toindex">返回首页</van-button>
 
@@ -20,10 +20,11 @@
     import {
         Button
     } from 'vant'
+    import {BasicFunction} from '../connector/basic-service';
     export default {
         name: "share",
         components: {
-            [Button.name]: Button
+            [Button.name]: Button,
         },
         data() {
             return {
@@ -156,4 +157,11 @@
         margin: 10px 0 10px;
         width: 55%;
     }
+
+    div {
+        margin-top: 10px;
+        background-color: white;
+        border: solid 1px;
+        padding: 10px;
+    }
 </style>

+ 18 - 31
sourcecode/h5app/vue/src/views/giftDetail.vue

@@ -4,7 +4,7 @@
                 v-if="myPresent.status===2"
                 :present-name="recievedPresent.presentName"
                 :present-desc="recievedPresent.presentDesc"
-                :owner="recievedPresent.owner"
+                :owner="1"
                 :placeId="recievedPresent.placeId"
                 :gender="recievedPresent.gender"
                 :status="recievedPresent.status"
@@ -17,7 +17,7 @@
         <gift-card
                 :present-name="myPresent.presentName"
                 :present-desc="myPresent.presentDesc"
-                :owner="myPresent.owner"
+                :owner="0"
                 :placeId="myPresent.placeId"
                 :gender="myPresent.gender"
                 :status="myPresent.status"
@@ -27,12 +27,13 @@
             <p style="font-size: 110%"><strong>我收到的感谢信</strong></p>
             <p>{{myPresent.comment}}</p>
         </div>
+        <div style="height: 100px; width: 100%"></div>
         <img src="../assets/gift_card_background.png"
              style="position: fixed; bottom: 100px; max-width: 100%; z-index: -1"
         />
         <div
                 v-if="myPresent.status===2"
-                style="position: fixed; bottom: 0; width: 100%"
+                style="position: fixed; bottom: 0; width: 100%; background-color: #fff6e3"
         >
             <van-button
                     type="primary" size="large"
@@ -69,33 +70,12 @@
         },
         data() {
             return {
-                presentId: '',
-            }
-        },
-        computed: {
-            myPresent: function () {
-                // return get_present(presentId)
-                return {
-                    presentName: '一本神秘的书',
-                    presentDesc: "description",
-                    owner: 0,
+                myPresent: {
                     placeId: 1,
-                    gender: 0,
-                    status: 1,
-                    wechat: 'wechat_id',
-                    comment: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean euismod bibendum laoreet.'
-                }
-            },
-            recievedPresent: function () {
-                // return get_present(get_sender(presentId))
-                return {
-                    presentName: '一本不神秘的书',
-                    presentDesc: "description",
-                    owner: 1,
-                    placeId: 3,
-                    gender: 1,
-                    status: 2,
-                    wechat: 'wechat_id',
+                    wechat: 'wx_id',
+                    comment: ''
+                },
+                recievedPresent: {
                     comment: ''
                 }
             }
@@ -103,7 +83,6 @@
         methods:{
             editPresent: function() {
                 let p = this.myPresent;
-                p.id = this.presentId;
                 this.$router.push({path: 'presentRegister', query: {present: p}});
             },
             deletePresent: function() {
@@ -119,7 +98,15 @@
             }
         },
         created: function () {
-            this.presentId = this.$route.query.presentId;
+            this.myPresent.id = this.$route.query.presentId;
+            this.myPresent.presentName = this.$route.query.name;
+            this.myPresent.presentDesc = this.$route.query.desc;
+            this.myPresent.status = 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);
         }
     }
 

+ 51 - 44
sourcecode/h5app/vue/src/views/index.vue

@@ -17,7 +17,7 @@
                     is="index-present"
                     v-for="(present, index) in presents"
                     :key="present.id"
-                    :present-name="present.presentName"
+                    :present-name="present.name"
                     :present-desc="present.desc"
                     :publish-time="present.time"
                     :status="present.status"
@@ -51,59 +51,66 @@
                 active: 0,
                 indexTop: require('../assets/banner.png'),
                 button_active: true,
-            }
-        },
-        computed: {
-            presents: function() {
-                // return get_present_data()
-
-                var userId = localStorage.getItem("frontend-userid");
-                // 判断userId 是不是空的
-
-                BasicFunction.get_data("smartGoods/list?ownerId" + userId, function (response) {
-                    console.log("------ Data Rcvd in Index --------");
-                    console.log(response);
-                    if (response.ret === "10000") {
-                        // response 就是
-                        console.warn(response);
-                        var list = response.model.list;
-                        if (list == undefined || list.length == 0) // ....
-                            console.warn(list);
-                    } else {
-                        // 注册失败的处理
-                        console.warn("注册失败");
-                    }
-                }, {});
-
-                return [
-                    {
-                        id: 0,
-                        presentName: '礼物1',
-                        desc: '描述1blabla',
-                        time: '2018-01-02',
-                        status: 1
-                    },
-                    {
-                        id: 1,
-                        presentName: '礼物2',
-                        desc: '描述2blabla啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊(max45)',
-                        time: '2018-11-02',
-                        status: 2
-                    }
-                ]
+                presents: {}
             }
         },
         methods: {
             toShare() {
                 this.$router.push('share')
             },
-            toDetail(id) {
-                this.$router.push({ path: 'giftDetail', query: { presentId: id } })
+            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
+                    }
+                });
             }
+        },
+        created: function () {
+            // return get_present_data()
+
+            let userId = localStorage.getItem("frontend-userid");
+            // 判断userId 是不是空的
+
+            let presentList = [];
+            BasicFunction.get_data("smartGoods/list?ownerId" + userId, function (response) {
+                console.log("------ Data Rcvd in Index --------");
+                console.log(response);
+                if (response.ret === "10000") {
+                    let list = response.model.list;
+                    if (list !== undefined || list.length > 0) console.warn(list);
+                    list.forEach(gift => {
+                        let temp = {};
+                        temp.id = gift.goodid;
+                        temp.name = gift.name;
+                        if (gift.description.length > 45) {
+                            temp.desc = gift.description.substring(0, 30);
+                            temp.desc += "..."
+                        }
+                        else temp.desc = gift.description;
+                        temp.desc_long = gift.description;
+                        temp.time = gift.createTime.substring(0, 9);
+                        temp.status = 0;
+                        temp.gender_tags = gift.goodFirstKind.toString(2);
+                        presentList.push(temp);
+                    });
+                } else {
+                    // 失败的处理
+                    console.warn("获取资源失败");
+                }
+            }, {});
+
+            console.log("presents:");
+            console.log(presentList);
+            this.presents = presentList;
         }
     }
 
-
 </script>
 
 <style scoped>

+ 3 - 10
sourcecode/h5app/vue/src/views/login.vue

@@ -94,22 +94,15 @@
                         console.warn("登录失败");
                     }
                 }, {});
-                // this.$router.push('index');
             },
             Register() {
                     this.$router.push('verify');
             },
             SendOTP() {
-                BasicFunction.get_data("ajaxsendotp", function (response) {
-                    console.log("------ Data Rcvd in OTP --------");
+                BasicFunction.get_data("ajaxsendotp?u=" + this.phone, function (response) {
+                    console.log('------ sms Rcvd in Login --------');
                     console.log(response);
-                    if (response.ret === "10000") {
-                        // 提示用户已经发送
-                    } else {
-                        // 发送失败
-                        console.warn("发送失败");
-                    }
-                }, {u: this.phone});
+                }, {})
             }
         }
     }

Einige Dateien werden nicht angezeigt, da zu viele Dateien in diesem Diff geändert wurden.