Commit 6a9da170 authored by Facius's avatar Facius

Merge branch 'dev-photo-v2' of https://git.banshouhui.com/heyinchen/take_order into dev-photo-v2

parents 8beeb8ea de64a660
This diff is collapsed.
...@@ -288,6 +288,10 @@ ...@@ -288,6 +288,10 @@
"name": "照片预览", //模式名称 "name": "照片预览", //模式名称
"path": "pages/photo/preview", //启动页面,必选 "path": "pages/photo/preview", //启动页面,必选
"query": "standardId=1&img=https://papers.co/wallpaper/papers.co-bk57-art-illust-girl-pink-tomboy-red-6-wallpaper.jpg" //启动参数,在页面的onLoad函数里面得到 "query": "standardId=1&img=https://papers.co/wallpaper/papers.co-bk57-art-illust-girl-pink-tomboy-red-6-wallpaper.jpg" //启动参数,在页面的onLoad函数里面得到
},{
"name": "授权登录",
"path": "pages/login/wxlogin",
"query": ""
}] }]
} }
} }
This diff is collapsed.
...@@ -4,7 +4,7 @@ const app = getApp(); ...@@ -4,7 +4,7 @@ const app = getApp();
function appLogin() { function appLogin() {
return new Promise(function (resolve, reject) { return new Promise(function (resolve, reject) {
uni.login({ uni.login({
success: res => { success(res) {
if (!res.code) { if (!res.code) {
uni.hideLoading(); uni.hideLoading();
uni.showModal({ uni.showModal({
...@@ -17,7 +17,7 @@ function appLogin() { ...@@ -17,7 +17,7 @@ function appLogin() {
fail() { fail() {
uni.hideLoading(); uni.hideLoading();
uni.showModal({ uni.showModal({
content: '登录失败', content: '小程序登录失败',
showCancel: false showCancel: false
}); });
reject(); reject();
...@@ -28,51 +28,51 @@ function appLogin() { ...@@ -28,51 +28,51 @@ function appLogin() {
// 小程序授权 // 小程序授权
function authorization(data) { function authorization(data) {
return new Promise(function (resolve, reject) { return new Promise(async function (resolve, reject) {
data = data || {} const res = await app.$vm.$u.api.loginWechatAuth(data)
const res = await app.$u.api.loginWechatAuth(data) if (res) {
if (res && res.status) { if (res.code == 200 && res.data) {
let data = res.data app.setUserData(res.data)
app.setUserData(data)
uni.hideLoading();
resolve(res); resolve(res);
} else () { } else {
uni.hideLoading();
uni.showModal({ uni.showModal({
title: '请求失败', title: '用户登录失败',
content: err.message, content: res.message,
showCancel: false showCancel: false
}); });
reject(); reject(res);
}, }
} else {
uni.showModal({
title: '请求失败',
content: res.message
});
}
}); });
} }
// 小程序注册 // 小程序注册
function signup(data) { function signup(data) {
return new Promise(function (resolve, reject) { return new Promise(async function (resolve, reject) {
const res = await app.$u.api.loginWechatAuth(data) const res = await app.$vm.$u.api.loginWechatAuth(data)
if (res) {
api.request('login/signup-login', { if (res.code == 200 && res.data) {
method: "post", app.setUserData(res.data)
data: {
code: data.code,
encryptedData: data.encryptedData,
iv: data.iv
},
success: function (res) {
if (res && res.status) {
let data = res.data
app.setUserData(data)
resolve(res);
}else{
if(!res.status && res.message==='用户授权信息失效,请重新授权'){
api.setAuthToken('')
}
resolve(res); resolve(res);
} else {
uni.showModal({
title: '用户授权失败',
content: res.message,
showCancel: false
});
reject(res);
} }
} } else {
uni.showModal({
title: '请求失败',
content: res.message
}); });
}
}); });
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment