changeAccount.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. <template>
  2. <view>
  3. <navbar :config="config" backColor="#999999"></navbar>
  4. <view class="box" v-if="config.title=='注销账户'">
  5. <view class="item">
  6. <view class="item_lab">手机号</view>
  7. <view class="item_val">{{form.mobile}}</view>
  8. </view>
  9. <view class="item">
  10. <view class="item_lab">验证码</view>
  11. <view class="item_code">
  12. <u-input v-model="form.captcha" type="text" placeholder="请输入验证码" maxlength="6"/>
  13. <view @click="getCode()">{{txt}}</view>
  14. </view>
  15. </view>
  16. <view class="tig">注意:注销账户提交后,工作人员会及时跟进处理。</view>
  17. <view class="btnBox">
  18. <u-button type="primary" @click="logout">确认提交</u-button>
  19. </view>
  20. </view>
  21. <view class="box" v-if="config.title=='更换手机号'">
  22. <view class="item">
  23. <view class="item_lab">当前绑定的手机号码</view>
  24. <view class="item_val bold">{{form.mobile}}</view>
  25. </view>
  26. <view class="item">
  27. <view class="item_lab">验证码</view>
  28. <view class="item_code">
  29. <u-input v-model="form.captcha" type="text" placeholder="请输入验证码" maxlength="6" />
  30. <view @click="getCode()">{{txt}}</view>
  31. </view>
  32. </view>
  33. <view class="btnBox">
  34. <u-button type="primary" hover-class="hoverClass" @click="next()">下一步</u-button>
  35. </view>
  36. </view>
  37. <view class="box" v-if="config.title=='新手机号'">
  38. <view class="item">
  39. <view class="item_lab">新手机号</view>
  40. <view class="item_val">
  41. <u-input v-model="form.newMobile" type="text" placeholder="请输入新手机号" maxlength="11" />
  42. </view>
  43. </view>
  44. <view class="item">
  45. <view class="item_lab">验证码</view>
  46. <view class="item_code">
  47. <u-input v-model="form.newCaptcha" type="text" placeholder="请输入验证码" maxlength="6" />
  48. <view @click="getCode('newMobile')">{{txt}}</view>
  49. </view>
  50. </view>
  51. <view class="btnBox">
  52. <u-button type="primary" hover-class="hoverClass" @click="changePhoneSub()">确认提交</u-button>
  53. </view>
  54. </view>
  55. </view>
  56. </template>
  57. <script>
  58. import {smsCode} from "@/api/government.js"
  59. export default {
  60. data() {
  61. return {
  62. config: {
  63. back: true, //false是tolbar页面 是则不写
  64. title: '注销账户',
  65. color: '#000',
  66. rightSlot: true,
  67. },
  68. txt: "获取验证码",
  69. form: {},
  70. setTime:null
  71. }
  72. },
  73. onLoad(options) {
  74. if (options.type == 1) {
  75. this.config.title = '注销账户';
  76. } else if (options.type == 2) {
  77. this.config.title = '更换手机号';
  78. } else if (options.type == 3) {
  79. this.config.title = '新手机号';
  80. }
  81. if (options.mobile) {
  82. this.form.mobile = options.mobile;
  83. }
  84. },
  85. methods: {
  86. getCode(newMobile) {
  87. if (this.txt == "获取验证码") {
  88. uni.showLoading({
  89. title: '正在获取验证码'
  90. })
  91. let mobile=newMobile?this.form.newMobile:this.form.mobile;
  92. smsCode({mobile:mobile}).then(res=>{
  93. this.$u.toast('验证码已发送');
  94. this.txt = 60 + 's'
  95. let num = 60;
  96. this.setTime = setInterval(() => {
  97. num--
  98. this.txt = num + 's'
  99. if (num == 0) {
  100. this.txt = "获取验证码";
  101. clearInterval(this.setTime);
  102. }
  103. }, 1000);
  104. }).finally(e=>{
  105. uni.hideLoading();
  106. })
  107. }
  108. },
  109. next() {
  110. if (!this.form.captcha) {
  111. uni.showToast({
  112. icon:"none",
  113. title: '请输入验证码',
  114. duration: 2000,
  115. mask: true
  116. });
  117. return
  118. }
  119. this.$yghttp.post('/user/checkMobile',this.form).then(res=>{
  120. this.config.title = '新手机号';
  121. clearInterval(this.setTime)
  122. this.txt="获取验证码";
  123. })
  124. },
  125. // 修改手机号
  126. changePhoneSub() {
  127. if (this.btnLoading) return
  128. this.btnLoading = true;
  129. if (!this.form.newMobile) {
  130. uni.showToast({
  131. icon: "none",
  132. title: '请输入新的手机号',
  133. duration: 2000,
  134. mask: true
  135. });
  136. this.btnLoading = false;
  137. return
  138. } else if (!this.form.newCaptcha) {
  139. uni.showToast({
  140. icon: "none",
  141. title: '请输入验证码',
  142. duration: 2000,
  143. mask: true
  144. });
  145. this.btnLoading = false;
  146. return
  147. }
  148. this.$yghttp.post('/user/updateMobile', this.form).then(res => {
  149. uni.showToast({
  150. title: '更新成功!',
  151. duration: 1500,
  152. });
  153. this.btnLoading = false;
  154. setTimeout(() => {
  155. uni.navigateBack()
  156. }, 1500)
  157. }).catch(() => {
  158. this.btnLoading = false;
  159. })
  160. },
  161. // 用户注销申请
  162. logout() {
  163. if (this.btnLoading) return
  164. this.btnLoading = true;
  165. if (!this.form.captcha) {
  166. uni.showToast({
  167. icon:"none",
  168. title: '请输入验证码',
  169. duration: 2000,
  170. mask: true
  171. });
  172. this.btnLoading = false;
  173. return
  174. }
  175. uni.showLoading({
  176. title: '提交中',
  177. mask: true
  178. });
  179. this.$yghttp.post('/user/logout/apply/add', this.form).then(res => {
  180. uni.removeStorageSync('apiToken');
  181. uni.showToast({
  182. title: '注销成功!',
  183. duration: 1500,
  184. });
  185. uni.hideLoading();
  186. this.btnLoading = false;
  187. setTimeout(() => {
  188. uni.switchTab({
  189. url: '/pages/home'
  190. });
  191. }, 1500)
  192. }).catch(() => {
  193. uni.hideLoading();
  194. this.btnLoading = false;
  195. })
  196. }
  197. }
  198. }
  199. </script>
  200. <style>
  201. page {
  202. background-color: #F8F8F8;
  203. }
  204. </style>
  205. <style lang="scss">
  206. .box {
  207. padding: 0rpx 40rpx;
  208. background: #fff;
  209. border-radius: 20rpx;
  210. margin: 30rpx;
  211. min-height:88vh;
  212. .item {
  213. padding: 40rpx 0;
  214. border-bottom: 2rpx solid rgba(239, 239, 239, .6);
  215. .item_lab{
  216. font-size: 30rpx;
  217. color: #333333;
  218. }
  219. .item_val {
  220. color: #333333;
  221. margin-top: 40rpx;
  222. }
  223. .item_code {
  224. display: flex;
  225. align-items: center;
  226. margin-top: 20rpx;
  227. >view {
  228. color: #45C5DA;
  229. }
  230. }
  231. }
  232. .tig {
  233. font-size: 24rpx;
  234. padding: 30rpx 0;
  235. }
  236. }
  237. .bold{
  238. font-weight: 700;
  239. }
  240. .btnBox{
  241. width: 100%;
  242. margin-top: 150rpx;
  243. }
  244. .u-btn{
  245. width: 534rpx;
  246. border-radius: 10rpx;
  247. background: rgb(64,149,229);
  248. font-size: 30rpx;
  249. font-weight: 700;
  250. margin: auto;
  251. font-family: Microsoft YaHei, Microsoft YaHei-Bold;
  252. background: linear-gradient(6deg,#56d9ee 0%, #3ebcd0 100%) #3c66d9;
  253. }
  254. .hoverClass{
  255. background: linear-gradient(6deg,#56d9ee 0%, #3ebcd0 100%) #3c66d9;
  256. }
  257. </style>