105 lines
3.2 KiB
JavaScript
105 lines
3.2 KiB
JavaScript
var a = getApp();
|
|
|
|
Page({
|
|
data: {
|
|
token: a.globalData.token,
|
|
serviceUrl: a.baseUrls.serviceUrl,
|
|
baseImgUrl: a.baseUrls.baseImgUrl,
|
|
cardType: "",
|
|
realName: "张三",
|
|
intro: "简介简介简介简介简介简介简介简介简介",
|
|
phone: "0471-3360077",
|
|
address: "呼和浩特市新城区",
|
|
qrCode: "",
|
|
photo: ""
|
|
},
|
|
onLoad: function(a) {
|
|
this.setData({
|
|
cardType: a.type
|
|
});
|
|
},
|
|
choosePhoto: function() {
|
|
var e = this;
|
|
wx.chooseImage({
|
|
count: 1,
|
|
sourceType: [ "album", "camera" ],
|
|
success: function(t) {
|
|
wx.showToast({
|
|
title: "上传中",
|
|
icon: "loading"
|
|
});
|
|
var o = t.tempFiles[0].path;
|
|
a.restAjax.file(a.restAjax.path(a.apis.uploadImg, [ a.baseUrls.serviceUrl ]), o, "image", {
|
|
headers: {
|
|
token: a.globalData.token
|
|
}
|
|
}, function(a, t) {
|
|
if ("200" == a) {
|
|
var o = JSON.parse(t).data;
|
|
e.setData({
|
|
photo: o
|
|
}), wx.hideToast();
|
|
}
|
|
}, function(a, e) {
|
|
console.log(e);
|
|
});
|
|
}
|
|
});
|
|
},
|
|
chooseQrCode: function() {
|
|
var e = this;
|
|
wx.chooseImage({
|
|
count: 1,
|
|
sourceType: [ "album", "camera" ],
|
|
success: function(t) {
|
|
wx.showToast({
|
|
title: "上传中",
|
|
icon: "loading"
|
|
});
|
|
var o = t.tempFiles[0].path;
|
|
a.restAjax.file(a.restAjax.path(a.apis.uploadImg, [ a.baseUrls.serviceUrl ]), o, "image", {
|
|
headers: {
|
|
token: a.globalData.token
|
|
}
|
|
}, function(a, t) {
|
|
if ("200" == a) {
|
|
var o = JSON.parse(t).data;
|
|
e.setData({
|
|
qrCode: o
|
|
}), wx.hideToast();
|
|
}
|
|
}, function(a, e) {
|
|
console.log(e);
|
|
});
|
|
}
|
|
});
|
|
},
|
|
submitCreate: function() {
|
|
var e = {
|
|
address: this.data.address,
|
|
job: this.data.intro,
|
|
realName: this.data.realName,
|
|
photo: this.data.photo,
|
|
qrCode: this.data.qrCode,
|
|
templateId: this.data.cardType
|
|
};
|
|
a.restAjax.post(a.restAjax.path(a.apis.submitCreateCard, [ a.baseUrls.requestUrl ]), e, {
|
|
headers: {
|
|
token: a.globalData.token
|
|
}
|
|
}, function(a, e) {
|
|
"200" == a && wx.showToast({
|
|
title: "创建成功!"
|
|
});
|
|
}, function(a, e) {
|
|
console.log(e);
|
|
});
|
|
},
|
|
onReady: function() {},
|
|
onShow: function() {},
|
|
onHide: function() {},
|
|
onUnload: function() {},
|
|
onPullDownRefresh: function() {},
|
|
onReachBottom: function() {},
|
|
onShareAppMessage: function() {}
|
|
}); |