作者 潘浩文
1 个管道 的构建 通过 耗费 0 秒

1

@@ -68,9 +68,6 @@ @@ -68,9 +68,6 @@
68 <script type="text/javascript" src="__TMPL__/public/assets/js/jquery.min.js"></script> 68 <script type="text/javascript" src="__TMPL__/public/assets/js/jquery.min.js"></script>
69 <script src="http://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script> 69 <script src="http://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
70 <script> 70 <script>
71 - wx.config(  
72 - {$js}  
73 - );  
74 // function clacImgZoomParam(maxWidth, maxHeight, width, height) { 71 // function clacImgZoomParam(maxWidth, maxHeight, width, height) {
75 // var param = { 72 // var param = {
76 // top: 0, 73 // top: 0,
@@ -128,38 +125,39 @@ @@ -128,38 +125,39 @@
128 // } 125 // }
129 // 126 //
130 // } 127 // }
  128 + wx.config(
  129 + {$js}
  130 + );
131 var serverIds = ''; 131 var serverIds = '';
132 -wx.ready(function () {  
133 - $('#imghead').click(function () {  
134 -// var id = $(this).attr('id'); 132 + wx.ready(function () {
  133 + $('#imghead').click(function () {
135 // if ($(this).find('img').length=="") { 134 // if ($(this).find('img').length=="") {
136 - wx.chooseImage({  
137 - count: 1, // 默认9  
138 - sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图,默认二者都有  
139 - sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有  
140 - success: function (res) {  
141 - $('#imghead').attr('src',res.localIds)  
142 - uploadImages(res.localIds, id)  
143 - }  
144 - }); 135 + wx.chooseImage({
  136 + count: 1, // 默认9
  137 + sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图,默认二者都有
  138 + sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有
  139 + success: function (res) {
  140 + $('#imghead').attr('src',res.localIds)
  141 + uploadImages(res.localIds)
  142 + }
  143 + });
145 // } 144 // }
146 - });  
147 - function uploadImages(localIds) {  
148 -// var localId = localIds.pop();  
149 - wx.uploadImage({  
150 - localId: localIds,  
151 - isShowProgressTips: 1,  
152 - success: function (res) {  
153 - serverIds = res.serverId; // 返回图片的服务器端ID  
154 - alert(serverIds)  
155 - },  
156 - fail: function (res) {  
157 - alert(res)  
158 - $modal.toast(JSON.stringify(res)); 145 + });
  146 + function uploadImages(localIds) {
  147 + var localId = localIds.pop();
  148 + wx.uploadImage({
  149 + localId: localId,
  150 + isShowProgressTips: 1,
  151 + success: function (res) {
  152 + var serverId = res.serverId; // 返回图片的服务器端ID
  153 + serverIds += id+':'+serverId + ',';
  154 + },
  155 + fail: function (res) {
  156 + $modal.toast(JSON.stringify(res));
  157 + }
  158 + });
159 } 159 }
160 }); 160 });
161 - }  
162 -});  
163 //确定上传小票 161 //确定上传小票
164 $(".footer").click(function(){ 162 $(".footer").click(function(){
165 $.ajax({ 163 $.ajax({