blob: 31a1c6887ef0866832841e006e0eac9bdcc14228 [file] [log] [blame]
guangchao.xu070005a2020-12-07 09:56:40 +08001<template>
2 <view class="bindSxy">
3 <view class="bindSxy-list">
4 <u-field v-model="code" label="短信验证" placeholder="请输入验证码" placeholder-style="color:#999999" clear-size="40">
5 <u-button size="mini" slot="right" type="primary" @click="getCode" shape="circle" class="btn" :disabled="disabled">{{codeText}}</u-button>
6 </u-field>
7 </view>
8 <view class="bindSxy-lay">
guangchao.xu6cdd45e2021-04-16 17:44:30 +08009 <u-checkbox v-model="checked" shape="circle" label-size="24">我已同意<text class="bindSxy-lay-text" @click="toPath('/pages/sub_mine/agreementSign')">《市民卡免密代扣签约协议》</text></u-checkbox>
guangchao.xu070005a2020-12-07 09:56:40 +080010 </view>
11 <u-button :custom-style="bindSxyBtn" @click="bindSxy">提交</u-button>
12 </view>
13</template>
14
15<script>
16 export default {
17 data() {
18 return {
19 code: "",
20 disabled: false,
21 codeText: "获取验证码",
22 checked: false,
23 bindSxyBtn:{
24 width: '600rpx',
25 backgroundColor: '#2FA8E1',
26 color: '#FFFFFF',
27 fontFamily: "PingFang-SC-Medium",
28 fontSize: '30rpx',
29 marginTop: '100rpx',
30 padding: '50rpx 0'
31 }
32 }
33 },
34 methods: {
35
36 //获取验证码
37 getCode() {
38 let that = this
39 that.$u.post('/v1/bindcardcode').then(res => {
40 uni.showToast({
41 title: '发送成功',
42 icon: "none",
43 duration: 800
44 })
45 let i = 60
46 that.disabled = true
47 that.timer = setInterval(() => {
48 if (i != 0) {
49 i--
50 that.codeText = i + "s"
51 } else {
52 clearInterval(that.timer)
53 that.codeText = "重新获取"
54 that.disabled = false
55 }
56 }, 1000)
57 })
58 },
59 bindSxy() {
60 let that = this
61 let {
62 code,
63 checked
64 } = that
65 if (code == "") {
66 uni.showToast({
67 title: "请输入验证码",
68 duration: 800,
69 icon: "none"
70 })
71 return false
72 }
73 if (checked == false) {
74 uni.showToast({
75 title: "请先阅读并同意《市民卡免密代扣签约协议》",
76 duration: 800,
77 icon: "none"
78 })
79 return false
80 }
81 that.$u.post("/v1/signbxy", {
82 "agree": code
83 }).then((res) => {
84 uni.setStorageSync("signed", "yes")
85 uni.showToast({
86 title: "签约成功",
87 icon: "none",
88 duration: 800,
89 complete(res) {
90 setTimeout(() => {
91 uni.switchTab({
92 url: "/pages/sub_tabbar/index"
93 })
94 }, 1500)
95 }
96 })
97 })
98 },
99
100 },
101 onLoad(){
102 let that = this
103 let i = 60
104 that.disabled = true
105 that.timer = setInterval(() => {
106 if (i != 0) {
107 i--
108 that.codeText = i + "s"
109 } else {
110 clearInterval(that.timer)
111 that.codeText = "重新获取"
112 that.disabled = false
113 }
114 }, 1000)
115 }
116 }
117</script>
118
119<style scoped lang="scss">
120 .btn {
121 color: #2FA8E1;
122 background-color: #FFFFFF;
123 border-color: #2FA8E1;
124 border-width: 1rpx;
125 border-style: solid;
126 font-family: "PingFang-SC-Regular";
127 }
128 .bindSxy {
129 width: 100vw;
130 overflow: hidden;
131 padding-bottom: 30rpx;
132
133 // background-color: ;
134 &-list {
135 margin-top: 30rpx;
136 background-color: #FFFFFF;
137 }
138 &-lay {
139 font-family: "PingFang-SC-Regular";
140 color: #666666;
141 margin: 10rpx 30rpx;
142
143 &-text {
144 color: #2FA8E1;
145 }
146 }
147
148 &-btn {
149 width: 600rpx;
150 background-color: #2FA8E1;
151 color: #FFFFFF;
152 font-family: "PingFang-SC-Medium";
153 font-size: 30rpx;
154 margin-top: 30rpx;
155 padding: 50rpx 0;
156 }
157 }
158</style>