login.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. <template>
  2. <view class="page" :style="{'min-height':h+'px', 'padding-top':mt+'px'}">
  3. <cus-header title='创衡汇教练AI智能体' bgColor="transparent" backUrl="/pages/home"></cus-header>
  4. <image class="topbg" :src="imgBase+'login_top_bg.png'"></image>
  5. <div class="content">
  6. <div class="c_top">
  7. <image :src="imgBase+'logo.png'" mode="heightFix"></image>
  8. <div class="title">Hi,我是创衡团队教练助手</div>
  9. <div class="tip">可以为您提供PERILL团队评估、团队评估报告分析和团队教练督导对话,期待和您的共创~</div>
  10. <div class="item adf">
  11. <div class="qa">
  12. <p>PERILL团队发展动态评估</p>
  13. <p>据您对相关陈述的评分,帮助团队从六个维度评估团队的现状。</p>
  14. </div>
  15. </div>
  16. <div class="item adf">
  17. <div class="qa">
  18. <p>AI教练督导对话</p>
  19. <p>保持正念教练督导心态,对您的PERILL测评报告或团队教练计划进行启发式沟通。</p>
  20. </div>
  21. </div>
  22. </div>
  23. <div class="c_bottom">
  24. <button class="zt_btn" open-type="getPhoneNumber" @getphonenumber="decryptPhoneNumber">手机号一键登录</button>
  25. <div class="qx_btn" style="margin-top: 40rpx;" @tap="codeLogin" v-if="!channelType">授权码登录</div>
  26. <div class="agree adfacjc" @click="changeAgree">
  27. <image :src="imgBase+'not_select.png'" v-if="!agree"></image>
  28. <image :src="imgBase+'selected.png'" v-else></image>
  29. <div class="text">已阅读并同意我们的<span>“服务协议与隐私政策”</span></div>
  30. </div>
  31. </div>
  32. </div>
  33. <u-popup :show="show" @close="cancel" mode="center" :round="20">
  34. <div class="code">
  35. <p>授权码登录</p>
  36. <u-input v-model="phone" placeholder="请输入手机号"></u-input>
  37. <div style="margin-top: 20rpx;"></div>
  38. <u-input v-model="code" placeholder="请输入授权码"></u-input>
  39. <div class="cbtns adfacjb">
  40. <div class="zt_btn" @tap="toCodeLogin">登录</div>
  41. <div class="qx_btn" @tap="cancel">取消</div>
  42. </div>
  43. </div>
  44. </u-popup>
  45. </view>
  46. </template>
  47. <script>
  48. export default {
  49. data(){
  50. return {
  51. show:false,
  52. phone:'',
  53. code:'',
  54. agree:false,
  55. channelType:''
  56. }
  57. },
  58. created() {
  59. if(uni.getStorageSync('channelType')) this.channelType = uni.getStorageSync('channelType')
  60. },
  61. methods:{
  62. decryptPhoneNumber(e){
  63. if(!this.agree) return this.$showToast('请勾选协议与政策')
  64. if(uni.getStorageSync('token')){
  65. uni.reLaunch({
  66. url:'/pages/home'
  67. })
  68. return
  69. }
  70. if(e.detail.code) this.wxLogin(e.detail.code);
  71. },
  72. codeLogin(){
  73. if(!this.agree) return this.$showToast('请勾选协议与政策')
  74. this.show = true;
  75. },
  76. toCodeLogin(){
  77. if(!this.$reg.mobile(this.phone)) return this.$showToast('请输入正确的手机号!')
  78. if(!this.code) return this.$showToast('请输入授权码!')
  79. this.$api.get('/wx/login-code',{
  80. checkCode:this.code,
  81. phone:this.phone
  82. }).then(res=>{
  83. if(res.data.code!==0) return this.$showToast(res.data.msg)
  84. this.loginSuccessFn(res);
  85. })
  86. },
  87. cancel(){
  88. this.code = '';
  89. this.show = false;
  90. },
  91. wxLogin(code){
  92. uni.showLoading({ title:'登录中' });
  93. let that = this;
  94. wx.login({
  95. success(res){
  96. that.$api.get('/wx/login',{
  97. code:res.code,
  98. phoneCode:code,
  99. channelType:that.channelType
  100. },false).then(res=>{
  101. if(res.data.code===0){
  102. if(res.data.data.isRegister==1) that.loginSuccessFn(res);
  103. else{
  104. uni.navigateTo({
  105. url:'/pages/registerInfo?params='+encodeURIComponent(JSON.stringify({
  106. info:{
  107. channelType:that.channelType,
  108. mobile:res.data.data.mobile||'',
  109. isRegister:res.data.data.isRegister,
  110. referrerId:res.data.data.referrerId||'',
  111. teamQuestionnaireId:res.data.data.teamQuestionnaireId||'',
  112. userId:res.data.data.id||''
  113. },
  114. user:{
  115. token:res.data.data.token,
  116. id:res.data.data.id,
  117. gender:res.data.data.gender,
  118. realName:res.data.data.realName,
  119. mobile:res.data.data.mobile,
  120. headUrl:res.data.data.headUrl,
  121. teamId:res.data.data.teamId,
  122. enterpriseId:res.data.data.enterpriseId,
  123. enterpriseName:res.data.data.enterpriseName,
  124. teamName:res.data.data.teamName,
  125. referrerId:res.data.data.referrerId,
  126. teamQuestionnaireId:res.data.data.teamQuestionnaireId,
  127. isRegister:res.data.data.isRegister
  128. }
  129. }))
  130. })
  131. }
  132. }else that.$showToast(res.data.msg)
  133. })
  134. }
  135. })
  136. },
  137. loginSuccessFn(res){
  138. uni.setStorageSync('token',res.data.data.token);
  139. uni.setStorageSync('userInfo',JSON.stringify({
  140. id:res.data.data.id,
  141. gender:res.data.data.gender,
  142. realName:res.data.data.realName,
  143. mobile:res.data.data.mobile,
  144. headUrl:res.data.data.headUrl,
  145. teamId:res.data.data.teamId,
  146. enterpriseId:res.data.data.enterpriseId,
  147. enterpriseName:res.data.data.enterpriseName,
  148. teamName:res.data.data.teamName,
  149. referrerId:res.data.data.referrerId,
  150. teamQuestionnaireId:res.data.data.teamQuestionnaireId,
  151. isRegister:res.data.data.isRegister
  152. }));
  153. uni.hideLoading();
  154. this.$showToast('登录成功');
  155. setTimeout(()=>{
  156. uni.reLaunch({ url:'/pages/home' })
  157. },1500)
  158. },
  159. changeAgree(){
  160. this.agree = !this.agree
  161. }
  162. }
  163. }
  164. </script>
  165. <style scoped lang="scss">
  166. .page{
  167. background: #FFFFFF;
  168. display: flex;
  169. flex-direction: column;
  170. box-sizing: border-box;
  171. .topbg{
  172. width: 100%;
  173. height: 584rpx;
  174. position: fixed;
  175. top: 0;
  176. left: 0;
  177. }
  178. .content{
  179. padding: 0 45rpx;
  180. flex: 1;
  181. overflow-y: auto;
  182. display: flex;
  183. flex-direction: column;
  184. justify-content: space-between;
  185. position: relative;
  186. .c_top{
  187. padding: 0 20rpx;
  188. &>image{
  189. height: 88rpx;
  190. margin-top: 76rpx;
  191. }
  192. .title{
  193. font-family: PingFang-SC, PingFang-SC;
  194. font-weight: bold;
  195. font-size: 48rpx;
  196. color: #252525;
  197. line-height: 67rpx;
  198. margin-top: 36rpx;
  199. }
  200. .tip{
  201. font-family: PingFangSC, PingFang SC;
  202. font-weight: 400;
  203. font-size: 30rpx;
  204. color: #646464;
  205. line-height: 47rpx;
  206. margin-top: 20rpx;
  207. }
  208. .item{
  209. margin-top: 64rpx;
  210. .qa{
  211. box-sizing: border-box;
  212. p{
  213. font-family: PingFang-SC, PingFang-SC;
  214. font-weight: bold;
  215. font-size: 32rpx;
  216. color: #252525;
  217. line-height: 45rpx;
  218. &:last-child{
  219. font-weight: 400;
  220. font-size: 28rpx;
  221. color: #646464;
  222. line-height: 47rpx;
  223. }
  224. }
  225. }
  226. }
  227. }
  228. .c_bottom{
  229. .qx_btn{
  230. margin-top: 36rpx;
  231. }
  232. .agree{
  233. margin-top: 64rpx;
  234. image{
  235. width: 30rpx;
  236. height: 30rpx;
  237. }
  238. .text{
  239. margin-left: 8rpx;
  240. font-family: PingFangSC, PingFang SC;
  241. font-weight: 400;
  242. font-size: 24rpx;
  243. color: #95A5B1;
  244. line-height: 44rpx;
  245. span{
  246. color: #833478;
  247. }
  248. }
  249. }
  250. }
  251. }
  252. }
  253. .code{
  254. width: 700rpx;
  255. padding: 40rpx 60rpx 40rpx;
  256. border-radius: 32rpx 32rpx 0 0;
  257. box-sizing: border-box;
  258. p{
  259. font-size: 40rpx;
  260. font-weight: bold;
  261. margin-bottom: 50rpx;
  262. }
  263. .cbtns{
  264. margin-top: 50rpx;
  265. &>div{
  266. width: calc(50% - 20rpx);
  267. }
  268. .qx_btn{
  269. background: #f1f1f1;
  270. }
  271. }
  272. }
  273. </style>