login-account.vue 7.2 KB

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