guhongwei 2 роки тому
батько
коміт
a912b31486
6 змінених файлів з 231 додано та 167 видалено
  1. 1 1
      common/api.js
  2. 3 3
      config.js
  3. 1 1
      manifest.json
  4. 74 69
      pagesHome/order/order.vue
  5. 36 38
      pagesMy/address/index.vue
  6. 116 55
      pagesMy/order/index.vue

+ 1 - 1
common/api.js

@@ -11,7 +11,7 @@ const getDomain = (uri, method, type) => {
 			return url + `/point/v1/api` + uri;
 		} else if (system.uniPlatform == 'mp-weixin') {
 			if (wx_env.envVersion == 'develop' || wx_env.envVersion == 'trial') {
-				return url + `/${config.wx_dev}/point/v1/api` + uri;
+				return url + `${config.wx_dev}/point/v1/api` + uri;
 			} else if (wx_env.envVersion == 'release') {
 				return url + '/point/v1/api' + uri;
 			}

+ 3 - 3
config.js

@@ -2,18 +2,18 @@
 const wx_min = uni.getAccountInfoSync();
 // 设备信息
 const system = uni.getSystemInfoSync();
-let wx_projectkey = 'tnhqApp';
+let wx_projectkey = 'tehqApp';
 
 if (system.uniPlatform == 'mp-weixin') {
 	let envV = wx_min.miniProgram.envVersion;
-	if (envV == 'develop' || envV == 'trial') wx_projectkey = 'pointApp';
+	// if (envV == 'develop' || envV == 'trial') wx_projectkey = 'pointApp';
 }
 export default {
 	serverUrl: 'https://broadcast.waityou24.cn',
 	// serverUrl: 'http://192.168.223.1:12111',
 	wx_projectkey: wx_projectkey,
 	wx_miniProgram: wx_min.miniProgram,
-	wx_dev: 'dev',
+	wx_dev: '', // /dev
 	system: system,
 	share: {},
 	my_menu: [ //

+ 1 - 1
manifest.json

@@ -128,7 +128,7 @@
     "quickapp" : {},
     /* 小程序特有相关 */
     "mp-weixin" : {
-        "appid" : "wx8cdd28824dfcdf19",
+        "appid" : "wx928648edf0df1882",
         "setting" : {
             "urlCheck" : true,
             "postcss" : true,

+ 74 - 69
pagesHome/order/order.vue

@@ -108,6 +108,8 @@
 		},
 		data() {
 			return {
+				// 设备平台信息
+				system: {},
 				popup: {
 					type: '1'
 				},
@@ -158,6 +160,9 @@
 					success: function(res) {
 						let user = that.$jwt(res.data);
 						that.$set(that, `user`, user);
+						// 设备平台信息
+						let config = that.$config;
+						that.$set(that, `system`, config.system);
 						that.search()
 					},
 					fail: function(err) {
@@ -226,8 +231,9 @@
 			// 提交订单
 			async toSubmit() {
 				const that = this;
+				let system = that.system;
 				if (that.address) {
-					let data = {
+					let obj = {
 						address: that.address,
 						goods: that.orderList,
 						total_detail: that.total_detail,
@@ -235,85 +241,84 @@
 						type: that.type,
 						inviter: that.inviter
 					}
-					if (that.group_id) {
-						data.group = that.group_id
-					}
-					const arr = await that.$api(`/order`, 'POST', data)
-					if (arr.errcode == '0') {
-						uni.getStorage({
-							key: 'system',
-							success: async function(res) {
-								// 微信小程序支付
-								if (res.data.uniPlatform == "mp-weixin") {
-									uni.showLoading({
-										title: '加载中'
-									})
-									const res = await that.$api('/pay/toPayOrder', 'POST', {
-										order_id: arr.data,
-										type: '0'
-									})
-									uni.requestPayment({
-										"provider": "wxpay",
-										...res.data,
-										async success(res) {
-											const group = await that.$api('/group/getGroup',
-												'GET', {
-													order_id: arr.data,
+					if (that.group_id) obj.group = that.group_id;
+					// 创建订单
+					let p1 = await that.$api(`/order`, 'POST', obj);
+					if (p1.errcode == '0') {
+						if (system.uniPlatform == "mp-weixin") {
+							// 微信支付
+							uni.showLoading({
+								title: '加载中'
+							})
+							// 支付信息
+							let p2 = await that.$api('/pay/toPayOrder', 'POST', {
+								order_id: p1.data,
+								type: '0'
+							})
+							if (p2.errcode == '0' && p2.data.paySign) {
+								uni.requestPayment({
+									"provider": "wxpay",
+									...p2.data,
+									success: async function(res) {
+										// 获取团信息
+										let p3 = await that.$api('/group/getGroup', 'GET', {
+											order_id: p1.data,
+										})
+										if (p3.errcode == '0') {
+											uni.hideLoading();
+											if (p3.data) {
+												uni.reLaunch({
+													url: `/pagesHome/group/share?id=${p3.data}`
 												})
-											if (group.errcode == '0') {
-												if (group.data) {
-													uni.hideLoading();
-													uni.reLaunch({
-														url: `/pagesHome/group/share?id=${group.data}`
-													})
-												} else {
-													uni.hideLoading();
-													uni.reLaunch({
-														url: `/pagesMy/order/index?status=${'1'}`
-													})
-												}
 											} else {
-												uni.showToast({
-													title: group.errmsg,
-													icon: 'none'
+												uni.reLaunch({
+													url: `/pagesMy/order/index?status=${'1'}`
 												})
 											}
-										},
-										fail(e) {
+										} else {
 											uni.showToast({
-												title: `支付失败`,
+												title: p3.errmsg,
 												icon: 'none'
 											})
-											uni.hideLoading();
-											uni.reLaunch({
-												url: `/pagesMy/order/index?status=${'0'}`
-											})
 										}
-									})
-								} else if (res.data.uniPlatform == "app") {
-									// app支付
-									uni.requestPayment({
-										provider: 'alipay',
-										orderInfo: 'orderInfo', //微信、支付宝订单数据 【注意微信的订单信息,键值应该全部是小写,不能采用驼峰命名】
-										success: function(res) {
-											console.log('success:' + JSON.stringify(res));
-										},
-										fail: function(err) {
-											console.log('fail:' + JSON.stringify(err));
-										}
-									});
-								} else {
-									uni.showToast({
-										title: `平台不支持支付`,
-										icon: 'none'
-									})
+									},
+									fail: function(err) {
+										uni.showToast({
+											title: `支付失败`,
+											icon: 'none'
+										})
+										uni.hideLoading();
+										uni.reLaunch({
+											url: `/pagesMy/order/index?status=${'0'}`
+										})
+									}
+								})
+							} else {
+								uni.showToast({
+									title: p2.errmsg,
+									icon: 'none'
+								})
+							}
+						} else if (system.uniPlatform == "app") {
+							uni.requestPayment({
+								provider: 'alipay',
+								orderInfo: 'orderInfo',
+								success: function(res) {
+									console.log('success:' + JSON.stringify(res));
+								},
+								fail: function(err) {
+									console.log('fail:' + JSON.stringify(err));
 								}
-							},
-							fail: function(err) {}
-						})
+							});
+						} else {
+							uni.showToast({
+								title: `平台不支持支付`,
+								icon: 'none'
+							})
+						}
 					} else {
 						uni.showToast({
-							title: arr.errmsg,
+							title: p1.errmsg,
 							icon: 'none'
 						})
 					}

+ 36 - 38
pagesMy/address/index.vue

@@ -204,47 +204,45 @@
 			toWxaddress() {
 				const that = this;
 				let user = that.user;
-				uni.getStorage({
-					key: 'system',
-					success: function(res) {
-						if (res.data.uniPlatform == 'app') {
-							uni.showToast({
-								title: '请进入微信小程序进行获取微信地址',
-								icon: 'none'
-							})
-						} else if (res.data.uniPlatform == 'mp-weixin') {
-							uni.chooseAddress({
-								success: async function(add) {
-									let params = {
-										customer: user._id,
-										name: add.userName,
-										phone: add.telNumber,
-										province: add.provinceName,
-										city: add.cityName,
-										area: add.countyName,
-										address: add.detailInfo
-									}
-									const arr = await that.$api(`/address`, 'POST', params);
-									if (arr.errcode == '0') {
-										uni.showToast({
-											title: '添加收货地址成功',
-											icon: 'none'
-										})
-										that.clearPage()
-									} else {
-										uni.showToast({
-											title: arr.errmsg,
-											icon: 'none'
-										})
-									}
-								},
-								fail: function() {
+				let config = that.$config;
+				if (config.system) {
+					if (config.system.uniPlatform == 'app') {
+						uni.showToast({
+							title: '请进入微信小程序进行获取微信地址',
+							icon: 'none'
+						})
+					} else if (config.system.uniPlatform == 'mp-weixin') {
+						uni.chooseAddress({
+							success: async function(add) {
+								let params = {
+									customer: user._id,
+									name: add.userName,
+									phone: add.telNumber,
+									province: add.provinceName,
+									city: add.cityName,
+									area: add.countyName,
+									address: add.detailInfo
+								}
+								const arr = await that.$api(`/address`, 'POST', params);
+								if (arr.errcode == '0') {
+									uni.showToast({
+										title: '添加收货地址成功',
+										icon: 'none'
+									})
 									that.clearPage()
+								} else {
+									uni.showToast({
+										title: arr.errmsg,
+										icon: 'none'
+									})
 								}
-							})
-						}
+							},
+							fail: function() {
+								that.clearPage()
+							}
+						})
 					}
-				})
+				}
 			},
 			// 编辑
 			toCommon(e) {

+ 116 - 55
pagesMy/order/index.vue

@@ -135,6 +135,8 @@
 			return {
 				// 系统设置
 				config: {},
+				// 设备信息
+				system: {},
 				user: {},
 				status: '',
 				searchInfo: {},
@@ -199,6 +201,9 @@
 					key: 'config',
 					success: function(res) {
 						if (res.data) that.$set(that, `config`, res.data)
+						// 设备平台信息
+						let config = that.$config;
+						that.$set(that, `system`, config.system);
 					},
 					fail: function(err) {
 						console.log(err);
@@ -325,63 +330,119 @@
 				});
 			},
 			// 付款
-			toPay(e) {
+			async toPay(e) {
 				const that = this;
-				uni.getStorage({
-					key: 'system',
-					success: async function(res) {
-						// 微信小程序支付
-						if (res.data.uniPlatform == "mp-weixin") {
-							uni.showLoading({
-								title: '加载中'
-							})
-							const res = await that.$api('/pay/toPayOrder', 'POST', {
-								order_id: e,
-								type: '0'
-							})
-							uni.requestPayment({
-								"provider": "wxpay",
-								...res.data,
-								success(res) {
-									uni.showToast({
-										title: '支付成功',
-										icon: 'none'
-									})
-									uni.hideLoading();
-									that.clearPage();
-									that.search();
-								},
-								fail(e) {
-									uni.showToast({
-										title: `支付失败`,
-										icon: 'none'
-									})
-									uni.hideLoading();
-									that.clearPage();
-									that.search();
-								}
-							})
-						} else if (res.data.uniPlatform == "app") {
-							// app支付
-							uni.requestPayment({
-								provider: 'alipay',
-								orderInfo: 'orderInfo', //微信、支付宝订单数据 【注意微信的订单信息,键值应该全部是小写,不能采用驼峰命名】
-								success: function(res) {
-									console.log('success:' + JSON.stringify(res));
-								},
-								fail: function(err) {
-									console.log('fail:' + JSON.stringify(err));
-								}
-							});
-						} else {
-							uni.showToast({
-								title: `平台不支持支付`,
-								icon: 'none'
-							})
+				let system = that.system;
+				if (system.uniPlatform == "mp-weixin") {
+					uni.showLoading({
+						title: '加载中'
+					})
+					// 支付信息
+					let p2 = await that.$api('/pay/toPayOrder', 'POST', {
+						order_id: e,
+						type: '0'
+					})
+					if (p2.errcode == '0' && p2.data.paySign) {
+						uni.requestPayment({
+							"provider": "wxpay",
+							...p2.data,
+							success: function(res) {
+								uni.showToast({
+									title: '支付成功',
+									icon: 'none'
+								})
+							},
+							fail: function(err) {
+								uni.showToast({
+									title: `支付失败`,
+									icon: 'none'
+								})
+							},
+							complete: function() {
+								uni.hideLoading();
+								that.clearPage();
+								that.search();
+							}
+						})
+					} else {
+						uni.showToast({
+							title: p2.errmsg || '错误信息',
+							icon: 'none'
+						})
+					}
+				} else if (res.data.uniPlatform == "app") {
+					// app支付
+					uni.requestPayment({
+						provider: 'alipay',
+						orderInfo: 'orderInfo',
+						success: function(res) {
+							console.log('success:' + JSON.stringify(res));
+						},
+						fail: function(err) {
+							console.log('fail:' + JSON.stringify(err));
 						}
-					},
-					fail: function(err) {}
-				})
+					});
+				} else {
+					uni.showToast({
+						title: `平台不支持支付`,
+						icon: 'none'
+					})
+				}
+				// uni.getStorage({
+				// 	key: 'system',
+				// 	success: async function(res) {
+				// 		// 微信小程序支付
+				// 		if (res.data.uniPlatform == "mp-weixin") {
+				// 			uni.showLoading({
+				// 				title: '加载中'
+				// 			})
+				// 			const res = await that.$api('/pay/toPayOrder', 'POST', {
+				// 				order_id: e,
+				// 				type: '0'
+				// 			})
+				// 			uni.requestPayment({
+				// 				"provider": "wxpay",
+				// 				...res.data,
+				// 				success(res) {
+				// 					uni.showToast({
+				// 						title: '支付成功',
+				// 						icon: 'none'
+				// 					})
+				// 					uni.hideLoading();
+				// 					that.clearPage();
+				// 					that.search();
+				// 				},
+				// 				fail(e) {
+				// 					uni.showToast({
+				// 						title: `支付失败`,
+				// 						icon: 'none'
+				// 					})
+				// 					uni.hideLoading();
+				// 					that.clearPage();
+				// 					that.search();
+				// 				}
+				// 			})
+				// 		} else if (res.data.uniPlatform == "app") {
+				// 			// app支付
+				// 			uni.requestPayment({
+				// 				provider: 'alipay',
+				// 				orderInfo: 'orderInfo', //微信、支付宝订单数据 【注意微信的订单信息,键值应该全部是小写,不能采用驼峰命名】
+				// 				success: function(res) {
+				// 					console.log('success:' + JSON.stringify(res));
+				// 				},
+				// 				fail: function(err) {
+				// 					console.log('fail:' + JSON.stringify(err));
+				// 				}
+				// 			});
+				// 		} else {
+				// 			uni.showToast({
+				// 				title: `平台不支持支付`,
+				// 				icon: 'none'
+				// 			})
+				// 		}
+				// 	},
+				// 	fail: function(err) {}
+				// })
 			},
 			// 确认收货
 			toConfirm(e) {