5613d4bR328">328
 
334 329
         function displayornot() {
335
-            $('#buy').show();
330
+            var photoInfo = swipePhotos[curIdx];
331
+            var display_payment_btn = photoInfo['display_payment_btn'];
332
+            if (photoInfo['display_payment_btn'] && (typeof photoInfo['porder'].m_photo_url == 'undefined' || photoInfo['porder'].m_photo_url == '')) {
333
+                $('#buy').show();
334
+            } else {
335
+                $('#buy').hide();
336
+            }
336 337
             $('#mask-thump').show();
337 338
         }
338 339
 
@@ -361,8 +362,53 @@
361 362
             });
362 363
         })
363 364
 
365
+        function order_query(orderId, photoId) {
366
+            $.ajax({
367
+                url: '/mini/order_query',
368
+                type: 'POST',
369
+                data: {
370
+                    order_id: orderId,
371
+                },
372
+                timeout: 5000,
373
+                cache: true,
374
+                success: function (res) {
375
+                    if (res.status == 200) {
376
+                        window.clearTimeout(orderQueryTimer);
377
+                        // 支付成功,获取 porder
378
+                        $.ajax({
379
+                            url: 'f/bought',
380
+                            data: {
381
+                                user_id: '{{ request.GET.user_id }}',
382
+                                photo_id: photoId,
383
+                            },
384
+                            success: function (res) {
385
+                                if (res.data.status == 200) {
386
+                                    var swipeItem = swipeItems[curIdx];
387
+                                    swipeItem['src'] = res.data.porder.m_photo_url || swipeItem['src'];
388
+                                    swipeItems[curIdx] = swipeItem;
389
+
390
+                                    $('.pswp__img')[0].src = swipeItem['src'];
391
+
392
+                                    var photoInfo = swipePhotos[curIdx];
393
+                                    photoInfo['porder'] = res.data.porder;
394
+                                    swipePhotos[curIdx] = photoInfo;
395
+                                }
396
+                            }
397
+                        })
398
+                    } else {
399
+                        orderQueryTimer = window.setTimeout(function () {
400
+                            order_query(orderId, photoId);
401
+                        }, 1000)
402
+                    }
403
+                },
404
+                error: function (res) {
405
+                }
406
+            });
407
+        }
408
+
364 409
         $('#nomark').click(function () {
365 410
             var photoInfo = swipePhotos[curIdx];
411
+            var photoId = photoInfo.photo_id;
366 412
 
367 413
             $.ajax({
368 414
                 url: '/mini/order_create',
@@ -370,7 +416,7 @@
370 416
                 data: {
371 417
                     group_id: photoInfo.group_id,
372 418
                     user_id: photoInfo.user_id,
373
-                    photo_id: photoInfo.photo_id,
419
+                    photo_id: photoId,
374 420
                     photo_type: 'nomark',
375 421
                     body: '去除水印',
376 422
                     total_fee: 1,
@@ -380,7 +426,7 @@
380 426
                 cache: true,
381 427
                 success: function (res) {
382 428
                     if (res.status == 200) {
383
-                        var order_id = res.data.order_id;
429
+                        orderId = res.data.order_id;
384 430
                         var wxpay_params = res.data.wxpay_params;
385 431
                         //点击微信支付后,调取统一下单接口生成微信小程序支付需要的支付参数
386 432
                         var params = '?timeStamp=' + wxpay_params.timeStamp + '&nonceStr=' + wxpay_params.nonceStr
@@ -390,6 +436,8 @@
390 436
                         var path = '/pages/wxpay/wxpay' + params;
391 437
                         //通过JSSDK的api使小程序跳转到指定的小程序页面
392 438
                         wx.miniProgram.navigateTo({url: path});
439
+
440
+                        order_query(orderId, photoId);
393 441
                     }
394 442
                 },
395 443
                 error: function (res) {

+ 2 - 0
pai2/urls.py

@@ -80,6 +80,8 @@ urlpatterns += [
80 80
     url(r'^mini/userinfo$', mini_views.get_userinfo_api, name='get_userinfo_api2'),  # 获取用户信息
81 81
     url(r'^mini/order_create$', pay_views.wx_order_create_api, name='wx_order_create_api'),  # 订单创建
82 82
     url(r'^mini/order_query$', pay_views.wx_order_query_api, name='wx_order_query_api'),  # 订单查询补单
83
+
84
+    url(r'^f/bought$', group_views.lensman_photo_bought, name='lensman_photo_bought'),  # 摄影师照片已购买
83 85
 ]
84 86
 
85 87
 # Wire up our API using automatic URL routing.

Kodo/kodo - Gogs: Go Git Service

1 Ревизии (b4edba1e4c2b39ebe59e468f9b0a1f2b132f5bc1)

Автор SHA1 Съобщение Дата
  Brightcells b95db9c5c3 Basic gis command преди 8 години