| | |
| | | <view class="login">
|
| | | <view class="login_title">欢迎登录</view>
|
| | | <view class="login_title login_title2">阜宁文体中心</view>
|
| | | <view v-if="devMockTip" class="dev-tip">{{ devMockTip }}</view>
|
| | | <view class="login_list">
|
| | | <view class="login_list_item">
|
| | | <image src="@/static/login_ic_phone@2x.png" mode="widthFix" />
|
| | |
| | |
|
| | | getRecordByUserPoint
|
| | | } from '@/api'
|
| | | import { devWechatMock } from '@/utils/config.js'
|
| | | import { runWechatOAuthFlow } from '@/utils/wechatAuth.js'
|
| | | import { requestLoginSmsCode } from '@/utils/loginSms.js'
|
| | | import {
|
| | | mapState,
|
| | | mapMutations
|
| | |
| | | },
|
| | | ywinfo: {},
|
| | | downTime: 0,
|
| | | code: ''
|
| | | code: '',
|
| | | devMockTip: devWechatMock.enabled ? `开发模式:模拟 openid ${devWechatMock.openId}` : ''
|
| | | }
|
| | | },
|
| | | onLoad(option) {
|
| | |
| | | }
|
| | | },
|
| | | onShow() {
|
| | | // return
|
| | | var that = this
|
| | | let url = window.location.href
|
| | | if (url.indexOf('code=') !== -1 || this.code) {
|
| | | let code = ''
|
| | | const query = url.split('?')
|
| | | for (const q of query) {
|
| | | if (q.indexOf('code=') !== -1) {
|
| | | let statusIndex = q.indexOf('&state')
|
| | | code = q.substring(q.indexOf('code=') + 5, statusIndex)
|
| | | }
|
| | | }
|
| | | ywWxAuthorize({
|
| | | code: code || this.code
|
| | | }).then(res => {
|
| | | if (res.code === 200) {
|
| | | // console.log('res', res);
|
| | | const that = this
|
| | | runWechatOAuthFlow({
|
| | | authorizeApi: ywWxAuthorize,
|
| | | fallbackCode: this.code,
|
| | | onSuccess: (res) => {
|
| | | if (res.data.openid) {
|
| | | that.$store.commit('setOpenId', res.data.openid)
|
| | | if (res.data.token && res.data.token != '') {
|
| | | that.$store.commit('setToken', res.data.token)
|
| | | getUserInfo().then(ress => {
|
| | | that.$store.commit('setUserInfo', ress.data)
|
| | | })
|
| | | const ywinfo = this.ywinfo
|
| | | if (ywinfo.ywid && (ywinfo.type || ywinfo.type == 0)) {
|
| | | getRecordByUserPoint({
|
| | | pointCode: ywinfo.ywid
|
| | | }).then(res => {
|
| | | if (res.data && res.data.id) {
|
| | | uni.redirectTo({
|
| | | url: "/pages/polling/point?id=" + res.data.id
|
| | | })
|
| | | } else {
|
| | | uni.redirectTo({
|
| | | url: "/pages/polling/empty?message=" + res.message
|
| | | })
|
| | | }
|
| | | })
|
| | | } else {
|
| | | setTimeout(() => {
|
| | | }
|
| | | if (res.data.token && res.data.token != '') {
|
| | | that.$store.commit('setToken', res.data.token)
|
| | | getUserInfo().then(ress => {
|
| | | that.$store.commit('setUserInfo', ress.data)
|
| | | })
|
| | | const ywinfo = this.ywinfo
|
| | | if (ywinfo.ywid && (ywinfo.type || ywinfo.type == 0)) {
|
| | | getRecordByUserPoint({
|
| | | pointCode: ywinfo.ywid
|
| | | }).then(res => {
|
| | | if (res.data && res.data.id) {
|
| | | uni.redirectTo({
|
| | | url: "/pages/index"
|
| | | url: "/pages/polling/point?id=" + res.data.id
|
| | | })
|
| | | }, 300)
|
| | | }
|
| | | } else {
|
| | | uni.redirectTo({
|
| | | url: "/pages/polling/empty?message=" + res.message
|
| | | })
|
| | | }
|
| | | })
|
| | | } else {
|
| | | setTimeout(() => {
|
| | | uni.redirectTo({
|
| | | url: "/pages/index"
|
| | | })
|
| | | }, 300)
|
| | | }
|
| | | }
|
| | | })
|
| | | } else {
|
| | | let url = 'https://zhcg.fnwtzx.com/fn_h5'
|
| | | // const appID = 'wx95ac1efb67f0330d'
|
| | | //let url = 'https://dmtest.ahapp.net/yunwei_h5'
|
| | | const appID = 'wx15dfdae9a19177f3'
|
| | | let uri = encodeURIComponent(url)
|
| | | let authURL =
|
| | | `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appID}&redirect_uri=${uri}&response_type=code&scope=snsapi_base#wechat_redirect`
|
| | | window.location.href = authURL
|
| | | }
|
| | |
|
| | | }
|
| | | })
|
| | | },
|
| | | methods: {
|
| | | ...mapMutations(["setToken", "setUserInfo"]),
|
| | |
| | |
|
| | | },
|
| | | sendSms() {
|
| | | this.downTime = 60
|
| | | let timer = setInterval(() => {
|
| | | if (this.downTime == 0) return clearInterval(timer)
|
| | | this.downTime = this.downTime - 1
|
| | | }, 1000)
|
| | | const {
|
| | | form
|
| | | } = this
|
| | | sendSMsPost({
|
| | | phone: form.phone,
|
| | | type: 0
|
| | | }).then(res => {
|
| | | this.showToast('短信发送成功')
|
| | | })
|
| | | requestLoginSmsCode(this, this.form.phone, sendSMsPost, { phone: this.form.phone, userType: 0 })
|
| | | },
|
| | | }
|
| | | }
|
| | |
| | |
|
| | | .login_title2 {
|
| | | margin-top: 10rpx;
|
| | | margin-bottom: 80rpx;
|
| | | margin-bottom: 40rpx;
|
| | | }
|
| | |
|
| | | .dev-tip {
|
| | | width: 100%;
|
| | | padding: 0 60rpx;
|
| | | box-sizing: border-box;
|
| | | font-size: 24rpx;
|
| | | color: #e6a23c;
|
| | | margin-bottom: 40rpx;
|
| | | line-height: 1.5;
|
| | | }
|
| | |
|
| | | .login_list {
|