吃个甘蔗嚼一年 3 年前
父节点
当前提交
bec4ac4eee

+ 40
- 34
src/components/CompoentsOrder/OrderCard/index.jsx 查看文件

1
 import Taro from "@tarojs/taro";
1
 import Taro from "@tarojs/taro";
2
 import { View, Text } from '@tarojs/components'
2
 import { View, Text } from '@tarojs/components'
3
 import formatTime from "@/utils/formatTime";
3
 import formatTime from "@/utils/formatTime";
4
+import SlideViewOrder from '@/components/SlideViewOrder';
5
+import { getOrderSub, deleteOrder } from "@/services/payOrder";
6
+
4
 import CouponCard from '@/components/CouponCard'
7
 import CouponCard from '@/components/CouponCard'
5
 import QRcode from "@/assets/icons/UserCenter/QRcode.png";
8
 import QRcode from "@/assets/icons/UserCenter/QRcode.png";
6
 import refund from "@/assets/icons/GuideCheck/refund.png";
9
 import refund from "@/assets/icons/GuideCheck/refund.png";
17
 const Action = CouponCard.Action
20
 const Action = CouponCard.Action
18
 
21
 
19
 export default (props) => {
22
 export default (props) => {
20
-  const { item, setShowCutover, show, sh, kkp } = props
23
+  const { item, setShowCutover, show, sh, kkp, handeDelete } = props
21
 
24
 
22
   const handleDetail = () => {
25
   const handleDetail = () => {
23
     if (item.status === 0) {
26
     if (item.status === 0) {
27
     }
30
     }
28
   }
31
   }
29
 
32
 
33
+
34
+
30
   //核销
35
   //核销
31
   const onWriteOff = (item) => {
36
   const onWriteOff = (item) => {
32
     Taro.scanCode({
37
     Taro.scanCode({
70
                   item.isVerified == true && item.isEvaluated > 0 ? <Action.Image image={Evaluated} /> :
75
                   item.isVerified == true && item.isEvaluated > 0 ? <Action.Image image={Evaluated} /> :
71
                     item.isVerified == true ? <Action.Icon icon={Evaluation} text='评价' onClick={() => evaluation(item)} /> : null
76
                     item.isVerified == true ? <Action.Icon icon={Evaluation} text='评价' onClick={() => evaluation(item)} /> : null
72
 
77
 
73
-
74
   return (
78
   return (
75
     <>
79
     <>
76
       {
80
       {
77
-        sh != '1'|| kkp == '1'? <view className='OrderNumber'>订单编号:{item.orderId}</view> : null
81
+        sh != '1' || kkp == '1' ? <view className='OrderNumber'>订单编号:{item.orderId}</view> : null
78
       }
82
       }
79
-      <CouponCard action={PayAction}>
80
-        <CouponMedia>
81
-          <CouponMedia.Header
82
-            cashback={item.cashback}
83
-            image={item.poster}
84
-            badge='food'
85
-          />
86
-          <CouponMedia.Body star={kkp == '1' ? 'ss' : item.score}>
87
-            <View className='orderCard'>
88
-              <View className='cpn-card-text'>
89
-                <View style={{ flex: '1' }}>{(item.packageDescription).toString().length > 25 ? (item.packageDescription).substring(0, 25) + '...' : (item.packageDescription)}</View>
90
-                <text className={kkp == '1' ? 'shanchu' : 'title-money-2'}>
91
-                  数量:{item.amount}张
92
-                </text>
93
-              </View>
94
-              <View className='cpn-card-text' style={{ marginTop: '10rpx' }}>
95
-                <Text className='cpn-card-text_mn'>¥{`${(item.unitPrice / 100)?.toFixed(2)}元`}</Text>
96
-              </View>
97
-              <View className='cpn-md-act'>
98
-                <view className={item.isVerified == 1 ? 'title-time' : ''}>
99
-                  {
100
-                    sh == 1 ? '有效期:' + formatTime(item.endTime, "yyyy/MM/dd") :
101
-                      item.isVerified == 1 ? '核销时间 :' + formatTime(item?.verifiedDate, "yyyy/MM/dd") :
102
-                        '有效期:' + formatTime(item?.startTime, "yyyy/MM/dd") + '-' +
103
-                        formatTime(item.endTime, "yyyy/MM/dd")
104
-                  }
105
-                </view>
83
+      <SlideViewOrder del onDelete={() => handeDelete(item)} >
84
+        <CouponCard action={PayAction}>
85
+          <CouponMedia>
86
+            <CouponMedia.Header
87
+              cashback={item.cashback}
88
+              image={item.poster}
89
+              badge='food'
90
+            />
91
+            <CouponMedia.Body star={kkp == '1' ? 'ss' : item.score}>
92
+              <View className='orderCard'>
93
+                <View className='cpn-card-text'>
94
+                  <View style={{ flex: '1' }}>{(item.packageDescription).toString().length > 25 ? (item.packageDescription).substring(0, 25) + '...' : (item.packageDescription)}</View>
95
+                  <text className={kkp == '1' ? 'shanchu' : 'title-money-2'}>
96
+                    数量:{item.amount}张
97
+                  </text>
98
+                </View>
99
+                <View className='cpn-card-text' style={{ marginTop: '10rpx' }}>
100
+                  <Text className='cpn-card-text_mn'>¥{`${(item.unitPrice / 100)?.toFixed(2)}元`}</Text>
101
+                </View>
102
+                <View className='cpn-md-act'>
103
+                  <view className={item.isVerified == 1 ? 'title-time' : ''}>
104
+                    {
105
+                      sh == 1 ? '有效期:' + formatTime(item.endTime, "yyyy/MM/dd") :
106
+                        item.isVerified == 1 ? '核销时间 :' + formatTime(item?.verifiedDate, "yyyy/MM/dd") :
107
+                          '有效期:' + formatTime(item?.startTime, "yyyy/MM/dd") + '-' +
108
+                          formatTime(item.endTime, "yyyy/MM/dd")
109
+                    }
110
+                  </view>
111
+                </View>
106
               </View>
112
               </View>
107
-            </View>
108
-          </CouponMedia.Body>
109
-        </CouponMedia>
110
-      </CouponCard>
113
+            </CouponMedia.Body>
114
+          </CouponMedia>
115
+        </CouponCard>
116
+      </SlideViewOrder>
111
     </>
117
     </>
112
   )
118
   )
113
 }
119
 }

+ 6
- 5
src/components/CompoentsOrder/complete/index.jsx 查看文件

7
 import OrderCard from '../OrderCard'
7
 import OrderCard from '../OrderCard'
8
 import "./style.less";
8
 import "./style.less";
9
 import { View } from "@tarojs/components";
9
 import { View } from "@tarojs/components";
10
+import SlideViewOrder from '@/components/SlideViewOrder';
10
 
11
 
11
 
12
 
12
 const dict = {
13
 const dict = {
117
                 /* 待支付 */
118
                 /* 待支付 */
118
                 if (item.status === 0) {
119
                 if (item.status === 0) {
119
                   return (
120
                   return (
120
-                    <mp-slideview buttons={button} onButtontap={() => slideButtonTap(item)} icon >
121
-                      <view key={`${type}-${item.orderId}`}  >
122
-                        <OrderCard item={item} />
123
-                      </view>
124
-                    </mp-slideview>
121
+                    // <SlideViewOrder del onDelete={() => slideButtonTap(item)}>
122
+                    <view key={`${type}-${item.orderId}`}  >
123
+                      <OrderCard item={item} handeDelete={slideButtonTap} />
124
+                    </view>
125
+                    // </SlideViewOrder>
125
                   );
126
                   );
126
                 }
127
                 }
127
                 /* 已使用 */
128
                 /* 已使用 */

+ 97
- 0
src/components/SlideViewOrder/index.jsx 查看文件

1
+
2
+import React, { useEffect, useMemo, useRef, useState } from 'react'
3
+import Taro from '@tarojs/taro';
4
+import { ScrollView, View, Image, Text } from '@tarojs/components';
5
+import deleteIcon from '@/assets/icons/landlord/delete.png';
6
+import './style.less'
7
+
8
+export default (props) => {
9
+  const { className, action, del, onDelete } = props;
10
+
11
+  const contextRef = useRef()
12
+  const contentHeightRef = useRef(0)
13
+  const [actStyle, setActStyle]= useState()
14
+
15
+  const uqClass = useMemo(() => `f-${Math.random().toString(36).substring(2)}`, [])
16
+  const classes = [className, 'slideview-wrapper', uqClass].filter(Boolean).join(' ');
17
+
18
+  const handleScrollLeft = () => {
19
+    if (contextRef.current) {
20
+      contextRef.current.scrollIntoView('.slideview-content')
21
+    }
22
+  }
23
+
24
+  const handleScrollRight = () => {
25
+    if (contextRef.current) {
26
+      contextRef.current.scrollIntoView('.slideview-actions')
27
+    }
28
+  }
29
+
30
+  const handleDelete = (e) => {
31
+    if (onDelete) {
32
+      onDelete(e)
33
+    }
34
+  }
35
+
36
+  useEffect(() => {
37
+    Taro.nextTick(() => {
38
+      Taro.createSelectorQuery()
39
+      .select(`.${uqClass}`)
40
+      .node()
41
+      .exec((res) => {
42
+        contextRef.current = res[0].node;
43
+      })
44
+    })
45
+  }, [])
46
+
47
+  useEffect(() => {
48
+    Taro.nextTick(() => {
49
+      // 不清楚为什么, 此处获取高度一直不准确
50
+      const t = setTimeout(() => {
51
+        Taro.createSelectorQuery()
52
+        .select(`.${uqClass}`)
53
+        .boundingClientRect()
54
+        .exec((res) => {
55
+          if (res && res[0]) {
56
+            const { height } = res[0]
57
+            if (height && height !== contentHeightRef.current) {
58
+              setActStyle({
59
+                height: `${height}px`,
60
+              })
61
+              contentHeightRef.current = height
62
+            }
63
+          }
64
+        })
65
+        clearTimeout(t)
66
+      }, 500)
67
+    })
68
+  })
69
+
70
+  return (
71
+    <ScrollView
72
+      className={classes}
73
+      upperThreshold={20}
74
+      lowerThreshold={20}
75
+      scrollX
76
+      scrollWithAnimation
77
+      enhanced
78
+      onScrollToUpper={handleScrollLeft}
79
+      onScrollToLower={handleScrollRight}
80
+    >
81
+      <View className='slideview-content'>{props.children}</View>
82
+      <View className='slideview-actions' style={actStyle}>
83
+        <View className='slideview-action'>
84
+          {
85
+            del && (
86
+              <View className='slideview-action_delete' onClick={handleDelete}>
87
+                <Image src={deleteIcon} />
88
+                <View>删除</View>
89
+              </View>
90
+            )
91
+          }
92
+          {action}
93
+        </View>
94
+      </View>
95
+    </ScrollView>
96
+  )
97
+}

+ 52
- 0
src/components/SlideViewOrder/style.less 查看文件

1
+.slideview-wrapper {
2
+  box-sizing: border-box;
3
+  white-space: nowrap;
4
+
5
+  &::-webkit-scrollbar{
6
+    width: 0;
7
+    height: 0;
8
+    color: transparent;
9
+  }
10
+
11
+  .slideview-content {
12
+    min-width: 100%;
13
+    display: inline-block;
14
+    vertical-align: middle;
15
+  }
16
+
17
+  .slideview-actions {
18
+    display: inline-block;
19
+    vertical-align: middle;
20
+    margin: 0 20px;
21
+    background: #FFFFFF;
22
+    box-shadow: 0px 8px 38px 0px rgba(0, 0, 0, 0.12);
23
+    border-radius: 12px;
24
+
25
+    .slideview-action {
26
+      height: 100%;
27
+      display: flex;
28
+      align-items: center;
29
+      justify-content: center;
30
+      
31
+      &_delete {
32
+        display: block;
33
+        flex: none;
34
+        height: 74px;
35
+        width: 67px;
36
+        text-align: center;
37
+        padding: 10px;
38
+        font-size: 24px;
39
+        font-weight: bold;
40
+        color: #FF3434;
41
+
42
+        & > image {
43
+          width: 28px;
44
+          height: 30px;
45
+          display: block;
46
+          margin: 0 auto 20px;
47
+        }
48
+      }
49
+    }
50
+
51
+  }
52
+}

+ 1
- 1
src/components/add-tips/index.wxml 查看文件

2
   <view class='arrow' style="margin-right:{{arrowR}}px;"></view>
2
   <view class='arrow' style="margin-right:{{arrowR}}px;"></view>
3
   <view class='body' bindtap='hidden' style="margin-right:{{bodyR}}px;">
3
   <view class='body' bindtap='hidden' style="margin-right:{{bodyR}}px;">
4
     <image src="{{logo}}" class="logo"></image>
4
     <image src="{{logo}}" class="logo"></image>
5
-    <view class="tips">选择"添加到我的小程序",使用更便捷</view>
5
+    <view class="tips"></view>
6
   </view>
6
   </view>
7
 </view>
7
 </view>

+ 4
- 2
src/components/add-tips/index.wxss 查看文件

26
   zoom: 1.5;
26
   zoom: 1.5;
27
 }
27
 }
28
 .tips {
28
 .tips {
29
+  height: 200px;
30
+  width: 200px;
29
   flex: 1;
31
   flex: 1;
30
   color: #fff;
32
   color: #fff;
31
   font-size: 20px;
33
   font-size: 20px;
32
   font-weight: 700;
34
   font-weight: 700;
33
 }
35
 }
34
 .logo {
36
 .logo {
35
-  height: 42px;
36
-  width: 42px;
37
+  height: 200px;
38
+  width: 200px;
37
   border-radius: 8px;
39
   border-radius: 8px;
38
   margin-right: 10px;
40
   margin-right: 10px;
39
 }
41
 }

+ 75
- 63
src/pages/details/foodDetails/foodDetails.less 查看文件

1
-.storeDetails{
2
-  background-color: #fff;  
1
+.storeDetails {
2
+  background-color: #fff;
3
   border-radius: 12px;
3
   border-radius: 12px;
4
   margin-bottom: 20px;
4
   margin-bottom: 20px;
5
 
5
 
6
-  .swiper{
6
+  .swiper {
7
     height: calc((100vw - 60px) * 0.6);
7
     height: calc((100vw - 60px) * 0.6);
8
   }
8
   }
9
-  .storeImage{
9
+  .storeImage {
10
     position: relative;
10
     position: relative;
11
     border-radius: 22px;
11
     border-radius: 22px;
12
     width: 100%;
12
     width: 100%;
13
     height: 100%;
13
     height: 100%;
14
-    .tpPage{
14
+    .tpPage {
15
       position: absolute;
15
       position: absolute;
16
       right: 20px;
16
       right: 20px;
17
       bottom: 20px;
17
       bottom: 20px;
18
       background: #000000;
18
       background: #000000;
19
-      border-radius: 16px;  
20
-      font-size: 24px;       
21
-      color: #FFFFFF;
22
-      padding:0 7px;
23
-      opacity: 0.4;  
19
+      border-radius: 16px;
20
+      font-size: 24px;
21
+      color: #ffffff;
22
+      padding: 0 7px;
23
+      opacity: 0.4;
24
       line-height: 32px;
24
       line-height: 32px;
25
       padding: 7px 8px 8px 7px;
25
       padding: 7px 8px 8px 7px;
26
-      text{
26
+      text {
27
         opacity: 0.64;
27
         opacity: 0.64;
28
       }
28
       }
29
     }
29
     }
30
-  }  
31
-  .storeJs{
30
+  }
31
+  .storeJs {
32
     padding: 20px;
32
     padding: 20px;
33
-    .storeName{      
34
-      font-size: 32px;         
33
+    .storeName {
34
+      font-size: 32px;
35
       font-weight: bold;
35
       font-weight: bold;
36
       color: #202020;
36
       color: #202020;
37
     }
37
     }
38
-    .sprice{
38
+    .sprice {
39
       color: #202020;
39
       color: #202020;
40
-      font-size: 32px;         
40
+      font-size: 32px;
41
       font-weight: bold;
41
       font-weight: bold;
42
-      .t1{        
42
+      .t1 {
43
         font-size: 24px;
43
         font-size: 24px;
44
         padding-right: 10px;
44
         padding-right: 10px;
45
       }
45
       }
46
-      .bzRight{        
46
+      .bzRight {
47
         font-weight: 400;
47
         font-weight: 400;
48
         font-size: 24px;
48
         font-size: 24px;
49
         float: right;
49
         float: right;
50
       }
50
       }
51
     }
51
     }
52
-    .appraise{
52
+    .appraise {
53
       line-height: 0;
53
       line-height: 0;
54
       margin-top: 28px;
54
       margin-top: 28px;
55
       margin-bottom: 37px;
55
       margin-bottom: 37px;
56
-      font-size: 24px;         
56
+      font-size: 24px;
57
       font-weight: bold;
57
       font-weight: bold;
58
       color: #020200;
58
       color: #020200;
59
-      .t1{
59
+      .t1 {
60
         margin-left: 10px;
60
         margin-left: 10px;
61
       }
61
       }
62
-      .comment{
62
+      .comment {
63
         color: #666;
63
         color: #666;
64
       }
64
       }
65
     }
65
     }
66
-    .yysj{
66
+    .yysj {
67
       line-height: 0;
67
       line-height: 0;
68
       font-size: 24px;
68
       font-size: 24px;
69
       color: #666;
69
       color: #666;
70
-      .yysjImg{
70
+      .yysjImg {
71
         width: 26px;
71
         width: 26px;
72
         height: 26px;
72
         height: 26px;
73
         position: relative;
73
         position: relative;
75
         padding-right: 10px;
75
         padding-right: 10px;
76
       }
76
       }
77
     }
77
     }
78
-    .dpPosition{
78
+    .dpPosition {
79
       margin-top: 40px;
79
       margin-top: 40px;
80
       position: relative;
80
       position: relative;
81
-      .dwTip{
81
+      .dwTip {
82
         width: 28px;
82
         width: 28px;
83
         height: 28px;
83
         height: 28px;
84
         position: absolute;
84
         position: absolute;
85
         top: 4px;
85
         top: 4px;
86
-        left:0;
86
+        left: 0;
87
       }
87
       }
88
-      view{
89
-        font-size: 24px;         
88
+      view {
89
+        font-size: 24px;
90
         color: #666666;
90
         color: #666666;
91
         padding-left: 34px;
91
         padding-left: 34px;
92
         padding-bottom: 40px;
92
         padding-bottom: 40px;
93
-        .zhuandao{
93
+        .zhuandao {
94
           width: 14px;
94
           width: 14px;
95
           height: 24px;
95
           height: 24px;
96
           transform: rotate(180deg);
96
           transform: rotate(180deg);
97
           position: relative;
97
           position: relative;
98
           left: 8px;
98
           left: 8px;
99
           top: 5px;
99
           top: 5px;
100
-        }        
100
+        }
101
       }
101
       }
102
-      
103
     }
102
     }
104
   }
103
   }
105
 }
104
 }
106
-.title{
105
+.title {
107
   margin: 59px 0 41px 0;
106
   margin: 59px 0 41px 0;
108
-  image{
107
+  image {
109
     width: 30px;
108
     width: 30px;
110
     height: 30px;
109
     height: 30px;
111
     position: relative;
110
     position: relative;
112
     top: 5px;
111
     top: 5px;
113
   }
112
   }
114
-  text{
115
-    font-size: 34px;       
113
+  text {
114
+    font-size: 34px;
116
     font-weight: bold;
115
     font-weight: bold;
117
     color: #202020;
116
     color: #202020;
118
     margin-left: 10px;
117
     margin-left: 10px;
119
   }
118
   }
120
 }
119
 }
121
-.cs{
120
+.cs {
122
   height: 500px;
121
   height: 500px;
123
   // background: rgb(240, 142, 142);
122
   // background: rgb(240, 142, 142);
124
   // background: radial-gradient(circle at top left, transparent 15px, rgb(240, 142, 142) 0) top left,
123
   // background: radial-gradient(circle at top left, transparent 15px, rgb(240, 142, 142) 0) top left,
126
   //           radial-gradient(circle at bottom left, transparent 15px, #58a 0) bottom left,
125
   //           radial-gradient(circle at bottom left, transparent 15px, #58a 0) bottom left,
127
   //           radial-gradient(circle at bottom right, transparent 15px, #58a 0) bottom right;
126
   //           radial-gradient(circle at bottom right, transparent 15px, #58a 0) bottom right;
128
 
127
 
128
+  background: radial-gradient(
129
+        circle at 82% top,
130
+        transparent 15px,
131
+        rgb(240, 140, 140) 0
132
+      )
133
+      top,
134
+    radial-gradient(
135
+        circle at 82% bottom,
136
+        transparent 15px,
137
+        rgb(230, 120, 120) 0
138
+      )
139
+      bottom;
129
 
140
 
130
-  background: radial-gradient(circle at 82% top,transparent 15px,rgb(240,140,140) 0) top,
131
-              radial-gradient(circle at 82% bottom,transparent 15px,rgb(230,120,120) 0) bottom;
132
-
133
-background-repeat: no-repeat;
134
-background-size: auto 50%;
141
+  background-repeat: no-repeat;
142
+  background-size: auto 50%;
135
 }
143
 }
136
 
144
 
137
-.showMore{
145
+.showMore {
138
   width: 100%;
146
   width: 100%;
139
-  background: linear-gradient(0deg, rgba(248, 248, 248, 0.58) 42%, rgba(248, 248, 248, 0) 100%);
147
+  background: linear-gradient(
148
+    0deg,
149
+    rgba(248, 248, 248, 0.58) 42%,
150
+    rgba(248, 248, 248, 0) 100%
151
+  );
140
   font-size: 28px;
152
   font-size: 28px;
141
   font-weight: bold;
153
   font-weight: bold;
142
   color: #202020;
154
   color: #202020;
143
   text-align: center;
155
   text-align: center;
144
   position: absolute;
156
   position: absolute;
145
-  bottom: -100px;
157
+  bottom: -140px;
146
   padding-top: 77px;
158
   padding-top: 77px;
147
   padding-bottom: 20px;
159
   padding-bottom: 20px;
148
-  .moreTip{
160
+  .moreTip {
149
     width: 38px;
161
     width: 38px;
150
     height: 19px;
162
     height: 19px;
151
     margin-top: 14px;
163
     margin-top: 14px;
152
   }
164
   }
153
 }
165
 }
154
-.storezn{
155
-  font-size: 28px;    
166
+.storezn {
167
+  font-size: 28px;
156
   color: #202020;
168
   color: #202020;
157
   line-height: 54px;
169
   line-height: 54px;
158
   margin-bottom: 44px;
170
   margin-bottom: 44px;
159
 }
171
 }
160
-.storezn+image{
172
+.storezn + image {
161
   width: 100%;
173
   width: 100%;
162
   margin-bottom: 40px;
174
   margin-bottom: 40px;
163
 }
175
 }
164
 
176
 
165
-.botton{
166
-  font-size: 28px;   
167
-  color: #C0C8D3;
177
+.botton {
178
+  font-size: 28px;
179
+  color: #c0c8d3;
168
   line-height: 34px;
180
   line-height: 34px;
169
   text-align: center;
181
   text-align: center;
170
-  padding:40px 0 68px 0;
171
-  background-color: #F8F8F8;
182
+  padding: 40px 0 68px 0;
183
+  background-color: #f8f8f8;
172
 }
184
 }
173
-.bottomTab{
174
-  background: #FFF;
185
+.bottomTab {
186
+  background: #fff;
175
   border-radius: 12px;
187
   border-radius: 12px;
176
   column-count: 3;
188
   column-count: 3;
177
-  text-align: center;  
178
-  .sharebtn{
189
+  text-align: center;
190
+  .sharebtn {
179
     position: absolute;
191
     position: absolute;
180
     width: 260px;
192
     width: 260px;
181
     opacity: 0;
193
     opacity: 0;
182
   }
194
   }
183
-  .tab{
195
+  .tab {
184
     line-height: 96px;
196
     line-height: 96px;
185
-    font-size: 28px;     
197
+    font-size: 28px;
186
     font-weight: bold;
198
     font-weight: bold;
187
     color: #202020;
199
     color: #202020;
188
-    image{
200
+    image {
189
       width: 31px;
201
       width: 31px;
190
       height: 31px;
202
       height: 31px;
191
       position: relative;
203
       position: relative;
193
       margin-right: 12px;
205
       margin-right: 12px;
194
     }
206
     }
195
   }
207
   }
196
-}
208
+}

+ 0
- 38
src/utils/copyTxt.js 查看文件

1
-
2
-export default function copyTxt(text, fn) { // 复制功能
3
-  if (typeof document.execCommand !== 'function') {
4
-    console.log('复制失败,请长按复制')
5
-    return
6
-  }
7
-  var dom = document.createElement('textarea')
8
-  dom.value = text
9
-  dom.setAttribute('style', 'display: block;width: 1px;height: 1px;')
10
-  document.body.appendChild(dom)
11
-  dom.select()
12
-  var result = document.execCommand('copy')
13
-  document.body.removeChild(dom)
14
-  if (result) {
15
-    console.log('复制成功')
16
-    typeof fn === 'function' && fn()
17
-    return
18
-  }
19
-  if (typeof document.createRange !== 'function') {
20
-    console.log('复制失败,请长按复制')
21
-    return
22
-  }
23
-  var range = document.createRange()
24
-  var div = document.createElement('div')
25
-  div.innerhtml = text
26
-  div.setAttribute('style', 'height: 1px;fontSize: 1px;overflow: hidden;')
27
-  document.body.appendChild(div)
28
-  range.selectNode(div)
29
-  var selection = window.getSelection()
30
-  console.log(selection)
31
-  if (selection.rangeCount > 0) {
32
-    selection.removeAllRanges()
33
-  }
34
-  selection.addRange(range)
35
-  document.execCommand('copy')
36
-  typeof fn === 'function' && fn()
37
-  console.log('复制成功')
38
-}