|
@@ -0,0 +1,183 @@
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+var lasttime = 0;
|
|
|
+
|
|
|
+var clickTime = 200;
|
|
|
+
|
|
|
+Component({
|
|
|
+
|
|
|
+ * 组件的属性列表
|
|
|
+ */
|
|
|
+ properties: {
|
|
|
+ itemHeight: {
|
|
|
+ type: Number,
|
|
|
+ value:100
|
|
|
+ },
|
|
|
+ padding: {
|
|
|
+ type: Number,
|
|
|
+ value:15
|
|
|
+ },
|
|
|
+ radius: {
|
|
|
+ type: Number,
|
|
|
+ value:15
|
|
|
+ },
|
|
|
+ showExit: {
|
|
|
+ type: Boolean,
|
|
|
+ value:true
|
|
|
+ },
|
|
|
+ exitText: {
|
|
|
+ type: String,
|
|
|
+ value:"取消"
|
|
|
+ },
|
|
|
+ exitColor: {
|
|
|
+ type: String,
|
|
|
+ value:"#666666"
|
|
|
+ },
|
|
|
+ selectItemText: {
|
|
|
+ type: Array,
|
|
|
+ value: ["测试1", "测试2"]
|
|
|
+ },
|
|
|
+ selectItemTextColor: {
|
|
|
+ type: Array,
|
|
|
+ value: ["#576B95", "#576B95"],
|
|
|
+ },
|
|
|
+ outExit: {
|
|
|
+ type: Boolean,
|
|
|
+ value:false
|
|
|
+ },
|
|
|
+ mark: {
|
|
|
+ type: String,
|
|
|
+ value:"selectPopup"
|
|
|
+ },
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
+
|
|
|
+ * 组件的初始数据
|
|
|
+ */
|
|
|
+ data: {
|
|
|
+
|
|
|
+ itemHeight: 100,
|
|
|
+
|
|
|
+ padding: 15,
|
|
|
+
|
|
|
+ radius: 15,
|
|
|
+
|
|
|
+ showExit: true,
|
|
|
+
|
|
|
+ exitText: "取消",
|
|
|
+
|
|
|
+ exitColor: "#666666",
|
|
|
+
|
|
|
+ selectItemText: ["测试1", "测试2"],
|
|
|
+
|
|
|
+ selectItemTextColor: ["#576B95", "#ff0000"],
|
|
|
+ popupSelectDisplay: "hidden",
|
|
|
+
|
|
|
+ outExit:false,
|
|
|
+
|
|
|
+ mark:"selectPopup",
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
+
|
|
|
+ * 组件的方法列表
|
|
|
+ */
|
|
|
+ methods: {
|
|
|
+
|
|
|
+ click: function (e) {
|
|
|
+
|
|
|
+ let d = new Date();
|
|
|
+ let nowtime = d.getTime();
|
|
|
+ if (nowtime - lasttime > clickTime) {
|
|
|
+ lasttime = nowtime;
|
|
|
+ let index = parseInt(e.currentTarget.id.replace("list_", ""));
|
|
|
+ console.log(index)
|
|
|
+ this.closePopup('selectPopupItemClick', [ index,this.data.mark ])
|
|
|
+ }
|
|
|
+ },
|
|
|
+ exitClick: function (e) {
|
|
|
+
|
|
|
+ let d = new Date();
|
|
|
+ let nowtime = d.getTime();
|
|
|
+ if (nowtime - lasttime > clickTime) {
|
|
|
+ lasttime = nowtime;
|
|
|
+ switch (e.currentTarget.id) {
|
|
|
+ case "out":
|
|
|
+ if(this.data.outExit){
|
|
|
+ this.closePopup('selectPopupExit', [ -1,this.data.mark ])
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case "cancel":
|
|
|
+ this.closePopup('selectPopupExit', [ -1,this.data.mark ])
|
|
|
+
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ },
|
|
|
+ show(selectItemText,selectItemTextColor){
|
|
|
+ var that = this
|
|
|
+ that.setData({
|
|
|
+ selectItemText: selectItemText,
|
|
|
+ selectItemTextColor:selectItemTextColor,
|
|
|
+ })
|
|
|
+ this.openPopup()
|
|
|
+ },
|
|
|
+
|
|
|
+
|
|
|
+ openPopup() {
|
|
|
+ var query = this.createSelectorQuery()
|
|
|
+ var that = this
|
|
|
+
|
|
|
+ query.select('#popup_select_content').boundingClientRect(function (res) {
|
|
|
+
|
|
|
+ var screenH = res.height;
|
|
|
+ that.setData({
|
|
|
+ popupSelectDisplay: "visible",
|
|
|
+ })
|
|
|
+ that.animation_select = wx.createAnimation({
|
|
|
+ duration: 300,
|
|
|
+ timingFunction: 'ease',
|
|
|
+ delay: 0,
|
|
|
+ transformOrigin: 'left top 0',
|
|
|
+ })
|
|
|
+ that.animation_select.translate(0, -screenH).step()
|
|
|
+ that.setData({
|
|
|
+
|
|
|
+ animation_select: that.animation_select.export()
|
|
|
+ })
|
|
|
+ }).exec();
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
+ closePopup(event,detail) {
|
|
|
+
|
|
|
+ var that = this
|
|
|
+ that.animation_select = wx.createAnimation({
|
|
|
+
|
|
|
+ duration: 300,
|
|
|
+ timingFunction: 'ease',
|
|
|
+
|
|
|
+ delay: 0,
|
|
|
+ transformOrigin: 'left top 0',
|
|
|
+ })
|
|
|
+ that.animation_select.translate(0, 0).step()
|
|
|
+ that.setData({
|
|
|
+
|
|
|
+ animation_select: that.animation_select.export()
|
|
|
+ })
|
|
|
+ setTimeout(function () {
|
|
|
+ that.setData({
|
|
|
+ popupSelectDisplay: "hidden",
|
|
|
+ })
|
|
|
+ this.triggerEvent(event,detail,{})
|
|
|
+
|
|
|
+ }.bind(this), 300)
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+})
|