authSms.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. <template>
  2. <view class="container">
  3. <UserInfo :userInfo="currentUser" :showBtn="false" :type="pageType" bgClass="bgLinGra"></UserInfo>
  4. <view class="tipsMsg">请输入手机验证码</view>
  5. <view class="mainBox">
  6. <view class="termBox border-bottom">
  7. <text>手机号码</text>
  8. <text>{{currentUser.mobile}}</text>
  9. </view>
  10. <view class="termBox">
  11. <text>验证码</text>
  12. <view class="displayFlexRow">
  13. <input class="code" type='number' placeholder="请输入验证码" v-model="provingCode"></input>
  14. <view class="codeText border-left colorCustom" @click="getCode" v-if="seconds<=0">获取验证码</view>
  15. <view class="codeText colorCustom" v-else>{{seconds}}秒后重新获取</view>
  16. </view>
  17. </view>
  18. </view>
  19. <view class="nextBtnBox">
  20. <text class="backgroundCustom" @click="nextBtna">确定</text>
  21. </view>
  22. </view>
  23. </template>
  24. <script lang="ts" setup>
  25. import { ref } from 'vue';
  26. import { useStore } from 'vuex';
  27. import { useOnLoad } from '@/hook';
  28. import { sendVerificationCode_V3, addUserLevelL1_V3, checkVerificationCode_V3 } from '@/pagesPersonal/service/patientManagement';
  29. import { common } from '@/utils';
  30. import UserInfo from '@/pagesPersonal/st1/components/userInfo/userInfo.vue';
  31. const app = getApp();
  32. const currentUser = ref<any>({});
  33. const provingCode = ref("");
  34. const pcId = ref("");
  35. const seconds = ref(0);
  36. const pageType = ref('member');
  37. const timer = ref<any>(null);
  38. useOnLoad((options) => {
  39. let cUser = app.globalData.currentUser;
  40. let pType = 'member';
  41. if (common.isNotEmpty(cUser.cardNo)) {
  42. pType = cUser.cardType == 1 ? 'card' : 'hospital';
  43. }
  44. currentUser.value = cUser;
  45. pageType.value = pType;
  46. });
  47. // 点击获取验证码
  48. const getCode = async () => {
  49. let queryData = {
  50. openid: store.state.openId,
  51. memberId: currentUser.value.memberId
  52. };
  53. let resp = await sendVerificationCode_V3(queryData);
  54. if (!common.isEmpty(resp)) {
  55. pcId.value = resp[0].pcId;
  56. common.showModal('发送成功!');
  57. // Custom countdown logic
  58. seconds.value = 60;
  59. if(timer.value) clearInterval(timer.value);
  60. timer.value = setInterval(() => {
  61. seconds.value--;
  62. if (seconds.value <= 0) {
  63. clearInterval(timer.value);
  64. }
  65. }, 1000);
  66. }
  67. };
  68. // 点击下一步
  69. const nextBtna = async () => {
  70. if (common.isEmpty(provingCode.value)) {
  71. common.showToast('请输入验证码');
  72. return;
  73. }
  74. let queryData = {
  75. openId: store.state.openid,
  76. mobile: currentUser.value.mobile,
  77. memberId: currentUser.value.memberId,
  78. store: {
  79. cardEncryptionStore: currentUser.value.encryptionStore || '',
  80. baseMemberEncryptionStore: currentUser.value.baseMemberEncryptionStore
  81. },
  82. pcId: pcId.value,
  83. verificationCode: provingCode.value
  84. };
  85. // 校验验证码是否正确
  86. if (await checkVerificationCode(queryData)) return;
  87. // 校验成功 添加等级
  88. let resLevel = await addUserLevelL1_V3(queryData);
  89. if (resLevel) {
  90. common.navigateBack(1);
  91. } else {
  92. common.showModal("系统异常,请联系管理员。", () => {
  93. common.navigateBack(2);
  94. });
  95. }
  96. };
  97. // 检验验证码
  98. const checkVerificationCode = async (queryData: any) => {
  99. return new Promise(async (resolve, reject) => {
  100. if (common.isEmpty(queryData.pcId)) {
  101. common.showModal('请先获取验证码');
  102. resolve(true); // Should return true to stop execution in nextBtna
  103. } else {
  104. let reqData = {
  105. pcId: queryData.pcId || '',
  106. verificationCode: queryData.verificationCode,
  107. };
  108. let { resData } = await checkVerificationCode_V3(reqData);
  109. if (resData && resData.RespCode == 10000) {
  110. resolve(false);
  111. } else {
  112. resolve(true);
  113. }
  114. }
  115. });
  116. };
  117. </script>
  118. <style lang="scss" scoped>
  119. .tipsMsg {
  120. line-height: 80upx;
  121. padding-left: 30upx;
  122. font-size: 28upx;
  123. color: #999
  124. }
  125. .mainBox {
  126. padding-left: 30upx;
  127. box-sizing: border-box;
  128. background: white;
  129. margin: 0 30upx;
  130. border-radius: 24upx;
  131. }
  132. .termBox {
  133. height: 120upx;
  134. padding-right: 30upx;
  135. display: flex;
  136. flex-direction: row;
  137. justify-content: space-between;
  138. align-items: center;
  139. }
  140. .termBox:last-child {
  141. border-bottom: none;
  142. }
  143. .termBox text:nth-child(1){
  144. width: 23%;
  145. font-size: 30upx;
  146. color: #333;
  147. }
  148. .termBox text:nth-child(2){
  149. font-size: 30upx;
  150. color: #333;
  151. }
  152. .termBox .displayFlexRow{
  153. justify-content: flex-end;
  154. }
  155. .termBox input{
  156. width: 75%;
  157. font-size: 30upx;
  158. text-align: right;
  159. }
  160. .termBox picker{
  161. width: 75%;
  162. text-align: right;
  163. position: relative;
  164. }
  165. .code {
  166. width: 40% !important;
  167. padding-right: 30upx;
  168. }
  169. .codeText {
  170. /* width: 30% !important; */
  171. font-size: 30upx;
  172. color: #999;
  173. text-align: right;
  174. padding-left: 30upx;
  175. }
  176. .codeStype {
  177. white-space:nowrap;
  178. color: var(--dominantColor) !important;
  179. }
  180. .nextBtnBox {
  181. width: 100%;
  182. padding: 0 30upx;
  183. box-sizing: border-box;
  184. }
  185. .nextBtnBox text {
  186. display: inline-block;
  187. width: 100%;
  188. line-height: 98upx;
  189. font-size: 30upx;
  190. color: white;
  191. font-weight: bold;
  192. text-align: center;
  193. margin-top: 80upx;
  194. border-radius: 45upx;
  195. }
  196. </style>