Commit 0904f37f2c7b62a3a165c023d8293771c259acf3

Authored by yvan.ni
1 parent da5d0c0f

pos收银支付的优化

packageC/pages/presell/cart/cart2.js
@@ -213,7 +213,7 @@ Page({ @@ -213,7 +213,7 @@ Page({
213 util_pay.set_fir(); 213 util_pay.set_fir();
214 214
215 //-- 通联的第三方支付的返回优化 -- 215 //-- 通联的第三方支付的返回优化 --
216 - ut.is_pay_ok("/pages/payment/pay_success/pay_success?type=2&order_sn=" + this.data.ok_order_sn,null,function (){ 216 + ut.is_pay_ok("/pages/payment/pay_success/pay_success?type=2&order_sn=" + this.data.ok_order_sn,'none',function (){
217 if(!th.data.ok_order_sn) return false; 217 if(!th.data.ok_order_sn) return false;
218 getApp().request.promiseGet("/api/weshop/order/page", 218 getApp().request.promiseGet("/api/weshop/order/page",
219 {data:{store_id:os.stoid,parent_sn:th.data.ok_order_sn}}).then(res=>{ 219 {data:{store_id:os.stoid,parent_sn:th.data.ok_order_sn}}).then(res=>{
packageD/pages/user/deposit/prepaid/msg/msg.js
@@ -68,10 +68,7 @@ Page({ @@ -68,10 +68,7 @@ Page({
68 }) 68 })
69 }, 69 },
70 homepage:function(){ 70 homepage:function(){
71 -  
72 - wx.navigateTo({  
73 - url: "../../../../index/index/index",  
74 - }) 71 + getApp().goto('/pages/index/index/index');
75 }, 72 },
76 73
77 /** 74 /**
packageD/pages/user/deposit/prepaid/prepaid.js
@@ -205,7 +205,7 @@ Page({ @@ -205,7 +205,7 @@ Page({
205 var store_id = os.stoid; 205 var store_id = os.stoid;
206 t_pay.set_pay_url("/api/weshop/order/pay/createRechargeOrder"); 206 t_pay.set_pay_url("/api/weshop/order/pay/createRechargeOrder");
207 207
208 - th.data.ok_order_sn=parentSn; 208 + e.data.ok_order_sn=parentSn;
209 t_pay.pay({ 209 t_pay.pay({
210 parentSn: parentSn, 210 parentSn: parentSn,
211 store_id: store_id 211 store_id: store_id
packageD/pages/user/integral/integral.js
@@ -345,7 +345,7 @@ Page({ @@ -345,7 +345,7 @@ Page({
345 t_pay.set_fir(); 345 t_pay.set_fir();
346 346
347 //-- 通联的第三方支付的返回优化 -- 347 //-- 通联的第三方支付的返回优化 --
348 - ut.is_pay_ok("/packageD/pages/user/deposit/prepaid/msg/msg",null,function (){ 348 + ut.is_pay_ok("/packageD/pages/user/integral/msg/msg",'none',function (){
349 349
350 console.log('show--11') 350 console.log('show--11')
351 console.log(th.data.ok_order_sn); 351 console.log(th.data.ok_order_sn);
@@ -359,7 +359,7 @@ Page({ @@ -359,7 +359,7 @@ Page({
359 //支付支付,返回首页 359 //支付支付,返回首页
360 ut.m_toast('支付成功'); 360 ut.m_toast('支付成功');
361 setTimeout(()=>{ 361 setTimeout(()=>{
362 - getApp().re_to("/packageD/pages/user/deposit/prepaid/msg/msg"); 362 + getApp().re_to("/packageD/pages/user/integral/msg/msg");
363 },1000) 363 },1000)
364 364
365 }else{ 365 }else{
packageD/pages/user/integral/msg/msg.js
@@ -68,7 +68,6 @@ Page({ @@ -68,7 +68,6 @@ Page({
68 }) 68 })
69 }, 69 },
70 homepage:function(){ 70 homepage:function(){
71 -  
72 getApp().goto('/pages/index/index/index'); 71 getApp().goto('/pages/index/index/index');
73 }, 72 },
74 73
packageE/pages/cart/cart2/cart2.js
@@ -285,7 +285,7 @@ Page({ @@ -285,7 +285,7 @@ Page({
285 util_pay.set_fir(); 285 util_pay.set_fir();
286 286
287 //-- 通联的第三方支付的返回优化 -- 287 //-- 通联的第三方支付的返回优化 --
288 - ut.is_pay_ok("/pages/payment/pay_success/pay_success?type=2&order_sn=" + this.data.ok_order_sn,null,function (){ 288 + ut.is_pay_ok("/pages/payment/pay_success/pay_success?type=2&order_sn=" + this.data.ok_order_sn,"none",function (){
289 //支付信息会先记录着 289 //支付信息会先记录着
290 if(!th.data.ok_order_sn) return false; 290 if(!th.data.ok_order_sn) return false;
291 getApp().request.promiseGet("/api/weshop/order/page", 291 getApp().request.promiseGet("/api/weshop/order/page",
packageE/pages/cart/cart2_inte/cart2_inte.js
@@ -225,7 +225,7 @@ Page({ @@ -225,7 +225,7 @@ Page({
225 util_pay.set_fir(); 225 util_pay.set_fir();
226 226
227 //-- 通联的第三方支付的返回优化 -- 227 //-- 通联的第三方支付的返回优化 --
228 - ut.is_pay_ok("/pages/payment/pay_success/pay_success?type=2&order_sn=" + th.data.ok_order_sn,null,function (){ 228 + ut.is_pay_ok("/pages/payment/pay_success/pay_success?type=2&order_sn=" + th.data.ok_order_sn,"none",function (){
229 if(!th.data.ok_order_sn) return false; 229 if(!th.data.ok_order_sn) return false;
230 getApp().request.promiseGet("/api/weshop/order/page", 230 getApp().request.promiseGet("/api/weshop/order/page",
231 {data:{store_id:os.stoid,parent_sn:th.data.ok_order_sn}}).then(res=>{ 231 {data:{store_id:os.stoid,parent_sn:th.data.ok_order_sn}}).then(res=>{
packageE/pages/user/cardinfo/cardinfo.js
@@ -696,28 +696,39 @@ Page({ @@ -696,28 +696,39 @@ Page({
696 t_pay.set_fir(); 696 t_pay.set_fir();
697 697
698 //-- 通联的第三方支付的返回优化 -- 698 //-- 通联的第三方支付的返回优化 --
699 - ut.is_pay_ok("/pages/payment/pay_success/pay_success?type=2&order_sn=" + this.data.ok_order_sn,null,function (){ 699 + ut.is_pay_ok("func",'none',function (){
  700 +
  701 + console.log('1111');
  702 + console.log(th.data.ok_order_sn);
  703 +
700 if(!th.data.ok_order_sn) return false; 704 if(!th.data.ok_order_sn) return false;
701 - getApp().request.promiseGet("/api/weshop/order/page",  
702 - {data:{store_id:os.stoid,parent_sn:th.data.ok_order_sn}}).then(res=>{  
703 - if(ut.ajax_ok(res)){  
704 - var item=res.data.data.pageData[0]; 705 +
  706 + var ck_url="/api/weshop/recharge/get/"+os.stoid+"/"+th.data.ok_order_sn;
  707 + getApp().request.promiseGet(ck_url,{}).then(res=>{
  708 + if(res.data.code==0 && res.data.data){
  709 +
  710 + var item=res.data.data;
  711 +
  712 + console.log('222');
  713 + console.log(item);
  714 +
705 if(item.pay_status==1){ 715 if(item.pay_status==1){
706 //支付支付,返回首页 716 //支付支付,返回首页
707 - ut.m_toast('支付成功');  
708 - setTimeout(()=>{  
709 - getApp().goto("/pages/payment/pay_success/pay_success?type=2&order_sn=" + th.data.ok_order_sn);  
710 - },1000)  
711 - 717 + th.success(); //支付成功提示
712 }else{ 718 }else{
713 //支付支付,返回首页 719 //支付支付,返回首页
714 ut.m_toast('支付失败'); 720 ut.m_toast('支付失败');
715 - setTimeout(()=>{  
716 - getApp().goto("/pages/index/index/index");  
717 - },1000)  
718 } 721 }
719 } 722 }
720 }) 723 })
  724 + },
  725 + //支付成功后的提示
  726 + function (){
  727 +
  728 + console.log('2222');
  729 + console.log(th.data.ok_order_sn);
  730 +
  731 + th.success(); //支付成功提示
721 }); 732 });
722 } 733 }
723 734
@@ -834,7 +845,11 @@ Page({ @@ -834,7 +845,11 @@ Page({
834 t_pay.pay(req, th.success, function (e) { 845 t_pay.pay(req, th.success, function (e) {
835 th.data.paying=0; 846 th.data.paying=0;
836 getApp().my_warnning("支付失败", 0, th); 847 getApp().my_warnning("支付失败", 0, th);
837 - }); 848 + },function (ordno){
  849 + console.log('get_order')
  850 + console.log(ordno)
  851 + th.data.ok_order_sn=ordno;
  852 + });
838 853
839 }, 854 },
840 855
pages/cart/cart2_pt/cart2_pt.js
@@ -585,7 +585,7 @@ Page({ @@ -585,7 +585,7 @@ Page({
585 if(fy) return false; 585 if(fy) return false;
586 util_pay.set_fir(); 586 util_pay.set_fir();
587 //-- 通联的第三方支付的返回优化 -- 587 //-- 通联的第三方支付的返回优化 --
588 - ut.is_pay_ok("/pages/team/team_success/team_success?ordersn=" + th.data.ok_order_sn,null,function (){ 588 + ut.is_pay_ok("/pages/team/team_success/team_success?ordersn=" + th.data.ok_order_sn,"none",function (){
589 if(!th.data.ok_order_sn) return false; 589 if(!th.data.ok_order_sn) return false;
590 getApp().request.promiseGet("/api/weshop/order/page", 590 getApp().request.promiseGet("/api/weshop/order/page",
591 {data:{store_id:os.stoid,parent_sn:th.data.ok_order_sn}}).then(res=>{ 591 {data:{store_id:os.stoid,parent_sn:th.data.ok_order_sn}}).then(res=>{
pages/user/order_detail/order_detail.js
@@ -81,7 +81,7 @@ Page({ @@ -81,7 +81,7 @@ Page({
81 81
82 //通联第三方 82 //通联第三方
83 //-- 通联的第三方支付的返回优化 -- 83 //-- 通联的第三方支付的返回优化 --
84 - ut.is_pay_ok("back",null,function (){ 84 + ut.is_pay_ok("back","none",function (){
85 if(!th.data.ok_order_sn) return false; 85 if(!th.data.ok_order_sn) return false;
86 getApp().request.promiseGet("/api/weshop/order/page", 86 getApp().request.promiseGet("/api/weshop/order/page",
87 {data:{store_id:os.stoid,order_sn:th.data.ok_order_sn}}).then(res=>{ 87 {data:{store_id:os.stoid,order_sn:th.data.ok_order_sn}}).then(res=>{
pages/user/plus/plus.js
@@ -144,7 +144,7 @@ Page({ @@ -144,7 +144,7 @@ Page({
144 ut.fy_back('',0); 144 ut.fy_back('',0);
145 t_pay.set_fir(); 145 t_pay.set_fir();
146 //-- 通联的第三方支付的返回优化 -- 146 //-- 通联的第三方支付的返回优化 --
147 - ut.is_pay_ok("/pages/payment/pay_success/pay_success?type=2&order_sn=" + this.data.ok_order_sn,null,function (){ 147 + ut.is_pay_ok("func","func",function (){
148 if(!th.data.ok_order_sn) return false; 148 if(!th.data.ok_order_sn) return false;
149 getApp().request.promiseGet("/api/weshop/order/page", 149 getApp().request.promiseGet("/api/weshop/order/page",
150 {data:{store_id:os.stoid,parent_sn:th.data.ok_order_sn}}).then(res=>{ 150 {data:{store_id:os.stoid,parent_sn:th.data.ok_order_sn}}).then(res=>{
@@ -152,21 +152,31 @@ Page({ @@ -152,21 +152,31 @@ Page({
152 var item=res.data.data.pageData[0]; 152 var item=res.data.data.pageData[0];
153 if(item.pay_status==1){ 153 if(item.pay_status==1){
154 //支付支付,返回首页 154 //支付支付,返回首页
155 - ut.m_toast('支付成功');  
156 - setTimeout(()=>{  
157 - getApp().goto("/pages/payment/pay_success/pay_success?type=2&order_sn=" + th.data.ok_order_sn);  
158 - },1000) 155 + th.success()
159 156
160 }else{ 157 }else{
161 - //支付支付,返回首页  
162 - ut.m_toast('支付失败');  
163 - setTimeout(()=>{  
164 - getApp().goto("/pages/index/index/index");  
165 - },1000) 158 + //支付支付,返回首页
  159 + getApp().my_warnning('支付失败', 0, th);
  160 + th.setData({
  161 + is_select:0,
  162 + focus:true,
  163 + })
166 } 164 }
167 } 165 }
168 }) 166 })
169 - }); 167 + }, //成功的回调
  168 + function (){
  169 + th.success();
  170 + },//失败的回调
  171 + function (){
  172 +
  173 + getApp().my_warnning('支付失败', 0, th);
  174 + th.setData({
  175 + is_select:0,
  176 + focus:true,
  177 + })
  178 +
  179 + });
170 } 180 }
171 181
172 this.setData({ 182 this.setData({
@@ -540,12 +550,13 @@ Page({ @@ -540,12 +550,13 @@ Page({
540 t_pay.set_pay_url('/api/weshop/plus/create/plus/order'); 550 t_pay.set_pay_url('/api/weshop/plus/create/plus/order');
541 t_pay.pay(req, th.success, function (msg) { 551 t_pay.pay(req, th.success, function (msg) {
542 if(!msg) msg="支付失败"; 552 if(!msg) msg="支付失败";
543 -  
544 getApp().my_warnning(msg, 0, th); 553 getApp().my_warnning(msg, 0, th);
545 th.setData({ 554 th.setData({
546 is_select:0, 555 is_select:0,
547 focus:true, 556 focus:true,
548 }) 557 })
  558 + },function (ordno){
  559 + th.data.ok_order_sn=ordno;
549 }); 560 });
550 } 561 }
551 } else { 562 } else {
utils/pay2.js
@@ -10,7 +10,8 @@ module.exports = { @@ -10,7 +10,8 @@ module.exports = {
10 this.wx_paying=0; 10 this.wx_paying=0;
11 }, 11 },
12 //-- createRechargeOrder create/plus/order -- 12 //-- createRechargeOrder create/plus/order --
13 - pay: function(dd, succ,fail) { 13 + // get_order是通联专用,获取订单号
  14 + pay: function(dd, succ,fail,get_order) {
14 if(this.wx_paying) return false; 15 if(this.wx_paying) return false;
15 this.wx_paying=1; 16 this.wx_paying=1;
16 wx.showLoading(); 17 wx.showLoading();
@@ -57,6 +58,11 @@ module.exports = { @@ -57,6 +58,11 @@ module.exports = {
57 else if(is_pos_pay){ 58 else if(is_pos_pay){
58 var p_data=t.data.data; 59 var p_data=t.data.data;
59 delete p_data.is_pos_pay; //清理掉,不然签名不通过 60 delete p_data.is_pos_pay; //清理掉,不然签名不通过
  61 +
  62 + if(get_order){
  63 + get_order(p_data.reqsn); //把单号返回
  64 + }
  65 +
60 wx.openEmbeddedMiniProgram({ 66 wx.openEmbeddedMiniProgram({
61 appId: 'wxef277996acc166c3', 67 appId: 'wxef277996acc166c3',
62 extraData: p_data, 68 extraData: p_data,
utils/util.js
@@ -884,7 +884,15 @@ module.exports = { @@ -884,7 +884,15 @@ module.exports = {
884 }) 884 })
885 }, 885 },
886 //-- 支付的结果判断是不是完成了,通联支付pos收银的返回 -- 886 //-- 支付的结果判断是不是完成了,通联支付pos收银的返回 --
887 - is_pay_ok(back_url,err_url,func){ 887 + /**
  888 + *
  889 + * @param back_url 如果是地址,就跳转,如果是back,就返回。如果是func,就是要回调
  890 + * @param err_url 如果是地址,就跳转,如果是back,就返回。如果是func,就是要回调,如果是none,就没有反应,提示而已
  891 + * @param func 因为是物理键的返回,所以要调用结果,查询结果
  892 + * @param success //成功的回调函数, 当back_url是func
  893 + * @param fail //失败的回调函数, 当err_url是func
  894 + */
  895 + is_pay_ok(back_url,err_url,func,success,fail){
888 if(!err_url){ 896 if(!err_url){
889 err_url="/pages/index/index/index"; 897 err_url="/pages/index/index/index";
890 } 898 }
@@ -901,7 +909,11 @@ module.exports = { @@ -901,7 +909,11 @@ module.exports = {
901 setTimeout(function () { 909 setTimeout(function () {
902 if(back_url=='back') { 910 if(back_url=='back') {
903 wx.navigateBack(); 911 wx.navigateBack();
904 - }else{ 912 + }
  913 + else if(back_url=='func'){
  914 + success();
  915 + }
  916 + else{
905 wx.redirectTo({ url: back_url}); 917 wx.redirectTo({ url: back_url});
906 } 918 }
907 },2000) 919 },2000)
@@ -914,6 +926,9 @@ module.exports = { @@ -914,6 +926,9 @@ module.exports = {
914 if(err_url=='back'){ 926 if(err_url=='back'){
915 wx.navigateBack(); 927 wx.navigateBack();
916 } 928 }
  929 + else if(err_url=='func'){
  930 + fail();
  931 + }
917 else if(err_url!='none'){ 932 else if(err_url!='none'){
918 getApp().goto(err_url); 933 getApp().goto(err_url);
919 } 934 }