魏熙美 5 лет назад
Родитель
Сommit
f8a4681958
2 измененных файлов: 48 добавлений и 21 удалений
  1. 1
    0
      package.json
  2. 47
    21
      src/pages/activity/ActivityList.jsx

+ 1
- 0
package.json Просмотреть файл

53
     "moment": "^2.24.0",
53
     "moment": "^2.24.0",
54
     "omit.js": "^1.0.2",
54
     "omit.js": "^1.0.2",
55
     "path-to-regexp": "^3.0.0",
55
     "path-to-regexp": "^3.0.0",
56
+    "qrcodejs2": "0.0.2",
56
     "qs": "^6.7.0",
57
     "qs": "^6.7.0",
57
     "react": "^16.8.6",
58
     "react": "^16.8.6",
58
     "react-amap": "^1.2.8",
59
     "react-amap": "^1.2.8",

+ 47
- 21
src/pages/activity/ActivityList.jsx Просмотреть файл

1
 import React, { useState, useEffect } from 'react';
1
 import React, { useState, useEffect } from 'react';
2
 import { Form, Input, Button, Icon, Select, message, Table, Divider, Tag, Pagination, Modal, DatePicker } from 'antd';
2
 import { Form, Input, Button, Icon, Select, message, Table, Divider, Tag, Pagination, Modal, DatePicker } from 'antd';
3
 import { FormattedMessage } from 'umi-plugin-react/locale';
3
 import { FormattedMessage } from 'umi-plugin-react/locale';
4
-import styles from '../style/GoodsList.less';
5
 import router from 'umi/router';
4
 import router from 'umi/router';
6
 import moment from 'moment';
5
 import moment from 'moment';
6
+import QRCode from 'qrcodejs2'
7
+import styles from '../style/GoodsList.less';
7
 import SelectCity from '../../components/SelectButton/CitySelect'
8
 import SelectCity from '../../components/SelectButton/CitySelect'
8
 import BuildSelect from '../../components/SelectButton/BuildSelect'
9
 import BuildSelect from '../../components/SelectButton/BuildSelect'
9
 import apis from '../../services/apis';
10
 import apis from '../../services/apis';
41
     });
42
     });
42
   }
43
   }
43
 
44
 
