login-account.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  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. const WxCode = await authorize.getCode('weixin')
  96. const Wx = await authorize.getUserInfo('weixin')
  97. this.UserService.UserLoginAuthApplets({
  98. code:WxCode,
  99. encryptedData:Wx.encryptedData,
  100. iv:Wx.iv ,
  101. })
  102. .then(response =>{
  103. let data = response.data
  104. this.login(response.data)
  105. this.$store.commit('updateStatus',response.data)
  106. setTimeout(()=>{
  107. this.navigateLink(response.data.userType)
  108. },500)
  109. }).catch(error =>{
  110. this.logout()
  111. this.skeletonShow = false
  112. this.$store.commit('updateStatus',error.data)
  113. })
  114. },
  115. async UserLoginReceiptPassword(){// 账号密码登录
  116. const WxCode = await authorize.getCode('weixin')
  117. const Wx = await authorize.getUserInfo('weixin')
  118. this.param.code = WxCode
  119. this.param.iv = Wx.iv
  120. this.param.encryptedData = Wx.encryptedData
  121. this.UserService.UserLoginReceiptPassword(this.param).then(response =>{
  122. this.login(response.data)
  123. this.$store.commit('updateStatus',response.data)
  124. this.navigateLink(response.data.userType)
  125. }).catch(err =>{
  126. this.$util.msg(err.msg,2000)
  127. })
  128. },
  129. hanldeClick(){//点击登录
  130. this.UserLoginReceiptPassword()
  131. },
  132. navigateLink(userType){// 根据用户权限跳转对应页面
  133. /**
  134. * 用户类型 1协销人员,2客服,3财务,4超级管理员
  135. * 1. 协销人员跳转到收款列表页面
  136. * 2. 客服跳转到收款列表页面
  137. * 3. 财务人员跳转到款项识别页面
  138. * 4. 超级管理员跳转到款项识别页面
  139. * */
  140. switch(userType){
  141. case 1:
  142. this.$api.navigateTo('/pages/collection/list')
  143. break
  144. case 2:
  145. this.$api.navigateTo('/pages/collection/list')
  146. break
  147. case 3:
  148. this.$api.navigateTo('/pages/collection/sms')
  149. break
  150. case 4:
  151. this.$api.navigateTo('/pages/collection/sms')
  152. break
  153. }
  154. },
  155. changInputType(){// 控制显示密码
  156. this.isShowEye = !this.isShowEye
  157. },
  158. clearInput(type) {// 清除输入框信息
  159. if (type == 1) {
  160. this.param.mobile = ''
  161. } else {
  162. this.param.password = ''
  163. }
  164. }
  165. },
  166. onShow() {
  167. this.getWxAuthorize()
  168. }
  169. }
  170. </script>
  171. <style lang="scss">
  172. .container {
  173. .tui-status-bar {
  174. width: 100%;
  175. height: var(--status-bar-height);
  176. }
  177. .tui-header {
  178. width: 100%;
  179. padding: 40rpx;
  180. display: flex;
  181. align-items: center;
  182. justify-content: space-between;
  183. box-sizing: border-box;
  184. }
  185. .tui-page-title {
  186. width: 100%;
  187. font-size: 48rpx;
  188. font-weight: bold;
  189. color: $uni-text-color;
  190. line-height: 42rpx;
  191. padding: 40rpx;
  192. box-sizing: border-box;
  193. }
  194. .tui-form {
  195. padding-top: 50rpx;
  196. .tui-view-input {
  197. width: 100%;
  198. box-sizing: border-box;
  199. padding: 0 40rpx;
  200. .tui-cell-input {
  201. width: 100%;
  202. display: flex;
  203. align-items: center;
  204. padding-top: 48rpx;
  205. padding-bottom: $uni-spacing-col-base;
  206. input {
  207. flex: 1;
  208. padding-left: $uni-spacing-row-base;
  209. }
  210. .tui-icon-close {
  211. margin-left: auto;
  212. }
  213. }
  214. }
  215. .tui-cell-text {
  216. width: 100%;
  217. padding: $uni-spacing-col-lg $uni-spacing-row-lg;
  218. box-sizing: border-box;
  219. font-size: $uni-font-size-sm;
  220. color: $uni-text-color-grey;
  221. display: flex;
  222. align-items: center;
  223. justify-content: space-between;
  224. .tui-color-primary {
  225. color: $uni-color-primary;
  226. }
  227. }
  228. .tui-btn-box {
  229. width: 100%;
  230. padding: 0 $uni-spacing-row-lg;
  231. box-sizing: border-box;
  232. margin-top: 80rpx;
  233. }
  234. }
  235. .tui-login-way {
  236. width: 100%;
  237. font-size: 26rpx;
  238. color: $uni-color-primary;
  239. display: flex;
  240. justify-content: center;
  241. position: fixed;
  242. left: 0;
  243. bottom: 80rpx;
  244. view {
  245. padding: 12rpx 0;
  246. }
  247. }
  248. .tui-auth-login {
  249. width: 100%;
  250. display: flex;
  251. align-items: center;
  252. justify-content: center;
  253. padding-bottom: 80rpx;
  254. padding-top: 20rpx;
  255. .tui-icon-platform {
  256. width: 90rpx;
  257. height: 90rpx;
  258. display: flex;
  259. align-items: center;
  260. justify-content: center;
  261. position: relative;
  262. margin-left: 40rpx;
  263. &::after {
  264. content: '';
  265. position: absolute;
  266. width: 200%;
  267. height: 200%;
  268. transform-origin: 0 0;
  269. transform: scale(0.5, 0.5) translateZ(0);
  270. box-sizing: border-box;
  271. left: 0;
  272. top: 0;
  273. border-radius: 180rpx;
  274. border: 1rpx solid $uni-text-color-placeholder;
  275. }
  276. }
  277. .tui-login-logo {
  278. width: 60rpx;
  279. height: 60rpx;
  280. }
  281. }
  282. }
  283. </style>