Przeglądaj źródła

新增 领取礼品

XSLu08042 2 dni temu
rodzic
commit
f2181d26f7

+ 4 - 7
api/packageOrder.js

@@ -39,10 +39,7 @@ let request = new Request().http
  	 return request('/app/packageOrder/getOrderCount',data,'GET');
  }
  
-  
- 
- 
- 
- 
- 
-  
+ // 领取礼品(创建订单)
+ export function giftCreate(data) {
+  	return request('/app/pop',data,'POST','application/json;charset=UTF-8');
+ }

+ 26 - 3
pages_company/packageDetails.vue

@@ -151,6 +151,7 @@
 </template>
 
 <script>
+	import {getConfigByKey} from '@/api/common'
 	import {getPackageById,getPackageDoctorList} from '@/api/package.js'
 	export default {
 		data() {
@@ -168,22 +169,26 @@
 				doctorId:null,
 				doctorPageNum:1,
 				doctorLastPage:false,
-				doctorTotal:0
+				doctorTotal:0,
+				choose: 0
 			};
 		},
 		onLoad(option) {
 			this.packageId=option.packageId;
 			this.companyId=uni.getStorageSync('companyId');
-			this.companyUserId=uni.getStorageSync('companyUserId');		 
+			this.companyUserId=uni.getStorageSync('companyUserId');		
 		},
 		onShow() {
 			this.getPackageById();
 			this.getPackageDoctorList();
+			if(this.packageId) {
+				this.getConfigByKey()
+			}
 		},
 		onShareAppMessage(res) {
 			return {
 				title: this.item.packageName,
-				path: '/pages_index/packageDetails?packageId='+this.packageId+"&companyId="+this.companyId+"&companyUserId="+this.companyUserId,
+				path: '/pages_index/packageDetails?packageId='+this.packageId+"&companyId="+this.companyId+"&companyUserId="+this.companyUserId+'&choose='+this.choose|| '',
 				imageUrl: this.item.imgUrl //分享图标,路径可以是本地文件路径、代码包文件路径或者网络图片路径.支持PNG及JPG。显示图片长宽比是 5:4
 			}
 		},
@@ -286,6 +291,24 @@
 					rej => {}
 				);
 			},
+			getConfigByKey(){
+				let param = {key:"app.config"};
+				getConfigByKey(param).then(
+					res => {
+						if(res.code==200){
+							let data=res.data ? JSON.parse(res.data) : {};
+							const fsPackage = data.fsPackage&&data.fsPackage.length > 0 ? data.fsPackage[0] : {}
+							this.choose = fsPackage&&fsPackage.packageId == this.packageId ? 2 : 0
+						}else{
+							uni.showToast({
+								icon:'none',
+								title: "请求失败",
+							});
+						}
+					},
+					rej => {}
+				);
+			},
 		}
 	}
 </script>

+ 5 - 3
pages_index/packageDetails.vue

@@ -208,11 +208,13 @@
 				doctorLastPage:false,
 				doctorTotal:0,
 				companyUserId:null,
