|
@@ -216,7 +216,7 @@
|
|
</view>
|
|
</view>
|
|
<view class="submit_container">
|
|
<view class="submit_container">
|
|
<view
|
|
<view
|
|
- @click.stop="formList.length > 0 ? formSign() : getSubscription2()"
|
|
|
|
|
|
+ @click.stop="toSignUp"
|
|
class="sign_up flexC"
|
|
class="sign_up flexC"
|
|
>
|
|
>
|
|
支付¥{{ userInfo.cost }} 报名
|
|
支付¥{{ userInfo.cost }} 报名
|
|
@@ -256,7 +256,7 @@ export default {
|
|
},
|
|
},
|
|
onShow() {
|
|
onShow() {
|
|
this.getSystem();
|
|
this.getSystem();
|
|
- this.getState(); //获取后台订阅权限开启状态
|
|
|
|
|
|
+
|
|
if (!uni.getStorageSync('token')) {
|
|
if (!uni.getStorageSync('token')) {
|
|
uni.showModal({
|
|
uni.showModal({
|
|
content: '登录过期,请重新登录',
|
|
content: '登录过期,请重新登录',
|
|
@@ -283,6 +283,92 @@ export default {
|
|
this.getFormSignedInfo()
|
|
this.getFormSignedInfo()
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
|
|
+ // 报名
|
|
|
|
+ async toSignUp() {
|
|
|
|
+ const f = this.checkError()
|
|
|
|
+ if(!f) return false
|
|
|
|
+ const [, { subscriptionsSetting: { itemSettings: s } }] = await uni.getSetting({ withSubscriptions: true })
|
|
|
|
+ const go = () => {
|
|
|
|
+ const f_len = this.formList.length
|
|
|
|
+ f_len ? this.formSign() : this.toSubmitNoOther()
|
|
|
|
+ }
|
|
|
|
+ const tmplIds = [
|
|
|
|
+ 'BTmiw1Lr630I5ADYVX8Pzy75e4M7OmtgUBcCPVj7CKo',
|
|
|
|
+ 'dgL9BVJ65H7aeGJuQB3J9H3EqlqYsN2GRj_wWrGLVkQ',
|
|
|
|
+ '__-SjTtxTWmfAVwOyy7J9WXBuu8P7pJsJOXM6xCDSWw',
|
|
|
|
+ ]
|
|
|
|
+ const t_alen = tmplIds.length
|
|
|
|
+ let t_len = 0
|
|
|
|
+ if(s) {
|
|
|
|
+ const s_k = Object.keys(s)
|
|
|
|
+ const s_v = Object.values(s)
|
|
|
|
+ t_len = tmplIds.filter(id => s_k.indexOf(id) !== -1).length
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(!s && t_len) {
|
|
|
|
+ uni.requestSubscribeMessage({
|
|
|
|
+ tmplIds,
|
|
|
|
+ success(res) {
|
|
|
|
+ const _o = Object.assign({}, res)
|
|
|
|
+ Reflect.deleteProperty(_o, 'errMsg')
|
|
|
|
+ const a_len = Object.values(_o).filter(s => s === 'accept').length
|
|
|
|
+ if(a_len !== t_alen){
|
|
|
|
+ uni.showModal({
|
|
|
|
+ title: '提示',
|
|
|
|
+ content: '请选择订阅服务,以便我们通知您活动信息',
|
|
|
|
+ showCancel: false
|
|
|
|
+ })
|
|
|
|
+ } else {
|
|
|
|
+ go()
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ fail() {
|
|
|
|
+ uni.showModal({
|
|
|
|
+ title: '失败',
|
|
|
|
+ content: '打开订阅服务失败',
|
|
|
|
+ showCancel: false
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ } else {
|
|
|
|
+ go()
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ // 错误检测
|
|
|
|
+ checkError() {
|
|
|
|
+ const em = new Map([
|
|
|
|
+ [1, '请选择您的性别'],
|
|
|
|
+ [2, '请填写您的身份证号'],
|
|
|
|
+ [3, '请填写真实的身份证号'],
|
|
|
|
+ [4, '请选择您来自哪里'],
|
|
|
|
+ [5, '请填写您的详细地址'],
|
|
|
|
+ [6, '请填写您参加的次数'],
|
|
|
|
+ [7, '请正确填写您参加的次数']
|
|
|
|
+ ])
|
|
|
|
+ const e_fn = s => {
|
|
|
|
+ uni.showModal({
|
|
|
|
+ title:'提示',
|
|
|
|
+ content: em.get(s),
|
|
|
|
+ showCancel: false
|
|
|
|
+ })
|
|
|
|
+ return false
|
|
|
|
+ }
|
|
|
|
+ const { sex, id_code, detail } = this.signedInfo
|
|
|
|
+ if(!sex && sex !== 0) return e_fn(1)
|
|
|
|
+ if(!id_code) return e_fn(2)
|
|
|
|
+ const id_reg = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/
|
|
|
|
+ if(!id_reg.test(id_code)) return e_fn(3)
|
|
|
|
+ const rlen = this.baseInfo_region.length
|
|
|
|
+ if(!rlen) return e_fn(4)
|
|
|
|
+ if(!detail) return e_fn(5)
|
|
|
|
+ const n = this.join_num
|
|
|
|
+ if(!n) return e_fn(6)
|
|
|
|
+ const n_reg = /^\d{1,}$/
|
|
|
|
+ if(!n_reg.test(n)) return e_fn(7);
|
|
|
|
+ return true
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+
|
|
getFormSignedInfo(cb) {
|
|
getFormSignedInfo(cb) {
|
|
userSignUpInfo().then(res => {
|
|
userSignUpInfo().then(res => {
|
|
if(res.code === 200) {
|
|
if(res.code === 200) {
|
|
@@ -347,60 +433,6 @@ export default {
|
|
* @params address 详细地址
|
|
* @params address 详细地址
|
|
*/
|
|
*/
|
|
formSign() {
|
|
formSign() {
|
|
-
|
|
|
|
- if(!this.signedInfo.sex && this.signedInfo.sex !== 0) {
|
|
|
|
- uni.showModal({
|
|
|
|
- content: '请选择您的性别',
|
|
|
|
- showCancel: false
|
|
|
|
- });
|
|
|
|
- return false
|
|
|
|
- }
|
|
|
|
- if(!this.signedInfo.id_code) {
|
|
|
|
- uni.showModal({
|
|
|
|
- content: '请填写您的身份证号',
|
|
|
|
- showCancel: false
|
|
|
|
- });
|
|
|
|
- return false
|
|
|
|
- } else {
|
|
|
|
- var reg = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;
|
|
|
|
- if(!reg.test(this.signedInfo.id_code)) {
|
|
|
|
- uni.showModal({
|
|
|
|
- content: '请填写真实的身份证号',
|
|
|
|
- showCancel: false
|
|
|
|
- });
|
|
|
|
- return false
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if(!this.region.length === 0) {
|
|
|
|
- uni.showModal({
|
|
|
|
- content: '请选择您来自哪里',
|
|
|
|
- showCancel: false
|
|
|
|
- });
|
|
|
|
- return false
|
|
|
|
- }
|
|
|
|
- if(!this.signedInfo.detail) {
|
|
|
|
- uni.showModal({
|
|
|
|
- content: '请填写您的详细地址',
|
|
|
|
- showCancel: false
|
|
|
|
- });
|
|
|
|
- return false
|
|
|
|
- }
|
|
|
|
- if(!this.join_num) {
|
|
|
|
- uni.showModal({
|
|
|
|
- content: '请填写您参加的次数',
|
|
|
|
- showCancel: false
|
|
|
|
- });
|
|
|
|
- return falses
|
|
|
|
- } else {
|
|
|
|
- let reg = /^\d{1,}$/
|
|
|
|
- if(!reg.test(this.join_num)) {
|
|
|
|
- uni.showModal({
|
|
|
|
- content: '请正确填写您参加的次数',
|
|
|
|
- showCancel: false
|
|
|
|
- });
|
|
|
|
- return false
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
let that = this;
|
|
let that = this;
|
|
let id = [];
|
|
let id = [];
|
|
let value = [];
|
|
let value = [];
|
|
@@ -422,9 +454,7 @@ export default {
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
if (list[i].get_verify.value) {
|
|
if (list[i].get_verify.value) {
|
|
- console.log(1, list[i])
|
|
|
|
let reg = new RegExp(list[i].get_verify.value);
|
|
let reg = new RegExp(list[i].get_verify.value);
|
|
- console.log(reg, list[i].form_default, reg.test(list[i].form_default))
|
|
|
|
if (!reg.test(list[i].form_default)) {
|
|
if (!reg.test(list[i].form_default)) {
|
|
uni.showModal({
|
|
uni.showModal({
|
|
content: `${list[i].form_name}要求为: ${list[i].get_verify.name}` || list[i].form_name + '格式不正确',
|
|
content: `${list[i].form_name}要求为: ${list[i].get_verify.name}` || list[i].form_name + '格式不正确',
|
|
@@ -451,7 +481,7 @@ export default {
|
|
}
|
|
}
|
|
}).then(res => {
|
|
}).then(res => {
|
|
if (res.code == 200) {
|
|
if (res.code == 200) {
|
|
- this.getSubscription();
|
|
|
|
|
|
+ this.toPay();
|
|
} else {
|
|
} else {
|
|
uni.showModal({
|
|
uni.showModal({
|
|
content: res.message || '提交信息失败',
|
|
content: res.message || '提交信息失败',
|
|
@@ -462,111 +492,8 @@ export default {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
},
|
|
- getState() {
|
|
|
|
- let that = this;
|
|
|
|
- //判断用户小程序后台的订阅权限是否打开
|
|
|
|
- uni.getSetting({
|
|
|
|
- withSubscriptions: true,
|
|
|
|
- success(res) {
|
|
|
|
- const mainSwitch = res.subscriptionsSetting.mainSwitch; // 订阅消息总开关
|
|
|
|
- const itemSettings = res.subscriptionsSetting.itemSettings;
|
|
|
|
- if (!mainSwitch) {
|
|
|
|
- //后台订阅消息权限开启
|
|
|
|
- uni.showModal({
|
|
|
|
- title: '温馨提示',
|
|
|
|
- content: '您暂未开启订阅权限\n请手动开启订阅权限\n便于您接下来的报名',
|
|
|
|
- showCancel: false,
|
|
|
|
- success(res) {
|
|
|
|
- if (res.confirm) {
|
|
|
|
- uni.openSetting({
|
|
|
|
- withSubscriptions: true,
|
|
|
|
- success(res) {
|
|
|
|
- if (res.subscriptionsSetting == true) {
|
|
|
|
- uni.showModal({
|
|
|
|
- content: '您已开启订阅权限',
|
|
|
|
- showCancel: false
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
- fail(err) {
|
|
|
|
- uni.showModal({
|
|
|
|
- content: '开启订阅权限失败',
|
|
|
|
- showCancel: false
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
- if (
|
|
|
|
- mainSwitch &&
|
|
|
|
- itemSettings &&
|
|
|
|
- itemSettings['BTmiw1Lr630I5ADYVX8Pzy75e4M7OmtgUBcCPVj7CKo'] === 'accept' &&
|
|
|
|
- itemSettings['dgL9BVJ65H7aeGJuQB3J9H3EqlqYsN2GRj_wWrGLVkQ'] === 'accept' &&
|
|
|
|
- itemSettings['__-SjTtxTWmfAVwOyy7J9WXBuu8P7pJsJOXM6xCDSWw'] === 'accept'
|
|
|
|
- ) {
|
|
|
|
- //后台订阅消息权限开启,并已经订阅
|
|
|
|
- that.state = 1;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- },
|
|
|
|
- getSubscription2() {
|
|
|
|
-
|
|
|
|
- if(!this.signedInfo.sex && this.signedInfo.sex !== 0) {
|
|
|
|
- uni.showModal({
|
|
|
|
- content: '请选择您的性别',
|
|
|
|
- showCancel: false
|
|
|
|
- });
|
|
|
|
- return false
|
|
|
|
- }
|
|
|
|
- if(!this.signedInfo.id_code) {
|
|
|
|
- uni.showModal({
|
|
|
|
- content: '请填写您的身份证号',
|
|
|
|
- showCancel: false
|
|
|
|
- });
|
|
|
|
- return false
|
|
|
|
- } else {
|
|
|
|
- var reg = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;
|
|
|
|
- if(!reg.test(this.signedInfo.id_code)) {
|
|
|
|
- uni.showModal({
|
|
|
|
- content: '请填写真实的身份证号',
|
|
|
|
- showCancel: false
|
|
|
|
- });
|
|
|
|
- return false
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if(!this.region.length === 0) {
|
|
|
|
- uni.showModal({
|
|
|
|
- content: '请选择您来自哪里',
|
|
|
|
- showCancel: false
|
|
|
|
- });
|
|
|
|
- return false
|
|
|
|
- }
|
|
|
|
- if(!this.signedInfo.detail) {
|
|
|
|
- uni.showModal({
|
|
|
|
- content: '请填写您的详细地址',
|
|
|
|
- showCancel: false
|
|
|
|
- });
|
|
|
|
- return false
|
|
|
|
- }
|
|
|
|
- if(!this.join_num) {
|
|
|
|
- uni.showModal({
|
|
|
|
- content: '请填写您参加的次数',
|
|
|
|
- showCancel: false
|
|
|
|
- });
|
|
|
|
- return false
|
|
|
|
- } else {
|
|
|
|
- let reg = /^\d{1,}$/
|
|
|
|
- if(!reg.test(this.join_num)) {
|
|
|
|
- uni.showModal({
|
|
|
|
- content: '请正确填写您参加的次数',
|
|
|
|
- showCancel: false
|
|
|
|
- });
|
|
|
|
- return false
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+
|
|
|
|
+ toSubmitNoOther() {
|
|
subFrom({
|
|
subFrom({
|
|
id: [],
|
|
id: [],
|
|
value: [],
|
|
value: [],
|
|
@@ -581,7 +508,7 @@ export default {
|
|
}
|
|
}
|
|
}).then(res => {
|
|
}).then(res => {
|
|
if (res.code == 200) {
|
|
if (res.code == 200) {
|
|
- this.getSubscription();
|
|
|
|
|
|
+ this.toPay();
|
|
} else {
|
|
} else {
|
|
uni.showModal({
|
|
uni.showModal({
|
|
content: res.message || '提交信息失败',
|
|
content: res.message || '提交信息失败',
|
|
@@ -590,133 +517,38 @@ export default {
|
|
}
|
|
}
|
|
});
|
|
});
|
|
},
|
|
},
|
|
- getSubscription() {
|
|
|
|
-
|
|
|
|
- let that = this;
|
|
|
|
- if (that.state == 1) {
|
|
|
|
- console.log(1)
|
|
|
|
- //如果用户授权时候选择的是总是保持以上选择
|
|
|
|
- that.toSign();
|
|
|
|
- } else {
|
|
|
|
- console.log(2)
|
|
|
|
- //调用授权方法
|
|
|
|
- var tempIdList = ['BTmiw1Lr630I5ADYVX8Pzy75e4M7OmtgUBcCPVj7CKo', 'dgL9BVJ65H7aeGJuQB3J9H3EqlqYsN2GRj_wWrGLVkQ', '__-SjTtxTWmfAVwOyy7J9WXBuu8P7pJsJOXM6xCDSWw'];
|
|
|
|
- uni.requestSubscribeMessage({
|
|
|
|
- tmplIds: tempIdList,
|
|
|
|
- success(res) {
|
|
|
|
- if (res['errMsg'] == 'requestSubscribeMessage:ok') {
|
|
|
|
- tempIdList.map(function(item, index) {
|
|
|
|
- if (res[item] == 'accept') {
|
|
|
|
- //用户同意订阅
|
|
|
|
- that.state = 1;
|
|
|
|
- } else if (res[item] == 'reject') {
|
|
|
|
- //用户不同意订阅
|
|
|
|
- that.state = 2;
|
|
|
|
- }
|
|
|
|
- // else if (res[item] == 'ban') {
|
|
|
|
- // // state = '后台被禁用';
|
|
|
|
- // that.state = 3;
|
|
|
|
- // }
|
|
|
|
- });
|
|
|
|
- that.toSign();
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
- fail(err) {
|
|
|
|
- console.log(err)
|
|
|
|
- if (err.errCode == 20004) {
|
|
|
|
- uni.showModal({
|
|
|
|
- content: '请手动开启订阅权限',
|
|
|
|
- showCancel: false,
|
|
|
|
- success(res) {
|
|
|
|
- if (res.confirm) {
|
|
|
|
- uni.openSetting({
|
|
|
|
- withSubscriptions: true,
|
|
|
|
- success(res) {
|
|
|
|
- if (res.subscriptionsSetting == true) {
|
|
|
|
- uni.showModal({
|
|
|
|
- content: '您已开启订阅权限,请重新输入提交',
|
|
|
|
- showCancel: false
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
- fail(err) {
|
|
|
|
- uni.showModal({
|
|
|
|
- content: '开启订阅权限失败',
|
|
|
|
- showCancel: false
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- } else {
|
|
|
|
- uni.showModal({
|
|
|
|
- content: JSON.stringify(err),
|
|
|
|
- showCancel: false
|
|
|
|
- })
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
// 支付报名
|
|
// 支付报名
|
|
- toSign() {
|
|
|
|
- let that = this;
|
|
|
|
- let { is_limit, count, limit_num } = that.userInfo;
|
|
|
|
- if (is_limit && count == Number(limit_num)) {
|
|
|
|
- uni.showModal({
|
|
|
|
- content: '报名人数已满',
|
|
|
|
- showCancel: false
|
|
|
|
- });
|
|
|
|
- return false;
|
|
|
|
- }
|
|
|
|
- if (that.state == 2) {
|
|
|
|
- uni.showModal({
|
|
|
|
- title: '温馨提示',
|
|
|
|
- content: '不订阅消息将无法报名',
|
|
|
|
- showCancel: false
|
|
|
|
- });
|
|
|
|
- return false;
|
|
|
|
- }
|
|
|
|
- if (that.state == 1) {
|
|
|
|
- toSign()
|
|
|
|
- .then(res => {
|
|
|
|
- if (!that.payStatus) return false;
|
|
|
|
- console.log(res);
|
|
|
|
- if (res.code === 200) {
|
|
|
|
- let { appId, nonceStr, paySign, signType, timeStamp } = res.data;
|
|
|
|
- uni.requestPayment({
|
|
|
|
- provider: 'weixin',
|
|
|
|
- timeStamp,
|
|
|
|
- nonceStr,
|
|
|
|
- package: res.data.package,
|
|
|
|
- signType,
|
|
|
|
- paySign,
|
|
|
|
- success() {
|
|
|
|
- that.poyStatus();
|
|
|
|
- },
|
|
|
|
- fail() {
|
|
|
|
- uni.showModal({
|
|
|
|
- content: '支付失败',
|
|
|
|
- showCancel: false
|
|
|
|
- });
|
|
|
|
- },
|
|
|
|
- complete() {
|
|
|
|
- that.payStatus = true;
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- } else {
|
|
|
|
|
|
+ toPay() {
|
|
|
|
+ const _this = this
|
|
|
|
+ toSign().then(res => {
|
|
|
|
+ if (res.code === 200) {
|
|
|
|
+ uni.requestPayment({
|
|
|
|
+ provider: 'weixin',
|
|
|
|
+ ...res.data,
|
|
|
|
+ success() {
|
|
|
|
+ _this.poyStatus();
|
|
|
|
+ },
|
|
|
|
+ fail() {
|
|
uni.showModal({
|
|
uni.showModal({
|
|
- content: res.message || '报名失败',
|
|
|
|
|
|
+ title: '失败',
|
|
|
|
+ content: '支付失败',
|
|
showCancel: false
|
|
showCancel: false
|
|
});
|
|
});
|
|
- that.payStatus = true;
|
|
|
|
|
|
+ },
|
|
|
|
+ complete() {
|
|
|
|
+ _this.payStatus = true;
|
|
}
|
|
}
|
|
- })
|
|
|
|
- .catch(e => {
|
|
|
|
- that.payStatus = true;
|
|
|
|
});
|
|
});
|
|
- }
|
|
|
|
|
|
+ } else {
|
|
|
|
+ uni.showModal({
|
|
|
|
+ content: res.message || '报名失败',
|
|
|
|
+ showCancel: false
|
|
|
|
+ });
|
|
|
|
+ _this.payStatus = true;
|
|
|
|
+ }
|
|
|
|
+ }).catch(e => {
|
|
|
|
+ _this.payStatus = true;
|
|
|
|
+ });
|
|
},
|
|
},
|
|
getTime(date) {
|
|
getTime(date) {
|
|
if (date != NaN) {
|
|
if (date != NaN) {
|