paySuccess.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. <template>
  2. <view class="pay_success_bg">
  3. <view class="register_bg">
  4. <view class="phone_input"><input @blur="checkPhone()" v-model="phone" type="tel" placeholder="请输入手机号">
  5. </view>
  6. <view class="password_input"><input v-model="code" type="number" placeholder="请输入验证码">
  7. <view class="sms" @click='sendCode()'>{{sendCodeFlag}}</view>
  8. </view>
  9. </view>
  10. <view class="send_btn" @click="saveAndView">
  11. <image src="https://test.jue-ming.com:8849/api/show?filePath=./webo/EQtest/paymentPage/register_save_bg.png"
  12. mode="widthFix"></image>
  13. </view>
  14. </view>
  15. </template>
  16. <script>
  17. export default {
  18. data() {
  19. return {
  20. phone: '',
  21. code: '',
  22. //时间标志
  23. time: null,
  24. //倒计时数字
  25. timeCount: 60,
  26. //显示倒计时还是发送验证码
  27. sendCodeFlag: '发送验证码',
  28. userId: '',
  29. resultId: ''
  30. }
  31. },
  32. onLoad(options) {
  33. if (options.userId && options.resultId) {
  34. this.userId = options.userId;
  35. this.resultId = options.resultId;
  36. }
  37. },
  38. onUnload() {
  39. clearInterval(this.time);
  40. this.phone = '';
  41. this.code = '';
  42. this.timeCount = 60;
  43. this.sendCodeFlag = '发送验证码';
  44. },
  45. methods: {
  46. //对手机号进行校验
  47. checkPhone() {
  48. var phoneReg = /^[1][3,4,5,7,8][0-9]{9}$/;
  49. if (phoneReg.test(this.phone)) {
  50. return true;
  51. } else {
  52. uni.showToast({
  53. title: '请输入正确手机号',
  54. icon: 'error'
  55. })
  56. return false;
  57. }
  58. },
  59. sendCode() {
  60. if (!this.checkPhone()) {
  61. return;
  62. }
  63. if (this.sendCodeFlag == '重新发送' || this.sendCodeFlag == '发送验证码') {
  64. this.timeCount = 60;
  65. clearInterval(this.time)
  66. //起一个定时器开始倒计时
  67. this.sendCodeFlag = this.timeCount + 's'
  68. this.time = setInterval(() => {
  69. this.timeCount -= 1;
  70. this.sendCodeFlag = this.timeCount + 's'
  71. //如果倒计时为0时则停止倒计时
  72. if (this.timeCount == 0) {
  73. clearInterval(this.time)
  74. this.sendCodeFlag = '重新发送'
  75. }
  76. }, 1000)
  77. this.$request.get({
  78. url: 'user/authCode',
  79. loadingTip: "加载中...",
  80. data: {
  81. phone: this.phone
  82. },
  83. }).then((res) => {
  84. uni.showToast({
  85. title: '验证码已发送',
  86. icon: 'success',
  87. })
  88. })
  89. }
  90. },
  91. // 绑定手机号并查看报告
  92. saveAndView() {
  93. // 校验手机和验证码格式
  94. if (this.checkPhone() && this.code != '') {
  95. this.$request.get({
  96. url: 'user/updateMobile',
  97. loadingTip: "加载中...",
  98. data: {
  99. id: this.userId,
  100. mobile: this.phone,
  101. authCode: this.code,
  102. },
  103. }).then((res) => {
  104. if (res.code == 200) {
  105. uni.showToast({
  106. icon: 'success',
  107. title: '保存成功'
  108. })
  109. uni.navigateTo({
  110. url: `/newScale/Charm/testResult?resultId=${this.resultId}&messageShare=1`
  111. });
  112. } else {
  113. uni.showToast({
  114. icon: 'none',
  115. title: res.msg
  116. })
  117. }
  118. })
  119. }
  120. }
  121. }
  122. }
  123. </script>
  124. <style scoped>
  125. .pay_success_bg {
  126. width: 100%;
  127. min-height: 100vh;
  128. background: url(https://test.jue-ming.com:8849/api/show?filePath=./webo/EQtest/paymentPage/pay_success_bg.png) no-repeat top;
  129. background-size: 100% auto;
  130. overflow: hidden;
  131. }
  132. .register_bg {
  133. width: 750rpx;
  134. height: 498rpx;
  135. background: url(https://test.jue-ming.com:8849/api/show?filePath=./webo/EQtest/paymentPage/register_bg.png) no-repeat top;
  136. background-size: 100% auto;
  137. margin-top: 348rpx;
  138. overflow: hidden;
  139. }
  140. .register_bg input {
  141. border: 0;
  142. outline: none;
  143. width: 529rpx;
  144. height: 91rpx;
  145. padding-left: 100rpx;
  146. }
  147. .phone_input input {
  148. background: url(https://test.jue-ming.com:8849/api/show?filePath=./webo/EQtest/paymentPage/phone_input_bg.png) no-repeat top;
  149. background-size: cover;
  150. margin: 176rpx 0 0 64rpx;
  151. }
  152. .password_input {
  153. margin: 29rpx 0 0 64rpx;
  154. position: relative;
  155. }
  156. .password_input input {
  157. background: url(https://test.jue-ming.com:8849/api/show?filePath=./webo/EQtest/paymentPage/password_input_bg.png) no-repeat top;
  158. background-size: auto 100%;
  159. }
  160. ::v-deep .uni-input-input::placeholder {
  161. font-family: 'Alibaba PuHuiTi 2.0';
  162. font-weight: normal;
  163. font-size: 32rpx;
  164. color: #999999;
  165. line-height: 64rpx;
  166. }
  167. .sms {
  168. width: 168rpx;
  169. background: #FFEDF1;
  170. border-radius: 36rpx;
  171. position: absolute;
  172. top: 9rpx;
  173. right: 71rpx;
  174. font-family: Alibaba PuHuiTi 2.0;
  175. font-weight: bold;
  176. font-size: 24rpx;
  177. color: #EC3126;
  178. line-height: 71rpx;
  179. text-align: center;
  180. }
  181. .sms:active {
  182. border: 1rpx solid #cccccc;
  183. opacity: 0.8;
  184. border-radius: 40rpx;
  185. }
  186. .send_btn {
  187. margin: 340rpx auto 0;
  188. text-align: center;
  189. }
  190. </style>