Sfoglia il codice sorgente

观影人新增,列表,删除对接,修改请求封装

gcz 1 anno fa
parent
commit
0a64cd9669
6 ha cambiato i file con 160 aggiunte e 20 eliminazioni
  1. 52 10
      center/people.vue
  2. 15 0
      common/apiurl.js
  3. 5 1
      common/http.api.js
  4. 26 9
      pages/bookticket.vue
  5. 4 0
      static/css/common.scss
  6. 58 0
      utils/queryParams.js

+ 52 - 10
center/people.vue

@@ -11,14 +11,14 @@
 					<u-form-item label="姓名" prop="name" borderBottom>
 						<u--input v-model="form.name" placeholder="与证件名字一致" border="none"></u--input>
 					</u-form-item>
-					<u-form-item label="身份证" prop="sfz" borderBottom>
-						<u--input v-model="form.sfz" placeholder="身份证号码" border="none"></u--input>
+					<u-form-item label="身份证" prop="idcard" borderBottom>
+						<u--input v-model="form.idcard" placeholder="身份证号码" border="none"></u--input>
 					</u-form-item>
 					<u-form-item label="手机号" prop="mobile" borderBottom>
 						<u--input v-model="form.mobile" placeholder="常用手机号" border="none"></u--input>
 					</u-form-item>
 				</u--form>
-				<view class="set-default u-flex u-row-between">
+			<!-- 	<view class="set-default u-flex u-row-between">
 					<view class="left">
 						<view class="up">设置为默认信息</view>
 						<view class="down">提醒:每次下单会默认使用该信息</view>
@@ -26,10 +26,11 @@
 					<view class="right">
 						<u-switch v-model="form.default" activeValue='1' inactiveValue='0'></u-switch>
 					</view>
-				</view>
+				</view> -->
 			</view>
 			<view class="btn-wrap">
 				<view class="full-btn" @click="submit">保存</view>
+				<view class="full-btn red" v-if="type=='editVisitor'" @click="delVisitor">删除</view>
 				<view class="full-btn white" @click="cancel">取消</view>
 			</view>
 		</view>
