Merge branch 'master' of http://git.excellentkk.cn/C.C/nk-shop2.0
This commit is contained in:
commit
8e76eb836c
@ -65,6 +65,15 @@ export function login(data) {
|
|||||||
noAuth: true
|
noAuth: true
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* 绑定小程序账号
|
||||||
|
* @param data object 小程序用户登陆信息
|
||||||
|
*/
|
||||||
|
export function bindMp(data) {
|
||||||
|
return request.post("auth/bindMp", data, {
|
||||||
|
noAuth: true
|
||||||
|
});
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* 分享
|
* 分享
|
||||||
* @returns {*}
|
* @returns {*}
|
||||||
|
@ -40,7 +40,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { commonAuth } from '@/api/public';
|
import { commonAuth, bindMp } from '@/api/public';
|
||||||
import { loginMobile, registerVerify, getSiteAPI } from '@/api/user'
|
import { loginMobile, registerVerify, getSiteAPI } from '@/api/user'
|
||||||
import { LOGO_URL, USER_INFO, EXPIRES_TIME } from '@/config/cache';
|
import { LOGO_URL, USER_INFO, EXPIRES_TIME } from '@/config/cache';
|
||||||
import Cache from '@/utils/cache';
|
import Cache from '@/utils/cache';
|
||||||
@ -196,6 +196,31 @@
|
|||||||
.then(({
|
.then(({
|
||||||
data
|
data
|
||||||
}) => {
|
}) => {
|
||||||
|
// #ifdef MP
|
||||||
|
//用户没有绑定openid,授权并绑定
|
||||||
|
if (data.user.wechat_user_id === 0) {
|
||||||
|
wx.getUserInfo({
|
||||||
|
success: function (res) {
|
||||||
|
const encryptedData = res.encryptedData
|
||||||
|
const iv = res.iv
|
||||||
|
wx.login({
|
||||||
|
success (res) {
|
||||||
|
if (res.code) {
|
||||||
|
bindMp({code: res.code, iv: iv, encryptedData: encryptedData}).then(res => {
|
||||||
|
// console.log(res);
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
console.log('登录失败!' + res.errMsg)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
fail(e) {
|
||||||
|
console.log('登录失败!' + res.errMsg)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
// #endif
|
||||||
console.log('验证码登录', data);
|
console.log('验证码登录', data);
|
||||||
let time = data.expires_time - Cache.time();
|
let time = data.expires_time - Cache.time();
|
||||||
const backUrl = that.$Cache.get(BACK_URL) || "/pages/home/index";
|
const backUrl = that.$Cache.get(BACK_URL) || "/pages/home/index";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user