login.vue 8.7 KB

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