register.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518
  1. <template>
  2. <view class="container">
  3. <u-icon class="back-btn" name="arrow-left" color="black" size="20" @click="navBack"></u-icon>
  4. <view class="wrapper">
  5. <h2 class="Semibold">手机号注册</h2>
  6. <view style='width:100%;margin-top:50px;border-bottom:1px solid #E8E9ED;padding:10px;position:relative;'
  7. class="flex">
  8. <view class="NumberMedium" style='width:15%;border-right:1px solid #E8E9ED;'>+86</view>
  9. <view style='width:85%;'>
  10. <!-- <u-input border="none" maxlength="11" v-model='phone' @input='phoneinput' style='padding-left:10px;'
  11. placeholder="请输入手机号码" type="number" class="Regular" /> -->
  12. <input placeholder-style="color:#AFB3BF" border="none" maxlength="11" v-model='phone' @input='phoneinput' style='padding-left:10px;'
  13. placeholder="请输入手机号码" type="number" class="Regular" />
  14. </view>
  15. <!-- <image v-if='phone!=""' @click='phone=""' class='close' src='../../static/img/login/guanbi@2x.png'></image> -->
  16. </view>
  17. <view style='width:100%;border-bottom:1px solid #E8E9ED;position:relative;padding:10px;' class="flex">
  18. <view style='width:70%;position:relative;'>
  19. <!-- <u-input border="none" v-model='verifyCode' class="Regular" placeholder="请输入验证码" type="number" maxlength="6" />
  20. -->
  21. <input placeholder-style="color:#AFB3BF" border="none" maxlength="6" v-model='verifyCode' style='padding-left:10px;'
  22. placeholder="请输入验证码" type="number" class="Regular" /><!-- <image v-if='verifyCode' @click='verifyCode=""' class='close1' src='../../static/img/login/guanbi@2x.png'></image> -->
  23. </view>
  24. <button :class='codestatus&&!sendDisabled?"active":""' @click='getcode'
  25. class='getcode Regular'>{{sendText}}</button>
  26. </view>
  27. <view style='border-bottom:1px solid #E8E9ED;padding:10px;position:relative;'>
  28. <!-- <u-input border="none" maxlength='16' class='Regular input-style' style='height:30px;'
  29. v-model='password' placeholder="请输入密码,6-16位字符" :type="type" /> -->
  30. <input placeholder-style="color:#AFB3BF" border="none" maxlength="16" v-model='password' style='padding-left:10px;'
  31. placeholder="请输入密码,6-16位字符" :type="type" class="Regular input-style" />
  32. <!-- <input maxlength='16' class='password Regular input-style' style='height:30px;' v-model='password' placeholder="请输入密码,6-16位字符" :type="type"> -->
  33. <!-- <image v-if='password!=""' @click='password=""' class='close2' src='../../static/img/login/guanbi@2x.png'></image> -->
  34. <!-- <view @click='switchover' style='position:absolute;right:0;top:38%;z-index:10;cursor:pointer;' class="iconfont " :class='type=="password"?"icon-yanjing-biyan":"icon-yanjing-zhengyan"'></view> -->
  35. </view>
  36. <button :class='phone!=""&&verifyCode!=""&&password!=""?"active":""' @click='register'
  37. class='verificationCode'>注册</button>
  38. <view
  39. style='color:#6A6A6A;margin-top:10px;font-size:30rpx;display:flex;justify-content:center;align-items: center;'>
  40. <u--image style='margin-right:3px;position:relative;top:1rpx;' @click='consent'
  41. :src="consentStatus==true?'../../static/images/mine/duihao@2x.png':'../../static/images/mine/wxz.png'"
  42. width="17px" height="17px"></u--image>
  43. 已阅读并同意
  44. <navigator
  45. url="/pages/sale/webview?can_share=false&url=https://liangxin.zthymaoyi.com/userAgreement.html"
  46. class="path" hover-class="navigator-hover">《服务协议》</navigator>和<navigator
  47. url="/pages/sale/webview?can_share=false&url=https://liangxin.zthymaoyi.com/screctAgreement.html"
  48. class="path" hover-class="navigator-hover">《隐私政策》</navigator>
  49. </view>
  50. </view>
  51. </view>
  52. </template>
  53. <script>
  54. import {
  55. mapMutations
  56. } from 'vuex';
  57. import {
  58. openFSqlite,
  59. createFSQL,
  60. selectFSQL,
  61. addFSQL
  62. } from '../../util/f.js'
  63. import helper from '@/common/helper.js';
  64. import {
  65. queryData,
  66. upData,
  67. initData
  68. } from '../../util/dbUtil.js'
  69. export default {
  70. data() {
  71. return {
  72. inputContent: null,
  73. loginType: "wechat",
  74. phone: '',
  75. password: '',
  76. logining: false,
  77. isPhone: false,
  78. isApple: true,
  79. accessToken: '',
  80. params: {
  81. encryptedData: '',
  82. session_key: '',
  83. iv: '',
  84. },
  85. userInfo: {
  86. nickName: '',
  87. avatarUrl: '',
  88. gender: '',
  89. phone: ''
  90. },
  91. consentStatus: false,
  92. codestatus: false,
  93. type: 'password',
  94. inputStatus: 'none',
  95. verifyCode: null,
  96. sendText: '获取验证码',
  97. sendDisabled: false,
  98. system: '',
  99. platform: '',
  100. canIUseProfile: false
  101. }
  102. },
  103. onShow() {
  104. // this.loginType = "wechat"
  105. // this.$api.logout()
  106. },
  107. onLoad(options) {
  108. if (wx.getUserProfile) {
  109. console.log('--check getUserProfile--OK');
  110. this.canIUseProfile = true;
  111. }
  112. console.log("login on load")
  113. var that = this
  114. // that.$api.request('user', 'sendIsApple', {}).then(res => {
  115. // that.isApple = res.data
  116. // })
  117. // uni.getSystemInfo({
  118. // success: (res) => {
  119. // // console.log(res)
  120. // this.system = res.system // ios
  121. // this.platform = res.platform // 14.3
  122. // }
  123. // })
  124. },
  125. methods: {
  126. // 随机数
  127. randomAccess(min, max) {
  128. return Math.floor(Math.random() * (min - max) + max)
  129. },
  130. // 解码
  131. decodeUnicode(str) {
  132. //Unicode显示方式是\u4e00
  133. str = "\\u" + str
  134. str = str.replace(/\\/g, "%");
  135. //转换中文
  136. str = unescape(str);
  137. //将其他受影响的转换回原来
  138. str = str.replace(/%/g, "\\");
  139. return str;
  140. },
  141. /*
  142. *@param Number NameLength 要获取的名字长度
  143. */
  144. getRandomName(NameLength) {
  145. let name = ""
  146. for (let i = 0; i < NameLength; i++) {
  147. let unicodeNum = ""
  148. unicodeNum = this.randomAccess(0x4e00, 0x9fa5).toString(16)
  149. name += this.decodeUnicode(unicodeNum)
  150. }
  151. return name
  152. },
  153. phoneinput(e) {
  154. if (e.detail.value.length == 11) {
  155. this.codestatus = true
  156. }else{
  157. this.codestatus = false
  158. }
  159. },
  160. getcode() {
  161. var that = this
  162. if(that.sendText != "获取验证码"){
  163. return
  164. }
  165. if (/^0?1[3|4|5|6|7|8][0-9]\d{8}$/.test(this.phone)) {
  166. that.$request.baseRequest('get', '/commonUser/sendVerifyCode', {
  167. phone: this.phone
  168. }).then(res => {
  169. console.log(2222222)
  170. if (res.code == 200) {
  171. console.log(1121212)
  172. that.sendDisabled = true
  173. let sec = 60
  174. let interval = setInterval(() => {
  175. sec--;
  176. that.sendText = sec + 's后重发'
  177. if (sec <= 0) {
  178. that.sendDisabled = false
  179. that.sendText = "获取验证码"
  180. clearInterval(interval)
  181. }
  182. }, 1000)
  183. } else {
  184. uni.showToast({
  185. title: res.message,
  186. icon: 'none',
  187. duration: 2000
  188. })
  189. }
  190. })
  191. .catch(res => {
  192. uni.showToast({
  193. title: res.data.message,
  194. icon: 'none',
  195. duration: 2000
  196. })
  197. });
  198. } else {
  199. uni.showToast({
  200. title: '请输入正确的手机号',
  201. icon: 'none',
  202. duration: 2000
  203. })
  204. }
  205. },
  206. register() {
  207. var that = this
  208. if (!this.consentStatus) {
  209. uni.showToast({
  210. title: '请勾选协议',
  211. icon: 'none',
  212. duration: 2000
  213. })
  214. return
  215. }
  216. if (!this.phone) {
  217. uni.showToast({
  218. title: '手机号不能为空',
  219. icon: 'none',
  220. duration: 2000
  221. })
  222. return
  223. }
  224. if (!this.verifyCode) {
  225. uni.showToast({
  226. title: '验证码不能为空',
  227. icon: 'none',
  228. duration: 2000
  229. })
  230. return
  231. }
  232. if (!this.password) {
  233. uni.showToast({
  234. title: '密码不能为空',
  235. icon: 'none',
  236. duration: 2000
  237. })
  238. return
  239. }
  240. if (this.verifyCode.length != 6) {
  241. uni.showToast({
  242. title: '验证码错误',
  243. icon: 'none',
  244. duration: 2000
  245. })
  246. return
  247. }
  248. if (this.password.length < 6) {
  249. uni.showToast({
  250. title: '密码输入错误',
  251. icon: 'none',
  252. duration: 2000
  253. })
  254. return
  255. }
  256. var username = this.getRandomName(3)
  257. that.$request.baseRequest('post', '/commonUser/register', {
  258. phone: this.phone,
  259. password: this.password,
  260. verifyCode: this.verifyCode,
  261. userName: username,
  262. identification:1,//司机标识
  263. avatarUrl:"https://taohaoliang.oss-cn-beijing.aliyuncs.com/appData/1656724567954127.png"//司机默认头像
  264. }).then(res => {
  265. if (res.code == '11003') {
  266. uni.showToast({
  267. title: res.message,
  268. icon: 'none',
  269. duration: 2000
  270. })
  271. return
  272. } else if (res.code == '11004') {
  273. uni.showToast({
  274. title: '该手机号已注册,可直接登录',
  275. icon: 'none',
  276. duration: 2000
  277. })
  278. return
  279. } else {
  280. uni.showLoading({
  281. title: '登录中',
  282. mask: true
  283. })
  284. that.$request.baseRequest('get', '/commonUser/login', {
  285. phone: this.phone,
  286. password: this.password,
  287. loginFlag: 2,
  288. identification:1 //司机标识
  289. }).then(res => {
  290. if (res.code == 200) {
  291. uni.setStorageSync("shiro",encodeURIComponent(`ws_login_companyShortName=
  292. '黑龙江中天昊元贸易有限公司'; ws_login_rememberMe=1; ws_login_account=${that.phone}; ws_login_pwd=${that.password}; shiro.session=65500189-7bb5-457f-9ff6-0db069150e78`))
  293. // // pc登录
  294. // that.$request.baseRequest('post', '/commonUser/api/loginQuickly', {
  295. // mobilePhone: this.phone,
  296. // veriCode: "123456",
  297. // }).then(res1 => {
  298. // if (res1.code == 200) {
  299. // uni.setStorageSync('pcUserInfo', res1.data)
  300. // helper.getListByUserId()
  301. // } else {
  302. // that.$api.doRequest('post',
  303. // '/commonUser/api/loginQuickly', {
  304. // mobilePhone: '14444444444',
  305. // veriCode: "123456",
  306. // }).then(res2 => {
  307. // uni.setStorageSync('pcUserInfo', res2
  308. // .data)
  309. // helper.getListByUserId()
  310. // })
  311. // }
  312. // })
  313. uni.setStorageSync('userInfo', res.data)
  314. that.$store.commit('login', res.data)
  315. uni.switchTab({
  316. url: '/pages/goodSource/index'
  317. });
  318. } else {
  319. uni.showToast({
  320. title: res.message,
  321. icon: 'none',
  322. duration: 2000
  323. })
  324. }
  325. uni.hideLoading()
  326. })
  327. .catch(res => {
  328. uni.hideLoading()
  329. console.log(res);
  330. });
  331. }
  332. })
  333. .catch(res => {
  334. uni.hideLoading()
  335. console.log(res);
  336. });
  337. },
  338. consent() {
  339. this.consentStatus = !this.consentStatus
  340. uni.setStorage({
  341. key: 'policyStorageKey',
  342. data: this.consentStatus
  343. });
  344. },
  345. switchover() {
  346. if (this.type == 'password') {
  347. this.type = 'text'
  348. } else {
  349. this.type = 'password'
  350. }
  351. },
  352. ...mapMutations(['login']),
  353. navBack() {
  354. uni.navigateBack();
  355. },
  356. },
  357. }
  358. </script>
  359. <style lang='scss' scoped>
  360. uni-navigator {
  361. display: inline-block;
  362. color: #2772FB;
  363. }
  364. .password {
  365. border: none;
  366. outline: none;
  367. }
  368. .apple {
  369. background: #000;
  370. width: 35px;
  371. height: 35px;
  372. padding: 8px;
  373. border-radius: 50%;
  374. vertical-align: middle;
  375. }
  376. page {
  377. background: #fff;
  378. }
  379. .cuIcon-weixin {
  380. background: #2772FB;
  381. color: #fff;
  382. font-size: 18px;
  383. padding: 9px;
  384. border-radius: 50%;
  385. vertical-align: middle;
  386. margin-right: 5px;
  387. }
  388. .container {
  389. padding-top: 85px;
  390. position: relative;
  391. width: 100vw;
  392. height: calc(100vh - 85px);
  393. overflow: hidden;
  394. background: url('~@/static/images/mine/bg@2x.png');
  395. background-size: 100%;
  396. }
  397. .close {
  398. width: 20px;
  399. height: 20px;
  400. position: absolute;
  401. right: 0px;
  402. }
  403. .close1 {
  404. width: 20px;
  405. height: 20px;
  406. position: absolute;
  407. right: 10px;
  408. top: 0;
  409. }
  410. .close2 {
  411. width: 15px;
  412. height: 15px;
  413. position: absolute;
  414. right: 19px;
  415. top: 50%;
  416. transform: translateY(-45%);
  417. }
  418. .wrapper {
  419. position: relative;
  420. z-index: 90;
  421. padding-bottom: 40upx;
  422. height: 100%;
  423. padding: 0 30px;
  424. }
  425. .back-btn {
  426. position: absolute;
  427. left: 40upx;
  428. z-index: 9999;
  429. padding-top: var(--status-bar-height);
  430. top: 40upx;
  431. font-size: 40upx;
  432. color: black;
  433. }
  434. .verificationCode {
  435. margin-top: 20px;
  436. background: #F5F6F9;
  437. color: #AFB3BF;
  438. }
  439. .verificationCode:after {
  440. border: none;
  441. }
  442. .register {
  443. position: absolute;
  444. bottom: 20px;
  445. left: 50%;
  446. transform: translateX(-50%);
  447. color: #333333;
  448. height: 50px;
  449. line-height: 50px;
  450. border-radius: 30px;
  451. border: 1px solid #444444;
  452. }
  453. .register:after {
  454. border: none;
  455. }
  456. .verificationCode.active {
  457. background: #2772FB;
  458. color: #fff;
  459. }
  460. .getcode {
  461. font-size: 14px;
  462. position: absolute;
  463. right: 0;
  464. top: 50%;
  465. transform: translateY(-50%);
  466. color: #AFB3BF;
  467. background: #F5F6F9;
  468. height: 30px;
  469. line-height: 30px;
  470. }
  471. .getcode:after {
  472. border: none;
  473. }
  474. uni-navigator {
  475. display: inline-block;
  476. color: #2772FB;
  477. }
  478. .getcode.active {
  479. background: #2772FB;
  480. color: #fff;
  481. }
  482. .NumberMedium {
  483. display: flex;
  484. align-items: center;
  485. }
  486. .flex {
  487. align-items: center;
  488. }
  489. </style>