• uniapp订单循环列表倒计时


    效果图片

    请添加图片描述

    插件uni-countdown

    地址

    代码

    <template>
    	<view class="">
    		
    		<view class="item" v-for="(item, index) in listData" :key="index">
    			{ item.state_text }}
    			
    				
    			 -->
    			<uni-countdown :showDay="false" :showHour="true" :fontSize="12" color="#F81111" splitorColor='#F81111'
    				:minute="item.minute" :second="item.second" style="">uni-countdown>
    		view>
    	view>
    template>
    
    <script>
    	export default {
    		data() {
    			return {
    				// listData: [],
    				//定义一个假数据
    				listData: [
    					{
    						"order_id": 70,
    						"order_no": "2023101751999997",
    						"total_price": "345.00",
    						"order_price": "345.00",
    						"coupon_id": 0,
    						"coupon_money": "0.00",
    						"coupon_id_sys": 0,
    						"coupon_money_sys": "0.00",
    						"points_money": "0.00",
    						"points_num": 0,
    						"pay_price": "345.00",
    						"update_price": {
    							"symbol": "+",
    							"value": "0.00"
    						},
    						"fullreduce_money": 0,
    						"fullreduce_remark": "",
    						"product_reduce_money": "0.00",
    						"buyer_remark": "",
    						"pay_type": {
    							"text": "微信支付",
    							"value": 20
    						},
    						"pay_source": "",
    						"pay_status": {
    							"text": "待付款",
    							"value": 10
    						},
    						"pay_time": 0,
    						"pay_end_time": 1697538731,
    						"delivery_type": {
    							"text": "快递配送",
    							"value": 10
    						},
    						"extract_store_id": 0,
    						"extract_clerk_id": 0,
    						"express_price": "0.00",
    						"express_id": 0,
    						"express_company": "",
    						"express_no": "",
    						"delivery_status": {
    							"text": "待发货",
    							"value": 10
    						},
    						"delivery_time": 0,
    						"receipt_status": {
    							"text": "待收货",
    							"value": 10
    						},
    						"receipt_time": 0,
    						"order_status": {
    							"text": "进行中",
    							"value": 10
    						},
    						"points_bonus": 0,
    						"is_settled": 0,
    						"transaction_id": "",
    						"is_comment": 0,
    						"order_source": 10,
    						"user_id": 1,
    						"is_refund": 0,
    						"assemble_status": 0,
    						"activity_id": 0,
    						"is_agent": 1,
    						"shop_supplier_id": 3,
    						"supplier_money": "345.00",
    						"sys_money": "0.00",
    						"room_id": 0,
    						"cancel_remark": "",
    						"virtual_auto": 0,
    						"virtual_content": "",
    						"balance": "0.00",
    						"online_money": "0.00",
    						"refund_money": "0.00",
    						"trade_no": "2023101751999997",
    						"wx_delivery_status": 10,
    						"is_delete": 0,
    						"app_id": 10001,
    						"create_time": "2023-10-17 18:22:11",
    						"product_id": 12,
    						"category_id": 8,
    						"name": "智能设备",
    						"spec_name": "小时",
    						"logo_id": 13,
    						"storage": "local",
    						"save_name": "20230926/478df4597d5266ccb33c5fb1f1b5782c.png",
    						"file_url": "",
    						"file_name": "20230926155419ee8325089.png",
    						"pay_end_time_format": "6分钟",
    						"file_path": "http://bangke.yunjingwl.com/uploads/20230926/478df4597d5266ccb33c5fb1f1b5782c.png",
    						"product": [{
    							"order_product_id": 44,
    							"product_id": 12,
    							"product_name": "测试456",
    							"image_id": 37,
    							"deduct_stock_type": 10,
    							"spec_type": 10,
    							"spec_sku_id": "0",
    							"product_sku_id": 19,
    							"product_attr": "",
    							"product_no": "123",
    							"product_price": "345.00",
    							"line_price": "345.00",
    							"product_weight": 34553435,
    							"is_user_grade": 0,
    							"grade_ratio": 0,
    							"grade_product_price": "0.00",
    							"grade_total_money": "0.00",
    							"coupon_money_sys": "0.00",
    							"coupon_money": "0.00",
    							"points_money": "0.00",
    							"points_num": 0,
    							"points_bonus": 0,
    							"total_num": 1,
    							"total_price": "345.00",
    							"total_pay_price": "345.00",
    							"supplier_money": "345.00",
    							"sys_money": "0.00",
    							"fullreduce_money": "0.00",
    							"product_reduce_money": "0.00",
    							"is_agent": 0,
    							"is_ind_agent": 0,
    							"agent_money_type": 10,
    							"first_money": "0.00",
    							"second_money": "0.00",
    							"third_money": "0.00",
    							"is_comment": 0,
    							"order_id": 70,
    							"user_id": 1,
    							"product_source_id": 0,
    							"sku_source_id": 0,
    							"bill_source_id": 0,
    							"virtual_content": "",
    							"app_id": 10001,
    							"create_time": "2023-10-17 18:22:11",
    							"image": {
    								"file_id": 37,
    								"storage": "local",
    								"group_id": 0,
    								"file_url": "",
    								"save_name": "20231009/cfd4f6da754767b47f60197f1dd3e40b.png",
    								"file_name": "2023100910385524eb17726.png",
    								"file_size": 890511,
    								"file_type": "image",
    								"real_name": "371fa09067c9b88007071d53a38303a4@2x.png",
    								"extension": "png",
    								"is_user": 0,
    								"is_recycle": 0,
    								"shop_supplier_id": 3,
    								"is_delete": 0,
    								"app_id": 10001,
    								"create_time": "2023-10-09 10:38:55",
    								"update_time": 0,
    								"file_path": "http://bangke.yunjingwl.com/uploads/20231009/cfd4f6da754767b47f60197f1dd3e40b.png"
    							}
    						}],
    						"supplier": {
    							"shop_supplier_id": 3,
    							"name": "测试3",
    							"user_id": 3
    						},
    						"advance": null,
    						"state_text": "待付款",
    						"order_source_text": "普通",
    						"pay_end_time_text": "2023-10-17 18:32:11"
    					},
    					 {
    						"order_id": 69,
    						"order_no": "2023101799545110",
    						"total_price": "100.00",
    						"order_price": "100.00",
    						"coupon_id": 0,
    						"coupon_money": "0.00",
    						"coupon_id_sys": 0,
    						"coupon_money_sys": "0.00",
    						"points_money": "0.00",
    						"points_num": 0,
    						"pay_price": "100.00",
    						"update_price": {
    							"symbol": "+",
    							"value": "0.00"
    						},
    						"fullreduce_money": 0,
    						"fullreduce_remark": "",
    						"product_reduce_money": "0.00",
    						"buyer_remark": "",
    						"pay_type": {
    							"text": "微信支付",
    							"value": 20
    						},
    						"pay_source": "",
    						"pay_status": {
    							"text": "待付款",
    							"value": 10
    						},
    						"pay_time": 0,
    						"pay_end_time": 1697537876,
    						"delivery_type": {
    							"text": "快递配送",
    							"value": 10
    						},
    						"extract_store_id": 0,
    						"extract_clerk_id": 0,
    						"express_price": "0.00",
    						"express_id": 0,
    						"express_company": "",
    						"express_no": "",
    						"delivery_status": {
    							"text": "待发货",
    							"value": 10
    						},
    						"delivery_time": 0,
    						"receipt_status": {
    							"text": "待收货",
    							"value": 10
    						},
    						"receipt_time": 0,
    						"order_status": {
    							"text": "已取消",
    							"value": 20
    						},
    						"points_bonus": 0,
    						"is_settled": 0,
    						"transaction_id": "",
    						"is_comment": 0,
    						"order_source": 10,
    						"user_id": 1,
    						"is_refund": 0,
    						"assemble_status": 0,
    						"activity_id": 0,
    						"is_agent": 1,
    						"shop_supplier_id": 1,
    						"supplier_money": "100.00",
    						"sys_money": "0.00",
    						"room_id": 0,
    						"cancel_remark": "",
    						"virtual_auto": 0,
    						"virtual_content": "",
    						"balance": "0.00",
    						"online_money": "0.00",
    						"refund_money": "0.00",
    						"trade_no": "2023101799545110",
    						"wx_delivery_status": 10,
    						"is_delete": 0,
    						"app_id": 10001,
    						"create_time": "2023-10-17 18:07:56",
    						"product_id": 2,
    						"category_id": 3,
    						"name": "热门分类",
    						"spec_name": "小时",
    						"logo_id": 1,
    						"storage": "local",
    						"save_name": "20230926/0a1de3d0cf3ee4e7db4d84af5995237f.png",
    						"file_url": "",
    						"file_name": "202309261307338cdd12520.png",
    						"pay_end_time_format": "",
    						"file_path": "http://bangke.yunjingwl.com/uploads/20230926/0a1de3d0cf3ee4e7db4d84af5995237f.png",
    						"product": [{
    							"order_product_id": 43,
    							"product_id": 2,
    							"product_name": "哈哈哈",
    							"image_id": 15,
    							"deduct_stock_type": 10,
    							"spec_type": 10,
    							"spec_sku_id": "0",
    							"product_sku_id": 2,
    							"product_attr": "",
    							"product_no": "123",
    							"product_price": "100.00",
    							"line_price": "1000.00",
    							"product_weight": 1,
    							"is_user_grade": 0,
    							"grade_ratio": 0,
    							"grade_product_price": "0.00",
    							"grade_total_money": "0.00",
    							"coupon_money_sys": "0.00",
    							"coupon_money": "0.00",
    							"points_money": "0.00",
    							"points_num": 0,
    							"points_bonus": 0,
    							"total_num": 1,
    							"total_price": "100.00",
    							"total_pay_price": "100.00",
    							"supplier_money": "100.00",
    							"sys_money": "0.00",
    							"fullreduce_money": "0.00",
    							"product_reduce_money": "0.00",
    							"is_agent": 0,
    							"is_ind_agent": 0,
    							"agent_money_type": 10,
    							"first_money": "0.00",
    							"second_money": "0.00",
    							"third_money": "0.00",
    							"is_comment": 0,
    							"order_id": 69,
    							"user_id": 1,
    							"product_source_id": 0,
    							"sku_source_id": 0,
    							"bill_source_id": 0,
    							"virtual_content": "",
    							"app_id": 10001,
    							"create_time": "2023-10-17 18:07:56",
    							"image": {
    								"file_id": 15,
    								"storage": "local",
    								"group_id": 0,
    								"file_url": "",
    								"save_name": "20230926/98b35fa4f297b138ddf44899da654c5f.jpg",
    								"file_name": "20230926160205343ec9076.jpg",
    								"file_size": 267265,
    								"file_type": "image",
    								"real_name": "1695715325238_wx_camera_1695603440923.jpg",
    								"extension": "jpg",
    								"is_user": 1,
    								"is_recycle": 0,
    								"shop_supplier_id": 0,
    								"is_delete": 0,
    								"app_id": 10001,
    								"create_time": "2023-09-26 16:02:05",
    								"update_time": 0,
    								"file_path": "http://bangke.yunjingwl.com/uploads/20230926/98b35fa4f297b138ddf44899da654c5f.jpg"
    							}
    						}],
    						"supplier": {
    							"shop_supplier_id": 1,
    							"name": "测试1-1",
    							"user_id": 1
    						},
    						"advance": null,
    						"state_text": "已取消",
    						"order_source_text": "普通",
    						"pay_end_time_text": "2023-10-17 18:17:56"
    					}
    				]
    			}
    		},
    		mounted() {
    			/*获取订单列表*/
    			this.getData();
    
    		},
    		methods: {
    			handleTimeup(index) {
    				this.listData[index].state_text = '服务已取消';
    			},
    			/*获取数据*/
    			getData() {
    				let self = this;
    				self.loading = true;
    				let dataType = self.dataType;
    				self._get(
    					'user.order/lists', {
    						dataType: dataType,
    						page: self.page,
    						pay_source: self.getPlatform(),
    						list_rows: self.list_rows
    					},
    					function(res) {
    						self.loading = false;
    						self.listData = self.listData.concat(res.data.list.data);
    
    
    						console.log(res.data.list.data, '返回数据1111111111');
    
    						let result = res.data.list.data.map(item => {
    							let {
    								day,
    								hour,
    								minute,
    								second
    							} = self.countdowm(item.pay_end_time)
    
    
    							// console.log(item.pay_end_time,'pay_end_time时间戳');
    
    
    							// let {
    							// 	day: deliveryday,
    							// 	hour: deliveryhour,
    							// 	minute: deliveryminute,
    							// 	second: deliverysecond
    							// } = self.countdowm(item.delivery_end_time)
    
    							// let {
    							// 	day: receiptday,
    							// 	hour: receipthour,
    							// 	minute: receiptminute,
    							// 	second: receiptsecond
    							// } = self.countdowm(item.receipt_end_time)
    
    							item.day = day
    							item.hour = hour
    							item.minute = minute
    							item.second = second
    
    							// console.log(day, 'day');
    							// console.log(hour, 'hour');
    							// console.log(minute, 'minute');
    							// console.log(second, 'second');
    
    							// item.deliveryday = deliveryday
    							// item.deliveryhour = deliveryhour
    							// item.deliveryminute = deliveryminute
    							// item.deliverysecond = deliverysecond
    
    							// item.receiptday = receiptday
    							// item.receipthour = receipthour
    							// item.receiptminute = receiptminute
    							// item.receiptsecond = receiptsecond
    
    							// if(item.product.refund && item.product.refund.refund_end_time){
    							// 	let {
    							// 		day: refundday,
    							// 		hour: refundhour,
    							// 		minute: refundminute,
    							// 		second: refundsecond
    							// 	} = this.countdowm(item.product.refund.refund_end_time)	
    							// 	item.refundday = refundday
    							// 	item.refundhour = refundhour
    							// 	item.refundminute = refundminute
    							// 	item.refundsecond = refundsecond
    							// 	return item
    							// }
    
    							return item
    						})
    						// 格式化后结果,赋值给data里面listData数组,然后再view循环即可
    						self.listData = result;
    					}
    				);
    			},
    			// 计算时分秒	格式化
    			countdowm(timestamp) {
    				let nowTime = new Date();
    				let endTime = new Date(timestamp * 1000);
    				let t = endTime.getTime() - nowTime.getTime();
    				console.log(t, 'ttttttttttttttt');
    				if (t > 0) {
    					let day = Math.floor(t / 86400000);
    					let hour = Math.floor((t / 3600000) % 24);
    					let min = Math.floor((t / 60000) % 60);
    					let sec = Math.floor((t / 1000) % 60);
    					return {
    						day,
    						hour,
    						minute: min,
    						second: sec
    					}
    				} else {
    					return {
    						day: 0,
    						hour: 0,
    						minute: 0,
    						second: 0
    					}
    				}
    			},
    		}
    	}
    script>
    
    <style>
    	.item{
    		width: 100%;
    		height: 100rpx;
    		border: 1rpx solid blue;
    		margin-bottom: 100rpx;
    	}
    style>
    
    • 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
    • 372
    • 373
    • 374
    • 375
    • 376
    • 377
    • 378
    • 379
    • 380
    • 381
    • 382
    • 383
    • 384
    • 385
    • 386
    • 387
    • 388
    • 389
    • 390
    • 391
    • 392
    • 393
    • 394
    • 395
    • 396
    • 397
    • 398
    • 399
    • 400
    • 401
    • 402
    • 403
    • 404
    • 405
    • 406
    • 407
    • 408
    • 409
    • 410
    • 411
    • 412
    • 413
    • 414
    • 415
    • 416
    • 417
    • 418
    • 419
    • 420
    • 421
    • 422
    • 423
    • 424
    • 425
    • 426
    • 427
    • 428
    • 429
    • 430
    • 431
    • 432
    • 433
    • 434
    • 435
    • 436
    • 437
    • 438
    • 439
    • 440
    • 441
    • 442
    • 443
    • 444
    • 445
    • 446
    • 447
    • 448
    • 449
    • 450
    • 451
    • 452
    • 453
    • 454
    • 455
    • 456
    • 457
    • 458
    • 459
    • 460
    • 461
    • 462
    • 463
    • 464
    • 465
    • 466
    • 467
    • 468
    • 469
    • 470
    • 471
    • 472
    • 473
    • 474
    • 475
    • 476
    • 477
    • 478
    • 479
    • 480
    • 481
    • 482
    • 483
    • 484
    • 485
    • 486
    • 487
    • 488
    • 489
    • 490
    • 491
    • 492
    • 493

    最后

    感觉文章好的话记得点个心心和关注和收藏,有错的地方麻烦指正一下,如果需要转载,请标明出处,多谢!!!

  • 相关阅读:
    干货 | 如何在子查询和联接之间选择
    YOLOv5-理论部分
    cloud的初级使用方法
    2023年11月数据库流行度最新排名
    CSV 与 Excel(.xls)-有什么区别?
    MongoDB UPDATE使用$setOnInsert为新插入数据设置默认值
    Android---Android 是如何通过 Activity 进行交互的
    裸奔的前端绿皮车
    ChatGPT can make mistakes. Consider checking important information.
    超强,图解最常用的 10 个机器学习算法!建议收藏
  • 原文地址:https://blog.csdn.net/m0_49714202/article/details/133890108