45
+  const newQrcode = row => {
46
+    const qr = new QRCode('qrcode', {
47
+        text: row.dynamicId,
48
+        width: 128,
49
+        height: 128,
50
+    });
51
+  }
52
+
53
+  function download () {
54
+        const qrcode = document.getElementById('qrcode');
55
+        const imgs = qrcode.getElementsByTagName('img')
56
+        const img = imgs[imgs.length - 1]
57
+        console.log(img)
58
+        const link = document.createElement('a');
59
+        link.style.display = 'none'
60
+        const url = img.getAttribute('src');
61
+        console.log(img.getAttribute('src'))
62
+        link.setAttribute('href', url);
63
+        link.setAttribute('download', '活动二维码.png');
64
+        link.click();
65
+  }
66
+
44
   /**
67
   /**
45
    *
68
    *
46
    *
69
    *
59
       dataIndex: 'startDate',
82
       dataIndex: 'startDate',
60
       key: 'startDate',
83
       key: 'startDate',
61
       align: 'center',
84
       align: 'center',
62
-      render: (x, row) => <><span>{`${moment(row.startDate).format('YYYY-MM-DD')} —— ${moment(row.endDate).format('YYYY-MM-DD')}`}</span></>
85
+      render: (x, row) => <><span>{`${moment(row.startDate).format('YYYY-MM-DD')} —— ${moment(row.endDate).format('YYYY-MM-DD')}`}</span></>,
63
     },
86
     },
64
     {
87
     {
65
       title: '已参加人数',
88
       title: '已参加人数',
90
       dataIndex: 'activityStatus',
113
       dataIndex: 'activityStatus',
91
       key: 'activityStatus',
114
       key: 'activityStatus',
92
       align: 'center',
115
       align: 'center',
93
-      render: activityStatus => <><span>{activityStatus == 0 ? "进行中" : activityStatus == 1 ? '未开始' : '已结束'}</span></>,
116
+      render: activityStatus => <><span>{activityStatus == 0 ? '进行中' : activityStatus == 1 ? '未开始' : '已结束'}</span></>,
94
     },
117
     },
95
     {
118
     {
96
       title: '操作',
119
       title: '操作',
100
       render: (x, row) => (
123
       render: (x, row) => (
101
         <>
124
         <>
102
           <AuthButton name="admin.SignList.get" noRight={null}>
125
           <AuthButton name="admin.SignList.get" noRight={null}>
103
-            <span style={{ color: '#1990FF', cursor: 'pointer'}} onClick={getSignList.bind(this, row.dynamicId)}>{row.isEnlist == '1' || row.isEnlist == '2' ? "报名记录" : ""}<Icon type="snippets" className={styles.shoppingCart} /></span>
126
+            <span style={{ color: '#1990FF', cursor: 'pointer' }} onClick={getSignList.bind(this, row.dynamicId)}>{row.isEnlist == '1' || row.isEnlist == '2' ? '报名记录' : ''}<Icon type="snippets" className={styles.shoppingCart} /></span>
104
           </AuthButton>
127
           </AuthButton>
105
           <AuthButton name="admin.buildingDynamic.send.dynamicId.put" noRight={null}>
128
           <AuthButton name="admin.buildingDynamic.send.dynamicId.put" noRight={null}>
106
-            <span style={{ color: '#1990FF', cursor: 'pointer' }} onClick={sendOrPublicDynamic.bind(this,row)}>{ row.status === 1 ? '取消发布' : '发布' }<Icon type="close-circle" className={styles.edit} /></span>
129
+            <span style={{ color: '#1990FF', cursor: 'pointer' }} onClick={sendOrPublicDynamic.bind(this, row)}>{ row.status === 1 ? '取消发布' : '发布' }<Icon type="close-circle" className={styles.edit} /></span>
107
           </AuthButton>
130
           </AuthButton>
108
           <AuthButton name="admin.buildingDynamic.finish.put" noRight={null}>
131
           <AuthButton name="admin.buildingDynamic.finish.put" noRight={null}>
109
-            {row.isEnlist == 1 && <span style={{ color: '#1990FF', cursor: 'pointer' }} onClick={finishDynamic.bind(this,row)}>结束活动<Icon type="poweroff" className={styles.edit} /></span>}
132
+            {row.isEnlist == 1 && <span style={{ color: '#1990FF', cursor: 'pointer' }} onClick={finishDynamic.bind(this, row)}>结束活动<Icon type="poweroff" className={styles.edit} /></span>}
110
           </AuthButton>
133
           </AuthButton>
111
           <AuthButton name="admin.buildingDynamic.update.put" noRight={null}>
134
           <AuthButton name="admin.buildingDynamic.update.put" noRight={null}>
112
             <span style={{ color: '#1990FF', marginRight: '20px', cursor: 'pointer' }} onClick={topDynamic(row)}>{ row.weight === 1 ? '取消置顶' : '置顶' }<Icon type="vertical-align-top" className={styles.edit} /></span>
135
             <span style={{ color: '#1990FF', marginRight: '20px', cursor: 'pointer' }} onClick={topDynamic(row)}>{ row.weight === 1 ? '取消置顶' : '置顶' }<Icon type="vertical-align-top" className={styles.edit} /></span>
113
             {row.isEnlist != 2 && <span style={{ color: '#FF925C', cursor: 'pointer' }} onClick={toEditGoods(row.dynamicId)}>编辑<Icon type="form" className={styles.edit} /></span>}
136
             {row.isEnlist != 2 && <span style={{ color: '#FF925C', cursor: 'pointer' }} onClick={toEditGoods(row.dynamicId)}>编辑<Icon type="form" className={styles.edit} /></span>}
114
           </AuthButton>
137
           </AuthButton>
138
+          <span style={{ color: '#1990FF', cursor: 'pointer' }} onClick={newQrcode.bind(this, row)}>下载二维码<Icon type="qrcode" className={styles.shoppingCart} /></span>
115
         </>
139
         </>
116
-      )
140
+      ),
117
     },
141
     },
118
   ];
142
   ];
119
 
143
 
132
           okText: '确定',
156
           okText: '确定',
133
           cancelText: '取消',
157
           cancelText: '取消',
134
           onOk() {
158
           onOk() {
135
-              request({ ...apis.activity.finish, data: {dynamicId: row.dynamicId, top: "" } }).then(data => {
159
+              request({ ...apis.activity.finish, data: { dynamicId: row.dynamicId, top: '' } }).then(data => {
136
                   console.log(data)
160
                   console.log(data)
137
                   message.info('操作成功!')
161
                   message.info('操作成功!')
138
                   getList({ pageNum: 1, pageSize: 10 })
162
                   getList({ pageNum: 1, pageSize: 10 })
147
 //   置顶
171
 //   置顶
148
   const topDynamic = row => () => {
172
   const topDynamic = row => () => {
149
       const weight = Math.abs(row.weight - 1)
173
       const weight = Math.abs(row.weight - 1)
150
-      request({ ...apis.activity.weight, params: {dynamicId: row.dynamicId, weight} }).then(data => {
174
+      request({ ...apis.activity.weight, params: { dynamicId: row.dynamicId, weight } }).then(data => {
151
           console.log(data)
175
           console.log(data)
152
           message.info('操作成功!')
176
           message.info('操作成功!')
153
           getList({ pageNum: 1, pageSize: 10 })
177
           getList({ pageNum: 1, pageSize: 10 })
156
           message.info(err.msg || err.message)
180
           message.info(err.msg || err.message)
157
       })
181
       })
158
   }
182
   }
159
-  
183
+
160
   const sendOrPublicDynamic = row => {
184
   const sendOrPublicDynamic = row => {
161
       if (row.status === 1) {
185
       if (row.status === 1) {
162
           cancelDynamic(row)
186
           cancelDynamic(row)
164
           sendDynamic(row)
188
           sendDynamic(row)
165
       }
189
       }
166
   }
190
   }
167
-  
191
+
168
   // 取消活动
192
   // 取消活动
169
   const cancelDynamic = row => {
193
   const cancelDynamic = row => {
170
-      request({ ...apis.activity.cancel, urlData: {id: row.dynamicId}}).then((data) => {
194
+      request({ ...apis.activity.cancel, urlData: { id: row.dynamicId } }).then(data => {
171
           message.info('操作成功!')
195
           message.info('操作成功!')
172
           getList({ pageNum: 1, pageSize: 10 })
196
           getList({ pageNum: 1, pageSize: 10 })
173
-      }).catch((err) => {
197
+      }).catch(err => {
174
           console.log(err)
198
           console.log(err)
175
           message.info(err.msg || err.message)
199
           message.info(err.msg || err.message)
176
       })
200
       })
177
   }
201
   }
178
-  
179
-  //发布活动
202
+
203
+  // 发布活动
180
   const sendDynamic = row => {
204
   const sendDynamic = row => {
181
-      request({ ...apis.activity.send, urlData: {id: row.dynamicId}}).then((data) => {
205
+      request({ ...apis.activity.send, urlData: { id: row.dynamicId } }).then(data => {
182
           message.info('操作成功!')
206
           message.info('操作成功!')
183
           getList({ pageNum: 1, pageSize: 10 });
207
           getList({ pageNum: 1, pageSize: 10 });
184
-      }).catch((err) => {
208
+      }).catch(err => {
185
           console.log(err)
209
           console.log(err)
186
           message.info(err.msg || err.message)
210
           message.info(err.msg || err.message)
187
       })
211
       })
188
   }
212
   }
189
-  
213
+
190
   const changePageNum = pageNumber => {
214
   const changePageNum = pageNumber => {
191
       getList({ pageNum: pageNumber, pageSize: 10 })
215
       getList({ pageNum: pageNumber, pageSize: 10 })
192
   }
216
   }
202
     });
226
     });
203
   }
227
   }
204
 
228
 
205
-   //重置搜索
229
+   // 重置搜索
206
    function handleReset() {
230
    function handleReset() {
207
     props.form.resetFields();
231
     props.form.resetFields();
208
   }
232
   }
212
   return (
236
   return (
213
 
237
 
214
     <>
238
     <>
239
+      {/* style={{ display: 'none' }} */}
240
+      <div id="qrcode"></div>
215
       <Form layout="inline" onSubmit={e => handleSubmit(e, props)}>
