潘超林 2 ヶ月 前
コミット
449cec7f63

+ 13 - 13
app.config.js

@@ -4,23 +4,23 @@
 export const requestConfig = {
 	// BaseUrl: 'https://app.sxdirectpurchase.com/api/',
 	/**接口请求地址 */
-	BaseUrl: 'http://192.168.3.97:9001/api/',
-	
+	// BaseUrl: 'http://192.168.3.97:9001/api/',
+	BaseUrl: 'https://app.sxdirectpurchase.com/api/',
+
 	/**授权回调地址 */
 	// 授权后重定向的回调链接地址, 请使用 urlEncode 对链接进行处理
 	// redirect_uri: "http%3A%2F%2Fne.sxdirectpurchase.com%2F%23%2Fpages%2Findex%2Fpay",
-	
+
 	/*本地测试地址*/
-	redirect_uri: "http%3a%2f%2f192.168.3.183%3a81%2f%23%2fpages%2findex%2fpay%3fshopId%3d110351",
-	
+	redirect_uri: "https://ne.sxdirectpurchase.com/#/pages/index/pay",
+	// redirect_uri: "http://192.168.3.183:81/#/pages/index/pay",
+	redirectOpen: "https://ne.sxdirectpurchase.com/#/pages/index/paySuccess",
 	/**公众号信息 */
-	// appID: "wxad190b75af42ac7e",
-	// appsecret: "934a264458f4de42c5ccbe611d212587",
-	
+	appid: "wxad190b75af42ac7e",
+	appsecret: "934a264458f4de42c5ccbe611d212587",
+
 	/**测试公众号*/
-	appid: "wx0fbc26e298b0d9b9",
-	appsecret: "b24e3b109d6de1f019c4141d34a56781",
-	
-	/**返还多少钱红包 */
-	pay: 10
+	// appid: "wx0fbc26e298b0d9b9",
+	// appsecret: "b24e3b109d6de1f019c4141d34a56781",
+
 }

+ 15 - 10
package.json

@@ -1,11 +1,16 @@
 {
-  "dependencies": {
-    "axios": "^1.8.3",
-    "uview-ui": "^2.0.38",
-    "weixin-jsapi": "^1.1.0"
-  },
-  "devDependencies": {
-    "sass": "^1.85.1",
-    "sass-loader": "^16.0.5"
-  }
-}
+    "id": "tk-view2img",
+    "name": "kt-view2img 小程序截屏插件",
+    "displayName": "kt-view2img 小程序截屏插件",
+    "version": "0.0.1",
+    "description": "小程序截屏插件 将view,image,text 转为图片保存或发送给好友",
+    "keywords": [
+        "截屏,view转图片"
+    ],
+    "dcloudext": {
+        "category": [
+            "前端组件",
+            "通用组件"
+        ]
+    }
+}

+ 119 - 106
pages/index/index.vue

@@ -1,127 +1,140 @@
 <template>
-  <view class="login-main">
-    <view class="login-main-content">
-      <image class="img" src="../../static/images/logo.png" mode=""></image>
-    </view>
-    <view class="login-contont">
-      <view class="login-contont-info">
-        <h5>请确认以下信息并授权登录</h5>
-        <view class="text">获取您的信息(你的头像、信息等)</view>
-      </view>
-      <view class="login-contont-button">
-        <button class="btn" @click="login">授权登录</button>
-      </view>
-      <view class="radio">
-        <u-radio-group v-model="radiovalue">
-          <u-radio value="1" size="30" name="1" iconSize="25">
-            <text class="radioText"
-              >授权同意《用户服务协议》 和《隐私协议》</text
-            ></u-radio
-          >
-        </u-radio-group>
-      </view>
-    </view>
-  </view>
+	<view class="login-main">
+		<view class="login-main-content">
+			<image class="img" src="../../static/images/logo.png" mode=""></image>
+		</view>
+		<view class="login-contont">
+			<view class="login-contont-info">
+				<h5>请确认以下信息并授权登录</h5>
+				<view class="text">获取您的信息(你的头像、信息等)</view>
+			</view>
+			<view class="login-contont-button">
+				<button class="btn" @click="login">授权登录</button>
+			</view>
+			<view class="radio">
+				<u-radio-group v-model="radiovalue">
+					<u-radio value="1" size="30" name="1" iconSize="25">
+						<text class="radioText">授权同意《用户服务协议》 和《隐私协议》</text></u-radio>
+				</u-radio-group>
+			</view>
+		</view>
+	</view>
 </template>
 
 <script>
