| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472 |
- <template>
- <div class="defbb">
- <div class="defbb pt-spac pb-spac mt-spac">
- 平台账户授权 [
- <span class="gray-color" :class="{ 'green-color': progress }">{{
- stateText
- }}</span>
- ]<span class="ml-spac p-wcolor" v-if="waring"> [ 提醒:请先绑定“授权手机号”!]</span>
- </div>
- <div class="items p-spacd2">
- <div class="center justify-between p-spacd2">
- <div class="label-color">授权手机号</div>
- <div>
- <span>{{ value }}</span>
- <el-button class="ml-spac" type="text" @click="saveTel()" v-if="!$props.readOnly">{{
- bindPhoneText
- }}</el-button>
- </div>
- </div>
- <div class="center justify-between p-spacd2 defbt">
- <div class="label-color">转账授权</div>
- <div
- class="p-color"
- :class="{ 'gray-color': !isBindPhone||this.$props.readOnly ,'green-color':balanceAuthed,pointer:!$props.readOnly}"
- @click="authEvent(0)"
- >
- <i class="el-icon-loading
- " v-if="$reqState($interfaces.pay.sign_balance_protocol).ing"></i>{{authText(balanceAuthed)}}
- </div>
- </div>
- <div class="center justify-between p-spacd2 defbt" v-if="isDealer">
- <div class="label-color">提现授权</div>
- <div
- class="p-color"
- :class="{ 'gray-color': !isBindPhone||this.$props.readOnly,'green-color':withdrawAuthed,pointer:!$props.readOnly }"
- @click="authEvent(1)"
- >
- <i class="el-icon-loading
- " v-if="$reqState($interfaces.pay.sign_balance_protocol).ing"></i>{{authText(withdrawAuthed)}}
- </div>
- </div>
- </div>
- <el-dialog
- :append-to-body="true"
- title="修改手机号"
- :visible.sync="telDialogVisible"
- @close="closeEditTelDialog"
- >
- <el-steps :active="stepActive" align-center>
- <el-step title="解绑原手机号"></el-step>
- <el-step title="绑定新手机号"></el-step>
- </el-steps>
- <el-form
- :model="formStepOne"
- v-if="stepActive === 1"
- ref="formStepOne"
- :rules="formStepOneRules"
- >
- <el-form-item label="原手机号" prop="newTel">
- <el-input v-model="formStepOne.tel" disabled></el-input>
- </el-form-item>
- <el-form-item label="验证码" prop="code">
- <el-input v-model="formStepOne.code" clearable>
- <template slot="append"
- ><div class="getcode-btn" @click="getCodeEvent('formStepOne')">
- {{ codeBtn.text }}
- </div></template
- >
- </el-input>
- </el-form-item>
- </el-form>
- <el-form
- :model="formStepTwo"
- v-else-if="stepActive === 2"
- ref="formStepTwo"
- :rules="formStepTwoRules"
- >
- <el-form-item label="新手机号" prop="newTel">
- <el-input v-model="formStepTwo.newTel"></el-input>
- </el-form-item>
- <el-form-item label="验证码" prop="code">
- <el-input v-model="formStepTwo.code" clearable>
- <template slot="append"
- ><div class="getcode-btn" @click="getCodeEvent('formStepTwo')">
- {{ codeBtn.text }}
- </div></template
- >
- </el-input>
- </el-form-item>
- </el-form>
- <div slot="footer">
- <el-button type="primary" @click="footerBtnEvent">{{
- footerBtnText
- }}</el-button>
- </div>
- </el-dialog>
- <el-dialog
- :append-to-body="true"
- title="绑定手机号"
- :visible.sync="bindTelDialogVisible"
- @close="closeBindTelDialog"
- >
- <el-form
- :model="formBindTel"
- ref="formBindTel"
- v-if="bindTelDialogVisible"
- :rules="formBindTelRules"
- >
- <el-form-item label="手机号" prop="tel">
- <el-input v-model="formBindTel.tel"></el-input>
- </el-form-item>
- <el-form-item label="验证码" prop="code" clearable>
- <el-input v-model="formBindTel.code">
- <template slot="append"
- ><div class="getcode-btn" @click="getCodeEvent('formBindTel')">
- {{ codeBtn.text }}
- </div></template
- >
- </el-input>
- </el-form-item>
- </el-form>
- <div slot="footer">
- <el-button type="primary" @click="bindTelEvent">确认绑定</el-button>
- </div>
- </el-dialog>
- </div>
- </template>
- <script>
- import { $sendVerificationCode, $unbindPhone, $bindPhone, $signContractQuery } from '@/service/pay'
- export default {
- name: 'authorize',
- data() {
- return {
- authClicked: false,
- bindPhone: '66',
- formStepOne: {
- tel: '',
- code: ''
- },
- formStepOneRules: {
- code: [{ required: true, message: '此选项不能为空', trigger: 'blur' }]
- },
- formStepTwo: {
- newTel: '',
- code: ''
- },
- formStepTwoRules: {
- newTel: [
- { required: true, message: '此选项不能为空', trigger: 'blur' }
- ],
- code: [{ required: true, message: '此选项不能为空', trigger: 'blur' }]
- },
- telDialogVisible: false,
- bindTelDialogVisible: false,
- stepActive: 1,
- codeBtn: {
- text: '获取验证码',
- disabled: false
- },
- formBindTel: {
- tel: '',
- code: ''
- },
- formBindTelRules: {
- tel: [{ required: true, message: '此选项不能为空', trigger: 'blur' }],
- code: [{ required: true, message: '此选项不能为空', trigger: 'blur' }]
- },
- footerBtnText: '下一步'
- }
- },
- props: {
- tradeType: {
- type: Number
- },
- value: {
- type: String,
- default: ''
- },
- carrierBalanceInfo: {
- type: Object,
- default: () => ({})
- },
- carrierWithdrawInfo: {
- type: Object,
- default: () => ({})
- },
- readOnly: {
- type: Boolean,
- default: false
- }
- },
- computed: {
- /** 经销 */
- isDealer() {
- return this.$props.tradeType === 1
- },
- balanceAuthed() {
- return this.carrierBalanceInfo.balanceStatus === 2
- },
- withdrawAuthed() {
- return this.carrierWithdrawInfo.withdrawStatus === 2
- },
- progress() {
- let count = 0
- if (this.balanceAuthed) {
- count++
- }
- if (this.withdrawAuthed) {
- count++
- }
- return count
- },
- stateText() {
- let rv = '未完成'
- if (this.isDealer) {
- if (this.progress === 2) {
- rv = '已授权'
- } else {
- rv = `${this.progress}/2`
- }
- } else {
- if (this.carrierBalanceInfo.balanceStatus === 2) {
- rv = '已授权'
- }
- }
- return rv
- },
- isBindPhone() {
- return !!this.$props.value
- },
- bindPhoneText() {
- return this.isBindPhone ? '修改' : '绑定'
- },
- waring() {
- return !this.isBindPhone && this.authClicked
- }
- },
- created() {
- this.formStepOne.tel = this.$props.value
- },
- methods: {
- authText(authed) {
- let rv = '未授权'
- if (authed) {
- rv = '已授权'
- } else {
- if (this.$props.readOnly) {
- rv = '未授权'
- } else {
- rv = '去授权'
- }
- }
- return rv
- },
- authEvent(type) {
- if (this.$props.readOnly) {
- return
- }
- if (!this.isBindPhone) {
- this.authClicked = true
- return
- }
- // 转账授权
- if (type === 0) {
- // 已授权
- if (this.carrierBalanceInfo.balanceStatus === 2) {
- this.$router.push('accountSetting/balanceProtocol')
- } else {
- const params = {
- source: 2,
- backUrl: window.location.href,
- jumpUrl: location.href.split('/#')[0] + '/#/signSuccess'
- }
- this.$http(this.$interfaces.pay.sign_balance_protocol, params).then(res => {
- window.location.href = res
- })
- }
- }
- // 提现授权
- if (type === 1) {
- // 已授权
- if (this.carrierWithdrawInfo.withdrawStatus === 2) {
- const params = {
- jumpUrl: window.location.href,
- source: 2
- }
- $signContractQuery(params).then(res => {
- if (res.code === 0) {
- window.location.href = res.data
- }
- })
- } else {
- const params = {
- source: 2,
- backUrl: window.location.href,
- jumpUrl: location.href.split('/#')[0] + '/#/signSuccess'
- }
- this.$http(this.$interfaces.pay.sign_withdraw_protocol, params).then(res => {
- window.location.href = res
- })
- }
- }
- },
- bindTelEvent() {
- this.$refs.formBindTel.validate((valid) => {
- if (valid) {
- const params = {
- verificationCode: this.formBindTel.code,
- phone: this.formBindTel.tel
- }
- $bindPhone(params).then((res) => {
- this.$message.success(res.message)
- this.$emit('input', this.formBindTel.tel)
- this.formStepOne.tel = this.formBindTel.tel
- this.bindTelDialogVisible = false
- })
- }
- })
- },
- saveTel() {
- if (this.isBindPhone) {
- this.telDialogVisible = true
- if (this.timer) {
- clearInterval(this.timer)
- this.codeBtn.text = '获取验证码'
- this.codeBtn.disabled = false
- }
- } else {
- this.bindTelDialogVisible = true
- }
- },
- getCodeEvent(param) {
- // let step = this.stepActive
- if (this.codeBtn.disabled) {
- return
- }
- if (param === 'formStepOne') {
- this.codeEvent(this.formStepOne.tel, param)
- } else if (param === 'formStepTwo') {
- this.$refs[param].validateField('newTel', (valid) => {
- if (!valid) {
- this.codeEvent(this.formStepTwo.newTel, param)
- } else {
- return null
- }
- })
- } else {
- this.$refs[param].validateField('tel', (valid) => {
- if (!valid) {
- this.codeEvent(this.formBindTel.tel, param)
- } else {
- return null
- }
- })
- }
- },
- codeEvent(tel, param) {
- let verificationCodeType = 0
- if (param === 'formStepTwo' || param === 'formBindTel') {
- verificationCodeType = 9
- } else {
- verificationCodeType = 6
- }
- const params = {
- phone: tel,
- verificationCodeType
- }
- $sendVerificationCode(params)
- .then((res) => {
- this.$message.success(res.message)
- })
- .catch((msg) => {
- clearInterval(this.timer)
- this.codeBtn.text = '获取验证码'
- this.codeBtn.disabled = false
- })
- let time = 60
- this.codeBtn.text = time + 's'
- this.timer = setInterval(() => {
- time--
- this.codeBtn.text = time + 's'
- this.codeBtn.disabled = true
- if (time < 0) {
- clearInterval(this.timer)
- this.codeBtn.text = '获取验证码'
- this.codeBtn.disabled = false
- }
- }, 1000)
- },
- footerBtnEvent() {
- if (this.stepActive === 1) {
- this.$refs.formStepOne.validateField('code', (valid) => {
- if (!valid) {
- const code = this.formStepOne.code
- const params = {
- phone: this.formStepOne.tel,
- verificationCode: code
- }
- $unbindPhone(params).then((res) => {
- if (res.code === 0) {
- this.stepActive = 2
- this.footerBtnText = '确认修改'
- this.$message.success(res.message)
- this.$emit('input', '')
- if (this.timer) {
- clearInterval(this.timer)
- this.codeBtn.text = '获取验证码'
- this.codeBtn.disabled = false
- }
- } else {
- this.$message.error(res.message)
- }
- })
- } else {
- return null
- }
- })
- } else {
- this.$refs.formStepTwo.validate((valid) => {
- if (valid) {
- const params = {
- phone: this.formStepTwo.newTel,
- verificationCode: this.formStepTwo.code
- }
- $bindPhone(params).then((res) => {
- if (res.code === 0) {
- this.stepActive = 1
- this.formStepOne.code = ''
- this.formStepTwo.tel = ''
- this.formStepTwo.code = ''
- this.$message.success(res.message)
- this.$emit('input', this.formStepTwo.newTel)
- this.telDialogVisible = false
- } else {
- this.$message.error(res.message)
- }
- })
- }
- })
- }
- },
- closeBindTelDialog() {
- this.formBindTel.tel = ''
- this.formBindTel.code = ''
- },
- closeEditTelDialog() {
- this.formStepOne.code = ''
- this.formStepTwo.newTel = ''
- this.formStepTwo.code = ''
- this.stepActive = 1
- if (this.$refs.formStepOne) {
- this.$refs.formStepOne.clearValidate()
- }
- if (this.$refs.formStepTwo) {
- this.$refs.formStepTwo.clearValidate()
- }
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- @import "submodule/utils/style/variables.scss";
- .items {
- width: 400px;
- }
- .getcode-btn {
- width: 70px;
- text-align: center;
- cursor: pointer;
- color: $p-color;
- }
- </style>
|