5613d4bR328">328
function displayornot() {
- $('#buy').show();
+ var photoInfo = swipePhotos[curIdx];
+ var display_payment_btn = photoInfo['display_payment_btn'];
+ if (photoInfo['display_payment_btn'] && (typeof photoInfo['porder'].m_photo_url == 'undefined' || photoInfo['porder'].m_photo_url == '')) {
+ $('#buy').show();
+ } else {
+ $('#buy').hide();
+ }
$('#mask-thump').show();
}
@@ -361,8 +362,53 @@
});
})
+ function order_query(orderId, photoId) {
+ $.ajax({
+ url: '/mini/order_query',
+ type: 'POST',
+ data: {
+ order_id: orderId,
+ },
+ timeout: 5000,
+ cache: true,
+ success: function (res) {
+ if (res.status == 200) {
+ window.clearTimeout(orderQueryTimer);
+ // 支付成功,获取 porder
+ $.ajax({
+ url: 'f/bought',
+ data: {
+ user_id: '{{ request.GET.user_id }}',
+ photo_id: photoId,
+ },
+ success: function (res) {
+ if (res.data.status == 200) {
+ var swipeItem = swipeItems[curIdx];
+ swipeItem['src'] = res.data.porder.m_photo_url || swipeItem['src'];
+ swipeItems[curIdx] = swipeItem;
+
+ $('.pswp__img')[0].src = swipeItem['src'];
+
+ var photoInfo = swipePhotos[curIdx];
+ photoInfo['porder'] = res.data.porder;
+ swipePhotos[curIdx] = photoInfo;
+ }
+ }
+ })
+ } else {
+ orderQueryTimer = window.setTimeout(function () {
+ order_query(orderId, photoId);
+ }, 1000)
+ }
+ },
+ error: function (res) {
+ }
+ });
+ }
+
$('#nomark').click(function () {
var photoInfo = swipePhotos[curIdx];
+ var photoId = photoInfo.photo_id;
$.ajax({
url: '/mini/order_create',
@@ -370,7 +416,7 @@
data: {
group_id: photoInfo.group_id,
user_id: photoInfo.user_id,
- photo_id: photoInfo.photo_id,
+ photo_id: photoId,
photo_type: 'nomark',
body: '去除水印',
total_fee: 1,
@@ -380,7 +426,7 @@
cache: true,
success: function (res) {
if (res.status == 200) {
- var order_id = res.data.order_id;
+ orderId = res.data.order_id;
var wxpay_params = res.data.wxpay_params;
//点击微信支付后,调取统一下单接口生成微信小程序支付需要的支付参数
var params = '?timeStamp=' + wxpay_params.timeStamp + '&nonceStr=' + wxpay_params.nonceStr
@@ -390,6 +436,8 @@
var path = '/pages/wxpay/wxpay' + params;
//通过JSSDK的api使小程序跳转到指定的小程序页面
wx.miniProgram.navigateTo({url: path});
+
+ order_query(orderId, photoId);
}
},
error: function (res) {
@@ -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. |