BindOld.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. <template>
  2. <view class="div container">
  3. <view class="div top-wrapper">
  4. <flex-line class="field-line input-wrapper" :show-border="true"><view class="div field-line-right" slot="right"><input class="field-input" v-model="username" placeholder="用户名" maxlength="11" /></view></flex-line>
  5. <flex-line class="field-line input-wrapper" :show-border="true"><view class="div field-line-right" slot="right"><input class="field-input" type="password" v-model="password" placeholder="密码" maxlength="20" /></view></flex-line>
  6. </view>
  7. <view class="div common-btn ds-button-large mt-10 mb-10" @click="onSubmit">绑定</view>
  8. </view>
  9. </template>
  10. <script>
  11. import { mapState, mapMutations } from 'vuex'
  12. import { bind, getThirdLogin } from '../../../api/memberLogin'
  13. import flexLine from '../../flexLine'
  14. export default {
  15. name: 'BindOld',
  16. data () {
  17. return {
  18. query:{},
  19. username: '',
  20. password: '',
  21. wxinfo: false
  22. }
  23. },
  24. components: { flexLine },
  25. mounted(){
  26. var pages = getCurrentPages()
  27. var page = pages[pages.length - 1]
  28. this.query = page.options
  29. getThirdLogin(this.query.id).then(res => {
  30. let wxinfo = res.result.wxinfo
  31. if (!wxinfo) {
  32. uni.showToast({icon:'none',title: '绑定信息不存在'})
  33. uni.navigateTo({url: '/pages/home/memberlogin/Login' })
  34. } else {
  35. this.wxinfo = wxinfo
  36. }
  37. })
  38. },
  39. computed: {
  40. ...mapState({
  41. inviter_id: state => state.member.inviterId
  42. })
  43. },
  44. methods: {
  45. ...mapMutations({
  46. saveAuthInfo: 'memberLogin'
  47. }),
  48. check () {
  49. let username = this.username
  50. let password = this.password
  51. if (username.length === 0) {
  52. uni.showToast({icon:'none',title: '请输入用户名'})
  53. return false
  54. }
  55. if (password.length === 0) {
  56. uni.showToast({icon:'none',title: '请输入密码'})
  57. return false
  58. }
  59. return true
  60. },
  61. signup () {
  62. if (!this.check()) {
  63. return
  64. }
  65. uni.showLoading({ title: '加载中' })
  66. bind(0, 'wx', this.wxinfo.openid, this.wxinfo.unionid, this.wxinfo.nickname, this.wxinfo.headimgurl, this.username, this.password, '', this.inviter_id).then(
  67. response => {
  68. uni.hideLoading()
  69. this.saveAuthInfo({ token: response.result.token, info: response.result.info })
  70. uni.navigateTo({url: '/pages/member/index/Index' })
  71. },
  72. error => {
  73. uni.hideLoading()
  74. uni.showToast({icon:'none',title: error.message})
  75. }
  76. )
  77. },
  78. onSubmit () {
  79. this.signup()
  80. }
  81. }
  82. }
  83. </script>
  84. <style scoped lang="scss">
  85. .ds-button-large{margin:0 $pageSpace}
  86. .container {
  87. display: flex;
  88. flex-direction: column;
  89. justify-content: flex-start;
  90. align-items: stretch;
  91. //background-color: $primaryColor;
  92. .input-wrapper {
  93. font-size:$subFontSize;
  94. display: flex;
  95. flex-direction: row;
  96. align-content: flex-start;
  97. align-items: center;
  98. background-color: #fff;
  99. height:2.2rem;
  100. padding-left:0.5rem;
  101. input {
  102. flex: 1;
  103. }
  104. .bottom-input {
  105. border-bottom-width: 0;
  106. }
  107. .img{height:1.75rem}
  108. }
  109. }
  110. .top-wrapper {margin:0 $pageSpace;}
  111. .bottom-wrapper {margin-top:0.5rem;}
  112. .tips {
  113. color: $descTextColor;
  114. font-size:$fontSize;
  115. white-space: nowrap;
  116. position: absolute;
  117. right: 0;
  118. top:50%;
  119. margin-top:-.3rem;
  120. }
  121. .countdown {min-width:4rem;margin-right:0.5rem;}
  122. .field-line-right{position: relative;
  123. .field-input{
  124. text-align: left !important;
  125. }
  126. }
  127. </style>