imgConsultDetail.js 4.92 KB
Newer Older
1 2 3 4
define(['zepto', 'medtap'], function($, medtap) {
	var detail = {
		orderSn: medtap.getRequest('id'),
		wechatId: medtap.getRequest('wechatId'),
hanpeng committed
5
		doctorId:0,
6 7 8
		init: function() {
			detail.getDetail();
			detail.bindEve();
hanpeng committed
9
			detail.getWechatTicket();
10 11 12 13 14 15 16 17 18 19 20
		},
		bindEve: function() {
			$('.pay').unbind().bind('click', function() {
				medtap.pushWindow(
					'https://review-formal.iplusmed.com/wechatForLungCancer/dev/wechat_lung_wxPay/wxPay.html?orderType=imgConsult&orderId=' +
					detail.orderSn + '&wechatId=' + detail.wechatId + '&wxLungToken=' + localStorage.wxLungToken)
			});

			$('.cancel').unbind().bind('click', function() {
				detail.cancelOrder();
			})
hanpeng committed
21 22 23 24
			$('.cancel_btn').unbind().bind('click', function() {
				detail.cancelOrder();
			});
			
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
		},
		getDetail: function() {
			medtap.loading(1);
			medtap.submitAjax({
				url: 'https://testdevgw.medtap.cn/trade/order/getOrderByOrderSn',
				type: 'get',
				async: false,
				data: {
					orderSn: detail.orderSn
				},
				success: function(res) {
					medtap.loading(0);
					if (res.success == true) {
						var detail = res.content.order;
						var imgConsult = detail.imageConsultOrder;
hanpeng committed
40 41
						detail.doctorId = imgConsult.doctorId;
						//alert(detail.doctorId)
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
						$('.service_type').html(detail.payDesc);
						$('.service_doctor').html(imgConsult.doctorName);
						$('.service_price').html(detail.payFee + '元');
						var sex = '';
						if (imgConsult.sex == 'M') {
							sex = '男';
						} else {
							sex = '女';
						}
						$('.patient_name').html(imgConsult.patientName + ' (' + sex + ' ' + imgConsult.age + '岁' + ')');
						$('.patient_disease').html(imgConsult.diseaseDiagnosisDesc);
						$('.patient_disease_type').html(imgConsult.pathologyTypeDesc);
						$('.disease_area').html(imgConsult.describe);
						$('.help_area').html(imgConsult.expectationHelp);
						if (detail.status.key == '0') {
							$('.order_status_type').html(detail.status.value);
							$('.pay_btn').show();
						} else {
							$('.order_status_type').html(imgConsult.serviceStatus.value);
							if (detail.status.key == '1' && imgConsult.serviceStatus.key == '0' || imgConsult.serviceStatus.key ==
								'1' || imgConsult.serviceStatus.key == '2') {
								$('.cancel_btn').show();
							} else if (detail.status.key == '1' && imgConsult.serviceStatus.key == '3') {
								$('.consult_now').show();
hanpeng committed
66 67 68
								$('.consult_now').unbind().bind('click',function(){
									medtap.pushWindow('../../wechat_lung_chat/pages/imgConsultChat.html?orderSn=' + detail.orderSn + '&doctorId=' + imgConsult.doctorId);
								})
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
							}

						}
						if (imgConsult.describePic.length > 0) {
							var str = '';
							for (var i = 0; i < imgConsult.describePic.length; i++) {
								str += '<img src="' + imgConsult.describePic[i] + '" >'
							}
							$('.content_item_imgList').show();
							$('.content_item_imgList').html(str);
						} else {
							$('.content_item_imgList').hide();
						}
						$('.order_orderSn').html(detail.orderSn);
						$('.order_time').html(detail.createTime.substring(0, 16));
						if (detail.hasOwnProperty('payTime')) {
							$('.pay_box').show();
							$('.order_pay_time').html(detail.payTime)
						} else {
							$('.pay_box').hide();
						}
					}
				}
			})
		},
		cancelOrder: function() {
			if (!confirm('确定要取消订单吗?')) {
				return;
			}
			medtap.loading(1);
			medtap.submitAjax({
				url: 'https://testdevgw.medtap.cn/trade/order/cancelOrder',
				type: 'post',
				contentType: "application/json",
				async: false,
				data: {
					orderSn: detail.orderSn
				},
				success: function(res) {
					medtap.loading(0);
					if (res.success == true) {
						medtap.toast({
							message: '取消订单成功',
							time: 1500
						});
						setTimeout(function() {
							window.location.reload();
						}, 1500);
					}
				}
			})
hanpeng committed
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160
		},
		getWechatTicket: function() {
			medtap.submitAjax({
				url: 'https://testdevgw.medtap.cn/wechat/lung/fetchWechatTicket',
				type: 'GET',
				async: false,
				data: {
					url: window.location.href
				},
				success: function(res) {
					var data = res.content;
					wx.config({
						debug: false,
						appId: data.appId, // 必填,公众号的唯一标识
						timestamp: data.timestamp, // 必填,生成签名的时间戳
						nonceStr: data.nonceStr, // 必填,生成签名的随机串
						signature: data.signature, // 必填,签名,见附录1
						jsApiList: [
							'previewImage'
						]
					})
				}
			})
		}, 
		//图片预览
		previewImage: function() {
			$('.content_item_imgList').on('click', 'img', function() {
				//alert(1)
				var imgArray = [];
				var curImageSrc = $(this).attr('src');
				if (curImageSrc) {
					$('.content_item_imgList img').each(function(index, el) {
						var itemSrc = $(this).attr('src');
						imgArray.push(itemSrc);
					});
					wx.previewImage({
						current: curImageSrc,
						urls: imgArray
					});
				}
			});
161 162 163
		}
	}
	detail.init();
hanpeng committed
164
	detail.previewImage();
165
})