123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492 |
- <template>
- <div class="wechat-view">
- <div class="header-view">
- <div class="hearder-kuang">
- <div class="header-img">
- <img src="/images/mobile/@2x/wechat/header-img.png" :src="headerImg"/>
- </div>
- </div>
- <div class="header-name">
- {{userName}}
- </div>
- <img src="/images/mobile/@2x/wechat/headerbg.png" class="headerbg"/>
- </div>
- <div class="middle-view">
- <ul>
- <li class="telphone">
- <input placeholder="请输入手机号" type="tel" maxlength="11" @blur="telphoneBlur" v-model="telphoneNum"/>
- </li>
- <li class="wechat-view-info">
- <div v-show="telerror">
- 请输入正确的手机号码
- </div>
- </li>
- <li class="password" v-if="!bindShow">
- <input placeholder="请输入密码" type="password" v-model="passwordNum"/>
- </li>
- <li v-if="bindShow" class="code clearfix">
- <input placeholder="请输入验证码" type="tel" v-model="codeNum" style="margin-left: 0;"/>
- <span class="pull-right codeBtn" @click="getCode()">
- {{showExtraTime ? getExtraTime + 'S' : '获取验证码'}}
- </span>
- </li>
- <li class="wechat-view-info clearfix" v-if="bindShow">
- <div v-show="codeerror" class="pull-left">
- 验证码错误
- </div>
- <div class="pull-right" @click="bindShow = false">用户名密码登录</div>
- </li>
- <li class="toInfoBind" @click="toInfoBind()" v-if="!bindShow">通过短信绑定</li>
- </ul>
- <div class="loginBtn" @click="login">确定绑定已有账号登录</div>
- <div class="register">还没有优软账号,直接<span @click="resgiter">创建新账号</span></div>
- <nuxt-link :to="'/'" class="mobile_footer company" tag="div">
- <div class="hr"></div>
- <img src="/images/mobile/@2x/wechat/logo.png" alt="">
- <div class="hr right"></div>
-
-
-
- </nuxt-link>
- </div>
- <remind-box :title="collectResult" :timeoutCount="timeoutCount"></remind-box>
- <div class="listAlert" ref="userContent" v-show="wechatInfo.enterprises">
- <ul>
- <li v-for="(item, index) in wechatInfo.enterprises" @click="clickItem(item)">
- {{item.enName}}
- </li>
- <li @click="clickItem({uu: 0})">
- <a>个人账户</a>
- </li>
- </ul>
- </div>
- </div>
- </template>
- <script>
- import { RemindBox } from '~components/mobile/common'
- import BScroll from 'better-scroll'
- export default {
- name: 'wechatView',
- layout: 'mobileNoHeader',
-
- data() {
- return {
- collectResult: '',
- timeoutCount: 0,
- telerror: false,
- telphoneNum: '',
- passwordNum: '',
- codeNum: '',
- bindShow: false,
- codeerror: false,
- showExtraTime: false,
- getExtraTime: 60,
- enuu: ''
- }
- },
- mounted() {
- let info = localStorage.getItem('USOFTMALLWECHATINFO')
- let _url = this.$route.query.url
-
- if (this.$route.query.url) {
- localStorage.setItem('RETURNURL', _url || '')
- }
- if (this.$route.query.enuu) {
- this.enuu = this.$route.query.enuu
- localStorage.setItem('Userenuu', this.enuu || '')
- }
- let ua = this.$store.state.option.userAgent.toLowerCase()
- if (ua.match(/micromessenger/i) && ua.match(/micromessenger/i)[0] === 'micromessenger' && !this.$route.query.code && !info) {
- window.location.href = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxb3274b676737a319&redirect_uri=https://mall.usoftchina.com/mobile/wechat&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect`
- } else if (info) {
-
- info = JSON.parse(info)
- if (info.openid) {
- this.$store.dispatch('GerWechatInfo', {code: '', openId: info.openid}).then(res => {
-
- this.enuu = localStorage.getItem('Userenuu')
- if (this.enuu) {
- this.loginFromEnuu()
- }
- })
- } else {
- localStorage.removeItem('USOFTMALLWECHATINFO')
- window.location.href = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxb3274b676737a319&redirect_uri=https://mall.usoftchina.com/mobile/wechat&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect`
- }
- } else {
-
-
- this.$store.dispatch('GerWechatInfo', {code: this.$route.query.code})
- }
- this.$nextTick(() => {
- if (this.BScroll) {
- this.BScroll.refresh()
- } else {
- this.BScroll = new BScroll(this.$refs.userContent, {
- click: true
- })
- }
- })
- },
- methods: {
-
- loginFromEnuu() {
- let _item = {}
- this.wechatInfo.enterprises.forEach((item) => {
- if (item.uu === parseInt(this.enuu)) {
- _item = item
- }
- })
- this.clickItem(_item)
- },
-
- clickItem(item) {
- let userAccount = this.baseUtils.deepCopy(this.$store.state.option.wechatInfo.data.userAccount)
- userAccount.spaceUU = item.uu
- this.$http.get('/newLogin/other', {params: userAccount}).then(res => {
- this.$store.dispatch('loadUserInfo').then(() => {
- let _url = localStorage.getItem('RETURNURL')
- let _uu = item.uu === 0 ? '' : item.uu
- this.$jsonp(`${process.env.ssoUrl}/sso/login/other?spaceUU=${_uu}&appId=mall&userUU=${userAccount.userUU}`, {timeout: 5000, name: 'successCallback'}, (err) => {
- console.log(err)
- })
- if (_url !== '') {
- localStorage.removeItem('RETURNURL')
- this.$router.replace(_url)
- } else if (this.$route.query.url && this.$route.query.url !== '') {
- this.$router.replace(this.$route.query.url)
- } else {
- this.goLastPage()
- }
- localStorage.removeItem('Userenuu')
- })
- })
- },
-
- telphoneBlur() {
- if (this.telphoneNum === '') { return }
- this.telerror = false
- if (!/^1[3|5|7|8]\d{9}$/.test(this.telphoneNum)) {
- this.telerror = true
- }
- },
-
- login() {
- let openid = this.$store.state.option.wechatInfo.data.openid
- if (this.telerror === true) {
- return false
- }
- if (!this.telphoneNum || this.telphoneNum === '') {
- this.collectResult = '手机号码不能为空'
- this.timeoutCount++
- return false
- }
-
- let _item = {
- userTel: this.telphoneNum,
- openId: openid
- }
- if (this.bindShow === true) {
- if (!this.codeNum || this.codeNum === '') {
- this.collectResult = '验证码不能为空'
- this.timeoutCount++
- return false
- }
- _item.code = this.codeNum
- } else {
- if (!this.passwordNum || this.passwordNum === '') {
- this.collectResult = '密码不能为空'
- this.timeoutCount++
- return false
- }
- _item.userPwd = this.passwordNum
- }
- this.$http.post('/wx/bindUser', _item).then(res => {
- if (res.data.success) {
- this.$store.commit('option/REQUEST_WECHATINFO_STATUS_SUCCESS', res.data)
- localStorage.setItem('USOFTMALLWECHATINFO', JSON.stringify(res.data))
- } else {
- localStorage.removeItem('USOFTMALLWECHATINFO')
- this.collectResult = res.data.message || res.data.errMsg
- this.timeoutCount++
- }
- }, err => {
- localStorage.removeItem('USOFTMALLWECHATINFO')
- this.collectResult = err.response.data || '绑定失败'
- this.timeoutCount++
- })
- },
- resgiter() {
- this.$http.get('/register/page').then(response => {
- if (response.data) {
- window.location.href = response.data.content
- }
- })
- },
-
- toInfoBind() {
- this.bindShow = true
- },
- getCode() {
- if (this.telerror) {
- return false
- }
- if (!this.telphoneNum || this.telphoneNum === '') {
- this.collectResult = '手机号码不能为空'
- this.timeoutCount++
- return false
- }
- if (this.showExtraTime) {
- this.collectResult = '获取验证码已发送,请查收'
- this.timeoutCount++
- return
- }
-
- this.$http.get(`/wx/sendSmsCode?mobile=${this.telphoneNum}`).then((data) => {
- if (data.data.success) {
- this.showExtraTime = true
- this.$timer = setInterval(() => {
- this.getExtraTime--
- if (this.getExtraTime === 0) {
- this.getExtraTime = 60
- this.showExtraTime = false
- clearInterval(this.$timer)
- }
- }, 1000)
- } else {
- this.collectResult = data.data.errMsg
- this.timeoutCount++
- }
- }, err => {
- this.collectResult = err.response.data || '获取失败'
- this.timeoutCount++
- })
- }
- },
- components: {
- RemindBox
- },
- computed: {
- userName() {
-
- return this.wechatInfo.nickname
- },
- headerImg() {
-
- return this.wechatInfo.headimgurl || '/images/mobile/@2x/wechat/header-img.png'
- },
- wechatInfo() {
- return this.$store.state.option.wechatInfo.data
- }
- }
- }
- </script>
- <style scoped lang="scss">
- .wechat-view {
- position: fixed;
- z-index: 999;
- width: 100%;
- left: 0;
- right: 0;
- top: 0;
- bottom: 0;
- background: #fff;
- .header-view {
- background: #376ef3;
- height: 4.26rem;
- width: 100%;
- position: relative;
- padding-top: 0.56rem;
- .hearder-kuang {
- background: rgba(0, 0, 0, 0.18);
- width: 1.86rem;
- height: 1.86rem;
- border-radius: 50%;
- margin: 0 auto;
- overflow: hidden;
- position: relative;
- .header-img {
- background: #fff;
- width: 1.6rem;
- height: 1.6rem;
- border-radius: 50%;
- overflow: hidden;
- text-align: center;
- position: absolute;
- left: 50%;
- top: 50%;
- margin: -0.8rem 0 0 -0.8rem;
- img {
- width: 1.6rem;
- height: 1.6rem;
- border-radius: 50%;
- vertical-align: center;
- }
- }
- }
- .header-name {
- font-size: 0.3rem;
- color: #fff;
- text-align: center;
- margin-top: 0.24rem;
- }
- .headerbg {
- position: absolute;
- width: 100%;
- height: 0.88rem;
- bottom: 0px;
- left: 0px;
- }
- }
- .middle-view {
- padding: 0 0.71rem;
- margin-top: 0.56rem;
- ul li {
- padding-bottom: 0.1rem;
- min-height: 0.4rem;
- &.wechat-view-info {
- color: #3872f4;
- font-size: 0.24rem;
- margin-left: 0.64rem;
- margin-top: 0.2rem;
- margin-bottom: 0.2rem;
- }
- input {
- margin-left: 0.34rem;
- color: #aaa;
- font-size: 0.3rem;
- height: 0.5rem;
- line-height: 0.5rem;
- border: 0;
- display: inline-block;
- vertical-align: top;
- }
- &.telphone {
- border-bottom: 1px solid #eee;
- &::before {
- background: url('/images/mobile/@2x/wechat/tel_icon.png');
- content: ' ';
- width: 0.28rem;
- height: 0.5rem;
- display: inline-block;
- background-size: 100% 100%;
- vertical-align: top;
- }
- input {
- margin-left: 0.4rem;
- }
- }
- &.password {
- border-bottom: 1px solid #eee;
- &::before {
- background: url('/images/mobile/@2x/wechat/pass_icon.png');
- content: ' ';
- width: 0.34rem;
- height: 0.42rem;
- display: inline-block;
- background-size: 100% 100%;
- vertical-align: top;
- }
- }
- &.code {
- border-bottom: 1px solid #eee;
- }
- &.toInfoBind {
- color: #3872f4;
- font-size: 0.28rem;
- text-align: right;
- margin-top: 0.2rem;
- margin-bottom: 0.2rem;
- }
- .codeBtn {
- font-size: 0.28rem;
- color: #376ef3;
- width: 1.8rem;
- height: 0.5rem;
- line-height: 0.5rem;
- border-radius: 0.04rem;
- border: 1px solid #376ef3;
- text-align: center;
- }
- }
- .loginBtn {
- width: 5.8rem;
- height: 0.9rem;
- line-height: 0.9rem;
- text-align: center;
- font-size: 0.3rem;
- color: #fff;
- background: #376ef3;
- border-radius: 5px;
- margin: 1rem auto 0;
- }
- .register {
- width: 5.8rem;
- text-align: left;
- font-size: 0.24rem;
- color: #999;
- margin: 0.25rem auto 0;
- span {
- color: #0076ff;
- font-size: 0.24rem;
- text-align: center;
- border: 1px solid #0076ff;
- border-radius: 5px;
- height:0.44rem;
- width: 1.48rem;
- margin-left: 0.2rem;
- }
- }
- .company {
- margin-top: 1.51rem;
- position: relative;
- text-align: center;
- img {
- width: 1.78rem;
- height: 0.39rem;
- margin-top: 0.24rem;
- }
- p {
- font-size: 0.21rem;
- color: #aaa;
- margin: 0.13rem 0 0 0;
- }
- a {
- margin-top: 0.12rem;
- font-size: 0.18rem;
- color: #bbb;
- }
- .hr {
- width: 1.62rem;
- height: 0.02rem;
- background: #e3e3e3;
- position: absolute;
- left: 0.3rem;
- top: 0.45rem;
- &.right {
- right: 0.3rem;
- left: auto;
- }
- }
- }
- }
- .listAlert {
- position: fixed;
- top: 0;
- left: 0;
- right: 0;
- bottom: 0;
- background: #fff;
- padding: 0 0.2rem;
- overflow: hidden;
- z-index: 10000;
- li {
- line-height: 0.98rem;
- height: 0.98rem;
- border-bottom: 1px solid #dedede;
- }
- }
- }
- </style>
|