Blame view

node_modules/mpvue-zanui/src/pages/zan_actionsheet/index.vue 2.16 KB
ce4c83ff   wxy   初始提交
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
  <template>
    <div class="container">
  
      <div class="doc-title zan-hairline--bottom zan-hairline--bottom">ACTIONSHEET</div>
  
      <div class="zan-btns" style="margin-top: 30vh;">
        <button class="zan-btn" @click="toggleActionsheet">
          Actionsheet
        </button>
      </div>
  
      <Actionsheet
        v-bind="baseActionsheet"
        :handleZanActionsheetClick="true"
        :handleZanActionsheetCancel="true"
        v-on:handleZanActionsheetClick="handleZanActionsheetClick"
        v-on:handleZanActionsheetCancel="handleZanActionsheetCancel"/>
    </div>
  </template>
  
  <script>
    import Actionsheet from '../../components/zan/actionsheet'
  
    export default {
      components: {
        Actionsheet
      },
      data () {
        return {
          baseActionsheet: {
            show: false,
            cancelText: '关闭 Action',
            closeOnClickOverlay: true,
            componentId: 'baseActionsheet',
            actions: [{
              name: '选项1',
              subname: '选项描述语1',
              className: 'action-class',
              loading: false
            }, {
              name: '选项2',
              subname: '选项描述语2',
              className: 'action-class',
              loading: false
            }, {
              name: '去分享',
              openType: 'share'
            }]
          }
        }
      },
      methods: {
        onShareAppMessage () {
          return {
            title: 'ZanUI-WeApp',
            imageUrl: 'https://img.yzcdn.cn/public_files/2017/02/06/ee0ebced79a80457d77ce71c7d414c74.png'
          }
        },
  
        toggleActionsheet () {
          this.baseActionsheet.show = true
        },
        handleZanActionsheetCancel ({componentId}) {
          this[componentId].show = false
        },
        handleZanActionsheetClick ({componentId, index}) {
          console.log('item index ' + index + ' clicked')
          // 如果是分享按钮被点击, 不处理关闭
          if (index === 2) {
            return
          }
          this[componentId].actions[index].loading = true
          setTimeout(() => {
            this[componentId].show = false
            this[componentId].actions[index].loading = false
          }, 1500)
        }
      }
    }
  
  </script>
  <style >
  </style>
  <style  scoped>
  </style>