浏览代码

Merge branch 'master' of http://git.liuniu946.com/xuhaolan/paopaoShop

xuhaolan 3 年之前
父节点
当前提交
044fd6f9ca
共有 5 个文件被更改,包括 57 次插入11 次删除
  1. 8 0
      api/user.js
  2. 41 6
      pages/money/pay.vue
  3. 5 3
      pages/order/createOrder.vue
  4. 1 1
      pages/product/groupBooking/productGroup.vue
  5. 2 1
      pages/user/user.vue

+ 8 - 0
api/user.js

@@ -16,6 +16,14 @@ export function getUserInfo(data) {
 		method: 'get',
 		data
 	});
+}
+// 获取用户信息
+export function userinfo(data) {
+	return request({
+		url: '/api/userinfo',
+		method: 'get',
+		data
+	});
 }
 
 // 用户分享图

+ 41 - 6
pages/money/pay.vue

@@ -27,6 +27,14 @@
 					<text>可用余额 ¥{{ now_money }}</text>
 				</view>
 				<label class="radio"><radio value="" color="#5dbc7c" :checked="payType == 3"></radio></label>
+			</view>
+			<view class="type-item" @click="changePayType(4)" v-if="isP == 1">
+				<text class="icon iconfont iconyue"></text>
+				<view class="con">
+					<text class="tit">拼团积分</text>
+					<text>可用余额 {{ userInfo.pink_integral }}</text>
+				</view>
+				<label class="radio"><radio value="" color="#5dbc7c" :checked="payType == 4"></radio></label>
 			</view>
 		</view>
 		<text class="mix-btn" :class="{ clickbg: payLoding }" @click="!payLoding ? confirm() : ''">确认支付</text>
@@ -36,7 +44,8 @@
 <script>
 import { balance } from '@/api/wallet.js';
 import { createOrderkey,computedOrderkey,orderPay } from '@/api/order.js';
-import { mapState } from 'vuex';
+import { mapState,mapMutations } from 'vuex';
+import { orderData, userinfo } from '@/api/user.js';
 export default {
 	data() {
 		return {
@@ -57,15 +66,20 @@ export default {
 			// #ifdef H5
 			froms: '', //保存h5中数据来源对象
 			// #endif
-			pinkid: '' //保存拼团商品id
+			pinkid: '' ,//保存拼团商品id
+			isP: 0,
 		};
 	},
 	computed: {
 		// #ifdef H5
-		...mapState(['weichatObj'])
+		...mapState(['weichatObj']),
+		...mapState('user',['userInfo'])
 		// #endif
 	},
-	onLoad(options) {
+	onLoad(options) {
+		if(options.isP) {
+			this.isP = options.isP
+		}
 		if (options.type == 1) {
 			this.type = 1;
 			this.orderId = options.ordid;
@@ -82,7 +96,8 @@ export default {
 				// 获取支付金额
 				this.money = data.result.pay_price;
 			});
-		}
+		}
+		this.getUserInfo()
 		// 保存pinkid
 		if (options.pinkid) {
 			this.pinkid = options.pinkid;
@@ -93,7 +108,17 @@ export default {
 			this.now_money = data.now_money;
 		});
 	},
-	methods: {
+	methods: {
+		...mapMutations('user', ['setUserInfo', 'setOrderInfo']),
+		getUserInfo() {
+			userinfo({})
+				.then(({ data }) => {
+					this.setUserInfo(data);
+				})
+				.catch(e => {
+					console.log(e);
+				});
+		},
 		//选择支付方式
 		changePayType(type) {
 			this.payType = type;
@@ -105,6 +130,9 @@ export default {
 			}
 			if (this.payType == 3) {
 				this.payName = 'yue';
+			}
+			if(this.payType == 4) {
+				this.payName = 'pink_integral';
 			}
 		},
 		// 支付金额
@@ -131,6 +159,13 @@ export default {
 						} else {
 							obj.$api.msg(msg);
 						}
+					}
+					if (obj.payName == 'pink_integral' && e.data.status == 'SUCCESS') {
+						if (e.status == 200) {
+							obj.paySuccessTo();
+						} else {
+							obj.$api.msg(msg);
+						}
 					}
 					if (obj.payName == 'weixin' || obj.payName == 'routine') {
 						let da = e.data.result.jsConfig;

+ 5 - 3
pages/order/createOrder.vue

@@ -212,11 +212,13 @@ export default {
 			integralMoney: 0, //积分抵扣金额
 			integralShow: false, //是否显示积分抵扣金额
 			payType: true, //是否可支付
-			pinkid: '' //保存拼团商品id
+			pinkid: '' ,//保存拼团商品id
+			isP: 0,
 		};
 	},
 	onLoad(option) {
-		// 判断是否为拼团商品
+		// 判断是否为拼团商品
+		this.isP = option.isP
 		if (option.type == 'pink') {
 			this.pinkid = option.pinkId;
 			this.cartAdd(option);
@@ -359,7 +361,7 @@ export default {
 				this.$api.msg('请选择收货地址');
 				return false;
 			}
-			let url =  '/pages/money/pay?key='+ this.orderKey
+			let url =  '/pages/money/pay?key='+ this.orderKey + '&isP=' + this.isP
 			if(this.pinkid){
 				url += '&pinkid='+this.pinkid
 			}

+ 1 - 1
pages/product/groupBooking/productGroup.vue

@@ -376,7 +376,7 @@
 						if (obj.type == 1) {
 							// 跳转到支付页
 							uni.navigateTo({
-								url: '/pages/order/createOrder?id=' + da.cartId + '&goodsType=' + obj.goodsType
+								url: '/pages/order/createOrder?id=' + da.cartId + '&goodsType=' + obj.goodsType + '&isP=1'
 							});
 						}
 						if (obj.type == 2) {

+ 2 - 1
pages/user/user.vue

@@ -181,7 +181,8 @@ export default {
 			userMaxDowm: 0 //卡片最高高度
 		};
 	},
-	onShow() {
+	onShow() {
+		this.loadBaseData();
 		// 判断是否已经登录
 		if (this.hasLogin) {
 			this.loadBaseData();