|
@@ -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>
|