241
       <Form layout="inline" onSubmit={e => handleSubmit(e, props)}>
216
         <Form.Item>
242
         <Form.Item>
217
           {getFieldDecorator('cityId')(
243
           {getFieldDecorator('cityId')(
233
         </Form.Item>
259
         </Form.Item>
234
         <Form.Item>
260
         <Form.Item>
235
           {getFieldDecorator('time')(
261
           {getFieldDecorator('time')(
236
-            <DatePicker />
262
+            <DatePicker />,
237
           )}
263
           )}
238
         </Form.Item>
264
         </Form.Item>
239
         <Form.Item>
265
         <Form.Item>
258
       </AuthButton>
284
       </AuthButton>
259
       <Table dataSource={data.list} columns={columns} pagination={false} rowKey="activityList"/>
285
       <Table dataSource={data.list} columns={columns} pagination={false} rowKey="activityList"/>
260
       <div style={{ display: 'flex', justifyContent: 'flex-end', marginTop: '30px' }}>
286
       <div style={{ display: 'flex', justifyContent: 'flex-end', marginTop: '30px' }}>
261
-       <Pagination showQuickJumper defaultCurrent={1} total={data.total} onChange={(e) => changePageNum(e)} />
287
+       <Pagination showQuickJumper defaultCurrent={1} total={data.total} onChange={e => changePageNum(e)} />
262
       </div>
288
       </div>
263
     </>
289
     </>
264
   )
290
   )