浏览代码

提交代码

zhangli 8 月之前
父节点
当前提交
6ffbebc1f0
共有 2 个文件被更改,包括 50 次插入10 次删除
  1. 48 8
      pagesMain/contractInfo.vue
  2. 2 2
      pagesMain/openMember.vue

+ 48 - 8
pagesMain/contractInfo.vue

@@ -6,7 +6,7 @@
 				<view class="canvas-container" slot="label">
 					<canvas canvas-id="canvas" id="canvas" :disable-scroll="true" style="width: 100%; height: 260px;background-color: #FFFFFF;border:1px solid #aaa;border-radius: 5px;"
 					 @touchstart="handleTouchStart($event)" @touchmove="handleTouchMove($event)" @touchend="handleTouchEnd($event)"
-					 @touchcancel="handleEnd($event)"></canvas>
+					 ></canvas>
 				</view>
 			</u-cell-item>
 			<view style="width:80px;height:30px;text-align: center;line-height: 30px;background-color: #ff6e3e;color:#fff;border-radius: 5px;position: absolute;right:0;z-index:5;" @click="reset">重新签名</view>
@@ -45,7 +45,12 @@
 				ifSign: false,
 				signUrl: '',
 				realPayAmount: '',
-				canvasData: []
+				canvasData: [],
+				canvas: null,
+				context: null,
+				isDrawing: false,
+				lastX: 0,
+				lastY: 0
 			}
 		},
 		watch: {
@@ -68,6 +73,7 @@
 			console.log(this.realPayAmount);
 			this.getContractInfo(options.parentName, options.sex)
 			context = uni.createCanvasContext('canvas')
+			//this.canvas = uni.createCanvasContext('canvas', this);
 			context.setLineWidth(3)
 			context.setStrokeStyle("#000000")
 			this.reset()
@@ -94,28 +100,62 @@
 				this.ifSign = false
 				context.draw()
 			},
+			drawPoint( x, y,) {
+			  context.beginPath();
+			  context.arc(x, y, 2, 0, 2 * Math.PI);
+			  context.setFillStyle('#000000');
+			  context.fill();
+			  context.stroke()
+			  context.draw(true)
+			},
 			handleTouchStart(e) {
 				this.ifSign = true
-				this.canvasData = []
+				this.isDrawing = true;
+				const a = e.changedTouches[0]
+				const x = a.x;
+				const y = a.y;
+				this.lastX = x;
+				this.lastY = y;
+				//this.drawPoint(x, y)
+				context.beginPath();
+				context.moveTo(x, y);
+				/*this.canvasData = []
 				const a = e.changedTouches[0]
 				this.canvasData.push({
 					x: a.x,
 					y: a.y
-				})
+				})*/
 			},
 			handleTouchMove(e) {
-				const a = e.changedTouches[0]
+				if (this.isDrawing) {
+					const x = e.changedTouches[0].x;
+					const y = e.changedTouches[0].y;
+					//this.drawPoint(x, y)
+					context.lineTo(x, y);
+					context.stroke()
+					context.draw(true)
+					context.beginPath();
+					context.moveTo(x, y);
+				  }
+				/*const a = e.changedTouches[0]
 				this.canvasData.push({
 					x: a.x,
 					y: a.y
-				})
+				})*/
 			},
 			handleTouchEnd(e) {
-				const a = e.changedTouches[0]
+				this.isDrawing = false;
+				const x = e.changedTouches[0].x;
+				const y = e.changedTouches[0].y;
+				//this.drawPoint(x, y)
+				context.lineTo(x, y);
+				context.stroke()
+				context.draw(true)
+				/*const a = e.changedTouches[0]
 				this.canvasData.push({
 					x: a.x,
 					y: a.y
-				})
+				})*/
 			},
 			handleEnd() {
 				context.stroke()

+ 2 - 2
pagesMain/openMember.vue

@@ -66,7 +66,7 @@
 								<u-image width="60px" height="60px" :src="item.url" shape="circle"></u-image>
 							</view>
 							<view class="class-info-content">
-								<view class="class-info-label" v-if="item.discountType==3">{{item.name}}&nbsp;&nbsp;课时{{item.discountNum}}</view>
+								<view class="class-info-label" v-if="item.discountType==3||item.discountType==4">{{item.name}}&nbsp;&nbsp;课时{{item.discountNum}}</view>
 								<view class="class-info-label" v-else>{{item.name}}¥{{item.money}}</view>
 								<view class="class-info-text">{{item.content}}</view>
 								<view class="class-info-text">{{item.endDate}}&nbsp;&nbsp;到期</view>
@@ -294,7 +294,7 @@
 			// 选择优惠券
 			selectCoupon(item) {
 				this.couponId = item.id
-				if(item.discountType==3){
+				if(item.discountType==3||item.discountType==4){
 					this.discountsAmount = "课时"+item.discountNum
 				}else{
 					this.discountsAmount = "¥"+item.money