123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431 |
- <template>
- <view class="container login" >
- <!-- v-if="isUserInfo" -->
- <view class="login-form title">
- <view class="text">
- <label class="iconfont icon-tishi"></label>请填写如下信息成为机构运营人员后才能操作订单
- </view>
- </view>
- <view class="login-form clearfix">
- <view class="login-input">
- <input type="text"
- v-model="bindLinkName"
- maxlength="30"
- class="input"
- placeholder="请输入姓名"
- placeholder-class="placeholder"
- />
- </view>
- </view>
- <view class="login-form clearfix">
- <view class="login-input">
- <input type="number"
- v-model="bindMobile"
- maxlength="11"
- class="input"
- placeholder="请输入手机号"
- placeholder-class="placeholder"
- />
- </view>
- </view>
- <view class="login-form clearfix">
- <view class="login-input code">
- <input type="text"
- v-model="imageCode"
- maxlength="4"
- class="input"
- placeholder="请输入右侧图形验证码"
- placeholder-class="placeholder"
- />
- </view>
- <view class="login-input img-btn">
- <view class="vscodeimg">
- <image :src="imageCodeUrl" mode=""></image>
- </view>
- <view class="vscod-refresh" @click.stop="getVerificationCode">
- <text class="iconfont icon-shuaxin"></text>
- <text class="ref-text">刷新</text>
- </view>
- </view>
- </view>
- <view class="login-form clearfix">
- <view class="login-input code">
- <input type="number"
- v-model="mobildeCode"
- maxlength="6"
- class="input"
- placeholder="请输入短信验证码"
- placeholder-class="placeholder"
- />
- </view>
- <view class="login-input btn" :class="[isMobileDisabled ? 'disabled' : '']" >
- <button type="button"
- @click.stop="getMobileCodeFn"
- :disabled="isMobileDisabled"
- class="input">
- {{ mobileCodeText }}
- </button>
- </view>
- </view>
- <view class="login-form clearfix">
- <view class="login-btn" @click="bindWechatInfo">绑定</view>
- </view>
- <view class="login-foot">
- <text class="foot-text">本操作会绑定您的微信,绑定后您可使用微信直接登录【采美采购商城】小程序。</text>
- </view>
- </view>
- </template>
- <script>
- import { mapState,mapMutations } from 'vuex'
- import authorize from '@/common/config/authorize.js'
- import wxLogin from "@/common/config/wxLogin.js"
- import { userInfoLogin } from "@/services/use.js"
- import { getbindOperatorCode } from "@/services/public.js"
- export default{
- data() {
- return{
- wxUserInfo:'', //储存用户微信信息
- bindLinkName:'', //用户姓名
- bindMobile:'', //用户手机号
- mobildeCode:'', //手机验证码
- imageCode:'', //图形验证码
- imageCodeUrl:'', //图形验证码地址
- imageCodetoken:'', //图形校验token
- isMobileDisabled:false, //获取手机短信按钮
- count: '', //倒计时
- mobileCodeText: '获取验证码',
- codeTime: null,
- isUserInfo:false
- }
- },
- onLoad(option) {
- console.log(option)
- uni.setStorageSync('bind_id', option.userID);
- this.getVerificationCode()
- authorize.getSetting().then(wxResponse =>{// console.log('是否已授权',res);//0:为取消授权 1:为已授权 2:为未操作
- if(wxResponse == 1){
- this.getWxAuthorize()
- }else{
- this.$api.navigateTo('/pages/authorization/authorization')
- this.isUserInfo = true
- }
- })
- },
- computed: {
- ...mapState(['isWxAuthorize'])
- },
- methods:{
- ...mapMutations(['login','logout']),
- getWxAuthorize(){// 根据微信的code获取用户登录状态:1已登录过 -1未登录过
- authorize.getCode('weixin').then(wechatcode =>{
- // 根据微信的code获取用户登录状态:1已登录过 -1未登录过
- authorize.getUserInfo('weixin').then(wxResponse =>{
- userInfoLogin({code:wechatcode,encryptedData:wxResponse.encryptedData,iv:wxResponse.iv}).then(response =>{
- this.login(response.data)
- uni.setStorageSync('token',response.data.token)
- uni.removeStorageSync('sessionid')
- uni.setStorageSync('sessionid','JSESSIONID='+response.data.sessionId)
- this.$store.commit('updateStatus',response.data)
- if(response.data.userIdentity ==1){
- // this.$api.navigateTo('/seller/pages/index/index')
- }else{
- // this.$api.switchTabTo('/pages/tabBar/home/index')
- }
- }).catch(error =>{
- this.logout()
- this.isUserInfo = true
- uni.removeStorageSync('sessionid')
- uni.setStorageSync('sessionid','JSESSIONID='+error.data)
- this.$store.commit('updateStatus',error.data)
- })
- })
- })
- },
- bindWechatInfo(){
- if( this.bindLinkName == ''){
- this.$util.msg('请输入姓名',2000)
- return
- }
- if( this.bindMobile == ''){
- this.$util.msg('请输入手机号',2000)
- return
- }
- if(!this.$reg.isMobile(this.bindMobile)){
- this.$util.msg('请输入正确的手机号',2000)
- return
- }
- if( this.mobildeCode == ''){
- this.$util.msg('请输入手机验证码',2000)
- return
- }
- if(!this.$reg.isMobileCode(this.mobildeCode)){
- this.$util.msg('验证码格式不正确',2000)
- return
- }
- authorize.getSetting().then(wxResponse =>{// console.log('是否已授权',res);//0:为取消授权 1:为已授权 2:为未操作
- if(wxResponse == 1){
- this.bindingWechatLogin()
- }else{
- this.$api.navigateTo('/pages/authorization/authorization')
- }
- })
- },
- getVerificationCode(){//图形验证
- this.PublicService.GetImgVerifyCode().then(res => {
- this.imageCodeUrl = res.data.baseImage
- this.imageCodetoken = res.data.token
- })
- },
- getMobileCodeFn(){//获取手机验证码
- if( this.bindMobile == ''){
- this.$util.msg('请输入手机号',2000);
- return
- }
- if(!this.$reg.isMobile(this.bindMobile)){
- this.$util.msg('请输入正确的手机号',2000);
- return
- }
- if( this.imageCode == ''){
- this.$util.msg('请输入图形验证码',2000);
- return
- }
- let params = {
- userId:uni.getStorageSync('bind_id'),
- mobile:this.bindMobile,
- platformType:2,
- imgCode:this.imageCode,
- token:this.imageCodetoken,
- }
- this.isMobileDisabled = true;
- getbindOperatorCode(params).then(res =>{
- const TIME_COUNT = 60;
- this.$util.msg('验证短信已发送',2000)
- if (!this.codeTime) {
- this.count = TIME_COUNT;
- this.isMobileDisabled = true;
- this.codeTime = setInterval(() => {
- if (this.count > 1 && this.count <= TIME_COUNT) {
- this.count--
- this.mobileCodeText = this.count +'s重新发送'
- } else {
- this.isMobileDisabled = false;
- clearInterval(this.codeTime)
- this.codeTime = null
- this.mobileCodeText = '获取验证码'
- }
- },1000)
- }
- }).catch( res =>{
- this.$util.msg(res.msg,2000)
- this.isMobileDisabled = false;
- })
- },
-
- bindingWechatLogin(){//获取用户基本信息登录
- wx.getUserInfo({
- success: res => {
- this.wxUserInfo = res.userInfo;
- let params ={
- userID: uni.getStorageSync('bind_id'),
- mobile: this.bindMobile,
- linkName: this.bindLinkName,
- verificationCode: this.mobildeCode,
- nickName: this.wxUserInfo.nickName,
- headimgurl: this.wxUserInfo.avatarUrl,
- }
- this.SellerService.SellerBindingOperation(params).then(response =>{
- this.login(response.data)
- this.$api.switchTabTo('/pages/tabBar/home/index')
- }).catch(error =>{
- this.$util.msg(error.msg,2000)
- this.isUserInfo = true
- })
- }
- })
- }
- },
- onShow() {
- }
- }
- </script>
- <style lang="scss">
- .login{
- width: 100%;
- height: auto;
- border-top: 1px solid #F7F7F7;
- padding-top: 30rpx;
- .login-foot{
- width: 528rpx;
- height: 88rpx;
- padding: 0 24rpx;
- margin: 30rpx auto;
- text-align: center;
- .foot-text{
- font-size: 24rpx;
- line-height: 44rpx;
- color:#999999;
- }
- }
- .login-form{
- width: 702rpx;
- height: auto;
- padding: 0 24rpx;
- &.title{
- color: #e15616;
- font-size: 24rpx;
- text-align: center;
- margin-bottom: 20rpx;
- .text{
- padding: 20rpx 24rpx;
- background: #fff0e9;
- border-radius: 16rpx;
- .iconfont{
- margin-right: 20rpx;
- position: relative;
- top: 5rpx;
- }
- }
- }
- .login-input{
- width: 654rpx;
- height: 40rpx;
- padding: 24rpx;
- margin-bottom: 20rpx;
- display: flex;
- flex-direction: column;
- align-items: center;
- border-bottom: 1rpx solid #e1e1e1;
- &.code{
- width: 370rpx;
- float: left;
- margin-right: 10rpx;
- }
- &.btn{
- width: 258rpx;
- height: 88rpx;
- padding: 0;
- float: left;
- border: 0;
- .input{
- width: 280rpx;
- height: 88rpx;
- line-height: 88rpx;
- padding: 0;
- border-radius: 45rpx;
- color: #FFFFFF;
- background: $btn-confirm;
- }
- &.disabled{
- background: #F7F7F7;
- .input{
- color: #999999;
- }
- }
- }
- &.img-btn{
- width: 270rpx;
- height: 88rpx;
- padding: 0;
- float: left;
- background: #FFFFFF;
- display: block;
- border: 0;
- .vscodeimg{
- width: 160rpx;
- height: 64rpx;
- float: left;
- display: flex;
- flex-direction: column;
- align-items: center;
- border-radius: 6rpx;
- image{
- width: 180rpx;
- height: 88rpx;
- border-radius: 14rpx;
- }
- }
- .vscod-refresh{
- width: 95rpx;
- float: right;
- // display: flex;
- flex-direction: column;
- align-items: center;
- margin-top: 10rpx;
- .icon-shuaxin{
- font-size: 36rpx;
- color: #999999;
- display: inline-block;
- }
- .ref-text{
- font-size: 24rpx;
- color: #999999;
- display: inline-block;
- margin-left: 10rpx;
- }
- }
- }
- .input{
- width: 100%;
- height: 100%;
- // background: #F7F7F7;
- font-size: $font-size-28;
- line-height: 40rpx;
- color: #333333;
- border-radius: 14rpx;
- }
- }
- }
- .login-btn{
- width: 600rpx;
- height: 88rpx;
- border-radius: 44rpx;
- font-size: $font-size-28;
- line-height: 88rpx;
- color: #FFFFFF;
- margin: 0 auto;
- text-align: center;
- background: $btn-confirm;
- margin-top: 100rpx;
- }
- .model-authorization{
- width: 100%;
- height: 100%;
- position: fixed;
- top: 0;
- left: 0;
- z-index: 999;
- .authorization{
- width: 518rpx;
- height: 320rpx;
- position: absolute;
- background: rgba(255,255,255,.7);
- left: 0;
- right: 0;
- bottom: 0;
- top: 0;
- margin: auto;
- .to-btn{
- position: absolute;
- top: 0;
- left: 0;
- right: 0;
- bottom: 0;
- margin: auto;
- width: 70%;
- height: 88rpx;
- font-size: $font-size-28;
- line-height: 88rpx;
- color: #FFFFFF;
- text-align: center;
- border-radius: 44rpx;
- }
- }
- }
- }
- .placeholder{
- color:#b2b2b2 ;
- }
- </style>
|