zhengkaixin 3 éve
szülő
commit
de9a0f8d0e

+ 9 - 0
apis/weixin.js

@@ -11,6 +11,15 @@ export function wxpay(data) {
 		method: 'post',
 	})
 }
+
+export function alpay(data) {
+	return request({
+		url: '/aliPay/tradePrecreatePay',
+		data: data,
+		method: 'post',
+	})
+}
+
 //根据code换取openid
 export function getDataByCode(code) {
 	return request({

+ 1 - 0
package.json

@@ -8,6 +8,7 @@
  "dependencies": {
   "compression-webpack-plugin": "^8.0.1",
   "echarts": "^5.3.2",
+  "qrcodejs2": "^0.0.2",
   "uni-crazy-router": "0.0.31",
   "uni-simple-router": "^2.0.1",
   "uview-ui": "^1.8.4",

+ 6 - 6
pages/index/index.vue

@@ -3,7 +3,7 @@
 
 		<!-- 头部图片 -->
 		<view class="banner">
-			<img src="/static/img/banner1.jpg" alt="">
+			<img src="static/img/banner1.jpg" alt="">
 		</view>
 
 
@@ -52,7 +52,7 @@
 		<!-- 站点 -->
 		<!-- <view class="station">
 			<view class="img-box">
-				<img src="/static/img/Frame 198 (1).png" alt="">
+				<img src="static/img/Frame 198 (1).png" alt="">
 			</view>
 			<view class="text"> 
 				
@@ -93,7 +93,7 @@
 					</view>
 				</view>
 				<view class="img-box">
-					<img src="/static/img/暂无网络信号-缺省页 1.png">
+					<img src="static/img/暂无网络信号-缺省页 1.png">
 				</view>
 			</view>
 
@@ -114,7 +114,7 @@
 			</view>
 		 </view>
 	 	<view class="img-box">
-	 		<img src="/static/img/等待中-缺省页.png">
+	 		<img src="static/img/等待中-缺省页.png">
 	 	</view>
 	 </view> -->
 	 <!-- <view class="state2 state">
@@ -130,7 +130,7 @@
 	 			</view>
 	 		 </view>
 	 	<view class="img-box">
-	 		<img src="/static/img/充电中-缺省页.png">
+	 		<img src="static/img/充电中-缺省页.png">
 	 	</view>
 	 </view> -->
 	 <!-- <view class="state3 state">
@@ -146,7 +146,7 @@
 	 			</view>
 	 		 </view>
 	 	<view class="img-box">
-	 		<img src="/static/img/已充满-缺省页.png">
+	 		<img src="static/img/已充满-缺省页.png">
 	 	</view>
 	 </view> -->
 

+ 2 - 2
pages/searchPile/searchPileMap.vue

@@ -49,7 +49,7 @@
 			<view class="station-icon3"><text class="iconfont">&#xe606;</text>
 				<view class="corner3"></view>
 			</view>
-			<img src="/static/img/地图@1x.png" alt="">
+			<img src="static/img/地图@1x.png" alt="">
 		</view>
 
 		<view class="charing-slow">
@@ -77,7 +77,7 @@
 					<text class="iconfont distance-font">&#xe615;</text><text class="text">1.2公里 3分钟</text>
 				</view>
 			</view>
-			<view class="img-box"><img src="/static/img/定位.png" alt=""></view>
+			<view class="img-box"><img src="static/img/定位.png" alt=""></view>
 		</view>
 
 		<u-tabbar v-model="current" :list="tabbarList" active-color="#009143"></u-tabbar>

+ 1 - 1
pages/searchPile/stationAndPile/stationDetails.vue

@@ -21,7 +21,7 @@
 
 			</view>
 			<view class="station-address">
-				<img src="/static/img/Frame 201.png" alt="">
+				<img src="static/img/Frame 201.png" alt="">
 				<view class="address-text" >
 					{{info.station.address}}
 				</view>

+ 1 - 1
pages/user/car/index.vue

@@ -2,7 +2,7 @@
 	<view>
 		<u-navbar title="车辆管理"></u-navbar>
 		<view class="carNone" v-if="carList.length == 0">
-			<img src="/static/img/none2.svg" alt="">
+			<img src="static/img/none2.svg" alt="">
 			<p>暂无绑定车辆</p>
 			<view class="carNone-btn" @click="addCar">
 				添加车牌

+ 101 - 43
pages/user/finance/recharge.vue

@@ -5,7 +5,7 @@
 			<view class="title">选择充值金额</view>
 			<p>当前余额{{detail.balance}}</p>
 			<view class="rechargeMain">
-				<view class="recharge-item" :class="otherNum&&moneyActiveClass == item.id ? 'active' : ''"
+				<view class="recharge-item" :class="!otherNum&&moneyActiveClass == item.id ? 'active' : ''"
 					v-for="(item,index) in moneyList" :key="item.id" @click="moneyClick(item.id,item)">
 					{{item.rechargeAmount}}
 					<view class="amount">赠20元</view>
@@ -15,8 +15,7 @@
 			<p>其他充值金额</p>
 			<view 
 			
-			@click="moneyClick(-1)"
-			:class="!otherNum&&moneyActiveClass == -1? 'active' : ''"
+			:class="otherNum? 'active' : ''"
 			class="recharge-input self-stop">
 				<u-input v-model="otherNum" @input="ckInput" type="text" :border="true" />
 			</view>
@@ -24,7 +23,7 @@
 			<view class="recharge-radio">
 				<u-radio-group v-model="value2" @change="radioGroupChange" :wrap="true" width="100%">
 					<u-radio active-color="#00B962" @change="radioChange" v-for="(item, index) in list" :key="index"
-						:name="item.name" :disabled="item.disabled" width="100%">
+						:name="item.id" :disabled="item.disabled" width="100%">
 						<view class="recharge-radio-item">
 							<u-icon :name="item.icon" custom-prefix="custom-icon" :color="item.color" size="48">
 							</u-icon>
@@ -35,6 +34,23 @@
 					</u-radio>
 				</u-radio-group>
 			</view>
+					<u-modal v-model="showModel" 
+					:show-cancel-button="true"
+					 @confirm="confirm"
+					confirm-text="支付成功?"
+					title="扫码支付" >
+						<view    style="
+								text-align: center;
+							">
+							<img id="qrcode2" :src="qrCodeImg" >
+						</view>
+						<view    style="
+								text-align: center;
+							">请使用支付宝扫码</view>
+						
+					</u-modal>
+			<img id="qrcode" style="display: none;" >
+					
 			<view class="recharge-btn">
 				<u-checkbox-group>
 					<u-checkbox v-model="checked" shape="circle" @change="checkboxChange()">我已阅读并同意《充值协议》</u-checkbox>
@@ -49,6 +65,10 @@
 
 <script>
 	import * as Pay from '@/apis/weixin.js'
+	import QRCode from 'qrcodejs2'
+	import {
+		convertCanvasToImage,
+	} from '@/utils'
 	import {
 		wxPayJs
 	} from '@/utils/wxpay'
@@ -56,26 +76,31 @@
 	export default {
 		data() {
 			return {
+				showModel:false,
 				selectItem:{},
 				userId: '',
 				detail: {},
 				moneyActiveClass: 1,
+				submitForm:{},
+				qrCodeImg:"",
 				moneyList: [
 
 				],
 				list: [{
+						id:'0',
 						name: '微信支付',
 						icon: 'wechat-pay-fill',
 						color: '#22ac38',
 					},
 					{
+						id:'1',
 						name: '支付宝支付',
 						icon: 'alipay-fill',
 						color: '#1677ff',
 					},
 				],
 				// u-radio-group的v-model绑定的值如果设置为某个radio的name,就会被默认选中
-				value2: '微信支付',
+				value2: '0',
 				otherNum:"",
 				value1: '',
 				checked: true,
@@ -89,6 +114,9 @@
 			this.init();
 		},
 		methods: {
+			confirm(){
+				
+			},
 			ckInput(text){
 				if(text.indexOf('.')>0){
 					
@@ -114,32 +142,7 @@
 				}
 				
 			},
-			submit() {
-				uni.showLoading({
-					title: "加载中",
-					mask: true,
-				})
-				Pay.wxpay({
-					chargingMarketingId: this.chargingMarketingId,
-					type:2
-				}).then((response) => {
-					if (!response.result) {
-						uni.showToast({
-							title: response.message
-						})
-						return
-					}
-					var data = response.data
-					
-					uni.hideLoading()
-					console.log("Pay+" + new Date().getTime())
-					wxPayJs(data);
-
-				}).catch(error => {
-					this.$refs.common.showLoading(false, error);
-
-				})
-			},
+			
 			init1() {
 				uni.showLoading({
 					title: "加载中",
@@ -189,8 +192,9 @@
 			},
 			moneyClick(index,item) {
 				this.moneyActiveClass = index;
-				this.selectItem=item;
-				
+				if(item){
+					this.selectItem=item;
+				}
 			},
 			// 选中某个单选框时,由radio时触发
 			radioChange(e) {
@@ -203,19 +207,73 @@
 			checkboxChange() {
 				this.checked = !this.checked;
 			},
+			alpy(){
+				uni.showLoading({
+					title: "加载中",
+					mask: true,
+				})
+				Pay.alpay(this.submitForm).then((response) => {
+					
+					let qrcode = new QRCode('qrcode', {
+						width: 200,
+						height: 200,
+						text: response.data,
+						correctLevel: QRCode.CorrectLevel.M,
+					
+					})
+					
+					var canvas = document.getElementsByTagName('canvas')[0];
+					this.qrCodeImg = convertCanvasToImage(canvas);
+					uni.hideLoading()
+					this.showModel=true
+						
+				}).catch(error => {
+						uni.showToast({
+						
+							title: error
+						})
+				})
+			},
+			wxpy(){
+				uni.showLoading({
+					title: "加载中",
+					mask: true,
+				})
+				Pay.wxpay(this.submitForm).then((response) => {
+					
+					if(!response.result){		
+						uni.showToast({
+							title:  response.message
+						})
+						return
+					}
+					var data = response.data
+					uni.hideLoading()
+					console.log("Pay+"+new Date().getTime())		
+					wxPayJs(data);
+						
+				}).catch(error => {
+					uni.showToast({
+					
+						title: error
+					})
+ 						
+				})
+			},
 			rechargeNow() {
-				if(this.moneyActiveClass==-1&&!this.otherNum){
-					this.submitForm.chargeStrategy=0;
-					this.submitForm.amount=0
+				this.submitForm={};
+				if(!this.otherNum){
+					this.submitForm.chargingMarketingId=this.selectItem.id;
 				}else{
-					this.submitForm.chargeStrategy=2;
-					if(this.otherNum){
-						this.submitForm.amount=this.otherNum
-					}else{
-						this.submitForm.amount=this.moneyActiveClass
-					}
+					this.submitForm.amount=this.otherNum
 				}
 				console.log(this.submitForm)
+				if(this.value2=="0"){
+					this.wxpy()
+				}else{
+					this.alpy()
+				}
+				
 			}
 		},
 		onShow() {
@@ -257,7 +315,7 @@
 			margin-top: 4px;
 		}
 	.self-stop.active{
-		 
+		     border: 1px solid;
 			background-color: #EFFFF7;
 			border-color: #00B962;
 			color: #00B962;

+ 1 - 1
pages/user/finance/refundList.vue

@@ -43,7 +43,7 @@
 						</view>
 					</view>
 					<!-- <view class="refundList-none">
-						<u-image width="200px" height="200px" src="/static/img/none.svg"></u-image>
+						<u-image width="200px" height="200px" src="static/img/none.svg"></u-image>
 					</view> -->
 				</view>
 			</view>