找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
热搜: 活动 交友 discuz
查看: 454|回复: 0

点微-活动报名,不显示-立即下单【替换文件】

[复制链接]
发表于 2022-12-9 11:09:58 | 显示全部楼层 |阅读模式
wx_upload.htm  覆盖source/plugin/tom_tchuodong/template/
  1. <script>
  2. var picnum = {};
  3. <!--{loop $bmnumArr $k $i}-->
  4. picnum[$i] = {};
  5. <!--{loop $attrpicList $key $val}-->
  6. picnum[{$i}][{$val['id']}] = 0;
  7. <!--{/loop}-->
  8. <!--{/loop}-->
  9.    
  10. var oldWindowHeight = $(window).height();

  11. function photoupload(attr_id,num,numberid){

  12.     wx.ready(function () {
  13.             var picnums = picnum[numberid][attr_id];
  14.             
  15.             var newWindowHeight = $(window).height();
  16.             if(newWindowHeight < (oldWindowHeight - 100)){
  17.                 return false;
  18.             }

  19.             var photo_num = num - picnums;
  20.             if(photo_num == 0){
  21.                 tusi("{lang tom_tchuodong:over_photo}");
  22.                 return false;
  23.             }else if(photo_num > 9){
  24.                 photo_num = 9;
  25.             }

  26.             wx.chooseImage({
  27.                 count: photo_num,
  28.                 sizeType: ['original', 'compressed'],
  29.                 sourceType: ['album', 'camera'],
  30.                 success: function (res) {
  31.                     var length = res.localIds.length;
  32.                     if(length > 0){
  33.                         loading('{lang tom_tchuodong:uploading}');
  34.                         uploadImg(res);
  35.                     }
  36.                 }
  37.             });

  38.         function uploadImg(res){
  39.             var i = 0, length = res.localIds.length;
  40.             if(length > 0){
  41.                 function upload(){   
  42.                     wx.uploadImage({
  43.                         localId: res.localIds[i],
  44.                         isShowProgressTips: 0,
  45.                         success: function (res) {
  46.                             var serverId = res.serverId;
  47.                             downloadServer(serverId);
  48.                             i++;
  49.                             if(i < length){
  50.                                 upload();
  51.                             }else{
  52.                                 loading(false);
  53.                             }
  54.                         },
  55.                         fail:function(res){
  56.                             loading(false);
  57.                             tusi('{lang tom_tchuodong:wx_upload_error}');
  58.                         }
  59.                     });
  60.                 }
  61.                 upload();
  62.             }
  63.         }

  64.         function downloadServer(serverId){
  65.             $.ajax({
  66.                 type:'POST',
  67.                 url:'{$wxUploadUrl}',
  68.                 data:{serverId:serverId},
  69.                 dataType:'json',
  70.                 success:function(data){
  71.                     if(data.status == 200){
  72.                         $("#photolist_"+attr_id+'_'+numberid).append('<li class="li_'+li_i+'"><section class="img"><img src="'+data.picurl+'" /><input type="hidden" name="photo_'+attr_id+'_'+numberid+'[]" value="'+data.picurl+'"/></section><div class=" close pic-delete-btn pointer" onclick="picremove('+li_i+','+attr_id+','+numberid+');"> X </div></li>');
  73.                         li_i ++;
  74.                         picnum[numberid][attr_id]++;
  75.                     }else if(data.status == 301){
  76.                         <!--{if $test == 1}-->
  77.                         alert(data.content);
  78.                         <!--{/if}-->
  79.                         tusi('{lang tom_tchuodong:wx_upload_error_301}');
  80.                         return false;
  81.                     }else if(data.status == 302){
  82.                         tusi('{lang tom_tchuodong:wx_upload_error_302}');
  83.                         return false;
  84.                     }else{
  85.                         tusi('error');
  86.                         return false;
  87.                     }
  88.                 },
  89.                 error:function(){
  90.                     loading(false);
  91.                     tusi('{lang tom_tchuodong:wx_upload_error_1}');
  92.                 }
  93.             })
  94.         }
  95.     });
  96. }
  97.    
  98. wx.ready(function () {
  99.    
  100.     $(document).on('click', '#filedata2', function(){
  101.         
  102.         var newWindowHeight = $(window).height();
  103.         if(newWindowHeight < (oldWindowHeight - 100)){
  104.             return false;
  105.         }
  106.         
  107.         wx.chooseImage({
  108.             count: 1,
  109.             sizeType: ['original', 'compressed'],
  110.             sourceType: ['album', 'camera'],
  111.             success: function (res) {
  112.                 var length = res.localIds.length;
  113.                 if(length > 0){
  114.                     loading('{lang tom_tcshop:uploading}');
  115.                     uploadImg(res, 2);
  116.                 }
  117.             }
  118.         });
  119.     })
  120.    
  121.     $(document).on('click', '#filedata3', function(){
  122.         var count = $("#photolist").find("li").length;
  123.         
  124.         var newWindowHeight = $(window).height();
  125.         if(newWindowHeight < (oldWindowHeight - 100)){
  126.             return false;
  127.         }
  128.         
  129.         var photo_num = max_photo_num - count;
  130.         if(photo_num == 0){
  131.             tusi("{lang tom_tchuodong:fabu_max_photo_num}"+max_photo_num+"{lang tom_tchuodong:bm_zhang}");exit;
  132.             return false;
  133.         }else if(photo_num > 9){
  134.             photo_num = 9;
  135.         }
  136.         wx.chooseImage({
  137.             count: photo_num,
  138.             sizeType: ['original', 'compressed'],
  139.             sourceType: ['album', 'camera'],
  140.             success: function (res) {
  141.                 var length = res.localIds.length;
  142.                 if(length > 0){
  143.                     loading('{lang tom_tcshop:uploading}');
  144.                     uploadImg(res, 3);
  145.                 }
  146.             }
  147.         });
  148.     })
  149.    
  150.     $(document).on('click', '#filedata4', function(){
  151.         
  152.         var newWindowHeight = $(window).height();
  153.         if(newWindowHeight < (oldWindowHeight - 100)){
  154.             return false;
  155.         }
  156.         
  157.         wx.chooseImage({
  158.             count: 1,
  159.             sizeType: ['original', 'compressed'],
  160.             sourceType: ['album', 'camera'],
  161.             success: function (res) {
  162.                 var length = res.localIds.length;
  163.                 if(length > 0){
  164.                     loading('{lang tom_tcshop:uploading}');
  165.                     uploadImg(res, 4);
  166.                 }
  167.             }
  168.         });
  169.     })
  170.    
  171.     function uploadImg(res, type){
  172.         var i = 0, length = res.localIds.length;
  173.         if(length > 0){
  174.             function upload(){   
  175.                 wx.uploadImage({
  176.                     localId: res.localIds[i],
  177.                     isShowProgressTips: 0,
  178.                     success: function (res) {
  179.                         var serverId = res.serverId;
  180.                         downloadServer(serverId, type);
  181.                         i++;
  182.                         if(i < length){
  183.                             upload();
  184.                         }else{
  185.                             loading(false);
  186.                         }
  187.                     },
  188.                     fail:function(res){
  189.                         loading(false);
  190.                         tusi('{lang tom_tcshop:wx_upload_error}');
  191.                     }
  192.                 });
  193.             }
  194.             upload();
  195.         }
  196.     }
  197.    
  198.     function downloadServer(serverId, type){
  199.         var type = type;
  200.         $.ajax({
  201.             type:'POST',
  202.             url:'{$wxUploadUrl2}',
  203.             data:{serverId:serverId},
  204.             dataType:'json',
  205.             success:function(data){
  206.                 if(data.status == 200){
  207.                     if(type == 2){
  208.                         $("#picurl").html('<li><section class="img"><img src="'+data.picurl+'" /><input type="hidden" name="picurl" value="'+data.picurl+'"/></section></li>');
  209.                         picurl_count++;
  210.                     }else if(type == 3){
  211.                         $("#photolist").append('<li class="li_'+li_i+'"><section class="img"><img src="'+data.picurl+'" /><input type="hidden" name="photo_'+li_i+'" value="'+data.picurl+'"/></div><div class=" close pic-delete-btn pointer" onclick="picremove('+li_i+');"> X </div></li>');
  212.                         li_i++;
  213.                         photo_count++;
  214.                     }else if(type == 4){
  215.                         $("#toppic").html('<li><section class="img"><img src="'+data.picurl+'" /><input type="hidden" name="toppic" value="'+data.picurl+'"/></section></li>');
  216.                         toppic_count++;
  217.                     }
  218.                 }else if(data.status == 301){
  219.                     <!--{if $test == 1}-->
  220.                     alert(data.content);
  221.                     <!--{/if}-->
  222.                     tusi('{lang tom_tcshop:wx_upload_error_301}');
  223.                     return false;
  224.                 }else if(data.status == 302){
  225.                     <!--{if $test == 1}-->
  226.                     alert(data.type);
  227.                     <!--{/if}-->
  228.                     tusi('{lang tom_tcshop:wx_upload_error_302}');
  229.                     return false;
  230.                 }else{
  231.                     tusi('error');
  232.                     return false;
  233.                 }
  234.             },
  235.             error:function(){
  236.                 loading(false);
  237.                 tusi('{lang tom_tcshop:wx_upload_error_1}');
  238.             }
  239.         })
  240.     }   
  241. });
  242. </script>
复制代码


回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|站长网 网站备案:鄂ICP备13006300号-4

GMT+8, 2024-4-27 02:00 , Processed in 0.045739 second(s), 16 queries .

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表