找回后的代码修改

This commit is contained in:
itgaojian 2023-07-18 16:54:17 +08:00
parent 7fe51944d0
commit 8a10703e14
41 changed files with 6149 additions and 4923 deletions

93
app.js
View File

@ -2,50 +2,53 @@
var restAjax = require('./utils/restAjax.js');
var request = require('./utils/request.js');
App({
restAjax: restAjax,
http: request,
apis: restAjax.apis,
urls:request.apis,
baseUrls: restAjax.baseUrl,
onLaunch() {
this.globalData.windowHeight = wx.getSystemInfoSync().windowHeight
//设置状态栏
wx.getSystemInfo({
success: e => {
this.globalData.StatusBar = e.statusBarHeight;
let capsule = wx.getMenuButtonBoundingClientRect();
if (capsule) {
this.globalData.Custom = capsule;
this.globalData.CustomBar = capsule.bottom + capsule.top - e.statusBarHeight;
} else {
this.globalData.CustomBar = e.statusBarHeight + 50;
}
}
})
},
// 获取用户信息
getUserInfo: function () {
var self = this
app.restAjax.get(app.restAjax.path('{loginUrl}app/user/get-app-user', [app.personIntroUrl]), {}, {
headers: {
token: app.globalData.token
}
}, function (code, data) {
app.globalData.userInfo = data
}, function (code, data) {
app.dialog.msg(data.msg);
});
},
globalData: {
userIcon: '',
userInfo: {},
currentCommunity: {
communityId: '',
communityName: '切换社区'
restAjax: restAjax,
http: request,
apis: restAjax.apis,
urls: request.apis,
baseUrls: restAjax.baseUrl,
onLaunch() {
var _self = this;
this.globalData.windowHeight = wx.getSystemInfoSync().windowHeight
//设置状态栏
wx.getSystemInfo({
success: e => {
this.globalData.StatusBar = e.statusBarHeight;
let capsule = wx.getMenuButtonBoundingClientRect();
if (capsule) {
this.globalData.Custom = capsule;
this.globalData.CustomBar = capsule.bottom + capsule.top - e.statusBarHeight;
} else {
this.globalData.CustomBar = e.statusBarHeight + 50;
}
}
})
//获取手机屏幕高度、宽度
_self.globalData.windowHeight = wx.getSystemInfoSync().windowHeight
_self.globalData.windowWidth = wx.getSystemInfoSync().windowWidth
},
token: ''
}
// 获取用户信息
getUserInfo: function () {
var self = this
app.restAjax.get(app.restAjax.path('{loginUrl}app/user/get-app-user', [app.personIntroUrl]), {}, {
headers: {
token: app.globalData.token
}
}, function (code, data) {
app.globalData.userInfo = data
}, function (code, data) {
app.dialog.msg(data.msg);
});
},
globalData: {
userIcon: '',
userInfo: {},
currentCommunity: {
communityId: '',
communityName: '切换社区'
},
token: ''
}
})

View File

@ -1,5 +1,4 @@
{
"style": "v2",
"sitemapLocation": "sitemap.json",
"pages": [
"pages/index/index",
@ -97,6 +96,7 @@
"common/corpperimg/cropperimg"
]
}],
"requiredPrivateInfos": ["chooseLocation","getLocation"]
"requiredPrivateInfos": ["chooseLocation","getLocation"],
"plugins": {"chooseLocation":{"version": "1.0.10","provider": "wx76a9a06e5b4e693e"}}
}

View File

