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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
<template>
<div>
<div style="display: flex;align-items: center;justify-content: space-between;" v-if="isShow">
<div>
<a-input-search v-model:value="value" placeholder="请输入商品名" style="width: 200px;margin-left: 20px;"
@search="onSearch" />
</div>
<div>
<a-button type="primary" block @click="onCreatePay">新建支付项</a-button>
</div>
</div>
<div style="margin-top: 10px;" v-if="isShow">
<a-table :dataSource="list" :columns="columns">
<template #bodyCell="{ column, record }">
<div v-if="column.key == 'picurl'">
<div style="display:flex;align-items: center;">
<a-image :width="100" :src="record.picurl" />
<div>{{ record.subject }}
</div>
</div>
</div>
<div v-else-if="column.key == 'status'">
<div v-if="record.status == 0" style="color: rgb(12, 191, 33);">
正常
</div>
<div v-else-if="record.status == 1" style="color: #e6a23c;">
预警额度
</div>
<div v-else style="color: #f56c6c;">
风控
</div>
</div>
<div v-if="column.key == 'tags'">
<a-button type="primary" @click="onEdit(record)">编辑</a-button>
<a-button type="primary" style="margin-left: 20px;" @click="onCopy(record)">支付链接</a-button>
<!-- <a-button type="primary" style="margin-left: 20px;">统计</a-button> -->
<a-popconfirm title="确定下架这条数据" ok-text="确定" cancel-text="取消" @confirm="onDel(record)">
<a-button type="primary" style="margin-left: 20px">删除</a-button>
</a-popconfirm>
</div>
<div v-if="column.key == 'time' && (record.starttime >= new Date())" style="color: #DDD222;">
{{moment(record.starttime).format('YYYY-MM-DD HH:mm')}}
</div>
<div v-else-if="column.key == 'time' && (record.starttime<new Date())" style="color: red;">
{{moment(record.starttime).format('YYYY-MM-DD HH:mm')}}
</div>
</template>
</a-table>
</div>
<div v-else>
<div style="display:flex">
<a-button class="small left" @click="onBack">
<template #icon>
<LeftOutlined />
</template>
</a-button>
</div>
<CreatePay @onBack="onBack"></CreatePay>
</div>
<a-modal v-model:visible="visible" title="编辑" @ok="handleOk" :width="1000">
<a-form :model="formState" name="basic" :label-col="{ span: 8 }" :wrapper-col="{ span: 16 }"
autocomplete="off" @finish="onFinish" @finishFailed="onFinishFailed">
<a-form-item label="选择商品" name="subject" :label-col="{ span: 2 }" labelAlign="left">
<div style="width:100%;display: flex;align-items: center;">
<a-select v-model:value="formState.subject" style="width: 120px"
:options="listArray.map((item:any, index:number) => ({ value: item.goodsid, label: item.subject, index: index }))" @change="onSelect">
</a-select>
</div>
</a-form-item>
<a-form-item label="项目描述" name="shortname" :label-col="{ span: 2 }" labelAlign="left">
<a-input v-model:value="formState.shortname" placeholder="请输入商品描述" />
</a-form-item>
<a-form-item label="支付金额" name="price" :label-col="{ span: 2 }" labelAlign="left">
<a-radio-group v-model:value="formState.paymentmodel" name="radioGroup" class="pay">
<div style="display: flex;height: 35px;">
<a-radio :value="0" style="width:150px;">商品默认金额</a-radio>
<a-input-number style="width:200px;height: 35px;" v-model:value="formState.payment" :formatter="value => `${value}`.replace(/\B(?=(\d{3})+(?!\d))/g, ',')"
:parser="value => value.replace(/\$\s?|(,*)/g, '')" :disabled="true"/>
<div style="width:50px;">元</div>
</div>
<div style="display: flex;height: 35px;margin-top: 20px;">
<a-radio :value="1" style="width:150px;">自定义金额</a-radio>
<a-input-number style="width:200px;height: 35px;" v-model:value="formState.paymentmodel" :formatter="value => `${value}`.replace(/\B(?=(\d{3})+(?!\d))/g, ',')"
:parser="value => value.replace(/\$\s?|(,*)/g, '')"/>
<div style="width:50px;">元</div>
</div>
</a-radio-group>
</a-form-item>
<a-form-item label="支付前填写手机号" name="price" :label-col="{ span: 3 }" labelAlign="left">
<div style="display: flex;">
<a-switch :checked="formState.fullphone === '0'" />
</div>
</a-form-item>
<a-form-item label="开始时间" name="price" :label-col="{ span: 2 }" labelAlign="left">
<div style="display:flex">
<a-date-picker v-model:value="value2" :format="dateFormat"
:disabledDate="disabledDate" />
<a-time-picker style="margin-left: 20px;" v-model:value="value3" format="HH:mm" />
</div>
</a-form-item>
<a-form-item label="结束时间" name="price" :label-col="{ span: 2 }" labelAlign="left">
<div style="display:flex">
<a-date-picker v-model:value="value4" :format="dateFormat"
:disabledDate="disabledDate" />
<a-time-picker style="margin-left: 20px;" v-model:value="value5" format="HH:mm" />
</div>
</a-form-item>
<a-form-item label="信息备注" name="price" :label-col="{ span: 2 }" labelAlign="left">
<div style="display:flex">
<a-input v-model:value="formState.remark" placeholder="请填写备注" />
</div>
</a-form-item>
</a-form>
</a-modal>
</div>
</template>
<script lang="ts" setup>
import { ref, defineExpose, onMounted, } from 'vue';
import { SelectProps,message } from 'ant-design-vue';
import { getUid } from '@/utils/userInfo'
import moment from 'moment';
import { onUpdateGoodsPay, onfindby, onSelectGoods,onfindWX,onfindAli,onDelectgoodpay} from '@/api/index'
import CreatePay from './components/createpay/index.vue'
import dayjs, { Dayjs } from 'dayjs';
import useClipboard from 'vue-clipboard3'
import { LeftOutlined} from "@ant-design/icons-vue";
const dateFormat = 'YYYY/MM/DD';
let listValue = ref<any>([])
const startvalue = ref<Dayjs>(dayjs('08:00', 'HH:mm'));
const endvalue = ref<Dayjs>(dayjs('10:00', 'HH:mm'));
const { toClipboard } = useClipboard()
const disabledDate = (current: any) => {
return current && current < moment().startOf("day")
}
const popupScroll = () => {
console.log('popupScroll');
};
const uid =getUid()
const value = ref<string>('');
const checkboxValue = ref<any>([])
const optionss = ref<Array<Object>>([])
const options = [...Array(25)].map((_, i) => ({ value: (i + 10).toString(36) + (i + 1) }))
let list = ref()
let listArray = ref<any>([])
let isShow = ref(true)
let formState = ref<any>({})
const optionsWithDisabled = [
{ value: '微信', label: '1' },
{ label: '2', value: '支付宝' },
{ label: '3', value: '京东白条' },
{ label: '4', value: '花呗' }
];
const columns = [
{
title: '支付项目名称',
dataIndex: 'picurl',
key: 'picurl',
},
{
title: '绑定商品编号',
dataIndex: 'goodsid',
key: 'goodsid',
},
{
title: '支付金额',
dataIndex: 'price',
key: 'price',
},
{
title: '状态',
dataIndex: 'status',
key: 'status',
},
{
title: '创始人',
dataIndex: 'userid',
key: 'userid',
},
{
title: '备注',
dataIndex: 'body',
key: 'body',
},
{
title: '操作',
dataIndex: 'tags',
key: 'tags',
},
{
title: '生效时间',
dataIndex: 'time',
key: 'time',
},
]
const visible = ref<boolean>(false);
const value2 = ref<any>(dayjs('2015/01/01', dateFormat))
const value3 = ref<any>()
const value4 = ref<any>(dayjs('2015/01/01', dateFormat))
const value5 = ref<any>()
const showModal = () => {
visible.value = true;
};
const handleOk =async(e: MouseEvent) => {
const starttime = (moment(value2.value.$d).format('YYYY-MM-DD'))+(moment(value3.value.$d).format('THH:mm:[00][Z]'))
const expireendtime = (moment(value4.value.$d).format('YYYY-MM-DD'))+(moment(value5.value.$d).format('THH:mm:[00][Z]'))
const uid =getUid()
const params={
id: formState.value.id,
goodsid: formState.value.goodspayditch[0].goodsid,
paymentmodel: formState.value.paymentmodel*100,
payment: formState.value.payment *100,
fullphone:formState.value.fullphone,
expiremodel:formState.value.expiremodel,
expireendtime:expireendtime,
expiremillisecond: formState.value.expiremillisecond,
starttime: starttime,
subject:formState.value.subject,
uid: uid,
status: formState.value.status,
shortname: formState.value.shortname,
remark: formState.value.remark,
goodspayditch: formState.value.goodspayditch.map((item:any)=>{
return {
id:item.id,
payname:item.payname,
optpay:item.optpay,
random:item.random,
appointpay:item.appointpay
}
})
}
const data:any = await onUpdateGoodsPay(params)
if(data.state == 1){
visible.value = false;
onSearch()
}
};
const onEdit = (e: any) => {
formState.value =e
value2.value = dayjs(moment(formState.value.starttime).format(('YYYY/MM/DD')), dateFormat)
value3.value = dayjs(moment(formState.value.starttime).format(('HH:mm')), 'HH:mm')
value4.value = dayjs(moment(formState.value.expireendtime).format(('YYYY-MM-DD')), dateFormat)
value5.value = dayjs(moment(formState.value.expireendtime).format(('HH:mm')), 'HH:mm')
showModal()
}
const onSearch = async () => {
const params = {
status: "0",
name: value.value,
uid: getUid()
}
const data = await onfindby(params)
list.value = data.data
};
const onBack = (e: Number) => {
isShow.value = !isShow.value;
onSearch()
};
const onCreatePay = async () => {
isShow.value = !isShow.value
}
const onCopy = async(e:any) => {
const value = localStorage.getItem('url') || ''
try {
await toClipboard(`${value}/#/?ditch=${uid}&goodsid=${e.id}&phone=${e.fullphone}`)
message.success('复制成功')
} catch (e) {
console.error(e)
}
}
const onSet = async(index:string)=>{
const uid =getUid()
let data:any ={}
if (index == '1') {
data = await onfindWX(uid);
} else if (index == '2') {
data = await onfindAli(uid);
}
list.value = data.data;
}
const onDel = async (e: any) => {
const prarms = {
uid:getUid(),
goodspayid:e.id
}
const data:any = await onDelectgoodpay(prarms)
if(data.state == 1){
await onSearch()
}
}
const onFinish = (values: any) => {
console.log('Success:', values);
};
const onFinishFailed = (errorInfo: any) => {
console.log('Failed:', errorInfo);
};
const init = async () => {
const uid = getUid()
const data = await onSelectGoods(uid)
listArray.value = data.data
}
const onSelectCheckboxValue = (e: any, index: any) => {
checkboxValue.value[index] = e
}
const onSelect =(e:any,label:any,index:any)=>{
console.log(e,'e',label,index,formState,'formState');
}
onMounted(async () => {
onSearch()
init()
})
defineExpose({
size: ref<SelectProps['size']>('middle'),
value1: ref('a1'),
options,
value,
isShow,
visible,
formState,
checkboxValue,
optionsWithDisabled,
dateFormat,
startvalue,
endvalue,
listValue,
list,
value2,
value3,
value4,
value5,
uid,
onSet,
onSearch,
columns,
onEdit,
optionss,
onCreatePay,
onBack,
onCopy,
onDel,
showModal,
handleOk,
onSelect,
disabledDate,
onFinish,
onFinishFailed,
onSelectCheckboxValue
})
</script>
<style lang="less" scoped>
.small {
border: none;
height: 30px;
width: 50px;
}
.left {
border-left: 1px solid rgb(236, 236, 236);
border-top: 1px solid rgb(236, 236, 236);
border-bottom: 1px solid rgb(236, 236, 236);
border-right-width: 80%;
border-right: 1px solid rgb(236, 236, 236);
border-bottom-left-radius: 25px;
border-top-left-radius: 25px;
}
</style>