Parcourir la source

积分商城支付修改
客服微信号修改

lyb il y a 4 ans
Parent
commit
c6893b8436
5 fichiers modifiés avec 64 ajouts et 53 suppressions
  1. 2 2
      assets/http/config.js
  2. 0 1
      pages/activity/activityDetail.vue
  3. 1 1
      pages/mine/mine.vue
  4. 60 43
      pages/shop/detail.vue
  5. 1 6
      store/index.js

+ 2 - 2
assets/http/config.js

@@ -1,8 +1,8 @@
 let config = {}
 
-// config.baseURL = 'http://192.168.1.91:2888'
+config.baseURL = 'http://192.168.1.91:2888'
 // config.baseURL = 'http://123.60.225.130:2888'
-config.baseURL = 'https://vote.guosen-fumao.cn/api'
+// config.baseURL = 'https://vote.guosen-fumao.cn/api'
 //是否需要获取手机号
 config.isAuthPhone = true
 config.transformDomains = 'https://m.changyoyo.com'

+ 0 - 1
pages/activity/activityDetail.vue

@@ -189,7 +189,6 @@
 				},
 				//活动设置
 				activitySetting: {},
-				interval: '',
 			}
 		},
 		onShareAppMessage(res) {

+ 1 - 1
pages/mine/mine.vue

@@ -206,7 +206,7 @@
 			jump(url, auth) {
 				if (url == 'kefu') {
 					this.$dialog.showModal('是否添加客服微信?', true, this.vuex_theme.bgColor).then(res => {
-						this.$util.copy('czx19970103')
+						this.$util.copy('guoxinshuzi')
 					})
 					return
 				}

+ 60 - 43
pages/shop/detail.vue

@@ -113,6 +113,8 @@
 		>
 		</u-modal>
 		
+		<webAuthAlert ref="webAuthAlert" @confirm="webAuthConfirm"></webAuthAlert>
+		
 		<login ref="login" @signIn="signIn" @phoneSuccess="phoneSuccess"></login>
 		<toast ref="toast"></toast>
 		<home-btn></home-btn>
@@ -122,9 +124,11 @@
 
 <script>
 	import exchangeSuccess from "@/components/alert/exchangeSuccess.vue"
+	import webAuthAlert from "@/components/alert/webAuthAlert.vue"
 	export default {
 		components: {
-			exchangeSuccess
+			exchangeSuccess,
+			webAuthAlert
 		},
 		data() {
 			return {
@@ -165,7 +169,6 @@
 				confirmStyle: {
 					color: 'white',
 				},
-				interval: '',
 			}
 		},
 		onLoad(options) {
@@ -179,9 +182,6 @@
 			this.confirmStyle.color = this.vuex_theme.bgColor;
 		},
 		onShow() {
-			if(this.vuex_goodsInterval){
-				this.queryOrder();
-			}
 			uni.$on('ADDRESS',(res)=>{
 				this.address=res
 			})
@@ -274,13 +274,47 @@
 			 * 确认兑换
 			 */
 			async confirm() {
+				// #ifdef H5
+				if(this.$isEmpty(this.vuex_gzh_userOpenid)){
+					let code = this.$util.getUrlParam("code");
+					if(this.$isEmpty(code)){
+						this.$refs.webAuthAlert.show = true;
+					}else{
+						this.getWxUserInfo(code)
+					}
+				}else{
+					this.exchangeGoods();
+				}
+				// #endif
+				
+				// #ifdef MP-WEIXIN
+				this.exchangeGoods();
+				// this.$refs.toast.warn('小程序暂未开放现金兑换,请前往H5兑换')
+				// #endif
+			},
+			//获取微信网页授权用户信息
+			async getWxUserInfo(code) {
+				let params = {
+					code: code
+				}
+				let res = await this.$api.wxApp.getH5WxUserInfo(params)
+				if (res.data.success) {
+					this.$u.vuex('vuex_gzh_userOpenid', res.data.data.openid);
+					this.exchangeGoods();
+				} else {
+					this.$refs.toast.error(res.data.msg)
+				}
+			},
+			//商品兑换
+			async exchangeGoods() {
 				let params = {
 					type: this.exchangeType,
 					phone: this.vuex_phone,
 					goodsId: this.id,
 					addressId: this.address.id,
 					num: this.exChangeData.num,
-					activeId: this.vuex_active_setting.defaultActiveId
+					activeId: this.vuex_active_setting.defaultActiveId,
+					openId: this.vuex_gzh_userOpenid
 				}
 				if(this.exchangeType === 2){params.point = this.exChangeData.point;}
 				this.$api.pointgoods.exchange(params).then(res=>{
@@ -294,16 +328,26 @@
 							this.$refs.exchangeSuccess.showSuccess(this.detail.imgUrl)
 						}else{
 							//混合兑换,用户选择纯积分兑换
-							if(!this.$isNotEmpty(res.data.data.qrCodeUrl)){
+							if(!this.$isNotEmpty(res.data.data)){
 								this.$refs.exchangeSuccess.showSuccess(this.detail.imgUrl)
 								return;
 							}
-							// uni.navigateTo({
-							// 	url: `/pages/webview/payOrder?url=${res.data.data.qrCodeUrl}&orderId=${res.data.data.id}`
-							// })
-							this.$u.vuex('vuex_goodsOrder', res.data.data.id);
-							this.$u.vuex('vuex_goodsInterval', true);
-							window.location.href = res.data.data.qrCodeUrl
+					        
+							// #ifdef MP-WEIXIN
+							this.$refs.toast.warn('小程序暂未开放现金兑换,请前往H5兑换')
+							// #endif
+							
+							// #ifdef H5
+							console.log("支付订单",res.data.data)
+							this.$shareConfig.H5Pay(res.data.data).then((res) => {
+								console.log("商品兑换页面res", res)
+								this.$refs.exchangeSuccess.showSuccess(this.detail.imgUrl)
+							},(err) => {
+								console.log("商品兑换页面err", err)
+								this.$refs.toast.error(err.errMsg)
+							})
+							// #endif
+							
 						}
 						
 					}
@@ -311,36 +355,9 @@
 					console.log(error);
 				})
 			},
-			//查询订单状态
-			queryOrder(){
-				let params = {
-					id: this.vuex_goodsOrder
-				}
-				this.interval = setInterval(async() => {
-				  let res = await this.$api.order.orderDetail(params)
-				  if(res.data.success && res.data.data.payStatus === '付款成功'){
-					  this.$refs.exchangeSuccess.showSuccess(this.detail.imgUrl);
-					  this.$u.vuex('vuex_goodsInterval', false);
-					  this.$u.vuex('vuex_goodsOrder', 0);
-					  clearInterval(this.interval)
-				  }
-				}, 1500)
-				this.countDown(); //30秒拿不到支付回调抛出异常处理
-			},
-			countDown(){
-				let seconds = 30;
-				let timer = setInterval(() => {
-					seconds--
-					if (seconds == 0) {
-						if(this.vuex_goodsInterval){
-							this.$refs.toast.error('订单回调异常');
-							this.$u.vuex('vuex_goodsInterval', false);
-							this.$u.vuex('vuex_goodsOrder', 0);
-							clearInterval(this.interval) //清除支付回调接口轮询
-						}
-						clearInterval(timer)
-					}
-				}, 1000)
+			//网页授权
+			webAuthConfirm(){
+				this.$webAuth.getUserOpenid();
 			},
 			cancel(){
 				this.exchangeShow = false;

+ 1 - 6
store/index.js

@@ -17,8 +17,7 @@ try {
 
 // 需要永久存储,且下次APP启动需要取出的,在state中的变量名
 let saveStateKeys = ['vuex_audit', 'vuex_userId', 'vuex_phone', 'vuex_skin',
-	'vuex_theme', 'vuex_active_setting', 'vuex_isCMCC' , 'vuex_voteInterval' , 'vuex_voteOrder',
-	'vuex_goodsInterval', 'vuex_goodsOrder', 'vuex_gzh_userOpenid'
+	'vuex_theme', 'vuex_active_setting', 'vuex_isCMCC', 'vuex_gzh_userOpenid'
 ];
 
 // 保存变量到本地存储中
@@ -47,10 +46,6 @@ const store = new Vuex.Store({
 		vuex_theme: lifeData.vuex_theme ? lifeData.vuex_theme : config.themeRed.theme,
 		vuex_active_setting: lifeData.vuex_active_setting ? lifeData.vuex_active_setting : {},
 		vuex_isCMCC: lifeData.vuex_isCMCC ? lifeData.vuex_isCMCC : false,
-		vuex_voteInterval: lifeData.vuex_voteInterval ? lifeData.vuex_voteInterval : false,
-		vuex_voteOrder: lifeData.vuex_voteOrder ? lifeData.vuex_voteOrder : 0,
-		vuex_goodsInterval: lifeData.vuex_goodsInterval ? lifeData.vuex_goodsInterval : false,
-		vuex_goodsOrder: lifeData.vuex_goodsOrder ? lifeData.vuex_goodsOrder : 0,
 		vuex_gzh_userOpenid: lifeData.vuex_gzh_userOpenid ? lifeData.vuex_gzh_userOpenid : null
 	},