login.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376
  1. <template>
  2. <view class="app">
  3. <view>
  4. <view class="logo">
  5. 源代宝系统
  6. </view>
  7. <view class="tabs">
  8. <!-- <text :class="loginType == 1 ? 'cur' : ''" @click="loginType = 1; error='';">密码登录</text> -->
  9. <!-- <text :class="loginType == 2 ? 'cur' : ''" @click="loginType = 2; error='';">手机号登录</text> -->
  10. </view>
  11. <block v-if="loginType == 1">
  12. <view class="form-item">
  13. <text class="label">手机号</text>
  14. <view class="intput-area">
  15. <input type="number" placeholder="请填写手机号" v-model="mobile" />
  16. </view>
  17. </view>
  18. <view class="form-item">
  19. <view class="label">密码 <!--text class="icon-eye"></text--></view>
  20. <view class="intput-area">
  21. <input type="password" placeholder="请输入密码" v-model="pass" />
  22. <!-- <text>忘记密码</text> -->
  23. </view>
  24. </view>
  25. </block>
  26. <block v-else>
  27. <view class="form-item">
  28. <text class="label">手机号</text>
  29. <view class="intput-area">
  30. <input type="number" placeholder="请填写手机号" v-model="mobile" />
  31. </view>
  32. </view>
  33. <view class="form-item">
  34. <text class="label">验证码</text>
  35. <view class="intput-area">
  36. <input type="number" placeholder="请输入验证码" v-model="code" />
  37. <text v-if="!mobileValiting" class="enable" @click="getCode">获取验证码</text>
  38. <text v-if="mobileValiting" class="disabled">重新发送({{timelimit}})</text>
  39. </view>
  40. </view>
  41. </block>
  42. <view class="err-tips" v-if="error">
  43. {{error}}
  44. </view>
  45. <view class="flex flex-direction zaiui-btn-view" style="margin-top: 20upx;">
  46. <view class="cu-btn bg-red" @click="doLogin">
  47. 登录
  48. </view>
  49. </view>
  50. </view>
  51. <!-- <view class="button" @click="pay">
  52. 支付测试
  53. </view> -->
  54. <view class="xieyi">
  55. <text class="icon-checkbox checked"></text>我已阅读并同意<navigator url="/pages/assets/singlepage/singlepage?id=service" class="link">《用户服务协议》</navigator>和<navigator url="/pages/assets/singlepage/singlepage?id=yinsizhengce" class="link">《隐私政策》</navigator>
  56. </view>
  57. <!-- <iframe :src="payurl" ></iframe> -->
  58. </view>
  59. </template>
  60. <script>
  61. import {
  62. mapState,
  63. mapMutations,
  64. mapActions
  65. } from 'vuex'
  66. export default {
  67. data() {
  68. return {
  69. loginType: 2,
  70. code: '',
  71. mobile: '',
  72. error: '',
  73. mobileValiting: 0,
  74. countdownStart: 0,
  75. timelimit: 60,
  76. pass: '',
  77. payurl: '',
  78. suser: ''
  79. };
  80. },
  81. methods: {
  82. ...mapMutations(['setUserInfo']),
  83. pay() {
  84. this.req({
  85. url: 'service/agent/?l=auth.reg&sign=http%3A%2F%2Fzsmatest.nongxiaohe.com%2Fdata%2Fupload%2F9%2F2022%2F03%2F25%2F25ff280b871c75ba618666c43c1dcd6a.png&type=1&idcard=140224198312254712&name=qinj&idcard_back=http%3A%2F%2Fzsmatest.nongxiaohe.com%2Fdata%2Fupload%2F9%2F2022%2F02%2F26%2F734611c162a9606a5f947734d303658c.png&idcard_front=http%3A%2F%2Fzsmatest.nongxiaohe.com%2Fdata%2Fupload%2F9%2F2022%2F02%2F26%2F734611c162a9606a5f947734d303658c.png&code=1060&mobile=17316135130&company_name=&company_number=&company_pic=&area=110000%2C110100&role=6&code=&source_id=&pay_pic=&pay_type=1',
  86. data: {
  87. refer: location.origin + '/pages/dailishang/apply/success' //'http://daili.churenyiliao.com/pages/dailishang/apply/success'
  88. },
  89. success: res => {
  90. if(res.data.status == 1) {
  91. console.log(res.data.data.pay.order)
  92. location.href = res.data.data.pay.order;
  93. }else {
  94. this.error = res.data.msg
  95. }
  96. }
  97. })
  98. },
  99. countDown() {
  100. this.timelimit = 60 - Math.floor((Date.now() - this.countdownStart)/1000);
  101. if(this.timelimit > 0) {
  102. setTimeout(() => {
  103. this.countDown()
  104. }, 500)
  105. }else {
  106. this.mobileValiting = false;
  107. }
  108. },
  109. getCode() {
  110. uni.showLoading({
  111. mask: true
  112. })
  113. this.req({
  114. url: '?l=data.sms',
  115. data: {
  116. mobile: this.mobile.trim(),
  117. },
  118. success: res => {
  119. if(res.data.status == 1) {
  120. this.error = '';
  121. this.mobileValiting = 1;
  122. this.countdownStart = Date.now()
  123. this.countDown()
  124. let code = res.data.data.match(/::(\d*)/);
  125. this.code = code ? code[1] : '';
  126. }else {
  127. this.error = res.data.msg
  128. }
  129. uni.hideLoading()
  130. }
  131. })
  132. },
  133. doLogin() {
  134. let reqParams = {
  135. mobile: this.mobile.trim(),
  136. account: 'wechat',
  137. env: 2,
  138. applet_code: '',
  139. invite: '88151'
  140. };
  141. if(!this.mobile || !/^1\d{10}$/.test(this.mobile.trim())) {
  142. uni.showToast({
  143. icon: 'error',
  144. title: '手机号码不正确'
  145. })
  146. return
  147. }
  148. if(this.loginType == 1) {
  149. reqParams.pass = this.pass;
  150. if(!this.pass) {
  151. uni.showToast({
  152. icon: 'error',
  153. title: '请输入密码'
  154. })
  155. return
  156. }
  157. } else {
  158. reqParams.code = this.code;
  159. if(!this.code) {
  160. uni.showToast({
  161. icon: 'error',
  162. title: '请输入验证码'
  163. })
  164. return
  165. }
  166. }
  167. console.log(reqParams)
  168. this.req({
  169. url: '?l=data.login',
  170. data: reqParams,
  171. success: res => {
  172. if(res.data.status == 1) {
  173. uni.setStorage({
  174. key: 'baseToken',
  175. data: {
  176. t: res.data.data.t,
  177. mobile: this.mobile.trim()
  178. }
  179. })
  180. this.setUserInfo({
  181. t: res.data.data.t,
  182. mobile: this.mobile.trim()
  183. })
  184. this.code = ''
  185. this.mobile = ''
  186. this.error = ''
  187. this.pass = ''
  188. if (res.data.data.t) {
  189. if(getCurrentPages().length < 2) {
  190. uni.reLaunch({
  191. url: `/pages/app/index`
  192. })
  193. } else {
  194. uni.navigateBack({
  195. success: function () {
  196. getCurrentPages().forEach(page => {
  197. typeof page.$vm.globalLoginedCallback === "function" && page.$vm.globalLoginedCallback()
  198. })
  199. }
  200. })
  201. }
  202. }
  203. }else {
  204. this.error = res.data.msg
  205. }
  206. }
  207. })
  208. }
  209. },
  210. onLoad() {
  211. if(this.userInfo.t) {
  212. uni.switchTab({
  213. url: '/pages/app/index'
  214. })
  215. }
  216. }
  217. }
  218. </script>
  219. <style lang="scss">
  220. // @import '../../../common/common.scss';
  221. </style>
  222. <style lang="scss">
  223. page {
  224. height: 100%;
  225. background-color: #F7F7F7;
  226. display: flex;
  227. flex-direction: column;
  228. }
  229. .app {
  230. flex: 1;
  231. box-sizing: border-box;
  232. padding: 0 48upx;
  233. display: flex;
  234. flex-direction: column;
  235. justify-content: space-between;
  236. .logo {
  237. padding: 62upx 0 108upx;
  238. margin: 0 auto;
  239. display: flex;
  240. justify-content: center;
  241. align-items: center;
  242. color: #e54d42;
  243. font-size: 52upx;
  244. letter-spacing: 1upx;
  245. image {
  246. width: 80upx;
  247. height: 80upx;
  248. display: block;
  249. margin-right: 24upx;
  250. }
  251. }
  252. .tabs {
  253. display: flex;
  254. align-items: center;
  255. justify-content: center;
  256. padding-bottom: 42upx;
  257. text {
  258. position: relative;
  259. font-size: 32upx;
  260. margin: 0 32upx;
  261. display: flex;
  262. flex-direction: column;
  263. align-items: center;
  264. &:after {
  265. content: '';
  266. width: 40upx;
  267. height: 6upx;
  268. margin-top: 8upx;
  269. border-radius: 2upx;
  270. background-color: transparent;
  271. }
  272. &.cur {
  273. color: #e54d42;
  274. &:after {
  275. background-color: #e54d42;
  276. }
  277. }
  278. }
  279. }
  280. }
  281. .form-item {
  282. position: relative;
  283. display: flex;
  284. flex-direction: column;
  285. box-sizing: border-box;
  286. border-bottom: 2upx solid #999999;
  287. padding: 38upx 0 0;
  288. .label {
  289. width: 100%;
  290. color: #444444;
  291. font-size: 28upx;
  292. font-family: PingFangSC-Medium, PingFang SC;
  293. display: flex;
  294. justify-content: space-between;
  295. align-items: center;
  296. font-weight: bolder;
  297. text {
  298. opacity: 0.4;
  299. &.light {
  300. opacity: 1;
  301. }
  302. }
  303. }
  304. .intput-area {
  305. display: flex;
  306. justify-content: space-between;
  307. font-size: 26upx;
  308. line-height: 106upx;
  309. input {
  310. height: 106upx;
  311. flex: 1;
  312. font-size: 54upx;
  313. font-family: DINAlternate-Bold, DINAlternate;
  314. }
  315. .uni-input-placeholder {
  316. font-size: 28upx;
  317. }
  318. }
  319. text {
  320. color: #999999;
  321. &.enable {
  322. color: #e54d42;
  323. }
  324. }
  325. }
  326. .err-tips {
  327. color: #AB0000;
  328. font-size: 24upx;
  329. display: block;
  330. margin-top: 24upx;
  331. }
  332. .ctrls {
  333. margin-top: 100upx;
  334. display: flex;
  335. justify-content: space-between;
  336. box-sizing: border-box;
  337. .button {
  338. flex: 1;
  339. margin: 0 15upx;
  340. white-space: nowrap;
  341. }
  342. }
  343. .xieyi {
  344. // position: absolute;
  345. // bottom: 32upx;
  346. // left: 48upx;
  347. // right: 48upx;
  348. margin: 64upx 0 32upx;
  349. display: flex;
  350. align-items: center;
  351. justify-content: center;
  352. white-space: nowrap;
  353. .link {
  354. color: #e54d42;
  355. }
  356. .icon-checkbox {
  357. margin-right: 8upx;
  358. }
  359. }
  360. </style>