作者 李洪娟
1 -var baseurl = 'http://kindapp.w.bronet.cn/api/';//测试地址  
2 -var imgurl = 'http://kindapp.w.bronet.cn/' 1 +// var baseurl = 'http://kindapp.w.bronet.cn/api/';//测试地址
  2 +var baseurl='http://wx.cijievip.com/api/' //正式地址
  3 +var imgurl = 'http://kindapp.w.bronet.cn/';
  4 +var debug=true;
3 // var baseurl = 'http://192.168.1.3/api/';//本地测试 5 // var baseurl = 'http://192.168.1.3/api/';//本地测试
4 var mobileReg = /^1(3[0-9]|4[57]|5[0-35-9]|7[0135678]|8[0-9])\d{8}$/; //手机正则 6 var mobileReg = /^1(3[0-9]|4[57]|5[0-35-9]|7[0135678]|8[0-9])\d{8}$/; //手机正则
5 var id_card = /^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/;//身份证正则 7 var id_card = /^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/;//身份证正则
@@ -132,34 +132,34 @@ @@ -132,34 +132,34 @@
132 </div> 132 </div>
133 </div> 133 </div>
134 <div class="photo_re">(选填)</div> 134 <div class="photo_re">(选填)</div>
135 - <mt-popup v-model="popupVisible" position="bottom">  
136 - <ul class="moreoul">  
137 - <li @click="auth1('camera')">拍照</li>  
138 - <li @click="auth1('album')">从相册中选择</li>  
139 - <li @click="popupVisible=false" style="border-top: 2px solid #f0f0f0">取消</li>  
140 - </ul>  
141 - </mt-popup>  
142 - <mt-popup v-model="popupVisible1" position="bottom">  
143 - <ul class="moreoul">  
144 - <li @click="auth2('camera')">拍照</li>  
145 - <li @click="auth2('album')">从相册中选择</li>  
146 - <li @click="popupVisible1=false" style="border-top: 2px solid #f0f0f0">取消</li>  
147 - </ul>  
148 - </mt-popup>  
149 - <mt-popup v-model="popupVisible2" position="bottom">  
150 - <ul class="moreoul">  
151 - <li @click="auth3('camera')">拍照</li>  
152 - <li @click="auth3('album')">从相册中选择</li>  
153 - <li @click="popupVisible2=false" style="border-top: 2px solid #f0f0f0">取消</li>  
154 - </ul>  
155 - </mt-popup>  
156 - <mt-popup v-model="popupVisible3" position="bottom">  
157 - <ul class="moreoul">  
158 - <li @click="auth4('camera')">拍照</li>  
159 - <li @click="auth4('album')">从相册中选择</li>  
160 - <li @click="popupVisible2=false" style="border-top: 2px solid #f0f0f0">取消</li>  
161 - </ul>  
162 - </mt-popup> 135 + <!--<mt-popup v-model="popupVisible" position="bottom">-->
  136 + <!--<ul class="moreoul">-->
  137 + <!--<li @click="auth1('camera')">拍照</li>-->
  138 + <!--<li @click="auth1('album')">从相册中选择</li>-->
  139 + <!--<li @click="popupVisible=false" style="border-top: 2px solid #f0f0f0">取消</li>-->
  140 + <!--</ul>-->
  141 + <!--</mt-popup>-->
  142 + <!--<mt-popup v-model="popupVisible1" position="bottom">-->
  143 + <!--<ul class="moreoul">-->
  144 + <!--<li @click="auth2('camera')">拍照</li>-->
  145 + <!--<li @click="auth2('album')">从相册中选择</li>-->
  146 + <!--<li @click="popupVisible1=false" style="border-top: 2px solid #f0f0f0">取消</li>-->
  147 + <!--</ul>-->
  148 + <!--</mt-popup>-->
  149 + <!--<mt-popup v-model="popupVisible2" position="bottom">-->
  150 + <!--<ul class="moreoul">-->
  151 + <!--<li @click="auth3('camera')">拍照</li>-->
  152 + <!--<li @click="auth3('album')">从相册中选择</li>-->
  153 + <!--<li @click="popupVisible2=false" style="border-top: 2px solid #f0f0f0">取消</li>-->
  154 + <!--</ul>-->
  155 + <!--</mt-popup>-->
  156 + <!--<mt-popup v-model="popupVisible3" position="bottom">-->
  157 + <!--<ul class="moreoul">-->
  158 + <!--<li @click="auth4('camera')">拍照</li>-->
  159 + <!--<li @click="auth4('album')">从相册中选择</li>-->
  160 + <!--<li @click="popupVisible2=false" style="border-top: 2px solid #f0f0f0">取消</li>-->
  161 + <!--</ul>-->
  162 + <!--</mt-popup>-->
