123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183 |
- 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)
- }
- }
- })
|