zlisen 3 vuotta sitten
vanhempi
commit
a6ba000d4e

+ 1
- 1
config/proxy.js Näytä tiedosto

@@ -17,7 +17,7 @@ export default {
17 17
   },
18 18
   test: {
19 19
     '/api/': {
20
-      target: 'https://preview.pro.ant.design',
20
+      target: 'https://xlk.njyz.tech',
21 21
       changeOrigin: true,
22 22
       pathRewrite: {
23 23
         '^': '',

+ 161
- 93
src/pages/carouselFigure/carouselFigureList.jsx Näytä tiedosto

@@ -6,39 +6,39 @@ import AuthButton from '@/components/AuthButton';
6 6
 import withActions from '@/components/ActionList';
7 7
 import EditIcon from '@/components/EditIcon';
8 8
 import Navigate from '@/components/Navigate';
9
-import SelectCity from '../../components/SelectButton/CitySelect'
10
-import BuildSelect from '../../components/SelectButton/BuildSelect'
9
+import SelectCity from '../../components/SelectButton/CitySelect';
10
+import BuildSelect from '../../components/SelectButton/BuildSelect';
11 11
 import apis from '../../services/apis';
12 12
 import request from '../../utils/request';
13 13
 import styles from '../style/GoodsList.less';
14
+import {getImgURL} from '../../utils/image';
14 15
 
15 16
 const { Option } = Select;
16 17
 
17
-const header = (props) => {
18
-  const [data, setData] = useState({})
18
+const header = props => {
19
+  const [data, setData] = useState({});
19 20
 
20 21
   useEffect(() => {
21 22
     getList({ pageNum: 1, pageSize: 10, showType: 'banner' });
22
-  }, [])
23
+  }, []);
23 24
 
24 25
   // 查询列表
25
-  const getList = (params) => {
26
-    request({ ...apis.carsuseFigure.extendContent, params: { ...params }, }).then((data) => {
27
-      console.log(data)
28
-      setData(data)
29
-    })
30
-  }
31
-
26
+  const getList = params => {
27
+    request({ ...apis.carsuseFigure.extendContent, params: { ...params } }).then(data => {
28
+      console.log(data);
29
+      setData(data);
30
+    });
31
+  };
32 32
 
33 33
   // 跳转到编辑页面
34
-  const toEditCarouse = (contentId) => () => {
34
+  const toEditCarouse = contentId => () => {
35 35
     router.push({
36 36
       pathname: '/carouselFigure/editCarousel',
37 37
       query: {
38
-        contentId
38
+        contentId,
39 39
       },
40 40
     });
41
-  }
41
+  };
42 42
 
43 43
   const columns = [
44 44
     {
@@ -46,7 +46,20 @@ const header = (props) => {
46 46
       dataIndex: 'image',
47 47
       key: 'image',
48 48
       align: 'center',
49
-      render: (x, row) => <Navigate onClick={toEditCarouse(row.contentId)} ><img src={row.image} className={row.showPosition === 'index' ? styles.imgIndex : row.showPosition === 'mall' ? styles.imgPerfect : ''} /></Navigate>,
49
+      render: (x, row) => (
50
+        <Navigate onClick={toEditCarouse(row.contentId)}>
51
+          <img
52
+            src={getImgURL(row.image)}
53
+            className={
54
+              row.showPosition === 'index'
55
+                ? styles.imgIndex
56
+                : row.showPosition === 'mall'
57
+                ? styles.imgPerfect
58
+                : ''
59
+            }
60
+          />
61
+        </Navigate>
62
+      ),
50 63
     },
51 64
     {
52 65
       title: '发布城市',
@@ -59,36 +72,67 @@ const header = (props) => {
59 72
       dataIndex: 'buildingName',
60 73
       key: 'buildingName',
61 74
       align: 'center',
62
-      render: (buildingName) => <span>{buildingName === null ? '无' : buildingName}</span>
75
+      render: buildingName => <span>{buildingName === null ? '无' : buildingName}</span>,
63 76
     },
64 77
     {
65 78
       title: '关联内容类型',
66 79
       dataIndex: 'contentType',
67 80
       key: 'contentType',
68 81
       align: 'center',
69
-      render: (contentType) => <span>{contentType === 'project' ? '项目' : contentType === 'activity' ? '活动' : contentType === 'news' ? '资讯' : contentType === 'other' ? '其他' :
70
-        contentType === 'help' ? '助力' : contentType === 'group' ? '拼团' : contentType === 'h5' ? 'H5活动' : contentType === 'salesBatch' ? '销售批次详情' : contentType === 'live' ? '直播活动详情' : '无'}</span>
82
+      render: contentType => (
83
+        <span>
84
+          {contentType === 'project'
85
+            ? '项目'
86
+            : contentType === 'activity'
87
+            ? '活动'
88
+            : contentType === 'news'
89
+            ? '资讯'
90
+            : contentType === 'other'
91
+            ? '其他'
92
+            : contentType === 'help'
93
+            ? '助力'
94
+            : contentType === 'group'
95
+            ? '拼团'
96
+            : contentType === 'h5'
97
+            ? 'H5活动'
98
+            : contentType === 'salesBatch'
99
+            ? '销售批次详情'
100
+            : contentType === 'live'
101
+            ? '直播活动详情'
102
+            : '无'}
103
+        </span>
104
+      ),
71 105
     },
72 106
     {
73 107
       title: '发布位置',
74 108
       dataIndex: 'showPosition',
75 109
       key: 'showPosition',
76 110
       align: 'center',
77
-      render: (showPosition) => <span>{showPosition === 'index' ? '首页' : showPosition === 'mall' ? '商城' : ''}</span>
111
+      render: showPosition => (
112
+        <span>{showPosition === 'index' ? '首页' : showPosition === 'mall' ? '商城' : ''}</span>
113
+      ),
78 114
     },
79 115
     {
80 116
       title: '发布时间',
81 117
       dataIndex: 'createDate',
82 118
       key: 'createDate',
83 119
       align: 'center',
84
-      render: (x, row) => <><span>{moment(row.createDate).format('YYYY-MM-DD')}</span></>
120
+      render: (x, row) => (
121
+        <>
122
+          <span>{moment(row.createDate).format('YYYY-MM-DD')}</span>
123
+        </>
124
+      ),
85 125
     },
86 126
     {
87 127
       title: '状态',
88 128
       dataIndex: 'status',
89 129
       key: 'status',
90 130
       align: 'center',
91
-      render: (status) => <><span>{status == 1 ? '已上架' : '已下架'}</span></>
131
+      render: status => (
132
+        <>
133
+          <span>{status == 1 ? '已上架' : '已下架'}</span>
134
+        </>
135
+      ),
92 136
     },
93 137
     {
94 138
       title: '操作',
@@ -97,7 +141,11 @@ const header = (props) => {
97 141
       align: 'center',
98 142
       render: withActions((x, row) => [
99 143
         <AuthButton name="admin.extendContent.publish" noRight={null}>
100
-          <EditIcon type={row.status === 1 ? 'down' : 'up'} text={row.status === 1 ? '下架' : '上架'} onClick={changeStatus(row)} />
144
+          <EditIcon
145
+            type={row.status === 1 ? 'down' : 'up'}
146
+            text={row.status === 1 ? '下架' : '上架'}
147
+            onClick={changeStatus(row)}
148
+          />
101 149
         </AuthButton>,
102 150
 
103 151
         <AuthButton name="admin.extendContent.id.put" noRight={null}>
@@ -107,103 +155,121 @@ const header = (props) => {
107 155
         <AuthButton name="admin.extendContent.delete" noRight={null}>
108 156
           <EditIcon text="删除" type="delete" onClick={deleteCarouse(row.contentId)} />
109 157
         </AuthButton>,
110
-      ])
158
+      ]),
111 159
     },
112 160
   ];
113 161
 
114
-  const finishDynamic = (row) => {
162
+  const finishDynamic = row => {
115 163
     Modal.confirm({
116 164
       title: '结束以后将无法编辑, 是否继续?',
117 165
       okText: '确定',
118 166
       cancelText: '取消',
119 167
       onOk() {
120
-        request({ ...apis.carsuseFigure.finish, data: { dynamicId: row.dynamicId, top: "" }, }).then((data) => {
121
-          console.log(data)
122
-          message.info('操作成功!')
123
-          getList({ pageNum: 1, pageSize: 10, showType: 'banner' })
124
-        }).catch((err) => {
125
-          console.log(err)
126
-          message.info(err.msg || err.message)
127
-        })
168
+        request({ ...apis.carsuseFigure.finish, data: { dynamicId: row.dynamicId, top: '' } })
169
+          .then(data => {
170
+            console.log(data);
171
+            message.info('操作成功!');
172
+            getList({ pageNum: 1, pageSize: 10, showType: 'banner' });
173
+          })
174
+          .catch(err => {
175
+            console.log(err);
176
+            message.info(err.msg || err.message);
177
+          });
128 178
       },
129 179
     });
130
-  }
180
+  };
131 181
 
132 182
   //删除
133
-  const deleteCarouse = (contentId) => () => {
183
+  const deleteCarouse = contentId => () => {
134 184
     Modal.confirm({
135 185
       title: '确认删除此数据?',
136 186
       okText: '确定',
137 187
       cancelText: '取消',
138 188
       onOk() {
139
-        request({ ...apis.carsuseFigure.deleteExtendContent, urlData: { id: contentId } }).then((data) => {
140
-          message.info('操作成功!')
141
-          getList({ pageNum: 1, pageSize: 10, showType: 'banner' })
142
-        }).catch((err) => {
143
-          console.log(err)
144
-          message.info(err.msg || err.message)
145
-        })
189
+        request({ ...apis.carsuseFigure.deleteExtendContent, urlData: { id: contentId } })
190
+          .then(data => {
191
+            message.info('操作成功!');
192
+            getList({ pageNum: 1, pageSize: 10, showType: 'banner' });
193
+          })
194
+          .catch(err => {
195
+            console.log(err);
196
+            message.info(err.msg || err.message);
197
+          });
146 198
       },
147 199
     });
148
-  }
200
+  };
149 201
 
150 202
   //   停用启用
151
-  const changeStatus = (row) => () => {
152
-    console.log(row)
203
+  const changeStatus = row => () => {
204
+    console.log(row);
153 205
     if (row.status === 0) {
154
-
155 206
       Modal.confirm({
156 207
         title: '确认发布此数据?',
157 208
         okText: '确定',
158 209
         cancelText: '取消',
159 210
         onOk() {
160
-          row.status = 1
161
-          request({ ...apis.carsuseFigure.updataExtendContent, urlData: { id: row.contentId }, data: row, }).then((data) => {
162
-            message.info('操作成功!')
163
-            getList({ pageNum: 1, pageSize: 10, showType: 'banner' })
164
-          }).catch((err) => {
165
-            console.log(err)
166
-            row.status = 0
167
-            message.info(err.msg || err.message)
211
+          row.status = 1;
212
+          request({
213
+            ...apis.carsuseFigure.updataExtendContent,
214
+            urlData: { id: row.contentId },
215
+            data: row,
168 216
           })
217
+            .then(data => {
218
+              message.info('操作成功!');
219
+              getList({ pageNum: 1, pageSize: 10, showType: 'banner' });
220
+            })
221
+            .catch(err => {
222
+              console.log(err);
223
+              row.status = 0;
224
+              message.info(err.msg || err.message);
225
+            });
169 226
         },
170 227
       });
171 228
     } else if (row.status === 1) {
172
-
173 229
       Modal.confirm({
174 230
         title: '停用后不会再显示在小程序端',
175 231
         okText: '确定',
176 232
         cancelText: '取消',
177 233
         onOk() {
178
-          row.status = 0
179
-          request({ ...apis.carsuseFigure.updataExtendContent, urlData: { id: row.contentId }, data: row, }).then((data) => {
180
-            message.info('操作成功!')
181
-            getList({ pageNum: 1, pageSize: 10, showType: 'banner' })
182
-          }).catch((err) => {
183
-            console.log(err)
184
-            row.status = 1
185
-            message.info(err.msg || err.message)
234
+          row.status = 0;
235
+          request({
236
+            ...apis.carsuseFigure.updataExtendContent,
237
+            urlData: { id: row.contentId },
238
+            data: row,
186 239
           })
240
+            .then(data => {
241
+              message.info('操作成功!');
242
+              getList({ pageNum: 1, pageSize: 10, showType: 'banner' });
243
+            })
244
+            .catch(err => {
245
+              console.log(err);
246
+              row.status = 1;
247
+              message.info(err.msg || err.message);
248
+            });
187 249
         },
188 250
       });
189 251
     }
252
+  };
190 253
 
191
-  }
192
-
193
-  const changePageNum = (pageNumber) => {
194
-    getList({ pageNum: pageNumber, pageSize: 10, showType: 'banner', ...props.form.getFieldsValue() })
195
-  }
254
+  const changePageNum = pageNumber => {
255
+    getList({
256
+      pageNum: pageNumber,
257
+      pageSize: 10,
258
+      showType: 'banner',
259
+      ...props.form.getFieldsValue(),
260
+    });
261
+  };
196 262
 
197 263
   // 提交事件
198 264
   const handleSubmit = (e, props) => {
199 265
     e.preventDefault();
200 266
     props.form.validateFields((err, values) => {
201 267
       if (!err) {
202
-        console.log('提交数据: ', values)
203
-        getList({ pageNum: 1, pageSize: 10, ...values, showType: 'banner' })
268
+        console.log('提交数据: ', values);
269
+        getList({ pageNum: 1, pageSize: 10, ...values, showType: 'banner' });
204 270
       }
205 271
     });
206
-  }
272
+  };
207 273
 
208 274
   //重置搜索
209 275
   function handleReset() {
@@ -211,21 +277,12 @@ const header = (props) => {
211 277
     getList({ pageNum: 1, pageSize: 10, showType: 'banner' });
212 278
   }
213 279
 
214
-  const { getFieldDecorator } = props.form
280
+  const { getFieldDecorator } = props.form;
215 281
   return (
216
-
217 282
     <Card>
218 283
       <Form layout="inline" onSubmit={e => handleSubmit(e, props)}>
219
-        <Form.Item>
220
-          {getFieldDecorator('cityId')(
221
-            <SelectCity />,
222
-          )}
223
-        </Form.Item>
224
-        <Form.Item>
225
-          {getFieldDecorator('buildingId')(
226
-            <BuildSelect />,
227
-          )}
228
-        </Form.Item>
284
+        <Form.Item>{getFieldDecorator('cityId')(<SelectCity />)}</Form.Item>
285
+        <Form.Item>{getFieldDecorator('buildingId')(<BuildSelect />)}</Form.Item>
229 286
         <Form.Item>
230 287
           {getFieldDecorator('contentType')(
231 288
             <Select style={{ width: '180px' }} placeholder="类型">
@@ -258,25 +315,36 @@ const header = (props) => {
258 315
         </Form.Item>
259 316
         <Form.Item>
260 317
           <AuthButton name="admin.extendContent.search" noRight={null}>
261
-            <Button type="primary" htmlType="submit" className={styles.searchBtn}>
318
+            <Button type="primary" htmlType="submit" >
262 319
               搜索
263
-          </Button>
320
+            </Button>
264 321
           </AuthButton>
265 322
           <Button style={{ marginLeft: 8 }} onClick={handleReset}>
266 323
             重置
267
-            </Button>
324
+          </Button>
268 325
         </Form.Item>
269 326
       </Form>
270
-      <AuthButton name="admin.extendContent.post" noRight={null}>
271
-        <Button type='primary' onClick={toEditCarouse()} style={{margin:'20px 0'}}>新增</Button>
272
-      </AuthButton>
327
+      <div style={{textAlign:'right'}}>
328
+        <AuthButton name="admin.extendContent.post" noRight={null}>
329
+          <Button type="primary" onClick={toEditCarouse()} style={{ margin: '20px 0' }}>
330
+            新增
331
+          </Button>
332
+        </AuthButton>
333
+      </div>
334
+
273 335
       <Table dataSource={data.records} columns={columns} pagination={false} rowKey="contentId" />
274 336
       <div style={{ display: 'flex', justifyContent: 'flex-end', marginTop: '30px' }}>
275
-        <Pagination showQuickJumper defaultCurrent={1} total={data.total} onChange={changePageNum} current={data.current} />
337
+        <Pagination
338
+          showQuickJumper
339
+          defaultCurrent={1}
340
+          total={data.total}
341
+          onChange={changePageNum}
342
+          current={data.current}
343
+        />
276 344
       </div>
277 345
     </Card>
278
-  )
279
-}
346
+  );
347
+};
280 348
 const WrappedHeader = Form.create({ name: 'header' })(header);
281 349
 
282
-export default WrappedHeader
350
+export default WrappedHeader;

+ 20
- 19
src/pages/carouselFigure/editCarousel.jsx Näytä tiedosto

@@ -94,30 +94,27 @@ const Edit = props => {
94 94
   const XForm = createForm({ onValuesChange: handleFormValueChange });
95 95
 
96 96
   return props => {
97
-    const [tab, changeTab] = useState('basic');
98 97
     const { contentId } = props.location.query;
99 98
     const [data, setData] = useState({});
99
+    useEffect(() => {
100
+      if (contentId) {
101
+        isCanChoose = false;
102
+        // eslint-disable-next-line react-hooks/rules-of-hooks
100 103
 
101
-    if (contentId) {
102
-      isCanChoose = false;
103
-      // eslint-disable-next-line react-hooks/rules-of-hooks
104
-      useEffect(() => {
105 104
         getDetail(contentId);
106
-      }, []);
105
+      } else {
106
+        isCanChoose = true;
107
+      }
108
+    }, []);
107 109
 
108
-      // 查询列表
109
-      const getDetail = contentId => {
110
-        request({ ...apis.carsuseFigure.getExtendContent, urlData: { id: contentId } }).then(
111
-          data => {
112
-            console.log(data);
113
-            setExtraData1(data);
114
-            setData(data);
115
-          },
116
-        );
117
-      };
118
-    } else {
119
-      isCanChoose = true;
120
-    }
110
+    // 查询列表
111
+    const getDetail = contentId => {
112
+      request({ ...apis.carsuseFigure.getExtendContent, urlData: { id: contentId } }).then(data => {
113
+        console.log(data);
114
+        setExtraData1(data);
115
+        setData(data);
116
+      });
117
+    };
121 118
 
122 119
     const cancelPage = () => {
123 120
       router.push({
@@ -192,6 +189,10 @@ const Edit = props => {
192 189
             label: '直播活动详情',
193 190
             value: 'live',
194 191
           },
192
+          {
193
+            label: '无',
194
+            value: 'nothing',
195
+          },
195 196
         ],
196 197
         value: data.contentType,
197 198
         rules: [{ required: true, message: '请选择类型' }],