@@ -42,14 +43,14 @@
 		mixins:[systemInfo],
 		data() {
 			return {
-				id:'',
 				type:'',
 				fromPage:'',
 				form: {
+					id:null,
 					name: '',
-					sfz:'',
+					idcard:'',
 					mobile:'',
-					default:'0',
+					// default:'0',
 				},
 				rules: {
 					'name': [
@@ -60,7 +61,7 @@
 							trigger: ['blur', 'change']
 						}
 					],
-					'sfz': [
+					'idcard': [
 						{
 							type: 'string',
 							required: true,
@@ -103,7 +104,10 @@
 			this.getSystemInfo();
 			this.type = page.type;
 			this.fromPage = page.fromPage;
-			this.id = page.id;
+			this.form.id = page.id;
+			this.form.name = page.name;
+			this.form.idcard = page.idcard;
+			this.form.mobile = page.mobile;
 		},
 		onReady() {
 			this.$refs.uForm.setRules(this.rules)
@@ -121,11 +125,49 @@
 			},
 			submit() {
 				this.$refs.uForm.validate().then(res => {
-					uni.$u.toast('表单校验失败')
+					uni.$u.toast('表单校验成功')
+					console.log('this.type',this.type);
+					console.log('form',this.form);
+					this.$u.api.insertOrUpdateMember(this.form).then(res=>{
+						uni.navigateBack()
+						// if(this.type=='addVisitor'){
+						// 	// this.addVisitor()
+						// }else if(this.type=='editVisitor'){
+						// 	// this.editVisitor()
+						// }
+					}).catch(err=>{
+						console.log('insertOrUpdateMember',err);
+					})
 				}).catch(errors => {
+					console.log('errors',errors);
 					uni.$u.toast('表单校验失败')
 				})
 			},
+			addVisitor(){
+				console.log('form',this.form);
+				this.$u.api.insertOrUpdateMember(this.form).then(res=>{
+					// console.log('getSettlement',res.data);
+					this.pageContent =  res.data;
+				}).catch(err=>{
+					console.log('insertOrUpdateMember',err);
+				})
+			},
+			editVisitor(){
+				console.log('form',this.form);
+			},
+			delVisitor(){
+				console.log('form',this.form);
+				this.$u.api.deleteMember({id:this.form.id}).then(res=>{
+					uni.navigateBack()
+					// if(this.type=='addVisitor'){
+					// 	// this.addVisitor()
+					// }else if(this.type=='editVisitor'){
+					// 	// this.editVisitor()
+					// }
+				}).catch(err=>{
+					console.log('deleteMember',err);
+				})
+			},
 			cancel(){
 				this.leftClick();
 			}

+ 15 - 0
common/apiurl.js

@@ -102,6 +102,21 @@ const apiurl = {
 		url: '/order/orderInfo/getSettlement',
 		type: 'post'
 	},
+	// 观影人历史列表
+	selectMemberAll: {
+		url: '/member/memberInfoFamily/selectMemberAll',
+		type: 'get'
+	},
+	// 添加修改观影人
+	insertOrUpdateMember: {
+		url: '/member/memberInfoFamily/insertOrUpdate',
+		type: 'post'
+	},
+	// 删除观影人
+	deleteMember: {
+		url: '/member/memberInfoFamily/deleteById',
+		type: 'delete'
+	},
 	
 }
 

+ 5 - 1
common/http.api.js

@@ -2,6 +2,8 @@ import {
 	apiurl
 } from "./apiurl.js"
 
+import queryParams from "../utils/queryParams.js"
+
 // 此处第二个参数vm,就是我们在页面使用的this,你可以通过vm获取vuex等操作,更多内容详见uView对拦截器的介绍部分:
 const install = (Vue, vm) => {
 
@@ -12,7 +14,9 @@ const install = (Vue, vm) => {
 	Object.keys(apiurl).forEach((key) => {
 		if(apiurl[key]?.type=='get'){
 			httpMap[key] = (data = {}, config = {}) => http[apiurl[key]?.type](apiurl[key]?.url, {params:data}, config);
-		}else{
+		} else if (apiurl[key]?.type == 'delete') {
+			httpMap[key] = (data = {}, config = {}) => http[apiurl[key]?.type](apiurl[key]?.url + `${queryParams(data)}`, {}, config);
+		} else{
 			httpMap[key] = (params = {}, config = {}) => http[apiurl[key]?.type](apiurl[key]?.url, params, config);
 		}
 	    

+ 26 - 9
pages/bookticket.vue

@@ -13,6 +13,7 @@
 						<view class="time text-item">日期  {{pageContent.timeDate}}({{pageContent.timeWeek}})</view>
 						<view class="time text-item">场次  {{pageContent.performTimeStart}} - {{pageContent.performTimeEnd}}</view>
 						<view class="num text-item">{{pageContent.goodsName}} / {{pageContent.seatTypeName}}</view>
+						<view class=" text-item">{{pageContent.auditoriumName}}</view>
 						<!-- <view class="position text-item">{{performInfo.name}}</view> -->
 					<!-- 	<view class="addr u-flex u-row-between">
 							<view class="u-line-1">地址:遵义市《伟大转折》演艺中心</view>
@@ -65,7 +66,7 @@
 							<u-icon @click="delVisitor(visitor)" name="close-circle" color="#2D2D2D" size="32rpx"></u-icon>
 							<text style="margin-left: 8rpx;">观影人{{ index + 1 }}</text>
 							<text class="name">{{visitor.name}}</text>
-							<text class="people-id">{{ visitor.sfz | maskID }}</text>
+							<!-- <text class="people-id">{{ visitor.idcard | maskID }}</text> -->
 						</view>
 						<view class="right" @click="editVisitor(visitor)">编辑</view>
 					</view>
@@ -154,17 +155,13 @@
 				performId:'',
 				performInfo:{},
 				pageData:{},//上个页面传过来的数据
-				pageContent:{purchaser:{},ticketNotice:'aaa'},//页面信息
+				pageContent:{purchaser:{},ticketNotice:''},//页面信息
 				ticketNotice:'aaa',
 				cansubmit:true,
 				staticUrl:this.$commonConfig.staticUrl,
 				visitors:[],//游客
 				visitorShow:false,//游客弹层
-				visitorList:[
-					{id:'1',name:'张三',sfz:'522501199012037605'},
-					{id:'2',name:'李四',sfz:'522501196012037605'},
-					{id:'3',name:'王五',sfz:'522501202112037605'},
-				],//游客列表
+				visitorList:[],//游客列表
 				selectedVisitor:[],//选中的游客
 				params:{},//要提交的数据
 				
@@ -189,6 +186,7 @@
 			},
 		},
 		onShow() {
+			this.getMemberAll();
 		},
 		onLoad(page) {
 			console.log('page',page);
@@ -196,6 +194,7 @@
 			this.performId = page.performId;
 			this.getSystemInfo();
 			this.getSettlement();
+			
 		},
 		methods: {
 			leftClick(e){
@@ -214,6 +213,19 @@
 					console.log('getSettlement',err);
 				})
 			},
+			getMemberAll(){
+				let that = this;
+				const userId = this.vuex_member_info.id;
+				this.$u.api.selectMemberAll({userid:userId}).then(res=>{
+					// console.log('getMemberAll',res.data);
+					this.visitorList =  res.data.list;
+					console.log('this.visitorList',this.visitorList);
+					this.visitors = this.visitorList.filter(obj => obj.memberId==userId);
+					console.log('this.visitors',this.visitors);
+				}).catch(err=>{
+					console.log('getMemberAll',err);
+				})
+			},
 			confirmVisitor(){
 				let that = this;
 				// console.log('selectedVisitor',this.selectedVisitor);
@@ -235,11 +247,16 @@
 				uni.$u.route('/center/people', {
 					type: 'editVisitor',
 					fromPage:'bookticket',
-					id:item.id
+					id:item.id,
+					name:item.name,
+					mobile:item.mobile,
+					idcard:item.idcard,
 				});
 			},
 			submitorder(){
 				this.cansubmit = false;
+				console.log('pageData',this.pageData);
+				console.log('visitors',this.visitors);
 				console.log('params',this.params);
 			},
 
@@ -378,7 +395,7 @@
 .people-list{
 	margin-bottom: 20rpx;
 	.btn{
-		width: 200rpx;
+		width: 185rpx;
 		height: 60rpx;
 		line-height: 60rpx;
 		font-size: 24rpx;

+ 4 - 0
static/css/common.scss

@@ -84,6 +84,10 @@ $pagegap:32rpx;
 		background-color: #fff;
 		color: #606060;
 	}
+	&.red{
+		background-color: #ED0000;
+		color: #fff;
+	}
 }
 
 .single-til{

+ 58 - 0
utils/queryParams.js

@@ -0,0 +1,58 @@
+/**
+ * 对象转url参数
+ * @param {*} data,对象
+ * @param {*} isPrefix,是否自动加上"?"
+ */
+function queryParams(data = {}, isPrefix = true, arrayFormat = 'brackets') {
+	let prefix = isPrefix ? '?' : ''
+	let _result = []
+	if (['indices', 'brackets', 'repeat', 'comma'].indexOf(arrayFormat) == -1) arrayFormat = 'brackets';
+	for (let key in data) {
+		let value = data[key]
+		// 去掉为空的参数
+		if (['', undefined, null].indexOf(value) >= 0) {
+			continue;
+		}
+		// 如果值为数组,另行处理
+		if (value.constructor === Array) {
+			// e.g. {ids: [1, 2, 3]}
+			switch (arrayFormat) {
+				case 'indices':
+					// 结果: ids[0]=1&ids[1]=2&ids[2]=3
+					for (let i = 0; i < value.length; i++) {
+						_result.push(key + '[' + i + ']=' + value[i])
+					}
+					break;
+				case 'brackets':
+					// 结果: ids[]=1&ids[]=2&ids[]=3
+					value.forEach(_value => {
+						_result.push(key + '[]=' + _value)
+					})
+					break;
+				case 'repeat':
+					// 结果: ids=1&ids=2&ids=3
+					value.forEach(_value => {
+						_result.push(key + '=' + _value)
+					})
+					break;
+				case 'comma':
+					// 结果: ids=1,2,3
+					let commaStr = "";
+					value.forEach(_value => {
+						commaStr += (commaStr ? "," : "") + _value;
+					})
+					_result.push(key + '=' + commaStr)
+					break;
+				default:
+					value.forEach(_value => {
+						_result.push(key + '[]=' + _value)
+					})
+			}
+		} else {
+			_result.push(key + '=' + value)
+		}
+	}
+	return _result.length ? prefix + _result.join('&') : ''
+}
+
+export default queryParams;