-import { requestConfig } from "@/app.config.js";
-export default {
-  data() {
-    return {
-      radiovalue: 0,
-    };
-  },
-  onLoad() {},
-  methods: {
-    login() {
-		console.log(this.radiovalue);
-		if(this.radiovalue==1){
-			// ne.sxdirectpurchase.com
-			let url = `https://open.weixin.qq.com/connect/oauth2/authorize?
+	import {
+		requestConfig
+	} from "@/app.config.js";
+	export default {
+		data() {
+			return {
+				radiovalue: 0,
+				shopId: ""
+			};
+		},
+		onLoad(options) {
+			this.shopId = options.shopId;
+			// console.log(this.GetQueryString('shopId'));
+			// this.shopId = this.GetQueryString('shopId')
+		},
+		methods: {
+			GetQueryString(name) {
+				var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
+				var r = window.location.search.substr(1).match(reg);
+				if (r != null) return unescape(r[2]);
+				return null;
+			},
+			login() {
+				console.log(this.radiovalue);
+				if (this.radiovalue == 1) {
+					// ne.sxdirectpurchase.com
+					//地址进行编码,微信官方强制要求编码
+					let redirect_uri = encodeURIComponent(requestConfig.redirect_uri + '?shopId=' + this.shopId)
+					console.log(redirect_uri);
+					let url = `https://open.weixin.qq.com/connect/oauth2/authorize?
 								appid=${requestConfig.appid}
-								&redirect_uri=${requestConfig.redirect_uri}
+								&redirect_uri=${redirect_uri}
 								&response_type=code
 								&scope=snsapi_userinfo
 								&state=STATE
 								#wechat_redirect`;
-			window.location = url;
-		}else{
-				uni.$u.toast('请先同意用户授权!');
-		}
+					window.location = url;
+				} else {
+					uni.$u.toast('请先同意用户授权!');
+				}
 
-    },
-  },
-};
+			},
+		},
+	};
 </script>
 <style scoped lang="scss">
-.u-radio-group--row {
-  justify-content: center;
-}
+	.u-radio-group--row {
+		justify-content: center;
+	}
 
-.radioText {
-  font-weight: 500;
-  font-size: 24rpx;
-  color: #999999;
-  line-height: 34rpx;
-  text-align: left;
-  font-style: normal;
-}
+	.radioText {
+		font-weight: 500;
+		font-size: 24rpx;
+		color: #999999;
+		line-height: 34rpx;
+		text-align: left;
+		font-style: normal;
+	}
 
-.login-main {
-  background: url("../../static/images/back.png") no-repeat;
-  background-size: 100% 100%;
-  width: 100%;
-  display: flex;
-  flex-direction: column;
-  justify-content: space-between;
-  align-items: center;
-  height: 100vh;
-}
+	.login-main {
+		background: url("../../static/images/back.png") no-repeat;
+		background-size: 100% 100%;
+		width: 100%;
+		display: flex;
+		flex-direction: column;
+		justify-content: space-between;
+		align-items: center;
+		height: 100vh;
+	}
 
