login.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  1. <template>
  2. <view class="login" >
  3. <view :style="'padding-top:'+padtop+'px'">
  4. <navbar :back="false" :bgcolor="backgroundColor" fixed zIndex="1010" :center="true" :custom='true' @getTop="getTop" back="true"/>
  5. <view class="login_tit">潜山信惠</view>
  6. <view style="padding-bottom: 56rpx;">
  7. <view class="login_i">
  8. <image :src="zimg"></image>
  9. <input placeholder="请输入账号" v-model="formData.username"/>
  10. </view>
  11. <view class="login_i">
  12. <image :src="mimg"></image>
  13. <input placeholder="请输入密码" type="password" v-model="formData.password"/>
  14. </view>
  15. </view>
  16. <view class="login_btn btn1" @click="passwordlogin">账号登录</view>
  17. <button type="primary" class="login_btn btn2" open-type="getUserInfo" @getuserinfo="getuserinfo">
  18. <text class="btn-txt">快速登录</text>
  19. </button>
  20. <!-- 显示弹窗 -->
  21. <div class="box_hei" @click="btn" v-if="box_status">
  22. <div @click.stop="btns" class="hei_box">
  23. <div class="box_top">
  24. <div class="box_title">
  25. <div>
  26. 潜山信惠 申请使用
  27. </div>
  28. </div>
  29. <div class="box_nameq">你的手机号码</div>
  30. </div>
  31. <!-- <div class="boxs"></div> -->
  32. <div class="box_btns">
  33. <div @click="btn" class="box_btn box_btn1">拒绝</div>
  34. <button class="box_btn box_btn2" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">允许</button>
  35. </div>
  36. </div>
  37. </div>
  38. </view>
  39. </view>
  40. </template>
  41. <script>
  42. export default{
  43. data(){
  44. return{
  45. padtop:this.$http._GET.customBarH||0,
  46. backgroundColor:'transparent',
  47. zimg:require("static/images/loginz.png"),
  48. mimg:require("static/images/loginm.png"),
  49. formData: {
  50. username: '',
  51. password: ''
  52. },
  53. box_status: false,
  54. userId:''
  55. }
  56. },
  57. onLoad() {
  58. uni.clearStorage()
  59. },
  60. methods:{
  61. getTop(e){
  62. this.padtop=e
  63. },
  64. btns() {
  65. },
  66. btn() {
  67. this.box_status = false
  68. },
  69. // 手机号登录
  70. passwordlogin() {
  71. if(!this.formData.username){
  72. uni.showToast({
  73. title: "请输入账号",
  74. duration: 1000,
  75. icon: 'none'
  76. });
  77. return
  78. }
  79. if(!this.formData.password){
  80. uni.showToast({
  81. title: "请输入密码",
  82. duration: 1000,
  83. icon: 'none'
  84. });
  85. return
  86. }
  87. // this.$http.post('boman-auth/login', this.formData).then(res=>{
  88. this.$http.post('loginApp', this.formData).then(res=>{
  89. if(res.code == 200 ) {
  90. this.userId=res.userId;
  91. uni.setStorageSync('token', res.token)
  92. uni.setStorageSync('userId', res.userId)
  93. uni.setStorageSync('businessId',res.settledMerchants.businessId)
  94. uni.setStorageSync('phone', res.settledMerchants.businessPhone)
  95. setTimeout(function(){
  96. uni.switchTab({
  97. url: '/pages/index/index',
  98. });
  99. },1000)
  100. // this.getUserInfoes();
  101. // uni.switchTab({
  102. // url: '/pages/index/index',
  103. // });
  104. } else{
  105. uni.showToast({
  106. title: res.msg,
  107. duration: 1000,
  108. icon: 'none'
  109. });
  110. }
  111. })
  112. },
  113. // 快捷登录
  114. async getPhoneNumber(e){
  115. console.log(e)
  116. const {iv,encryptedData} = e.detail
  117. console.log(iv,encryptedData)
  118. let res = await this.$http.uniApi({events: uni.login})
  119. if(res.code) {
  120. // console.log(res,9876)
  121. this.$http.post("applet/login",{
  122. iv: iv,
  123. encryptedData: encryptedData,
  124. code : res.code,
  125. // mode:this.mode,
  126. // userInfo:this.userInfo
  127. }).then(red => {
  128. // console.log(red)
  129. if(red.code == 200){
  130. // console.log(JSON.parse(red.data).phoneNumber,9999)
  131. this.box_status = false;
  132. this.userId=red.data.userId;
  133. uni.setStorageSync('token', red.data.access_token)
  134. uni.setStorageSync('userId', red.data.userId)
  135. uni.setStorageSync('businessId',red.data.settledMerchants.businessId)
  136. uni.setStorageSync('phone', red.data.settledMerchants.businessPhone)
  137. // this.getUserInfoes();
  138. uni.switchTab({
  139. url: '/pages/index/index',
  140. });
  141. // uni.navigateTo({
  142. // url: '/pages/index/index'
  143. // })
  144. }else{
  145. uni.showToast({
  146. title: red.msg,
  147. duration: 1000,
  148. icon: 'none'
  149. });
  150. }
  151. })
  152. }
  153. },
  154. // 个人信息
  155. getUserInfoes() {
  156. this.$http.get('system/user/'+this.userId).then(res=>{
  157. // console.log(JSON.stringify(res))
  158. if(res.code == 200 ) {
  159. uni.setStorageSync('phone', res.data.phonenumber)
  160. setTimeout(function(){
  161. uni.switchTab({
  162. url: '/pages/index/index',
  163. });
  164. },1000)
  165. }
  166. })
  167. },
  168. async getuserinfo(e) {
  169. console.log(e,9999)
  170. const {nickName, avatarUrl, ...userInfo} = e.detail.userInfo
  171. // uni.navigateTo({
  172. // url: `login_phone?nickName=${nickName}&avatarUrl=${avatarUrl}`
  173. // })
  174. try{
  175. let res = await this.$http.uniApi({events: uni.login})
  176. if(res.code) {
  177. // console.log(res)
  178. // console.log(res.code)
  179. // console.log(nickName)
  180. // console.log(avatarUrl)
  181. this.avatarUrl = avatarUrl
  182. this.nickName = nickName
  183. this.code = res.code
  184. this.userInfo =e.detail.userInfo
  185. uni.setStorageSync('userInfo', e.detail.userInfo)
  186. // this.bindUserinfo({code: res.code, nickName, avatarUrl})
  187. this.box_status=true
  188. }
  189. } catch(e){
  190. //TODO handle the exception
  191. }
  192. },
  193. }
  194. }
  195. </script>
  196. <style scoped lang="scss">
  197. .login{height: 100vh;background: url("@/static/images/bg.png") no-repeat;width: 100%;box-sizing: border-box;background-size: 100% 100%;padding: 0 74rpx;}
  198. .login_tit{font-size: 56rpx;font-weight: bold;color: #000000;padding-top: 60rpx;margin-bottom: 160rpx;}
  199. .login_i{
  200. display: flex;align-items: center;height:90rpx;box-shadow: 2rpx 4rpx 10rpx 0px rgba(191,191,191,0.4100);padding: 0 32rpx;border-radius: 48rpx;margin-bottom: 28rpx;
  201. image{
  202. width: 46rpx;height: 44rpx;margin-right: 14rpx;
  203. }
  204. input{
  205. font-size: 28rpx;color: #000000;
  206. }
  207. }
  208. .login_btn{width: 100%;height: 90rpx;display: flex;align-items: center;justify-content: center;font-size: 30rpx;border-radius: 48rpx;
  209. &.btn1{background: linear-gradient(90deg, #A00517, #E93030);color: #ffffff;margin-bottom: 28rpx;}
  210. &.btn2{border: 1px solid #E4884E;color: #E4884E;background: #fff;}
  211. }
  212. // 快捷登录弹窗
  213. .box_hei{
  214. width: 100%;
  215. height: 100%;
  216. background: rgba(0,0,0,.8);
  217. position: fixed;
  218. top: 0;
  219. left: 0;
  220. z-index: 3;
  221. .hei_box{
  222. background: #fff;
  223. border-radius:22upx 22upx 0 0;
  224. height: 440upx;
  225. padding: 52upx 28upx 104upx;
  226. position: absolute;
  227. bottom:0;
  228. width: 100%;
  229. box-sizing: border-box;
  230. .box_top{
  231. padding: 0 18upx 62upx;
  232. .box_title{
  233. display: flex;
  234. justify-content: space-between;
  235. font-size: 30upx;
  236. margin-bottom: 30upx;
  237. div{
  238. display: flex;
  239. align-items: center;
  240. color: #333333;
  241. }
  242. .img{
  243. margin-right: 14upx;
  244. width: 180upx;
  245. height: 48upx;
  246. }
  247. .imgs{
  248. width: 40upx;
  249. height: 40upx;
  250. }
  251. }
  252. .box_nameq{
  253. color: #333333;
  254. font-size: 44upx;
  255. font-weight: bold;
  256. }
  257. }
  258. .box_phone{
  259. height: 106upx;
  260. display: flex;
  261. align-items: center;
  262. justify-content: space-between;
  263. font-size: 28upx;
  264. color: #A6A6A6;
  265. border-bottom: 1upx solid #EBEBEB;
  266. border-top: 1upx solid #EBEBEB;
  267. div{
  268. display: flex;
  269. align-items: center;
  270. }
  271. .img{
  272. width: 26upx;
  273. height: 22upx;
  274. }
  275. span{
  276. color: #333333;
  277. font-size: 32upx;
  278. padding-right: 18upx;
  279. font-weight: bold;
  280. }
  281. }
  282. .box_qita{
  283. height: 106upx;
  284. font-size: 28upx;
  285. color: #7CA4FC;
  286. line-height: 106upx;
  287. }
  288. .boxs{
  289. height: 50upx;
  290. }
  291. .box_btns{
  292. margin-top: 10upx;
  293. display: flex;
  294. justify-content: space-between;
  295. .box_btn{
  296. width: 324upx;
  297. height: 82upx;
  298. font-size: 32upx;
  299. display: flex;
  300. align-items: center;
  301. justify-content: center;
  302. border-radius: 4upx;
  303. }
  304. .box_btn1{
  305. background: #F3F3F3;
  306. color: #33B925;
  307. }
  308. .box_btn2{
  309. background: #37962B;
  310. color: #FFFFFF;
  311. }
  312. }
  313. }
  314. }
  315. </style>