163 <div class="save_btn" @click="auth_next">提交</div> 163 <div class="save_btn" @click="auth_next">提交</div>
164 <div class="auth2_tips">为提高审核速度,请最少上传1张清晰的图片</div> 164 <div class="auth2_tips">为提高审核速度,请最少上传1张清晰的图片</div>
165 </div> 165 </div>
@@ -176,6 +176,7 @@ @@ -176,6 +176,7 @@
176 </script> 176 </script>
177 <script type="text/javascript" src="../../assets/js/axios.min.js"></script> 177 <script type="text/javascript" src="../../assets/js/axios.min.js"></script>
178 <script type="text/javascript" src="../../assets/icon/iconfont.js"></script> 178 <script type="text/javascript" src="../../assets/icon/iconfont.js"></script>
  179 +<script type="text/javascript" src="http://res.wx.qq.com/open/js/jweixin-1.1.0.js"></script>
179 <script> 180 <script>
180 var app = new Vue({ 181 var app = new Vue({
181 el: "#app", 182 el: "#app",
@@ -188,186 +189,82 @@ @@ -188,186 +189,82 @@
188 popupVisible1: false, 189 popupVisible1: false,
189 popupVisible2: false, 190 popupVisible2: false,
190 popupVisible3: false, 191 popupVisible3: false,
  192 + configinfo: []
191 }, 193 },
192 created: function () { 194 created: function () {
193 apiready = function () { 195 apiready = function () {
  196 + app.getsdk();
194 if ($api.getStorage('img1') || ($api.getStorage('img2')) || ($api.getStorage('img3')) || ($api.getStorage('img4'))) { 197 if ($api.getStorage('img1') || ($api.getStorage('img2')) || ($api.getStorage('img3')) || ($api.getStorage('img4'))) {
195 app.img1 = $api.getStorage('img1'); 198 app.img1 = $api.getStorage('img1');
196 app.img2 = $api.getStorage('img2'); 199 app.img2 = $api.getStorage('img2');
197 app.img3 = $api.getStorage('img3'); 200 app.img3 = $api.getStorage('img3');
198 app.img4 = $api.getStorage('img4') 201 app.img4 = $api.getStorage('img4')
199 } 202 }
  203 +
200 } 204 }
201 }, 205 },
202 methods: { 206 methods: {
203 - //诊断证明/医疗处置单  
204 - auth1: function (type) {  
205 - app.popupVisible = false;  
206 - api.getPicture({  
207 - sourceType: type,  
208 - encodingType: 'jpg',  
209 - mediaValue: 'pic',  
210 - destinationType: 'url',  
211 - allowEdit: true,  
212 - quality: 50,  
213 - targetWidth: 300,  
214 - targetHeight: 400,  
215 - saveToPhotoAlbum: true  
216 - }, function (ret, err) {  
217 - if (ret && ret.data && ret.data !== "") {  
218 - api.ajax({  
219 - url: baseurl + 'portal/Goods/uploadProve',  
220 - method: 'post',  
221 - data: {  
222 - values: {  
223 - type_id: 1  
224 - },  
225 - files: {  
226 - file: ret.data  
227 - }  
228 - },  
229 - headers: { 207 + // 获取微信配置
  208 + getsdk: function () {
  209 + var header = {
230 "XX-Device-Type": getDevice(), 210 "XX-Device-Type": getDevice(),
231 - 'XX-Token': getToken() 211 + 'XX-Token': getToken(),
  212 + };
  213 + var post = {
  214 + apis: 'chooseImage,uploadImage'
  215 + };
  216 + getRequest('post', 'user/index/getSingture', post, header).then(function (res) {
  217 + // alert(JSON.stringify(res))
  218 + if (res.data.code == 1) {
  219 + app.configinfo = res.data.data;
  220 + wx.config({
  221 + debug: debug, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
  222 + appId: app.configinfo.appId, // 必填,公众号的唯一标识
  223 + timestamp: app.configinfo.timestamp, // 必填,生成签名的时间戳
  224 + nonceStr: app.configinfo.nonceStr, // 必填,生成签名的随机串
  225 + signature: app.configinfo.signature,// 必填,签名,见附录1
  226 + jsApiList: app.configinfo.jsApiList // 必填,需要使用的JS接口列表,所有JS接口列表见附录2
  227 + });
232 } 228 }
233 - }, function (res, erro) {  
234 - // alert(JSON.stringify(res));  
235 - if (res.code == 1) {  
236 - toastMsg(res.msg)  
237 - app.img1 = res.data.url;  
238 - $api.setStorage('img1', res.data.url);  
239 - } else {  
240 - toastMsg(res.data.msg) 229 + loadEnd()
  230 + })
  231 + },
  232 +
  233 + //诊断证明/医疗处置单
  234 + auth1: function (type) {
  235 + wx.chooseImage({
  236 + count: 1, // 默认9
  237 + sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图,默认二者都有
  238 + sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有
  239 + success: function (res) {
  240 + var localIds = res.localIds; // 返回选定照片的本地ID列表,localId可以作为img标签的src属性显示图片
  241 + wx.uploadImage({
  242 + localId: localIds, // 需要上传的图片的本地ID,由chooseImage接口获得
  243 + isShowProgressTips: 1, // 默认为1,显示进度提示
  244 + success: function (res) {
  245 + var serverId = res.serverId; // 返回图片的服务器端ID
  246 + app.img1=serverId
241 } 247 }
  248 +
242 }); 249 });
243 } 250 }
  251 +
244 }); 252 });
245 }, 253 },
246 // 药品处方 254 // 药品处方
247 auth2: function (type) { 255 auth2: function (type) {
248 app.popupVisible1 = false; 256 app.popupVisible1 = false;
249 - api.getPicture({  
250 - sourceType: type,  
251 - encodingType: 'jpg',  
252 - mediaValue: 'pic',  
253 - destinationType: 'url',  
254 - allowEdit: true,  
255 - quality: 50,  
256 - targetWidth: 300,  
257 - targetHeight: 400,  
258 - saveToPhotoAlbum: true  
259 - }, function (ret, err) {  
260 - if (ret && ret.data && ret.data !== "") {  
261 - api.ajax({  
262 - url: baseurl + 'portal/Goods/uploadProve',  
263 - method: 'post',  
264 - data: {  
265 - values: {  
266 - type_id: 2  
267 - },  
268 - files: {  
269 - file: ret.data  
270 - }  
271 - },  
272 - headers: {  
273 - "XX-Device-Type": getDevice(),  
274 - 'XX-Token': getToken()  
275 - }  
276 - }, function (res, erro) {  
277 - if (res.code == 1) {  
278 - toastMsg(res.msg)  
279 - app.img2 = res.data.url;  
280 - $api.setStorage('img2', res.data.url);  
281 - } else {  
282 - toastMsg({msg: JSON.stringify(erro)});  
283 - }  
284 - });  
285 - }  
286 - }); 257 +
287 }, 258 },
288 // 药品照片 259 // 药品照片
289 auth3: function (type) { 260 auth3: function (type) {
290 app.popupVisible2 = false; 261 app.popupVisible2 = false;
291 - api.getPicture({  
292 - sourceType: type,  
293 - encodingType: 'jpg',  
294 - mediaValue: 'pic',  
295 - destinationType: 'url',  
296 - allowEdit: true,  
297 - quality: 50,  
298 - targetWidth: 300,  
299 - targetHeight: 400,  
300 - saveToPhotoAlbum: true  
301 - }, function (ret, err) {  
302 - if (ret && ret.data && ret.data !== "") {  
303 - api.ajax({  
304 - url: baseurl + 'portal/Goods/uploadProve',  
305 - method: 'post',  
306 - data: {  
307 - values: {  
308 - type_id: 3  
309 - },  
310 - files: {  
311 - file: ret.data  
312 - }  
313 - },  
314 - headers: {  
315 - "XX-Device-Type": getDevice(),  
316 - 'XX-Token': getToken()  
317 - }  
318 - }, function (res, erro) {  
319 - if (res.code == 1) {  
320 - toastMsg(res.msg)  
321 - app.img3 = res.data.url;  
322 - $api.setStorage('img3', res.data.url);  
323 - } else {  
324 - toastMsg({msg: JSON.stringify(erro)});  
325 - }  
326 - });  
327 - }  
328 - }); 262 +
329 }, 263 },
330 // 病例 264 // 病例
331 auth4: function (type) { 265 auth4: function (type) {
332 app.popupVisible3 = false; 266 app.popupVisible3 = false;
333 - api.getPicture({  
334 - sourceType: type,  
335 - encodingType: 'jpg',  
336 - mediaValue: 'pic',  
337 - destinationType: 'url',  
338 - allowEdit: true,  
339 - quality: 50,  
340 - targetWidth: 300,  
341 - targetHeight: 400,  
342 - saveToPhotoAlbum: true  
343 - }, function (ret, err) {  
344 - if (ret && ret.data && ret.data !== "") {  
345 - api.ajax({  
346 - url: baseurl + 'portal/Goods/uploadProve',  
347 - method: 'post',  
348 - data: {  
349 - values: {  
350 - type_id: 4  
351 - },  
352 - files: {  
353 - file: ret.data  
354 - }  
355 - },  
356 - headers: {  
357 - "XX-Device-Type": getDevice(),  
358 - 'XX-Token': getToken()  
359 - }  
360 - }, function (res, erro) {  
361 - if (res.code == 1) {  
362 - toastMsg(res.msg)  
363 - app.img4 = res.data.url;  
364 - $api.setStorage('img4', res.data.url);  
365 - } else {  
366 - toastMsg({msg: JSON.stringify(erro)});  
367 - }  
368 - });  
369 - }  
370 - }); 267 +
371 }, 268 },
372 auth_next: function () { 269 auth_next: function () {
373 if (app.img1 == '') { 270 if (app.img1 == '') {