Преглед на файлове

Signed-off-by: liuboyan <632697560@qq.com>
1

liuboyan преди 4 години
родител
ревизия
518ad24d40
променени са 5 файла, в които са добавени 201 реда и са изтрити 35 реда
  1. 4 0
      config/api.js
  2. 5 0
      pages.json
  3. 3 0
      pages/index/index.vue
  4. 181 0
      pagesMain/contractInfo.vue
  5. 8 35
      pagesMain/openMember.vue

+ 4 - 0
config/api.js

@@ -75,6 +75,10 @@ module.exports = {
 	getMemberCardInfoAfterCoupon: API_BASE + '/v2/student/myCenter/getMemberDetailAfterCoupon',
 	//  获取可购买会员卡学员列表
 	getAllStudentList: API_BASE + '/v2/student/myCenter/selectAllStudent',
+	//  获取合同模板
+	getContractInfo: API_BASE + '/v2/student/contract/download',
+	//  提交签字合同表单
+	submitContractForm: API_BASE + '/v2/student/contract/submit',
 	//  获取支付回调数据
 	getPayParams: API_BASE + '/v2/student/myCenter/getWxPayParams',
 	//  获取支付结果

+ 5 - 0
pages.json

@@ -112,6 +112,11 @@
 			"style": {
 				"navigationBarTitleText": "确认开通"
 			}
+		}, {
+			"path": "contractInfo",
+			"style": {
+				"navigationBarTitleText": "合同协议"
+			}
 		}, {
 			"path": "payResult",
 			"style": {

+ 3 - 0
pages/index/index.vue

@@ -92,6 +92,9 @@
 					url: '/pages/login/index'
 				});
 			}
