htc 8 tuntia sitten
vanhempi
commit
eb02593123

+ 6 - 2
components/QuestionItem/index3.vue

@@ -4,7 +4,7 @@
 			{{index+1}}. {{item.question}}
 		</view>
 		<view class="lb_card">
-			<view class="lb_box" v-for="(ua,ui) in item.userAnswer" :key="ui">
+			<view class="lb_box" v-for="(ua,ui) in item[arrayKey]" :key="ui">
 				<view class="memo">{{assessmentMethodCfg[ua.assessmentMethod]||''}}</view>
 				<view class="lb_answers">
 					<u-radio-group
@@ -40,7 +40,11 @@
 			index: {
 				type: Number,
 				required: true
-			}
+			},
+			arrayKey: {
+				type: String,
+				default:'userAnswer'
+			},
 		},
 		data(){
 			return {

+ 119 - 0
components/wechatPay/index.vue

@@ -0,0 +1,119 @@
+<template>
+	<u-popup :show="payShow" @close="payShow=false">
+		<view class="details_pay">
+			<view class="title">
+				<text>请选择</text>
+				<image :src="imgBase+'remind_close.png'" @tap="cancelPay"></image>
+			</view>
+			<view class="wechat_pay">
+				<view class="wp_left">
+					<image :src="imgBase+'img_pay.jpg'"></image>
+					<text>微信支付</text>
+				</view>
+					<image :src="imgBase+'selected.png'"></image>
+			</view>
+			<view class="zt_btn" @tap="confirmPay">确定</view>
+		</view>
+	</u-popup>
+</template>
+
+<script>
+	export default {
+		options: {
+			styleIsolation: 'shared' //样式分离,使组件/deep/下的样式生效
+		},
+		data() {
+			return {
+				payShow: false
+			}
+		},
+		methods: {
+			cancelPay(){
+				uni.showModal({
+					title:'温馨提示',
+					content:'您的订单尚未完成支付,确定要离开?',
+					success: (res) => {
+						if(res.confirm){
+							this.payShow = false;
+							this.$emit('cancelPay');
+						}
+					}
+				})
+			},
+			confirmPay() {
+				this.$emit('confirmPay');
+			}
+		}
+	}
+</script>
+
+<style lang="less">
+	/deep/.u-popup__content {
+		border-radius: 32rpx 32rpx 0 0;
+	}
+
+	.details_pay {
+		padding: 40rpx 30rpx 55rpx;
+		min-height: 400rpx;
+		border-radius: 32rpx 32rpx 0 0;
+		background: #F6F6F6;
+
+		.title {
+			position: relative;
+			text-align: center;
+
+			text {
+				font-size: 36rpx;
+				font-family: PingFang-SC-Bold, PingFang-SC;
+				font-weight: bold;
+				color: #333333;
+			}
+
+			image {
+				width: 36rpx;
+				height: 36rpx;
+				position: absolute;
+				right: 10rpx;
+				top: 50%;
+				margin-top: -18rpx;
+			}
+		}
+
+		.wechat_pay {
+			display: flex;
+			align-items: center;
+			justify-content: space-between;
+			margin-top: 83rpx;
+			background: #FFFFFF;
+			border-radius: 24rpx 24rpx 0rpx 0rpx;
+			padding: 41rpx 24rpx;
+
+			.wp_left {
+				display: flex;
+				align-items: center;
+
+				image {
+					width: 54rpx;
+					height: 54rpx;
+				}
+
+				text {
+					font-size: 32rpx;
+					font-family: PingFangSC-Regular, PingFang SC;
+					font-weight: 400;
+					color: #333333;
+					margin-left: 24rpx;
+				}
+			}
+
+			&>image {
+				width: 48rpx;
+				height: 48rpx;
+			}
+		}
+
+		.zt_btn {
+			margin-top: 59rpx;
+		}
+	}
+</style>

+ 3 - 1
http/index.js

@@ -24,7 +24,9 @@ export const $http = (url, method, data, json, isloading=true) => {
 			uni.hideLoading()
 		}
 		
-		if (response?.data?.code === 401 || response?.data?.msg.indexOf('未授权') > -1 || response?.data?.msg.indexOf('重新登录') > -1) {
+		if(response.hasOwnProperty('paySign')) return response
+		
+		if (response?.data?.code === 401 || response?.data?.msg?.indexOf('未授权') > -1 || response?.data?.msg?.indexOf('重新登录') > -1) {
 			return uni.showModal({
 				title: '温馨提示',
 				content:'当前登录已失效,是否重新登录',

+ 3 - 0
main.js

@@ -20,6 +20,9 @@ import api from '@/http/index.js'
 Vue.prototype.$api = api;
 Vue.prototype.$reg = regTest;
 Vue.prototype.$imgBase = 'https://gitee.com/hw_0302/chuang-heng-wechat-images/raw/master/'
+//微信支付
+import wxPay from '@/utils/wxPay.js'
+Vue.prototype.$wxPay = wxPay;
 
 //重载uni.showToast,简化调用
 Vue.prototype.$showToast = function(title, duration = 2000, icon = "none") {

+ 4 - 1
pages/login.vue

@@ -113,10 +113,12 @@
 												isRegister:res.data.data.isRegister,
 												referrerId:res.data.data.referrerId||'',
 												teamQuestionnaireId:res.data.data.teamQuestionnaireId||'',
-												userId:res.data.data.id||''
+												userId:res.data.data.id||'',
+												openId:res.data.data.openId||'',
 											},
 											user:{
 												token:res.data.data.token,
+												openId:res.data.data.openId,
 												id:res.data.data.id,
 												gender:res.data.data.gender,
 												realName:res.data.data.realName,
@@ -142,6 +144,7 @@
 				uni.setStorageSync('token',res.data.data.token);
 				uni.setStorageSync('userInfo',JSON.stringify({
 					id:res.data.data.id,
+					openId:res.data.data.openId,
 					gender:res.data.data.gender,
 					realName:res.data.data.realName,
 					mobile:res.data.data.mobile,

+ 20 - 5
pages/my.vue

@@ -11,7 +11,7 @@
 					<view class="top-left-info">
 						<view class="top-left-info-name">{{userInfo.realName||'未登录'}}</view>
 						<view class="top-left-info-tip" v-if="!userInfo.id" @click="handleLogin">点击立即登录</view>
-						<view class="top-left-info-version" v-else>{{'基础版'}}</view>
+						<view class="top-left-info-version" v-else>{{typeCfg[headData.type]||'基础版'}}</view>
 					</view>
 				</view>
 				<view class="top-right">
@@ -20,15 +20,15 @@
 			</view>
 			<view class="num adf">
 				<view class="num-pre adffcac">
-					<view class="num-pre-sz">{{0}}</view>
+					<view class="num-pre-sz">{{headData.basicCount||0}}</view>
 					<view class="num-pre-text">基础版次数</view>
 				</view>
 				<view class="num-pre adffcac">
-					<view class="num-pre-sz">{{0}}</view>
+					<view class="num-pre-sz">{{headData.proCount||0}}</view>
 					<view class="num-pre-text">专业版次数</view>
 				</view>
 				<view class="num-pre adffcac">
-					<view class="num-pre-sz">{{0}}</view>
+					<view class="num-pre-sz">{{headData.teamCount||0}}</view>
 					<view class="num-pre-text">我的团队</view>
 				</view>
 			</view>
@@ -60,6 +60,12 @@
 					avatar:this.$imgBase+'my_avatar.png',
 					name:''
 				},
+				headData:null,
+				typeCfg:{
+					1:'基础版',
+					2:'专业版',
+					3:'专家版',
+				},
 				menuList:[
 					{
 						img:this.$imgBase+'my_order.png',
@@ -90,9 +96,18 @@
 			}
 		},
 		onLoad(options) {
-			if(uni.getStorageSync('userInfo')) this.userInfo = JSON.parse(uni.getStorageSync('userInfo'))
+			if(uni.getStorageSync('userInfo')){
+				this.userInfo = JSON.parse(uni.getStorageSync('userInfo'))
+				this.getMyInfo(this.userInfo.id)
+			} 
 		},
 		methods:{
+			getMyInfo(userId){
+				this.$api.get(`/wx/myCount/${userId}`,this.params).then(({data:res})=>{
+					if(res.code!==0) return this.$showToast(res.msg)
+					this.headData = res.data;
+				})
+			},
 			handleLogin(){
 				uni.reLaunch({
 					url:'/pages/login'

+ 11 - 3
pages/publish.vue

@@ -38,6 +38,7 @@
 				list:[],
 				type:1,
 				questionnaireId:'',
+				questionnaireName:'',
 				typeDict:{
 					1:'基础版',
 					2:'专业版',
@@ -65,6 +66,7 @@
 			},
 			handleTurnPage(item){
 				this.type = item.type;
+				this.questionnaireName = item.title;
 				if(item.type==3) return this.$showToast('敬请期待专家版~')
 				this.$api.get(`/que/order/getUseFrequency/${JSON.parse(uni.getStorageSync('userInfo')).id}/${item.type}`).then(({data:res})=>{
 					if(res.code!==0) return this.$showToast(res.msg)
@@ -81,9 +83,15 @@
 			},
 			handleKnow(){
 				this.noticeShow = false;
-				uni.navigateTo({
-					url:'/pagesPublish/fillTeamInfo?type='+this.type+'&questionnaireId='+this.questionnaireId+'&next=true'
-				})
+				if(this.type==1){
+					uni.navigateTo({
+						url:'/pagesPublish/fillTeamInfo?type='+this.type+'&questionnaireId='+this.questionnaireId+'&next=true'
+					})
+				}else if(this.type==2){
+					uni.navigateTo({
+						url:'/pagesHome/questionnaireEdit?type=2&questionnaireId='+this.questionnaireId+'&questionnaireName='+this.questionnaireName+'&teamQuestionnaireId='+this.questionnaireId
+					})
+				}
 			}
 		}
 	}

+ 1 - 1
pages/registerInfo.vue

@@ -67,6 +67,7 @@
 					uni.setStorageSync('token',this.user.token);
 					uni.setStorageSync('userInfo',JSON.stringify({
 						id:this.user.id,
+						openId:this.user.openId||'',
 						gender:this.user.gender,
 						realName:this.dto.realName,
 						email:this.dto.email,
@@ -98,7 +99,6 @@
 				},false).then(({data:res})=>{
 					if(res.code!==0) return this.$showToast(res.msg)
 					uni.hideLoading();
-					console.log(res);
 				})
 			},
 		}

+ 36 - 17
pagesHome/questionnaireEdit.vue

@@ -1,6 +1,6 @@
 <template>
 	<view class="default_page" :style="{'min-height':h+'px', 'padding-top':mt+'px'}">
-		<cus-header title='编辑问卷'></cus-header>
+		<cus-header :title='title'></cus-header>
 		<view class="box adfacjb" style="padding: 32rpx 24rpx 40rpx;">
 			<view class="box-left">
 				<view class="box-title">问卷名称</view>
@@ -66,12 +66,12 @@
 			</view>
 		</view>
 		<view class="bottom">
-			<view class="zt_btn" @click="confirmPublish">确认发布</view>
+			<view class="zt_btn" @click="confirmPublish">{{confirmText}}</view>
 		</view>
 		<cus-select :show="teamShow" :list="teamList" :addShow="true" 
 			@close="teamShow=false" @addTeam="addTeam" @confirmTeam="confirmTeam"></cus-select>
-		<u-datetime-picker ref="datetimePicker1" title="开始时间" :minDate="minStartTime" itemHeight="88" :show="startShow" v-model="dto.startTime" mode="datetime" :formatter="formatter" @cancel="startShow=false" @confirm="startConfirm"></u-datetime-picker>
-		<u-datetime-picker ref="datetimePicker2" title="结束时间" :minDate="minEndTime" itemHeight="88" :show="endShow" v-model="dto.endTime" mode="datetime" :formatter="formatter" @cancel="endShow=false" @confirm="endConfirm"></u-datetime-picker>
+		<u-datetime-picker ref="datetimePicker1" title="开始时间" :minDate="minStartTime" itemHeight="88" :show="startShow" mode="datetime" :formatter="formatter" @cancel="startShow=false" @confirm="startConfirm"></u-datetime-picker>
+		<u-datetime-picker ref="datetimePicker2" title="结束时间" :minDate="minEndTime" itemHeight="88" :show="endShow" mode="datetime" :formatter="formatter" @cancel="endShow=false" @confirm="endConfirm"></u-datetime-picker>
 	</view>
 </template>
 
@@ -84,13 +84,16 @@
 			return {
 				id:'',
 				type:'',
+				title:'编辑问卷',
+				confirmText:'保存',
+				questionnaireId:'',
 				questionnaireName:'',
 				limit:true,
 				teamShow:false,
 				startShow:false,
 				endShow:false,
 				dto:{},
-				teamName:'',
+				teamName:'请选择团队',
 				teamList:[],
 				minStartTime:new Date().getTime(),
 				minEndTime:''
@@ -102,9 +105,13 @@
 		},
 		onLoad(options) {
 			this.teamQuestionnaireId = options.teamQuestionnaireId;
-			this.type = options.type;
+			this.questionnaireId = options.questionnaireId;
 			this.questionnaireName = options.questionnaireName;
-			this.getDetail()
+			this.type = options.type;
+			if(this.type==2){
+				this.title = '发布问卷';
+				this.confirmText = '确认发布';
+			}else if(this.type==1) this.getDetail()
 		},
 		methods:{
 			formatter(type, value) {
@@ -126,6 +133,7 @@
 				this.$api.get('/core/team/questionnaire/'+this.teamQuestionnaireId).then(({data:res})=>{
 					if(res.code!==0) return this.$showToast(res.msg)
 					this.dto = {...this.dto,...res.data}
+					this.questionnaireId = this.dto.questionnaireId;
 					this.$refs.cnbRef.value = this.dto.answerSetting;
 					this.teamName = res.data.teamName;
 				})
@@ -144,19 +152,26 @@
 			},
 			handlePreview(){
 				uni.navigateTo({
-					url:`/pagesPublish/questionnairePreview?questionnaireName=${this.questionnaireName}&teamQuestionnaireId=${this.teamQuestionnaireId}`
+					url:`/pagesPublish/questionnairePreview?questionnaireName=${this.questionnaireName}&teamQuestionnaireId=${this.teamQuestionnaireId}&type=${this.type}`
 				})
 			},
 			addTeam(){
 				uni.navigateTo({
-					url:'/pagesPublish/fillTeamInfo?type=add',
+					url:'/pagesPublish/fillTeamInfo?type=add&questionnaireId='+this.questionnaireId,
 					events:{
 						saveTeamInfo: data =>{
-							console.log(data);
+							this.$api.get('/core/user/team/page',{
+								page:1,
+								limit:-1,
+								coachId:JSON.parse(uni.getStorageSync('userInfo')).id
+							}).then(({data:res})=>{
+								if(res.code!==0) return this.$showToast(res.msg)
+								this.teamList = res.data.list;
+								this.teamList.forEach(t=>t.name=t.teamName)
+							})
 						}
 					}
 				})
-				this.teamShow = false;
 			},
 			addTeamUser(){
 				
@@ -167,23 +182,27 @@
 				this.teamShow = false;
 			},
 			startConfirm(e){
-				this.dto.startTime = e.value;
+				this.dto.startTime = new Date(e.value).Format('yyyy-MM-dd hh:mm:ss');
 				this.minEndTime = e.value;
 				this.startShow = false;
 			},
 			endConfirm(e){
-				this.dto.endTime = e.value;
+				this.dto.endTime = new Date(e.value).Format('yyyy-MM-dd hh:mm:ss');
 				this.endShow = false;
 			},
 			confirmPublish(){
 				let params = JSON.parse(JSON.stringify(this.dto));
 				params.coachId = JSON.parse(uni.getStorageSync('userInfo')).id;
 				params.type = this.type;
-				this.$api.get('/core/team/questionnaire',params).then(({data:res})=>{
+				let url = '/core/team/questionnaire';
+				if(this.type==2){
+					url = '/core/team/questionnaire/publish';
+				}
+				this.$api[this.type==2?'post':'put'](url,params).then(({data:res})=>{
 					if(res.code!==0) return this.$showToast(res.msg)
-					uni.navigateTo({
-						url:'/pagesPublish/publishResult'
-					})
+					if(this.type==2){
+						uni.navigateTo({ url:'/pagesPublish/publishResult' })
+					}else uni.navigateBack()
 				})
 			}
 		}

+ 17 - 4
pagesMy/order.vue

@@ -16,13 +16,13 @@
 						<image class="list-pre-info-left-img" :src="imgBase+'order_img.png'"></image>
 						<view class="list-pre-info-left-texts">
 							<view class="list-pre-info-left-texts-num">{{typeCfg[item.type]}}{{item.totalFrequency}}次,剩余{{item.useFrequency}}次可用</view>
-							<view class="list-pre-info-left-texts-date">有效期至 {{item.expirationTime}}</view>
+							<view class="list-pre-info-left-texts-date">有效期至 {{item.expirationTime||' - '}}</view>
 						</view>
 					</view>
 					<view class="list-pre-info-right">¥{{(+item.totalAmount||0).toFixed(2)}}</view>
 				</view>
 				<view class="list-pre-btns adf">
-					<view class="list-pre-btns-pre cancel" v-if="item.orderStatus==0" @click.stop="orderCancel">取消订单</view>
+					<view class="list-pre-btns-pre cancel" v-if="item.orderStatus==0" @click.stop="orderCancel(item)">取消订单</view>
 					<view class="list-pre-btns-pre" @click.stop="buyAgain">再次购买</view>
 				</view>
 			</view>
@@ -103,10 +103,23 @@
 			},
 			handleDetail(item){
 				uni.navigateTo({
-					url:'/pagesMy/orderDetail?item='+encodeURIComponent(JSON.stringify(item))
+					url:'/pagesMy/orderDetail?id='+item.id
 				})
 			},
-			orderCancel(){
+			orderCancel(item){
+				uni.showModal({
+					title:'温馨提示',
+					content:'确定取消该订单?',
+					success: (res) => {
+						if(res.confirm){
+							this.$api.put(`/que/order/closeOrder/${item.orderNo}`).then(({data:res})=>{
+								if(res.code!==0) return this.$showToast(res.msg)
+								this.$showToast('取消成功')
+								this.init();
+							})
+						}
+					}
+				})
 			},
 			buyAgain(){
 				uni.navigateTo({

+ 67 - 22
pagesMy/orderDetail.vue

@@ -6,36 +6,37 @@
 			<view class="top-left adfac">
 				<image :src="imgBase+'order_detail_success.png'"></image>
 				<view class="top-left-texts adffc">
-					<view class="text">{{statusCfg[orderInfo.status]}}</view>
-					<view class="text tip" v-if="orderInfo.status>0">{{statusTip[orderInfo.status]}}</view>
-					<view class="text tip adfac" v-else>
+					<view class="text">{{statusCfg[orderInfo.orderStatus]}}</view>
+					<view class="text tip adfac" v-if="orderInfo.orderStatus===0">
 						剩余支付时间<text style="margin: 0 4rpx;"></text>
 						<u-count-down :time="countDownTime" format="HH:mm:ss" autoStart @finish="finish"></u-count-down>,
-						超时将自动取消</view>
+						超时将自动取消
+					</view>
+					<view class="text tip" v-else>{{statusTip[orderInfo.orderStatus]||''}}</view>
 				</view>
 			</view>
-			<view class="top-right">¥{{orderInfo.price}}</view>
+			<view class="top-right">¥{{orderInfo.payAmount||0}}</view>
 		</view>
 		<view class="form">
 			<view class="form-item adfacjb">
 				<view class="form-item-title">订单号</view>
-				<view class="form-item-value">{{orderInfo.no}}</view>
+				<view class="form-item-value">{{orderInfo.orderNo||''}}</view>
 			</view>
 			<view class="form-item adfacjb">
 				<view class="form-item-title">订单类型</view>
-				<view class="form-item-value">{{typeCfg[orderInfo.type]}} {{orderInfo.sum}}次</view>
+				<view class="form-item-value">{{typeCfg[orderInfo.type]}} {{orderInfo.totalFrequency}}次</view>
 			</view>
 			<view class="form-item adfacjb">
 				<view class="form-item-title">订单金额</view>
-				<view class="form-item-value">¥{{orderInfo.price}}</view>
+				<view class="form-item-value">¥{{orderInfo.payAmount||0}}</view>
 			</view>
 			<view class="form-item adfacjb">
 				<view class="form-item-title">下单时间</view>
-				<view class="form-item-value">{{'2025-10-10 09:10:11'}}</view>
+				<view class="form-item-value">{{orderInfo.createDate||''}}</view>
 			</view>
 			<view class="form-item adfacjb">
 				<view class="form-item-title">有效期至</view>
-				<view class="form-item-value">{{orderInfo.date}}</view>
+				<view class="form-item-value">{{orderInfo.expirationTime}}</view>
 			</view>
 		</view>
 		<view class="bottom adfacjb">
@@ -47,46 +48,90 @@
 				<view class="bottom-default half" @click="orderPay">去支付</view>
 			</template>
 		</view>
+		<WechatPay ref="wxPay" @confirmPay="toPay" @cancelPay="cancelPay"></WechatPay>
 	</view>
 </template>
 
 <script>
+	import WechatPay from '@/components/wechatPay/index.vue'
 	export default {
+		components:{ WechatPay },
 		data(){
 			return {
+				id:'',
 				orderInfo:null,
 				countDownTime:5 * 60 * 1000,
 				statusCfg:{
-					0:'待支付',
-					1:'已完成',
-					2:'已取消'
+					'-3':'已退款',
+					'-2':'已取消',
+					'-1':'已失效',
+					'0':'待支付',
+					'1':'已支付',
+					'2':'已完成'
 				},
 				typeCfg:{
-					1:'基础版',
-					2:'专业版'
+					'1':'基础版',
+					'2':'专业版'
 				},
 				statusTip:{
-					1:'您的问卷已激活,开始PREILL评估',
-					2:'您的订单已取消,可重新购买'
+					'1':'您的问卷已激活,开始PREILL评估',
+					'2':'您的问卷已激活,开始PREILL评估',
+					'-2':'您的订单已取消,可重新购买'
 				}
 			}
 		},
 		onLoad(options) {
-			if(options.item) this.orderInfo = JSON.parse(decodeURIComponent(options.item))
-			console.log(this.orderInfo);
+			this.id = options.id;
+			this.id&&this.getDetail()
 		},
 		methods:{
+			getDetail(){
+				this.$api.get(`/que/order/${this.id}`).then(({data:res})=>{
+					if(res.code!==0) return this.$showToast(res.msg)
+					this.orderInfo = res.data;
+				})
+			},
 			finish(){
 				
 			},
 			buyAgain(){
-				
+				uni.navigateTo({
+					url:'/pagesPublish/rechargeCenter'
+				})
 			},
 			orderCancel(){
-				
+				uni.showModal({
+					title:'温馨提示',
+					content:'确定取消该订单?',
+					success: (res) => {
+						if(res.confirm){
+							this.$api.put(`/que/order/closeOrder/${this.orderInfo.orderNo}`).then(({data:res})=>{
+								if(res.code!==0) return this.$showToast(res.msg)
+								this.$showToast('取消成功')
+								setTimeout(()=>{
+									uni.redirectTo({
+										url:'/pagesMy/order'
+									})
+								},1500)
+							})
+						}
+					}
+				})
 			},
 			orderPay(){
-				
+				this.$refs.wxPay.payShow = true;
+				this.$api.post('/pay/createOrder',{
+					orderNo:this.orderInfo.orderNo,
+					openId:JSON.parse(uni.getStorageSync('userInfo')).openId
+				}).then(({data:res})=>{
+					if(!res.hasOwnProperty('paySign')) return this.$showToast('支付失败')
+					this.$refs.wxPay.payShow = false;
+					this.$wxPay(res).then(result => {
+						uni.navigateTo({
+							url:'/pagesPublish/payResult'
+						})
+					})
+				})	
 			},
 		}
 	}

+ 29 - 15
pagesPublish/fillTeamInfo.vue

@@ -26,23 +26,37 @@
 		},
 		methods:{
 			handleConfirm(team){
-				if(this.next){
-					team.questionnaireId = this.questionnaireId;
-					team.coachId = JSON.parse(uni.getStorageSync('userInfo')).id;
-					this.$api.post('/core/user/team',team).then(({data:res})=>{
-						if(res.code!==0) return this.$showToast(res.msg)
-						this.$showToast('保存成功,即将填写问卷')
+				team.questionnaireId = this.questionnaireId;
+				team.coachId = JSON.parse(uni.getStorageSync('userInfo')).id;
+				this.$api.post('/core/user/team',team).then(({data:res})=>{
+					if(res.code!==0) return this.$showToast(res.msg)
+					if(this.next){
+						this.$api.post('/core/team/questionnaire/publish',{
+							answerSetting:1,
+							coachId:JSON.parse(uni.getStorageSync('userInfo')).id,
+							startTime:new Date().Format('yyyy-MM-dd hh:mm:ss'),
+							endTime:new Date(new Date().setDate(new Date().getDate()+30)).Format('yyyy-MM-dd hh:mm:ss'),
+							questionnaireId:this.questionnaireId,
+							teamId:res.data.teamId,
+							type:1
+						}).then(({data:res2})=>{
+							if(res2.code!==0) return this.$showToast(res2.msg)
+							this.$showToast('保存成功,即将填写问卷')
+							setTimeout(()=>{
+								uni.removeStorageSync('newUser')
+								uni.navigateTo({
+									url:'/pagesPublish/questionnaireFill?teamQuestionnaireId='+res2.data+'&teamId='+res.data.teamId+'&type='+this.type
+								})	
+							},1500)	
+						})	
+					}else{
+						this.$showToast('团队新增成功')
 						setTimeout(()=>{
-							uni.removeStorageSync('newUser')
-							uni.navigateTo({
-								url:'/pagesPublish/questionnaireFill?teamQuestionnaireId='+res.data.teamQueId+'&teamId='+res.data.teamId+'&type='+this.type
-							})	
+							this.getOpenerEventChannel().emit('saveTeamInfo')
+							uni.navigateBack()
 						},1500)
-					})			
-				}else{
-					this.getOpenerEventChannel().emit('saveTeamInfo',111)
-					uni.navigateBack()
-				} 
+					} 
+				})	
 			}
 		}
 	}

+ 3 - 1
pagesPublish/payResult.vue

@@ -18,7 +18,9 @@
 		},
 		methods:{
 			reviewOrder(){
-				
+				uni.redirectTo({
+					url:'/pagesMy/order'
+				})
 			},
 			returnHome(){
 				uni.reLaunch({

+ 31 - 2
pagesPublish/questionnairePreview.vue

@@ -12,7 +12,15 @@
 			</view>
 		</view>
 		<view class="list">
-			<question-item v-for="(item,index) in list" :key="index" :item="item"></question-item>
+			<div v-if="isLoading" class="loading-container adfacjc">
+				<div class="adfac">
+					<u-loading-icon size="42"></u-loading-icon>
+					<text style="margin-left: 10rpx; font-size: 34rpx; color: #666666">问卷加载中...</text>
+				</div>
+			</div>
+			<template v-else>
+				<question-item v-for="(item,index) in list" :arrayKey="arrayKey" :index="index" :key="index" :item="item"></question-item>
+			</template>
 		</view>
 		<view class="bottom adfacjb">
 			<view class="zt_btn" @click="handleBack">返回</view>
@@ -26,21 +34,38 @@
 		components:{ QuestionItem },
 		data(){
 			return {
+				type:'',
 				questionnaireName:'',
 				total:0,
 				list:[],
+				arrayKey:'userAnswer',
+				isLoading: true,
 			}
 		},
 		onLoad(options) {
+			this.type = options.type;
 			this.questionnaireName = options.questionnaireName;
-			this.getData(options.teamQuestionnaireId)
+			if(this.type==2) this.getData2(options.teamQuestionnaireId)
+			else this.getData(options.teamQuestionnaireId)
 		},
 		methods:{
 			getData(id){
+				this.isLoading = true;
 				this.$api.get(`/core/team/member/answer/listByUser/${id}`).then(({data:res})=>{
 					if(res.code!==0) return this.$showToast(res.msg)
 					this.list = res.data;
 					this.total = res.data.length;
+					this.isLoading = false;
+				})
+			},
+			getData2(id){
+				this.isLoading = true;
+				this.$api.get(`/core/questionnaire/${id}`).then(({data:res})=>{
+					if(res.code!==0) return this.$showToast(res.msg)
+					this.arrayKey = 'questionOption';
+					this.list = res.data.detailList;
+					this.total = res.data.detailList.length;
+					this.isLoading = false;
 				})
 			},
 			handleBack(){
@@ -51,6 +76,10 @@
 </script>
 
 <style scoped lang="scss">
+	.loading-container {
+		width: 100%;
+		height: 100%;
+	}
 	.default_page{
 		padding: 0 0 192rpx;
 		background: #FFFFFF;

+ 100 - 34
pagesPublish/rechargeCenter.vue

@@ -3,14 +3,14 @@
 		<cus-header title='PERILL评估' bgColor="transparent"></cus-header>
 		<view class="info adfac">
 			<view class="info-left">
-				<image :src="avatar"></image>
+				<image :src="userInfo.headUrl||avatar"></image>
 			</view>
 			<view class="info-right">
 				<view class="info-right-name adfac">
-					<view class="text">{{'龙傲天'}}</view>
-					<view class="version">{{'基础版'}}</view>
+					<view class="text">{{userInfo.realName||'游客'}}</view>
+					<view class="version">{{typeCfg[headData.type]||'基础版'}}</view>
 				</view>
-				<view class="info-right-tip">可用次数:基础版{{0}}次,专业版{{0}}次</view>
+				<view class="info-right-tip">可用次数:基础版{{headData.basicCount||0}}次,专业版{{headData.proCount||0}}次</view>
 			</view>
 		</view>
 		<view class="box adffc">
@@ -23,15 +23,17 @@
 					<view class="box-price-pre adffcac" :class="{'active':pindex===index}"
 						v-for="(item,index) in priceList" :key="index" @click="changePrice(item,index)">
 						<view class="box-price-pre-once" v-if="index===0">限时优惠</view>
-						<view class="box-price-pre-times">{{item.times}}</view>
-						<view class="box-price-pre-money"><span>¥</span>{{item.money}}<span v-if="index===priceList.length-1">/次</span></view>
-						<view class="box-price-pre-bottom">{{item.tip}}</view>
+						<view class="box-price-pre-times">{{item.frequency<11?(item.frequency+'次'):'超过10次'}}</view>
+						<view class="box-price-pre-money"><span>¥</span>{{item.price}}<span v-if="item.frequency>10">/次</span></view>
+						<view class="box-price-pre-bottom">
+							{{item.frequency==1?'首次登录赠送1次':(item.frequency>10?('超过10次,¥'+item.price+'/次'):('¥'+(item.price/item.frequency)+'/次'))}}
+						</view>
 					</view>
 				</view>
-				<view class="box-other adfacjb" v-if="pindex===priceList.length-1">
+				<view class="box-other adfacjb" v-if="frequency>10">
 					<view class="box-other-left">其他次数</view>
 					<view class="box-other-right">
-						<cus-number-box :min="otherTimes" :number="otherTimes" @valueChange="valueChange"></cus-number-box>
+						<cus-number-box :min="min" :number="otherTimes" @valChange="valueChange"></cus-number-box>
 					</view>
 				</view>
 			</template>
@@ -39,16 +41,17 @@
 				<view class="box-price adf">
 					<view class="box-price-pre adffcac" :class="{'active':pindex===index}"
 						v-for="(item,index) in priceList2" :key="index" @click="changePrice(item,index)">
-						<view class="box-price-pre-once" v-if="index===0">限时优惠</view>
-						<view class="box-price-pre-times">{{item.times}}</view>
-						<view class="box-price-pre-money"><span>¥</span>{{item.money}}<span v-if="index===priceList2.length-1">/次</span></view>
-						<view class="box-price-pre-bottom">{{item.tip}}</view>
+						<view class="box-price-pre-times">{{item.frequency<11?(item.frequency+'次'):'超过10次'}}</view>
+						<view class="box-price-pre-money"><span>¥</span>{{item.price}}<span v-if="item.frequency>10">/次</span></view>
+						<view class="box-price-pre-bottom">
+							{{item.frequency==1?'首次登录赠送1次':(item.frequency>10?('超过10次,¥'+item.price+'/次'):('¥'+(item.price/item.frequency)+'/次'))}}
+						</view>
 					</view>
 				</view>
-				<view class="box-other adfacjb" v-if="pindex===priceList2.length-1">
+				<view class="box-other adfacjb" v-if="frequency>10">
 					<view class="box-other-left">其他次数</view>
 					<view class="box-other-right">
-						<cus-number-box :min="otherTimes" :number="otherTimes" @valueChange="valueChange"></cus-number-box>
+						<cus-number-box :min="min" :number="otherTimes" @valChange="valueChange"></cus-number-box>
 					</view>
 				</view>
 			</template>
@@ -64,7 +67,7 @@
 				<view class="box-btn adfacjb">
 					<view class="box-btn-left adfac">
 						<view class="box-btn-left-text">实付</view>
-						<view class="box-btn-left-money adfac"><span>¥</span>{{590}}<span style="margin-left: 9rpx;">/{{10}}次</span></view>
+						<view class="box-btn-left-money adfac"><span>¥</span>{{sumPrice}}<span style="margin-left: 9rpx;">/{{times}}次</span></view>
 					</view>
 					<view class="box-btn-right" @click="confirmBuy">确认协议并购买</view>
 				</view>
@@ -77,49 +80,112 @@
 				</view>
 			</template>
 		</view>
+		<WechatPay ref="wxPay" @confirmPay="toPay" @cancelPay="cancelPay"></WechatPay>
 	</view>
 </template>
 
 <script>
 	import CusNumberBox from '@/components/CusNumberBox/index.vue'
+	import WechatPay from '@/components/wechatPay/index.vue'
 	export default {
-		components:{ CusNumberBox },
+		components:{ CusNumberBox, WechatPay },
 		data(){
 			return {
+				userInfo:null,
+				headData:null,
 				avatar:this.$imgBase+'avatar.png',
 				tabList:['基础版','专业版','专家版'],
+				typeCfg:{
+					1:'基础版',
+					2:'专业版',
+					3:'专家版',
+				},
 				tindex:0,
-				pindex:0,
-				priceList:[
-					{times:'1次',money:99,tip:'首次登录赠送1次'},
-					{times:'5次',money:395,tip:'¥79/次'},
-					{times:'10次',money:590,tip:'¥59/次'},
-					{times:'超过10次',money:39,tip:'超过10次,¥39/次'}
-				],
-				priceList2:[
-					{times:'1次',money:199,tip:'首次登录赠送1次'},
-					{times:'5次',money:795,tip:'¥155/次'},
-					{times:'10次',money:1090,tip:'¥109/次'},
-					{times:'超过10次',money:89,tip:'超过10次,¥89/次'}
-				],
-				otherTimes:11
+				pindex:'',
+				frequency:0,
+				priceList:[],
+				priceList2:[],
+				min:11,
+				otherTimes:11,
+				price:0,
+				times:0,
+				sumPrice:0,
+				productId:'',
+				orderNo:'',
 			}
 		},
+		onLoad(options) {
+			if(uni.getStorageSync('userInfo')){
+				this.userInfo = JSON.parse(uni.getStorageSync('userInfo'));
+				this.getMyInfo(this.userInfo.id);
+				this.getList(this.tindex+1)
+			} 
+		},
 		methods:{
+			getMyInfo(userId){
+				this.$api.get(`/wx/myCount/${userId}`,this.params).then(({data:res})=>{
+					if(res.code!==0) return this.$showToast(res.msg)
+					this.headData = res.data;
+				})
+			},
 			changeTab(index){
 				this.tindex = index;
-				this.pindex = 0;
+				this.pindex = '';
 				this.otherTimes = 11;
+				this.price = 0;
+				this.times = 0;
+				this.sumPrice = 0;
+				this.getList(this.tindex+1)
+			},
+			getList(type){
+				this.$api.get(`/core/v2/queproduct/listByType/${type}`).then(({data:res})=>{
+					if(res.code!==0) return this.$showToast(res.msg)
+					if(type==1) this.priceList = res.data
+					else if(type==2) this.priceList2 = res.data
+				})
 			},
 			changePrice(item,index){
+				this.productId = item.id;
 				this.pindex = index;
+				this.frequency = item.frequency;
+				this.price = item.price;
+				this.times = item.frequency;
+				if(this.frequency>10){
+					this.otherTimes = 11;
+					this.sumPrice = this.price*this.otherTimes;
+				} else this.sumPrice = this.price;
 			},
 			valueChange(val){
 				this.otherTimes = val;
+				this.times = this.otherTimes;
+				this.sumPrice = this.price*this.otherTimes;
 			},
 			confirmBuy(){
-				uni.navigateTo({
-					url:'/pagesPublish/payResult'
+				this.$api.post('/que/order/createOrder',{
+					payAmount:this.sumPrice,
+					productId:this.productId,
+					totalAmount:this.sumPrice,
+					totalFrequency:this.times,
+					type:this.tindex+1,
+					userId:this.userInfo.id
+				}).then(({data:res})=>{
+					if(res.code!==0) return this.$showToast(res.msg)
+					this.orderNo = res.data;
+					this.$refs.wxPay.payShow = true;
+				})
+			},
+			toPay(){
+				this.$api.post('/pay/createOrder',{
+					orderNo:this.orderNo,
+					openId:this.userInfo.openId
+				}).then(({data:res})=>{
+					if(!res.hasOwnProperty('paySign')) return this.$showToast('支付失败')
+					this.$refs.wxPay.payShow = false;
+					this.$wxPay(res).then(result => {
+						uni.navigateTo({
+							url:'/pagesPublish/payResult'
+						})
+					})
 				})
 			}
 		}

+ 22 - 0
utils/wxPay.js

@@ -0,0 +1,22 @@
+/*
+	微信支付
+*/
+const wxPay = (params)=>{
+	return new Promise((resolve, rejects)=>{
+		wx.requestPayment({
+			timeStamp:params.timeStamp,
+			nonceStr:params.nonceStr,
+			package:params.packageValue,
+			signType:params.signType,
+			paySign:params.paySign,
+			success(res){
+				return resolve(res)
+			},
+			fail(err){
+				return rejects(err)
+			}
+		})
+	})
+}
+
+export default wxPay