Browse Source

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

liuboyan 4 years ago
parent
commit
4db54a7b18
5 changed files with 130 additions and 161 deletions
  1. 4 0
      config/api.js
  2. 9 0
      pages/login/index.vue
  3. 45 3
      pages/user/index.vue
  4. 10 4
      pagesMain/contractInfo.vue
  5. 62 154
      pagesMain/openMember.vue

+ 4 - 0
config/api.js

@@ -5,6 +5,8 @@ module.exports = {
 	wxLogin: API_BASE + '/v2/student/login/wxLogin',
 	//  账号密码登录
 	loginByPassword: API_BASE + '/v2/student/login/login',
+	//  更换昵称头像
+	changeWxInfo: API_BASE + '/v2/student/login/changeWxInfo',
 	//  根据经纬度获取位置
 	getAddressInfo: API_BASE + '/v2/location/pointToAddress',
 	
@@ -69,6 +71,8 @@ module.exports = {
 	getMemberCardList: API_BASE + '/v2/student/myCenter/getMemberList',
 	//  获取可购买会员卡信息
 	getMemberCardInfo: API_BASE + '/v2/student/myCenter/getMemberDetail',
+	//  获取前用户家长信息
+	getParentInfo: API_BASE + '/v2/student/contract/getUserInfo',
 	//  获取可用优惠券列表
 	getUsableCouponList: API_BASE + '/v2/student/myCenter/getOwnCouponList',
 	//  获取可购买会员卡选择优惠券后信息

+ 9 - 0
pages/login/index.vue

@@ -100,6 +100,15 @@
 				});
 			},
 			getUserinfoWechat(data) {
+				uni.getUserInfo({
+					provider: 'weixin',
+					success: function(infoRes) {
+						console.log('用户信息:' + infoRes);
+					},
+					fail: (error) => {
+						console.log('获取用户信息失败:' + error);
+					}
+				});
 				uni.login({
 					provider: 'weixin',
 					success: (res) => {

+ 45 - 3
pages/user/index.vue

@@ -43,14 +43,26 @@
 				<u-icon name="arrow-right" color="#cccccc" size="32"></u-icon>
 			</view>
 		</view>
+		<u-modal v-model="userInfoShow" title="您没有上传头像" :show-confirm-button="false" :mask-close-able="true">
+			<u-button type="default" :ripple="true" @getuserinfo="changeWxInfo" :custom-style="{...handleDefaultCustomStyle, marginLeft: '', marginTop: '20px'}"
+			 open-type="getUserInfo">点击一键上传</u-button>
+		</u-modal>
 		<u-top-tips ref="uTips"></u-top-tips>
 	</view>
 </template>
 
 <script>
+	import {
+		mapGetters
+	} from 'vuex'
 	const NET = require('@/utils/request')
 	const API = require('@/config/api')
 	export default {
+		computed: {
+			...mapGetters([
+				'handleDefaultCustomStyle',
+			])
+		},
 		data() {
 			return {
 				userData: {
@@ -60,6 +72,7 @@
 					userName: '',
 					phone: '',
 				},
+				userInfoShow: false,
 				memberInfo: {
 					lastDays: 0,
 					status: 0,
@@ -103,12 +116,13 @@
 				studentList: []
 			}
 		},
-		onLoad() {
+		onShow() {
 			if (uni.getStorageSync('userData')) {
 				this.userData = uni.getStorageSync('userData')
 			}
-		},
-		onShow() {
+			if (!this.userData.headImage || !this.userData.nickName) {
+				this.userInfoShow = true
+			}
 			NET.request(API.getAllStudentList, {}, 'POST').then(res => {
 				this.studentList = res.data
 			}).catch(error => {
@@ -168,6 +182,34 @@
 						console.log("fail:" + JSON.stringify(err));
 					}
 				});
+			},
+			//  更换昵称头像
+			changeWxInfo(info) {
+				NET.request(API.changeWxInfo, {
+					avatarUrl: info.target.userInfo.avatarUrl,
+					nickName: info.target.userInfo.nickName,
+				}, 'POST').then(res => {
+					this.$refs.uTips.show({
+						title: '设置成功',
+						type: 'success',
+					})
+					this.userInfoShow = false
+					uni.setStorage({
+						key: 'userData',
+						data: {
+							...uni.getStorageSync('userData'),
+							headImage: res.data.avatarUrl,
+							nickName: res.data.nickName,
+						}
+					})
+					this.userData.headImage = res.data.avatarUrl
+					this.userData.nickName = res.data.nickName
+				}).catch(error => {
+					this.$refs.uTips.show({
+						title: error.message,
+						type: 'warning',
+					})
+				})
 			}
 		}
 	}

+ 10 - 4
pagesMain/contractInfo.vue

@@ -11,7 +11,7 @@
 			</u-cell-item>
 		</u-cell-group>
 		<view class="handle-fix-box">
-			<u-button type="warning" shape="circle" :ripple="true" :custom-style="customStyle" @click="submitContract()">确定支付</u-button>
+			<u-button type="warning" shape="circle" :ripple="true" :custom-style="customStyle" :disabled="!ifSign" @click="submitContract()">确定支付</u-button>
 		</view>
 		<u-top-tips ref="uTips"></u-top-tips>
 	</view>
@@ -42,6 +42,7 @@
 					id: '',
 					url: '',
 				},
+				ifSign: false,
 				signUrl: '',
 				realPayAmount: '',
 				canvasData: []
@@ -64,7 +65,7 @@
 				studentId: options.studentId,
 			}
 			this.realPayAmount = options.realPayAmount
-			this.getContractInfo()
+			this.getContractInfo(options.parentName, options.sex)
 			context = uni.createCanvasContext('canvas')
 			context.setLineWidth(3)
 			context.setStrokeStyle("#000000")
@@ -73,9 +74,12 @@
 		onShow() {},
 		methods: {
 			//  获取数据
-			getContractInfo() {
+			getContractInfo(parentName, sex) {
 				NET.request(API.getContractInfo, {
-					cardId: this.orderInfo.id
+					cardId: this.orderInfo.id,
+					studentId: this.orderInfo.studentId,
+					parentName: parentName,
+					sex: sex,
 				}, 'POST').then(res => {
 					this.contractInfo = res.data
 				}).catch(error => {
@@ -86,9 +90,11 @@
 				})
 			},
 			reset() {
+				this.ifSign = false
 				context.draw()
 			},
 			handleTouchStart(e) {
+				this.ifSign = true
 				this.canvasData = []
 				const a = e.changedTouches[0]
 				this.canvasData.push({

+ 62 - 154
pagesMain/openMember.vue

@@ -5,19 +5,26 @@
 			<view class="card-num">¥{{memberInfo.originalAmount}}</view>
 			<view class="card-icon iconfont iconzu4931"></view>
 		</view>
-		<u-cell-group style="width: 100%; float: left;">
-			<u-cell-item title="使用时间" :value="memberInfo.startDate + '~' + memberInfo.endDate" :arrow="false"></u-cell-item>
-			<u-cell-item title="优惠金额" :value="couponId ? '-¥' + memberInfo.discountsAmount : ''" @click="couponShow = true"></u-cell-item>
-			<u-cell-item title="学员姓名" :value="studentName" @click="studentShow = true" required></u-cell-item>
-			<u-cell-item title="实际金额" :value="'¥' + memberInfo.realPayAmount" :arrow="false"></u-cell-item>
-			<!-- <u-cell-item title="乙方签字" :arrow="false" :title-style="{width: '100%'}" required>
-				<view class="canvas-container" slot="label">
-					<canvas canvas-id="canvas" id="canvas" :disable-scroll="true" v-show="!couponShow && !studentShow" style="width: 100%; height: 200px;background-color: #FFFFFF;"
-					 @touchstart="handleTouchStart($event)" @touchmove="handleTouchMove($event)" @touchend="handleTouchEnd($event)"
-					 @touchcancel="handleEnd($event)"></canvas>
-				</view>
-			</u-cell-item> -->
-		</u-cell-group>
+		<u-form :model="form" label-width="140" style="width: 100%; float: left;">
+			<u-form-item label="使用时间">
+				<text>{{memberInfo.startDate + '~' + memberInfo.endDate}}</text>
+			</u-form-item>
+			<u-form-item label="优惠金额" right-icon="arrow-right" @click.native="couponShow = true">
+				<text>{{couponId ? '-¥' + memberInfo.discountsAmount : ''}}</text>
+			</u-form-item>
+			<u-form-item label="学员姓名" right-icon="arrow-right" required @click.native="studentShow = true">
+				<text>{{studentName}}</text>
+			</u-form-item>
+			<u-form-item label="实际金额" @click.native="studentShow = true">
+				<text>{{'¥' + memberInfo.realPayAmount}}</text>
+			</u-form-item>
+			<u-form-item label="家长名称" required>
+				<u-input v-model="form.parentName" placeholder="请输入家长姓名" />
+			</u-form-item>
+			<u-form-item label="性别" prop="sex" required right-icon="arrow-right" @click.native="sexShow = true">
+				<text>{{form.sex}}</text>
+			</u-form-item>
+		</u-form>
 		<u-popup v-model="couponShow" mode="bottom" border-radius="30" closeable>
 			<scroll-view scroll-y style="height:300px;margin: 30px 0 15px 0;">
 				<u-card :show-head="false" :show-foot="false" padding="0px" margin="0px 30px 20px 30px" borderRadius="40" v-for="(item, index) in couponList"
@@ -51,12 +58,12 @@
 			<u-button type="warning" shape="circle" :ripple="true" :custom-style="{...customStyle,margin:'15px',float: 'left',width: 'calc(100% - 30px)'}"
 			 @click="goToSubscribelForm()">新增学员</u-button>
 		</u-popup>
+		<u-action-sheet :list="sexList" v-model="sexShow" @click="setSex"></u-action-sheet>
 		<u-top-tips ref="uTips"></u-top-tips>
 	</view>
 </template>
 
 <script>
-	var context = null
 	import {
 		mapGetters
 	} from 'vuex'
@@ -90,31 +97,23 @@
 				studentName: '',
 				studentShow: false,
 				studentList: [],
-				contractInfo: {
-					id: '',
-					url: '',
+				form: {
+					parentName: 'xsaxs',
+					sex: '',
 				},
-				canvasData: [],
-				signUrl: ''
-			}
-		},
-		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)
+				sexShow: false,
+				sexList: [{
+						text: '男'
+					},
+					{
+						text: '女'
+					}
+				],
 			}
 		},
 		onLoad(options) {
 			this.memberCardId = options.id
 			this.getMemberInfo()
-			context = uni.createCanvasContext('canvas')
-			context.setLineWidth(3)
-			context.setStrokeStyle("#000000")
-			this.reset()
 		},
 		onShow() {
 			NET.request(API.getAllStudentList, {}, 'POST').then(res => {
@@ -126,6 +125,18 @@
 				})
 			})
 		},
+		onReady() {
+			NET.request(API.getParentInfo, {}, 'POST').then(res => {
+				debugger
+				this.form.parentName = res.data.parentName
+				this.form.sex = res.data.sex
+			}).catch(error => {
+				this.$refs.uTips.show({
+					title: error.message,
+					type: 'warning',
+				})
+			})
+		},
 		methods: {
 			//  获取数据
 			getMemberInfo() {
@@ -149,16 +160,6 @@
 						type: 'warning',
 					})
 				})
-				NET.request(API.getContractInfo, {
-					cardId: this.memberCardId
-				}, 'POST').then(res => {
-					this.contractInfo = res.data
-				}).catch(error => {
-					this.$refs.uTips.show({
-						title: error.message,
-						type: 'warning',
-					})
-				})
 			},
 			//  更新数据
 			refreshMemberInfo() {
@@ -188,10 +189,14 @@
 				this.studentName = item.studentName
 				this.refreshMemberInfo()
 			},
+			//  设置性别
+			setSex(index) {
+				this.form.sex = this.sexList[index].text
+			},
 			//  显示合同
 			checkContract() {
 				uni.downloadFile({
-					url: this.contractInfo.url,
+					url: '',
 					success: (res) => {
 						uni.openDocument({
 							filePath: res.tempFilePath,
@@ -199,49 +204,8 @@
 					}
 				})
 			},
-			//  重置
-			reset() {
-				context.draw()
-			},
-			//  签字版触屏开始
-			handleTouchStart(e) {
-				if (!this.studentShow && !this.couponShow) {
-					const a = e.changedTouches[0]
-					this.canvasData.push({
-						x: a.x,
-						y: a.y
-					})
-				}
-				this.canvasData = []
-			},
-			//  签字版触屏移动
-			handleTouchMove(e) {
-				if (!this.studentShow && !this.couponShow) {
-					const a = e.changedTouches[0]
-					this.canvasData.push({
-						x: a.x,
-						y: a.y
-					})
-				}
-			},
-			//  签字版触屏结束
-			handleTouchEnd(e) {
-				if (!this.studentShow && !this.couponShow) {
-					const a = e.changedTouches[0]
-					this.canvasData.push({
-						x: a.x,
-						y: a.y
-					})
-				}
-			},
-			handleEnd() {
-				if (!this.studentShow && !this.couponShow) {
-					context.stroke()
-					context.draw(true)
-				}
-			},
-			//  提交签字
-			submitContract() {
+			//  支付
+			toPay(contractId) {
 				if (!this.studentId) {
 					this.$refs.uTips.show({
 						title: '请选择学员',
@@ -249,80 +213,24 @@
 					})
 					return
 				}
-				let that = this
-				uni.canvasToTempFilePath({
-					canvasId: 'canvas',
-					success: res => {
-						uni.uploadFile({
-							url: API.uploadFile,
-							filePath: res.tempFilePath,
-							name: 'file',
-							header: {
-								Authorization: uni.getStorageSync('token')
-							},
-							success: (uploadFileRes) => {
-								that.signUrl = JSON.parse(uploadFileRes.data).data.id
-								NET.request(API.submitContractForm, {
-									contractId: that.contractInfo.id,
-									fileId: that.signUrl,
-								}, 'POST').then(res => {
-									that.toPay(res.data.id)
-								}).catch(error => {
-									that.$refs.uTips.show({
-										title: error.message,
-										type: 'warning',
-									})
-								})
-							}
-						});
-					}
-				})
-			},
-			//  支付
-			toPay(contractId) {
-				if (!this.studentId) {
+				if (!this.form.parentName) {
 					this.$refs.uTips.show({
-						title: '请选择学员',
+						title: '请输入家长姓名',
+						type: 'warning',
+					})
+					return
+				}
+				if (!this.form.sex) {
+					this.$refs.uTips.show({
+						title: '请选择性别',
 						type: 'warning',
 					})
 					return
 				}
-				// NET.request(API.getPayParams, {
-				// 	id: this.memberCardId,
-				// 	couponId: this.couponId,
-				// 	studentId: this.studentId,
-				// 	contractId: contractId
-				// }, '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',
-				// 	})
-				// })
 				uni.navigateTo({
 					url: '/pagesMain/contractInfo?memberCardId=' + this.memberCardId + '&couponId=' + this.couponId + '&studentId=' +
-						this.studentId + '&realPayAmount=' + this.memberInfo.realPayAmount
+						this.studentId + '&realPayAmount=' + this.memberInfo.realPayAmount + '&parentName=' + this.form.parentName +
+						'&sex=' + this.form.sex
 				});
 			},
 			//  跳转支付结果