register.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489
  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 (/^0?1[3|4|5|6|7|8][0-9]\d{8}$/.test(this.phone)) {
  163. that.$request.baseRequest('get', '/commonUser/sendVerifyCode', {
  164. phone: this.phone
  165. }).then(res => {
  166. console.log(2222222)
  167. if (res.code == 200) {
  168. console.log(1121212)
  169. that.sendDisabled = true
  170. let sec = 60
  171. let interval = setInterval(() => {
  172. sec--;
  173. that.sendText = sec + 's后重发'
  174. if (sec <= 0) {
  175. that.sendDisabled = false
  176. that.sendText = "获取验证码"
  177. clearInterval(interval)
  178. }
  179. }, 1000)
  180. } else {
  181. uni.showToast({
  182. title: res.message,
  183. icon: 'none',
  184. duration: 2000
  185. })
  186. }
  187. })
  188. .catch(res => {
  189. uni.showToast({
  190. title: res.data.message,
  191. icon: 'none',
  192. duration: 2000
  193. })
  194. });
  195. } else {
  196. uni.showToast({
  197. title: '请输入正确的手机号',
  198. icon: 'none',
  199. duration: 2000
  200. })
  201. }
  202. },
  203. register() {
  204. var that = this
  205. if (!this.consentStatus) {
  206. uni.showToast({
  207. title: '请勾选协议',
  208. icon: 'none',
  209. duration: 2000
  210. })
  211. return
  212. }
  213. if (this.verifyCode.length != 6) {
  214. uni.showToast({
  215. title: '验证码错误',
  216. icon: 'none',
  217. duration: 2000
  218. })
  219. return
  220. }
  221. if (this.password.length < 6) {
  222. uni.showToast({
  223. title: '密码请输入6-16字符格式',
  224. icon: 'none',
  225. duration: 2000
  226. })
  227. return
  228. }
  229. var username = this.getRandomName(3)
  230. that.$request.baseRequest('post', '/commonUser/register', {
  231. phone: this.phone,
  232. password: this.password,
  233. verifyCode: this.verifyCode,
  234. userName: username,
  235. identification:1,//司机标识
  236. avatarUrl:"https://taohaoliang.oss-cn-beijing.aliyuncs.com/appData/1656724567954127.png"//司机默认头像
  237. }).then(res => {
  238. if (res.code == '11002') {
  239. uni.showToast({
  240. title: '验证码错误或过期,请重新获取',
  241. icon: 'none',
  242. duration: 2000
  243. })
  244. return
  245. } else if (res.code == '11004') {
  246. uni.showToast({
  247. title: '该手机号已注册,可直接登录',
  248. icon: 'none',
  249. duration: 2000
  250. })
  251. return
  252. } else {
  253. uni.showLoading({
  254. title: '登录中',
  255. mask: true
  256. })
  257. that.$request.baseRequest('get', '/commonUser/login', {
  258. phone: this.phone,
  259. password: this.password,
  260. loginFlag: 2,
  261. identification:1 //司机标识
  262. }).then(res => {
  263. if (res.code == 200) {
  264. uni.setStorageSync("shiro",encodeURIComponent(`ws_login_companyShortName=
  265. '黑龙江中天昊元贸易有限公司'; ws_login_rememberMe=1; ws_login_account=${that.phone}; ws_login_pwd=${that.password}; shiro.session=65500189-7bb5-457f-9ff6-0db069150e78`))
  266. // // pc登录
  267. // that.$request.baseRequest('post', '/commonUser/api/loginQuickly', {
  268. // mobilePhone: this.phone,
  269. // veriCode: "123456",
  270. // }).then(res1 => {
  271. // if (res1.code == 200) {
  272. // uni.setStorageSync('pcUserInfo', res1.data)
  273. // helper.getListByUserId()
  274. // } else {
  275. // that.$api.doRequest('post',
  276. // '/commonUser/api/loginQuickly', {
  277. // mobilePhone: '14444444444',
  278. // veriCode: "123456",
  279. // }).then(res2 => {
  280. // uni.setStorageSync('pcUserInfo', res2
  281. // .data)
  282. // helper.getListByUserId()
  283. // })
  284. // }
  285. // })
  286. uni.setStorageSync('userInfo', res.data)
  287. that.$store.commit('login', res.data)
  288. uni.switchTab({
  289. url: '/pages/goodSource/index'
  290. });
  291. } else {
  292. uni.showToast({
  293. title: res.message,
  294. icon: 'none',
  295. duration: 2000
  296. })
  297. }
  298. uni.hideLoading()
  299. })
  300. .catch(res => {
  301. console.log(res);
  302. });
  303. }
  304. })
  305. .catch(res => {
  306. console.log(res);
  307. });
  308. },
  309. consent() {
  310. this.consentStatus = !this.consentStatus
  311. uni.setStorage({
  312. key: 'policyStorageKey',
  313. data: this.consentStatus
  314. });
  315. },
  316. switchover() {
  317. if (this.type == 'password') {
  318. this.type = 'text'
  319. } else {
  320. this.type = 'password'
  321. }
  322. },
  323. ...mapMutations(['login']),
  324. navBack() {
  325. uni.navigateBack();
  326. },
  327. },
  328. }
  329. </script>
  330. <style lang='scss' scoped>
  331. uni-navigator {
  332. display: inline-block;
  333. color: #2772FB;
  334. }
  335. .password {
  336. border: none;
  337. outline: none;
  338. }
  339. .apple {
  340. background: #000;
  341. width: 35px;
  342. height: 35px;
  343. padding: 8px;
  344. border-radius: 50%;
  345. vertical-align: middle;
  346. }
  347. page {
  348. background: #fff;
  349. }
  350. .cuIcon-weixin {
  351. background: #2772FB;
  352. color: #fff;
  353. font-size: 18px;
  354. padding: 9px;
  355. border-radius: 50%;
  356. vertical-align: middle;
  357. margin-right: 5px;
  358. }
  359. .container {
  360. padding-top: 85px;
  361. position: relative;
  362. width: 100vw;
  363. height: calc(100vh - 85px);
  364. overflow: hidden;
  365. background: url('~@/static/images/mine/bg@2x.png');
  366. background-size: 100%;
  367. }
  368. .close {
  369. width: 20px;
  370. height: 20px;
  371. position: absolute;
  372. right: 0px;
  373. }
  374. .close1 {
  375. width: 20px;
  376. height: 20px;
  377. position: absolute;
  378. right: 10px;
  379. top: 0;
  380. }
  381. .close2 {
  382. width: 15px;
  383. height: 15px;
  384. position: absolute;
  385. right: 19px;
  386. top: 50%;
  387. transform: translateY(-45%);
  388. }
  389. .wrapper {
  390. position: relative;
  391. z-index: 90;
  392. padding-bottom: 40upx;
  393. height: 100%;
  394. padding: 0 30px;
  395. }
  396. .back-btn {
  397. position: absolute;
  398. left: 40upx;
  399. z-index: 9999;
  400. padding-top: var(--status-bar-height);
  401. top: 40upx;
  402. font-size: 40upx;
  403. color: black;
  404. }
  405. .verificationCode {
  406. margin-top: 20px;
  407. background: #F5F6F9;
  408. color: #AFB3BF;
  409. }
  410. .verificationCode:after {
  411. border: none;
  412. }
  413. .register {
  414. position: absolute;
  415. bottom: 20px;
  416. left: 50%;
  417. transform: translateX(-50%);
  418. color: #333333;
  419. height: 50px;
  420. line-height: 50px;
  421. border-radius: 30px;
  422. border: 1px solid #444444;
  423. }
  424. .register:after {
  425. border: none;
  426. }
  427. .verificationCode.active {
  428. background: #2772FB;
  429. color: #fff;
  430. }
  431. .getcode {
  432. font-size: 14px;
  433. position: absolute;
  434. right: 0;
  435. top: 50%;
  436. transform: translateY(-50%);
  437. color: #AFB3BF;
  438. background: #F5F6F9;
  439. height: 30px;
  440. line-height: 30px;
  441. }
  442. .getcode:after {
  443. border: none;
  444. }
  445. uni-navigator {
  446. display: inline-block;
  447. color: #2772FB;
  448. }
  449. .getcode.active {
  450. background: #2772FB;
  451. color: #fff;
  452. }
  453. .NumberMedium {
  454. display: flex;
  455. align-items: center;
  456. }
  457. .flex {
  458. align-items: center;
  459. }
  460. </style>