Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
take_order
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
和慭琛
take_order
Commits
6a9da170
Commit
6a9da170
authored
Mar 30, 2021
by
Facius
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev-photo-v2' of
https://git.banshouhui.com/heyinchen/take_order
into dev-photo-v2
parents
8beeb8ea
de64a660
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
767 additions
and
835 deletions
+767
-835
App.vue
take-order/App.vue
+352
-372
pages.json
take-order/pages.json
+6
-2
wxlogin.vue
take-order/pages/login/wxlogin.vue
+368
-420
login.js
take-order/utils/login.js
+41
-41
No files found.
take-order/App.vue
View file @
6a9da170
<
style
lang=
"scss"
>
<
style
lang=
"scss"
>
@import
'@/common/index.scss'
;
@import
'@/common/index.scss'
;
@import
'uview-ui/index.scss'
;
@import
'uview-ui/index.scss'
;
</
style
>
</
style
>
<
script
>
<
script
>
import
{
import
{
AnalysysAgent
AnalysysAgent
}
from
'@/utils/analysys_paas.js'
}
from
'@/utils/analysys_paas.js'
import
util
from
'@/utils/util.js'
import
util
from
'@/utils/util.js'
export
default
{
export
default
{
globalData
:
{
globalData
:
{
//https://system.banshouhui.com
//https://system.banshouhui.com
//https://system.dev.banshouhui.com
//https://system.dev.banshouhui.com
//正式环境
//正式环境
//domain_Name: 'https://system.banshouhui.com',
//domain_Name: 'https://system.banshouhui.com',
//测试环境
//测试环境
domain_Name
:
'https://system.banshouhui.com'
,
domain_Name
:
'https://system.banshouhui.com'
,
//http://192.168.0.208:8192
//http://192.168.0.208:8192
//小青本地环境
//小青本地环境
//domain_Name: 'http://192.168.0.208:37080',
//domain_Name: 'http://192.168.0.208:37080',
token
:
''
,
token
:
''
,
//RTOKEN45f41a3053238cb72b3b72fe14df8d7040c9f502
//RTOKEN45f41a3053238cb72b3b72fe14df8d7040c9f502
//定位 图标
//定位 图标
icon_location
:
'https://qn-static.banshouhui.com/take_order/icon/location.png'
,
icon_location
:
'https://qn-static.banshouhui.com/take_order/icon/location.png'
,
//首页提示 图标
//首页提示 图标
icon_index_notice
:
'https://qn-static.banshouhui.com/index_notice.png'
,
icon_index_notice
:
'https://qn-static.banshouhui.com/index_notice.png'
,
//授权提示 图标
//授权提示 图标
icon_auth_notice
:
'https://qn-static.banshouhui.com/auth_notice.png'
,
icon_auth_notice
:
'https://qn-static.banshouhui.com/auth_notice.png'
,
//勾选确认 图标
//勾选确认 图标
icon_agree_yes
:
'https://qn-static.banshouhui.com/agree_yes.png'
,
icon_agree_yes
:
'https://qn-static.banshouhui.com/agree_yes.png'
,
//勾选取消 图标
//勾选取消 图标
icon_agrss_no
:
'https://qn-static.banshouhui.com/agree_no.png'
,
icon_agrss_no
:
'https://qn-static.banshouhui.com/agree_no.png'
,
//无数据 图标
//无数据 图标
icon_noData
:
'https://qn-static.banshouhui.com/empty.png'
,
icon_noData
:
'https://qn-static.banshouhui.com/empty.png'
,
//抢单 图标
//抢单 图标
icon_rob
:
'https://qn-static.banshouhui.com/take_order/icon/rob.png'
,
icon_rob
:
'https://qn-static.banshouhui.com/take_order/icon/rob.png'
,
//右箭头 图标
//右箭头 图标
icon_arrow_right
:
'https://qn-static.banshouhui.com/arrow_right.png'
,
icon_arrow_right
:
'https://qn-static.banshouhui.com/arrow_right.png'
,
//照片添加 图标
//照片添加 图标
icon_photo_add
:
'https://qn-static.banshouhui.com/take_order/icon/photo_add.png'
,
icon_photo_add
:
'https://qn-static.banshouhui.com/take_order/icon/photo_add.png'
,
//关闭 图标
//关闭 图标
icon_close
:
'https://qn-static.banshouhui.com/close.png'
,
icon_close
:
'https://qn-static.banshouhui.com/close.png'
,
//顶部 图标
//顶部 图标
icon_top
:
'https://qn-static.banshouhui.com/topIcon.png'
,
icon_top
:
'https://qn-static.banshouhui.com/topIcon.png'
,
//我的 图标
//我的 图标
icon_mine
:
'https://qn-static.banshouhui.com/mine.png'
,
icon_mine
:
'https://qn-static.banshouhui.com/mine.png'
,
//三角形向下 图标
//三角形向下 图标
icon_trangle_down
:
'https://qn-static.banshouhui.com/trangle_down.png'
,
icon_trangle_down
:
'https://qn-static.banshouhui.com/trangle_down.png'
,
//i 图标
//i 图标
icon_i
:
'https://qn-static.banshouhui.com/i.png'
,
icon_i
:
'https://qn-static.banshouhui.com/i.png'
,
//客服 图片
//客服 图片
icon_customer_service
:
'https://qn-static.banshouhui.com/customer-service.png'
,
icon_customer_service
:
'https://qn-static.banshouhui.com/customer-service.png'
,
//三角形向上 图标
//三角形向上 图标
icon_trangle_up
:
'https://qn-static.banshouhui.com/trangle_up.png'
,
icon_trangle_up
:
'https://qn-static.banshouhui.com/trangle_up.png'
,
//勾选 图标
//勾选 图标
icon_selected
:
'https://qn-static.banshouhui.com/selected.png'
,
icon_selected
:
'https://qn-static.banshouhui.com/selected.png'
,
//关闭新 图标
//关闭新 图标
icon_close_new
:
'https://qn-static.banshouhui.com/close_new.png'
,
icon_close_new
:
'https://qn-static.banshouhui.com/close_new.png'
,
//授权提示新 图标
//授权提示新 图标
icon_auth_notice_new
:
'https://qn-static.banshouhui.com/auth_notice_new.png'
,
icon_auth_notice_new
:
'https://qn-static.banshouhui.com/auth_notice_new.png'
,
//登录注册页--
//登录注册页--
//通过code获取用户信息(登录)
//通过code获取用户信息(登录)
getUsersByCode
:
'/wxh-support-rest/rest/ssoinfo/v3/getUsersByCode'
,
getUsersByCode
:
'/wxh-support-rest/rest/ssoinfo/v3/getUsersByCode'
,
//通过手机号获取用户信息(注册并登录)
//通过手机号获取用户信息(注册并登录)
findByMobile
:
'/wxh-support-rest/rest/ssoinfo/v3/findByMobile'
,
findByMobile
:
'/wxh-support-rest/rest/ssoinfo/v3/findByMobile'
,
//下单模块--
//下单模块--
//立即下单
//立即下单
createAppletsOrder
:
''
,
createAppletsOrder
:
''
,
//下单列表
//下单列表
createOrderList
:
''
,
createOrderList
:
''
,
//接单模块--
//接单模块--
//抢单广场
//抢单广场
grabbing
:
''
,
grabbing
:
''
,
//检查抢单用户状态
//检查抢单用户状态
checkRobStatus
:
''
,
checkRobStatus
:
''
,
///wxh-worker-rest/rest/order/revision/applets/{token}/order/check
///wxh-worker-rest/rest/order/revision/applets/{token}/order/check
//工单列表
//工单列表
workOrderList
:
''
,
workOrderList
:
''
,
//工单详情
//工单详情
workOrderDetail
:
''
,
workOrderDetail
:
''
,
//预约 V2
//预约 V2
orderReserve
:
''
,
orderReserve
:
''
,
//工单完工
//工单完工
configCompletion
:
''
,
configCompletion
:
''
,
protocolContent
:
''
,
protocolContent
:
''
,
signUrl
:
''
,
signUrl
:
''
,
jumpLoginStatus
:
true
,
jumpLoginStatus
:
true
,
settleRecommend
:
''
,
settleRecommend
:
''
,
navHeight
:
0
,
//导航栏高度
navHeight
:
0
,
//导航栏高度
rpxScreenHeight
:
0
,
// 照相视框高度
rpxScreenHeight
:
0
,
// 照相视框高度
//拍照相关数据
//拍照相关数据
photo
:{
photo
:
{
product
:{
product
:
{
brandId
:
''
,
// 品牌id
brandId
:
''
,
// 品牌id
brandName
:
''
,
// 品牌名称
brandName
:
''
,
// 品牌名称
classifyId
:
''
,
// 分类id
classifyId
:
''
,
// 分类id
systemId
:
''
,
// 系统id
systemId
:
''
,
// 系统id
},
currentItemLength
:
0
,
//已拍摄照片张数
productList
:[],
currentItem
:
null
,
// 选择的某一项
setting
:
null
,
//自定义设置
waterSetting
:
null
,
// 水印设置
tempPath
:{
origin
:
''
,
// 缓存拍照图片
mixWater
:
''
// 缓存水印拍照图片
}
},
},
// 用户信息
currentItemLength
:
0
,
//已拍摄照片张数
tempUserInfo
:
''
,
// 临时用户选项
productList
:
[],
userInfo
:
''
,
// 用户信息
currentItem
:
null
,
// 选择的某一项
authLoading
:
false
,
setting
:
null
,
//自定义设置
},
waterSetting
:
null
,
// 水印设置
tempPath
:
{
onLaunch
:
function
()
{
origin
:
''
,
// 缓存拍照图片
this
.
getSystemInfo
()
mixWater
:
''
// 缓存水印拍照图片
this
.
checkUpdate
()
}
var
that
=
this
that
.
globalData
.
token
=
util
.
getToken
()
console
.
log
(
that
.
globalData
.
token
,
'that.globalData.token'
)
that
.
initAPIneedToken
()
// uni.getStorage({
// key: 'token',
// success: function (res) {
// that.globalData.token = res.data
// that.initAPIneedToken()
// }
// })
this
.
getProtocolContent
()
AnalysysAgent
.
registerSuperProperty
(
"platform"
,
"take-order"
);
},
},
onShow
:
function
()
{
// 用户信息
if
(
this
.
globalData
.
token
)
{
tempUserInfo
:
''
,
// 临时用户选项
this
.
globalData
.
authLoading
=
false
},
}
else
{
this
.
autoLogin
()
onLaunch
:
function
()
{
this
.
getSystemInfo
()
this
.
checkUpdate
()
var
that
=
this
that
.
globalData
.
token
=
util
.
getToken
()
console
.
log
(
that
.
globalData
.
token
,
'that.globalData.token'
)
that
.
initAPIneedToken
()
// uni.getStorage({
// key: 'token',
// success: function (res) {
// that.globalData.token = res.data
// that.initAPIneedToken()
// }
// })
this
.
getProtocolContent
()
AnalysysAgent
.
registerSuperProperty
(
"platform"
,
"take-order"
);
},
onShow
:
function
()
{
if
(
!
this
.
globalData
.
token
)
{
this
.
autoLogin
()
}
},
methods
:
{
getSystemInfo
()
{
try
{
let
a
=
wx
.
getSystemInfoSync
();
// this.globalData.platform = systemInfo.platform, this.globalData.pixelRatio = a.pixelRatio,
// this.globalData.statusBarHeight = a.statusBarHeight, this.globalData.navHeight = a.statusBarHeight / a.screenWidth * 750 + 90,
// this.globalData.rpxScreenHeight = a.screenHeight / a.screenWidth * 750, this.globalData.screenWidth = a.screenWidth,
// this.globalData.screenHeight = a.screenHeight;
this
.
globalData
.
navHeight
=
a
.
statusBarHeight
/
a
.
screenWidth
*
750
+
90
this
.
globalData
.
rpxScreenHeight
=
a
.
screenHeight
/
a
.
screenWidth
*
750
this
.
globalData
.
screenHeight
=
a
.
screenHeight
}
catch
(
a
)
{
}
}
},
},
methods
:
{
//检查更新
getSystemInfo
(){
checkUpdate
:
function
()
{
try
{
const
updateManager
=
wx
.
getUpdateManager
()
let
a
=
wx
.
getSystemInfoSync
();
updateManager
.
onCheckForUpdate
(
function
(
res
)
{
// this.globalData.platform = systemInfo.platform, this.globalData.pixelRatio = a.pixelRatio,
// 请求完新版本信息的回调
// this.globalData.statusBarHeight = a.statusBarHeight, this.globalData.navHeight = a.statusBarHeight / a.screenWidth * 750 + 90,
console
.
log
(
res
.
hasUpdate
)
// this.globalData.rpxScreenHeight = a.screenHeight / a.screenWidth * 750, this.globalData.screenWidth = a.screenWidth,
})
// this.globalData.screenHeight = a.screenHeight;
this
.
globalData
.
navHeight
=
a
.
statusBarHeight
/
a
.
screenWidth
*
750
+
90
updateManager
.
onUpdateReady
(
function
()
{
this
.
globalData
.
rpxScreenHeight
=
a
.
screenHeight
/
a
.
screenWidth
*
750
wx
.
showModal
({
this
.
globalData
.
screenHeight
=
a
.
screenHeight
title
:
'更新提示'
,
}
catch
(
a
)
{}
content
:
'新版本已经准备好,是否重启应用?'
,
},
success
(
res
)
{
//检查更新
if
(
res
.
confirm
)
{
checkUpdate
:
function
()
{
// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
const
updateManager
=
wx
.
getUpdateManager
()
updateManager
.
applyUpdate
()
}
updateManager
.
onCheckForUpdate
(
function
(
res
)
{
}
// 请求完新版本信息的回调
console
.
log
(
res
.
hasUpdate
)
})
updateManager
.
onUpdateReady
(
function
()
{
wx
.
showModal
({
title
:
'更新提示'
,
content
:
'新版本已经准备好,是否重启应用?'
,
success
(
res
)
{
if
(
res
.
confirm
)
{
// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
updateManager
.
applyUpdate
()
}
}
})
})
updateManager
.
onUpdateFailed
(
function
()
{
// 新版本下载失败
})
})
},
})
async
getBaseInfo
(
vm
,
callBack
){
updateManager
.
onUpdateFailed
(
function
()
{
uni
.
showLoading
({
// 新版本下载失败
title
:
'加载中……'
})
})
},
const
res
=
await
vm
.
$u
.
api
.
getSettleBaseInfo
()
if
(
!
res
||
!
res
.
status
)
{
async
getBaseInfo
(
vm
,
callBack
)
{
if
(
res
&&
res
.
message
){
uni
.
showLoading
({
title
:
'加载中……'
})
const
res
=
await
vm
.
$u
.
api
.
getSettleBaseInfo
()
if
(
!
res
||
!
res
.
status
)
{
if
(
res
&&
res
.
message
)
{
uni
.
showToast
({
uni
.
showToast
({
title
:
res
&&
res
.
message
||
'获取基本信息错误'
,
title
:
res
&&
res
.
message
||
'获取基本信息错误'
,
icon
:
'none'
icon
:
'none'
});
});
}
}
return
false
;
return
false
;
}
}
this
.
globalData
.
settledInfo
=
res
.
data
this
.
globalData
.
settledInfo
=
res
.
data
if
(
!
res
.
data
)
{
if
(
!
res
.
data
)
{
return
return
}
}
callBack
(
vm
,
res
.
data
)
callBack
(
vm
,
res
.
data
)
uni
.
hideLoading
()
uni
.
hideLoading
()
return
res
.
data
return
res
.
data
},
},
initAPIneedToken
:
function
()
{
initAPIneedToken
:
function
()
{
//RTOKEN45f41a3053238cb72b3b72fe14df8d7040c9f502
//RTOKEN45f41a3053238cb72b3b72fe14df8d7040c9f502
///*
///*
if
(
this
.
globalData
.
token
)
{
if
(
this
.
globalData
.
token
)
{
//console.log('initAPIneedToken')
//console.log('initAPIneedToken')
//下单模块--
//下单模块--
//立即下单
//立即下单
this
.
globalData
.
createAppletsOrder
=
'/wxh-worker-rest/rest/order/revision/applets/'
this
.
globalData
.
createAppletsOrder
=
'/wxh-worker-rest/rest/order/revision/applets/'
+
this
.
globalData
.
token
+
'/order/createAppletsOrder'
,
+
this
.
globalData
.
token
+
'/order/createAppletsOrder'
,
//console.log('立即下单'+this.globalData.createAppletsOrder)
//console.log('立即下单'+this.globalData.createAppletsOrder)
//下单列表
//下单列表
this
.
globalData
.
createOrderList
=
'/wxh-worker-rest/rest/order/revision/applets/'
this
.
globalData
.
createOrderList
=
'/wxh-worker-rest/rest/order/revision/applets/'
+
this
.
globalData
.
token
+
'/order/customer'
+
this
.
globalData
.
token
+
'/order/customer'
//console.log('下单列表'+this.globalData.createOrderList)
//console.log('下单列表'+this.globalData.createOrderList)
//接单模块--
//接单模块--
//抢单广场
//抢单广场
this
.
globalData
.
grabbing
=
'/wxh-worker-rest/rest/order/revision/applets/'
this
.
globalData
.
grabbing
=
'/wxh-worker-rest/rest/order/revision/applets/'
+
this
.
globalData
.
token
+
'/order/grabbing'
+
this
.
globalData
.
token
+
'/order/grabbing'
//console.log('抢单广场'+this.globalData.grabbing)
//console.log('抢单广场'+this.globalData.grabbing)
//检查抢单用户状态
//检查抢单用户状态
this
.
globalData
.
checkRobStatus
=
'/wxh-worker-rest/rest/order/revision/applets/'
this
.
globalData
.
checkRobStatus
=
'/wxh-worker-rest/rest/order/revision/applets/'
+
this
.
globalData
.
token
+
'/order/check'
,
+
this
.
globalData
.
token
+
'/order/check'
,
//console.log('检查抢单用户状态'+this.globalData.checkRobStatus)
//console.log('检查抢单用户状态'+this.globalData.checkRobStatus)
//工单列表
//工单列表
this
.
globalData
.
workOrderList
=
'/wxh-worker-rest/rest/order/revision/applets/'
this
.
globalData
.
workOrderList
=
'/wxh-worker-rest/rest/order/revision/applets/'
+
this
.
globalData
.
token
+
'/order/worker'
,
+
this
.
globalData
.
token
+
'/order/worker'
,
//console.log('工单列表'+this.globalData.workOrderList)
//console.log('工单列表'+this.globalData.workOrderList)
//工单详情
//工单详情
this
.
globalData
.
workOrderDetail
=
'/wxh-worker-rest/rest/order/revision/applets/'
this
.
globalData
.
workOrderDetail
=
'/wxh-worker-rest/rest/order/revision/applets/'
+
this
.
globalData
.
token
+
'/order/detail'
,
+
this
.
globalData
.
token
+
'/order/detail'
,
//console.log('工单详情'+this.globalData.workOrderDetail)
//console.log('工单详情'+this.globalData.workOrderDetail)
//预约 V2
//预约 V2
this
.
globalData
.
orderReserve
=
'/wxh-worker-rest/rest/project/order/reserve/'
this
.
globalData
.
orderReserve
=
'/wxh-worker-rest/rest/project/order/reserve/'
+
this
.
globalData
.
token
,
+
this
.
globalData
.
token
,
//console.log('预约 V2'+this.globalData.orderReserve)
//console.log('预约 V2'+this.globalData.orderReserve)
//工单完工
//工单完工
this
.
globalData
.
configCompletion
=
''
this
.
globalData
.
configCompletion
=
''
///wxh-worker-rest/rest/config/RTOKEN222bdab78b0d2a74f159b640df53180772813250/completion/11885887?inGuaranteePeriod=true
///wxh-worker-rest/rest/config/RTOKEN222bdab78b0d2a74f159b640df53180772813250/completion/11885887?inGuaranteePeriod=true
}
}
//*/
//*/
},
},
getProtocolContent
:
function
()
{
getProtocolContent
:
function
()
{
this
.
protocolContent
this
.
protocolContent
},
},
/* ------------------------- 数据埋点begin ------------------------------ */
/* ------------------------- 数据埋点begin ------------------------------ */
track
(
event
,
properties
)
{
track
(
event
,
properties
)
{
if
(
AnalysysAgent
)
{
if
(
AnalysysAgent
)
{
// 易观添加事件
// 易观添加事件
let
AnalysysAgent
=
wx
.
AnalysysAgent
;
let
AnalysysAgent
=
wx
.
AnalysysAgent
;
AnalysysAgent
.
track
(
"take_order_"
+
event
,
properties
);
AnalysysAgent
.
track
(
"take_order_"
+
event
,
properties
);
}
}
},
},
identify
(
userInfo
,
openid
,
unionid
=
null
)
{
identify
(
userInfo
,
openid
,
unionid
=
null
)
{
// 设备身份表示
// 设备身份表示
if
(
AnalysysAgent
)
{
if
(
AnalysysAgent
)
{
let
setProfile
=
{
let
setProfile
=
{
'openid'
:
openid
,
'openid'
:
openid
,
'unionid'
:
unionid
,
'unionid'
:
unionid
,
}
setProfile
=
Object
.
assign
(
setProfile
,
userInfo
)
AnalysysAgent
.
profileSet
(
setProfile
);
}
},
setUserId
(
userId
)
{
// 用户id设置
if
(
AnalysysAgent
)
{
AnalysysAgent
.
alias
(
userId
+
''
)
}
},
setUser
(
user
)
{
// 用户附加属性
if
(
AnalysysAgent
)
{
let
userInfo
=
{
'mobile'
:
user
.
mobile
,
'userfrom_id'
:
user
.
uid
,
'userfrom'
:
'家维广场'
,
'avatar'
:
user
.
avatar
,
'nickname'
:
user
.
nickname
,
'username'
:
user
.
username
,
'wxhuid'
:
user
.
wxhuid
,
'id'
:
user
.
id
,
'money'
:
user
.
money
,
'score'
:
user
.
score
};
Object
.
keys
(
userInfo
).
map
(
key
=>
{
if
(
key
&&
userInfo
[
key
]){
AnalysysAgent
.
profileAppend
(
key
,
userInfo
[
key
])
}
})
}
},
share
(
toShareProperties
,
trackProperties
)
{
if
(
AnalysysAgent
)
{
AnalysysAgent
.
share
(
toShareProperties
,
trackProperties
);
}
},
trackPage
(
pageName
,
properties
){
if
(
AnalysysAgent
)
{
AnalysysAgent
.
pageView
(
pageName
,
properties
);
}
}
},
setProfile
=
Object
.
assign
(
setProfile
,
userInfo
)
initShare
(
option
){
AnalysysAgent
.
profileSet
(
setProfile
);
console
.
log
(
option
,
'option-initShare'
)
}
option
=
option
||
{}
},
if
(
AnalysysAgent
&&
option
.
user_id
)
{
setUserId
(
userId
)
{
let
shareUserInfo
=
{
// 用户id设置
'share_from_id'
:
option
.
user_id
||
''
,
if
(
AnalysysAgent
)
{
'share_from_nickname'
:
option
.
user_name
||
''
,
AnalysysAgent
.
alias
(
userId
+
''
)
}
},
setUser
(
user
)
{
// 用户附加属性
if
(
AnalysysAgent
)
{
let
userInfo
=
{
'mobile'
:
user
.
mobile
,
'userfrom_id'
:
user
.
uid
,
'userfrom'
:
'家维广场'
,
'avatar'
:
user
.
avatar
,
'nickname'
:
user
.
nickname
,
'username'
:
user
.
username
,
'wxhuid'
:
user
.
wxhuid
,
'id'
:
user
.
id
,
'money'
:
user
.
money
,
'score'
:
user
.
score
};
Object
.
keys
(
userInfo
).
map
(
key
=>
{
if
(
key
&&
userInfo
[
key
])
{
AnalysysAgent
.
profileAppend
(
key
,
userInfo
[
key
])
}
}
AnalysysAgent
.
registerSuperProperties
(
shareUserInfo
);
})
}
},
share
(
toShareProperties
,
trackProperties
)
{
if
(
AnalysysAgent
)
{
AnalysysAgent
.
share
(
toShareProperties
,
trackProperties
);
}
},
trackPage
(
pageName
,
properties
)
{
if
(
AnalysysAgent
)
{
AnalysysAgent
.
pageView
(
pageName
,
properties
);
}
},
initShare
(
option
)
{
console
.
log
(
option
,
'option-initShare'
)
option
=
option
||
{}
if
(
AnalysysAgent
&&
option
.
user_id
)
{
let
shareUserInfo
=
{
'share_from_id'
:
option
.
user_id
||
''
,
'share_from_nickname'
:
option
.
user_name
||
''
,
}
}
},
AnalysysAgent
.
registerSuperProperties
(
shareUserInfo
);
/* ------------------------- 数据埋点end ------------------------------ */
}
},
/**
/* ------------------------- 数据埋点end ------------------------------ */
* 用户自动登录
*/
/**
autoLogin
()
{
* 用户自动登录
let
that
=
this
;
*/
that
.
globalData
.
authLoading
=
true
autoLogin
()
{
uni
.
login
({
let
that
=
this
success
(
res
)
{
uni
.
login
({
if
(
res
.
code
)
{
async
success
(
res
)
{
let
params
=
{
code
:
res
.
code
};
if
(
res
.
code
)
{
that
.
authorization
(
params
)
let
result
=
await
that
.
$u
.
api
.
loginWechatAuth
({
code
:
res
.
code
})
if
(
result
)
{
if
(
result
.
code
==
200
&&
result
.
data
)
{
that
.
setUserData
(
result
.
data
)
}
}
else
{
}
else
{
uni
.
showModal
({
uni
.
showModal
({
title
:
'登录失败'
,
title
:
'请求失败'
,
content
:
'未获取到code'
,
content
:
result
.
message
,
showCancel
:
false
});
});
}
}
},
uni
.
hideLoading
()
fail
()
{
}
else
{
wx
.
showModal
({
uni
.
showModal
({
title
:
'登录失败'
,
title
:
'登录失败'
,
content
:
'
接口调用失败
'
,
content
:
'
未获取到code
'
,
});
});
}
}
});
},
},
fail
()
{
async
authorization
(
params
)
{
let
that
=
this
const
res
=
await
that
.
$u
.
api
.
loginWechatAuth
(
params
)
if
(
!
res
||
!
res
.
code
||
!
res
.
data
){
uni
.
hideLoading
()
return
}
else
if
(
res
.
code
==
200
)
{
that
.
setUserData
(
res
.
data
)
if
(
typeof
callback
==
"function"
)
{
callback
();
}
}
else
{
wx
.
showModal
({
title
:
'请求失败'
,
showCancel
:
false
});
}
that
.
globalData
.
authLoading
=
false
uni
.
hideLoading
()
},
setUserData
(
userInfo
)
{
if
(
userInfo
&&
userInfo
.
token
)
{
// 如果已经登录则直接获取相关信息
util
.
setOpenid
(
userInfo
.
wxopenid
)
util
.
setToken
(
userInfo
.
token
)
this
.
globalData
.
userInfo
=
userInfo
;
uni
.
setStorageSync
(
'user-info'
,
userInfo
);
uni
.
setStorageSync
(
'isNewUser'
,
false
);
}
else
{
uni
.
setStorageSync
(
'isNewUser'
,
true
);
}
}
}
,
}
);
},
},
setUserData
(
userInfo
)
{
if
(
userInfo
&&
userInfo
.
token
)
{
onHide
:
function
()
{
// 如果已经登录则直接获取相关信息
console
.
log
(
'App Hide'
)
util
.
setOpenid
(
userInfo
.
wxopenid
)
util
.
setToken
(
userInfo
.
token
)
uni
.
setStorageSync
(
'user-info'
,
userInfo
);
}
else
{
util
.
setToken
(
''
)
}
},
},
},
}
onHide
:
function
()
{
console
.
log
(
'App Hide'
)
},
}
</
script
>
</
script
>
<
style
>
<
style
>
/*每个页面公共css */
/*每个页面公共css */
</
style
>
</
style
>
take-order/pages.json
View file @
6a9da170
...
@@ -124,8 +124,8 @@
...
@@ -124,8 +124,8 @@
{
{
"path"
:
"pages/photo/setting"
,
"path"
:
"pages/photo/setting"
,
"style"
:
{
"style"
:
{
"navigationBarTitleText"
:
"水印设置"
,
"navigationBarTitleText"
:
"水印设置"
,
"navigationBarBackgroundColor"
:
"#FFFFFF"
,
"navigationBarBackgroundColor"
:
"#FFFFFF"
,
"backgroundColor"
:
"#F4F5F7"
"backgroundColor"
:
"#F4F5F7"
//
"navigationBarBackgroundColor"
:
"#333333"
,
//
"navigationBarBackgroundColor"
:
"#333333"
,
//
"navigationBarTextStyle"
:
"#FFFFFF"
,
//
"navigationBarTextStyle"
:
"#FFFFFF"
,
...
@@ -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"
:
""
}]
}]
}
}
}
}
take-order/pages/login/wxlogin.vue
View file @
6a9da170
...
@@ -5,15 +5,19 @@
...
@@ -5,15 +5,19 @@
<image
class=
"noticeImage"
:src=
"icon_auth_notice_new"
mode=
""
></image>
<image
class=
"noticeImage"
:src=
"icon_auth_notice_new"
mode=
""
></image>
</view>
</view>
<view
class=
"noticeTitleView"
>
<view
class=
"noticeTitleView"
>
<text
class=
"noticeTitle"
>
{{
noticeTitle
}}
</text>
<text
class=
"noticeTitle"
>
{{
noticeTitle
}}
</text>
</view>
</view>
<button
class=
"loginBtn"
v-if=
"!isNewUser"
lang=
"zh_CN"
catchtap=
"getUserProfile"
>
<text
class=
"u-font-32 white"
>
立即登录
</text>
</button>
<!--
<button
class=
"loginBtn"
v-if=
"!isNewUser"
open-type=
"getUserInfo"
lang=
"zh_CN"
@
getuserinfo=
"getUserInfo"
>
<!--
<button
class=
"loginBtn"
v-if=
"!isNewUser"
open-type=
"getUserInfo"
lang=
"zh_CN"
@
getuserinfo=
"getUserInfo"
>
<text
class=
"u-font-32 white"
>
立即登录
</text>
</button>
-->
<button
class=
"loginBtn"
v-if=
"needAuth"
lang=
"zh_CN"
@
tap=
"getUserProfile"
>
<text
class=
"u-font-32 white"
>
立即登录
</text>
<text
class=
"u-font-32 white"
>
立即登录
</text>
</button>
<!--
<button
class=
"loginBtn"
v-if=
"isNewUser"
open-type=
"getPhoneNumber"
throttle-time=
"1000"
@
getphonenumber=
"getPhoneNumber"
>
<text
class=
"u-font-32 white"
>
授权登录
</text>
</button>
-->
</button>
-->
<button
class=
"loginBtn"
v-if=
"isNewUser"
open-type=
"getPhoneNumber"
throttle-time=
"1000"
@
getphonenumber=
"getPhoneNumber"
>
<button
class=
"loginBtn"
v-else
open-type=
"getPhoneNumber"
throttle-time=
"1000"
@
getphonenumber=
"signupLogin"
>
<text
class=
"u-font-32 white"
>
授权登录
</text>
<text
class=
"u-font-32 white"
>
授权登录
</text>
</button>
</button>
<view
class=
"cancelView"
>
<view
class=
"cancelView"
>
...
@@ -24,464 +28,408 @@
...
@@ -24,464 +28,408 @@
</
template
>
</
template
>
<
script
>
<
script
>
import
util
from
'@/utils/util.js'
import
util
from
'@/utils/util.js'
export
default
{
import
login
from
'@/utils/login.js'
data
()
{
return
{
domain_name
:
'http://192.168.0.208:8192'
,
isNewUser
:
false
,
unionID
:
''
,
openID
:
''
,
icon_notice
:
''
,
TimeID
:
-
1
,
icon_auth_notice_new
:
''
,
noticeTitle
:
'申请获得您的公开信息(昵称,头像等)以便于为您提供更好的服务'
,
}
},
onLoad
()
{
getApp
().
trackPage
(
'授权登录页'
)
this
.
icon_notice
=
getApp
().
globalData
.
icon_auth_notice
this
.
icon_auth_notice_new
=
getApp
().
globalData
.
icon_auth_notice_new
},
onShow
(){
const
app
=
getApp
()
app
.
globalData
.
jumpLoginStatus
=
true
},
methods
:
{
// 授权用户信息
getUserProfile
()
{
var
self
=
this
const
app
=
getApp
()
if
(
self
.
isNewUser
)
{
uni
.
getUserProfile
({
desc
:
'用于授权登录'
,
success
:
function
(
res
)
{
const
userInfo
=
res
.
userInfo
;
if
(
!
userInfo
)
{
uni
.
showModal
({
title
:
'授权失败'
,
content
:
'获取用户信息的授权失败'
,
showCancel
:
false
});
return
}
app
.
globalData
.
tempUserInfo
=
userInfo
;
uni
.
showLoading
({
title
:
'授权中..'
,
mask
:
true
});
self
.
authLogin
()
},
fail
:
function
(
res
){
uni
.
showModal
({
title
:
'授权失败'
,
content
:
'请允许获取用户信息的授权'
,
showCancel
:
false
});
return
;
}
})
}
},
async
authLogin
()
{
var
that
=
this
const
app
=
getApp
()
const
res
=
await
that
.
$u
.
api
.
loginWechatAuth
(
params
)
if
(
!
res
||
!
res
.
code
||
!
res
.
data
){
uni
.
hideLoading
()
return
}
else
if
(
res
.
code
==
200
)
{
app
.
setUserData
(
res
.
data
)
}
else
{
}
uni
.
hideLoading
()
},
async
signLogin
()
{
var
that
=
this
const
app
=
getApp
()
const
res
=
await
that
.
$u
.
api
.
loginWechatAuth
(
params
)
if
(
!
res
||
!
res
.
code
||
!
res
.
data
){
uni
.
hideLoading
()
return
}
else
if
(
res
.
code
==
200
)
{
app
.
setUserData
(
res
.
data
)
}
else
{
}
uni
.
hideLoading
()
},
//用户授权得到用户的信息
getUserInfo
:
async
function
(
e
)
{
clearTimeout
(
this
.
TimeID
);
this
.
TimeID
=
setTimeout
(()
=>
{
//console.log('获取用户信息')
//console.log(e.detail.userInfo)
if
(
e
.
detail
.
errMsg
==
'getUserInfo:fail auth deny'
)
{
const
app
=
getApp
()
export
default
{
data
()
{
return
{
isNewUser
:
false
,
needAuth
:
true
,
unionID
:
''
,
openID
:
''
,
icon_notice
:
''
,
TimeID
:
-
1
,
icon_auth_notice_new
:
''
,
noticeTitle
:
'申请获得您的公开信息(昵称,头像等)以便于为您提供更好的服务'
,
}
},
onLoad
()
{
getApp
().
trackPage
(
'授权登录页'
)
this
.
icon_notice
=
getApp
().
globalData
.
icon_auth_notice
this
.
icon_auth_notice_new
=
getApp
().
globalData
.
icon_auth_notice_new
},
onShow
()
{
app
.
globalData
.
jumpLoginStatus
=
true
// 微信授权过用户信息,则无需重复授权
if
(
app
.
globalData
.
tempUserInfo
)
{
this
.
needAuth
=
false
}
},
methods
:
{
// 授权用户信息
getUserProfile
()
{
var
that
=
this
const
app
=
getApp
()
uni
.
getUserProfile
({
desc
:
'用于授权登录'
,
success
:
function
(
res
)
{
const
userInfo
=
res
.
userInfo
;
if
(
userInfo
)
{
app
.
globalData
.
tempUserInfo
=
userInfo
;
uni
.
showLoading
({
title
:
'授权中..'
,
mask
:
true
});
that
.
authLogin
()
}
else
{
uni
.
showModal
({
uni
.
showModal
({
title
:
'授权失败'
,
title
:
'授权失败'
,
content
:
'
请允许获取用户信息的授权
'
,
content
:
'
获取用户信息的授权失败
'
,
showCancel
:
false
showCancel
:
false
});
});
}
else
{
this
.
getCode
()
}
}
},
1000
);
},
},
fail
:
function
(
res
)
{
//小程序获取code
uni
.
showModal
({
getCode
:
async
function
()
{
title
:
'授权失败'
,
let
that
=
this
content
:
'请允许获取用户信息的授权'
,
uni
.
showLoading
({
showCancel
:
false
title
:
'加载中'
,
})
return
new
Promise
((
resolve
,
reject
)
=>
{
console
.
log
(
uni
.
login
,
'uni.login('
)
uni
.
login
({
// #ifdef MP-ALIPAY
scopes
:
'auth_user'
,
// #endif
success
:
function
(
res
)
{
if
(
res
.
code
)
{
that
.
getUsersByCode
(
res
.
code
)
//that.getUnionID(res.code)
//resolve(res.code);
}
else
{
//login成功,但是没有取到code
reject
(
'未取得code'
);
}
},
fail
:
function
(
res
)
{
reject
(
'用户授权失败wx.login'
);
},
complete
(
res
)
{
reject
(
'code获取失败'
);
console
.
log
(
'code获取失败'
,
res
)
uni
.
hideLoading
()
}
});
});
});
},
//通过code获取用户信息(新接口)
getUsersByCode
:
async
function
(
code
)
{
uni
.
showLoading
({
title
:
'加载中'
})
const
params
=
{
code
:
code
,
}
}
const
res
=
await
this
.
$u
.
api
.
loginWxByUser
(
params
)
})
if
(
res
.
code
==
200
)
{
},
this
.
unionID
=
res
.
data
.
user
.
unionid
authLogin
()
{
this
.
openID
=
res
.
data
.
user
.
wxopenid
var
that
=
this
util
.
setOpenid
(
res
.
data
.
user
.
wxopenid
)
let
params
=
{
if
(
res
.
data
.
token
)
{
nickname
:
app
.
globalData
.
tempUserInfo
.
nickName
,
uni
.
showToast
({
avatar
:
app
.
globalData
.
tempUserInfo
.
avatarUrl
icon
:
'none'
,
}
title
:
'登陆成功'
login
.
appLogin
().
then
(
res
=>
{
})
params
.
code
=
res
.
code
this
.
saveUserInfo
(
res
)
return
login
.
authorization
(
params
);
}
else
{
}).
then
(
res
=>
{
uni
.
hideLoading
();
uni
.
showToast
({
if
(
res
&&
util
.
getToken
())
{
icon
:
'none'
,
that
.
goBackPage
()
title
:
'新用户请授权登录'
})
this
.
isNewUser
=
true
}
}
else
{
}
else
{
uni
.
showToast
({
uni
.
showToast
({
icon
:
'none'
,
title
:
'授权失败,请重新授权'
,
title
:
res
.
data
.
message
icon
:
'none'
})
});
this
.
setLoginStatus
()
}
}
}).
catch
(
res
=>
{
uni
.
hideLoading
()
uni
.
hideLoading
()
},
uni
.
showToast
({
title
:
res
.
message
,
//用户信息存本地
icon
:
'none'
saveUserInfo
:
async
function
(
res
)
{
});
//console.log('用户信息存本地 token:' +res.data.data.token);
this
.
setLoginStatus
()
// this.$u.vuex('vuex_token', res.data.data.token)
})
console
.
log
(
'token'
,
'token'
)
},
util
.
setToken
(
res
.
data
.
token
)
// uni.setStorage({
signupLogin
(
e
)
{
// key: 'token',
var
that
=
this
// data: res.data.token,
if
(
!
e
||
!
detail
||
e
.
detail
.
errMsg
.
indexOf
(
'user deny'
)
>
-
1
)
{
// success: function(e) {
wx
.
showModal
({
// //console.log('保存token 成功'+e);
title
:
'提示'
,
// }
showCancel
:
false
,
// });
content
:
'用户未授权不能完成注册'
});
let
pages
=
getCurrentPages
();
}
else
{
let
prevPage
=
pages
[
pages
.
length
-
2
];
//上一个页面
let
params
=
{
// if (prevPage.route == 'pages/index/index') {
nickname
:
app
.
globalData
.
tempUserInfo
.
nickName
,
// prevPage.$vm.isRefresh = true;
avatar
:
app
.
globalData
.
tempUserInfo
.
avatarUrl
,
// }
encryptedData
:
e
.
detail
.
encryptedData
,
if
(
prevPage
&&
prevPage
.
$vm
){
iv
:
e
.
detail
.
iv
prevPage
.
$vm
.
isRefresh
=
true
;
}
}
uni
.
navigateBack
({
login
.
appLogin
().
then
(
res
=>
{
delta
:
2
params
.
code
=
res
.
code
return
login
.
signup
(
params
);
}).
then
(
res
=>
{
uni
.
hideLoading
()
if
(
util
.
getToken
())
{
that
.
goBackPage
()
}
else
{
this
.
setLoginStatus
(
false
)
}
}).
catch
(
res
=>
{
uni
.
hideLoading
()
uni
.
showToast
({
title
:
res
.
message
,
icon
:
'none'
});
this
.
setLoginStatus
(
false
)
})
})
}
},
},
goBackPage
()
{
let
pages
=
getCurrentPages
();
let
prevPage
=
pages
[
pages
.
length
-
2
];
//上一个页面
if
(
prevPage
&&
prevPage
.
$vm
)
{
prevPage
.
$vm
.
isRefresh
=
true
;
}
uni
.
navigateBack
({
delta
:
2
})
},
//获取用户手机号
setLoginStatus
(
authed
=
true
)
{
getPhoneNumber
:
async
function
(
e
)
{
if
(
authed
)
{
this
.
needAuth
=
false
uni
.
setNavigationBarTitle
({
title
:
'登录页'
});
}
else
{
this
.
needAuth
=
true
uni
.
setNavigationBarTitle
({
title
:
'授权页'
});
}
},
clearTimeout
(
this
.
TimeID
);
//用户授权得到用户的信息
this
.
TimeID
=
setTimeout
(()
=>
{
getUserInfo
:
async
function
(
e
)
{
//console.log('获取用户手机号')
clearTimeout
(
this
.
TimeID
);
//console.log(e.detail)
this
.
TimeID
=
setTimeout
(()
=>
{
//console.log('获取用户信息')
//console.log(e.detail.userInfo)
if
(
e
.
detail
.
errMsg
==
'getPhoneNumber:fail user deny'
)
{
if
(
e
.
detail
.
errMsg
==
'getUserInfo:fail auth deny'
)
{
//this.$u.toast('未授权');
uni
.
showModal
({
title
:
'授权失败'
,
content
:
'请允许获取用户信息的授权'
,
showCancel
:
false
});
}
else
{
this
.
findByMobile
(
e
)
}
},
1000
);
uni
.
showModal
({
title
:
'授权失败'
,
content
:
'请允许获取用户信息的授权'
,
showCancel
:
false
});
}
else
{
this
.
getCode
()
}
},
1000
);
},
},
//通过手机号获取用户信息
//小程序获取code
findByMobile
:
async
function
(
e
)
{
getCode
:
async
function
()
{
uni
.
showLoading
({
let
that
=
this
title
:
'加载中'
uni
.
showLoading
({
})
title
:
'加载中'
,
const
params
=
{
})
wxopenid
:
this
.
openID
,
return
new
Promise
((
resolve
,
reject
)
=>
{
unionid
:
this
.
unionID
,
console
.
log
(
uni
.
login
,
'uni.login('
)
encryptedData
:
e
.
detail
.
encryptedData
,
uni
.
login
({
iv
:
e
.
detail
.
iv
// #ifdef MP-ALIPAY
}
scopes
:
'auth_user'
,
const
res
=
await
this
.
$u
.
api
.
loginWxByPhone
(
params
)
// #endif
if
(
res
.
code
==
200
)
{
success
:
function
(
res
)
{
if
(
res
.
code
)
{
that
.
getUsersByCode
(
res
.
code
)
//that.getUnionID(res.code)
//resolve(res.code);
}
else
{
//login成功,但是没有取到code
reject
(
'未取得code'
);
}
},
fail
:
function
(
res
)
{
reject
(
'用户授权失败wx.login'
);
},
complete
(
res
)
{
reject
(
'code获取失败'
);
console
.
log
(
'code获取失败'
,
res
)
uni
.
hideLoading
()
}
});
});
},
//通过code获取用户信息(新接口)
getUsersByCode
:
async
function
(
code
)
{
uni
.
showLoading
({
title
:
'加载中'
})
const
params
=
{
code
:
code
,
}
const
res
=
await
this
.
$u
.
api
.
loginWxByUser
(
params
)
if
(
res
.
code
==
200
)
{
this
.
unionID
=
res
.
data
.
user
.
unionid
this
.
openID
=
res
.
data
.
user
.
wxopenid
util
.
setOpenid
(
res
.
data
.
user
.
wxopenid
)
if
(
res
.
data
.
token
)
{
uni
.
showToast
({
uni
.
showToast
({
icon
:
'none'
,
icon
:
'none'
,
title
:
'登
录
成功'
title
:
'登
陆
成功'
})
})
this
.
saveUserInfo
(
res
)
this
.
saveUserInfo
(
res
)
}
else
{
}
else
{
uni
.
showToast
({
uni
.
showToast
({
icon
:
'none'
,
icon
:
'none'
,
title
:
res
.
message
title
:
'新用户请授权登录'
})
})
this
.
isNewUser
=
true
}
}
else
{
uni
.
showToast
({
icon
:
'none'
,
title
:
res
.
data
.
message
})
}
uni
.
hideLoading
()
},
//用户信息存本地
saveUserInfo
:
async
function
(
res
)
{
//console.log('用户信息存本地 token:' +res.data.data.token);
// this.$u.vuex('vuex_token', res.data.data.token)
console
.
log
(
'token'
,
'token'
)
util
.
setToken
(
res
.
data
.
token
)
// uni.setStorage({
// key: 'token',
// data: res.data.token,
// success: function(e) {
// //console.log('保存token 成功'+e);
// }
// });
let
pages
=
getCurrentPages
();
let
prevPage
=
pages
[
pages
.
length
-
2
];
//上一个页面
// if (prevPage.route == 'pages/index/index') {
// prevPage.$vm.isRefresh = true;
// }
if
(
prevPage
&&
prevPage
.
$vm
)
{
prevPage
.
$vm
.
isRefresh
=
true
;
}
uni
.
navigateBack
({
delta
:
2
})
},
//获取用户手机号
getPhoneNumber
:
async
function
(
e
)
{
clearTimeout
(
this
.
TimeID
);
this
.
TimeID
=
setTimeout
(()
=>
{
//console.log('获取用户手机号')
//console.log(e.detail)
if
(
e
.
detail
.
errMsg
==
'getPhoneNumber:fail user deny'
)
{
//this.$u.toast('未授权');
uni
.
showModal
({
title
:
'授权失败'
,
content
:
'请允许获取用户信息的授权'
,
showCancel
:
false
});
}
else
{
this
.
findByMobile
(
e
)
}
}
},
//取消点击
},
1000
);
cancelClick
:
function
()
{
uni
.
navigateBack
({
},
//通过手机号获取用户信息
findByMobile
:
async
function
(
e
)
{
uni
.
showLoading
({
title
:
'加载中'
})
const
params
=
{
wxopenid
:
this
.
openID
,
unionid
:
this
.
unionID
,
encryptedData
:
e
.
detail
.
encryptedData
,
iv
:
e
.
detail
.
iv
}
const
res
=
await
this
.
$u
.
api
.
loginWxByPhone
(
params
)
if
(
res
.
code
==
200
)
{
uni
.
showToast
({
icon
:
'none'
,
title
:
'登录成功'
})
})
},
this
.
saveUserInfo
(
res
)
/*
}
else
{
//微信授权
uni
.
showToast
({
toLogin: async function(data) {
icon
:
'none'
,
uni.showLoading({
title
:
res
.
message
title:'授权中……'
})
})
let res = await this.$u.api.gowxLogin(data);
}
console.log('微信授权')
},
console.log(res)
uni.hideLoading()
//取消点击
if (res.code!==1) {
cancelClick
:
function
()
{
this.$u.toast(res.msg);
uni
.
navigateBack
({})
return;
},
}
if (res.data) {
//this.setLoginStatus()
// this.success(res.data.user.id);
}
},
//获取unionID
getUnionID: async function(code) {
uni.request({
url: getApp().globalData.domain_Name
+'/wxh-support-rest/rest/ssoinfo/getUsersByCode',
method: 'GET',
data: {
code: code,
},
success: (res) => {
console.log('获取unionID 成功')
console.log(res)
if(res.data.code==200){
this.getSSOID(res.data.data.unionid)
}
},
fail: (e) => {
console.log('获取unionID 失败')
console.log(e)
}
})
},
//获取SSOID
getSSOID: async function(unionID) {
uni.request({
url: getApp().globalData.domain_Name
+ '/wxh-support-rest/rest/ssoinfo/v2/findByUnionId',
method: 'GET',
data: {
unionid: unionID,
},
success: (res) => {
console.log('获取SSOID 成功')
console.log(res)
},
fail: (e) => {
console.log('获取SSOID 失败')
console.log(e)
}
})
},
//获取loginCode
getLoginCode: async function() {
uni.request({
url: getApp().globalData.domain_Name
+ '/wxh-support-rest/rest/ssoinfo/v2/getLoginCode',
method: 'GET',
data: {
ssoId: '93140',
},
success: (res) => {
console.log('获取loginCode 成功')
console.log(res)
if(res.data.code==200){
this.getToken(res.data.data.loginCode)
}
},
fail: (e) => {
console.log('获取loginCode 失败')
console.log(e)
}
})
},
//获取token
getToken: async function(loginCode) {
uni.request({
url: getApp().globalData.domain_Name
+ '/wxh-support-rest/rest/worker/login/applets/'
+loginCode,
method: 'GET',
data: {
},
success: (res) => {
console.log('获取token 成功')
console.log(res)
},
fail: (e) => {
console.log('获取token 失败')
console.log(e)
}
})
},
*/
}
}
}
}
</
script
>
</
script
>
<
style
>
<
style
>
.backView
{
.backView
{
background-color
:
#FFFFFF
;
background-color
:
#FFFFFF
;
position
:
absolute
;
position
:
absolute
;
top
:
0
;
top
:
0
;
left
:
0
;
left
:
0
;
width
:
100%
;
width
:
100%
;
height
:
100%
;
height
:
100%
;
display
:
flex
;
display
:
flex
;
flex-direction
:
column
;
flex-direction
:
column
;
}
}
.noticeView
{
.noticeView
{
background-color
:
#FFFFFF
;
background-color
:
#FFFFFF
;
width
:
100%
;
width
:
100%
;
height
:
470
rpx
;
height
:
470
rpx
;
display
:
flex
;
display
:
flex
;
flex-direction
:
column
;
flex-direction
:
column
;
align-items
:
center
;
align-items
:
center
;
}
}
.noticeImage
{
.noticeImage
{
background-color
:
#FFFFFF
;
background-color
:
#FFFFFF
;
width
:
386
rpx
;
width
:
386
rpx
;
height
:
270
rpx
;
height
:
270
rpx
;
margin-top
:
180
rpx
;
margin-top
:
180
rpx
;
}
}
.noticeTitleView
{
margin-top
:
80
rpx
;
width
:
100%
;
display
:
flex
;
align-items
:
center
;
justify-content
:
center
;
}
.noticeTitle
{
width
:
60%
;
font-size
:
24
rpx
;
color
:
#999999
;
text-align
:
center
;
line-height
:
40
rpx
;
}
.loginBtn
{
.noticeTitleView
{
background-color
:
#2272FF
;
margin-top
:
80
rpx
;
width
:
390
rpx
;
width
:
100%
;
height
:
80
rpx
;
display
:
flex
;
border-radius
:
40
rpx
;
align-items
:
center
;
margin-top
:
334
rpx
;
justify-content
:
center
;
display
:
flex
;
}
align-items
:
center
;
justify-content
:
center
;
}
.cancelView
{
.noticeTitle
{
width
:
10
0%
;
width
:
6
0%
;
margin-top
:
30
rpx
;
font-size
:
24
rpx
;
display
:
flex
;
color
:
#999999
;
align-items
:
center
;
text-align
:
center
;
justify-content
:
center
;
line-height
:
40
rpx
;
}
}
.cancelText
{
.loginBtn
{
color
:
#666666
;
background-color
:
#2272FF
;
font-size
:
32
rpx
;
width
:
390
rpx
;
}
height
:
80
rpx
;
border-radius
:
40
rpx
;
margin-top
:
334
rpx
;
display
:
flex
;
align-items
:
center
;
justify-content
:
center
;
}
.white
{
.cancelView
{
color
:
#FFFFFF
;
width
:
100%
;
}
margin-top
:
30
rpx
;
display
:
flex
;
align-items
:
center
;
justify-content
:
center
;
}
.cancelText
{
color
:
#666666
;
font-size
:
32
rpx
;
}
.white
{
color
:
#FFFFFF
;
}
</
style
>
</
style
>
take-order/utils/login.js
View file @
6a9da170
...
@@ -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
)
resolve
(
res
);
uni
.
hideLoading
();
}
else
{
resolve
(
res
);
uni
.
showModal
({
}
else
()
{
title
:
'用户登录失败'
,
uni
.
hideLoading
();
content
:
res
.
message
,
uni
.
showModal
({
showCancel
:
false
title
:
'请求失败'
,
});
content
:
err
.
message
,
reject
(
res
);
showCancel
:
false
}
});
}
else
{
reject
();
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
:
{
resolve
(
res
);
code
:
data
.
code
,
}
else
{
encryptedData
:
data
.
encryptedData
,
uni
.
showModal
({
iv
:
data
.
iv
title
:
'用户授权失败'
,
},
content
:
res
.
message
,
success
:
function
(
res
)
{
showCancel
:
false
if
(
res
&&
res
.
status
)
{
});
let
data
=
res
.
data
reject
(
res
);
app
.
setUserData
(
data
)
resolve
(
res
);
}
else
{
if
(
!
res
.
status
&&
res
.
message
===
'用户授权信息失效,请重新授权'
){
api
.
setAuthToken
(
''
)
}
resolve
(
res
);
}
}
}
});
}
else
{
uni
.
showModal
({
title
:
'请求失败'
,
content
:
res
.
message
});
}
});
});
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment