|  |  |  | 
|---|
|  |  |  | </view> | 
|---|
|  |  |  | <view class="t-a input form-input" v-if="loginType=='pwd'"> | 
|---|
|  |  |  | <!-- <input type="text" name="userName" placeholder="请输入账号" v-model="userName" /> --> | 
|---|
|  |  |  | <u-input placeholder="请输入账号" :border="false" v-model="userName" @blur="validatePhoneNumber()"></u-input> | 
|---|
|  |  |  | <u-input placeholder="请输入账号" :border="false" v-model="userName" | 
|---|
|  |  |  | @blur="validatePhoneNumber()"></u-input> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | </view> | 
|---|
|  |  |  | <view class="t-a input form-input" v-if="loginType=='pwd'"> | 
|---|
|  |  |  | 
|---|
|  |  |  | <view class="t-a input form-input" v-if="loginType=='code'"> | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <u-input placeholder="请输入手机号" :border="false" v-model="phoneNumber" @blur="validatePhoneNumber()"> | 
|---|
|  |  |  | <u-input placeholder="请输入手机号" :border="false" v-model="phoneNumber" | 
|---|
|  |  |  | @blur="validatePhoneNumber()"> | 
|---|
|  |  |  | <template slot="suffix"> | 
|---|
|  |  |  | <view class="get-code" :style="{'color':getCodeBtnColor}" @click.stop="getCode()"> | 
|---|
|  |  |  | {{ getCodeText }} | 
|---|
|  |  |  | 
|---|
|  |  |  | <button @tap="login()" class="bottom-button">登 录</button> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <view class="flex"> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <view class="topic-font" v-if="loginType=='pwd'&&apitype!=='loginAdmin'" | 
|---|
|  |  |  | @click="loginType='code'">手机验证码登录</view> | 
|---|
|  |  |  | <view class="topic-font" v-if="loginType=='code'&&apitype!=='loginAdmin'" | 
|---|
|  |  |  | 
|---|
|  |  |  | {{optionsStr}} | 
|---|
|  |  |  | </view> --> | 
|---|
|  |  |  | </view> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <!-- #ifdef PUB_CUSTOMER --> | 
|---|
|  |  |  | <view class="flex" style="justify-content: center; margin-top: 150px;"> | 
|---|
|  |  |  | <u--image :showLoading="true" v-if="false" | 
|---|
|  |  |  | src="https://hmy-flower.oss-cn-shanghai.aliyuncs.com/6e/6e74997e6d4c4a29be3903b35bc1f38fwechat.png" | 
|---|
|  |  |  | width="40rpx" height="40rpx" @click="handleWechatClick"> | 
|---|
|  |  |  | </u--image> | 
|---|
|  |  |  | <u-grid :border="false" :col="1"> | 
|---|
|  |  |  | <u-grid-item @click="handleWechatClick"> | 
|---|
|  |  |  | <u--image :showLoading="true" | 
|---|
|  |  |  | src="https://hmy-flower.oss-cn-shanghai.aliyuncs.com/6e/6e74997e6d4c4a29be3903b35bc1f38fwechat.png" | 
|---|
|  |  |  | width="40rpx" height="40rpx" @click="handleWechatClick"> | 
|---|
|  |  |  | </u--image> | 
|---|
|  |  |  | <text class="third-login-text" @click="handleWechatClick">微信登录</text> | 
|---|
|  |  |  | </u-grid-item> | 
|---|
|  |  |  | </u-grid> | 
|---|
|  |  |  | </view> | 
|---|
|  |  |  | <!-- #endif --> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | </view> | 
|---|
|  |  |  | </template> | 
|---|
|  |  |  | <script> | 
|---|
|  |  |  | 
|---|
|  |  |  | }; | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | methods: { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | handleWechatClick() { | 
|---|
|  |  |  | let that = this | 
|---|
|  |  |  | // 微信登录 | 
|---|
|  |  |  | uni.login({ | 
|---|
|  |  |  | "provider": "weixin", | 
|---|
|  |  |  | "onlyAuthorize": true, // 微信登录仅请求授权认证 | 
|---|
|  |  |  | success: async function (event) { | 
|---|
|  |  |  | console.log("客户端成功获取授权临时票据(code),向业务服务器发起登录请求。") | 
|---|
|  |  |  | console.log(event) | 
|---|
|  |  |  | const { code } = event | 
|---|
|  |  |  | console.log('code', code) | 
|---|
|  |  |  | that.$message.showLoading(); | 
|---|
|  |  |  | const resp = await that.$store.dispatch('loginwx', { code }) | 
|---|
|  |  |  | if (resp && resp.data) { | 
|---|
|  |  |  | that.$forceUpdate() | 
|---|
|  |  |  | uni.reLaunch({ | 
|---|
|  |  |  | url: '/pages/home/home' | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // const resp = await that.$http.request('get', '/api/wx/jscode2session', { | 
|---|
|  |  |  | //     params: { | 
|---|
|  |  |  | //         jsCode: code, | 
|---|
|  |  |  | //         userType: that.apitype.replace("login", "").toLowerCase() | 
|---|
|  |  |  | //     } | 
|---|
|  |  |  | // }); | 
|---|
|  |  |  | that.$message.hideLoading(); | 
|---|
|  |  |  | // console.log('resp', resp) | 
|---|
|  |  |  | // if (resp && resp.data) { | 
|---|
|  |  |  | //     var cts = resp.data; | 
|---|
|  |  |  | //     var openid = cts.openid; //openid 用户唯一标识 | 
|---|
|  |  |  | //     if (cts && cts.openid) { | 
|---|
|  |  |  | //         that.$storage.setItem('openid', cts.openid); | 
|---|
|  |  |  | //     } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //     var session_key = cts.session_key; //session_key  会话密钥 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //     if (true) { | 
|---|
|  |  |  | //         if (!!cts.errmsg) { | 
|---|
|  |  |  | //             that.$message.showToast('获取失败' + cts.errmsg); | 
|---|
|  |  |  | //         } else { | 
|---|
|  |  |  | //             //成功了,再调用 | 
|---|
|  |  |  | //             uni.getUserInfo({ | 
|---|
|  |  |  | //             provider: 'weixin', | 
|---|
|  |  |  | //             success: function (infoRes) { | 
|---|
|  |  |  | //                 console.log("uni.getUserInfo") | 
|---|
|  |  |  | //                 console.log(infoRes) | 
|---|
|  |  |  | //                 console.log('用户信息:', infoRes.userInfo); | 
|---|
|  |  |  | //             }, | 
|---|
|  |  |  | //             fail: function (err) { | 
|---|
|  |  |  | //                 console.error('获取用户信息失败:', err); | 
|---|
|  |  |  | //             }, | 
|---|
|  |  |  | //             }); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //         } | 
|---|
|  |  |  | //     } | 
|---|
|  |  |  | // } | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | fail: function (err) { | 
|---|
|  |  |  | // 登录授权失败 | 
|---|
|  |  |  | // err.code是错误码 | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }) | 
|---|
|  |  |  |  | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | // 手机号码正则表达式校验 | 
|---|
|  |  |  | validatePhoneNumber() { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | height: 0; | 
|---|
|  |  |  | content: '\20'; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | .third-login-text{ | 
|---|
|  |  |  | font-size: 18rpx; | 
|---|
|  |  |  | margin-top:5rpx; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | </style> | 
|---|