Browse Source

代理登录

master
yangrz 2 years ago
parent
commit
665efc0f20
  1. 12
      agentApp/common/api.js
  2. 83
      agentApp/pages/agent-login/index.vue

12
agentApp/common/api.js

@ -59,6 +59,18 @@ export const userWithdraw = (params) => http.post(baseUrl + '/api/user/withdraw'
export const userWithdrawList = (params) => http.post(baseUrl + '/api/user/withdrawList', params, userConfig())
// 带上代理token
const agentConfig = function() {
return {
header: {
'Agent-Token': uni.getStorageSync('agent_token')
}
}
}
export const agentSmsLogin = (params) => http.post(baseUrl + '/api/agent/smsLogin', params)
// 带上商户token
const merchantConfig = function() {
return {

83
agentApp/pages/agent-login/index.vue

@ -6,23 +6,25 @@
</view>
<view class="login-main">
<view class="login-item">
<input type="text" class="log-phone" placeholder="请输入手机号"/>
<input type="tel" class="log-phone" placeholder="请输入手机号" v-model="phone" />
</view>
<view class="login-item">
<input type="text" class="log-phone log-code" placeholder="请输入验证码"/>
<view class="getCode" @click="getCode">
<input type="number" class="log-phone log-code" placeholder="请输入验证码" v-model="sms_code" />
<view class="getCode" @click="getCode" v-if="countdown==0">
获取验证码
</view>
<view class="getCode" v-else>
剩余{{countdown}}
</view>
</view>
<view class="login-btn">
<button size="default" type="default" @click="btnLogin"
style="color:#ffffff;backgroundColor:#1783FF;borderColor:#1783FF;border-radius: 50rpx;height: 88rpx;line-height: 88rpx;"
>登录</button>
style="color:#ffffff;backgroundColor:#1783FF;borderColor:#1783FF;border-radius: 50rpx;height: 88rpx;line-height: 88rpx;">登录</button>
</view>
<view class="login-sign">
<u-radio-group v-model="value">
<u-radio labelSize="13" size="20" label="我同意"></u-radio>
</u-radio-group>
<u-checkbox-group @change="handleCheck">
<u-checkbox labelSize="13" size="20" shape="circle" name="agree" label="我同意"></u-checkbox>
</u-checkbox-group>
<view class="log-link" @click="handlerApply">
排队支付代理用户服务协议
</view>
@ -32,28 +34,72 @@
</view>
</view>
</view>
<u-toast ref="uToast"></u-toast>
<u-modal :show="show" @confirm="confirm" :title="title" :content='content'></u-modal>
</view>
</template>
<script>
import {
publicSendSms,
agentSmsLogin
} from '../../common/api.js'
import md5 from 'js-md5'
export default {
data() {
return {
phone: '',
sms_code: '',
bgColor: '#bgColor',
value: 1,
checked: false,
show: false,
title: '',
content:''
content: '',
countdown: 0
};
},
methods: {
getCode() {
this.$refs.uToast.show({
message: '短信已发送'
if (!this.phone) {
uni.$u.toast('请填写手机号')
return
}
if (!this.checked) {
uni.$u.toast('需同意协议')
return
}
let phone = this.phone
let nonce_str = md5(Math.random() + '');
let sign = md5(md5(phone) + md5(nonce_str) + nonce_str)
publicSendSms({
phone,
nonce_str,
sign,
type: 2
}).then(() => {
uni.$u.toast('短信已发送')
this.startCountdown()
})
},
startCountdown() {
this.countdown = 60;
let h = setInterval(() => {
this.countdown--
if (this.countdown == 0) {
clearInterval(h)
}
}, 1000)
},
handleCheck(detail) {
console.log(detail)
if (detail.indexOf('agree') != -1) {
this.checked = true
} else {
this.checked = false
}
},
handlerApply() {
this.show = true;
this.title = '排队支付代理用户服务协议';
@ -68,9 +114,20 @@
this.show = false;
},
btnLogin() {
if (!this.checked) {
uni.$u.toast('需同意协议')
return
}
agentSmsLogin({
phone: this.phone,
sms_code: this.sms_code
}).then(data => {
uni.setStorageSync('agent_token', data.token)
uni.navigateTo({
url: '/pages/index/index'
});
})
}
}
}

Loading…
Cancel
Save