@ -1,339 +1,487 @@
var e = require("../../@babel/runtime/helpers/defineProperty"), t = getApp();
require("../../utils/util.js");
const app = getApp()
Page({
data: {
preview: "",
showHide: !1,
isLoading: !1,
isMain: "",
cardPersonId: "",
choose_index: 0,
active: 0,
cardUrl: t.baseUrls.baseCardUrl,
areaList: [],
cardInfo: {},
bgImg: "",
fontFamilyList: [],
useFontFamily: "",
cardId: "",
cardHeight: "",
shareTicket: "",
encryptedData: "",
iv: "",
isFromOut: !1,
token: "",
oldToken: "",
fromMine: !1,
imgTempSrc: "",
currentIndex: 0,
windowWidth: t.globalData.windowWidth,
scale: 1,
pageType: null
},
tabChange: function(e) {
this.setData({
active: e.detail
}), 0 == this.data.active || (1 == this.data.active ? 1 == t.globalData.servicePageType ? wx.redirectTo({
url: "/pages/shop/catalog/bannerlist/bannerlist"
}) : 2 == t.globalData.servicePageType ? wx.redirectTo({
url: "/pages/shop/catalog/column/column"
}) : 3 == t.globalData.servicePageType ? wx.redirectTo({
url: "/pages/shop/catalog/list/list"
}) : 4 == t.globalData.servicePageType && wx.redirectTo({
url: "/pages/shop/bespeak/bespeak"
}) : wx.redirectTo({
url: "/pages/mine/index/index"
}));
},
createMyCard: function() {
var e = this;
wx.showLoading({
title: "生成中...",
success: function() {
e.setData({
isLoading: !0
});
}
});
for (var a = {
pictureTemplateId: e.data.cardId,
cardTemplateUseAreaList: []
}, r = 0; r < e.data.areaList.length; r++) if ("1" != e.data.areaList[r].templateAreaType) {
var o = {
cardTemplateUseId: "",
picturesTemplateAreaId: e.data.areaList[r].picturesTemplateAreaId,
templateAreaFile: e.data.areaList[r].templateAreaFile,
templateAreaFontValue: e.data.areaList[r].templateAreaFontValue
};
a.cardTemplateUseAreaList.push(o);
}
t.http.post(t.urls.creatCard, {
data: a,
header: {
token: t.globalData.token
}
}).then(function(t) {
console.log(t), "200" == t.statusCode && e.getMineCardList();
}).catch(function(t) {
e.setData({
isLoading: !1,
showHide: !1
});
});
},
getMineCardList: function() {
var e = this;
t.http.get(t.urls.getMyCard, {
header: {
token: t.globalData.token
},
data: {}
}).then(function(t) {
e.setData({
cardList: t.data
}), t.data.length > 0 && (e.setDefaultCard(t.data[0].cardTemplateUseId), console.log(e.data.pageType),
"org" == e.data.pageType ? e.saveOrgCard(t.data[0].cardTemplateUseId) : e.saveCardIdToSyzl(t.data[0].cardTemplateUseId));
}).catch(function(t) {
wx.hideLoading({}), e.setData({
isLoading: !1,
showHide: !1
});
});
},
saveCardIdToSyzl: function(e) {
console.log("设置网格员名片" + e);
var a = this;
t.restAjax.put(t.restAjax.path(t.apis.doUpdateCard, [ t.baseUrls.requestUrl, a.data.id ]), {
cardSysId: e
}, {
headers: {
token: t.globalData.token
}
}, function(e, t) {
console.log(e), console.log(t), "200" == e && a.onShowHintDialog();
}, function(e, t) {
wx.hideLoading({}), wx.showToast({
icon: "none",
title: "设置名片失败"
}), console.log(e), console.log(t);
});
},
saveOrgCard: function(e) {
var a = this;
t.restAjax.put(t.restAjax.path(t.apis.doUpdateOrg, [ t.baseUrls.requestUrl, a.data.id ]), {
cardSysId: e
}, {
headers: {
token: t.globalData.token
}
}, function(e, t) {
"200" == e && a.onShowHintDialog();
}, function(e, t) {
wx.hideLoading({}), wx.showToast({
icon: "none",
title: "设置名片失败"
}), console.log(t);
});
},
setDefaultCard: function(e) {
t.http.put(t.urls.setDefaultCard.format({
cardTemplateUseId: e
}), {
header: {
token: t.globalData.token
}
}).then(function(e) {}).catch(function(e) {});
},
onShowHintDialog: function() {
var e = this;
wx.hideLoading({
success: function(t) {
e.setData({
isLoading: !1
}), wx.showModal({
content: "恭喜您名片创建成功,如需查看请到(我的 → 我的卡包)",
cancelText: "继续创建",
confirmText: "返回列表",
cancelColor: "#333333",
confirmColor: "#333333",
success: function(t) {
t.confirm ? e.backList() : e.continueCreate();
}
});
}
});
},
inputBlur: function(e) {
var t = e.detail.value, a = e.currentTarget.dataset.num, r = e.currentTarget.dataset.item, o = r.templateAreaFontLength;
"" != t && o > 0 && (t = t.substr(0, o), this.data.areaList[a].templateAreaFontValue = t,
this.data.areaList[a].focus = !1, this.setData({
areaList: this.data.areaList
})), "1" != r.templateAreaServerLink && this.getFileId(a);
},
choosePhoto: function(e) {
var t = e.currentTarget.dataset.cur, a = e.currentTarget.dataset.item;
console.log(t), this.setData({
currentIndex: t
});
var r = a.templateAreaWidth / a.templateAreaHeight;
wx.chooseImage({
count: 1,
sourceType: [ "album", "camera" ],
success: function(e) {
wx.navigateTo({
url: "/packagecard/common/corpperimg/cropperimg?imgSrc=" + e.tempFiles[0].path + "&scale=" + r
});
}
});
},
doUploadImg: function(a) {
var r = this;
wx.showLoading({
title: "上传中..."
}), t.http.upload(t.urls.doUploadImg, {
path: a,
name: "image",
header: {
token: t.globalData.token
}
}).then(function(t) {
wx.hideLoading({}), t = JSON.parse(t);
var a = "areaList[" + r.data.currentIndex + "].templateAreaFile";
r.setData(e({}, a, t.data)), wx.showToast({
title: "上传成功",
duration: 1500
}), r.setData({
imgTempSrc: "",
currentIndex: 0
});
}).catch(function(e) {
r.setData({
imgTempSrc: "",
currentIndex: 0
});
});
},
getNameCard: function() {
var e = this;
e.data.fromMine && e.data.cardPersonId, t.http.get(t.urls.getCardDetail.format({
cardTemplateId: e.data.cardId
}), {
header: {
token: t.globalData.token
},
data: {}
}).then(function(t) {
var a = t.data.areaList, r = t.data.picturesTemplateWidth / e.data.windowWidth;
t.data.picturesTemplateWidth = t.data.picturesTemplateWidth / r, t.data.picturesTemplateHeight = t.data.picturesTemplateHeight / r;
for (var o = 0; o < a.length; o++) "1" == a[o].templateAreaFontCenter ? a[o].templateAreaFontCenter = "left" : "2" == a[o].templateAreaFontCenter ? a[o].templateAreaFontCenter = "center" : a[o].templateAreaFontCenter = "right",
"0" == a[o].templateAreaFontBold ? a[o].templateAreaFontBold = "normal" : "1" == a[o].templateAreaFontBold ? a[o].templateAreaFontBold = "bold" : a[o].templateAreaFontStyle = "italic",
a[o].templateAreaFontSize = a[o].templateAreaFontSize / r + "px", a[o].templateAreaHeight = a[o].templateAreaHeight / r,
a[o].templateAreaWidth = a[o].templateAreaWidth / r, a[o].templateAreaDown = a[o].templateAreaDown / r,
a[o].templateAreaTop = a[o].templateAreaTop / r, a[o].templateAreaRight = a[o].templateAreaRight / r,
a[o].templateAreaLeft = a[o].templateAreaLeft / r;
e.setData({
cardInfo: t.data,
areaList: a
});
}).catch(function(e) {});
},
getNameCradArea: function() {
var e = this, a = [];
t.restAjax.get(t.restAjax.path("{cardUrl}app/cardtemplatearea/listcardtemplateareabytemplateid/" + e.data.cardId, [ t.tradeUrl ]), {}, {
headers: {
token: t.globalData.token
}
}, function(t, r) {
for (var o = 0; o < r.length; o++) if (r[o].focus = !1, "1" != r[o].templateAreaType) a.push(r[o]); else {
var n = parseInt(r[o].templateAreaFontSize.replace("px", ""));
n = Math.floor(750 * n / wx.getSystemInfoSync().windowWidth) + "rpx", r[o].templateAreaFontSize = n,
a.push(r[o]);
}
e.setData({
areaList: a
});
}, function(e, a) {
t.dialog.msg(a.msg);
});
},
editInfo: function(t) {
var a = t.currentTarget.dataset.num, r = t.detail.value, o = "areaList[" + a + "].templateAreaFontValue";
this.setData(e({}, o, r));
},
giveFocus: function(t) {
console.log(t.currentTarget.dataset.cur);
var a = "areaList[" + t.currentTarget.dataset.cur + "].focus";
this.setData(e({}, a, !0));
},
continueCreate: function() {
this.setData({
showHide: !1
});
},
backList: function() {
wx.navigateBack({
delta: 1
});
},
getUserInfo: function() {
t.restAjax.get(t.restAjax.path("{loginUrl}app/user/get-app-user", [ t.personIntroUrl ]), {}, {
headers: {
token: t.globalData.token
}
}, function(e, a) {
t.globalData.userInfo = a;
}, function(e, a) {
t.dialog.msg(a.msg);
});
},
getFileId: function(a) {
var r = this, o = a, n = r.data.areaList[o].templateAreaFontValue;
console.log(n);
var i = r.data.areaList[o].picturesTemplateAreaId;
t.http.get(t.urls.getFileId.format({
picturesTemplateAreaId: i
}), {
header: {
token: t.globalData.token
},
data: {
content: n
}
}).then(function(t) {
console.log(t.data);
var a = "areaList[" + o + "].templateAreaFile";
r.setData(e({}, a, t.data.data));
}).catch(function(e) {});
},
onLoad: function(e) {
this.setData({
cardId: e.id,
token: t.globalData.token,
pageType: e.type,
id: e.taskId
}), this.getNameCard();
},
postRecord: function(e) {
t.restAjax.post(t.restAjax.path("{loginUrl}app/cardtemplateforwardingrecord/savecardtemplateforwardingrecord", [ t.tradeUrl ]), {
encryptedData: e.encryptedData,
iv: e.iv,
templateUseId: this.data.cardId,
templateFromUserId: this.data.oldToken,
templateToUserId: this.data.token
}, {
headers: {
token: this.data.token
}
}, function(e, t) {
console.log("1" + t);
}, function(e, a) {
t.dialog.msg(a.msg);
});
},
openPage: function() {},
onShow: function() {
console.log(this.data.imgTempSrc), "" != this.data.imgTempSrc && this.doUploadImg(this.data.imgTempSrc);
data: {
preview: '',
showHide: false,
isLoading: false,
isMain: '',
cardPersonId: '',
choose_index: 0,
active: 0,
cardUrl: app.baseUrls.baseCardUrl,
areaList: [],
cardInfo: {},
bgImg: '',
fontFamilyList: [],
useFontFamily: '',
cardId: '',
cardHeight: '',
shareTicket: '',
encryptedData: '',
iv: '',
isFromOut: false,
token: '',
oldToken: '',
fromMine: false,
imgTempSrc: '',
currentIndex: 0,
windowWidth: app.globalData.windowWidth,
scale: 1,
pageType: null
},
tabChange: function (e) {
this.setData({
active: e.detail
})
if (this.data.active == 0) {
} else if (this.data.active == 1) {
// 服务
if (app.globalData.servicePageType == 1) {
wx.redirectTo({
url: '/pages/shop/catalog/bannerlist/bannerlist',
})
} else if (app.globalData.servicePageType == 2) {
wx.redirectTo({
url: '/pages/shop/catalog/column/column',
})
} else if (app.globalData.servicePageType == 3) {
wx.redirectTo({
url: '/pages/shop/catalog/list/list',
})
} else if (app.globalData.servicePageType == 4) {
wx.redirectTo({
url: '/pages/shop/bespeak/bespeak',
})
}
} else {
//我的
wx.redirectTo({
url: '/pages/mine/index/index',
})
}
// this.setData({
// active: e.detail
// }), 0 == this.data.active || (1 == this.data.active ? 1 == app.globalData.servicePageType ? wx.redirectTo({
// url: "/pages/shop/catalog/bannerlist/bannerlist"
// }) : 2 == app.globalData.servicePageType ? wx.redirectTo({
// url: "/pages/shop/catalog/column/column"
// }) : 3 == app.globalData.servicePageType ? wx.redirectTo({
// url: "/pages/shop/catalog/list/list"
// }) : 4 == app.globalData.servicePageType && wx.redirectTo({
// url: "/pages/shop/bespeak/bespeak"
// }) : wx.redirectTo({
// url: "/pages/mine/index/index"
// }));
},
createMyCard: function () {
var self = this
wx.showLoading({
title: '生成中...',
success() {
self.setData({
isLoading: true
})
}
})
var content = {
pictureTemplateId: self.data.cardId,
cardTemplateUseAreaList: []
}
for (let i = 0; i < self.data.areaList.length; i++) {
if (self.data.areaList[i].templateAreaType != '1') {
var info = {
cardTemplateUseId: "",
picturesTemplateAreaId: self.data.areaList[i].picturesTemplateAreaId,
templateAreaFile: self.data.areaList[i].templateAreaFile,
templateAreaFontValue: self.data.areaList[i].templateAreaFontValue
}
content.cardTemplateUseAreaList.push(info)
}
}
app.http.post(app.urls.creatCard, {
data: content,
header: {
token: app.globalData.token
}
}).then(res => {
console.log(res)
// "200" == t.statusCode && e.getMineCardList();
if (res.statusCode == '200') {
self.getMineCardList();
}
}).catch(res => {
console.log(res)
self.setData({
isLoading: false,
showHide: false
})
})
// var e = this;
// wx.showLoading({
// title: "生成中...",
// success: function () {
// e.setData({
// isLoading: !0
// });
// }
// });
// for (var a = {
// pictureTemplateId: e.data.cardId,
// cardTemplateUseAreaList: []
// }, r = 0; r < e.data.areaList.length; r++) if ("1" != e.data.areaList[r].templateAreaType) {
// var o = {
// cardTemplateUseId: "",
// picturesTemplateAreaId: e.data.areaList[r].picturesTemplateAreaId,
// templateAreaFile: e.data.areaList[r].templateAreaFile,
// templateAreaFontValue: e.data.areaList[r].templateAreaFontValue
// };
// a.cardTemplateUseAreaList.push(o);
// }
// app.http.post(t.urls.creatCard, {
// data: a,
// header: {
// token: t.globalData.token
// }
// }).then(function (t) {
// console.log(t), "200" == t.statusCode && e.getMineCardList();
// }).catch(function (t) {
// e.setData({
// isLoading: !1,
// showHide: !1
// });
// });
},
getMineCardList: function () {
var e = this;
app.http.get(app.urls.getMyCard, {
header: {
token: app.globalData.token
},
data: {}
}).then(function (t) {
e.setData({
cardList: t.data
}), t.data.length > 0 && (e.setDefaultCard(t.data[0].cardTemplateUseId), console.log(e.data.pageType),
"org" == e.data.pageType ? e.saveOrgCard(t.data[0].cardTemplateUseId) : e.saveCardIdToSyzl(t.data[0].cardTemplateUseId));
}).catch(function (t) {
wx.hideLoading({}), e.setData({
isLoading: !1,
showHide: !1
});
});
},
saveCardIdToSyzl: function (e) {
console.log("设置网格员名片" + e);
var a = this;
app.restAjax.put(app.restAjax.path(app.apis.doUpdateCard, [app.baseUrls.requestUrl, a.data.id]), {
cardSysId: e
}, {
headers: {
token: app.globalData.token
}
}, function (e, t) {
console.log(e), console.log(t), "200" == e && a.onShowHintDialog();
}, function (e, t) {
wx.hideLoading({}), wx.showToast({
icon: "none",
title: "设置名片失败"
}), console.log(e), console.log(t);
});
},
saveOrgCard: function (e) {
var a = this;
app.restAjax.put(app.restAjax.path(app.apis.doUpdateOrg, [app.baseUrls.requestUrl, a.data.id]), {
cardSysId: e
}, {
headers: {
token: app.globalData.token
}
}, function (e, t) {
"200" == e && a.onShowHintDialog();
}, function (e, t) {
wx.hideLoading({}), wx.showToast({
icon: "none",
title: "设置名片失败"
}), console.log(t);
});
},
setDefaultCard: function (e) {
app.http.put(app.urls.setDefaultCard.format({
cardTemplateUseId: e
}), {
header: {
token: app.globalData.token
}
}).then(function (e) { }).catch(function (e) { });
},
onShowHintDialog: function () {
var e = this;
wx.hideLoading({
success: function (t) {
e.setData({
isLoading: !1
}), wx.showModal({
content: "恭喜您名片创建成功,如需查看请到(我的 → 我的卡包)",
cancelText: "继续创建",
confirmText: "返回列表",
cancelColor: "#333333",
confirmColor: "#333333",
success: function (t) {
t.confirm ? e.backList() : e.continueCreate();
}
});
}
});
},
inputBlur: function (e) {
var t = e.detail.value, a = e.currentTarget.dataset.num, r = e.currentTarget.dataset.item, o = r.templateAreaFontLength;
"" != t && o > 0 && (t = t.substr(0, o), this.data.areaList[a].templateAreaFontValue = t,
this.data.areaList[a].focus = !1, this.setData({
areaList: this.data.areaList
})), "1" != r.templateAreaServerLink && this.getFileId(a);
},
choosePhoto: function (e) {
var t = e.currentTarget.dataset.cur, a = e.currentTarget.dataset.item;
console.log(t), this.setData({
currentIndex: t
});
var r = a.templateAreaWidth / a.templateAreaHeight;
wx.chooseMedia({
count: 1,
mediaType: ['image'],
sourceType: ['album', 'camera'],
success: function (e) {
console.log(e)
wx.navigateTo({
url: "/packagecard/common/corpperimg/cropperimg?imgSrc=" + e.tempFiles[0].tempFilePath + "&scale=" + r
});
}
})
},
doUploadImg: function (path) {
var _self = this
wx.showLoading({
title: '上传中...',
})
app.http.upload(app.urls.doUploadImg, {
path: path,
name: 'image',
header: {
token: app.globalData.token
}
}).then(res => {
wx.hideLoading({})
res = JSON.parse(res)
var change = 'areaList[' + _self.data.currentIndex + '].templateAreaFile'
_self.setData({
[change]: res.data
})
wx.showToast({
title: '上传成功',
duration: 1500
})
_self.setData({
imgTempSrc: '',
currentIndex: 0
})
}).catch(res => {
_self.setData({
imgTempSrc: '',
currentIndex: 0
})
})
// var r = this;
// wx.showLoading({
// title: "上传中..."
// }), app.http.upload(app.urls.doUploadImg, {
// path: a,
// name: "image",
// header: {
// token: app.globalData.token
// }
// }).then(function (t) {
// wx.hideLoading({}), t = JSON.parse(t);
// var a = "areaList[" + r.data.currentIndex + "].templateAreaFile";
// r.setData(e({}, a, t.data)), wx.showToast({
// title: "上传成功",
// duration: 1500
// }), r.setData({
// imgTempSrc: "",
// currentIndex: 0
// });
// }).catch(function (e) {
// r.setData({
// imgTempSrc: "",
// currentIndex: 0
// });
// });
},
getNameCard: function () {
var self = this;
app.http.get(app.urls.getCardDetail.format({
cardTemplateId: self.data.cardId
}), {
header: {
token: app.globalData.token
},
data: {}
}).then(res => {
var area = res.data.areaList
var scale = res.data.picturesTemplateWidth / self.data.windowWidth
res.data.picturesTemplateWidth = res.data.picturesTemplateWidth / scale
res.data.picturesTemplateHeight = res.data.picturesTemplateHeight / scale
for (let i = 0; i < area.length; i++) {
if (area[i].templateAreaFontCenter == '1') {
area[i].templateAreaFontCenter = 'left'
} else if (area[i].templateAreaFontCenter == '2') {
area[i].templateAreaFontCenter = 'center'
} else {
area[i].templateAreaFontCenter = 'right'
}
if (area[i].templateAreaFontBold == '0') {
area[i].templateAreaFontBold = 'normal'
} else if (area[i].templateAreaFontBold == '1') {
area[i].templateAreaFontBold = 'bold'
} else {
area[i]['templateAreaFontStyle'] = 'italic'
}
area[i].templateAreaFontSize = area[i].templateAreaFontSize / scale + 'px'
area[i].templateAreaHeight = area[i].templateAreaHeight / scale
area[i].templateAreaWidth = area[i].templateAreaWidth / scale
area[i].templateAreaDown = area[i].templateAreaDown / scale
area[i].templateAreaTop = area[i].templateAreaTop / scale
area[i].templateAreaRight = area[i].templateAreaRight / scale
area[i].templateAreaLeft = area[i].templateAreaLeft / scale
}
self.setData({
cardInfo: res.data,
areaList: area
})
})
.catch(err => {
})
// var e = this;
// e.data.fromMine && e.data.cardPersonId, app.http.get(app.urls.getCardDetail.format({
// cardTemplateId: e.data.cardId
// }), {
// header: {
// token: app.globalData.token
// },
// data: {}
// }).then(function (t) {
// var a = t.data.areaList, r = t.data.picturesTemplateWidth / e.data.windowWidth;
// t.data.picturesTemplateWidth = t.data.picturesTemplateWidth / r, t.data.picturesTemplateHeight = t.data.picturesTemplateHeight / r;
// for (var o = 0; o < a.length; o++) "1" == a[o].templateAreaFontCenter ? a[o].templateAreaFontCenter = "left" : "2" == a[o].templateAreaFontCenter ? a[o].templateAreaFontCenter = "center" : a[o].templateAreaFontCenter = "right",
// "0" == a[o].templateAreaFontBold ? a[o].templateAreaFontBold = "normal" : "1" == a[o].templateAreaFontBold ? a[o].templateAreaFontBold = "bold" : a[o].templateAreaFontStyle = "italic",
// a[o].templateAreaFontSize = a[o].templateAreaFontSize / r + "px", a[o].templateAreaHeight = a[o].templateAreaHeight / r,
// a[o].templateAreaWidth = a[o].templateAreaWidth / r, a[o].templateAreaDown = a[o].templateAreaDown / r,
// a[o].templateAreaTop = a[o].templateAreaTop / r, a[o].templateAreaRight = a[o].templateAreaRight / r,
// a[o].templateAreaLeft = a[o].templateAreaLeft / r;
// e.setData({
// cardInfo: t.data,
// areaList: a
// });
// }).catch(function (e) { });
},
getNameCradArea: function () {
var e = this, a = [];
app.restAjax.get(app.restAjax.path("{cardUrl}app/cardtemplatearea/listcardtemplateareabytemplateid/" + e.data.cardId, [app.tradeUrl]), {}, {
headers: {
token: app.globalData.token
}
}, function (t, r) {
for (var o = 0; o < r.length; o++) if (r[o].focus = !1, "1" != r[o].templateAreaType) a.push(r[o]); else {
var n = parseInt(r[o].templateAreaFontSize.replace("px", ""));
n = Math.floor(750 * n / wx.getSystemInfoSync().windowWidth) + "rpx", r[o].templateAreaFontSize = n,
a.push(r[o]);
}
e.setData({
areaList: a
});
}, function (e, a) {
t.dialog.msg(a.msg);
});
},
editInfo: function (t) {
var a = t.currentTarget.dataset.num, r = t.detail.value, o = "areaList[" + a + "].templateAreaFontValue";
this.setData(e({}, o, r));
},
giveFocus: function (t) {
console.log(t.currentTarget.dataset.cur);
var a = "areaList[" + t.currentTarget.dataset.cur + "].focus";
this.setData(e({}, a, !0));
},
continueCreate: function () {
this.setData({
showHide: !1
});
},
backList: function () {
wx.navigateBack({
delta: 1
});
},
getUserInfo: function () {
app.restAjax.get(app.restAjax.path("{loginUrl}app/user/get-app-user", [app.personIntroUrl]), {}, {
headers: {
token: app.globalData.token
}
}, function (e, a) {
app.globalData.userInfo = a;
}, function (e, a) {
app.dialog.msg(a.msg);
});
},
getFileId: function (a) {
var r = this, o = a, n = r.data.areaList[o].templateAreaFontValue;
console.log(n);
var i = r.data.areaList[o].picturesTemplateAreaId;
app.http.get(app.urls.getFileId.format({
picturesTemplateAreaId: i
}), {
header: {
token: app.globalData.token
},
data: {
content: n
}
}).then(function (t) {
console.log(t.data);
var a = "areaList[" + o + "].templateAreaFile";
r.setData(e({}, a, t.data.data));
}).catch(function (e) { });
},
onLoad: function (e) {
this.setData({
cardId: e.id,
token: app.globalData.token,
pageType: e.type,
id: e.taskId
});
console.log(app.globalData.token)
this.getNameCard();
},
postRecord: function (e) {
app.restAjax.post(app.restAjax.path("{loginUrl}app/cardtemplateforwardingrecord/savecardtemplateforwardingrecord", [app.tradeUrl]), {
encryptedData: e.encryptedData,
iv: e.iv,
templateUseId: this.data.cardId,
templateFromUserId: this.data.oldToken,
templateToUserId: this.data.token
}, {
headers: {
token: this.data.token
}
}, function (e, t) {
console.log("1" + t);
}, function (e, a) {
t.dialog.msg(a.msg);
});
},
openPage: function () { },
onShow: function () {
console.log(this.data.imgTempSrc), "" != this.data.imgTempSrc && this.doUploadImg(this.data.imgTempSrc);
}
});

View File

@ -1,55 +1,91 @@
<view style="margin:15rpx;">
<view class="card" style="padding-bottom:{{cardInfo.picturesTemplateHeight/cardInfo.picturesTemplateWidth*100+'%'}};">
<image alt="" class="card-bgImg" src="{{cardUrl}}{{cardInfo.picturesTemplateBackgroundImage}}" wx:if="{{cardInfo.picturesTemplateBackgroundImage}}"></image>
<view catchtap="giveFocus" class="area-box {{item.templateAreaFontCenter=='left'?'wrap-line':''}} {{item.templateAreaFontCenter=='center'?'wrap-center':''}} {{item.templateAreaFontCenter=='right'?'wrap-line':''}} " data-cur="{{index}}" style="position:absolute;top: {{item.templateAreaTop/cardInfo.picturesTemplateHeight*100+'%'}};left:{{item.templateAreaLeft/cardInfo.picturesTemplateWidth*100+'%'}};color:{{item.templateAreaFontColor}};;width:{{item.templateAreaWidth}}px;height:{{item.templateAreaHeight}}px;font-size:{{item.templateAreaFontSize}};font-style:{{item.templateAreaFontStyle}};font-weight:{{item.templateAreaFontBold}};text-align:{{item.templateAreaFontCenter}};" wx:if="{{item.templateAreaServerLink=='1'&&item.templateAreaType!='1'}}" wx:for="{{areaList}}" wx:key="index"> {{item.templateAreaFontValue}} </view>
<view data-cur="{{index}}" data-item="{{item}}" style="position:absolute;top: {{item.templateAreaTop/cardInfo.picturesTemplateHeight*100+'%'}};left:{{item.templateAreaLeft/cardInfo.picturesTemplateWidth*100+'%'}};color:{{item.templateAreaFontColor}};width:{{item.templateAreaWidth/cardInfo.picturesTemplateWidth*100+'%'}};height:{{item.templateAreaHeight/cardInfo.picturesTemplateHeight*100+'%'}};" wx:if="{{item.templateAreaServerLink=='2'}}" wx:for="{{areaList}}" wx:key="index">
<image src="{{cardUrl}}{{item.templateAreaFile}}" style="width: 100%;height:100%"></image>
</view>
<view catchtap="giveFocus" class="area-box" data-cur="{{index}}" style="position:absolute;top: {{item.templateAreaTop/cardInfo.picturesTemplateHeight*100+'%'}};left:{{item.templateAreaLeft/cardInfo.picturesTemplateWidth*100+'%'}};color:{{item.templateAreaFontColor}};width:{{item.templateAreaWidth/cardInfo.picturesTemplateWidth*100+'%'}};height:{{item.templateAreaHeight/cardInfo.picturesTemplateHeight*100+'%'}}" wx:if="{{item.templateAreaType=='1'&&item.templateAreaServerLink=='1'}}" wx:for="{{areaList}}" wx:key="index">
<text wx:if="{{!item.templateAreaFile}}">{{item.templateAreaFontValue}}</text>
<image src="{{cardUrl}}{{item.templateAreaFile}}" wx:else></image>
</view>
<view class="card"
style="padding-bottom:{{(cardInfo.picturesTemplateHeight / cardInfo.picturesTemplateWidth) *100 +'%'}};">
<!-- 背景图 -->
<image src="{{cardUrl}}{{cardInfo.picturesTemplateBackgroundImage}}" alt="" class="card-bgImg"
wx:if="{{cardInfo.picturesTemplateBackgroundImage}}"></image>
<!-- 文字 -->
<view
class="area-box {{item.templateAreaFontCenter == 'left' ? 'wrap-line' :''}} {{item.templateAreaFontCenter == 'center' ? 'wrap-center' :''}} {{item.templateAreaFontCenter == 'right' ? 'wrap-line' :''}} "
wx:for="{{areaList}}" data-cur="{{index}}" catchtap="giveFocus" wx:key="index"
style="position:absolute;top: {{(item.templateAreaTop / cardInfo.picturesTemplateHeight) * 100 + '%'}};left:{{(item.templateAreaLeft / cardInfo.picturesTemplateWidth) * 100 + '%'}};color:{{item.templateAreaFontColor}};;width:{{item.templateAreaWidth }}px;height:{{item.templateAreaHeight}}px;font-size:{{item.templateAreaFontSize}};font-style:{{item.templateAreaFontStyle}};font-weight:{{item.templateAreaFontBold}};text-align:{{item.templateAreaFontCenter}};line-height:{{item.templateAreaHeight}}px;"
wx:if="{{item.templateAreaServerLink == '1' && item.templateAreaType != '1'}}">
{{item.templateAreaFontValue}}
</view>
<!-- 图片 -->
<!-- catchtap="choosePhoto" -->
<view wx:for="{{areaList}}" data-cur="{{index}}" wx:key="index" data-item="{{item}}"
style="position:absolute;top: {{(item.templateAreaTop / cardInfo.picturesTemplateHeight) * 100 + '%'}};left:{{(item.templateAreaLeft / cardInfo.picturesTemplateWidth) * 100 + '%'}};color:{{item.templateAreaFontColor}};width:{{(item.templateAreaWidth / cardInfo.picturesTemplateWidth) * 100 + '%'}};height:{{(item.templateAreaHeight / cardInfo.picturesTemplateHeight) * 100 + '%'}};"
wx:if="{{item.templateAreaServerLink == '2'}}">
<image src="{{cardUrl}}{{item.templateAreaFile}}" style="width: 100%;height:100%"></image>
</view>
<!-- 其他 -->
<view class="area-box" wx:for="{{areaList}}" data-cur="{{index}}" wx:key="index" catchtap="giveFocus"
style="position:absolute;top: {{(item.templateAreaTop / cardInfo.picturesTemplateHeight) * 100 + '%'}};left:{{(item.templateAreaLeft / cardInfo.picturesTemplateWidth) * 100 + '%'}};color:{{item.templateAreaFontColor}};width:{{(item.templateAreaWidth / cardInfo.picturesTemplateWidth) * 100 + '%'}};height:{{(item.templateAreaHeight / cardInfo.picturesTemplateHeight) * 100 + '%'}}"
wx:if="{{item.templateAreaType == '1' && item.templateAreaServerLink == '1'}}">
<text wx:if="{{!item.templateAreaFile}}">{{item.templateAreaFontValue}}</text>
<image src="{{cardUrl}}{{item.templateAreaFile}}" wx:else></image>
<!-- <image src="{{cardUrl}}{{item.templateAreaFile}}" style="width: 100%;height:100%"></image> -->
</view>
</view>
</view>
<view class="content-box">
<view class="card-title">适用行业:{{cardInfo.templateIndustryName}}</view>
<view class="card-info">
<view class="edit-card">
<view wx:if="{{item.templateAreaServerLink!='2'&&item.templateAreaType!='1'}}" wx:for="{{areaList}}" wx:key="index">
<view class="row-ver">
<view class="item-title-box">
<view class="item-title">{{item.templateAreaName}}</view>
<view class="hint-txt" wx:if="{{item.templateAreaFontLength>0}}">最多输入{{item.templateAreaFontLength}}个字符 </view>
</view>
<view class="item-input">
<input bindblur="inputBlur" data-item="{{item}}" data-num="{{index}}" focus="{{item.focus}}" type="text" value="{{item.templateAreaFontValue}}" wx:if="{{item.templateAreaServerLink!='1'}}"></input>
<input bindblur="inputBlur" data-item="{{item}}" data-num="{{index}}" focus="{{item.focus}}" placeholder="请输入内容,最多{{item.templateAreaFontLength}}个字" type="text" value="{{item.templateAreaFontValue}}" wx:else></input>
</view>
</view>
</view>
<view class="row-ver" wx:if="{{item.templateAreaServerLink=='2'&&item.templateAreaType!='1'}}" wx:for="{{areaList}}" wx:key="index">
<view class="item-title-box">
<view class="item-title">{{item.templateAreaName}}</view>
<view class="hint-txt" wx:if="{{item.templateAreaFontLength>0}}">最多输入1张图片</view>
</view>
<view bindtap="choosePhoto" class="card-img-box" data-cur="{{index}}" data-item="{{item}}">
<image mode="widthFix" src="{{cardUrl}}{{item.templateAreaFile}}"></image>
<text class="cuIcon-cameraadd" style="font-size: 100rpx;"></text>
</view>
<view class="card-title">适用行业:{{cardInfo.templateIndustryName}}</view>
<view class="card-info">
<view class="edit-card">
<view wx:for="{{areaList}}" wx:key="index"
wx:if="{{item.templateAreaServerLink != '2' && item.templateAreaType != '1'}}">
<view class="row-ver">
<view class="item-title-box">
<view class="item-title">{{item.templateAreaName}}</view>
<view class="hint-txt" wx:if="{{item.templateAreaFontLength>0}}">最多输入{{item.templateAreaFontLength}}个字符
</view>
</view>
<view class="item-input">
<input type="text" data-num="{{index}}" bindblur="inputBlur" data-item="{{item}}"
value="{{item.templateAreaFontValue}}" focus="{{item.focus}}"
wx:if="{{item.templateAreaServerLink != '1'}}"></input>
<input type="text" placeholder="请输入内容,最多{{item.templateAreaFontLength}}个字" data-item="{{item}}"
bindblur="inputBlur" data-num="{{index}}" value="{{item.templateAreaFontValue}}" focus="{{item.focus}}"
wx:else></input>
</view>
</view>
</view>
<view class="row-ver" wx:for="{{areaList}}" wx:key="index"
wx:if="{{item.templateAreaServerLink == '2' && item.templateAreaType != '1'}}">
<view class="item-title-box">
<view class="item-title">{{item.templateAreaName}}</view>
<view class="hint-txt" wx:if="{{item.templateAreaFontLength>0}}">最多输入1张图片</view>
</view>
<view bindtap="choosePhoto" data-cur="{{index}}" data-item="{{item}}" class="card-img-box">
<image src="{{cardUrl}}{{item.templateAreaFile}}" mode="widthFix"></image>
<text class="cuIcon-cameraadd" style="font-size: 100rpx;"></text>
</view>
</view>
<!-- <view class="row" wx:for="{{areaList}}" wx:key="index" wx:if="{{item.templateAreaType == '9'}}">
<view class="item-title">二维码:</view>
<view class="item-input item-code-input" bindtap="choosePhoto" data-cur="{{index}}">
<image src="{{cardUrl}}route/file/download/true/{{item.templateAreaTitle}}"></image>
点击修改
</view>
</view> -->
</view>
</view>
</view>
<view class="foot bg-white" style="padding: 15rpx;" wx:if="{{!isLoading}}">
<button bindtap="createMyCard" class="cu-btn bg-blue" style="width:100%">生成我的名片</button>
<button class="cu-btn bg-blue" style="width:100%" bindtap="createMyCard">生成我的名片</button>
</view>
<view class="hide-link" wx:if="{{showHide}}">
<view class="hide">
<view class="hide-title">创建成功</view>
<view class="hide-text">恭喜您名片创建成功,如需查看请到(我的 → 我的卡包)</view>
<view class="hide-btn-box">
<view bindtap="continueCreate" class="hide-btn">继续创建</view>
<view bindtap="backList" class="hide-btn">返回模板</view>
</view>
<view class="hide">
<view class="hide-title">创建成功</view>
<view class="hide-text">恭喜您名片创建成功,如需查看请到(我的 → 我的卡包)</view>
<view class="hide-btn-box">
<view class="hide-btn" bindtap="continueCreate">继续创建</view>
<view class="hide-btn" bindtap="backList">返回模板</view>
</view>
</view>
</view>

View File

@ -1,215 +1,223 @@
.card {
box-sizing: border-box;
width: 100%;
height: 0;
position: relative;
width: 100%;
box-sizing: border-box;
z-index: 100;
}
/* text-align: center; */
}
.card-bgImg {
height: 100%;
left: 0;
.card-bgImg {
position: absolute;
top: 0;
left: 0;
width: 100%;
}
.area-box {
background: none!important;
white-space: nowrap;
z-index: 111;
}
.area-box image {
height: 100%;
width: 100%;
}
}
.card-info {
margin-top: 15rpx;
.area-box {
background: none !important;
z-index: 111;
}
.area-box image {
width: 100%;
height: 100%;
}
.card-info {
padding-bottom: 100rpx;
width: 100%;
}
margin-top: 15rpx;
}
.card-title {
background: #fff;
.card-title {
font-size: 30rpx;
padding: 15rpx;
background: #ffffff;
width: 100%;
}
.row {
background: #fff;
}
.row,.row-ver {
border-bottom: 1rpx solid #f5f5f5;
display: flex;
}
.row-ver {
background-color: #fff;
flex-direction: column;
padding: 15rpx;
}
}
.row-ver:nth-child(1) {
padding: 15rpx 15rpx 7.5rpx;
}
.row {
display: flex;
border-bottom: 1px solid #EEE;
background: #ffffff;
border-bottom: 1rpx solid #f5f5f5;
}
.row-ver:last-child {
padding: 7.5rpx 15rpx 15rpx;
}
.row-ver {
display: flex;
border-bottom: 1px solid #EEE;
border-bottom: 1rpx solid #f5f5f5;
flex-direction: column;
background-color: #ffffff;
padding: 15rpx;
}
.item-title {
color: grey;
.row-ver:nth-child(1) {
padding: 15rpx 15rpx 7.5rpx 15rpx;
}
.row-ver:last-child {
padding: 7.5rpx 15rpx 15rpx 15rpx;
}
.item-title {
flex: 1;
font-size: 32rpx;
line-height: 50rpx;
}
color: #808080;
}
.item-title-box {
.item-title-box {
display: flex;
flex-direction: row;
justify-content: space-between;
margin-top: 7.5rpx;
}
.item-input,.item-title-box {
align-items: center;
display: flex;
}
margin-top: 7.5rpx;
}
.item-input {
box-sizing: border-box;
.item-input {
flex: 4;
box-sizing: border-box;
display: flex;
align-items: center;
margin-top: 15rpx;
}
}
.item-input input {
color: #333;
font-size: 32rpx;
height: 50rpx;
text-align: left;
.item-input input {
width: 100%;
}
text-align: left;
height: 50rpx;
font-size: 32rpx;
color: #333;
}
.item-input image {
.item-input image {
max-width: 70%;
}
/* max-height: 120rpx; */
}
.item-code-input image {
max-height: 160rpx;
.item-code-input image {
max-width: 35%;
}
max-height: 160rpx;
}
.hide-link {
background: rgba(0,0,0,.6);
.hide-link {
position: fixed;
top: 0;
bottom: 0;
left: 0;
position: fixed;
right: 0;
top: 0;
background: rgba(0, 0, 0, 0.6);
z-index: 1000;
}
}
.hide {
background: #fff;
border-radius: 10rpx;
flex-direction: column;
left: 50%;
.hide {
position: absolute;
top: 50%;
transform: translate(-50%,-50%);
left: 50%;
width: 60%;
}
.hide,.hide-btn {
align-items: center;
display: flex;
justify-content: center;
}
.hide-btn {
background: #1d7ff0;
border-bottom-left-radius: 10rpx;
border-bottom-right-radius: 10rpx;
color: #fff;
font-size: 30rpx;
height: 60rpx;
width: 50%;
}
.hide-btn:nth-child(1) {
background: #e6b980;
border-bottom-left-radius: 10rpx;
border-bottom-right-radius: 0rpx;
}
.hide-btn:last-child {
border-bottom-left-radius: 0rpx;
border-bottom-right-radius: 10rpx;
}
.hide-text {
color: #000;
font-size: 36rpx;
padding: 50rpx 30rpx;
}
.hide-title {
color: #ffc107;
font-size: 43rpx;
padding: 10rpx;
}
.hide-btn-box {
display: flex;
justify-content: space-between;
width: 100%;
}
.input-box {
width: 100%;
}
.content-box {
align-items: center;
transform: translate(-50%, -50%);
border-radius: 10rpx;
background: #fff;
display: flex;
flex-direction: column;
justify-content: center;
padding: 15rpx;
width: 100%;
}
.cuIcon-cameraadd {
font-size: 60rpx;
}
.card-img-box {
align-items: center;
}
.hide-btn {
display: flex;
width: 50%;
height: 60rpx;
background: #1d7ff0;
color: #fff;
font-size: 30rpx;
justify-content: center;
align-items: center;
border-bottom-left-radius: 10rpx;
border-bottom-right-radius: 10rpx;
}
.hide-btn:nth-child(1) {
background: #E6B980;
border-bottom-left-radius: 10rpx;
border-bottom-right-radius: 0rpx;
}
.hide-btn:last-child {
border-bottom-left-radius: 0rpx;
border-bottom-right-radius: 10rpx;
}
.hide-text {
font-size: 36rpx;
color: #000;
padding: 50rpx 30rpx;
}
.hide-title {
font-size: 43rpx;
color: #ffC107;
padding: 10rpx;
}
.hide-btn-box {
display: flex;
width: 100%;
justify-content: space-between;
}
.input-box {
width: 100%;
}
.content-box {
width: 100%;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
padding: 15rpx;
}
.cuIcon-cameraadd {
font-size: 60rpx;
}
.card-img-box {
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
margin-right: 40rpx;
}
justify-content: space-between;
}
.card-img-box image {
height: 200rpx;
.card-img-box image {
width: 200rpx;
}
height: 200rpx;
}
.hint-txt {
.hint-txt {
text-align: right;
color: #fd9494;
font-size: 24rpx;
text-align: right;
}
}
.wrap-line {
white-space: pre-line;
}
.wrap-center {
/* 换行 */
.wrap-line {
overflow-wrap: break-word;
}
/* 居中 */
.wrap-center {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
overflow-wrap: break-word;
}

View File

@ -8,49 +8,56 @@ Page({
width: 250,
height: 250
},
onLoad: function(e) {
onLoad: function (e) {
console.log(e.imgSrc)
wx.setNavigationBarTitle({
title: "图片裁剪"
}), this.cropper = this.selectComponent("#image-cropper"), this.setData({
src: e.imgSrc
}), wx.showLoading({
});
this.cropper = this.selectComponent("#image-cropper");
this.setData({
src: e.imgSrc,
scale:e.scale
});
wx.showLoading({
title: "加载中"
});
},
cropperload: function(e) {
cropperload: function (e) {
console.log("cropper初始化完成");
},
loadimage: function(e) {
console.log("图片加载完成", e.detail), wx.hideLoading(), this.cropper.imgReset();
loadimage: function (e) {
console.log("图片加载完成", e.detail);
wx.hideLoading();
this.cropper.imgReset();
},
clickcut: function(e) {
clickcut: function (e) {
console.log(e.detail);
var t = getCurrentPages();
(t.length >= 2 ? t[t.length - 2] : void 0).setData({
imgTempSrc: e.detail.url
}), wx.navigateBack({});
},
cropperDone: function(e) {
cropperDone: function (e) {
var t = e.detail, o = t.src, a = (t.cropperData, getCurrentPages());
(a.length >= 2 ? a[a.length - 2] : void 0).setData({
imgTempSrc: o
});
},
cropperCancel: function() {
cropperCancel: function () {
wx.navigateBack({});
},
doCropperDone: function(e) {
doCropperDone: function (e) {
var t = getCurrentPages();
(t.length >= 2 ? t[t.length - 2] : void 0).setData({
imgTempSrc: e
}), wx.navigateBack({});
},
cropperFail: function(e) {
cropperFail: function (e) {
e.detail;
console.log(e), wx.showToast({
title: "裁剪失败,请重试",
icon: "none",
success: function() {
success: function () {
wx.navigateBack({});
}
});

View File

@ -1,6 +1,6 @@
{
"usingComponents": {
"image-cropper": "/vant/dist/cropper/index",
"image-cropper": "/vant/dist/cropper/image-cropper",
"van-tabbar": "/vant/dist/tabbar/index",
"van-tabbar-item": "/vant/dist/tabbar-item/index",
"van-swipe-cell": "/vant/dist/swipe-cell/index",

File diff suppressed because it is too large Load Diff

View File

@ -1,12 +1,22 @@
var t = getApp(), a = wx.getRecorderManager(), e = wx.createInnerAudioContext(), i = requirePlugin("chooseLocation"), s = {
// var t = getApp(), a = wx.getRecorderManager(), , i = requirePlugin("chooseLocation"), s = {
// latitude: 39.90877,
// longitude: 116.39695
// };
const app = getApp()
const recorderManager = wx.getRecorderManager()
var e = wx.createInnerAudioContext();
const chooseLocation = requirePlugin('chooseLocation');
var location = {
latitude: 39.90877,
longitude: 116.39695
};
}; //默认坐标点
Page({
data: {
maringHeight: t.globalData.CustomBar,
fieldList: [ {
maringHeight: app.globalData.CustomBar,
fieldList: [{
type: "text"
}, {
type: "video"
@ -22,7 +32,7 @@ Page({
type: "link"
}, {
type: "photo"
} ],
}],
valueList: [],
isShowInput: !1,
isShowPhoto: !1,
@ -50,7 +60,7 @@ Page({
speedStep: 5,
sourceType: "add",
insertIndex: -1,
optionsList: [ {
optionsList: [{
id: "1",
name: "选项一",
isSel: !1
@ -70,35 +80,35 @@ Page({
id: "5",
name: "选项五",
isSel: !1
} ]
}]
},
onLoad: function(t) {
onLoad: function (t) {
this.setData({
columnId: t.id
}), this.checkPermission(), this.countBoxHeight();
},
countBoxHeight: function() {
countBoxHeight: function () {
var t = this, a = wx.createSelectorQuery();
a.select("#top-box").boundingClientRect(), a.exec(function(a) {
a.select("#top-box").boundingClientRect(), a.exec(function (a) {
t.setData({
topBoxHeight: a[0].height + 7
});
});
},
onShow: function() {
onShow: function () {
var t = this;
if (null != i.getLocation()) {
var a = i.getLocation(), e = {
if (null != chooseLocation.getLocation()) {
var a = chooseLocation.getLocation(), e = {
type: "map"
};
e.value = a, "add" == t.data.sourceType ? t.data.valueList.push(e) : t.data.valueList.splice(t.data.currentIndex, "edit" == t.data.sourceType ? 1 : 0, e),
t.setData({
valueList: t.data.valueList
});
t.setData({
valueList: t.data.valueList
});
}
wx.getSetting({
withSubscriptions: !0,
success: function(a) {
success: function (a) {
var e = a.authSetting["scope.record"];
t.setData({
isAuthAudio: e
@ -106,50 +116,50 @@ Page({
}
});
},
showType: function(t) {
showType: function (t) {
switch (t.currentTarget.dataset.type) {
case "text":
case "textarea":
this.setData({
isShowInput: !0
});
break;
case "text":
case "textarea":
this.setData({
isShowInput: !0
});
break;
case "video":
this.chooseVideo();
break;
case "video":
this.chooseVideo();
break;
case "audio":
this.checkRecordPermission();
break;
case "audio":
this.checkRecordPermission();
break;
case "photo":
this.chooseImg();
break;
case "photo":
this.chooseImg();
break;
case "map":
this.doChooseLocation();
break;
case "map":
this.doChooseLocation();
break;
case "select":
this.setData({
isShowSelect: !0
});
break;
case "select":
this.setData({
isShowSelect: !0
});
break;
case "link":
this.setData({
isShowLink: !0
});
case "link":
this.setData({
isShowLink: !0
});
}
},
chooseImg: function() {
chooseImg: function () {
var t = this;
wx.chooseImage({
count: 9,
sourceType: [ "album", "camera" ],
success: function(a) {
console.log(a), a.tempFilePaths.forEach(function(a) {
sourceType: ["album", "camera"],
success: function (a) {
console.log(a), a.tempFilePaths.forEach(function (a) {
var e = {};
e.path = a, t.data.photoList.push(e);
}), t.setData({
@ -157,7 +167,7 @@ Page({
isShowPhoto: !0
});
},
fail: function(t) {
fail: function (t) {
-1 == t.errMsg.indexOf("fail cancel") && wx.showToast({
title: "请重新选择",
icon: "error"
@ -165,15 +175,15 @@ Page({
}
});
},
chooseVideo: function() {
chooseVideo: function () {
var t = this;
wx.chooseMedia({
count: 9,
mediaType: [ "video" ],
sourceType: [ "album", "camera" ],
mediaType: ["video"],
sourceType: ["album", "camera"],
maxDuration: 60,
success: function(a) {
a.tempFiles.forEach(function(a) {
success: function (a) {
a.tempFiles.forEach(function (a) {
var e = {};
e.path = a.tempFilePath, e.coverPath = a.thumbTempFilePath, t.data.videoList.push(e);
}), t.setData({
@ -181,7 +191,7 @@ Page({
isShowVideo: !0
});
},
fail: function(t) {
fail: function (t) {
-1 == t.errMsg.indexOf("fail cancel") && wx.showToast({
title: "请重新选择",
icon: "error"
@ -189,7 +199,7 @@ Page({
}
});
},
showEditBox: function(t) {
showEditBox: function (t) {
var a = t.currentTarget.dataset.idx;
this.data.currentIndex == a ? this.setData({
currentIndex: -1
@ -197,41 +207,41 @@ Page({
currentIndex: a
});
},
chooseDirection: function(t) {
chooseDirection: function (t) {
var a = t.currentTarget.dataset.idx;
this.setData({
selDirection: a
});
},
choosePhotoDisplay: function(t) {
choosePhotoDisplay: function (t) {
var a = t.currentTarget.dataset.type;
this.setData({
curSelPhotoDisplay: a
});
},
chooseVideoDisplay: function(t) {
chooseVideoDisplay: function (t) {
var a = t.currentTarget.dataset.type;
this.setData({
curVideoDisplay: a
});
},
chooseTextAlign: function(t) {
chooseTextAlign: function (t) {
var a = t.currentTarget.dataset.type;
this.setData({
curTextAlign: a
});
},
chooseFieldType: function(t) {
chooseFieldType: function (t) {
var a = t.currentTarget.dataset.idx, e = t.currentTarget.dataset.type;
this.setData({
curFieldTypeIndex: a,
curFieldType: e
});
},
confirmPhoto: function() {
confirmPhoto: function () {
if (this.data.photoList.length > 0) {
var t = [];
this.data.photoList.forEach(function(a) {
this.data.photoList.forEach(function (a) {
var e = {};
e.path = a.path, t.push(e);
});
@ -239,21 +249,21 @@ Page({
type: "photo"
};
a.valueList = t, a.displayType = this.data.curSelPhotoDisplay, "add" == this.data.sourceType ? this.data.valueList.push(a) : this.data.valueList.splice(this.data.currentIndex, "edit" == this.data.sourceType ? 1 : 0, a),
this.setData({
valueList: this.data.valueList,
photoList: [],
curSelPhotoDisplay: 1,
isShowPhoto: !1
});
this.setData({
valueList: this.data.valueList,
photoList: [],
curSelPhotoDisplay: 1,
isShowPhoto: !1
});
} else wx.showToast({
title: "请选择图片",
icon: "error"
});
},
confirmVideo: function() {
confirmVideo: function () {
if (this.data.videoList.length > 0) {
var t = [];
this.data.videoList.forEach(function(a) {
this.data.videoList.forEach(function (a) {
var e = {};
e.path = a.path, e.coverPath = a.coverPath, t.push(e);
});
@ -261,20 +271,20 @@ Page({
type: "video"
};
a.valueList = t, a.displayType = this.data.curVideoDisplay, "add" == this.data.sourceType ? this.data.valueList.push(a) : this.data.valueList.splice(this.data.currentIndex, "edit" == this.data.sourceType ? 1 : 0, a),
this.setData({
valueList: this.data.valueList,
videoList: [],
curVideoDisplay: 1,
isShowVideo: !1,
currentIndex: -1,
sourceType: "add"
});
this.setData({
valueList: this.data.valueList,
videoList: [],
curVideoDisplay: 1,
isShowVideo: !1,
currentIndex: -1,
sourceType: "add"
});
} else wx.showToast({
title: "请选择视频",
icon: "error"
});
},
doInsert: function() {
doInsert: function () {
var t = -1;
switch (t = 1 == this.data.selDirection ? this.data.currentIndex : ++this.data.currentIndex,
this.setData({
@ -282,47 +292,47 @@ Page({
sourceType: "insert",
isInsert: !1
}), this.data.curFieldType) {
case "text":
case "textarea":
this.setData({
isShowInput: !0
});
break;
case "text":
case "textarea":
this.setData({
isShowInput: !0
});
break;
case "video":
this.chooseVideo();
break;
case "video":
this.chooseVideo();
break;
case "audio":
this.checkRecordPermission();
break;
case "audio":
this.checkRecordPermission();
break;
case "photo":
this.chooseImg();
break;
case "photo":
this.chooseImg();
break;
case "map":
this.doChooseLocation();
break;
case "map":
this.doChooseLocation();
break;
case "select":
this.setData({
isShowSelect: !0
});
break;
case "select":
this.setData({
isShowSelect: !0
});
break;
case "link":
this.setData({
isShowLink: !0
});
case "link":
this.setData({
isShowLink: !0
});
}
},
hideEditBox: function() {
hideEditBox: function () {
this.setData({
currentIndex: -1
});
},
onClose: function() {
onClose: function () {
this.setData({
isShowInput: !1,
isShowLink: !1,
@ -330,17 +340,17 @@ Page({
sourceType: "add"
});
},
inputWatch: function(t) {
inputWatch: function (t) {
this.setData({
curTextValue: t.detail.value
});
},
inputLink: function(t) {
inputLink: function (t) {
this.setData({
curLinkText: t.detail.value
});
},
doConfirmLink: function() {
doConfirmLink: function () {
if ("" == this.data.curLinkText) wx.showToast({
title: "请输入链接",
icon: "error"
@ -349,14 +359,14 @@ Page({
type: "link"
};
t.value = this.data.curLinkText, "add" == this.data.sourceType ? this.data.valueList.push(t) : this.data.valueList.splice(this.data.currentIndex, "edit" == this.data.sourceType ? 1 : 0, t),
this.setData({
valueList: this.data.valueList,
curLinkText: "",
isShowLink: !1
});
this.setData({
valueList: this.data.valueList,
curLinkText: "",
isShowLink: !1
});
}
},
doConfirmInput: function() {
doConfirmInput: function () {
if ("" == this.data.curTextValue) wx.showToast({
title: "请输入内容",
icon: "error"
@ -367,39 +377,39 @@ Page({
t.value = this.data.curTextValue;
var a = "left";
switch (this.data.curTextAlign) {
case "1":
a = "left";
break;
case "1":
a = "left";
break;
case "2":
a = "center";
break;
case "2":
a = "center";
break;
case "3":
a = "right";
case "3":
a = "right";
}
t.textAlign = a, "add" == this.data.sourceType ? this.data.valueList.push(t) : this.data.valueList.splice(this.data.currentIndex, "edit" == this.data.sourceType ? 1 : 0, t),
this.setData({
valueList: this.data.valueList,
curTextValue: "",
isShowInput: !1,
curTextAlign: "1"
});
this.setData({
valueList: this.data.valueList,
curTextValue: "",
isShowInput: !1,
curTextAlign: "1"
});
}
},
checkPermission: function() {
checkPermission: function () {
var t = this;
wx.getSetting({
success: function(a) {
success: function (a) {
var e = a.authSetting["scope.record"];
void 0 === e ? wx.authorize({
scope: "scope.record",
success: function() {
success: function () {
t.setData({
isAuthAudio: !0
});
},
fail: function() {
fail: function () {
t.setData({
isAuthAudio: !1
});
@ -408,123 +418,123 @@ Page({
}
});
},
openSetting: function() {
openSetting: function () {
wx.showModal({
title: "提示",
content: "发布内容需要您授权录音权限.",
success: function(t) {
success: function (t) {
t.confirm && wx.openSetting({
withSubscriptions: !0
});
}
});
},
viewPhoto: function(t) {
viewPhoto: function (t) {
var a = t.currentTarget.dataset.url;
wx.previewImage({
urls: [ a ]
urls: [a]
});
},
delPhoto: function(t) {
delPhoto: function (t) {
var a = this;
wx.showModal({
title: "提示",
content: "确定要删除该图片吗?",
cancelText: "取消",
confirmText: "确定",
success: function(e) {
success: function (e) {
e.confirm && (a.data.photoList.splice(t.currentTarget.dataset.index, 1), a.setData({
photoList: a.data.photoList
}));
}
});
},
viewVideo: function(t) {
viewVideo: function (t) {
var a = t.currentTarget.dataset.idx, e = t.currentTarget.dataset.index, i = this.data.valueList[e].valueList[a].path, s = {};
s.url = i, s.type = "video", wx.previewMedia({
sources: [ s ]
sources: [s]
});
},
delVideo: function(t) {
delVideo: function (t) {
var a = this, e = t.currentTarget.dataset.index;
wx.showModal({
title: "提示",
content: "确定要删除该视频吗?",
success: function(t) {
success: function (t) {
t.confirm && (a.data.videoList.splice(e, 1), a.setData({
videoList: a.data.videoList
}));
}
});
},
doChooseLocation: function(t) {
doChooseLocation: function (t) {
var a = JSON.stringify(s);
wx.navigateTo({
url: "plugin://chooseLocation/index?key=".concat("HVDBZ-KJGKF-DNMJR-JHEWI-H2HN7-23BMS", "&referer=").concat("市域自治与互助", "&location=").concat(a, "&category=").concat("生活服务,娱乐休闲")
});
},
editItem: function(t) {
editItem: function (t) {
var a = t.currentTarget.dataset.index;
switch (this.setData({
sourceType: "edit"
}), this.data.valueList[a].type) {
case "text":
case "textarea":
var e = "1";
e = "left" == this.data.valueList[a].textAlign ? "1" : "center" == this.data.valueList[a].textAlign ? "2" : "3",
this.setData({
isShowInput: !0,
curTextValue: this.data.valueList[a].value,
curTextAlign: e
});
break;
case "text":
case "textarea":
var e = "1";
e = "left" == this.data.valueList[a].textAlign ? "1" : "center" == this.data.valueList[a].textAlign ? "2" : "3",
this.setData({
isShowInput: !0,
curTextValue: this.data.valueList[a].value,
curTextAlign: e
});
break;
case "video":
this.setData({
curVideoDisplay: this.data.valueList[a].displayType,
videoList: this.data.valueList[a].valueList,
isShowVideo: !0
});
break;
case "video":
this.setData({
curVideoDisplay: this.data.valueList[a].displayType,
videoList: this.data.valueList[a].valueList,
isShowVideo: !0
});
break;
case "audio":
this.checkRecordPermission();
break;
case "audio":
this.checkRecordPermission();
break;
case "photo":
this.setData({
curSelPhotoDisplay: this.data.valueList[a].displayType,
photoList: this.data.valueList[a].valueList,
isShowPhoto: !0
});
break;
case "photo":
this.setData({
curSelPhotoDisplay: this.data.valueList[a].displayType,
photoList: this.data.valueList[a].valueList,
isShowPhoto: !0
});
break;
case "map":
s.latitude = this.data.valueList[a].value.latitude, s.longitude = this.data.valueList[a].value.longitude,
this.doChooseLocation();
break;
case "map":
s.latitude = this.data.valueList[a].value.latitude, s.longitude = this.data.valueList[a].value.longitude,
this.doChooseLocation();
break;
case "select":
break;
case "select":
break;
case "link":
this.setData({
curLinkText: this.data.valueList[a].value,
isShowLink: !0
});
case "link":
this.setData({
curLinkText: this.data.valueList[a].value,
isShowLink: !0
});
}
},
insertItem: function(t) {
insertItem: function (t) {
this.setData({
isInsert: !this.data.isInsert
});
},
delItem: function(t) {
delItem: function (t) {
var a = this;
wx.showModal({
title: "提示",
content: "确定要删除该条数据吗?",
success: function(t) {
success: function (t) {
t.confirm && (a.data.valueList.splice(a.data.currentIndex, 1), a.setData({
valueList: a.data.valueList,
currentIndex: -1
@ -532,21 +542,21 @@ Page({
}
});
},
chooseTags: function(t) {
chooseTags: function (t) {
var a = t.currentTarget.dataset.idx, e = t.currentTarget.dataset.item;
this.data.optionsList[a].isSel = !e.isSel, this.setData({
optionsList: this.data.optionsList
});
},
doConfirmSel: function() {
doConfirmSel: function () {
var t = [];
this.data.optionsList.forEach(function(a) {
this.data.optionsList.forEach(function (a) {
a.isSel && t.push(a);
});
var a = {
type: "select"
};
a.valueList = t, this.data.valueList.push(a), this.data.optionsList.forEach(function(t) {
a.valueList = t, this.data.valueList.push(a), this.data.optionsList.forEach(function (t) {
t.isSel = !1;
}), this.setData({
valueList: this.data.valueList,
@ -554,28 +564,28 @@ Page({
optionsList: this.data.optionsList
});
},
doConfirmAudio: function() {
doConfirmAudio: function () {
this.data.audioFile.isPlay && e.stop();
var t = {
type: "audio"
};
t.value = this.data.audioFile, this.data.audioFile.curDurationStr = "00:00", this.data.audioFile.curDuration = 0,
this.data.audioFile.isPlay = !1, "add" == this.data.sourceType ? this.data.valueList.push(t) : this.data.valueList.splice(this.data.currentIndex, "edit" == this.data.sourceType ? 1 : 0, t),
this.setData({
valueList: this.data.valueList,
audioFile: null,
isShowAudio: !1
});
this.data.audioFile.isPlay = !1, "add" == this.data.sourceType ? this.data.valueList.push(t) : this.data.valueList.splice(this.data.currentIndex, "edit" == this.data.sourceType ? 1 : 0, t),
this.setData({
valueList: this.data.valueList,
audioFile: null,
isShowAudio: !1
});
},
checkRecordPermission: function() {
checkRecordPermission: function () {
var t = this;
wx.getSetting({
success: function(a) {
success: function (a) {
a.authSetting["scope.record"] ? t.setData({
isShowAudio: !0
}) : wx.authorize({
scope: "scope.record",
success: function() {
success: function () {
t.setData({
isShowAudio: !0
});
@ -584,9 +594,9 @@ Page({
}
});
},
startRecord: function() {
startRecord: function () {
var t = this;
t.data.setInter = setInterval(function() {
t.data.setInter = setInterval(function () {
var a = parseInt(t.data.audioDuration + 1);
t.setData({
audioDuration: parseInt(a),
@ -594,147 +604,152 @@ Page({
});
}, 1e3), t.start();
},
start: function() {
start: function () {
console.log("开始录音");
a.start({
recorderManager.start({
duration: 6e4,
format: "mp3"
}), a.onStart(function() {
}), recorderManager.onStart(function () {
console.log("recorder start");
}), a.onError(function(t) {
}), recorderManager.onError(function (t) {
console.log(t), _self.stop(!1);
});
},
doEndRecord: function() {
doEndRecord: function () {
var t = this;
clearInterval(t.data.setInter), a.stop(), a.onStop(function(a) {
clearInterval(t.data.setInter);
recorderManager.stop();
recorderManager.onStop(function (a) {
t.data.audioDuration < 10 ? wx.showToast({
title: "录音时长需大于10秒",
icon: "none"
}) : (a.isPlay = !1, a.durationStr = t.data.audioDuration + "", a.duration = t.data.audioDuration,
a.totalDurationStr = "00:" + (t.data.audioDuration > 9 ? t.data.audioDuration : "0" + t.data.audioDuration),
a.curDurationStr = "00:00", a.curDuration = 0, a.isPlay = !1, t.setData({
audioFile: a
})), t.setData({
audioDuration: 0,
isRecording: !1
});
a.totalDurationStr = "00:" + (t.data.audioDuration > 9 ? t.data.audioDuration : "0" + t.data.audioDuration),
a.curDurationStr = "00:00", a.curDuration = 0, a.isPlay = !1, t.setData({
audioFile: a
})), t.setData({
audioDuration: 0,
isRecording: !1
});
});
},
delAudio: function() {
delAudio: function () {
var t = this;
wx.showModal({
title: "警告",
content: "确定要删除该条录音吗?",
success: function(a) {
success: function (a) {
a.confirm && t.setData({
audioFile: null
});
}
});
},
closePop: function(t) {
closePop: function (t) {
var a = t.currentTarget.dataset.type, i = this;
a && "audio" == a && (null != i.data.audioFile ? (i.data.audioFile.isPlay && e.stop(),
wx.showModal({
title: "警告",
content: "关闭录音弹窗将清除当前录制的音频文件,确定要关闭吗?",
success: function(t) {
t.confirm && i.setData({
audioFile: null,
isShowAudio: !1
});
}
})) : i.setData({
isShowAudio: !1
})), this.setData({
isShowPhoto: !1,
isShowEdit: !1,
isShowVideo: !1,
isShowSelect: !1,
sourceType: "add"
});
wx.showModal({
title: "警告",
content: "关闭录音弹窗将清除当前录制的音频文件,确定要关闭吗?",
success: function (t) {
t.confirm && i.setData({
audioFile: null,
isShowAudio: !1
});
}
})) : i.setData({
isShowAudio: !1
})), this.setData({
isShowPhoto: !1,
isShowEdit: !1,
isShowVideo: !1,
isShowSelect: !1,
sourceType: "add"
});
},
slider4change: function(t) {
var a = t.currentTarget.dataset.item, i = t.currentTarget.dataset.type, s = t.currentTarget.dataset.idx, o = Number.parseInt(t.detail.value);
a.isPlay && (e.pause(), e.seek(o), setTimeout(function() {
slider4change: function (t) {
var a = t.currentTarget.dataset.item;
i = t.currentTarget.dataset.type;
s = t.currentTarget.dataset.idx;
o = Number.parseInt(t.detail.value);
a.isPlay && (e.pause(), e.seek(o), setTimeout(function () {
e.play();
}, 500), "record" == i ? (this.data.audioFile.curDuration = o, this.data.audioFile.curDurationStr = "00:" + (o > 9 ? o : "0" + o),
console.log(this.data.audioFile), this.setData({
audioFile: this.data.audioFile
})) : (this.data.valueList[s].value.curDuration = o, this.data.valueList[s].value.curDurationStr = "00:" + (o > 9 ? o : "0" + o),
this.setData({
valueList: this.data.valueList
})));
console.log(this.data.audioFile), this.setData({
audioFile: this.data.audioFile
})) : (this.data.valueList[s].value.curDuration = o, this.data.valueList[s].value.curDurationStr = "00:" + (o > 9 ? o : "0" + o),
this.setData({
valueList: this.data.valueList
})));
},
play: function(t) {
play: function (t) {
var a = t.currentTarget.dataset.item, i = this, s = t.currentTarget.dataset.type, o = t.currentTarget.dataset.idx;
a.isPlay ? e.stop() : ((e = wx.createInnerAudioContext()).src = a.tempFilePath,
e.autoplay = !0), e.onPlay(function() {
"record" == s ? (i.data.audioFile.isPlay = !0, i.setData({
audioFile: i.data.audioFile
})) : (i.data.valueList[o].value.isPlay = !0, i.setData({
valueList: i.data.valueList
}));
}), e.onStop(function(t) {
"record" == s ? i.setAudioDefault() : i.setShowAudioDefault(o);
}), e.onEnded(function(t) {
"record" == s ? i.setAudioDefault() : i.setShowAudioDefault(o);
}), e.onError(function(t) {
wx.showToast({
title: "播放失败",
icon: "error"
}), "record" == s ? i.setAudioDefault() : i.setShowAudioDefault(o);
}), e.onTimeUpdate(function() {
var t = e.currentTime;
if ("record" == s) {
i.data.audioFile.curDuration = t;
var a = Number.parseInt(i.data.audioFile.curDuration);
i.data.audioFile.curDurationStr = "00:" + (a > 9 ? a : "0" + a), i.setData({
e.autoplay = !0), e.onPlay(function () {
"record" == s ? (i.data.audioFile.isPlay = !0, i.setData({
audioFile: i.data.audioFile
});
} else {
i.data.valueList[o].value.curDuration = t;
var u = Number.parseInt(i.data.valueList[o].value.curDuration);
i.data.valueList[o].value.curDurationStr = "00:" + (u > 9 ? a : "0" + u), i.setData({
})) : (i.data.valueList[o].value.isPlay = !0, i.setData({
valueList: i.data.valueList
});
}
});
}));
}), e.onStop(function (t) {
"record" == s ? i.setAudioDefault() : i.setShowAudioDefault(o);
}), e.onEnded(function (t) {
"record" == s ? i.setAudioDefault() : i.setShowAudioDefault(o);
}), e.onError(function (t) {
wx.showToast({
title: "播放失败",
icon: "error"
}), "record" == s ? i.setAudioDefault() : i.setShowAudioDefault(o);
}), e.onTimeUpdate(function () {
var t = e.currentTime;
if ("record" == s) {
i.data.audioFile.curDuration = t;
var a = Number.parseInt(i.data.audioFile.curDuration);
i.data.audioFile.curDurationStr = "00:" + (a > 9 ? a : "0" + a), i.setData({
audioFile: i.data.audioFile
});
} else {
i.data.valueList[o].value.curDuration = t;
var u = Number.parseInt(i.data.valueList[o].value.curDuration);
i.data.valueList[o].value.curDurationStr = "00:" + (u > 9 ? a : "0" + u), i.setData({
valueList: i.data.valueList
});
}
});
},
setAudioDefault: function() {
setAudioDefault: function () {
null != this.data.audioFile && (this.data.audioFile.curDurationStr = "00:00", this.data.audioFile.curDuration = 0,
this.data.audioFile.isPlay = !1, this.setData({
audioFile: this.data.audioFile
}));
this.data.audioFile.isPlay = !1, this.setData({
audioFile: this.data.audioFile
}));
},
setShowAudioDefault: function(t) {
setShowAudioDefault: function (t) {
this.data.valueList[t].value.curDurationStr = "00:00", this.data.valueList[t].value.curDuration = 0,
this.data.valueList[t].value.isPlay = !1, this.setData({
valueList: this.data.valueList
});
this.data.valueList[t].value.isPlay = !1, this.setData({
valueList: this.data.valueList
});
},
rewind: function(t) {
rewind: function (t) {
var a = t.currentTarget.dataset.item, i = t.currentTarget.dataset.idx, s = t.currentTarget.dataset.type;
a.isPlay && ("record" == s ? (this.data.audioFile.curDuration = this.data.audioFile.curDuration - this.data.speedStep,
e.seek(this.data.audioFile.curDuration), this.setData({
audioFile: this.data.audioFile
})) : (this.data.valueList[i].value.curDuration = this.data.valueList[i].value.curDuration - this.data.speedStep,
e.seek(this.data.valueList[i].value.curDuration), this.setData({
valueList: this.data.valueList
})));
e.seek(this.data.audioFile.curDuration), this.setData({
audioFile: this.data.audioFile
})) : (this.data.valueList[i].value.curDuration = this.data.valueList[i].value.curDuration - this.data.speedStep,
e.seek(this.data.valueList[i].value.curDuration), this.setData({
valueList: this.data.valueList
})));
},
speed: function(t) {
speed: function (t) {
var a = t.currentTarget.dataset.item, i = t.currentTarget.dataset.idx, s = t.currentTarget.dataset.type;
a.isPlay && ("record" == s ? (this.data.audioFile.curDuration = this.data.audioFile.curDuration + this.data.speedStep,
e.seek(this.data.audioFile.curDuration), this.setData({
audioFile: this.data.audioFile
})) : (this.data.valueList[i].value.curDuration = this.data.valueList[i].value.curDuration + this.data.speedStep,
e.seek(this.data.valueList[i].value.curDuration), this.setData({
valueList: this.data.valueList
})));
e.seek(this.data.audioFile.curDuration), this.setData({
audioFile: this.data.audioFile
})) : (this.data.valueList[i].value.curDuration = this.data.valueList[i].value.curDuration + this.data.speedStep,
e.seek(this.data.valueList[i].value.curDuration), this.setData({
valueList: this.data.valueList
})));
},
onUnload: function() {
onUnload: function () {
i.setLocation(null), this.setData({
map: null
});

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
var t = require("../../../@babel/runtime/helpers/defineProperty"), e = getApp();
var e = getApp();
Page({
data: {

View File

@ -1,159 +1,164 @@
var e = require("../../@babel/runtime/helpers/defineProperty"), a = getApp();
var a = getApp();
Page({
data: {
token: a.globalData.token,
sourceUrl: a.baseUrls.sourceUrl,
areaList: [],
areaIndex: 0,
areaAll: [],
areaSelected: "",
areaName: "",
communityList: [],
myCommunityList: [],
page: {
rows: 10,
page: 1,
areaCode: ""
}
},
getAreaList: function() {
var t = this;
a.restAjax.get(a.restAjax.path(a.apis.getArea, [ a.baseUrls.serviceUrl, "110889" ]), {}, {
headers: {
token: a.globalData.token
}
}, function(a, r) {
for (var n = t.data.areaList, o = 0; o < r.length; o++) n.push(r[o].areaName);
t.setData(e({
areaList: n,
areaAll: r,
areaSelected: r[0].areaCode,
areaName: r[0].areaName
}, "page.areaCode", r[0].areaCode)), t.getCommunity();
}, function(e, a) {
console.log(a);
data: {
token: a.globalData.token,
sourceUrl: a.baseUrls.sourceUrl,
areaList: [],
areaIndex: 0,
areaAll: [],
areaSelected: "",
areaName: "",
communityList: [],
myCommunityList: [],
page: {
rows: 10,
page: 1,
areaCode: ""
}
},
getAreaList: function () {
var t = this;
a.restAjax.get(a.restAjax.path(a.apis.getArea, [a.baseUrls.serviceUrl, "110889"]), {}, {
headers: {
token: a.globalData.token
}
}, function (a, r) {
for (var n = t.data.areaList, o = 0; o < r.length; o++) {
n.push(r[o].areaName)
}
t.setData({
areaList: n,
areaAll: r,
areaSelected: r[0].areaCode,
areaName: r[0].areaName,
"page.areaCode": r[0].areaCode
});
t.getCommunity();
}, function (e, a) {
console.log(a);
});
},
getCommunity: function () {
var t = this, r = t.data.page;
t.data.keywords && (r.keywords = t.data.keywords), a.restAjax.get(a.restAjax.path(a.apis.getCommunityListPage, [a.baseUrls.communityUrl]), r, {
headers: {
token: a.globalData.token
}
}, function (a, r) {
if (1 == t.data.page.page) t.setData({
communityList: r.rows
}); else if (r.rows.length > 0) {
for (var n = t.data.communityList, o = 0; o < r.rows.length; o++) n.push(r.rows[o]);
t.setData({
communityList: n
});
},
getCommunity: function() {
var t = this, r = t.data.page;
t.data.keywords && (r.keywords = t.data.keywords), a.restAjax.get(a.restAjax.path(a.apis.getCommunityListPage, [ a.baseUrls.communityUrl ]), r, {
headers: {
token: a.globalData.token
}
}, function(a, r) {
if (1 == t.data.page.page) t.setData({
communityList: r.rows
}); else if (r.rows.length > 0) {
for (var n = t.data.communityList, o = 0; o < r.rows.length; o++) n.push(r.rows[o]);
t.setData({
communityList: n
});
} else t.setData(e({}, "page.page", t.data.page.page - 1));
r.rows.length < 10 && t.setData({
haveMore: !1
});
}, function(e, a) {
console.log(a);
});
},
bindAreaPickerChange: function(a) {
var t;
this.setData((t = {
areaIndex: a.detail.value,
areaSelected: this.data.areaAll[a.detail.value].areaCode
}, e(t, "page.areaCode", this.data.areaAll[a.detail.value].areaCode), e(t, "page.page", 1),
e(t, "haveMore", !0), t)), this.getCommunity();
},
getMyCommunity: function() {
var e = this;
a.restAjax.get(a.restAjax.path(a.apis.mycommunity, [ a.baseUrls.requestUrl ]), {}, {
headers: {
token: a.globalData.token
}
}, function(a, t) {
e.setData({
myCommunityList: t
});
}, function(e, a) {
console.log(a);
});
},
otherCommunity: function() {
wx.navigateTo({
url: "./selectCommunity"
});
},
selectCommunity: function(e) {
var t = {
communityId: e.currentTarget.dataset.item.communityId,
communityName: e.currentTarget.dataset.item.communityName
};
a.globalData.currentCommunity = t, wx.setStorage({
data: e.currentTarget.dataset.item.communityName,
key: "curCommunityName"
}), wx.setStorage({
data: e.currentTarget.dataset.item.communityId,
key: "curCommunityId"
}), wx.setStorage({
data: e.currentTarget.dataset.item.locationCode,
key: "areaCode"
}), wx.setStorage({
data: parseInt(e.currentTarget.dataset.item.areaLevel),
key: "areaLevel"
}), wx.reLaunch({
url: "../index/index"
});
},
selectMyCommunity: function(e) {
var t = {
communityId: e.currentTarget.dataset.item.communityId,
communityName: e.currentTarget.dataset.item.communityName
};
a.globalData.currentCommunity = t, wx.setStorage({
data: e.currentTarget.dataset.item.communityName,
key: "curCommunityName"
}), wx.setStorage({
data: e.currentTarget.dataset.item.communityId,
key: "curCommunityId"
}), wx.setStorage({
data: e.currentTarget.dataset.item.areaCode,
key: "areaCode"
}), wx.setStorage({
data: "4",
key: "areaLevel"
}), wx.reLaunch({
url: "../index/index"
});
},
loadMore: function() {
this.setData(e({}, "page.page", this.data.page.page + 1)), this.getCommunity();
},
enterCurrentArea: function() {
wx.setStorage({
data: this.data.areaAll[this.data.areaIndex].areaName,
key: "curCommunityName"
}), wx.setStorage({
data: this.data.areaAll[this.data.areaIndex].areaId,
key: "curCommunityId"
}), wx.setStorage({
data: this.data.page.areaCode,
key: "areaCode"
}), wx.setStorage({
data: parseInt(this.data.areaAll[this.data.areaIndex].areaLevel),
key: "areaLevel"
}), wx.reLaunch({
url: "../index/index"
});
},
onLoad: function(e) {
this.getAreaList(), this.getMyCommunity();
},
onReady: function() {},
onShow: function() {},
onHide: function() {},
onUnload: function() {},
onPullDownRefresh: function() {},
onReachBottom: function() {},
onShareAppMessage: function() {}
} else t.setData(e({}, "page.page", t.data.page.page - 1));
r.rows.length < 10 && t.setData({
haveMore: !1
});
}, function (e, a) {
console.log(a);
});
},
bindAreaPickerChange: function (a) {
var _self = this;
_self.setData({
areaIndex: a.detail.value,
areaSelected: _self.data.areaAll[a.detail.value].areaCode,
"page.areaCode": _self.data.areaAll[a.detail.value].areaCode,
"page.page": 1,
"haveMore": !0
})
_self.getCommunity();
},
getMyCommunity: function () {
var e = this;
a.restAjax.get(a.restAjax.path(a.apis.mycommunity, [a.baseUrls.requestUrl]), {}, {
headers: {
token: a.globalData.token
}
}, function (a, t) {
e.setData({
myCommunityList: t
});
}, function (e, a) {
console.log(a);
});
},
otherCommunity: function () {
wx.navigateTo({
url: "./selectCommunity"
});
},
selectCommunity: function (e) {
var t = {
communityId: e.currentTarget.dataset.item.communityId,
communityName: e.currentTarget.dataset.item.communityName
};
a.globalData.currentCommunity = t, wx.setStorage({
data: e.currentTarget.dataset.item.communityName,
key: "curCommunityName"
}), wx.setStorage({
data: e.currentTarget.dataset.item.communityId,
key: "curCommunityId"
}), wx.setStorage({
data: e.currentTarget.dataset.item.locationCode,
key: "areaCode"
}), wx.setStorage({
data: parseInt(e.currentTarget.dataset.item.areaLevel),
key: "areaLevel"
}), wx.reLaunch({
url: "../index/index"
});
},
selectMyCommunity: function (e) {
var t = {
communityId: e.currentTarget.dataset.item.communityId,
communityName: e.currentTarget.dataset.item.communityName
};
a.globalData.currentCommunity = t, wx.setStorage({
data: e.currentTarget.dataset.item.communityName,
key: "curCommunityName"
}), wx.setStorage({
data: e.currentTarget.dataset.item.communityId,
key: "curCommunityId"
}), wx.setStorage({
data: e.currentTarget.dataset.item.areaCode,
key: "areaCode"
}), wx.setStorage({
data: "4",
key: "areaLevel"
}), wx.reLaunch({
url: "../index/index"
});
},
loadMore: function () {
this.setData({
"page.page": this.data.page.page + 1
});
this.getCommunity();
},
enterCurrentArea: function () {
wx.setStorage({
data: this.data.areaAll[this.data.areaIndex].areaName,
key: "curCommunityName"
}), wx.setStorage({
data: this.data.areaAll[this.data.areaIndex].areaId,
key: "curCommunityId"
}), wx.setStorage({
data: this.data.page.areaCode,
key: "areaCode"
}), wx.setStorage({
data: parseInt(this.data.areaAll[this.data.areaIndex].areaLevel),
key: "areaLevel"
}), wx.reLaunch({
url: "../index/index"
});
},
onLoad: function (e) {
this.getAreaList();
this.getMyCommunity();
},
});

View File

@ -1,4 +1,4 @@
var e = require("../../@babel/runtime/helpers/defineProperty"), a = getApp();
var a = getApp();
Page({
data: {

View File

@ -105,7 +105,7 @@ Page({
});
},
doLogin: function () {
var _self= this;
var _self = this;
wx.login({
success: function (a) {
t.restAjax.post(t.restAjax.path(t.apis.doLogin, [t.baseUrls.serviceUrl]), {
@ -117,7 +117,7 @@ Page({
token: t.globalData.token,
isBindPhone: 0 == r
}), "" != _self.data.cardId && null != _self.data.cardId ? (console.log(_self.data.cardId),
_self.getCard()) : _self.getDefaultCard(), _self.getNotice(), "" != _self.data.cardTemplateDispatchId && null != _self.data.cardTemplateDispatchId) {
_self.getCard()) : _self.getDefaultCard(), _self.getNotice(), "" != _self.data.cardTemplateDispatchId && null != _self.data.cardTemplateDispatchId) {
var s = "/pages/mine/otherCard/othercarddetail?cardTemplateUseId=" + _self.data.cardTemplateDispatchId;
wx.navigateTo({
url: s
@ -243,7 +243,10 @@ Page({
onLoad: function (e) {
e.cardTemplateDispatchId && this.setData({
cardTemplateDispatchId: e.cardTemplateDispatchId
}), this.doLogin(), this.checkPermission(), wx.setStorage({
});
this.doLogin();
this.checkPermission();
wx.setStorage({
data: "1",
key: "gridMiniId"
});

View File

@ -1,4 +1,4 @@
var t = require("../../../@babel/runtime/helpers/defineProperty"), a = getApp();
var a = getApp();
Page({
data: {

View File

@ -1,4 +1,4 @@
var t = require("../../../@babel/runtime/helpers/defineProperty"), e = getApp();
var e = getApp();
Page({
data: {

File diff suppressed because it is too large Load Diff

View File

@ -1,63 +1,63 @@
var e = require("../../../@babel/runtime/helpers/defineProperty"), t = getApp();
var t = getApp();
Page({
data: {
token: t.globalData.token,
helpList: [],
page: {
page: 1,
rows: 10,
communityId: ""
},
haveMore: !0,
serviceUrl: t.baseUrls.serviceUrl,
baseImgUrl: t.baseUrls.baseImgUrl
data: {
token: t.globalData.token,
helpList: [],
page: {
page: 1,
rows: 10,
communityId: ""
},
getHelpList: function() {
var a = this;
t.restAjax.get(t.restAjax.path(t.apis.getHelpList, [ t.baseUrls.requestUrl ]), a.data.page, {
headers: {
token: t.globalData.token
}
}, function(t, o) {
for (var s = 0; s < o.rows.length; s++) o.rows[s].photo && (o.rows[s].photo = o.rows[s].photo.split(","));
if (1 == a.data.page.page) a.setData({
helpList: o.rows
}); else if (o.rows.length > 0) {
for (var n = a.data.helpList, r = 0; r < o.rows.length; r++) n.push(o.rows[r]);
a.setData({
helpList: n
});
} else wx.showToast({
title: "暂无更多",
icon: "none"
}), a.setData(e({}, "page.page", a.data.page.page - 1));
o.rows.length < 10 && a.setData({
haveMore: !1
});
}, function(e, t) {
console.log(t);
haveMore: !0,
serviceUrl: t.baseUrls.serviceUrl,
baseImgUrl: t.baseUrls.baseImgUrl
},
getHelpList: function () {
var a = this;
t.restAjax.get(t.restAjax.path(t.apis.getHelpList, [t.baseUrls.requestUrl]), a.data.page, {
headers: {
token: t.globalData.token
}
}, function (t, o) {
for (var s = 0; s < o.rows.length; s++) o.rows[s].photo && (o.rows[s].photo = o.rows[s].photo.split(","));
if (1 == a.data.page.page) a.setData({
helpList: o.rows
}); else if (o.rows.length > 0) {
for (var n = a.data.helpList, r = 0; r < o.rows.length; r++) n.push(o.rows[r]);
a.setData({
helpList: n
});
},
checkHelpDetail: function(e) {
var t = e.currentTarget.dataset.id;
wx.navigateTo({
url: "./helpDetail?neighborId=" + t
});
},
loadMore: function() {
this.setData(e({}, "page.page", this.data.page.page + 1)), this.getHelpList();
},
onLoad: function(a) {
var o;
this.setData((e(o = {}, "page.communityId", a.communityId), e(o, "token", t.globalData.token),
o)), this.getHelpList();
},
onReady: function() {},
onShow: function() {},
onHide: function() {},
onUnload: function() {},
onPullDownRefresh: function() {},
onReachBottom: function() {},
onShareAppMessage: function() {}
} else wx.showToast({
title: "暂无更多",
icon: "none"
}), a.setData(e({}, "page.page", a.data.page.page - 1));
o.rows.length < 10 && a.setData({
haveMore: !1
});
}, function (e, t) {
console.log(t);
});
},
checkHelpDetail: function (e) {
var t = e.currentTarget.dataset.id;
wx.navigateTo({
url: "./helpDetail?neighborId=" + t
});
},
loadMore: function () {
this.setData(e({}, "page.page", this.data.page.page + 1)), this.getHelpList();
},
onLoad: function (a) {
var o;
this.setData((e(o = {}, "page.communityId", a.communityId), e(o, "token", t.globalData.token),
o)), this.getHelpList();
},
onReady: function () { },
onShow: function () { },
onHide: function () { },
onUnload: function () { },
onPullDownRefresh: function () { },
onReachBottom: function () { },
onShareAppMessage: function () { }
});

View File

@ -1,4 +1,4 @@
var t = require("../../@babel/runtime/helpers/defineProperty"), e = getApp();
var e = getApp();
Page({
data: {

View File

@ -1,4 +1,4 @@
var e = require("../../@babel/runtime/helpers/defineProperty"), t = getApp();
var t = getApp();
Page({
data: {
@ -16,71 +16,86 @@ Page({
serviceUrl: t.baseUrls.serviceUrl,
baseImgUrl: t.baseUrls.baseImgUrl
},
getNewsType: function() {
getNewsType: function () {
var a = this;
t.restAjax.get(t.restAjax.path(t.apis.getNewsType, [ t.baseUrls.requestUrl ]), {
t.restAjax.get(t.restAjax.path(t.apis.getNewsType, [t.baseUrls.requestUrl]), {
showArea: "6dcbb862-4b48-4dca-aee1-d78fd76adc05"
}, {
headers: {
token: a.data.token
}
}, function(t, s) {
}, function (t, s) {
var n;
a.setData((e(n = {
newsType: s
}, "page.newsTypeId", s[0].newsTypeId), e(n, "curType", s[0].newsTypeId), n)), a.getNewsList();
}, function(e, t) {
a.setData({
newsType: s,
"page.newsTypeId": s[0].newsTypeId,
"curType": s[0].newsTypeId
});
a.getNewsList();
}, function (e, t) {
console.log(t);
});
},
changeType: function(t) {
changeType: function (t) {
var a, s = t.currentTarget.dataset.id;
this.setData((e(a = {
curType: s
}, "page.newsTypeId", s), e(a, "page.page", 1), a)), this.getNewsList();
this.setData({
curType: s,
"page.newsTypeId": s,
"page.page": 1,
});
this.getNewsList();
},
getNewsList: function() {
getNewsList: function () {
var a = this;
t.restAjax.get(t.restAjax.path(t.apis.getNewsList, [ t.baseUrls.requestUrl ]), a.data.page, {
t.restAjax.get(t.restAjax.path(t.apis.getNewsList, [t.baseUrls.requestUrl]), a.data.page, {
headers: {
token: a.data.token
}
}, function(t, s) {
for (var n = 0; n < s.rows.length; n++) s.rows[n].photo && (s.rows[n].photo = s.rows[n].photo.split(","));
if (1 == a.data.page.page) a.setData({
newsList: s.rows
}); else if (s.rows.length > 0) {
}, function (t, s) {
for (var n = 0; n < s.rows.length; n++) {
s.rows[n].photo && (s.rows[n].photo = s.rows[n].photo.split(","));
}
if(1==a.data.page.page){
a.setData({
newsList:s.rows
})
}else if(s.rows.length>0){
for (var o = a.data.newsList, r = 0; r < s.rows.length; r++) o.push(s.rows[r]);
a.setData({
newsList: o
});
} else wx.showToast({
title: "暂无更多",
icon: "none"
}), a.setData(e({}, "page.page", a.data.page.page - 1));
}, function(e, t) {
}else{
wx.showToast({
title: '暂无更多',
icon:'none'
})
a.setData({
"page.page":a.data.page.page-1
})
}
}, function (e, t) {
console.log(t);
});
},
checkDetail: function(e) {
checkDetail: function (e) {
var t = e.currentTarget.dataset.id;
wx.navigateTo({
url: "./newsDetail?newsId=" + t
});
},
onLoad: function(a) {
this.setData(e({
token: t.globalData.token
}, "page.areaCode", wx.getStorageSync("areaCode") ? wx.getStorageSync("areaCode") : "")),
onLoad: function (a) {
this.setData({
token: t.globalData.token,
"page.areaCode": wx.getStorageSync("areaCode") ? wx.getStorageSync("areaCode") : ""
})
this.getNewsType();
},
onReady: function() {},
onShow: function() {},
onHide: function() {},
onUnload: function() {},
onPullDownRefresh: function() {},
onReachBottom: function() {
this.setData(e({}, "page.page", this.data.page.page + 1)), this.getNewsList();
onReachBottom: function () {
this.setData({
"page.page": this.data.page.page + 1,
});
this.getNewsList();
},
onShareAppMessage: function() {}
});

View File

@ -21,5 +21,5 @@
"van-collapse": "/vant/dist/collapse/index",
"van-collapse-item": "/vant/dist/collapse-item/index"
},
"navigationBarTitleText": "事件上报"
"navigationBarTitleText": "述求上报"
}

View File

@ -1,83 +1,89 @@
var e = require("../../@babel/runtime/helpers/defineProperty"), t = getApp();
var t = getApp();
Page({
data: {
token: t.globalData.token,
newsType: [],
curType: "",
page: {
page: 1,
rows: 10,
newsTypeId: ""
},
newsList: [],
serviceUrl: t.baseUrls.serviceUrl,
baseImgUrl: t.baseUrls.baseImgUrl
data: {
token: t.globalData.token,
newsType: [],
curType: "",
page: {
page: 1,
rows: 10,
newsTypeId: ""
},
getNewsType: function() {
var a = this;
t.restAjax.get(t.restAjax.path(t.apis.getNewsType, [ t.baseUrls.requestUrl ]), {
showArea: "6dcbb862-4b48-4dca-aee1-d78fd76adc05"
}, {
headers: {
token: a.data.token
}
}, function(t, s) {
var n;
a.setData((e(n = {
newsType: s
}, "page.newsTypeId", s[0].newsTypeId), e(n, "curType", s[0].newsTypeId), n)), a.getNewsList();
}, function(e, t) {
console.log(t);
newsList: [],
serviceUrl: t.baseUrls.serviceUrl,
baseImgUrl: t.baseUrls.baseImgUrl
},
getNewsType: function () {
var a = this;
t.restAjax.get(t.restAjax.path(t.apis.getNewsType, [t.baseUrls.requestUrl]), {
showArea: "6dcbb862-4b48-4dca-aee1-d78fd76adc05"
}, {
headers: {
token: a.data.token
}
}, function (t, s) {
var n;
a.setData({
newsType: s,
"page.newsTypeId": s[0].newsTypeId,
"curType": s[0].newsTypeId
});
a.getNewsList();
}, function (e, t) {
console.log(t);
});
},
changeType: function (t) {
var a, s = t.currentTarget.dataset.id;
this.setData({
curType: s,
"page.newsTypeId": s,
"page.page": 1
});
this.getNewsList();
},
getNewsList: function () {
var a = this;
t.restAjax.get(t.restAjax.path(t.apis.getNewsList, [t.baseUrls.requestUrl]), a.data.page, {
headers: {
token: a.data.token
}
}, function (t, s) {
for (var n = 0; n < s.rows.length; n++) s.rows[n].photo && (s.rows[n].photo = s.rows[n].photo.split(","));
if (1 == a.data.page.page) a.setData({
newsList: s.rows
}); else if (s.rows.length > 0) {
for (var o = a.data.newsList, r = 0; r < s.rows.length; r++) o.push(s.rows[r]);
a.setData({
newsList: o
});
},
changeType: function(t) {
var a, s = t.currentTarget.dataset.id;
this.setData((e(a = {
curType: s
}, "page.newsTypeId", s), e(a, "page.page", 1), a)), this.getNewsList();
},
getNewsList: function() {
var a = this;
t.restAjax.get(t.restAjax.path(t.apis.getNewsList, [ t.baseUrls.requestUrl ]), a.data.page, {
headers: {
token: a.data.token
}
}, function(t, s) {
for (var n = 0; n < s.rows.length; n++) s.rows[n].photo && (s.rows[n].photo = s.rows[n].photo.split(","));
if (1 == a.data.page.page) a.setData({
newsList: s.rows
}); else if (s.rows.length > 0) {
for (var o = a.data.newsList, r = 0; r < s.rows.length; r++) o.push(s.rows[r]);
a.setData({
newsList: o
});
} else wx.showToast({
title: "暂无更多",
icon: "none"
}), a.setData(e({}, "page.page", a.data.page.page - 1));
}, function(e, t) {
console.log(t);
});
},
checkDetail: function(e) {
var t = e.currentTarget.dataset.id;
wx.navigateTo({
url: "../news/newsDetail?newsId=" + t
});
},
onLoad: function(e) {
this.setData({
token: t.globalData.token
}), this.getNewsType();
},
onReady: function() {},
onShow: function() {},
onHide: function() {},
onUnload: function() {},
onPullDownRefresh: function() {},
onReachBottom: function() {
this.setData(e({}, "page.page", this.data.page.page + 1)), this.getNewsList();
},
onShareAppMessage: function() {}
} else wx.showToast({
title: "暂无更多",
icon: "none"
}), a.setData(e({}, "page.page", a.data.page.page - 1));
}, function (e, t) {
console.log(t);
});
},
checkDetail: function (e) {
var t = e.currentTarget.dataset.id;
wx.navigateTo({
url: "../news/newsDetail?newsId=" + t
});
},
onLoad: function (e) {
this.setData({
token: t.globalData.token
}), this.getNewsType();
},
onReady: function () { },
onShow: function () { },
onHide: function () { },
onUnload: function () { },
onPullDownRefresh: function () { },
onReachBottom: function () {
this.setData(e({}, "page.page", this.data.page.page + 1)), this.getNewsList();
},
onShareAppMessage: function () { }
});

View File

@ -1,94 +1,94 @@
var e = require("../../@babel/runtime/helpers/defineProperty"), t = getApp();
var t = getApp();
Page({
data: {
token: t.globalData.token,
sourceUrl: t.baseUrls.sourceUrl,
page: {
page: 1,
rows: 5
},
talkList: [],
serviceUrl: t.baseUrls.serviceUrl,
baseImgUrl: t.baseUrls.baseImgUrl,
data: {
token: t.globalData.token,
sourceUrl: t.baseUrls.sourceUrl,
page: {
page: 1,
rows: 5
},
talkList: [],
serviceUrl: t.baseUrls.serviceUrl,
baseImgUrl: t.baseUrls.baseImgUrl,
isShowMenu: !1
},
getTalkList: function () {
var a = this;
t.restAjax.get(t.restAjax.path(t.apis.getTalkList, [t.baseUrls.requestUrl]), {
pages: a.data.page,
areaCode: wx.getStorageSync("areaCode")
}, {
headers: {
token: t.globalData.token
}
}, function (t, o) {
if (o.rows.length > 0) {
for (var s = 0; s < o.rows.length; s++) o.rows[s].photo && (o.rows[s].photo = o.rows[s].photo.split(","));
if (1 == a.data.page.page) a.setData({
talkList: o.rows
}); else {
for (var n = a.data.talkList, l = 0; l < o.rows.length; l++) n.push(o.rows[l]);
a.setData({
talkList: n
});
}
} else wx.showToast({
title: "暂无更多",
icon: "none"
}), a.data.page.page > 1 && a.setData(e({}, "page.page", a.data.page.page - 1));
}, function (e, t) {
console.log(t);
});
},
newTalk: function () {
wx.navigateTo({
url: "./newTalk"
});
},
checkMyTalk: function () {
wx.navigateTo({
url: "./myTalk"
});
},
checkDetail: function (e) {
var t = e.currentTarget.dataset.id;
wx.navigateTo({
url: "./talkDetail?trifleMyselfId=" + t
});
},
clickVideo: function () { },
onLoad: function (e) { },
getMenuIsShow: function () {
var e = this;
t.restAjax.get(t.restAjax.path(t.apis.getBtnIsShow, [t.baseUrls.requestUrl, "talk"]), null, {
headers: {
token: t.globalData.token
}
}, function (t, a) {
null != a && null != a ? e.setData({
isShowMenu: 1 == a.isShow
}) : e.setData({
isShowMenu: !1
},
getTalkList: function() {
var a = this;
t.restAjax.get(t.restAjax.path(t.apis.getTalkList, [ t.baseUrls.requestUrl ]), {
pages: a.data.page,
areaCode: wx.getStorageSync("areaCode")
}, {
headers: {
token: t.globalData.token
}
}, function(t, o) {
if (o.rows.length > 0) {
for (var s = 0; s < o.rows.length; s++) o.rows[s].photo && (o.rows[s].photo = o.rows[s].photo.split(","));
if (1 == a.data.page.page) a.setData({
talkList: o.rows
}); else {
for (var n = a.data.talkList, l = 0; l < o.rows.length; l++) n.push(o.rows[l]);
a.setData({
talkList: n
});
}
} else wx.showToast({
title: "暂无更多",
icon: "none"
}), a.data.page.page > 1 && a.setData(e({}, "page.page", a.data.page.page - 1));
}, function(e, t) {
console.log(t);
});
},
newTalk: function() {
wx.navigateTo({
url: "./newTalk"
});
},
checkMyTalk: function() {
wx.navigateTo({
url: "./myTalk"
});
},
checkDetail: function(e) {
var t = e.currentTarget.dataset.id;
wx.navigateTo({
url: "./talkDetail?trifleMyselfId=" + t
});
},
clickVideo: function() {},
onLoad: function(e) {},
getMenuIsShow: function() {
var e = this;
t.restAjax.get(t.restAjax.path(t.apis.getBtnIsShow, [ t.baseUrls.requestUrl, "talk" ]), null, {
headers: {
token: t.globalData.token
}
}, function(t, a) {
null != a && null != a ? e.setData({
isShowMenu: 1 == a.isShow
}) : e.setData({
isShowMenu: !1
});
}, function(t, a) {
e.setData({
isShowMenu: !1
});
});
},
onReady: function() {},
onShow: function() {
this.setData({
token: t.globalData.token
}), this.getTalkList(), this.getMenuIsShow();
},
onHide: function() {},
onUnload: function() {},
onPullDownRefresh: function() {},
onReachBottom: function() {
var t = this.data.page.page + 1;
this.setData(e({}, "page.page", t)), this.getTalkList();
},
onShareAppMessage: function() {}
});
}, function (t, a) {
e.setData({
isShowMenu: !1
});
});
},
onReady: function () { },
onShow: function () {
this.setData({
token: t.globalData.token
}), this.getTalkList(), this.getMenuIsShow();
},
onHide: function () { },
onUnload: function () { },
onPullDownRefresh: function () { },
onReachBottom: function () {
var t = this.data.page.page + 1;
this.setData(e({}, "page.page", t)), this.getTalkList();
},
onShareAppMessage: function () { }
});

View File

@ -1,29 +1,30 @@
{
"appid": "wxa5e5552f8a3b1616",
"compileType": "miniprogram",
"libVersion": "2.31.1",
"packOptions": {
"ignore": [],
"include": []
},
"setting": {
"coverView": true,
"es6": true,
"postcss": true,
"minified": true,
"enhance": true,
"showShadowRootInWxmlPanel": true,
"packNpmRelationList": [],
"babelSetting": {
"ignore": [],
"disablePlugins": [],
"outputPath": ""
"compileType": "miniprogram",
"setting": {
"coverView": true,
"es6": true,
"postcss": true,
"minified": true,
"enhance": true,
"showShadowRootInWxmlPanel": true,
"packNpmRelationList": [],
"babelSetting": {
"ignore": [],
"disablePlugins": [],
"outputPath": ""
},
"condition": false,
"ignoreUploadUnusedFiles": true
},
"condition": false
},
"condition": {},
"editorSetting": {
"tabIndent": "insertSpaces",
"tabSize": 2
}
"condition": {},
"editorSetting": {
"tabIndent": "insertSpaces",
"tabSize": 4
},
"libVersion": "2.31.1",
"packOptions": {
"ignore": [],
"include": []
},
"appid": "wxa5e5552f8a3b1616"
}

View File

@ -1,8 +1,8 @@
{
"description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
"projectname": "city_card",
"setting": {
"compileHotReLoad": true,
"urlCheck": false
}
"description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
"projectname": "city_card",
"setting": {
"compileHotReLoad": true,
"urlCheck": false
}
}

View File

@ -6,7 +6,9 @@ var baseUrls = {
caseUrl: "https://www.wlcbsyzl.cn/case/",
sourceUrl: "https://www.wlcbsyzl.cn/systemmunicipalmini/assets/weCharMiniFile/images/",
baseCardUrl: "https://www.wlcbsyzl.cn/citycard/route/file/download/true/",
// baseCardUrl: "http://192.168.0.115:8089/citycard/route/file/download/true/",
url: "https://www.wlcbsyzl.cn/citycard/"
// url: "http://192.168.0.115:8089/citycard/"
}

View File

@ -266,6 +266,7 @@ function upload(url, params) {
}
},
fail: function (response) {
console.log(response)
wx.hideLoading({})
try {
if (typeof (response.data.msg) != undefined) {

1117
vant/dist/cropper/image-cropper.js vendored Executable file

File diff suppressed because it is too large Load Diff

3
vant/dist/cropper/image-cropper.json vendored Executable file
View File

@ -0,0 +1,3 @@
{
"component": true
}

24
vant/dist/cropper/image-cropper.wxml vendored Executable file
View File

@ -0,0 +1,24 @@
<view class='image-cropper' catchtouchmove='_preventTouchMove'>
<view class='main' bindtouchend="_cutTouchEnd" bindtouchstart="_cutTouchStart" bindtouchmove="_cutTouchMove" bindtap="_click">
<view class='content'>
<view class='content_top bg_gray {{_flag_bright?"":"bg_black"}}' style="height:{{cut_top}}px;transition-property:{{_cut_animation?'':'background'}}"></view>
<view class='content_middle' style="height:{{height}}px;">
<view class='content_middle_left bg_gray {{_flag_bright?"":"bg_black"}}' style="width:{{cut_left}}px;transition-property:{{_cut_animation?'':'background'}}"></view>
<view class='content_middle_middle' style="width:{{width}}px;height:{{height}}px;transition-duration: .3s;transition-property:{{_cut_animation?'':'background'}};">
<view class="border border-top-left"></view>
<view class="border border-top-right"></view>
<view class="border border-right-top"></view>
<view class="border border-right-bottom"></view>
<view class="border border-bottom-right"></view>
<view class="border border-bottom-left"></view>
<view class="border border-left-bottom"></view>
<view class="border border-left-top"></view>
</view>
<view class='content_middle_right bg_gray {{_flag_bright?"":"bg_black"}}' style="transition-property:{{_cut_animation?'':'background'}}"></view>
</view>
<view class='content_bottom bg_gray {{_flag_bright?"":"bg_black"}}' style="transition-property:{{_cut_animation?'':'background'}}"></view>
</view>
<image bindload="imageLoad" bindtouchstart="_start" bindtouchmove="_move" bindtouchend="_end" style="width:{{img_width ? img_width + 'px' : 'auto'}};height:{{img_height ? img_height + 'px' : 'auto'}};transform:translate3d({{_img_left-img_width/2}}px,{{_img_top-img_height/2}}px,0) scale({{scale}}) rotate({{angle}}deg);transition-duration:{{_cut_animation?.4:0}}s;" class='img' src='{{imgSrc}}'></image>
</view>
<canvas canvas-id='image-cropper' disable-scroll="true" style="width:{{_canvas_width * export_scale}}px;height:{{_canvas_height * export_scale}}px;left:{{canvas_left}}px;top:{{canvas_top}}px" class='image-cropper-canvas'></canvas>
</view>

143
vant/dist/cropper/image-cropper.wxss vendored Executable file
View File

@ -0,0 +1,143 @@
.image-cropper {
background: rgba(14, 13, 13, .8);
position: fixed;
top: 0;
left: 0;
width: 100vw;
height: 100vh;
z-index: 1;
}
.image-cropper .main {
position: absolute;
width: 100vw;
height: 100vh;
overflow: hidden;
}
.image-cropper .content {
z-index: 9;
position: absolute;
width: 100vw;
height: 100vh;
display: flex;
flex-direction: column;
pointer-events: none;
}
.image-cropper .bg_black {
background: rgba(0, 0, 0, 0.8) !important;
}
.image-cropper .bg_gray {
background: rgba(0, 0, 0, 0.45);
transition-duration: .35s;
}
.image-cropper .content>.content_top {
pointer-events: none;
}
.image-cropper .content>.content_middle {
display: flex;
height: 200px;
width: 100%;
}
.image-cropper .content_middle_middle {
width: 200px;
box-sizing: border-box;
position: relative;
transition-duration: .3s;
}
.image-cropper .content_middle_right {
flex: auto;
}
.image-cropper .content>.content_bottom {
flex: auto;
}
.image-cropper .img {
z-index: 2;
top: 0;
left: 0;
position: absolute;
border: none;
width: 100%;
backface-visibility: hidden;
transform-origin: center;
}
.image-cropper .image-cropper-canvas {
position: fixed;
background: white;
width: 150px;
height: 150px;
z-index: 10;
top: -200%;
pointer-events: none;
}
.image-cropper .border {
background: white;
pointer-events: auto;
position: absolute;
}
.image-cropper .border-top-left {
left: -2.5px;
top: -2.5px;
height: 2.5px;
width: 33rpx;
}
.image-cropper .border-top-right {
right: -2.5px;
top: -2.5px;
height: 2.5px;
width: 33rpx;
}
.image-cropper .border-right-top {
top: -1px;
width: 2.5px;
height: 30rpx;
right: -2.5px;
}
.image-cropper .border-right-bottom {
width: 2.5px;
height: 30rpx;
right: -2.5px;
bottom: -1px;
}
.image-cropper .border-bottom-left {
height: 2.5px;
width: 33rpx;
bottom: -2.5px;
left: -2.5px;
}
.image-cropper .border-bottom-right {
height: 2.5px;
width: 33rpx;
bottom: -2.5px;
right: -2.5px;
}
.image-cropper .border-left-top {
top: -1px;
width: 2.5px;
height: 30rpx;
left: -2.5px;
}
.image-cropper .border-left-bottom {
width: 2.5px;
height: 30rpx;
left: -2.5px;
bottom: -1px;
}

View File

@ -1,381 +0,0 @@
const defaultData = {
isShowCropper:false,
// 初始化的宽高
cropperInitW: 750,
cropperInitH: 750,
// 动态的宽高
cropperW: 750,
cropperH: 750,
// 动态的left top值
cropperL: 0,
cropperT: 0,
transL: 0,
transT: 0,
// 图片缩放值
scaleP: 0,
imageW: 0,
imageH: 0,
// 裁剪框 宽高
cutL: 0,
cutT: 0,
cutB: 0,
cutR: 0,
qualityWidth: '',
innerAspectRadio: 750 / wx.getSystemInfoSync().windowWidth,
C_CONSTANTS:{
SCREEN_WIDTH : 750,
PAGE_X:0, // 手按下的x位置
PAGE_Y:0, // 手按下y的位置
PR : wx.getSystemInfoSync().pixelRatio, // dpi
T_PAGE_X:{}, // 手移动的时候x的位置
T_PAGE_Y:{}, // 手移动的时候Y的位置
CUT_L:0, // 初始化拖拽元素的left值
CUT_T:0, // 初始化拖拽元素的top值
CUT_R:0, // 初始化拖拽元素的
CUT_B:0, // 初始化拖拽元素的
CUT_W:0, // 初始化拖拽元素的宽度
CUT_H:0, // 初始化拖拽元素的高度
IMG_RATIO:0, // 图片比例
IMG_REAL_W:0, // 图片实际的宽度
IMG_REAL_H:0, // 图片实际的高度
IMG_TYPE:'',//图片的格式
DRAFG_MOVE_RATIO : 750 / wx.getSystemInfoSync().windowWidth //移动时候的比例
}
};
let data = {};
try{
data = JSON.parse(JSON.stringify(defaultData));
}catch(e){console.log(e)};
Component({
properties: {
imageSrc:{
type:String,
value:'',
observer(newVal, oldVal) {
if(newVal !== oldVal){
this.setData({
isShowCropper:true
},() => {
this.loadImage();
})
}
}
},
isCircleCrop:{
type:Boolean,
value:false
},
enableScale:{
type:Boolean,
value:false
},
ratio:{
type:Number,
value:1
}
},
data,
ready(){
if(this.data.isCircleCrop){
//圆形裁剪 强制比例为1
this.setData({
ratio:1
})
}
},
methods: {
loadImage() {
let {ratio,imageSrc} = this.data;
let {IMG_REAL_W,IMG_REAL_H,IMG_RATIO,SCREEN_WIDTH,IMG_TYPE} = this.data.C_CONSTANTS;
wx.getImageInfo({
src: imageSrc,
success: res => {
IMG_REAL_W = res.width;
IMG_REAL_H = res.height;
IMG_RATIO = IMG_REAL_W / IMG_REAL_H;
IMG_TYPE = res.type === 'png' ? 'png' : 'jpg';
// 根据图片的宽高显示不同的效果 保证图片可以正常显示
let temp = {};
let cropperData = {};
if (IMG_RATIO >= 1) {
cropperData = {
cropperW: SCREEN_WIDTH,
cropperH: SCREEN_WIDTH / IMG_RATIO,
// 初始化left right
cropperL: Math.ceil((SCREEN_WIDTH - SCREEN_WIDTH) / 2),
cropperT: Math.ceil((SCREEN_WIDTH - SCREEN_WIDTH / IMG_RATIO) / 2)
}
if(ratio > 1){
temp = {
cutL: (SCREEN_WIDTH - SCREEN_WIDTH / IMG_RATIO) / 2,
cutT: (SCREEN_WIDTH / IMG_RATIO - SCREEN_WIDTH / IMG_RATIO / ratio ) / 2,
cutR: SCREEN_WIDTH - (SCREEN_WIDTH - SCREEN_WIDTH / IMG_RATIO) / 2 - SCREEN_WIDTH / IMG_RATIO,
cutB: SCREEN_WIDTH / IMG_RATIO - (SCREEN_WIDTH / IMG_RATIO - SCREEN_WIDTH / IMG_RATIO / ratio ) / 2 - SCREEN_WIDTH / IMG_RATIO / ratio
}
}else{
temp = {
cutT:0,
cutB:0,
cutL:(SCREEN_WIDTH - SCREEN_WIDTH / IMG_RATIO * ratio) / 2,
cutR: SCREEN_WIDTH - (SCREEN_WIDTH - SCREEN_WIDTH / IMG_RATIO * ratio) / 2 - SCREEN_WIDTH / IMG_RATIO * ratio
}
}
} else {
cropperData = {
cropperW: SCREEN_WIDTH * IMG_RATIO,
cropperH: SCREEN_WIDTH,
// 初始化left right
cropperL: Math.ceil((SCREEN_WIDTH - SCREEN_WIDTH * IMG_RATIO) / 2),
cropperT: Math.ceil((SCREEN_WIDTH - SCREEN_WIDTH) / 2)
}
if(ratio > 1){
temp = {
cutL:0,
cutR:0,
cutT: (SCREEN_WIDTH - SCREEN_WIDTH * IMG_RATIO / ratio) / 2,
cutB: SCREEN_WIDTH - (SCREEN_WIDTH - SCREEN_WIDTH * IMG_RATIO / ratio) / 2 - SCREEN_WIDTH * IMG_RATIO / ratio
}
}else{
temp = {
cutL: (SCREEN_WIDTH * IMG_RATIO - SCREEN_WIDTH * IMG_RATIO * ratio) / 2,
cutR: SCREEN_WIDTH * IMG_RATIO - (SCREEN_WIDTH * IMG_RATIO - SCREEN_WIDTH * IMG_RATIO * ratio) / 2 - SCREEN_WIDTH * IMG_RATIO * ratio,
cutT: (SCREEN_WIDTH - SCREEN_WIDTH * IMG_RATIO) / 2,
cutB: SCREEN_WIDTH - (SCREEN_WIDTH - SCREEN_WIDTH * IMG_RATIO) / 2 - SCREEN_WIDTH * IMG_RATIO
}
}
}
this.setData({
C_CONSTANTS:Object.assign({},this.data.C_CONSTANTS,{
IMG_REAL_W,
IMG_REAL_H,
IMG_RATIO,
IMG_TYPE
}),
isShowCropper: true,
// 图片缩放值
scaleP: IMG_REAL_W / SCREEN_WIDTH,
qualityWidth: IMG_REAL_W,
innerAspectRadio: IMG_RATIO,
...temp,
...cropperData
})
}
});
},
contentStartMove(e) {
this.setData({
'C_CONSTANTS.PAGE_X':e.touches[0].pageX,
'C_CONSTANTS.PAGE_Y':e.touches[0].pageY
})
},
// 拖动时候触发的touchMove事件
contentMoveing(e) {
let {PAGE_X,PAGE_Y,DRAFG_MOVE_RATIO} = this.data.C_CONSTANTS;
let {cutL,cutR,cutT,cutB} = this.data;
let dragLengthX = (PAGE_X - e.touches[0].pageX) * DRAFG_MOVE_RATIO
let dragLengthY = (PAGE_Y - e.touches[0].pageY) * DRAFG_MOVE_RATIO
// 左移
if (dragLengthX > 0) {
if (cutL - dragLengthX < 0) dragLengthX = cutL
} else {
if (cutR + dragLengthX < 0) dragLengthX = -cutR
}
if (dragLengthY > 0) {
if (cutT - dragLengthY < 0) dragLengthY = cutT
} else {
if (cutB + dragLengthY < 0) dragLengthY = -cutB
}
this.setData({
cutL: cutL - dragLengthX,
cutT: cutT - dragLengthY,
cutR: cutR + dragLengthX,
cutB: cutB + dragLengthY,
'C_CONSTANTS.PAGE_X':e.touches[0].pageX,
'C_CONSTANTS.PAGE_Y':e.touches[0].pageY
});
},
// 设置大小的时候触发的touchStart事件
dragStart(e) {
let {cutL,cutR,cutT,cutB} = this.data;
this.setData({
C_CONSTANTS:Object.assign({},this.data.C_CONSTANTS,{
T_PAGE_X : e.touches[0].pageX,
T_PAGE_Y : e.touches[0].pageY,
CUT_L : cutL,
CUT_R : cutR,
CUT_B : cutB,
CUT_T : cutT
})
})
},
// 设置大小的时候触发的touchMove事件
dragMove(e) {
let dragType = e.target.dataset.drag
let {ratio,cropperW,cropperH,cutL,cutT,cutR,cutB,enableScale} = this.data;
let {CUT_R,CUT_L,CUT_T,CUT_B,T_PAGE_X,T_PAGE_Y,DRAFG_MOVE_RATIO} = this.data.C_CONSTANTS;
let dragLength;
switch (dragType) {
case 'right':
dragLength = (T_PAGE_X - e.touches[0].pageX) * DRAFG_MOVE_RATIO
if (CUT_R + dragLength < 0) dragLength = -CUT_R
cutR = CUT_R + dragLength;
if(enableScale){
cutT = CUT_T + dragLength / ratio;
}
if(cutR < 0 || cutT < 0 || cutT > cropperH || cutR > cropperW) return;
break;
case 'left':
dragLength = (T_PAGE_X - e.touches[0].pageX) * DRAFG_MOVE_RATIO
if (CUT_L - dragLength < 0) dragLength = CUT_L
if ((CUT_L - dragLength) > (this.data.cropperW - this.data.cutR)) dragLength = CUT_L - (this.data.cropperW - this.data.cutR)
cutL = CUT_L - dragLength;
if(enableScale){
cutT = CUT_T - dragLength / ratio;
}
if(cutL < 0 || cutT < 0 || cutT > cropperH || cutL > cropperW) return;
break;
case 'top':
dragLength = (T_PAGE_Y - e.touches[0].pageY) * DRAFG_MOVE_RATIO
if (CUT_T - dragLength < 0) dragLength = CUT_T
if ((CUT_T - dragLength) > (this.data.cropperH - this.data.cutB)) dragLength = CUT_T - (this.data.cropperH - this.data.cutB)
cutT = CUT_T - dragLength;
if(enableScale){
cutR = CUT_R - dragLength * ratio;
}
break;
case 'bottom':
dragLength = (T_PAGE_Y - e.touches[0].pageY) * DRAFG_MOVE_RATIO
if (CUT_B + dragLength < 0) dragLength = -CUT_B
cutB = CUT_B + dragLength;
if(enableScale){
cutR = CUT_R + dragLength * ratio;
}
if(cutR < 0 || cutT < 0 || cutT > cropperH || cutR > cropperW) return;
break;
default:'';
}
this.setData({
cutL,
cutT,
cutR,
cutB
});
},
contentTouchEnd(){},
// 获取图片
confirmCropper() {
const {isCircleCrop} = this.data;;
if(isCircleCrop){
this.circleCrop()
}else{
this.normalCropper();
}
},
normalCropper(){
let {imageSrc,cropperW,cropperH,cutL,cutT,cutR,cutB} = this.data;
let {IMG_REAL_W,IMG_REAL_H,IMG_TYPE} = this.data.C_CONSTANTS;
// 将图片写入画布
const ctx = wx.createCanvasContext('cropper',this)
ctx.drawImage(imageSrc, 0, 0, IMG_REAL_W, IMG_REAL_H);
ctx.draw(true, () => {
// 获取画布要裁剪的位置和宽度 均为百分比 * 画布中图片的宽度 保证了在微信小程序中裁剪的图片模糊 位置不对的问题 canvasT = (_this.data.cutT / _this.data.cropperH) * (_this.data.imageH / pixelRatio)
let canvasW = ((cropperW - cutL - cutR) / cropperW) * IMG_REAL_W
let canvasH = ((cropperH - cutT - cutB) / cropperH) * IMG_REAL_H
let canvasL = (cutL / cropperW) * IMG_REAL_W
let canvasT = (cutT / cropperH) * IMG_REAL_H
wx.canvasToTempFilePath({
x: canvasL,
y: canvasT,
width: canvasW,
height: canvasH,
destWidth: canvasW,
destHeight: canvasH,
fileType:IMG_TYPE || 'jpg',
canvasId: 'cropper',
success: (res) => {
//图片裁剪成功
this.cancelCropper();
this.triggerEvent('cropperDone', {
src:res.tempFilePath,
cropperData:{
x: canvasL,
y: canvasT,
width: canvasW,
height: canvasH
}
})
},
fail:err =>{
this.triggerEvent('cropperFail',err)
}
},this);
})
},
circleCrop(){
let {imageSrc,cropperW,cropperH,cutL,cutT,cutR,cutB} = this.data;
let {IMG_REAL_W,IMG_REAL_H,IMG_TYPE} = this.data.C_CONSTANTS;
// 将图片写入画布
const ctx = wx.createCanvasContext('cropper',this)
let canvasW = ((cropperW - cutL - cutR) / cropperW) * IMG_REAL_W
let canvasL = (cutL / cropperW) * IMG_REAL_W
let canvasT = (cutT / cropperH) * IMG_REAL_H
this.setData({
canvasW:canvasW,
canvasH:canvasW
},() => {
ctx.arc(canvasW / 2,canvasW / 2,canvasW / 2,0,2 * Math.PI);
ctx.clip();
ctx.drawImage(imageSrc, canvasL, canvasT, canvasW, canvasW,0,0,canvasW,canvasW);
ctx.draw(true, () => {
wx.canvasToTempFilePath({
fileType:IMG_TYPE || 'jpg',
canvasId: 'cropper',
success: (res) => {
//图片裁剪成功
this.cancelCropper();
this.triggerEvent('cropperDone', {
src:res.tempFilePath,
cropperData:{
x: canvasL,
y: canvasT,
width: canvasW,
height: canvasW
}
})
},
fail:err =>{
this.triggerEvent('cropperFail',err)
}
},this);
})
})
},
cancelCropper(){
let originData = {}
try{
originData = JSON.parse(JSON.stringify(defaultData))
}catch(e){};
this.setData({
...originData
});
this.triggerEvent('cropperCancel')
}
}
})

View File

@ -1,3 +0,0 @@
{
"component": true
}

View File

@ -1,44 +0,0 @@
<view class="wx-cropper-info" wx:if="{{isShowCropper}}">
<view class='cropper-content'>
<!-- {{cropperInitH}}rpx -->
<view class="wx-corpper" style="width:{{cropperInitW}}rpx;height:85%;background:#000;display: flex;justify-content: center;align-items: center;">
<!-- left:{{cropperL}}rpx;top:{{cropperT}}rpx -->
<view class="wx-corpper-content" style="width:{{cropperW}}rpx;height:{{cropperH}}rpx;">
<image class="img" src="{{imageSrc}}" style="width:{{cropperW}}rpx;height:{{cropperH}}rpx"></image>
<view class="wx-corpper-crop-box" bindtouchstart="contentStartMove" bindtouchmove="contentMoveing"
bindtouchend="contentTouchEnd" style="left:{{cutL}}rpx;top:{{cutT}}rpx;right:{{cutR}}rpx;bottom:{{cutB}}rpx">
<view class="wx-cropper-view-box">
<view class="wx-cropper-dashed-h"></view>
<view class="wx-cropper-dashed-v"></view>
<view class="wx-cropper-line-t" data-drag="top" catchtouchstart="dragStart" catchtouchmove="dragMove"></view>
<view class="wx-cropper-line-r" data-drag="right" catchtouchstart="dragStart"
catchtouchmove="dragMove"></view>
<view class="wx-cropper-line-b" data-drag="bottom" catchtouchstart="dragStart"
catchtouchmove="dragMove"></view>
<view class="wx-cropper-line-l" data-drag="left" catchtouchstart="dragStart" catchtouchmove="dragMove"></view>
<view class="wx-cropper-point point-t" data-drag="top" catchtouchstart="dragStart"
catchtouchmove="dragMove"></view>
<view class="wx-cropper-point point-tr" data-drag="topTight"></view>
<view class="wx-cropper-point point-r" data-drag="right" catchtouchstart="dragStart"
catchtouchmove="dragMove"></view>
<view class="wx-cropper-point point-rb" data-drag="rightBottom" catchtouchstart="dragStart"
catchtouchmove="dragMove"></view>
<view class="wx-cropper-point point-b" data-drag="bottom" catchtouchstart="dragStart"
catchtouchmove="dragMove" catchtouchend="dragEnd"></view>
<view class="wx-cropper-point point-bl" data-drag="bottomLeft"></view>
<view class="wx-cropper-point point-l" data-drag="left" catchtouchstart="dragStart"
catchtouchmove="dragMove"></view>
<view class="wx-cropper-point point-lt" data-drag="leftTop"></view>
</view>
</view>
</view>
</view>
</view>
<view class='cropper-config'>
<button type="primary reverse" class="btn" bindtap="cancelCropper" style='margin-top: 30rpx;'> 取消 </button>
<button type="primary" class="cropper-confirm btn" bindtap="confirmCropper" style='margin-top: 30rpx;'> 确认 </button>
</view>
<canvas wx:if="{{!isCircleCrop}}" canvas-id="cropper" style="position:absolute;border: 1px solid red; width:{{qualityWidth}}px;height:{{qualityWidth/innerAspectRadio}}px;top:-9999px;left:-9999px;"></canvas>
<canvas wx:else canvas-id="cropper" style="position:absolute;border: 1px solid red; width:{{canvasW}}px;height:{{canvasH}}px;top:-9999px;left:-9999px;"></canvas>
</view>

View File

@ -1,296 +0,0 @@
/* pages/wx-cropper/index.wxss */
.wx-cropper-info {
position: fixed;
top: 140rpx;
left: 0;
right: 0;
bottom: 0;
display: block;
z-index: 10000;
align-items: center;
flex-direction: column;
height: 100%;
background: #000;
}
.cropper-config {
display: flex;
position: fixed;
width: 100%;
bottom: 20rpx;
}
.cropper-config .btn {
min-width: 300rpx;
}
.cropper-config .cropper-confirm {
background: #fac208;
}
.cropper-content {
min-height: 750rpx;
width: 100%;
height: 100%;
}
.wx-corpper {
position: relative;
overflow: hidden;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
-webkit-tap-highlight-color: transparent;
-webkit-touch-callout: none;
box-sizing: border-box;
}
.wx-corpper-content {
position: relative;
}
.wx-corpper-content .img {
display: block;
width: 100%;
min-width: 0 !important;
max-width: none !important;
height: 100%;
min-height: 0 !important;
max-height: none !important;
image-orientation: 0deg !important;
margin: 0 auto;
}
/* 移动图片效果 */
.wx-cropper-drag-box {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
cursor: move;
background: rgba(0, 0, 0, 0.6);
z-index: 1;
}
/* 内部的信息 */
.wx-corpper-crop-box {
position: absolute;
background: rgba(255, 255, 255, 0.3);
z-index: 2;
}
.wx-corpper-crop-box .wx-cropper-view-box {
position: relative;
display: block;
width: 100%;
height: 100%;
overflow: visible;
outline: 1px solid #69f;
outline-color: rgba(102, 153, 255, .75)
}
/* 横向虚线 */
.wx-cropper-dashed-h {
position: absolute;
top: 33.33333333%;
left: 0;
width: 100%;
height: 33.33333333%;
border-top: 1px dashed rgba(255, 255, 255, 0.5);
border-bottom: 1px dashed rgba(255, 255, 255, 0.5);
}
/* 纵向虚线 */
.wx-cropper-dashed-v {
position: absolute;
left: 33.33333333%;
top: 0;
width: 33.33333333%;
height: 100%;
border-left: 1px dashed rgba(255, 255, 255, 0.5);
border-right: 1px dashed rgba(255, 255, 255, 0.5);
}
/* 四个方向的线 为了之后的拖动事件*/
.wx-cropper-line-t {
position: absolute;
display: block;
width: 100%;
background-color: #69f;
top: 0;
left: 0;
height: 1px;
opacity: 0.1;
cursor: n-resize;
}
.wx-cropper-line-t::before {
content: '';
position: absolute;
top: 50%;
right: 0rpx;
width: 100%;
-webkit-transform: translate3d(0, -50%, 0);
transform: translate3d(0, -50%, 0);
bottom: 0;
height: 41rpx;
background: transparent;
z-index: 11;
}
.wx-cropper-line-r {
position: absolute;
display: block;
background-color: #69f;
top: 0;
right: 0px;
width: 1px;
opacity: 0.1;
height: 100%;
cursor: e-resize;
}
.wx-cropper-line-r::before {
content: '';
position: absolute;
top: 0;
left: 50%;
width: 41rpx;
-webkit-transform: translate3d(-50%, 0, 0);
transform: translate3d(-50%, 0, 0);
bottom: 0;
height: 100%;
background: transparent;
z-index: 11;
}
.wx-cropper-line-b {
position: absolute;
display: block;
width: 100%;
background-color: #69f;
bottom: 0;
left: 0;
height: 1px;
opacity: 0.1;
cursor: s-resize;
}
.wx-cropper-line-b::before {
content: '';
position: absolute;
top: 50%;
right: 0rpx;
width: 100%;
-webkit-transform: translate3d(0, -50%, 0);
transform: translate3d(0, -50%, 0);
bottom: 0;
height: 41rpx;
background: transparent;
z-index: 11;
}
.wx-cropper-line-l {
position: absolute;
display: block;
background-color: #69f;
top: 0;
left: 0;
width: 1px;
opacity: 0.1;
height: 100%;
cursor: w-resize;
}
.wx-cropper-line-l::before {
content: '';
position: absolute;
top: 0;
left: 50%;
width: 41rpx;
-webkit-transform: translate3d(-50%, 0, 0);
transform: translate3d(-50%, 0, 0);
bottom: 0;
height: 100%;
background: transparent;
z-index: 11;
}
.wx-cropper-point {
width: 5px;
height: 5px;
background-color: #69f;
opacity: .75;
position: absolute;
z-index: 3;
}
.point-t {
top: -3px;
left: 50%;
margin-left: -3px;
cursor: n-resize;
}
.point-tr {
top: -3px;
left: 100%;
margin-left: -3px;
cursor: n-resize;
}
.point-r {
top: 50%;
left: 100%;
margin-left: -3px;
margin-top: -3px;
cursor: n-resize;
}
.point-rb {
left: 100%;
top: 100%;
-webkit-transform: translate3d(-50%, -50%, 0);
transform: translate3d(-50%, -50%, 0);
cursor: n-resize;
/* width: 24rpx; */
/* height: 24rpx; */
background-color: #69f;
position: absolute;
z-index: 1112;
opacity: 1;
}
.point-b {
left: 50%;
top: 100%;
margin-left: -3px;
margin-top: -3px;
cursor: n-resize;
}
.point-bl {
left: 0%;
top: 100%;
margin-left: -3px;
margin-top: -3px;
cursor: n-resize;
}
.point-l {
left: 0%;
top: 50%;
margin-left: -3px;
margin-top: -3px;
cursor: n-resize;
}
.point-lt {
left: 0%;
top: 0%;
margin-left: -3px;
margin-top: -3px;
cursor: n-resize;
}

View File

@ -1,271 +1,302 @@
import { VantComponent } from '../common/component';
import { touch } from '../mixins/touch';
import {
getAllRect,
getRect,
groupSetData,
nextTick,
requestAnimationFrame,
} from '../common/utils';
import { getAllRect, getRect, groupSetData, nextTick, requestAnimationFrame, } from '../common/utils';
import { isDef } from '../common/validator';
import { useChildren } from '../common/relation';
VantComponent({
mixins: [touch],
classes: ['nav-class', 'tab-class', 'tab-active-class', 'line-class'],
relation: useChildren('tab', function () {
this.updateTabs();
}),
props: {
sticky: Boolean,
border: Boolean,
swipeable: Boolean,
titleActiveColor: String,
titleInactiveColor: String,
color: String,
animated: {
type: Boolean,
observer() {
this.children.forEach((child, index) =>
child.updateRender(index === this.data.currentIndex, this)
);
},
mixins: [touch],
classes: [
'nav-class',
'tab-class',
'tab-active-class',
'line-class',
'wrap-class',
],
relation: useChildren('tab', function () {
this.updateTabs();
}),
props: {
sticky: Boolean,
border: Boolean,
swipeable: Boolean,
titleActiveColor: String,
titleInactiveColor: String,
color: String,
animated: {
type: Boolean,
observer() {
this.children.forEach((child, index) => child.updateRender(index === this.data.currentIndex, this));
},
},
lineWidth: {
type: null,
value: 40,
observer: 'resize',
},
lineHeight: {
type: null,
value: -1,
},
active: {
type: null,
value: 0,
observer(name) {
if (name !== this.getCurrentName()) {
this.setCurrentIndexByName(name);
}
},
},
type: {
type: String,
value: 'line',
},
ellipsis: {
type: Boolean,
value: true,
},
duration: {
type: Number,
value: 0.3,
},
zIndex: {
type: Number,
value: 1,
},
swipeThreshold: {
type: Number,
value: 5,
observer(value) {
this.setData({
scrollable: this.children.length > value || !this.data.ellipsis,
});
},
},
offsetTop: {
type: Number,
value: 0,
},
lazyRender: {
type: Boolean,
value: true,
},
useBeforeChange: {
type: Boolean,
value: false,
},
},
lineWidth: {
type: null,
value: 40,
observer: 'resize',
data: {
tabs: [],
scrollLeft: 0,
scrollable: false,
currentIndex: 0,
container: null,
skipTransition: true,
scrollWithAnimation: false,
lineOffsetLeft: 0,
inited: false,
},
lineHeight: {
type: null,
value: -1,
},
active: {
type: null,
value: 0,
observer(name) {
if (name !== this.getCurrentName()) {
this.setCurrentIndexByName(name);
}
},
},
type: {
type: String,
value: 'line',
},
ellipsis: {
type: Boolean,
value: true,
},
duration: {
type: Number,
value: 0.3,
},
zIndex: {
type: Number,
value: 1,
},
swipeThreshold: {
type: Number,
value: 5,
observer(value) {
this.setData({
scrollable: this.children.length > value || !this.data.ellipsis,
mounted() {
requestAnimationFrame(() => {
this.swiping = true;
this.setData({
container: () => this.createSelectorQuery().select('.van-tabs'),
});
this.resize();
this.scrollIntoView();
});
},
},
offsetTop: {
type: Number,
value: 0,
methods: {
updateTabs() {
const { children = [], data } = this;
this.setData({
tabs: children.map((child) => child.data),
scrollable: this.children.length > data.swipeThreshold || !data.ellipsis,
});
this.setCurrentIndexByName(data.active || this.getCurrentName());
},
trigger(eventName, child) {
const { currentIndex } = this.data;
const data = this.getChildData(currentIndex, child);
if (!isDef(data)) {
return;
}
this.$emit(eventName, data);
},
onTap(event) {
const { index } = event.currentTarget.dataset;
const child = this.children[index];
if (child.data.disabled) {
this.trigger('disabled', child);
return;
}
this.onBeforeChange(index).then(() => {
this.setCurrentIndex(index);
nextTick(() => {
this.trigger('click');
});
});
},
// correct the index of active tab
setCurrentIndexByName(name) {
const { children = [] } = this;
const matched = children.filter((child) => child.getComputedName() === name);
if (matched.length) {
this.setCurrentIndex(matched[0].index);
}
},
setCurrentIndex(currentIndex) {
const { data, children = [] } = this;
if (!isDef(currentIndex) ||
currentIndex >= children.length ||
currentIndex < 0) {
return;
}
groupSetData(this, () => {
children.forEach((item, index) => {
const active = index === currentIndex;
if (active !== item.data.active || !item.inited) {
item.updateRender(active, this);
}
});
});
if (currentIndex === data.currentIndex) {
if (!data.inited) {
this.resize();
}
return;
}
const shouldEmitChange = data.currentIndex !== null;
this.setData({ currentIndex });
requestAnimationFrame(() => {
this.resize();
this.scrollIntoView();
});
nextTick(() => {
this.trigger('input');
if (shouldEmitChange) {
this.trigger('change');
}
});
},
getCurrentName() {
const activeTab = this.children[this.data.currentIndex];
if (activeTab) {
return activeTab.getComputedName();
}
},
resize() {
if (this.data.type !== 'line') {
return;
}
const { currentIndex, ellipsis, skipTransition } = this.data;
Promise.all([
getAllRect(this, '.van-tab'),
getRect(this, '.van-tabs__line'),
]).then(([rects = [], lineRect]) => {
const rect = rects[currentIndex];
if (rect == null) {
return;
}
let lineOffsetLeft = rects
.slice(0, currentIndex)
.reduce((prev, curr) => prev + curr.width, 0);
lineOffsetLeft +=
(rect.width - lineRect.width) / 2 + (ellipsis ? 0 : 8);
this.setData({ lineOffsetLeft, inited: true });
this.swiping = true;
if (skipTransition) {
// waiting transition end
setTimeout(() => {
this.setData({ skipTransition: false });
}, this.data.duration);
}
});
},
// scroll active tab into view
scrollIntoView() {
const { currentIndex, scrollable, scrollWithAnimation } = this.data;
if (!scrollable) {
return;
}
Promise.all([
getAllRect(this, '.van-tab'),
getRect(this, '.van-tabs__nav'),
]).then(([tabRects, navRect]) => {
const tabRect = tabRects[currentIndex];
const offsetLeft = tabRects
.slice(0, currentIndex)
.reduce((prev, curr) => prev + curr.width, 0);
this.setData({
scrollLeft: offsetLeft - (navRect.width - tabRect.width) / 2,
});
if (!scrollWithAnimation) {
nextTick(() => {
this.setData({ scrollWithAnimation: true });
});
}
});
},
onTouchScroll(event) {
this.$emit('scroll', event.detail);
},
onTouchStart(event) {
if (!this.data.swipeable)
return;
this.swiping = true;
this.touchStart(event);
},
onTouchMove(event) {
if (!this.data.swipeable || !this.swiping)
return;
this.touchMove(event);
},
// watch swipe touch end
onTouchEnd() {
if (!this.data.swipeable || !this.swiping)
return;
const { direction, deltaX, offsetX } = this;
const minSwipeDistance = 50;
if (direction === 'horizontal' && offsetX >= minSwipeDistance) {
const index = this.getAvaiableTab(deltaX);
if (index !== -1) {
this.onBeforeChange(index).then(() => this.setCurrentIndex(index));
}
}
this.swiping = false;
},
getAvaiableTab(direction) {
const { tabs, currentIndex } = this.data;
const step = direction > 0 ? -1 : 1;
for (let i = step; currentIndex + i < tabs.length && currentIndex + i >= 0; i += step) {
const index = currentIndex + i;
if (index >= 0 &&
index < tabs.length &&
tabs[index] &&
!tabs[index].disabled) {
return index;
}
}
return -1;
},
onBeforeChange(index) {
const { useBeforeChange } = this.data;
if (!useBeforeChange) {
return Promise.resolve();
}
return new Promise((resolve, reject) => {
this.$emit('before-change', Object.assign(Object.assign({}, this.getChildData(index)), { callback: (status) => (status ? resolve() : reject()) }));
});
},
getChildData(index, child) {
const currentChild = child || this.children[index];
if (!isDef(currentChild)) {
return;
}
return {
index: currentChild.index,
name: currentChild.getComputedName(),
title: currentChild.data.title,
};
},
},
lazyRender: {
type: Boolean,
value: true,
},
},
data: {
tabs: [],
scrollLeft: 0,
scrollable: false,
currentIndex: 0,
container: null,
skipTransition: true,
lineOffsetLeft: 0,
},
mounted() {
requestAnimationFrame(() => {
this.setData({
container: () => this.createSelectorQuery().select('.van-tabs'),
});
this.resize(true);
this.scrollIntoView();
});
},
methods: {
updateTabs() {
const { children = [], data } = this;
this.setData({
tabs: children.map((child) => child.data),
scrollable:
this.children.length > data.swipeThreshold || !data.ellipsis,
});
this.setCurrentIndexByName(data.active || this.getCurrentName());
},
trigger(eventName, child) {
const { currentIndex } = this.data;
const currentChild = child || this.children[currentIndex];
if (!isDef(currentChild)) {
return;
}
this.$emit(eventName, {
index: currentChild.index,
name: currentChild.getComputedName(),
title: currentChild.data.title,
});
},
onTap(event) {
const { index } = event.currentTarget.dataset;
const child = this.children[index];
if (child.data.disabled) {
this.trigger('disabled', child);
} else {
this.setCurrentIndex(index);
nextTick(() => {
this.trigger('click');
});
}
},
// correct the index of active tab
setCurrentIndexByName(name) {
const { children = [] } = this;
const matched = children.filter(
(child) => child.getComputedName() === name
);
if (matched.length) {
this.setCurrentIndex(matched[0].index);
}
},
setCurrentIndex(currentIndex) {
const { data, children = [] } = this;
if (
!isDef(currentIndex) ||
currentIndex >= children.length ||
currentIndex < 0
) {
return;
}
groupSetData(this, () => {
children.forEach((item, index) => {
const active = index === currentIndex;
if (active !== item.data.active || !item.inited) {
item.updateRender(active, this);
}
});
});
if (currentIndex === data.currentIndex) {
return;
}
const shouldEmitChange = data.currentIndex !== null;
this.setData({ currentIndex });
nextTick(() => {
this.resize();
this.scrollIntoView();
this.trigger('input');
if (shouldEmitChange) {
this.trigger('change');
}
});
},
getCurrentName() {
const activeTab = this.children[this.data.currentIndex];
if (activeTab) {
return activeTab.getComputedName();
}
},
resize(skipTransition = false) {
if (this.data.type !== 'line') {
return;
}
const { currentIndex, ellipsis } = this.data;
Promise.all([
getAllRect(this, '.van-tab'),
getRect(this, '.van-tabs__line'),
]).then(([rects = [], lineRect]) => {
const rect = rects[currentIndex];
if (rect == null) {
return;
}
let lineOffsetLeft = rects
.slice(0, currentIndex)
.reduce((prev, curr) => prev + curr.width, 0);
lineOffsetLeft +=
(rect.width - lineRect.width) / 2 + (ellipsis ? 0 : 8);
this.setData({
lineOffsetLeft,
skipTransition,
});
});
},
// scroll active tab into view
scrollIntoView() {
const { currentIndex, scrollable } = this.data;
if (!scrollable) {
return;
}
Promise.all([
getAllRect(this, '.van-tab'),
getRect(this, '.van-tabs__nav'),
]).then(([tabRects, navRect]) => {
const tabRect = tabRects[currentIndex];
const offsetLeft = tabRects
.slice(0, currentIndex)
.reduce((prev, curr) => prev + curr.width, 0);
this.setData({
scrollLeft: offsetLeft - (navRect.width - tabRect.width) / 2,
});
});
},
onTouchScroll(event) {
this.$emit('scroll', event.detail);
},
onTouchStart(event) {
if (!this.data.swipeable) return;
this.touchStart(event);
},
onTouchMove(event) {
if (!this.data.swipeable) return;
this.touchMove(event);
},
// watch swipe touch end
onTouchEnd() {
if (!this.data.swipeable) return;
const { direction, deltaX, offsetX } = this;
const minSwipeDistance = 50;
if (direction === 'horizontal' && offsetX >= minSwipeDistance) {
const index = this.getAvaiableTab(deltaX);
if (index !== -1) {
this.setCurrentIndex(index);
}
}
},
getAvaiableTab(direction) {
const { tabs, currentIndex } = this.data;
const step = direction > 0 ? -1 : 1;
for (
let i = step;
currentIndex + i < tabs.length && currentIndex + i >= 0;
i += step
) {
const index = currentIndex + i;
if (
index >= 0 &&
index < tabs.length &&
tabs[index] &&
!tabs[index].disabled
) {
return index;
}
}
return -1;
},
},
});

View File

@ -1,7 +1,7 @@
<wxs src="../wxs/utils.wxs" module="utils" />
<wxs src="./index.wxs" module="computed" />
<view class="custom-class {{ utils.bem('tabs', [type]) }}">
<view class="custom-class {{ utils.bem('tabs') }}">
<van-sticky
disabled="{{ !sticky }}"
z-index="{{ zIndex }}"
@ -9,18 +9,18 @@
container="{{ container }}"
bind:scroll="onTouchScroll"
>
<view class="{{ utils.bem('tabs__wrap', { scrollable }) }} {{ type === 'line' && border ? 'van-hairline--top-bottom' : '' }}">
<view class="{{ utils.bem('tabs--') + type }} {{ utils.bem('tabs__wrap', { scrollable }) }} {{ type === 'line' && border ? 'van-hairline--top-bottom' : '' }} wrap-class">
<slot name="nav-left" />
<scroll-view
scroll-x="{{ scrollable }}"
scroll-with-animation
scroll-with-animation="{{ scrollWithAnimation }}"
scroll-left="{{ scrollLeft }}"
class="{{ utils.bem('tabs__scroll', [type]) }}"
style="{{ color ? 'border-color: ' + color : '' }}"
>
<view class="{{ utils.bem('tabs__nav', [type, { complete: !ellipsis }]) }} nav-class" style="{{ computed.navStyle(color, type) }}">
<view wx:if="{{ type === 'line' }}" class="van-tabs__line" style="{{ computed.lineStyle({ color, lineOffsetLeft, lineHeight, skipTransition, duration, lineWidth }) }}" />
<view wx:if="{{ type === 'line' }}" class="van-tabs__line" style="{{ computed.lineStyle({ color, lineOffsetLeft, lineHeight, skipTransition, duration, lineWidth, inited }) }}" />
<view
wx:for="{{ tabs }}"
wx:key="index"

View File

@ -60,6 +60,7 @@ function trackStyle(data) {
function lineStyle(data) {
return style({
width: utils.addUnit(data.lineWidth),
opacity: data.inited ? 1 : 0,
transform: 'translateX(' + data.lineOffsetLeft + 'px)',
'-webkit-transform': 'translateX(' + data.lineOffsetLeft + 'px)',
'background-color': data.color,

View File

@ -1 +1 @@
@import '../common/index.wxss';.van-tabs{position:relative;-webkit-tap-highlight-color:transparent}.van-tabs__wrap{display:-webkit-flex;display:flex;overflow:hidden}.van-tabs__wrap--scrollable .van-tab{-webkit-flex:0 0 22%;flex:0 0 22%}.van-tabs__wrap--scrollable .van-tab--complete{-webkit-flex:1 0 auto!important;flex:1 0 auto!important;padding:0 12px}.van-tabs__wrap--scrollable .van-tabs__nav--complete{padding-right:8px;padding-left:8px}.van-tabs__scroll{background-color:#fff;background-color:var(--tabs-nav-background-color,#fff)}.van-tabs__scroll--line{box-sizing:initial;height:calc(100% + 15px)}.van-tabs__scroll--card{margin:0 16px;margin:0 var(--padding-md,16px)}.van-tabs__scroll::-webkit-scrollbar{display:none}.van-tabs__nav{position:relative;display:-webkit-flex;display:flex;-webkit-user-select:none;user-select:none}.van-tabs__nav--card{box-sizing:border-box;height:30px;height:var(--tabs-card-height,30px);border:1px solid #ee0a24;border:var(--border-width-base,1px) solid var(--tabs-default-color,#ee0a24);border-radius:2px;border-radius:var(--border-radius-sm,2px)}.van-tabs__nav--card .van-tab{color:#ee0a24;color:var(--tabs-default-color,#ee0a24);line-height:28px;line-height:calc(var(--tabs-card-height, 30px) - var(--border-width-base, 1px)*2);border-right:1px solid #ee0a24;border-right:var(--border-width-base,1px) solid var(--tabs-default-color,#ee0a24)}.van-tabs__nav--card .van-tab:last-child{border-right:none}.van-tabs__nav--card .van-tab.van-tab--active{color:#fff;color:var(--white,#fff);background-color:#ee0a24;background-color:var(--tabs-default-color,#ee0a24)}.van-tabs__nav--card .van-tab--disabled{color:#c8c9cc;color:var(--tab-disabled-text-color,#c8c9cc)}.van-tabs__line{position:absolute;bottom:0;left:0;z-index:1;height:3px;height:var(--tabs-bottom-bar-height,3px);border-radius:3px;border-radius:var(--tabs-bottom-bar-height,3px);background-color:#ee0a24;background-color:var(--tabs-bottom-bar-color,#ee0a24)}.van-tabs__track{position:relative;width:100%;height:100%}.van-tabs__track--animated{display:-webkit-flex;display:flex;transition-property:left}.van-tabs__content{overflow:hidden}.van-tabs--line .van-tabs__wrap{height:44px;height:var(--tabs-line-height,44px)}.van-tabs--card .van-tabs__wrap{height:30px;height:var(--tabs-card-height,30px)}.van-tab{position:relative;-webkit-flex:1;flex:1;box-sizing:border-box;min-width:0;padding:0 5px;text-align:center;cursor:pointer;color:#646566;color:var(--tab-text-color,#646566);font-size:14px;font-size:var(--tab-font-size,14px);line-height:44px;line-height:var(--tabs-line-height,44px)}.van-tab--active{font-weight:500;font-weight:var(--font-weight-bold,500);color:#323233;color:var(--tab-active-text-color,#323233)}.van-tab--disabled{color:#c8c9cc;color:var(--tab-disabled-text-color,#c8c9cc)}.van-tab__title__info{position:relative!important;top:-1px!important;display:inline-block;-webkit-transform:translateX(0)!important;transform:translateX(0)!important}
@import '../common/index.wxss';.van-tabs{-webkit-tap-highlight-color:transparent;position:relative}.van-tabs__wrap{display:flex;overflow:hidden}.van-tabs__wrap--scrollable .van-tab{flex:0 0 22%}.van-tabs__wrap--scrollable .van-tab--complete{flex:1 0 auto!important;padding:0 12px}.van-tabs__wrap--scrollable .van-tabs__nav--complete{padding-left:8px;padding-right:8px}.van-tabs__scroll{background-color:var(--tabs-nav-background-color,#fff);overflow:auto}.van-tabs__scroll--line{box-sizing:initial;height:calc(100% + 15px)}.van-tabs__scroll--card{border:1px solid var(--tabs-default-color,#ee0a24);border-radius:2px;box-sizing:border-box;margin:0 var(--padding-md,16px);width:calc(100% - var(--padding-md, 16px)*2)}.van-tabs__scroll::-webkit-scrollbar{display:none}.van-tabs__nav{display:flex;position:relative;-webkit-user-select:none;user-select:none}.van-tabs__nav--card{box-sizing:border-box;height:var(--tabs-card-height,30px)}.van-tabs__nav--card .van-tab{border-right:1px solid var(--tabs-default-color,#ee0a24);color:var(--tabs-default-color,#ee0a24);line-height:calc(var(--tabs-card-height, 30px) - 2px)}.van-tabs__nav--card .van-tab:last-child{border-right:none}.van-tabs__nav--card .van-tab.van-tab--active{background-color:var(--tabs-default-color,#ee0a24);color:#fff}.van-tabs__nav--card .van-tab--disabled{color:var(--tab-disabled-text-color,#c8c9cc)}.van-tabs__line{background-color:var(--tabs-bottom-bar-color,#ee0a24);border-radius:var(--tabs-bottom-bar-height,3px);bottom:0;height:var(--tabs-bottom-bar-height,3px);left:0;opacity:0;position:absolute;z-index:1}.van-tabs__track{height:100%;position:relative;width:100%}.van-tabs__track--animated{display:flex;transition-property:left}.van-tabs__content{overflow:hidden}.van-tabs--line{height:var(--tabs-line-height,44px)}.van-tabs--card{height:var(--tabs-card-height,30px)}.van-tab{box-sizing:border-box;color:var(--tab-text-color,#646566);cursor:pointer;flex:1;font-size:var(--tab-font-size,14px);line-height:var(--tabs-line-height,44px);min-width:0;padding:0 5px;position:relative;text-align:center}.van-tab--active{color:var(--tab-active-text-color,#323233);font-weight:var(--font-weight-bold,500)}.van-tab--disabled{color:var(--tab-disabled-text-color,#c8c9cc)}.van-tab__title__info{position:relative!important;top:-1px!important;transform:translateX(0)!important}