Quellcode durchsuchen

绑定房号新增身份信息填写与协议同意

wzz vor 1 Stunde
Ursprung
Commit
c3bd5c6ef6
3 geänderte Dateien mit 199 neuen und 5 gelöschten Zeilen
  1. 3 2
      App.vue
  2. 13 0
      common/ys-validate.js
  3. 183 3
      pages/selfCenter/with_house.vue

+ 3 - 2
App.vue

@@ -2,8 +2,9 @@
 import md5 from '@/common/md5.js';
 export default {
   globalData: {
-    //shareUrl: "https://heater.xazhima.com/", 测试地址
-	shareUrl:"https://h.xayuanju.com/",
+    shareUrl: "http://h.xajdkenergy.com/", //生产地址
+	//shareUrl: "https://heater.xazhima.com/", //测试地址
+	//shareUrl:"https://h.xayuanju.com/", //旧生产地址
     globalTimestamp: Date.now().toString(),
     secret: "Heater_weichat_app_zhima",
     selectedIndex:0,

+ 13 - 0
common/ys-validate.js

@@ -16,6 +16,19 @@ export default {
 	isPhone: function(val) {
 		return phoneReg.test(val)
 	},
+	isIdCard: function(val) {
+		// 18位身份证:格式 + 出生日期 + 校验位
+		if (!/^[1-9]\d{5}(19|20)\d{2}(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])\d{3}[0-9Xx]$/.test(val)) {
+			return false
+		}
+		const weights = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2]
+		const codes = '10X98765432'
+		let sum = 0
+		for (let i = 0; i < 17; i++) {
+			sum += parseInt(val[i]) * weights[i]
+		}
+		return codes[sum % 11] === val[17].toUpperCase()
+	},
 	isEmail: function(val) {
 		return emailReg.test(val)
 	},

+ 183 - 3
pages/selfCenter/with_house.vue

@@ -96,8 +96,34 @@
 		<label>住宅面积:</label>
 		<input type="text" class="card input" v-model="house.area" disabled/>
 	  </view>
+	  <view class="tel flex">
+		<label>{{ conf.nameRequired ? '*' : '' }}姓名:</label>
+		<input type="text" class="card input" v-model="band_name" placeholder="请输入姓名" maxlength="20"/>
+	  </view>
+	  <view class="tel flex">
+		<label>{{ conf.phoneRequired ? '*' : '' }}手机号:</label>
+		<input type="number" class="card input" v-model="band_phone" placeholder="请输入手机号" maxlength="11"/>
+	  </view>
+	  <view class="tel flex">
+		<label>{{ conf.idRequired ? '*' : '' }}身份证号:</label>
+		<input type="idcard" class="card input" v-model="band_id" placeholder="请输入身份证号" maxlength="18"/>
+	  </view>
     </view>
+	<view class="agree-row" v-if="conf.agreeContent" @tap="agreed = !agreed">
+	  <checkbox :checked="agreed" color="#02a7f0" style="transform: scale(0.8);" />
+	  <text>我已阅读并同意</text>
+	  <text class="agree-link" @tap.stop="showAgreement">《{{ conf.agreeTitle || '供暖缴费协议' }}》</text>
+	</view>
     <button class="submit" @tap="houseSubmit">提交</button>
+	<view class="agree-mask" v-if="showAgree" @tap="showAgree = false" @touchmove.stop.prevent>
+	  <view class="agree-box" @tap.stop>
+		<view class="agree-title">{{ conf.agreeTitle || '供暖缴费协议' }}</view>
+		<scroll-view scroll-y class="agree-content">
+		  <u-parse :content="conf.agreeContent" />
+		</scroll-view>
+		<button class="agree-close" @tap="showAgree = false">关闭</button>
+	  </view>
+	</view>
 	<uni-popup ref="popup" :mask-click="false">
 		  <view class="popup-box" style="height: 400rpx;">
 			  <view>
@@ -121,12 +147,27 @@
 <script>
 import md5 from "@/common/md5.js";
 import jPicker from '../../components/J-Picker/jPicker.vue';
+import uParse from '@/components/gaoyia-parse/parse.vue';
+import validate from '@/common/ys-validate.js';
 export default {
   components: {
-	jPicker
+	jPicker,
+	uParse
   },
   data() {
     return {
+	  band_name: '',
+	  band_phone: '',
+	  band_id: '',
+	  agreed: false,
+	  showAgree: false,
+	  conf: {
+		nameRequired: false,
+		phoneRequired: false,
+		idRequired: false,
+		agreeTitle: '',
+		agreeContent: '',
+	  },
       house: {
         name: "",
         num: "",
@@ -150,8 +191,59 @@ export default {
   },
   onShow() {
     this.searchHood()
+    this.loadConf()
   },
   methods: {
+	// 解析 conf 接口返回:*_flag 为 "1" 表示必填
+	applyConf(d){
+		if (!d || typeof d !== 'object') return;
+		const pick = (...keys) => {
+			for (let k of keys) {
+				if (d[k] !== undefined && d[k] !== null) return d[k];
+			}
+			return '';
+		};
+		const isOn = (v) => v === true || v === 1 || v === '1' || v === 'true' || v === 'yes';
+		this.conf = {
+			nameRequired: isOn(pick('band_name_flag')),
+			phoneRequired: isOn(pick('band_phone_flag')),
+			idRequired: isOn(pick('band_id_flag')),
+			agreeTitle: pick('band_title'),
+			agreeContent: pick('band_content'),
+		};
+	},
+	loadConf(){
+		let md5Sign = md5(
+		  "method=" +
+		    "conf" +
+		    "&timestamp=" +
+		    getApp().globalData.globalTimestamp +
+		    "&secret=" +
+		    getApp().globalData.secret
+		);
+		let url =
+		  getApp().globalData.shareUrl +
+		  "api/api.php" +
+		  "?method=conf&timestamp=" +
+		  getApp().globalData.globalTimestamp +
+		  "&sign=" +
+		  md5Sign;
+		uni.request({
+		  url: url,
+		  method: "GET",
+		  success: (res) => {
+		    if (res.data && res.data.code === 200) {
+				this.applyConf(res.data.data);
+		    }
+		  },
+		  fail: () => {
+		    console.log("连接失败");
+		  },
+		});
+	},
+	showAgreement(){
+		this.showAgree = true;
+	},
 	searchHood(){
 		let that = this;
 		this.hoodList = [];
@@ -362,6 +454,35 @@ export default {
 	houseSubmit(){
 	  //uni.navigateBack({});
 	  //this.open()
+		  if (!this.numList.length || !this.numList[this.numIndex].name || this.numList[this.numIndex].name === '请选择房号') {
+			uni.showToast({ title: "请选择房号", icon: "none" });
+			return;
+		  }
+		  let name = this.band_name.trim(), phone = this.band_phone.trim(), id = this.band_id.trim();
+		  if (this.conf.nameRequired && !name) {
+			uni.showToast({ title: "请输入姓名", icon: "none" });
+			return;
+		  }
+		  if (this.conf.phoneRequired && !phone) {
+			uni.showToast({ title: "请输入手机号", icon: "none" });
+			return;
+		  }
+		  if (phone && !validate.isPhone(phone)) {
+			uni.showToast({ title: "请输入正确的手机号", icon: "none" });
+			return;
+		  }
+		  if (this.conf.idRequired && !id) {
+			uni.showToast({ title: "请输入身份证号", icon: "none" });
+			return;
+		  }
+		  if (id && !validate.isIdCard(id)) {
+			uni.showToast({ title: "请输入正确的身份证号", icon: "none" });
+			return;
+		  }
+		  if (this.conf.agreeContent && !this.agreed) {
+			uni.showToast({ title: "请先阅读并同意供暖缴费协议", icon: "none" });
+			return;
+		  }
 	  let that = this;
 	  uni.showModal({
 	    title: "确定关联此住房信息吗?",
@@ -465,8 +586,11 @@ export default {
         "&sign=" +
         md5Sign;
       let postData = {
-        address:addressResult, 
+        address:addressResult,
         openId: getApp().globalData.open_id,
+        band_name: this.band_name.trim(),
+        band_phone: this.band_phone.trim(),
+        band_id: this.band_id.trim().toUpperCase(),
       };
       uni.request({
         url: url,
@@ -546,9 +670,65 @@ export default {
     width: 55%;
     border-radius: 20rpx;
     background-color: #02a7f0;
-    margin: 120rpx auto;
+    margin: 30rpx auto 120rpx;
   }
 }
+ .agree-row {
+	display: flex;
+	align-items: center;
+	justify-content: center;
+	font-size: 26rpx;
+	margin-top: 20rpx;
+	.agree-link {
+		color: #02a7f0;
+	}
+ }
+ .agree-mask {
+	position: fixed;
+	top: 0;
+	left: 0;
+	right: 0;
+	bottom: 0;
+	z-index: 999;
+	background: rgba(0, 0, 0, 0.5);
+	display: flex;
+	align-items: center;
+	justify-content: center;
+ }
+ .agree-box {
+	width: 620rpx;
+	max-height: 80vh;
+	box-sizing: border-box;
+	background: #fff;
+	border-radius: 20rpx;
+	padding: 24rpx;
+	display: flex;
+	flex-direction: column;
+	overflow: hidden;
+	.agree-title {
+		text-align: center;
+		font-weight: bold;
+		padding-bottom: 16rpx;
+		border-bottom: 1px solid #d8d8d8;
+	}
+	.agree-content {
+		flex: 1;
+		min-height: 300rpx;
+		max-height: 60vh;
+		margin: 20rpx 0;
+		font-size: 26rpx;
+		box-sizing: border-box;
+		overflow-x: hidden;
+		word-break: break-all;
+	}
+	.agree-close {
+		width: 100%;
+		flex-shrink: 0;
+		font-size: 28rpx;
+		color: #fff;
+		background-color: #02a7f0;
+	}
+ }
  .popup-box {
 	  height: 100%;
 	  display: flex;