-				companyId:null
+				companyId:null,
+				choose: 0
 			};
 		},
 		onLoad(option) {
 			this.packageId=option.packageId;
+			this.choose = option.choose || 0
 			if(!this.$isEmpty(option.companyId)){
 				this.companyId=option.companyId
 			}
@@ -257,7 +259,7 @@
 		onShareAppMessage(res) {
 			return {
 				title: this.item.packageName,
-				path: '/pages_index/packageDetails?packageId='+this.packageId+"&companyId="+this.companyId+"&companyUserId="+this.companyUserId,
+				path: '/pages_index/packageDetails?packageId='+this.packageId+"&companyId="+this.companyId+"&companyUserId="+this.companyUserId+"&choose="+this.choose || '',
 				imageUrl: this.item.imgUrl //分享图标,路径可以是本地文件路径、代码包文件路径或者网络图片路径.支持PNG及JPG。显示图片长宽比是 5:4
 			}
 			
@@ -311,7 +313,7 @@
 				}
 				else{
 					uni.navigateTo({
-						url:"/pages_index/packageForm?packageId="+this.packageId+"&doctorId="+this.doctorId+"&companyId="+this.companyId+"&companyUserId="+this.companyUserId,
+						url:"/pages_index/packageForm?packageId="+this.packageId+"&doctorId="+this.doctorId+"&companyId="+this.companyId+"&companyUserId="+this.companyUserId+"&choose="+this.choose || '',
 					})
 					// if(this.isDrug==1){
 						

+ 45 - 3
pages_index/packageForm.vue

@@ -61,7 +61,7 @@
 
 <script>
 	
-	import {create} from '@/api/packageOrder.js'
+	import {create,giftCreate} from '@/api/packageOrder.js'
 	export default {
 		data() {
 			return {
@@ -99,13 +99,14 @@
 				doctorId:null,
 				isComplete:0,
 				companyUserId:null,
-				companyId:null
-				
+				companyId:null,
+				choose: 0, // 1:付邮费领取 2:加粉领取
 			};
 		},
 		onLoad(option) {
 			this.packageId=option.packageId
 			this.doctorId=option.doctorId
+			this.choose = option.choose || 0
 			if(!this.$isEmpty(option.companyId)){
 				this.companyId=option.companyId
 			}
@@ -202,6 +203,10 @@
 					doctorId:this.doctorId,
 					formJson:JSON.stringify(this.items),
 				}
+				if(this.choose == 1 || this.choose == 2) {
+					this.giftCreateOrder(data)
+					return
+				}
 				var that=this;
 				create(data).then(res => {
 					uni.hideLoading()
@@ -234,6 +239,43 @@
 					}
 				});
 			 
+			},
+			giftCreateOrder(data) {
+				var that=this;
+				const param = {
+					...data,
+					choose: this.choose, //1:付邮费领取 2:加粉领取
+				}
+				giftCreate(param).then(res => {
+					uni.hideLoading()
+					
+					if(res.code==200){
+						var temps=['jARl4BpoBkRu-2MxPMkQVhIfGMG0V9qW-X3V_7NtEOU']
+						uni.requestSubscribeMessage({
+							tmplIds: temps,
+							success(e) {
+								setTimeout(function(){
+									uni.navigateTo({
+										url: '/pages_order/packageOrderPay?orderId='+res.order.orderId
+									})
+								},200);
+							},
+							fail(e) {
+								setTimeout(function(){
+									uni.navigateTo({
+										url: '/pages_order/packageOrderPay?orderId='+res.order.orderId
+									})
+								},200);
+							}
+						})
+						
+					}else{
+						uni.showToast({
+							icon:'none',
+							title: res.msg,
+						});
+					}
+				});
 			}
 		}
 	}

+ 16 - 6
pages_order/packageOrderPay.vue

@@ -83,7 +83,7 @@
 			<view class="pay-type">
 				<view class="title">支付方式</view>
 				<radio-group @change="payTypeChange"   >
-					<view class="item"  v-if="checkPayType('1')" >
+					<view class="item"  v-if="checkPayType('1')&&choose!=1" >
 						<view class="left" >
 							<image src="/static/images/wecha_pay.png" mode=""></image>
 							<text class="text">全款支付</text>
@@ -101,7 +101,7 @@
 							<radio  :value="2" :checked="payType=='2'" />
 						</label>
 					</view>
-					<view class="item"  v-if="checkPayType('3')" >
+					<view class="item"  v-if="checkPayType('3')&&choose!=2" >
 						<view class="left">
 							<image src="/static/images/pay_1.png" mode=""></image>
 							<text class="text">货到付款</text>
@@ -213,11 +213,13 @@
 				payDelivery:0,
 				payPrice:0,
 				gifts:[],
-				
+				choose: 0
 				
 			}
 		},
 		onLoad(option) {
+			this.choose = option.choose || 0
+			this.payType = this.choose == 1 ? 3:this.choose == 2 ? 1 :this.payType
 			this.orderId=option.orderId;
 			var that=this;
 			uni.$on('updateAddress', (e) => {
@@ -229,7 +231,7 @@
 		},
 		onShow() {
 			this.getPackageOrderById();
-			this.getPackageById();
+			// this.getPackageById();
 			this.getConfigByKey();
 		},
 		 
@@ -366,7 +368,8 @@
 					res => {
 						if(res.code==200){
 							this.order=res.order
-							 
+							this.choose = res.choose || 0
+							this.payType = this.choose == 1 ? 3:this.choose == 2 ? 1 :this.payType
 							this.compute();
 							this.getPackageById(this.order.packageId)
 						}else{
@@ -377,12 +380,19 @@
 				);
 			},
 			getPackageById(packageId){
-				var data={packageId:packageId};
+				let data={packageId:packageId};
+				if(this.choose == 1 || this.choose == 2) {
+					data={
+						packageId:packageId,
+						choose: this.choose
+					};
+				}
 				getPackageById(data).then(
 					res => {
 						if(res.code==200){
 							this.package=res.data;
 							this.payTypes=res.data.payType.split(',');
+							this.payType=this.choose == 1 ? 3:this.choose == 2 ? 1 :this.payType
 							console.log(this.payTypes)
 							this.getMyEnableCouponList();
 						}else{