+				// uni.navigateTo({
+				// 	url: '/pagesMain/contractInfo?memberCardId=1&couponId=&studentId=2628'
+				// });
 		},
 		onPullDownRefresh() {
 			this.initialize()

+ 181 - 0
pagesMain/contractInfo.vue

@@ -0,0 +1,181 @@
+<template>
+	<view class="content">
+		<!-- <u-image width="100vw" height="100vh" :src="contractInfo.url"></u-image> -->
+		<web-view :src="contractInfo.url" class="web-view"></web-view>
+		<view class="canvas-container">
+			<canvas canvas-id="canvas" id="canvas" :disable-scroll="true" style="width: 100%; height: 200px;background-color: #FFFFFF;"
+			 @touchstart="handleTouchStart($event)" @touchmove="handleTouchMove($event)" @touchend="handleTouchEnd($event)"
+			 @touchcancel="handleEnd($event)"></canvas>
+		</view>
+		<view class="handle-fix-box">
+			<u-button type="warning" shape="circle" :ripple="true" :custom-style="customStyle" @click="toPay()">确定支付</u-button>
+		</view>
+		<u-top-tips ref="uTips"></u-top-tips>
+	</view>
+</template>
+
+<script>
+	var context = null
+	import {
+		mapGetters
+	} from 'vuex'
+	const NET = require('@/utils/request')
+	const API = require('@/config/api')
+	export default {
+		computed: {
+			...mapGetters([
+				'mainColor',
+				'customStyle',
+			])
+		},
+		data() {
+			return {
+				orderInfo: {
+					id: '',
+					couponId: '',
+					studentId: '',
+				},
+				contractInfo: {
+					id: '',
+					url: '',
+				},
+				canvasData: []
+			}
+		},
+		watch: {
+			canvasData() {
+				context.moveTo(this.canvasData[0].x, this.canvasData[0].y)
+				for (let i = 0; i < this.canvasData.length; i++) {
+					context.lineTo(this.canvasData[i].x, this.canvasData[i].y)
+				}
+				context.stroke()
+				context.draw(true)
+			}
+		},
+		onLoad(options) {
+			this.orderInfo = {
+				id: options.memberCardId,
+				couponId: options.couponId,
+				studentId: options.studentId,
+			}
+			this.getContractInfo()
+
+			context = uni.createCanvasContext('canvas')
+			context.setLineWidth(3)
+			context.setStrokeStyle("#000000")
+			this.reset()
+		},
+		onShow() {},
+		methods: {
+			//  获取数据
+			getContractInfo() {
+				NET.request(API.getContractInfo, {
+					cardId: this.orderInfo.id
+				}, 'POST').then(res => {
+					this.contractInfo = res.data
+				}).catch(error => {
+					this.$refs.uTips.show({
+						title: error.message,
+						type: 'warning',
+					})
+				})
+			},
+			reset() {
+				context.draw()
+			},
+			handleTouchStart(e) {
+				this.canvasData = []
+				const a = e.changedTouches[0]
+				this.canvasData.push({
+					x: a.x,
+					y: a.y
+				})
+			},
+			handleTouchMove(e) {
+				const a = e.changedTouches[0]
+				this.canvasData.push({
+					x: a.x,
+					y: a.y
+				})
+			},
+			handleTouchEnd(e) {
+				const a = e.changedTouches[0]
+				this.canvasData.push({
+					x: a.x,
+					y: a.y
+				})
+			},
+			handleEnd() {
+				context.stroke()
+				context.draw(true)
+			},
+			handleConfirm() {
+				uni.canvasToTempFilePath({
+					canvasId: 'canvas',
+					success: res => {
+						this.$emit('success', res.tempFilePath)
+					}
+				})
+			},
+			//  支付
+			toPay() {
+				NET.request(API.getPayParams, {
+					...this.orderInfo
+				}, 'POST').then(res => {
+					if (this.memberInfo.realPayAmount <= 0) {
+						this.goToPayResult(res.data.oderNo)
+						return false
+					}
+					uni.requestPayment({
+						provider: 'wxpay',
+						timeStamp: res.data.timeStamp,
+						nonceStr: res.data.nonceStr,
+						package: res.data.packageString,
+						signType: res.data.signType,
+						paySign: res.data.paySign,
+						success: (payRes) => {
+							this.goToPayResult(res.data.oderNo)
+						},
+						fail: (error) => {
+							this.$refs.uTips.show({
+								title: '支付未成功',
+								type: 'warning',
+							})
+						}
+					})
+				}).catch(error => {
+					this.$refs.uTips.show({
+						title: error.message,
+						type: 'warning',
+					})
+				})
+			},
+			//  跳转支付结果
+			goToPayResult(oderNo) {
+				uni.redirectTo({
+					url: '/pagesMain/payResult?id=' + oderNo
+				});
+			}
+		},
+	}
+</script>
+
+<style>
+	page {
+		width: 100%;
+		height: 100%;
+	}
+</style>
+<style lang="scss" scoped>
+	@import "@/static/css/themes.scss";
+
+	.content {
+		width: 100%;
+		float: left;
+		padding: 15px 15px 60px 15px;
+		box-sizing: border-box;
+		.web-view{
+			height: 200px!important;
+		}
+	}
+</style>

+ 8 - 35
pagesMain/openMember.vue

@@ -150,45 +150,18 @@
 			},
 			//  支付
 			toPay() {
-				NET.request(API.getPayParams, {
-					id: this.memberCardId,
-					couponId: this.couponId,
-					studentId: this.studentId,
-				}, 'POST').then(res => {
-					if (this.memberInfo.realPayAmount <= 0) {
-						this.goToPayResult(res.data.oderNo)
-						return false
-					}
-					uni.requestPayment({
-						provider: 'wxpay',
-						timeStamp: res.data.timeStamp,
-						nonceStr: res.data.nonceStr,
-						package: res.data.packageString,
-						signType: res.data.signType,
-						paySign: res.data.paySign,
-						success: (payRes) => {
-							this.goToPayResult(res.data.oderNo)
-						},
-						fail: (error) => {
-							this.$refs.uTips.show({
-								title: '支付未成功',
-								type: 'warning',
-							})
-						}
-					})
-				}).catch(error => {
+				if (!this.studentId) {
 					this.$refs.uTips.show({
-						title: error.message,
+						title: '请选择学员',
 						type: 'warning',
 					})
-				})
-			},
-			//  跳转支付结果
-			goToPayResult(oderNo) {
-				uni.redirectTo({
-					url: '/pagesMain/payResult?id=' + oderNo
+					return
+				}
+				uni.navigateTo({
+					url: '/pagesMain/contractInfo?memberCardId=' + this.memberCardId + '&couponId=' + this.couponId + '&studentId=' +
+						this.studentId
 				});
-			}
+			},
 		},
 	}
 </script>