-.login-contont-button {
-  .btn {
-    margin-top: 20px;
-    width: 90%;
-    height: 90rpx;
-    background: linear-gradient(275deg, #01cf6c 0%, #07e278 100%);
-    border-radius: 44rpx;
-    color: #fff;
-  }
-}
+	.login-contont-button {
+		.btn {
+			margin-top: 20px;
+			width: 90%;
+			height: 90rpx;
+			background: linear-gradient(275deg, #01cf6c 0%, #07e278 100%);
+			border-radius: 44rpx;
+			color: #fff;
+		}
+	}
 
-.login-contont {
-  width: 100%;
-  height: 50%;
+	.login-contont {
+		width: 100%;
+		height: 50%;
 
-  .login-contont-info {
-    text-align: center;
+		.login-contont-info {
+			text-align: center;
 
-    .text {
-      margin-top: 10px;
-      font-weight: 500;
-      font-size: 28rpx;
-      color: #999999;
-      line-height: 40rpx;
-      font-style: normal;
-    }
-  }
-}
+			.text {
+				margin-top: 10px;
+				font-weight: 500;
+				font-size: 28rpx;
+				color: #999999;
+				line-height: 40rpx;
+				font-style: normal;
+			}
+		}
+	}
 
-.radio {
-  text-align: center;
-  margin-top: 10px;
-}
+	.radio {
+		text-align: center;
+		margin-top: 10px;
+	}
 
-.login-main-content {
-  text-align: center;
-  padding-top: 100px;
-  width: 100%;
-  height: 50%;
+	.login-main-content {
+		text-align: center;
+		padding-top: 100px;
+		width: 100%;
+		height: 50%;
 
-  .img {
-    width: 100px;
-    height: 130px;
-  }
-}
-</style>
+		.img {
+			width: 100px;
+			height: 130px;
+		}
+	}
+</style>

+ 81 - 34
pages/index/pay.vue

@@ -9,14 +9,16 @@
 
 		<view class="login-contont">
 			<view class="uInput">
-				<u-input placeholder="请输入金额" border="bottom" type="number" v-model="price" :customStyle="inpustyle">
+
+				<u-input placeholder="请输入金额" border="bottom" :fontSize="40" type="digit"
+					@change="validateInput($event,1)" v-model="price" :customStyle="inpustyle">
 					<span slot="prefix" style="font-size: 30px">¥</span>
 				</u-input>
 			</view>
 			<view class="login-contont-button">
 				<button class="btn" @click="Pay">立即支付</button>
 				<view style="margin-top: 20rpx; font-size: 26rpx">
-					支付成功后,次日有奖励红包,农商小程序领取
+					支付成功后,次日有奖励红包,农商直采小程序领取
 					<!-- 	支付成功立返
 				<span
 						style="color: red">
@@ -88,8 +90,21 @@
 		onLoad(options) {
 			this.shopId = options.shopId
 			this.getInfo();
+			this.getShopInfo();
 		},
 		methods: {
+			validateInput(e, num) {
+				const inputTypeNum = /[^\d]/g //数字
+				switch (num) {
+					case 1:
+						//要写nextTick 不然无效 
+						this.$nextTick(() => {
+							this.listData.integral = e.replace(inputTypeNum, '');
+						})
+						break;
+				}
+			},
+
 			async getShopInfo() {
 				let res = await axios.get(
 					`${requestConfig.BaseUrl}user/app/v1/store/getStoreInfoByScan?shopId=${this.shopId}`, {
@@ -99,7 +114,8 @@
 					});
 				if (res.data.code == 200) {
 					this.shopInfo = res.data.data
-
+				} else {
+					uni.$u.toast(res.data.msg);
 				}
 			},
 
@@ -114,7 +130,10 @@
 				);
 				if (res.data.code == 200) {
 					uni.$u.toast('绑定手机号成功');
+					this.userInfo = res.data.data
 					this.showPhone = false
+					this.getShopInfo()
+
 				}
 
 			},
@@ -139,44 +158,71 @@
 				}
 			},
 			async Pay() {
+				uni.showLoading({
+					title: '支付中'
+				});
+				// uni.hideLoading();
+				// window.open(`${requestConfig.redirectOpen}pages/index/paySuccess`)
+
+				if (!this.price) {
+					uni.$u.toast('请输入支付金额!');
+				}
 				let res = await axios.get(`${requestConfig.BaseUrl}order/app/v1/buyer/order/createOfflineOrder
-					?shopId=110351${this.shopId}&price=${this.price}`, {
+					?shopId=${this.shopId}&price=${this.price}`, {
 					headers: {
 						'token': `${this.userInfo.token}`
 					}
 				});
 				if (res.data.code == 200) {
-					uni.$u.toast('线下订单创建成功!订单id=', res.data.data);
+					//post请求
+					let data = {
+						"orderId": res.data.data, //订单id
+						"orderType": 11, //订单类型  -1--其他 2-司机保证金 3-商品交易  4-线下交易
+						"payKinds": 0, //支付类型  0-微信  1-支付宝
+						"payMeth": 6 //5-微信小程序支付  6-微信H5支付 7-支付宝app支付
+					}
+					const pay = await axios.post(`${requestConfig.BaseUrl}order/app/v1/buyer/order/offlineOrderPay
+						`, data, {
+						headers: {
+							'Token': `${this.userInfo.token}`
+						}
+					});
+					if (pay.data.code == 200) {
+						let res = JSON.parse(pay.data.data.result)
+						console.log(res);
+						WeixinJSBridge.invoke(
+							"getBrandWCPayRequest", {
+								// 公众号名称,由商户传入
+								appId: res.appId,
+								// 时间戳,自1970年以来的秒数
+								timeStamp: res.timeStamp,
+								// 随机串
+								nonceStr: res.nonceStr,
+								package: res.package,
+								// 微信签名方式:
+								signType: res.signType,
+								// 微信签名
+								paySign: res.paySign,
+							},
+							function(res) {
+								if (res.err_msg == "get_brand_wcpay_request:ok") {
+									// 使用以上方式判断前端返回,
+									// 微信团队郑重提示:
+									uni.hideLoading();
+									window.location.href = requestConfig.redirectOpen
+									// res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠。
+								} else {
+									uni.hideLoading();
+									uni.$u.toast('支付失败!');
+								}
+							}
+						);
 
+					} else {
+						uni.hideLoading();
+						uni.$u.toast('支付失败!');
+					}
 				}
-				//post请求
-				// const res = await axios.get(`${requestConfig.BaseUrl}order/app/v1/buyer/order/createOfflineOrder
-				// 	?shopId=110330&price=${this.price}`, {}, {
-				// 	headers: {
-				// 		'Token': `${this.userInfo.token}`
-				// 	}
-				// });
-				// WeixinJSBridge.invoke(
-				// 	"getBrandWCPayRequest", {
-				// 		// 公众号名称,由商户传入
-				// 		appId: requestConfig.appID,
-				// 		// 时间戳,自1970年以来的秒数
-				// 		timeStamp: '',
-				// 		// 随机串
-				// 		nonceStr: '',
-				// 		package: "",
-				// 		// 微信签名方式:
-				// 		signType: "MD5",
-				// 		// 微信签名
-				// 		paySign: '',
-				// 	},
-				// 	function(res) {
-				// 		if (res.err_msg == "get_brand_wcpay_request:ok") {
-				// 			// 使用以上方式判断前端返回,微信团队郑重提示:
-				// 			// res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠。
-				// 		}
-				// 	}
-				// );
 			},
 			async getInfo() {
 				let code = this.GetQueryString("code");
@@ -189,8 +235,9 @@
 						this.showPhone = true
 					} else {
 						this.showPhone = false
+						this.getShopInfo()
 					}
-					this.getShopInfo()
+
 				} else {
 					uni.$u.toast('获取微信登录信息失败!');
 				}

+ 4 - 3
pages/index/paySuccess.vue

@@ -7,9 +7,10 @@
     ></image>
     <span style="font-weight: 600; font-size: 44rpx; color: #333333">支付成功</span>
     <view style="margin-top: 20px">
-      已返
+		奖励红包,次日到账,可进入农商直采小程序查看
+    <!--  已返
       <span style="color: red">{{ requestConfig.pay }}元</span>
-      红包,可进入农商网小程序查看
+      红包,可进入农商网小程序查看 -->
     </view>
     <view style="margin-top: 20px">
       <button class="btn">查看红包</button>
@@ -39,7 +40,7 @@ export default {
 
 .btn {
   margin-top: 20px;
-  width: 400px;
+  width: 600rpx;
   height: 90rpx;
   background: linear-gradient(275deg, #01cf6c 0%, #07e278 100%);
   border-radius: 44rpx;

ファイルの差分が大きいため隠しています
+ 1 - 1
unpackage/dist/build/web/index.html


ファイルの差分が大きいため隠しています
+ 0 - 18
unpackage/dist/build/web/static/js/chunk-vendors.9ab410eb.js


ファイルの差分が大きいため隠しています
+ 0 - 1
unpackage/dist/build/web/static/js/index.5482876c.js


ファイルの差分が大きいため隠しています
+ 0 - 1
unpackage/dist/build/web/static/js/pages-index-index.06cae255.js


ファイルの差分が大きいため隠しています
+ 0 - 1
unpackage/dist/build/web/static/js/pages-index-pay.3d77604d.js