twt il y a 2 ans
Parent
commit
055908c149
4 fichiers modifiés avec 61 ajouts et 5 suppressions
  1. 1 1
      pages/index/index.vue
  2. 56 0
      pages/shop/confirm.vue
  3. 2 2
      pages/shop/shop.vue
  4. 2 2
      utils/request.js

+ 1 - 1
pages/index/index.vue

@@ -201,7 +201,7 @@
 			var that=this;
 			 this.$common.getExtStoreId()
 			 var ext=this.$common.getExtStoreId();
-			console.log(ext)
+			//console.log( String(Date.now()))
 			this.shopId=ext.shopId;
 			this.url=ext.url;
 			// uni.setStorage({

+ 56 - 0
pages/shop/confirm.vue

@@ -143,11 +143,25 @@
 				this.$http('openMallOrder/submitOrder', params,'POST').then(res => {
 					uni.hideLoading();
 					if(res.code==0){
+						
+						this.unifiedPay(res.data)
+					}else{
 						uni.showToast({
 							title: res.msg,
 							icon: 'none',
 							duration: 3000
 						});
+					}
+				 })
+			},
+			unifiedPay(res){
+				this.$http('openMallOrder/unifiedPay', {
+					sheetId:res.id
+				},'POST').then(res => {
+					
+					if(res.code==0){
+						
+						this.requestPayment(res.data)
 					}else{
 						uni.showToast({
 							title: res.msg,
@@ -157,6 +171,48 @@
 					}
 				 })
 			},
+			requestPayment(res){
+				var payInfo=res;
+				console.log(payInfo)
+				console.log(String(Date.now()))
+				uni.requestPayment({
+					provider: 'wxpay',
+					//timeStamp: String(Date.now()),
+					timeStamp: payInfo.timeStamp,
+					nonceStr: payInfo.nonceStr,
+					package:payInfo.package,
+					signType: payInfo.signType,
+					paySign: payInfo.paySign,
+					appid:payInfo.appId,	
+					/* provider: 'wxpay',
+					orderInfo:{
+						"appid":payInfo.appid,  // 微信开放平台 - 应用 - AppId,注意和微信小程序、公众号 AppId 可能不一致
+						"noncestr": payInfo.nonceStr, // 随机字符串
+						 "package": "Sign=WXPay",         // 固定值
+						"partnerid":payInfo.mchId,      // 微信支付商户号
+						"prepayid": payInfo.prepayId, // 统一下单订单号 
+						"timeStamp": String(Date.now()),      // 时间戳(单位:秒)
+						"sign": payInfo.sign // 签名,这里用的 MD5/RSA 签名
+					}, */
+				    success: function (res) {
+				        console.log('success:' + JSON.stringify(res));
+						 uni.showToast({
+							 title: '支付成功',
+							 icon:'none',
+							 duration: 2000
+						 });
+						
+				    },
+				    fail: function (err) {
+					  console.log(err)
+				      uni.showToast({
+						 title: '支付失败',
+						 icon:'none',
+						 duration: 2000
+				      });			 
+				    }
+				}); 
+			},
 			openGoodsDetailById(){
 				this.$http('openMall/openGoodsDetailById', {
 				  id:this.id

+ 2 - 2
pages/shop/shop.vue

@@ -56,8 +56,8 @@
 	   					<view class="goodsPrice">
 	   						<view class="goodsPrice1">店庆价</view>
 	   						<view class="goodsPrice2">¥</view>
-	   						<view class="goodsPrice3">{{item.scribingPrice?item.scribingPrice:item.salePrice}}</view>
-	   						<view class="goodsPrice4" v-if="item.scribingPrice">¥{{item.salePrice}}</view>
+	   						<view class="goodsPrice3">{{item.salePrice?item.salePrice:item.scribingPrice}}</view>
+	   						<view class="goodsPrice4" v-if="item.salePrice">¥{{item.scribingPrice}}</view>
 	   					</view>
 	   				</view>
 	   			</view>

+ 2 - 2
utils/request.js

@@ -1,6 +1,6 @@
 //测试地址
-const baseUrl = 'http://api.dms.66km.com.cn/'
-//const baseUrl = 'http://192.168.0.122:20187/'
+//const baseUrl = 'http://api.dms.66km.com.cn/'
+const baseUrl = 'http://192.168.0.122:20187/'
 
 //正式地址