You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

213 lines
4.6 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. <template>
  2. <view class="app-container">
  3. <view class="login-content">
  4. <view class="login-font">
  5. <image style="width: 364rpx;height: 200rpx;" src="/static/login/merchant-copy.png" alt="" />
  6. </view>
  7. <view class="login-main">
  8. <view class="login-item">
  9. <input type="tel" class="log-phone" placeholder="请输入手机号" v-model="phone" />
  10. </view>
  11. <view class="login-item">
  12. <input type="number" class="log-phone log-code" placeholder="请输入验证码" v-model="sms_code" />
  13. <view class="getCode" @click="getCode" v-if="countdown==0">
  14. 获取验证码
  15. </view>
  16. <view class="getCode" v-else>
  17. 剩余{{countdown}}
  18. </view>
  19. </view>
  20. <view class="login-btn">
  21. <button size="default" type="default" @click="btnLogin"
  22. style="color:#ffffff;backgroundColor:#F52F3E;borderColor:#F52F3EF;border-radius: 50rpx;height: 88rpx;line-height: 88rpx;">登录</button>
  23. </view>
  24. <view class="login-sign">
  25. <u-checkbox-group @change="handleCheck">
  26. <u-checkbox labelSize="13" size="20" shape="circle" name="agree" label="我同意"></u-checkbox>
  27. </u-checkbox-group>
  28. <view class="log-link" @click="handlerApply">
  29. 排队支付商户用户服务协议
  30. </view>
  31. <view class="log-link" @click="handlerProtect">
  32. 隐私保护协议
  33. </view>
  34. </view>
  35. </view>
  36. </view>
  37. <u-modal :show="show" @confirm="confirm" :title="title" :content='content'></u-modal>
  38. </view>
  39. </template>
  40. <script>
  41. import {
  42. publicSendSms,
  43. merchantSmsLogin,
  44. merchantAccountInfo
  45. } from '../../common/api.js'
  46. import md5 from 'js-md5'
  47. export default {
  48. data() {
  49. return {
  50. phone: '',
  51. sms_code: '',
  52. bgColor: '#bgColor',
  53. checked: false,
  54. show: false,
  55. title: '',
  56. content: '',
  57. countdown: 0
  58. };
  59. },
  60. onLoad() {
  61. // 如果已登录就跳转到商户主页
  62. merchantAccountInfo({}, false).then(data => {
  63. uni.navigateTo({
  64. url: '/pages/merchant-index/index'
  65. });
  66. })
  67. },
  68. methods: {
  69. getCode() {
  70. if (!this.phone) {
  71. uni.$u.toast('请填写手机号')
  72. return
  73. }
  74. if (!this.checked) {
  75. uni.$u.toast('需同意协议')
  76. return
  77. }
  78. let phone = this.phone
  79. let nonce_str = md5(Math.random() + '');
  80. let sign = md5(md5(phone) + md5(nonce_str) + nonce_str)
  81. publicSendSms({
  82. phone,
  83. nonce_str,
  84. sign,
  85. type: 1
  86. }).then(() => {
  87. uni.$u.toast('短信已发送')
  88. this.startCountdown()
  89. })
  90. },
  91. startCountdown() {
  92. this.countdown = 60;
  93. let h = setInterval(() => {
  94. this.countdown--
  95. if (this.countdown == 0) {
  96. clearInterval(h)
  97. }
  98. }, 1000)
  99. },
  100. handleCheck(detail) {
  101. console.log(detail)
  102. if (detail.indexOf('agree') != -1) {
  103. this.checked = true
  104. } else {
  105. this.checked = false
  106. }
  107. },
  108. handlerApply() {
  109. this.show = true;
  110. this.title = '排队支付商户用户服务协议';
  111. this.content = '排队支付商户用户服务协议';
  112. },
  113. handlerProtect() {
  114. this.show = true;
  115. this.title = '隐私保护协议';
  116. this.content = '隐私保护协议';
  117. },
  118. confirm() {
  119. this.show = false;
  120. },
  121. btnLogin() {
  122. if (!this.checked) {
  123. uni.$u.toast('需同意协议')
  124. return
  125. }
  126. merchantSmsLogin({
  127. phone: this.phone,
  128. sms_code: this.sms_code
  129. }).then(data => {
  130. uni.setStorageSync('merchant_token', data.token)
  131. uni.navigateTo({
  132. url: '/pages/merchant-index/index'
  133. });
  134. })
  135. }
  136. }
  137. }
  138. </script>
  139. <style lang="scss">
  140. .login-content {
  141. width: 100%;
  142. height: 1600rpx;
  143. padding-left: 30rpx;
  144. padding-right: 30rpx;
  145. background: url(../../static/login/merchant-bg.png) no-repeat center center;
  146. background-size: cover;
  147. box-sizing: border-box;
  148. .login-font {
  149. width: 364rpx;
  150. height: 200rpx;
  151. padding-top: 80rpx;
  152. }
  153. .login-main {
  154. margin-top: 120rpx;
  155. .login-item {
  156. position: relative;
  157. margin-top: 40rpx;
  158. .log-phone {
  159. width: 100%;
  160. height: 88rpx;
  161. line-height: 88rpx;
  162. padding-left: 50rpx;
  163. border-radius: 44rpx;
  164. border: none;
  165. box-sizing: border-box;
  166. background-color: #fff;
  167. font-size: 16px;
  168. color: #454545;
  169. }
  170. .getCode {
  171. position: absolute;
  172. right: 50rpx;
  173. top: 30rpx;
  174. font-size: 12px;
  175. color: #454545;
  176. cursor: pointer;
  177. }
  178. }
  179. .login-btn {
  180. margin-top: 80rpx;
  181. }
  182. .login-sign {
  183. display: flex;
  184. justify-content: flex-start;
  185. margin-top: 30rpx;
  186. padding-left: 20rpx;
  187. .u-radio-group {
  188. flex-grow: 0;
  189. margin-right: 60rpx;
  190. }
  191. .log-link {
  192. height: 40rpx;
  193. line-height: 40rpx;
  194. font-size: 12px;
  195. }
  196. }
  197. }
  198. }
  199. </style>