login-account.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  1. <template>
  2. <view class="container" :style="{paddingTop:CustomBar+'px'}">
  3. <tui-skeleton v-if="skeletonShow" backgroundColor="#fafafa" borderRadius="10rpx" :isLoading ="true" :loadingType="7"></tui-skeleton>
  4. <template v-else>
  5. <view class="tui-page-title">登录</view>
  6. <view class="tui-form">
  7. <view class="tui-view-input">
  8. <tui-list-cell :hover="false" :lineLeft="false" backgroundColor="transparent">
  9. <view class="tui-cell-input">
  10. <tui-icon name="mobile" color="#6d7a87" :size="20"></tui-icon>
  11. <input
  12. :adjust-position="false"
  13. v-model="param.mobile"
  14. placeholder="请输入账号/手机号"
  15. placeholder-class="tui-phcolor"
  16. type="number"
  17. maxlength="11"
  18. />
  19. <view class="" v-show="param.mobile" @click.stop="clearInput(1)">
  20. <tui-icon name="close-fill" :size="16" color="#bfbfbf" ></tui-icon>
  21. </view>
  22. </view>
  23. </tui-list-cell>
  24. <tui-list-cell :hover="false" :lineLeft="false" backgroundColor="transparent">
  25. <view class="tui-cell-input">
  26. <tui-icon name="pwd" color="#6d7a87" :size="20"></tui-icon>
  27. <input
  28. v-if="!isShowEye"
  29. :adjust-position="false"
  30. v-model="param.password"
  31. placeholder="请输入密码"
  32. placeholder-class="tui-phcolor"
  33. type="text"
  34. maxlength="36"
  35. />
  36. <input
  37. v-if="isShowEye"
  38. :adjust-position="false"
  39. v-model="param.password"
  40. placeholder="请输入密码"
  41. placeholder-class="tui-phcolor"
  42. type="password"
  43. maxlength="36"
  44. />
  45. <view class="" v-show="param.password" style="margin: 0 20rpx 0 0;" @click.stop="changInputType">
  46. <tui-icon :name="isShowEye ? 'unseen' : 'eye'" :size="22" color="#bfbfbf"></tui-icon>
  47. </view>
  48. <view class="" v-show="param.password" @click.stop="clearInput(2)">
  49. <tui-icon name="close-fill" :size="16" color="#bfbfbf" ></tui-icon>
  50. </view>
  51. </view>
  52. </tui-list-cell>
  53. </view>
  54. <view class="tui-btn-box">
  55. <tui-button type="primary" :disabledGray="true" :disabled="disabled" :shadow="true" shape="circle" @click="hanldeClick">登录</tui-button>
  56. </view>
  57. </view>
  58. </template>
  59. </view>
  60. </template>
  61. <script>
  62. import { mapMutations } from 'vuex'
  63. import authorize from '@/common/config/authorize.js'
  64. export default {
  65. computed: {
  66. disabled: function() {
  67. let bool = true
  68. if (this.param.mobile && this.param.password) {
  69. bool = false
  70. }
  71. return bool
  72. }
  73. },
  74. data() {
  75. return {
  76. CustomBar:this.CustomBar,// 顶部导航栏高度
  77. param:{
  78. code:null,
  79. encryptedData:null,
  80. iv:null ,
  81. mobile: '',
  82. password: '',
  83. },
  84. popupShow: false,
  85. passwordType:'password',
  86. skeletonShow:true,
  87. isShowEye:true
  88. }
  89. },
  90. onLoad(options) {
  91. },
  92. methods: {
  93. ...mapMutations(['login', 'logout']),
  94. async getWxAuthorize(){// 初始化授权登录
  95. try{
  96. const wXCode = await authorize.getCode('weixin')
  97. const wEchat = await authorize.getUserInfo('weixin')
  98. const param = { code: wXCode,encryptedData: wEchat.encryptedData,iv: wEchat.iv}
  99. const res = await this.UserService.UserLoginAuthApplets(param)
  100. const data = res.data
  101. this.login(data)
  102. this.$store.commit('updateStatus',data)
  103. setTimeout(()=>{
  104. this.navigateLink(data.userType)
  105. },500)
  106. }catch(error){
  107. this.logout()
  108. this.skeletonShow = false
  109. this.$store.commit('updateStatus',error.data)
  110. }
  111. },
  112. async UserLoginReceiptPassword(){// 账号密码登录
  113. const WxCode = await authorize.getCode('weixin')
  114. const Wx = await authorize.getUserInfo('weixin')
  115. this.param.code = WxCode
  116. this.param.iv = Wx.iv
  117. this.param.encryptedData = Wx.encryptedData
  118. this.UserService.UserLoginReceiptPassword(this.param).then(response =>{
  119. this.login(response.data)
  120. this.$store.commit('updateStatus',response.data)
  121. this.navigateLink(response.data.userType)
  122. }).catch(err =>{
  123. this.$util.msg(err.msg,2000)
  124. })
  125. },
  126. hanldeClick(){//点击登录
  127. this.UserLoginReceiptPassword()
  128. },
  129. navigateLink(userType){// 根据用户权限跳转对应页面
  130. /**
  131. * 用户类型 1服务商人员,2客服,3财务,4超级管理员
  132. * 1. 服务商人员跳转到收款列表页面
  133. * 2. 客服跳转到收款列表页面
  134. * 3. 财务人员跳转到款项识别页面
  135. * 4. 超级管理员跳转到款项识别页面
  136. * */
  137. switch(userType){
  138. case 1:
  139. this.$api.navigateTo('/pages/collection/list')
  140. break
  141. case 2:
  142. this.$api.navigateTo('/pages/collection/list')
  143. break
  144. case 3:
  145. this.$api.navigateTo('/pages/collection/sms')
  146. break
  147. case 4:
  148. this.$api.navigateTo('/pages/collection/sms')
  149. break
  150. }
  151. },
  152. changInputType(){// 控制显示密码
  153. this.isShowEye = !this.isShowEye
  154. },
  155. clearInput(type) {// 清除输入框信息
  156. if (type == 1) {
  157. this.param.mobile = ''
  158. } else {
  159. this.param.password = ''
  160. }
  161. }
  162. },
  163. onShow() {
  164. this.getWxAuthorize()
  165. }
  166. }
  167. </script>
  168. <style lang="scss">
  169. .container {
  170. .tui-status-bar {
  171. width: 100%;
  172. height: var(--status-bar-height);
  173. }
  174. .tui-header {
  175. width: 100%;
  176. padding: 40rpx;
  177. display: flex;
  178. align-items: center;
  179. justify-content: space-between;
  180. box-sizing: border-box;
  181. }
  182. .tui-page-title {
  183. width: 100%;
  184. font-size: 48rpx;
  185. font-weight: bold;
  186. color: $uni-text-color;
  187. line-height: 42rpx;
  188. padding: 40rpx;
  189. box-sizing: border-box;
  190. }
  191. .tui-form {
  192. padding-top: 50rpx;
  193. .tui-view-input {
  194. width: 100%;
  195. box-sizing: border-box;
  196. padding: 0 40rpx;
  197. .tui-cell-input {
  198. width: 100%;
  199. display: flex;
  200. align-items: center;
  201. padding-top: 48rpx;
  202. padding-bottom: $uni-spacing-col-base;
  203. input {
  204. flex: 1;
  205. padding-left: $uni-spacing-row-base;
  206. }
  207. .tui-icon-close {
  208. margin-left: auto;
  209. }
  210. }
  211. }
  212. .tui-cell-text {
  213. width: 100%;
  214. padding: $uni-spacing-col-lg $uni-spacing-row-lg;
  215. box-sizing: border-box;
  216. font-size: $uni-font-size-sm;
  217. color: $uni-text-color-grey;
  218. display: flex;
  219. align-items: center;
  220. justify-content: space-between;
  221. .tui-color-primary {
  222. color: $uni-color-primary;
  223. }
  224. }
  225. .tui-btn-box {
  226. width: 100%;
  227. padding: 0 $uni-spacing-row-lg;
  228. box-sizing: border-box;
  229. margin-top: 80rpx;
  230. }
  231. }
  232. .tui-login-way {
  233. width: 100%;
  234. font-size: 26rpx;
  235. color: $uni-color-primary;
  236. display: flex;
  237. justify-content: center;
  238. position: fixed;
  239. left: 0;
  240. bottom: 80rpx;
  241. view {
  242. padding: 12rpx 0;
  243. }
  244. }
  245. .tui-auth-login {
  246. width: 100%;
  247. display: flex;
  248. align-items: center;
  249. justify-content: center;
  250. padding-bottom: 80rpx;
  251. padding-top: 20rpx;
  252. .tui-icon-platform {
  253. width: 90rpx;
  254. height: 90rpx;
  255. display: flex;
  256. align-items: center;
  257. justify-content: center;
  258. position: relative;
  259. margin-left: 40rpx;
  260. &::after {
  261. content: '';
  262. position: absolute;
  263. width: 200%;
  264. height: 200%;
  265. transform-origin: 0 0;
  266. transform: scale(0.5, 0.5) translateZ(0);
  267. box-sizing: border-box;
  268. left: 0;
  269. top: 0;
  270. border-radius: 180rpx;
  271. border: 1rpx solid $uni-text-color-placeholder;
  272. }
  273. }
  274. .tui-login-logo {
  275. width: 60rpx;
  276. height: 60rpx;
  277. }
  278. }
  279. }
  280. </style>